205. Araxis Merge File Comparison Report

Produced by Araxis Merge on 2/1/2017 2:56:24 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.

205.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\BusinessManagement RetrieveOpportunity.cs Tue Dec 20 19:51:44 2016 UTC
2 Wed Feb 1 19:56:24 2017 UTC

205.2 Comparison summary

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

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

205.4 Active regular expressions

No regular expressions were active.

205.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 RetrieveOp portunity>        
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           // / <summary >        
37       /// Th is Sample  shows how  to retriev e an oppor tunity wit        
38       /// re lated oppo rtunity pr oducts.        
39           // / </summar y>        
40           pu blic class  RetrieveO pportunity        
41           {             
42           #r egion Clas s Level Me mbers        
43                  
44           // / <summary >        
45           // / Stores t he organiz ation serv ice proxy.        
46           // / </summar y>        
47           Or ganization ServicePro xy _servic eProxy;        
48          
49           //  Define th e IDs need ed for thi s sample.        
50           pu blic Guid  _unitGroup Id;        
51           pu blic Guid  _defaultUn itId;        
52           pu blic Guid  _product1I d;        
53           pu blic Guid  _product2I d;        
54           pu blic Guid  _discountT ypeId;        
55           pu blic Guid  _discountI d;        
56           pu blic Guid  _priceList Id;        
57           pu blic Guid  _priceList Item1Id;        
58           pu blic Guid  _priceList Item2Id;        
59           pu blic Guid  _accountId ;        
60           pu blic Guid  _opportuni tyId;        
61           pu blic Guid  _opportuni tyProduct1 Id;        
62           pu blic Guid  _opportuni tyProduct2 Id;        
63                   
64           #e ndregion C lass Level  Members        
65          
66           #r egion How  To Sample  Code        
67           // / <summary >        
68           // / Create a nd configu re the org anization  service pr oxy.        
69           // / Initiate  method to  create an y data tha t this sam ple requir es.        
70           // / Retrieve  opportuni ty and opp ortunity p roducts.        
71           // / Optional ly delete  any entity  records t hat were c reated for  this samp le.        
72           // / </summar y>        
73           // / <param n ame="serve rConfig">C ontains se rver conne ction info rmation.</ param>        
74           // / <param n ame="promp tforDelete ">When Tru e, the use r will be  prompted t o delete a ll        
75           // / created  entities.< /param>        
76           pu blic void  Run(Server Connection .Configura tion serve rConfig, b ool prompt ForDelete)        
77           {        
78                try        
79                {        
80                             
81                    // C onnect to  the Organi zation ser vice.         
82                    // T he using s tatement a ssures tha t the serv ice proxy  will be pr operly dis posed.        
83                    usin g (_servic eProxy = n ew Organiz ationServi ceProxy(se rverConfig .Organizat ionUri, se rverConfig .HomeRealm Uri,server Config.Cre dentials,  serverConf ig.DeviceC redentials ))        
84                    {        
85                         // This st atement is  required  to enable  early-boun d type sup port.        
86                         _servicePr oxy.Enable ProxyTypes ();        
87          
88          
89                         // Call th e method t o create a ny data th at this sa mple requi res.        
90                         CreateRequ iredRecord s();        
91          
92                         //<snippet RetrieveOp portunity1 >        
93                         // Retriev e Opportun ity record .                         
94                         Opportunit y checkOpp ortunity =  (Opportun ity)_servi ceProxy.Re trieve(        
95                             Opport unity.Enti tyLogicalN ame,        
96                             _oppor tunityId,        
97                             new Co lumnSet("n ame"));        
98          
99                         Console.Wr iteLine("R etrieved { 0}", check Opportunit y.Name);        
100          
101                         // Retriev e the rela ted opport unity prod ucts        
102                         QueryExpre ssion oppo rtunityPro ductsQuery  = new Que ryExpressi on        
103                         {        
104                             Entity Name = Opp ortunityPr oduct.Enti tyLogicalN ame,        
105                             Column Set = new  ColumnSet( "opportuni typroducti d", "volum ediscounta mount"),        
106                             Criter ia = new F ilterExpre ssion        
107                             {        
108                                 Co nditions =          
109                             {        
110                                 ne w Conditio nExpressio        
111                                 {        
112                                      Attribut eName = "o pportunity id",        
113                                      Operator  = Conditi onOperator .Equal,        
114                                      Values =  { _opport unityId }        
115                                 }        
116                             }        
117                             }        
118                         };        
119          
120                         DataCollec tion<Entit y> opportu nityProduc ts = _serv iceProxy.R etrieveMul tiple(        
121                             opport unityProdu ctsQuery). Entities;        
122          
123                         foreach (E ntity enti ty in oppo rtunityPro ducts)        
124                         {        
125                             Opport unityProdu ct opportu nityProduc t = (Oppor tunityProd uct)entity ;        
126                             Consol e.WriteLin e("Retriev ed Opportu nity Produ ct {0}",        
127                                 op portunityP roduct.Opp ortunityPr oductId.Va lue);        
128                         }        
129                         //</snippe tRetrieveO pportunity 1>                         
130          
131                         DeleteRequ iredRecord s(promptFo rDelete);        
132                    }        
133                }        
134                // Catch  any servi ce fault e xceptions  that Micro soft Dynam ics CRM th rows.        
135                catch (F aultExcept ion<Micros oft.Xrm.Sd k.Organiza tionServic eFault>)        
136                {        
137                    // Y ou can han dle an exc eption her e or pass  it back to  the calli ng method.        
138                    thro w;        
139                }        
140           }        
141                   
142          
143           // / <summary >        
144           // / This met hod create s any enti ty records  that this  sample re quires.        
145           // / Create a  unit grou p.        
146           // / Retrieve  the defau lt unit.        
147           // / Create f ew product s.        
148           // / Create n ew discoun t list and  discount.        
149           // / Create n ew price l ist and fe w price li st items.        
150           // / Create a n account  record.        
151           // / Create a  new oppor tunity and  few oppor tunity pro ducts.        
152           // / </summar y>        
153           pu blic void  CreateRequ iredRecord s()        
154           {        
155                // Creat e a unit g roup        
156                UoMSched ule newUni tGroup = n ew UoMSche dule        
157                {        
158                    Name  = "Exampl e Unit Gro up",        
159                    Base UoMName =  "Example P rimary Uni t"        
160                };        
161          
162                _unitGro upId = _se rviceProxy .Create(ne wUnitGroup );        
163                Console. WriteLine( "Created { 0}", newUn itGroup.Na me);        
164          
165                // Retri eve the de fault unit  id that w as automat ically cre ated        
166                // when  we created  the Unit  Group        
167                QueryExp ression un itQuery =  new QueryE xpression        
168                {        
169                    Enti tyName = U oM.EntityL ogicalName ,        
170                    Colu mnSet = ne w ColumnSe t("uomid",  "name"),        
171                    Crit eria = new  FilterExp ression        
172                    {        
173                         Conditions  =         
174                             {        
175                                 ne w Conditio nExpressio        
176                                 {        
177                                      Attribut eName = "u omschedule id",        
178                                      Operator  = Conditi onOperator .Equal,        
179                                      Values =  { _unitGr oupId }        
180                                 }        
181                             }        
182                    },        
183                    Page Info = new  PagingInf o        
184                    {        
185                         PageNumber  = 1,        
186                         Count = 1        
187                    }        
188                };                   
189                        
190                // Retri eve the un it.        
191                UoM unit  = (UoM)_s erviceProx y.Retrieve Multiple(u nitQuery). Entities[0 ];        
192          
193                _default UnitId = u nit.UoMId. Value;        
194          
195                Console. WriteLine( "Retrieved  {0}", uni t.Name);        
196                     
197                // Creat e a few pr oducts        
198                Product  newProduct 1 = new Pr oduct        
199                {        
200                    Prod uctNumber  = "1",        
201                    Name  = "Exampl e Product  1",        
202                    Prod uctStructu re = new O ptionSetVa lue(1),        
203                    Quan tityDecima l = 2,        
204                    Defa ultUoMSche duleId = n ew EntityR eference(U oMSchedule .EntityLog icalName,         
205                         _unitGroup Id),        
206                    Defa ultUoMId =  new Entit yReference (UoM.Entit yLogicalNa me, _defau ltUnitId)        
207                };        
208          
209                _product 1Id = _ser viceProxy. Create(new Product1);        
210                Console. WriteLine( "Created { 0}", newPr oduct1.Nam e);        
211          
212                Product  newProduct 2 = new Pr oduct        
213                {        
214                   Produ ctNumber =  "2",        
215                   Name  = "Example  Product 2 ",        
216                   Produ ctStructur e = new Op tionSetVal ue(1),        
217                   Quant ityDecimal  = 3,        
218                   Defau ltUoMSched uleId = ne w EntityRe ference(Uo MSchedule. EntityLogi calName,         
219                       _ unitGroupI d),        
220                   Defau ltUoMId =  new Entity Reference( UoM.Entity LogicalNam e, _defaul tUnitId)        
221                };        
222          
223                _product 2Id = _ser viceProxy. Create(new Product2);        
224                Console. WriteLine( "Created { 0}", newPr oduct2.Nam e);        
225          
226                // Creat e a new di scount lis t        
227                Discount Type newDi scountType  = new Dis countType        
228                {        
229                    Name  = "Exampl e Discount  List",        
230                    IsAm ountType =  false        
231                };        
232          
233                _discoun tTypeId =  _servicePr oxy.Create (newDiscou ntType);        
234                Console. WriteLine( "Created { 0}", newDi scountType .Name);        
235          
236                // Creat e a new di scount        
237                Discount  newDiscou nt = new D iscount        
238                {        
239                    Disc ountTypeId  = new Ent ityReferen ce(Discoun tType.Enti tyLogicalN ame,         
240                         _discountT ypeId),        
241                    LowQ uantity =  5,        
242                    High Quantity =  10,        
243                    Perc entage = 3        
244                };        
245          
246                _discoun tId = _ser viceProxy. Create(new Discount);        
247          
248                Console. WriteLine( "Created n ew discoun t for the  {0}.", new DiscountTy pe.Name);        
249          
250                // Creat e a price  list        
251                PriceLev el newPric eList = ne w PriceLev el        
252                {        
253                    Name  = "Exampl e Price Li st"        
254                };        
255          
256                _priceLi stId = _se rviceProxy .Create(ne wPriceList );        
257                Console. WriteLine( "Created { 0}", newPr iceList.Na me);        
258          
259                // Creat e a price  list item  for the fi rst produc t and appl y volume d iscount        
260                ProductP riceLevel  newPriceLi stItem1 =  new Produc tPriceLeve        
261                {        
262                    Pric eLevelId =  new Entit yReference (PriceLeve l.EntityLo gicalName,  _priceLis tId),        
263                    Prod uctId = ne w EntityRe ference(Pr oduct.Enti tyLogicalN ame, _prod uct1Id),        
264                    UoMI d = new En tityRefere nce(UoM.En tityLogica lName, _de faultUnitI d),        
265                    Amou nt = new M oney(20),        
266                    Disc ountTypeId  = new Ent ityReferen ce(Discoun tType.Enti tyLogicalN ame,         
267                         _discountT ypeId)        
268                };        
269          
270                _priceLi stItem1Id  = _service Proxy.Crea te(newPric eListItem1 );        
271                Console. WriteLine( @"Created  price list  item for  the {0} an d applied         
272                    volu me discoun t.", newPr oduct1.Nam e);        
273          
274                // Creat e a price  list item  for the se cond produ ct        
275                ProductP riceLevel  newPriceLi stItem2 =  new Produc tPriceLeve l        
276                {        
277                    Pric eLevelId =  new Entit yReference (PriceLeve l.EntityLo gicalName,  _priceLis tId),        
278                    Prod uctId = ne w EntityRe ference(Pr oduct.Enti tyLogicalN ame, _prod uct2Id),        
279                    UoMI d = new En tityRefere nce(UoM.En tityLogica lName, _de faultUnitI d),        
280                    Amou nt = new M oney(20)        
281                };        
282          
283                _priceLi stItem2Id  = _service Proxy.Crea te(newPric eListItem2 );        
284                Console. WriteLine( "Created p rice list  item for t he {0}.",  newProduct 1.Name);        
285          
286                //Publis h Product1        
287                SetState Request pu blishReque st1 = new  SetStateRe quest        
288                {        
289                    Enti tyMoniker  = new Enti tyReferenc e(Product. EntityLogi calName, _ product1Id ),        
290                    Stat e = new Op tionSetVal ue((int)Pr oductState .Active),        
291                    Stat us = new O ptionSetVa lue(1)        
292                };        
293                _service Proxy.Exec ute(publis hRequest1) ;        
294          
295                //Publis h Product2        
296                SetState Request pu blishReque st2 = new  SetStateRe quest        
297                {        
298                    Enti tyMoniker  = new Enti tyReferenc e(Product. EntityLogi calName, _ product2Id ),        
299                    Stat e = new Op tionSetVal ue((int)Pr oductState .Active),        
300                    Stat us = new O ptionSetVa lue(1)        
301                };        
302                _service Proxy.Exec ute(publis hRequest2) ;        
303                Console. WriteLine( "Published  both the  products") ;        
304          
305                // Creat e an accou nt record  for the op porutnity' s potentia l customer id         
306                Account  newAccount  = new Acc ount        
307                {        
308                    Name  = "Exampl e Account"        
309                };        
310                _account Id = _serv iceProxy.C reate(newA ccount);        
311          
312                Console. WriteLine( "Created { 0}", newAc count.Name );        
313          
314                // Creat e a new op portunity        
315                Opportun ity newOpp ortunity =  new Oppor tunity        
316                {        
317                    Name  = "Exampl e Opportun ity",        
318                    Cust omerId = n ew EntityR eference(A ccount.Ent ityLogical Name,        
319                         _accountId ),        
320                    Pric eLevelId =  new Entit yReference (PriceLeve l.EntityLo gicalName,        
321                         _priceList Id)        
322                };        
323          
324                _opportu nityId = _ servicePro xy.Create( newOpportu nity);        
325                Console. WriteLine( "Created { 0}.", newO pportunity .Name);        
326          
327                // Creat e some opp ortunity p roducts        
328                Opportun ityProduct  newOpport unityProdu ct1 = new  Opportunit yProduct        
329                {        
330                    Oppo rtunityId  = new Enti tyReferenc e(Opportun ity.Entity LogicalNam e,        
331                         _opportuni tyId),        
332                    Prod uctId = ne w EntityRe ference(Pr oduct.Enti tyLogicalN ame,        
333                         _product1I d),        
334                    UoMI d = new En tityRefere nce(UoM.En tityLogica lName, _de faultUnitI d),        
335                    Quan tity = 8        
336                };        
337          
338                _opportu nityProduc t1Id = _se rviceProxy .Create(ne wOpportuni tyProduct1 );        
339          
340                Opportun ityProduct  newOpport unityProdu ct2 = new  Opportunit yProduct        
341                {        
342                    Oppo rtunityId  = new Enti tyReferenc e(Opportun ity.Entity LogicalNam e,        
343                         _opportuni tyId),        
344                    Prod uctId = ne w EntityRe ference(Pr oduct.Enti tyLogicalN ame,        
345                         _product2I d),        
346                    UoMI d = new En tityRefere nce(UoM.En tityLogica lName, _de faultUnitI d),        
347                    Quan tity = 1        
348                };        
349          
350                _opportu nityProduc t2Id = _se rviceProxy .Create(        
351                    newO pportunity Product2);        
352          
353                Console. WriteLine( "Created f ew opportu nity produ cts.");        
354          
355                return;        
356           }        
357                   
358           // / <summary >        
359           // / Deletes  any entity  records t hat were c reated for  this samp le.        
360           // / <param n ame="promp t">Indicat es whether  to prompt  the user  to delete         
361           // / the reco rds create d in this  sample.</p aram>        
362           // / </summar y>        
363           pu blic void  DeleteRequ iredRecord s(bool pro mpt)        
364           {        
365                bool del eteRecords  = true;        
366          
367                if (prom pt)        
368                {        
369                    Cons ole.WriteL ine("\nDo  you want t hese entit y records  deleted? ( y/n)");        
370                    Stri ng answer  = Console. ReadLine() ;        
371                            
372                    dele teRecords  = (answer. StartsWith ("y") || a nswer.Star tsWith("Y" ));        
373                }        
374          
375                if (dele teRecords)        
376                {        
377                    _ser viceProxy. Delete("op portunityp roduct", _ opportunit yProduct1I d);        
378                    _ser viceProxy. Delete("op portunityp roduct", _ opportunit yProduct2I d);        
379                                      _service Proxy.Dele te("opport unity", _o pportunity Id);        
380                                      _service Proxy.Dele te("accoun t", _accou ntId);        
381                    _ser viceProxy. Delete("pr oductprice level", _p riceListIt em1Id);        
382                    _ser viceProxy. Delete("pr oductprice level", _p riceListIt em2Id);        
383                                      _service Proxy.Dele te("pricel evel", _pr iceListId) ;        
384                    _ser viceProxy. Delete("pr oduct", _p roduct1Id) ;        
385                    _ser viceProxy. Delete("pr oduct", _p roduct2Id) ;        
386                                      _service Proxy.Dele te("discou nt", _disc ountId);        
387                                      _service Proxy.Dele te("discou nttype", _ discountTy peId);        
388                                      _service Proxy.Dele te("uomsch edule", _u nitGroupId );                        
389          
390                    Cons ole.WriteL ine("Entit y records  have been  deleted.") ;        
391                }        
392           }        
393                   
394           #e ndregion H ow To Samp le Code        
395          
396           #r egion Main        
397           // / <summary >        
398           // / Standard  Main() me thod used  by most SD K samples.        
399           // / </summar y>        
400           // / <param n ame="args" ></param>        
401           st atic publi c void Mai n(string[]  args)        
402           {        
403                try        
404                {        
405                    // O btain the  target org anization' s Web addr ess and cl ient logon          
406                    // c redentials  from the  user.        
407                    Serv erConnecti on serverC onnect = n ew ServerC onnection( );        
408                    Serv erConnecti on.Configu ration con fig = serv erConnect. GetServerC onfigurati on();        
409          
410                    Retr ieveOpport unity app  = new Retr ieveOpport unity();        
411                    app. Run(config , true);        
412                }        
413          
414                catch (F aultExcept ion<Micros oft.Xrm.Sd k.Organiza tionServic eFault> ex )        
415                {        
416                    Cons ole.WriteL ine("The a pplication  terminate d with an  error.");        
417                    Cons ole.WriteL ine("Times tamp: {0}" , ex.Detai l.Timestam p);        
418                    Cons ole.WriteL ine("Code:  {0}", ex. Detail.Err orCode);        
419                    Cons ole.WriteL ine("Messa ge: {0}",  ex.Detail. Message);        
420                    Cons ole.WriteL ine("Plugi n Trace: { 0}", ex.De tail.Trace Text);        
421                    Cons ole.WriteL ine("Inner  Fault: {0 }",        
422                         null == ex .Detail.In nerFault ?  "No Inner  Fault" :  "Has Inner  Fault");        
423                }        
424                catch (S ystem.Time outExcepti on ex)        
425                {        
426                    Cons ole.WriteL ine("The a pplication  terminate d with an  error.");        
427                    Cons ole.WriteL ine("Messa ge: {0}",  ex.Message );        
428                    Cons ole.WriteL ine("Stack  Trace: {0 }", ex.Sta ckTrace);        
429                    Cons ole.WriteL ine("Inner  Fault: {0 }",        
430                         null == ex .InnerExce ption.Mess age ? "No  Inner Faul t" : ex.In nerExcepti on.Message );        
431                }        
432                catch (S ystem.Exce ption ex)        
433                {        
434                    Cons ole.WriteL ine("The a pplication  terminate d with an  error.");        
435                    Cons ole.WriteL ine(ex.Mes sage);        
436          
437                    // D isplay the  details o f the inne r exceptio n.        
438                    if ( ex.InnerEx ception !=  null)        
439                    {        
440                         Console.Wr iteLine(ex .InnerExce ption.Mess age);        
441          
442                         FaultExcep tion<Micro soft.Xrm.S dk.Organiz ationServi ceFault> f        
443                             = ex.I nnerExcept ion         
444                             as Fau ltExceptio n<Microsof t.Xrm.Sdk. Organizati onServiceF ault>;        
445                         if (fe !=  null)        
446                         {        
447                             Consol e.WriteLin e("Timesta mp: {0}",  fe.Detail. Timestamp) ;        
448                             Consol e.WriteLin e("Code: { 0}", fe.De tail.Error Code);        
449                             Consol e.WriteLin e("Message : {0}", fe .Detail.Me ssage);        
450                             Consol e.WriteLin e("Plugin  Trace: {0} ", fe.Deta il.TraceTe xt);        
451                             Consol e.WriteLin e("Inner F ault: {0}" ,        
452                                 nu ll == fe.D etail.Inne rFault ? " No Inner F ault" : "H as Inner F ault");        
453                         }        
454                    }        
455                }        
456                // Addit ional exce ptions to  catch: Sec urityToken Validation Exception,  ExpiredSe curityToke nException ,        
457                // Secur ityAccessD eniedExcep tion, Mess ageSecurit yException , and Secu rityNegoti ationExcep tion.        
458          
459                finally        
460                {        
461                    Cons ole.WriteL ine("Press  <Enter> t o exit.");        
462                    Cons ole.ReadLi ne();        
463                }        
464           }        
465           #e ndregion M ain        
466           }        
467   }        
468   //</snippe tRetrieveO pportunity >