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

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

203.2 Comparison summary

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

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

203.4 Active regular expressions

No regular expressions were active.

203.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 QueryConne ctions>        
18   using Syst em;        
19   using Syst em.Service Model;        
20   using Syst em.Service Model.Desc ription;        
21          
22   // These n amespaces  are found  in the Mic rosoft.Xrm .Sdk.dll a ssembly        
23   // found i n the SDK\ bin folder .        
24   using Micr osoft.Xrm. Sdk;        
25   using Micr osoft.Xrm. Sdk.Client ;        
26   using Micr osoft.Xrm. Sdk.Query;        
27   using Micr osoft.Xrm. Sdk.Discov ery;        
28   using Micr osoft.Xrm. Sdk.Messag es;        
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 query c onnections .        
38       /// </ summary>        
39       public  class Que ryConnecti ons        
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  _connectio nRoleId;        
50           pu blic Guid  _account1I d;        
51           pu blic Guid  _account2I d;        
52           pu blic Guid  _contactId ;        
53           pu blic Guid  _connectio n1Id;        
54           pu blic Guid  _connectio n2Id;        
55          
56           #e ndregion C lass Level  Members        
57          
58           #r egion How  To Sample  Code        
59           // / <summary >        
60           // / Create a nd configu re the org anization  service pr oxy.        
61           // / Call the  method to  create an y data tha t this sam ple requir es.        
62           // / Query th e connecti ons.        
63           // / Optional ly delete  any entity  records t hat were c reated for  this samp le.        
64           // / </summar y>        
65                    ///  <param nam e="serverC onfig">Con tains serv er connect ion inform ation.</pa ram>        
66           // / <param n ame="promp tforDelete ">When Tru e, the use r will be  prompted t o delete a ll        
67           // / created  entities.< /param>        
68           pu blic void  Run(Server Connection .Configura tion serve rConfig, b ool prompt ForDelete)        
69           {        
70                try        
71                {        
72                    // C onnect to  the Organi zation ser vice.         
73                    // T he using s tatement a ssures tha t the serv ice proxy  will be pr operly dis posed.        
74                    usin g (_servic eProxy = n ew Organiz ationServi ceProxy(se rverConfig .Organizat ionUri, se rverConfig .HomeRealm Uri,server Config.Cre dentials,  serverConf ig.DeviceC redentials ))        
75                    {        
76                         // This st atement is  required  to enable  early-boun d type sup port.        
77                         _servicePr oxy.Enable ProxyTypes ();        
78          
79          
80                         // Call th e method t o create a ny data th at this sa mple requi res.        
81                         CreateRequ iredRecord s();        
82          
83                         //<snippet QueryConne ctions1>        
84                         // This qu ery retrie ves all co nnections  this conta ct is part  of.        
85                         QueryExpre ssion quer y = new Qu eryExpress ion        
86                         {        
87                             Entity Name = Con nection.En tityLogica lName,        
88                             Column Set = new  ColumnSet( "connectio nid"),        
89                             Criter ia = new F ilterExpre ssion        
90                             {        
91                                 Fi lterOperat or = Logic alOperator .And,        
92                                 Co nditions =          
93                             {        
94                                 //  You can s afely quer y against  only recor d1id or        
95                                 //  record2id  - CRM wil l find all  connectio ns this         
96                                 //  entity is  a part of  either wa y.        
97                                 ne w Conditio nExpressio n        
98                                 {        
99                                      Attribut eName = "r ecord1id",        
100                                      Operator  = Conditi onOperator .Equal,        
101                                      Values =  { _contac tId }        
102                                 }        
103                             }        
104                             }        
105                         };        
106          
107                         EntityColl ection res ults = _se rviceProxy .RetrieveM ultiple(qu ery);        
108          
109                         // TODO: H ere you co uld do a v ariety of  tasks with  the         
110                         // connect ions retri eved, such  as listin g the conn ected enti ties,        
111                         // finding  reciproca l connecti ons, etc.        
112                         //</snippe tQueryConn ections1>           
113          
114                         Console.Wr iteLine("R etrieved { 0} connect ionrole in stances.",  results.E ntities.Co unt);        
115          
116                         DeleteRequ iredRecord s(promptFo rDelete);        
117          
118                    }        
119                }        
120                // Catch  any servi ce fault e xceptions  that Micro soft Dynam ics CRM th rows.        
121                catch (F aultExcept ion<Micros oft.Xrm.Sd k.Organiza tionServic eFault>)        
122                {        
123                    // Y ou can han dle an exc eption her e or pass  it back to  the calli ng method.        
124                    thro w;        
125                }        
126           }        
127          
128           // / <summary >        
129           // / This met hod create s any enti ty records  that this  sample re quires.        
130           // / Create a  new conne ctionrole  instance.         
131           // / </summar y>        
132           pu blic void  CreateRequ iredRecord s()        
133           {        
134                // Defin e some ano nymous typ es to defi ne the ran ge         
135                // of po ssible con nection pr operty val ues.        
136                var Cate gories = n ew        
137                {        
138                    Busi ness = 1,        
139                    Fami ly = 2,        
140                    Soci al = 3,        
141                    Sale s = 4,        
142                    Othe r = 5        
143                };        
144          
145                // Creat e a Connec tion Role        
146                Connecti onRole set upConnecti onRole = n ew Connect ionRole        
147                {        
148                    Name  = "Exampl e Connecti on Role",        
149                    Desc ription =  "This is a n example  one sided  connection  role.",        
150                    Cate gory = new  OptionSet Value(Cate gories.Bus iness),        
151                };        
152          
153                _connect ionRoleId  = _service Proxy.Crea te(setupCo nnectionRo le);        
154                Console. WriteLine( "Created { 0}.", setu pConnectio nRole.Name );        
155          
156                // Creat e a relate d Connecti on Role Ob ject Type  Code recor d for Acco unt        
157                Connecti onRoleObje ctTypeCode  newAccoun tConnectio nRoleTypeC ode        
158                    = ne w Connecti onRoleObje ctTypeCode        
159                    {        
160                         Connection RoleId = n ew EntityR eference(        
161                             Connec tionRole.E ntityLogic alName, _c onnectionR oleId),        
162                         Associated ObjectType Code = Acc ount.Entit yLogicalNa me        
163                    };        
164          
165                _service Proxy.Crea te(newAcco untConnect ionRoleTyp eCode);        
166                Console. WriteLine(        
167                    "Cre ated a rel ated Conne ction Role  Object Ty pe Code re cord for A ccount."        
168                    );        
169          
170                // Creat e a relate d Connecti on Role Ob ject Type  Code recor d for Cont act        
171                Connecti onRoleObje ctTypeCode  newContac tConnectio nRoleTypeC ode        
172                    = ne w Connecti onRoleObje ctTypeCode        
173                    {        
174                         Connection RoleId = n ew EntityR eference(        
175                             Connec tionRole.E ntityLogic alName, _c onnectionR oleId),        
176                         Associated ObjectType Code = Con tact.Entit yLogicalNa me        
177                    };        
178          
179                _service Proxy.Crea te(newCont actConnect ionRoleTyp eCode);        
180                Console. WriteLine(        
181                    "Cre ated a rel ated Conne ction Role  Object Ty pe Code re cord for C ontact."        
182                    );        
183          
184                //Create  a few acc ount recor ds for use  in the co nnections.        
185                Account  setupAccou nt1 = new  Account {  Name = "Ex ample Acco unt 1" };        
186                _account 1Id = _ser viceProxy. Create(set upAccount1 );        
187                Console. WriteLine( "Created { 0}.", setu pAccount1. Name);        
188          
189                Account  setupAccou nt2 = new  Account {  Name = "Ex ample Acco unt 2" };        
190                _account 2Id = _ser viceProxy. Create(set upAccount2 );        
191                Console. WriteLine( "Created { 0}.", setu pAccount2. Name);        
192          
193                //Create s a contac t used in  the connec tion.        
194                Contact  setupConta ct = new C ontact { L astName =  "Example C ontact" };        
195                _contact Id = _serv iceProxy.C reate(setu pContact);        
196                Console. WriteLine( "Created { 0}.", setu pContact.L astName);        
197          
198                // Creat e a new co nnection b etween Acc ount 1 and  the conta ct record.        
199                Connecti on newConn ection1 =  new Connec tion        
200                {        
201                    Reco rd1Id = ne w EntityRe ference(Ac count.Enti tyLogicalN ame,        
202                         _account1I d),        
203                    Reco rd1RoleId  = new Enti tyReferenc e(Connecti onRole.Ent ityLogical Name,        
204                         _connectio nRoleId),        
205                    Reco rd2Id = ne w EntityRe ference(Co ntact.Enti tyLogicalN ame,        
206                         _contactId )        
207                };        
208          
209                _connect ion1Id = _ servicePro xy.Create( newConnect ion1);        
210          
211                Console. WriteLine(        
212                         "Created a  connectio n between  the accoun t 1 and th e contact. ");        
213          
214                // Creat e a new co nnection b etween the  contact a nd Account  2 record        
215                Connecti on newConn ection2 =  new Connec tion        
216                {        
217                    Reco rd1Id = ne w EntityRe ference(Co ntact.Enti tyLogicalN ame,        
218                         _contactId ),        
219                    Reco rd1RoleId  = new Enti tyReferenc e(Connecti onRole.Ent ityLogical Name,        
220                         _connectio nRoleId),        
221                    Reco rd2Id = ne w EntityRe ference(Ac count.Enti tyLogicalN ame,        
222                         _account2I d)        
223                };        
224          
225                _connect ion2Id = _ servicePro xy.Create( newConnect ion2);        
226          
227                Console. WriteLine(        
228                         "Created a  connectio n between  the contac t and the  account 2. ");        
229          
230                return;        
231           }        
232          
233           // / <summary >        
234           // / Deletes  any entity  records t hat were c reated for  this samp le.        
235           // / <param n ame="promp t">Indicat es whether  to prompt  the user         
236           // / to delet e the reco rds create d in this  sample.</p aram>        
237           // / </summar y>        
238           pu blic void  DeleteRequ iredRecord s(bool pro mpt)        
239           {        
240                bool del eteRecords  = true;        
241          
242                if (prom pt)        
243                {        
244                    Cons ole.WriteL ine("\nDo  you want t hese entit y records  deleted? ( y/n)");        
245                    Stri ng answer  = Console. ReadLine() ;        
246          
247                    dele teRecords  = (answer. StartsWith ("y") || a nswer.Star tsWith("Y" ));        
248                }        
249          
250                if (dele teRecords)        
251                {        
252                    _ser viceProxy. Delete(Con nection.En tityLogica lName, _co nnection1I d);        
253                    _ser viceProxy. Delete(Con nection.En tityLogica lName, _co nnection2I d);        
254                    _ser viceProxy. Delete(Acc ount.Entit yLogicalNa me, _accou nt1Id);        
255                    _ser viceProxy. Delete(Acc ount.Entit yLogicalNa me, _accou nt2Id);        
256                    _ser viceProxy. Delete(Con tact.Entit yLogicalNa me, _conta ctId);        
257                    _ser viceProxy. Delete(Con nectionRol e.EntityLo gicalName,  _connecti onRoleId);        
258          
259                    Cons ole.WriteL ine("Entit y records  have been  deleted.") ;        
260                }        
261           }        
262          
263           #e ndregion H ow To Samp le Code        
264          
265           #r egion Main        
266           // / <summary >        
267           // / Standard  Main() me thod used  by most SD K samples.        
268           // / </summar y>        
269           // / <param n ame="args" ></param>        
270           st atic publi c void Mai n(string[]  args)        
271           {        
272                try        
273                {        
274                    // O btain the  target org anization' s Web addr ess and cl ient logon          
275                    // c redentials  from the  user.        
276                    Serv erConnecti on serverC onnect = n ew ServerC onnection( );        
277                    Serv erConnecti on.Configu ration con fig = serv erConnect. GetServerC onfigurati on();        
278          
279                    Quer yConnectio ns app = n ew QueryCo nnections( );        
280                    app. Run(config , true);        
281                }        
282          
283                catch (F aultExcept ion<Micros oft.Xrm.Sd k.Organiza tionServic eFault> ex )        
284                {        
285                    Cons ole.WriteL ine("The a pplication  terminate d with an  error.");        
286                    Cons ole.WriteL ine("Times tamp: {0}" , ex.Detai l.Timestam p);        
287                    Cons ole.WriteL ine("Code:  {0}", ex. Detail.Err orCode);        
288                    Cons ole.WriteL ine("Messa ge: {0}",  ex.Detail. Message);        
289                    Cons ole.WriteL ine("Plugi n Trace: { 0}", ex.De tail.Trace Text);        
290                    Cons ole.WriteL ine("Inner  Fault: {0 }",        
291                         null == ex .Detail.In nerFault ?  "No Inner  Fault" :  "Has Inner  Fault");        
292                }        
293                catch (S ystem.Time outExcepti on ex)        
294                {        
295                    Cons ole.WriteL ine("The a pplication  terminate d with an  error.");        
296                    Cons ole.WriteL ine("Messa ge: {0}",  ex.Message );        
297                    Cons ole.WriteL ine("Stack  Trace: {0 }", ex.Sta ckTrace);        
298                    Cons ole.WriteL ine("Inner  Fault: {0 }",        
299                         null == ex .InnerExce ption.Mess age ? "No  Inner Faul t" : ex.In nerExcepti on.Message );        
300                }        
301                catch (S ystem.Exce ption ex)        
302                {        
303                    Cons ole.WriteL ine("The a pplication  terminate d with an  error.");        
304                    Cons ole.WriteL ine(ex.Mes sage);        
305          
306                    // D isplay the  details o f the inne r exceptio n.        
307                    if ( ex.InnerEx ception !=  null)        
308                    {        
309                         Console.Wr iteLine(ex .InnerExce ption.Mess age);        
310          
311                         FaultExcep tion<Micro soft.Xrm.S dk.Organiz ationServi ceFault> f e        
312                             = ex.I nnerExcept ion        
313                             as Fau ltExceptio n<Microsof t.Xrm.Sdk. Organizati onServiceF ault>;        
314                         if (fe !=  null)        
315                         {        
316                             Consol e.WriteLin e("Timesta mp: {0}",  fe.Detail. Timestamp) ;        
317                             Consol e.WriteLin e("Code: { 0}", fe.De tail.Error Code);        
318                             Consol e.WriteLin e("Message : {0}", fe .Detail.Me ssage);        
319                             Consol e.WriteLin e("Plugin  Trace: {0} ", fe.Deta il.TraceTe xt);        
320                             Consol e.WriteLin e("Inner F ault: {0}" ,        
321                                 nu ll == fe.D etail.Inne rFault ? " No Inner F ault" : "H as Inner F ault");        
322                         }        
323                    }        
324                }        
325                // Addit ional exce ptions to  catch: Sec urityToken Validation Exception,  ExpiredSe curityToke nException ,        
326                // Secur ityAccessD eniedExcep tion, Mess ageSecurit yException , and Secu rityNegoti ationExcep tion.        
327          
328                finally        
329                {        
330                           
331                    Cons ole.WriteL ine("Press  <Enter> t o exit.");        
332                    Cons ole.ReadLi ne();        
333                }        
334          
335           }        
336           #e ndregion M ain        
337       }        
338   }        
339   //</snippe tQueryConn ections>