236. 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.

236.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 AddProductstoBundle.cs Tue Dec 20 19:51:44 2016 UTC
2 Wed Feb 1 19:56:27 2017 UTC

236.2 Comparison summary

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

236.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

236.4 Active regular expressions

No regular expressions were active.

236.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 AddProduct stoBundle>        
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 add pro ducts to a  bundle.        
38       /// </ summary>        
39       public  class Add Productsto Bundle        
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  _product1I d;        
51           pu blic Guid  _product2I d;        
52           pu blic Guid  _bundleId;        
53           pu blic Guid  _priceList Id;        
54           pu blic Guid  _priceList Item1Id;        
55           pu blic Guid  _priceList Item2Id;        
56           pu blic Guid  _priceList Item3Id;        
57           pu blic Guid  _product1A ssociation Id;        
58           pu blic Guid  _product2A ssociation Id;        
59          
60           pu blic UoM u nit;        
61                   
62           #e ndregion C lass Level  Members        
63          
64           #r egion How  To Sample  Code        
65           // / <summary >        
66           // / Create a nd configu re the org anization  service pr oxy.        
67           // / Initiate  creating  all entity  records t hat this s ample requ ires.        
68           // / Create a  bundle re cord.        
69           // / Add prod ucts to a  bundle.         
70           // / Optional ly delete  any entity  records t hat were c reated for  this samp le.        
71           // / </summar y>        
72           // / <param n ame="serve rConfig">C ontains se rver conne ction info rmation.</ param>        
73           // / <param n ame="promp tforDelete ">When Tru e, the use r will be  prompted t o delete a ll        
74           // / created  entities.< /param>        
75           pu blic void  Run(Server Connection .Configura tion serve rConfig, b ool prompt ForDelete)        
76           {        
77                try        
78                {        
79                    // C onnect to  the Organi zation ser vice.         
80                    // T he using s tatement a ssures tha t the serv ice proxy  will be pr operly dis posed.        
81                    usin g (_servic eProxy = S erverConne ction.GetO rganizatio nProxy(ser verConfig) )        
82                    {        
83                         // This st atement is  required  to enable  early-boun d type sup port.        
84                         _servicePr oxy.Enable ProxyTypes ();        
85          
86                         // Call th e method t o create a ny data th at this sa mple requi res.        
87                         CreateRequ iredRecord s();        
88          
89                         //<snippet AddProduct stoBundle1 >        
90                         // Add pro ducts to a  bundle        
91                         ProductAss ociation n ewAssociat ion1 = new  ProductAs sociation        
92                         {        
93                             Associ atedProduc t = new En tityRefere nce(Produc t.EntityLo gicalName,  _product1 Id),        
94                             Produc tId = new  EntityRefe rence(Prod uct.Entity LogicalNam e, _bundle Id),        
95                             Quanti ty = new d ecimal(15) ,        
96                             Produc tIsRequire d = new Op tionSetVal ue(0), //  Adding thi s as an op tional pro duct        
97                             UoMId  = new Enti tyReferenc e(UoM.Enti tyLogicalN ame, unit. Id)        
98                         };        
99                         _product1A ssociation Id = _serv iceProxy.C reate(newA ssociation 1);                              
100                                
101                         ProductAss ociation n ewAssociat ion2 = new  ProductAs sociation        
102                         {        
103                             Associ atedProduc t = new En tityRefere nce(Produc t.EntityLo gicalName,  _product2 Id),        
104                             Produc tId = new  EntityRefe rence(Prod uct.Entity LogicalNam e, _bundle Id),        
105                             Quanti ty = new d ecimal(20) ,        
106                             Produc tIsRequire d = new Op tionSetVal ue(1), //  Adding thi s as a man datory pro duct        
107                             UoMId  = new Enti tyReferenc e(UoM.Enti tyLogicalN ame, unit. Id),                                  
108                         };        
109                         _product2A ssociation Id = _serv iceProxy.C reate(newA ssociation 2);        
110          
111                         // Verify  if the pro duct assoc iation is  created        
112                         if ((_prod uct1Associ ationId !=  null) &&  (_product1 Associatio nId != nul l))        
113                         {        
114                             Consol e.WriteLin e("\nAdded  both the  products t o the bund le");        
115                         }                                  
116                                
117                         //</snippe tAddProduc tstoBundle 1>                             
118          
119                         DeleteRequ iredRecord s(promptFo rDelete);        
120                    }        
121                }        
122                catch        
123                {        
124                    // Y ou can han dle an exc eption her e or pass  it back to  the calli ng method.        
125                    thro w;        
126                }        
127           }        
128          
129           // / <summary >        
130           // / This met hod create s any enti ty records  that this  sample re quires.        
131           // / Create a  unit grou p and pric e list.        
132           // / </summar y>        
133           pu blic void  CreateRequ iredRecord s()        
134           {        
135                Console. WriteLine( "Creating  required r ecords for  the sampl e:");        
136                // Creat e a unit g roup.        
137                UoMSched ule newUni tGroup = n ew UoMSche dule        
138                {        
139                    Name  = "Exampl e Unit Gro up",        
140                    Base UoMName =  "Example P rimary Uni t"        
141                };        
142          
143                _unitGro upId = _se rviceProxy .Create(ne wUnitGroup );        
144          
145                Console. WriteLine( "Created { 0}", newUn itGroup.Na me);        
146          
147                // retri eve the un it id.        
148                QueryExp ression un itQuery =  new QueryE xpression        
149                {        
150                    Enti tyName = U oM.EntityL ogicalName ,        
151                    Colu mnSet = ne w ColumnSe t("uomid",  "name"),        
152                    Crit eria = new  FilterExp ression(),        
153                    Page Info = new  PagingInf o        
154                    {        
155                         PageNumber  = 1,        
156                         Count = 1        
157                    }        
158                };        
159                unitQuer y.Criteria .AddCondit ion("uomsc heduleid",  Condition Operator.E qual, _uni tGroupId);        
160          
161                // Retri eve the un it.        
162                 unit =  (UoM)_serv iceProxy.R etrieveMul tiple(unit Query).Ent ities[0];        
163          
164                Console. WriteLine( "Retrieved  {0}", uni t.Name);        
165          
166          
167                // Creat e a price  list        
168                PriceLev el newPric eList = ne w PriceLev el        
169                {        
170                    Name  = "Exampl e Price Li st"        
171                };        
172                _priceLi stId = _se rviceProxy .Create(ne wPriceList );        
173          
174                Console. WriteLine( "Created { 0}", newPr iceList.Na me);        
175          
176                // Creat e couple o f product  records        
177                Product  newProduct 1 = new Pr oduct        
178                {        
179                    Name  = "Exampl e Product  1",        
180                    Prod uctNumber  = "P001",        
181                    Prod uctStructu re = new O ptionSetVa lue(1),                          
182                    Quan tityDecima l = 2,        
183                    Defa ultUoMSche duleId = n ew EntityR eference(U oMSchedule .EntityLog icalName,  _unitGroup Id),        
184                    Defa ultUoMId =  new Entit yReference (UoM.Entit yLogicalNa me, unit.I d)        
185                };        
186                _product 1Id = _ser viceProxy. Create(new Product1);        
187          
188                Console. WriteLine( "\nCreated  {0}", new Product1.N ame);        
189          
190                Product  newProduct 2 = new Pr oduct        
191                {        
192                    Name  = "Exampl e Product  2",        
193                    Prod uctNumber  = "P002",        
194                    Prod uctStructu re = new O ptionSetVa lue(1),                          
195                    Quan tityDecima l = 2,        
196                    Defa ultUoMSche duleId = n ew EntityR eference(U oMSchedule .EntityLog icalName,  _unitGroup Id),        
197                    Defa ultUoMId =  new Entit yReference (UoM.Entit yLogicalNa me, unit.I d)        
198                };        
199                _product 2Id = _ser viceProxy. Create(new Product2);        
200          
201                Console. WriteLine( "Created { 0}", newPr oduct2.Nam e);        
202          
203                // Creat e price li st items f or the pro ducts        
204                ProductP riceLevel  newPriceLi stItem1 =  new Produc tPriceLeve l        
205                {        
206                    Pric eLevelId =  new Entit yReference (PriceLeve l.EntityLo gicalName,  _priceLis tId),        
207                    Prod uctId = ne w EntityRe ference(Pr oduct.Enti tyLogicalN ame, _prod uct1Id),        
208                    UoMI d = new En tityRefere nce(UoM.En tityLogica lName, uni t.Id),        
209                    Amou nt = new M oney(20)        
210                };        
211                _priceLi stItem1Id  = _service Proxy.Crea te(newPric eListItem1 );        
212                Console. WriteLine( "Created p rice list  for {0}",  newProduct 1.Name);        
213          
214                ProductP riceLevel  newPriceLi stItem2 =  new Produc tPriceLeve l        
215                {        
216                    Pric eLevelId =  new Entit yReference (PriceLeve l.EntityLo gicalName,  _priceLis tId),        
217                    Prod uctId = ne w EntityRe ference(Pr oduct.Enti tyLogicalN ame, _prod uct2Id),        
218                    UoMI d = new En tityRefere nce(UoM.En tityLogica lName, uni t.Id),        
219                    Amou nt = new M oney(20)        
220                };        
221                _priceLi stItem2Id  = _service Proxy.Crea te(newPric eListItem2 );        
222                Console. WriteLine( "Created p rice list  for {0}",  newProduct 2.Name);        
223          
224                Product  newBundle  = new Prod uct        
225                {        
226                    Name  = "Exampl e Bundle",        
227                    Prod uctNumber  = "B001",        
228                    Prod uctStructu re = new O ptionSetVa lue(3),        
229                    Quan tityDecima l = 0,        
230                    Defa ultUoMSche duleId = n ew EntityR eference(U oMSchedule .EntityLog icalName,  _unitGroup Id),        
231                    Defa ultUoMId =  new Entit yReference (UoM.Entit yLogicalNa me, unit.I d)        
232                };        
233                _bundleI d = _servi ceProxy.Cr eate(newBu ndle);        
234                Console. WriteLine( "\nCreated  {0}", new Bundle.Nam e);        
235          
236                // Creat e price li st item fo r the bund le        
237                ProductP riceLevel  newPriceLi stItem3 =  new Produc tPriceLeve l        
238                {        
239                    Pric eLevelId =  new Entit yReference (PriceLeve l.EntityLo gicalName,  _priceLis tId),        
240                    Prod uctId = ne w EntityRe ference(Pr oduct.Enti tyLogicalN ame, _bund leId),        
241                    UoMI d = new En tityRefere nce(UoM.En tityLogica lName, uni t.Id),        
242                    Amou nt = new M oney(200)        
243                };        
244                _priceLi stItem3Id  = _service Proxy.Crea te(newPric eListItem3 );        
245                Console. WriteLine( "Created p rice list  for {0}",  newBundle. Name);        
246                return;        
247           }        
248          
249           // / <summary >        
250           // / Deletes  any entity  records t hat were c reated for  this samp le.        
251           // / <param n ame="promp t">Indicat es whether  to prompt  the user  to delete  the record s created  in this sa mple.</par am>        
252           // / </summar y>        
253           pu blic void  DeleteRequ iredRecord s(bool pro mpt)        
254           {        
255                bool del eteRecords  = true;        
256          
257                if (prom pt)        
258                {        
259                    Cons ole.WriteL ine("\nDo  you want t hese entit y records  deleted? ( y/n)");        
260                    Stri ng answer  = Console. ReadLine() ;        
261                    dele teRecords  = (answer. StartsWith ("y") || a nswer.Star tsWith("Y" ));        
262                }        
263          
264                if (dele teRecords)        
265                {        
266                    Cons ole.WriteL ine("Delet ing entity  records.. . please w ait!");        
267          
268                    _ser viceProxy. Delete(Pro ductAssoci ation.Enti tyLogicalN ame, _prod uct1Associ ationId);        
269                    _ser viceProxy. Delete(Pro ductAssoci ation.Enti tyLogicalN ame, _prod uct2Associ ationId);        
270                    _ser viceProxy. Delete(Pro ductPriceL evel.Entit yLogicalNa me, _price ListItem1I d);        
271                    _ser viceProxy. Delete(Pro ductPriceL evel.Entit yLogicalNa me, _price ListItem2I d);        
272                    _ser viceProxy. Delete(Pro ductPriceL evel.Entit yLogicalNa me, _price ListItem3I d);        
273                    _ser viceProxy. Delete(Pro duct.Entit yLogicalNa me, _bundl eId);        
274                    _ser viceProxy. Delete(Pro duct.Entit yLogicalNa me, _produ ct1Id);        
275                    _ser viceProxy. Delete(Pro duct.Entit yLogicalNa me, _produ ct2Id);                          
276                    _ser viceProxy. Delete(Pri ceLevel.En tityLogica lName, _pr iceListId) ;        
277                    _ser viceProxy. Delete(UoM Schedule.E ntityLogic alName, _u nitGroupId );        
278          
279                    Cons ole.WriteL ine("Entit y records  have been  deleted.") ;        
280                }        
281           }        
282           #e ndregion H ow To Samp le Code        
283          
284           #r egion Main        
285           // / <summary >        
286           // / Standard  Main() me thod used  by most SD K samples.        
287           // / </summar y>        
288           // / <param n ame="args" ></param>        
289           st atic publi c void Mai n(string[]  args)        
290           {        
291                try        
292                {        
293                    // O btain the  target org anization' s Web addr ess and cl ient logon          
294                    // c redentials  from the  user.        
295                    Serv erConnecti on serverC onnect = n ew ServerC onnection( );        
296                    Serv erConnecti on.Configu ration con fig = serv erConnect. GetServerC onfigurati on();        
297          
298                    AddP roductstoB undle app  = new AddP roductstoB undle();        
299                    app. Run(config , true);        
300                }        
301          
302                catch (F aultExcept ion<Micros oft.Xrm.Sd k.Organiza tionServic eFault> ex )        
303                {        
304                    Cons ole.WriteL ine("The a pplication  terminate d with an  error.");        
305                    Cons ole.WriteL ine("Times tamp: {0}" , ex.Detai l.Timestam p);        
306                    Cons ole.WriteL ine("Code:  {0}", ex. Detail.Err orCode);        
307                    Cons ole.WriteL ine("Messa ge: {0}",  ex.Detail. Message);        
308                    Cons ole.WriteL ine("Plugi n Trace: { 0}", ex.De tail.Trace Text);        
309                    Cons ole.WriteL ine("Inner  Fault: {0 }",        
310                         null == ex .Detail.In nerFault ?  "No Inner  Fault" :  "Has Inner  Fault");        
311                }        
312                catch (S ystem.Time outExcepti on ex)        
313                {        
314                    Cons ole.WriteL ine("The a pplication  terminate d with an  error.");        
315                    Cons ole.WriteL ine("Messa ge: {0}",  ex.Message );        
316                    Cons ole.WriteL ine("Stack  Trace: {0 }", ex.Sta ckTrace);        
317                    Cons ole.WriteL ine("Inner  Fault: {0 }",        
318                         null == ex .InnerExce ption.Mess age ? "No  Inner Faul t" : ex.In nerExcepti on.Message );        
319                }        
320                catch (S ystem.Exce ption ex)        
321                {        
322                    Cons ole.WriteL ine("The a pplication  terminate d with an  error.");        
323                    Cons ole.WriteL ine(ex.Mes sage);        
324          
325                    // D isplay the  details o f the inne r exceptio n.        
326                    if ( ex.InnerEx ception !=  null)        
327                    {        
328                         Console.Wr iteLine(ex .InnerExce ption.Mess age);        
329          
330                         FaultExcep tion<Micro soft.Xrm.S dk.Organiz ationServi ceFault> f e = ex.Inn erExceptio n        
331                             as Fau ltExceptio n<Microsof t.Xrm.Sdk. Organizati onServiceF ault>;        
332                         if (fe !=  null)        
333                         {        
334                             Consol e.WriteLin e("Timesta mp: {0}",  fe.Detail. Timestamp) ;        
335                             Consol e.WriteLin e("Code: { 0}", fe.De tail.Error Code);        
336                             Consol e.WriteLin e("Message : {0}", fe .Detail.Me ssage);        
337                             Consol e.WriteLin e("Plugin  Trace: {0} ", fe.Deta il.TraceTe xt);        
338                             Consol e.WriteLin e("Inner F ault: {0}" ,        
339                                 nu ll == fe.D etail.Inne rFault ? " No Inner F ault" : "H as Inner F ault");        
340                         }        
341                    }        
342                }        
343                // Addit ional exce ptions to  catch: Sec urityToken Validation Exception,  ExpiredSe curityToke nException ,        
344                // Secur ityAccessD eniedExcep tion, Mess ageSecurit yException , and Secu rityNegoti ationExcep tion.        
345          
346                finally        
347                {        
348                    Cons ole.WriteL ine("Press  <Enter> t o exit.");        
349                    Cons ole.ReadLi ne();        
350                }        
351           }        
352           #e ndregion M ain        
353       }        
354   }        
355   //</snippe tAddProduc tstoBundle >