498. Araxis Merge File Comparison Report

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

498.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\Metadata\Relationships WorkWithRelationships.cs Tue Dec 20 19:51:47 2016 UTC
2 Wed Feb 1 19:56:48 2017 UTC

498.2 Comparison summary

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

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

498.4 Active regular expressions

No regular expressions were active.

498.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   //<snippet WorkWithRe lationship s>        
18   using Syst em;        
19   using Syst em.Linq;        
20   using Syst em.Xml.Lin q;        
21   using Syst em.Service Model;        
22   using Syst em.Service Model.Desc ription;        
23          
24   // These n amespaces  are found  in the Mic rosoft.Xrm .Sdk.dll a ssembly        
25   // found i n the SDK\ bin folder .        
26   using Micr osoft.Xrm. Sdk;        
27   using Micr osoft.Xrm. Sdk.Client ;        
28   using Micr osoft.Xrm. Sdk.Query;        
29   using Micr osoft.Xrm. Sdk.Metada ta;        
30   using Micr osoft.Xrm. Sdk.Messag es;        
31          
32   // This na mespace is  found in  Microsoft. Crm.Sdk.Pr oxy.dll as sembly        
33   // found i n the SDK\ bin folder .        
34   using Micr osoft.Crm. Sdk.Messag es;        
35          
36   namespace  Microsoft. Crm.Sdk.Sa mples        
37   {        
38       /// <s ummary>        
39       /// Th is sample  shows how  to create  one to man y, many to  many rela tionship.        
40       /// </ summary>        
41       public  class Wor kWithRelat ionships        
42       {        
43           #r egion Clas s Level Me mbers        
44                   
45           // / <summary >        
46           // / Stores t he organiz ation serv ice proxy.        
47           // / </summar y>        
48           pr ivate Orga nizationSe rviceProxy  _serviceP roxy;        
49          
50           //  Define th e IDs need ed for thi s sample.        
51           pr ivate Guid  _oneToMan yRelations hipId;        
52           pr ivate Syst em.String  _oneToMany Relationsh ipName;        
53          
54           pr ivate Guid  _manyToMa nyRelation shipId;        
55           pr ivate Syst em.String  _manyToMan yRelations hipName;        
56          
57           #e ndregion C lass Level  Members        
58          
59           #r egion How  To Sample  Code        
60           // / <summary >        
61           // / Create a nd configu re the org anization  service pr oxy.        
62           // / Create o ne-to-many  relations hip.        
63           // / Create m any-to-man y relation ship.        
64           // / Optional ly delete  any entity  records t hat were c reated for  this samp le.        
65           // / </summar y>        
66           // / <param n ame="serve rConfig">C ontains se rver conne ction info rmation.</ param>        
67           // / <param n ame="promp tForDelete ">When Tru e, the use r will be  prompted t o delete a ll        
68           // / created  entities.< /param>        
69           pu blic void  Run(Server Connection .Configura tion serve rConfig, b ool prompt ForDelete)        
70           {        
71                try        
72                {        
73          
74                    // C onnect to  the Organi zation ser vice.         
75                    // T he using s tatement a ssures tha t the serv ice proxy  will be pr operly dis posed.        
76                    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 ))        
77                    {        
78                         // This st atement is  required  to enable  early-boun d type sup port.        
79                         _servicePr oxy.Enable ProxyTypes ();        
80          
81                         //<snippet WorkWithRe lationship s1>        
82          
83                         bool eligi bleCreateO neToManyRe lationship  =        
84                             Eligib leCreateOn eToManyRel ationship( "account",  "campaign ");        
85          
86                         if (eligib leCreateOn eToManyRel ationship)        
87                         {        
88                             Create OneToManyR equest cre ateOneToMa nyRelation shipReques t =        
89                                 ne w CreateOn eToManyReq uest        
90                             {        
91                                 On eToManyRel ationship  =        
92                                 ne w OneToMan yRelations hipMetadat a        
93                                 {        
94                                      Referenc edEntity =  "account" ,        
95                                      Referenc ingEntity  = "campaig n",        
96                                      SchemaNa me = "new_ account_ca mpaign",        
97                                      Associat edMenuConf iguration  = new Asso ciatedMenu Configurat ion        
98                                      {        
99                                          Beha vior = Ass ociatedMen uBehavior. UseLabel,        
100                                          Grou p = Associ atedMenuGr oup.Detail s,        
101                                          Labe l = new La bel("Accou nt", 1033) ,        
102                                          Orde r = 10000        
103                                      },        
104                                      CascadeC onfigurati on = new C ascadeConf iguration        
105                                      {        
106                                          Assi gn = Casca deType.NoC ascade,        
107                                          Dele te = Casca deType.Rem oveLink,        
108                                          Merg e = Cascad eType.NoCa scade,        
109                                          Repa rent = Cas cadeType.N oCascade,        
110                                          Shar e = Cascad eType.NoCa scade,        
111                                          Unsh are = Casc adeType.No Cascade        
112                                      }        
113                                 },        
114                                 Lo okup = new  LookupAtt ributeMeta data        
115                                 {        
116                                      SchemaNa me = "new_ parent_acc ountid",        
117                                      DisplayN ame = new  Label("Acc ount Looku p", 1033),        
118                                      Required Level = ne w Attribut eRequiredL evelManage dProperty( AttributeR equiredLev el.None),        
119                                      Descript ion = new  Label("Sam ple Lookup ", 1033)        
120                                 }        
121                             };        
122          
123          
124                             Create OneToManyR esponse cr eateOneToM anyRelatio nshipRespo nse =        
125                                 (C reateOneTo ManyRespon se)_servic eProxy.Exe cute(        
126                                 cr eateOneToM anyRelatio nshipReque st);        
127          
128                             _oneTo ManyRelati onshipId =        
129                                 cr eateOneToM anyRelatio nshipRespo nse.Relati onshipId;        
130                             _oneTo ManyRelati onshipName  =         
131                                 cr eateOneToM anyRelatio nshipReque st.OneToMa nyRelation ship.Schem aName;        
132          
133                             Consol e.WriteLin e(        
134                                 "T he one-to- many relat ionship ha s been cre ated betwe en {0} and  {1}.",        
135                                 "a ccount", " campaign") ;        
136                         }        
137          
138                         //</snippe tWorkWithR elationshi ps1>        
139          
140                         //<snippet WorkWithRe lationship s2>        
141          
142                         bool accou ntEligible Participat e =        
143                             Eligib leCreateMa nyToManyRe lationship ("account" );        
144                         bool campa ignEligibl eParticipa te =        
145                             Eligib leCreateMa nyToManyRe lationship ("campaign ");        
146          
147                         if (accoun tEligibleP articipate  && campai gnEligible Participat e)        
148                         {        
149          
150                             Create ManyToMany Request cr eateManyTo ManyRelati onshipRequ est =        
151                                 ne w CreateMa nyToManyRe quest        
152                             {        
153                                 In tersectEnt itySchemaN ame = "new _accounts_ campaigns" ,        
154                                 Ma nyToManyRe lationship  = new Man yToManyRel ationshipM etadata        
155                                 {        
156                                      SchemaNa me = "new_ accounts_c ampaigns",        
157                                      Entity1L ogicalName  = "accoun t",        
158                                      Entity1A ssociatedM enuConfigu ration =        
159                                      new Asso ciatedMenu Configurat ion        
160                                      {        
161                                          Beha vior = Ass ociatedMen uBehavior. UseLabel,        
162                                          Grou p = Associ atedMenuGr oup.Detail s,        
163                                          Labe l = new La bel("Accou nt", 1033) ,        
164                                          Orde r = 10000        
165                                      },        
166                                      Entity2L ogicalName  = "campai gn",        
167                                      Entity2A ssociatedM enuConfigu ration =        
168                                      new Asso ciatedMenu Configurat ion        
169                                      {        
170                                          Beha vior = Ass ociatedMen uBehavior. UseLabel,        
171                                          Grou p = Associ atedMenuGr oup.Detail s,        
172                                          Labe l = new La bel("Campa ign", 1033 ),        
173                                          Orde r = 10000        
174                                      }        
175                                 }        
176                             };        
177          
178                             Create ManyToMany Response c reateManyt oManyRelat ionshipRes ponse =        
179                                 (C reateManyT oManyRespo nse)_servi ceProxy.Ex ecute(        
180                                 cr eateManyTo ManyRelati onshipRequ est);        
181          
182          
183                             _manyT oManyRelat ionshipId  =        
184                                 cr eateManyto ManyRelati onshipResp onse.ManyT oManyRelat ionshipId;        
185                             _manyT oManyRelat ionshipNam e =        
186                                 cr eateManyTo ManyRelati onshipRequ est.ManyTo ManyRelati onship.Sch emaName;        
187          
188                             Consol e.WriteLin e(        
189                                 "T he many-to -many rela tionship h as been cr eated betw een {0} an d {1}.",        
190                                 "a ccount", " campaign") ;        
191                         }        
192          
193                         //</snippe tWorkWithR elationshi ps2>        
194          
195                         // Publish  the custo mization c hanges.        
196                         _servicePr oxy.Execut e(new Publ ishAllXmlR equest());        
197          
198          
199                         //<snippet WorkWithRe lationship s.Retrieve Relationsh ip>        
200          
201                         //You can  use either  the Name  or the Met adataId of  the relat ionship.        
202          
203                         //Retrieve  the One-t o-many rel ationship  using the  MetadataId .        
204                         RetrieveRe lationship Request re trieveOneT oManyReque st =        
205                             new Re trieveRela tionshipRe quest { Me tadataId =  _oneToMan yRelations hipId };        
206                         RetrieveRe lationship Response r etrieveOne ToManyResp onse =        
207                             (Retri eveRelatio nshipRespo nse)_servi ceProxy.Ex ecute(retr ieveOneToM anyRequest );        
208          
209                         Console.Wr iteLine("R etrieved { 0} One-to- many relat ionship by  id", retr ieveOneToM anyRespons e.Relation shipMetada ta.SchemaN ame);        
210          
211                         //Retrieve  the Many- to-many re lationship  using the  Name.        
212                         RetrieveRe lationship Request re trieveMany ToManyRequ est =        
213                             new Re trieveRela tionshipRe quest { Na me = _many ToManyRela tionshipNa me};        
214                         RetrieveRe lationship Response r etrieveMan yToManyRes ponse =        
215                             (Retri eveRelatio nshipRespo nse)_servi ceProxy.Ex ecute(retr ieveManyTo ManyReques t);        
216          
217                         Console.Wr iteLine("R etrieved { 0} Many-to -Many rela tionship b y Name", r etrieveMan yToManyRes ponse.Rela tionshipMe tadata.Met adataId);        
218          
219                         //</snippe tWorkWithR elationshi ps.Retriev eRelations hip>        
220          
221                         DeleteRequ iredRecord s(promptFo rDelete);        
222          
223          
224                    }        
225                }        
226          
227                // Catch  any servi ce fault e xceptions  that Micro soft Dynam ics CRM th rows.        
228                catch (F aultExcept ion<Micros oft.Xrm.Sd k.Organiza tionServic eFault>)        
229                {        
230                    // Y ou can han dle an exc eption her e or pass  it back to  the calli ng method.        
231                    thro w;        
232                }        
233           }        
234          
235           // <snippetWo rkWithRela tionships3 >        
236           // / <summary >        
237           // / Determin es whether  the entit y can part icipate in  a many-to -many rela tionship.        
238           // / </summar y>        
239           // / <param n ame="entit y">Entity< /param>        
240           // / <returns ></returns >        
241           pu blic bool  EligibleCr eateManyTo ManyRelati onship(str ing entity )        
242           {        
243                CanManyT oManyReque st canMany ToManyRequ est = new  CanManyToM anyRequest        
244                {        
245                    Enti tyName = e ntity        
246                };        
247          
248                CanManyT oManyRespo nse canMan yToManyRes ponse =        
249                    (Can ManyToMany Response)_ servicePro xy.Execute (canManyTo ManyReques t);        
250          
251                if (!can ManyToMany Response.C anManyToMa ny)        
252                {        
253                    Cons ole.WriteL ine(        
254                         "Entity {0 } can't pa rticipate  in a many- to-many re lationship .",         
255                         entity);        
256                }        
257          
258                return c anManyToMa nyResponse .CanManyTo Many;        
259           }        
260           // </snippetW orkWithRel ationships 3>        
261           // <snippetWo rkWithRela tionships4 >        
262           // / <summary >        
263           // / Determin es whether  two entit ies are el igible to  participat e in a rel ationship        
264           // / </summar y>        
265           // / <param n ame="refer encedEntit y">Primary  Entity</p aram>        
266           // / <param n ame="refer encingEnti ty">Refere ncing Enti ty</param>        
267           // / <returns ></returns >        
268           pu blic bool  EligibleCr eateOneToM anyRelatio nship(stri ng referen cedEntity,          
269                string r eferencing Entity)        
270           {        
271                //Checks  whether t he specifi ed entity  can be the  primary e ntity in o ne-to-many        
272                //relati onship.        
273                CanBeRef erencedReq uest canBe Referenced Request =  new CanBeR eferencedR equest        
274                {        
275                    Enti tyName = r eferencedE ntity        
276                };        
277          
278                CanBeRef erencedRes ponse canB eReference dResponse  =        
279                    (Can BeReferenc edResponse )_serviceP roxy.Execu te(canBeRe ferencedRe quest);        
280          
281                if (!can BeReferenc edResponse .CanBeRefe renced)        
282                {        
283                    Cons ole.WriteL ine(        
284                         "Entity {0 } can't be  the prima ry entity  in this on e-to-many  relationsh ip",         
285                         referenced Entity);        
286                }        
287          
288                //Checks  whether t he specifi ed entity  can be the  referenci ng entity  in one-to- many        
289                //relati onship.        
290                CanBeRef erencingRe quest canB ereferenci ngRequest  = new CanB eReferenci ngRequest        
291                {        
292                    Enti tyName = r eferencing Entity        
293                };        
294          
295                CanBeRef erencingRe sponse can BeReferenc ingRespons e =        
296                    (Can BeReferenc ingRespons e)_service Proxy.Exec ute(canBer eferencing Request);        
297          
298                if (!can BeReferenc ingRespons e.CanBeRef erencing)        
299                {        
300                    Cons ole.WriteL ine(        
301                         "Entity {0 } can't be  the refer encing ent ity in thi s one-to-m any relati onship",         
302                         referencin gEntity);        
303                }        
304          
305          
306                if (canB eReference dResponse. CanBeRefer enced == t rue        
307                    && c anBeRefere ncingRespo nse.CanBeR eferencing  == true)        
308                {        
309                    retu rn true;        
310                }        
311                else        
312                {        
313                    retu rn false;        
314                }        
315           }        
316           // </snippetW orkWithRel ationships 4>        
317           // / <summary >        
318           // / Deletes  the relati onships th at was cre ated for t his sample .        
319           // / <param n ame="promp t">Indicat es whether  to prompt  the user  to delete         
320           // / the reco rds create d in this  sample.</p aram>        
321           // / </summar y>        
322           pu blic void  DeleteRequ iredRecord s(bool pro mpt)        
323           {        
324                bool del eteRecords  = true;        
325          
326                if (prom pt)        
327                {        
328                    Cons ole.WriteL ine("\nDo  you want t hese entit y relation ships to b e deleted?  (y/n)");        
329                    Stri ng answer  = Console. ReadLine() ;        
330          
331                    dele teRecords  = (answer. StartsWith ("y") || a nswer.Star tsWith("Y" ));        
332                }        
333          
334                if (dele teRecords)        
335                {        
336                    //<s nippetWork WithRelati onships5>        
337                    Dele teRelation shipReques t deleteOn eToManyRel ationshipR equest =         
338                         new Delete Relationsh ipRequest        
339                    {                              
340                         Name = "ne w_account_ campaign"        
341                    };        
342          
343                    _ser viceProxy. Execute(de leteOneToM anyRelatio nshipReque st);        
344          
345                    Dele teRelation shipReques t deleteMa nyToManyRe lationship Request =         
346                         new Delete Relationsh ipRequest        
347                    {        
348                         Name = "ne w_accounts _campaigns "        
349                    };        
350          
351                    _ser viceProxy. Execute(de leteManyTo ManyRelati onshipRequ est);        
352          
353                    Cons ole.WriteL ine("Entit y Relation ships have  been dele ted.");        
354                    //</ snippetWor kWithRelat ionships5>        
355                }        
356           }        
357          
358           #e ndregion H ow To Samp le Code        
359          
360           #r egion Main        
361           // / <summary >        
362           // / Standard  Main() me thod used  by most SD K samples.        
363           // / </summar y>        
364           // / <param n ame="args" ></param>        
365           st atic publi c void Mai n(string[]  args)        
366           {        
367                try        
368                {        
369                    // O btain the  target org anization' s Web addr ess and cl ient logon          
370                    // c redentials  from the  user.        
371                    Serv erConnecti on serverC onnect = n ew ServerC onnection( );        
372                    Serv erConnecti on.Configu ration con fig = serv erConnect. GetServerC onfigurati on();        
373          
374                    Work WithRelati onships ap p = new Wo rkWithRela tionships( );        
375                    app. Run(config , true);        
376                }        
377                catch (F aultExcept ion<Micros oft.Xrm.Sd k.Organiza tionServic eFault> ex )        
378                {        
379                    Cons ole.WriteL ine("The a pplication  terminate d with an  error.");        
380                    Cons ole.WriteL ine("Times tamp: {0}" , ex.Detai l.Timestam p);        
381                    Cons ole.WriteL ine("Code:  {0}", ex. Detail.Err orCode);        
382                    Cons ole.WriteL ine("Messa ge: {0}",  ex.Detail. Message);        
383                    Cons ole.WriteL ine("Plugi n Trace: { 0}", ex.De tail.Trace Text);        
384                    Cons ole.WriteL ine("Inner  Fault: {0 }",        
385                         null == ex .Detail.In nerFault ?  "No Inner  Fault" :  "Has Inner  Fault");        
386                }        
387                catch (S ystem.Time outExcepti on ex)        
388                {        
389                    Cons ole.WriteL ine("The a pplication  terminate d with an  error.");        
390                    Cons ole.WriteL ine("Messa ge: {0}",  ex.Message );        
391                    Cons ole.WriteL ine("Stack  Trace: {0 }", ex.Sta ckTrace);        
392                    Cons ole.WriteL ine("Inner  Fault: {0 }",        
393                         null == ex .InnerExce ption.Mess age ? "No  Inner Faul t" : ex.In nerExcepti on.Message );        
394                }        
395                catch (S ystem.Exce ption ex)        
396                {        
397                    Cons ole.WriteL ine("The a pplication  terminate d with an  error.");        
398                    Cons ole.WriteL ine(ex.Mes sage);        
399          
400                    // D isplay the  details o f the inne r exceptio n.        
401                    if ( ex.InnerEx ception !=  null)        
402                    {        
403                         Console.Wr iteLine(ex .InnerExce ption.Mess age);        
404          
405                         FaultExcep tion<Micro soft.Xrm.S dk.Organiz ationServi ceFault> f e        
406                             = ex.I nnerExcept ion        
407                             as Fau ltExceptio n<Microsof t.Xrm.Sdk. Organizati onServiceF ault>;        
408                         if (fe !=  null)        
409                         {        
410                             Consol e.WriteLin e("Timesta mp: {0}",  fe.Detail. Timestamp) ;        
411                             Consol e.WriteLin e("Code: { 0}", fe.De tail.Error Code);        
412                             Consol e.WriteLin e("Message : {0}", fe .Detail.Me ssage);        
413                             Consol e.WriteLin e("Plugin  Trace: {0} ", fe.Deta il.TraceTe xt);        
414                             Consol e.WriteLin e("Inner F ault: {0}" ,        
415                                 nu ll == fe.D etail.Inne rFault ? " No Inner F ault" : "H as Inner F ault");        
416                         }        
417                    }        
418                }        
419                // Addit ional exce ptions to  catch: Sec urityToken Validation Exception,  ExpiredSe curityToke nException ,        
420                // Secur ityAccessD eniedExcep tion, Mess ageSecurit yException , and Secu rityNegoti ationExcep tion.        
421          
422                finally        
423                {        
424                    Cons ole.WriteL ine("Press  <Enter> t o exit.");        
425                    Cons ole.ReadLi ne();        
426                }        
427          
428           }        
429           #e ndregion M ain        
430          
431       }        
432   }        
433   //</snippe tWorkWithR elationshi ps>