193. Araxis Merge File Comparison Report

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

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

193.2 Comparison summary

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

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

193.4 Active regular expressions

No regular expressions were active.

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