238. Araxis Merge File Comparison Report

Produced by Araxis Merge on 2/1/2017 2:56:27 PM Eastern Standard Time. See www.araxis.com for information about Merge. This report uses XHTML and CSS2, and is best viewed with a modern standards-compliant browser. For optimum results when printing this report, use landscape orientation and enable printing of background images and colours in your browser.

238.1 Files compared

# Location File Last Modified
1 C:\Araxis_Merge_Comprasion\Pub_un\BTSSS_CIF_122016.zip\BTSSS_CIF_12_20_16\clean\CRM\trunk\SDK\SampleCode\CS\BusinessDataModel\ProductCatalog CloneProducts.cs Tue Dec 20 19:51:44 2016 UTC
2 Wed Feb 1 19:56:27 2017 UTC

238.2 Comparison summary

Description Between
Files 1 and 2
Text Blocks Lines
Unchanged 0 0
Changed 0 0
Inserted 0 0
Removed 1 285

238.3 Comparison options

Whitespace
Character case Differences in character case are significant
Line endings Differences in line endings (CR and LF characters) are ignored
CR/LF characters Not shown in the comparison detail

238.4 Active regular expressions

No regular expressions were active.

238.5 Comparison detail

1   // ======= ========== ========== ========== ========== ========== ========== ==        
2   //        
3   //  This f ile is par t of the M icrosoft D ynamics CR M SDK code  samples.        
4   //        
5   //  Copyri ght (C) Mi crosoft Co rporation.   All righ ts reserve d.        
6   //        
7   //  This s ource code  is intend ed only as  a supplem ent to Mic rosoft        
8   //  Develo pment Tool s and/or o n-line doc umentation .  See the se other        
9   //  materi als for de tailed inf ormation r egarding M icrosoft c ode sample s.        
10   //        
11   //  THIS C ODE AND IN FORMATION  ARE PROVID ED "AS IS"  WITHOUT W ARRANTY OF  ANY        
12   //  KIND,  EITHER EXP RESSED OR  IMPLIED, I NCLUDING B UT NOT LIM ITED TO TH E        
13   //  IMPLIE D WARRANTI ES OF MERC HANTABILIT Y AND/OR F ITNESS FOR  A        
14   //  PARTIC ULAR PURPO SE.        
15   //        
16   // ======= ========== ========== ========== ========== ========== ========== ==        
17          
18   //<snippet CloneProdu cts>        
19   using Syst em;        
20   using Syst em.Service Model;        
21   using Syst em.Service Model.Desc ription;        
22          
23   // These n amespaces  are found  in the Mic rosoft.Xrm .Sdk.dll a ssembly        
24   // found i n the SDK\ bin folder .        
25   using Micr osoft.Xrm. Sdk;        
26   using Micr osoft.Xrm. Sdk.Client ;        
27   using Micr osoft.Xrm. Sdk.Query;        
28   using Micr osoft.Xrm. Sdk.Discov ery;        
29          
30   // This na mespace is  found in  Microsoft. Crm.Sdk.Pr oxy.dll as sembly        
31   // found i n the SDK\ bin folder .        
32   using Micr osoft.Crm. Sdk.Messag es;        
33          
34   namespace  Microsoft. Crm.Sdk.Sa mples        
35   {        
36       /// <s ummary>        
37       /// Th is sample  shows how  to clone a  product r ecord.        
38       /// </ summary>        
39       public  class Clo neProducts        
40       {        
41           #r egion Clas s Level Me mbers        
42          
43           // / <summary >        
44           // / Stores t he organiz ation serv ice proxy.        
45           // / </summar y>        
46           pr ivate Orga nizationSe rviceProxy  _serviceP roxy;        
47          
48           //  Define th e IDs need ed for thi s sample.        
49           pu blic Guid  _unitGroup Id;        
50           pu blic Guid  _productId ;        
51           pu blic Guid  _productCl oneId;                 
52           pu blic Guid  _priceList Id;        
53           pu blic Guid  _priceList ItemId;        
54          
55           #e ndregion C lass Level  Members        
56          
57           #r egion How  To Sample  Code        
58           // / <summary >        
59           // / Create a nd configu re the org anization  service pr oxy.        
60           // / Initiate  creating  all entity  records t hat this s ample requ ires.        
61           // / Create a  product r ecord.        
62           // / Clone th e product  record.        
63           // / Optional ly delete  any entity  records t hat were c reated for  this samp le.        
64           // / </summar y>        
65           // / <param n ame="serve rConfig">C ontains se rver conne ction info rmation.</ param>        
66           // / <param n ame="promp tforDelete ">When Tru e, the use r will be  prompted t o delete a ll        
67           // / created  entities.< /param>        
68           pu blic void  Run(Server Connection .Configura tion serve rConfig, b ool prompt ForDelete)        
69           {        
70                try        
71                {        
72                    // C onnect to  the Organi zation ser vice.         
73                    // T he using s tatement a ssures tha t the serv ice proxy  will be pr operly dis posed.        
74                    usin g (_servic eProxy = S erverConne ction.GetO rganizatio nProxy(ser verConfig) )        
75                    {        
76                         // This st atement is  required  to enable  early-boun d type sup port.        
77                         _servicePr oxy.Enable ProxyTypes ();        
78          
79                         // Call th e method t o create a ny data th at this sa mple requi res.        
80                         CreateRequ iredRecord s();        
81          
82                         //<snippet CloneProdu cts1>                              
83          
84                         CloneProdu ctRequest  cloneReq =  new Clone ProductReq uest        
85                         {        
86                             Source  = new Ent ityReferen ce(Product .EntityLog icalName,  _productId )        
87                         };        
88                                
89                         CloneProdu ctResponse  cloned =  (CloneProd uctRespons e)_service Proxy.Exec ute(cloneR eq);                                                 
90                         _productCl oneId = cl oned.Clone dProduct.I d;        
91                               
92                         // Retriev e the clon ed product  record        
93                         Product re trievedPro duct = (Pr oduct)_ser viceProxy. Retrieve(P roduct.Ent ityLogical Name, _pro ductCloneI d, new Col umnSet(tru e));        
94                         Console.Wr iteLine("\ nCreated c lone produ ct: {0}",  retrievedP roduct.Nam e);        
95                                
96                         //</snippe tCloneProd ucts1>        
97          
98                         DeleteRequ iredRecord s(promptFo rDelete);        
99                    }        
100                }        
101                catch        
102                {        
103                    // Y ou can han dle an exc eption her e or pass  it back to  the calli ng method.        
104                    thro w;        
105                }        
106           }        
107          
108           // / <summary >        
109           // / This met hod create s any enti ty records  that this  sample re quires.        
110           // / Create a  unit grou p and pric e list.        
111           // / </summar y>        
112           pu blic void  CreateRequ iredRecord s()        
113           {        
114                Console. WriteLine( "Creating  required r ecords for  the sampl e:");        
115                // Creat e a unit g roup.        
116                UoMSched ule newUni tGroup = n ew UoMSche dule        
117                {        
118                    Name  = "Exampl e Unit Gro up",        
119                    Base UoMName =  "Example P rimary Uni t"        
120                };        
121          
122                _unitGro upId = _se rviceProxy .Create(ne wUnitGroup );        
123          
124                Console. WriteLine( "Created { 0}", newUn itGroup.Na me);        
125          
126                // retri eve the un it id.        
127                QueryExp ression un itQuery =  new QueryE xpression        
128                {        
129                    Enti tyName = U oM.EntityL ogicalName ,        
130                    Colu mnSet = ne w ColumnSe t("uomid",  "name"),        
131                    Crit eria = new  FilterExp ression(),        
132                    Page Info = new  PagingInf o        
133                    {        
134                         PageNumber  = 1,        
135                         Count = 1        
136                    }        
137                };        
138                unitQuer y.Criteria .AddCondit ion("uomsc heduleid",  Condition Operator.E qual, _uni tGroupId);        
139          
140                // Retri eve the un it.        
141                UoM unit  = (UoM)_s erviceProx y.Retrieve Multiple(u nitQuery). Entities[0 ];        
142          
143                Console. WriteLine( "Retrieved  {0}", uni t.Name);        
144          
145          
146                // Creat e a price  list        
147                PriceLev el newPric eList = ne w PriceLev el        
148                {        
149                    Name  = "Exampl e Price Li st"        
150                };        
151                _priceLi stId = _se rviceProxy .Create(ne wPriceList );        
152          
153                Console. WriteLine( "Created { 0}", newPr iceList.Na me);        
154          
155                // Creat e a produc t record t o be clone d.        
156                Product  newProduct  = new Pro duct        
157                {        
158                    Name  = "Exampl e Product" ,        
159                    Prod uctNumber  = "P001",        
160                    Prod uctStructu re = new O ptionSetVa lue(1),                          
161                    Quan tityDecima l = 2,        
162                    Defa ultUoMSche duleId = n ew EntityR eference(U oMSchedule .EntityLog icalName,  _unitGroup Id),        
163                    Defa ultUoMId =  new Entit yReference (UoM.Entit yLogicalNa me, unit.I d)        
164                };        
165                _product Id = _serv iceProxy.C reate(newP roduct);        
166          
167                Console. WriteLine( "\nCreated  {0}", new Product.Na me);        
168          
169                // Creat e a price  list item  for the pr oduct        
170                ProductP riceLevel  newPriceLi stItem = n ew Product PriceLevel        
171                {        
172                    Pric eLevelId =  new Entit yReference (PriceLeve l.EntityLo gicalName,  _priceLis tId),        
173                    Prod uctId = ne w EntityRe ference(Pr oduct.Enti tyLogicalN ame, _prod uctId),        
174                    UoMI d = new En tityRefere nce(UoM.En tityLogica lName, uni t.Id),        
175                    Amou nt = new M oney(20)        
176                };        
177                _priceLi stItemId =  _serviceP roxy.Creat e(newPrice ListItem);        
178          
179                Console. WriteLine( "Created p rice list  for {0}",  newProduct .Name);        
180          
181                return;        
182           }        
183          
184           // / <summary >        
185           // / Deletes  any entity  records t hat were c reated for  this samp le.        
186           // / <param n ame="promp t">Indicat es whether  to prompt  the user  to delete  the record s created  in this sa mple.</par am>        
187           // / </summar y>        
188           pu blic void  DeleteRequ iredRecord s(bool pro mpt)        
189           {        
190                bool del eteRecords  = true;        
191          
192                if (prom pt)        
193                {        
194                    Cons ole.WriteL ine("\nDo  you want t hese entit y records  deleted? ( y/n)");        
195                    Stri ng answer  = Console. ReadLine() ;        
196                    dele teRecords  = (answer. StartsWith ("y") || a nswer.Star tsWith("Y" ));        
197                }        
198          
199                if (dele teRecords)        
200                {        
201                    Cons ole.WriteL ine("Delet ing entity  records.. . please w ait!");        
202          
203                    _ser viceProxy. Delete(Pro duct.Entit yLogicalNa me, _produ ctCloneId) ;        
204                    _ser viceProxy. Delete(Pro ductPriceL evel.Entit yLogicalNa me, _price ListItemId );                        
205                    _ser viceProxy. Delete(Pro duct.Entit yLogicalNa me, _produ ctId);        
206                    _ser viceProxy. Delete(Pri ceLevel.En tityLogica lName, _pr iceListId) ;        
207                    _ser viceProxy. Delete(UoM Schedule.E ntityLogic alName, _u nitGroupId );        
208          
209                    Cons ole.WriteL ine("Entit y records  have been  deleted.") ;        
210                }        
211           }        
212           #e ndregion H ow To Samp le Code        
213          
214           #r egion Main        
215           // / <summary >        
216           // / Standard  Main() me thod used  by most SD K samples.        
217           // / </summar y>        
218           // / <param n ame="args" ></param>        
219           st atic publi c void Mai n(string[]  args)        
220           {        
221                try        
222                {        
223                    // O btain the  target org anization' s Web addr ess and cl ient logon          
224                    // c redentials  from the  user.        
225                    Serv erConnecti on serverC onnect = n ew ServerC onnection( );        
226                    Serv erConnecti on.Configu ration con fig = serv erConnect. GetServerC onfigurati on();        
227          
228                    Clon eProducts  app = new  CloneProdu cts();        
229                    app. Run(config , true);        
230                }        
231          
232                catch (F aultExcept ion<Micros oft.Xrm.Sd k.Organiza tionServic eFault> ex )        
233                {        
234                    Cons ole.WriteL ine("The a pplication  terminate d with an  error.");        
235                    Cons ole.WriteL ine("Times tamp: {0}" , ex.Detai l.Timestam p);        
236                    Cons ole.WriteL ine("Code:  {0}", ex. Detail.Err orCode);        
237                    Cons ole.WriteL ine("Messa ge: {0}",  ex.Detail. Message);        
238                    Cons ole.WriteL ine("Plugi n Trace: { 0}", ex.De tail.Trace Text);        
239                    Cons ole.WriteL ine("Inner  Fault: {0 }",        
240                         null == ex .Detail.In nerFault ?  "No Inner  Fault" :  "Has Inner  Fault");        
241                }        
242                catch (S ystem.Time outExcepti on ex)        
243                {        
244                    Cons ole.WriteL ine("The a pplication  terminate d with an  error.");        
245                    Cons ole.WriteL ine("Messa ge: {0}",  ex.Message );        
246                    Cons ole.WriteL ine("Stack  Trace: {0 }", ex.Sta ckTrace);        
247                    Cons ole.WriteL ine("Inner  Fault: {0 }",        
248                         null == ex .InnerExce ption.Mess age ? "No  Inner Faul t" : ex.In nerExcepti on.Message );        
249                }        
250                catch (S ystem.Exce ption ex)        
251                {        
252                    Cons ole.WriteL ine("The a pplication  terminate d with an  error.");        
253                    Cons ole.WriteL ine(ex.Mes sage);        
254          
255                    // D isplay the  details o f the inne r exceptio n.        
256                    if ( ex.InnerEx ception !=  null)        
257                    {        
258                         Console.Wr iteLine(ex .InnerExce ption.Mess age);        
259          
260                         FaultExcep tion<Micro soft.Xrm.S dk.Organiz ationServi ceFault> f e = ex.Inn erExceptio n        
261                             as Fau ltExceptio n<Microsof t.Xrm.Sdk. Organizati onServiceF ault>;        
262                         if (fe !=  null)        
263                         {        
264                             Consol e.WriteLin e("Timesta mp: {0}",  fe.Detail. Timestamp) ;        
265                             Consol e.WriteLin e("Code: { 0}", fe.De tail.Error Code);        
266                             Consol e.WriteLin e("Message : {0}", fe .Detail.Me ssage);        
267                             Consol e.WriteLin e("Plugin  Trace: {0} ", fe.Deta il.TraceTe xt);        
268                             Consol e.WriteLin e("Inner F ault: {0}" ,        
269                                 nu ll == fe.D etail.Inne rFault ? " No Inner F ault" : "H as Inner F ault");        
270                         }        
271                    }        
272                }        
273                // Addit ional exce ptions to  catch: Sec urityToken Validation Exception,  ExpiredSe curityToke nException ,        
274                // Secur ityAccessD eniedExcep tion, Mess ageSecurit yException , and Secu rityNegoti ationExcep tion.        
275          
276                finally        
277                {        
278                    Cons ole.WriteL ine("Press  <Enter> t o exit.");        
279                    Cons ole.ReadLi ne();        
280                }        
281           }        
282           #e ndregion M ain        
283       }        
284   }        
285   //</snippe tCloneProd ucts>