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

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

201.2 Comparison summary

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

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

201.4 Active regular expressions

No regular expressions were active.

201.5 Comparison detail

1   // ======= ========== ========== ========== ========== ========== ========== ==        
2   //  This f ile is par t of the M icrosoft D ynamics CR M SDK code  samples.        
3   //        
4   //  Copyri ght (C) Mi crosoft Co rporation.   All righ ts reserve d.        
5   //        
6   //  This s ource code  is intend ed only as  a supplem ent to Mic rosoft        
7   //  Develo pment Tool s and/or o n-line doc umentation .  See the se other        
8   //  materi als for de tailed inf ormation r egarding M icrosoft c ode sample s.        
9   //        
10   //  THIS C ODE AND IN FORMATION  ARE PROVID ED "AS IS"  WITHOUT W ARRANTY OF  ANY        
11   //  KIND,  EITHER EXP RESSED OR  IMPLIED, I NCLUDING B UT NOT LIM ITED TO TH E        
12   //  IMPLIE D WARRANTI ES OF MERC HANTABILIT Y AND/OR F ITNESS FOR  A        
13   //  PARTIC ULAR PURPO SE.        
14   // ======= ========== ========== ========== ========== ========== ========== ==        
15          
16   //<snippet QueryConne ctionRoles ByEntityTy peCode>        
17   using Syst em;        
18   using Syst em.Service Model;        
19          
20   // These n amespaces  are found  in the Mic rosoft.Xrm .Sdk.dll a ssembly        
21   // found i n the SDK\ bin folder .        
22   using Micr osoft.Xrm. Sdk;        
23   using Micr osoft.Xrm. Sdk.Client ;        
24   using Micr osoft.Xrm. Sdk.Query;        
25          
26   namespace  Microsoft. Crm.Sdk.Sa mples        
27   {        
28       /// <s ummary>        
29       /// Th is sample  shows how  to find co nnection r oles by ob ject type  code.        
30       /// </ summary>        
31       public  class Que ryConnecti onRolesByE ntityTypeC ode        
32       {        
33           #r egion Clas s Level Me mbers        
34          
35           // / <summary >        
36           // / Stores t he organiz ation serv ice proxy.        
37           // / </summar y>        
38           pr ivate Orga nizationSe rviceProxy  _serviceP roxy;        
39          
40           //  Define th e IDs need ed for thi s sample.        
41           pr ivate Guid  _connecti onRoleId;        
42          
43           #e ndregion C lass Level  Members        
44          
45           #r egion How  To Sample  Code        
46           // / <summary >        
47           // / This sam ple create s a role t hat is not  linked to  any entit y type. Al l        
48           // / connecti on roles t hat apply  to all are  found and  shown. Th en the rol e is        
49           // / linked t o the acco unt entity  and it is  demonstra ted that t he role on ly works        
50           // / for acco unts at th is point,  not for al l. Subsequ ently the  link to th e account        
51           // / entity i s removed  and it is  shown that  the role  is now app licable to  all         
52           // / entities  again.        
53           // / </summar y>        
54           // / <param n ame="serve rConfig">C ontains se rver conne ction info rmation.</ param>        
55           // / <param n ame="promp tforDelete ">When Tru e, the use r will be  prompted t o delete a ll        
56           // / created  entities.< /param>        
57           pu blic void  Run(Server Connection .Configura tion serve rConfig, b ool prompt ForDelete)        
58           {        
59                try        
60                {        
61                    //<s nippetQuer yConnectio nRolesByEn tityTypeCo de1>        
62                    // C onnect to  the Organi zation ser vice.         
63                    // T he using s tatement a ssures tha t the serv ice proxy  will be pr operly dis posed.        
64                    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 ))        
65                    {        
66                         // This st atement is  required  to enable  early-boun d type sup port.        
67                         _servicePr oxy.Enable ProxyTypes ();        
68          
69                         // Define  some anony mous types  to define  the range          
70                         // of poss ible conne ction prop erty value s.        
71                         var Catego ries = new        
72                         {        
73                             Busine ss = 1,        
74                             Family  = 2,        
75                             Social  = 3,        
76                             Sales  = 4,        
77                             Other  = 5        
78                         };        
79          
80                         // Create  a Connecti on Role.        
81                         Connection Role setup Connection Role = new  Connectio nRole        
82                         {        
83                             Name =  "Example  Connection  Role",        
84                             Catego ry = new O ptionSetVa lue(Catego ries.Busin ess),        
85                         };        
86          
87                         _connectio nRoleId =  _servicePr oxy.Create (setupConn ectionRole );        
88                         setupConne ctionRole. Id = _conn ectionRole Id;        
89          
90                         Console.Wr iteLine("C reated {0} .", setupC onnectionR ole.Name);        
91          
92                         // Query f or all Con nection Ro les.        
93                         QueryExpre ssion allQ uery = new  QueryExpr ession        
94                         {        
95                             Entity Name = Con nectionRol e.EntityLo gicalName,        
96                             Column Set = new  ColumnSet( "connectio nroleid",  "name"),        
97                             Distin ct = true,        
98                             LinkEn tities =         
99                             {        
100                                 ne w LinkEnti ty        
101                                 {        
102                                      LinkToEn tityName =          
103                                      Connecti onRoleObje ctTypeCode .EntityLog icalName,        
104                                      LinkToAt tributeNam e = "conne ctionrolei d",        
105                                      LinkFrom EntityName  = Connect ionRole.En tityLogica lName,        
106                                      LinkFrom AttributeN ame = "con nectionrol eid",        
107                                      LinkCrit eria = new  FilterExp ression        
108                                      {        
109                                          Filt erOperator  = Logical Operator.A nd,        
110                                          // S et a condi tion to on ly get con nection ro les          
111                                          // r elated to  all entiti es (object  type code  = 0).        
112                                          Cond itions =         
113                                          {        
114                                               new Condit ionExpress ion         
115                                               {        
116                                                    Attri buteName =  "associat edobjectty pecode",        
117                                                    Opera tor = Cond itionOpera tor.Equal,        
118                                                    Value s = { 0 }        
119                                               }        
120                                          }        
121                                      }        
122                                 }        
123                             }        
124                         };        
125          
126                         EntityColl ection res ults = _se rviceProxy .RetrieveM ultiple(al lQuery);        
127          
128                         // Here yo u could pe rform oper ations on  all of         
129                         // the con nectionrol es found b y the quer y.        
130          
131                         Console.Wr iteLine("R etrieved { 0} unassoc iated conn ectionrole  instance( s).",        
132                             result s.Entities .Count);        
133          
134                         // Query t o find rol es which a pply only  to account s.        
135                         QueryExpre ssion acco untQuery =  new Query Expression        
136                         {        
137                             Entity Name = Con nectionRol e.EntityLo gicalName,        
138                             Column Set = new  ColumnSet( "connectio nroleid",  "name"),        
139                             Distin ct = true,        
140                             LinkEn tities =         
141                             {        
142                                 ne w LinkEnti ty        
143                                 {        
144                                      LinkToEn tityName =          
145                                      Connecti onRoleObje ctTypeCode .EntityLog icalName,        
146                                      LinkToAt tributeNam e = "conne ctionrolei d",        
147                                      LinkFrom EntityName  = Connect ionRole.En tityLogica lName,        
148                                      LinkFrom AttributeN ame = "con nectionrol eid",        
149                                      LinkCrit eria = new  FilterExp ression        
150                                      {        
151                                          Filt erOperator  = Logical Operator.A nd,        
152                                          // S et a condi tion to on ly get con nection ro les          
153                                          // r elated to  accounts ( object typ e code = 1 ).        
154                                          Cond itions =         
155                                          {        
156                                               new Condit ionExpress ion         
157                                               {        
158                                                    Attri buteName =  "associat edobjectty pecode",        
159                                                    Opera tor = Cond itionOpera tor.In,        
160                                                    Value s = { Acco unt.Entity LogicalNam e }        
161                                               }        
162                                          }        
163                                      }        
164                                 }        
165                             }        
166                         };        
167          
168                         results =  _servicePr oxy.Retrie veMultiple (accountQu ery);        
169          
170                         Console.Wr iteLine("R etrieved { 0} account -only conn ectionrole  instance( s).",        
171                             result s.Entities .Count);        
172          
173                         // Create  a related  Connection  Role Obje ct Type Co de record  for         
174                         // Account .        
175                         Connection RoleObject TypeCode s etupAccoun tConnectio nRoleTypeC ode        
176                             = new  Connection RoleObject TypeCode        
177                             {        
178                                 Co nnectionRo leId = new  EntityRef erence(        
179                                      Connecti onRole.Ent ityLogical Name, _con nectionRol eId),        
180                                 As sociatedOb jectTypeCo de = Accou nt.EntityL ogicalName        
181                             };        
182          
183                         setupAccou ntConnecti onRoleType Code.Id =         
184                             _servi ceProxy.Cr eate(setup AccountCon nectionRol eTypeCode) ;        
185          
186                         Console.Wr ite("Creat ed a relat ed Connect ion Role O bject Type  Code");        
187                         Console.Wr ite(" reco rd for Acc ount.");        
188          
189                         // Run the  query to  find unass ociated co nnectionro les again.        
190                         results =  _servicePr oxy.Retrie veMultiple (allQuery) ;        
191                                
192                         Console.Wr iteLine(@" Retrieved  {0} unasso ciated con nectionrol e instance (s).",        
193                             result s.Entities .Count);        
194          
195                         // Run the  account-o nly query  again.        
196                         results =  _servicePr oxy.Retrie veMultiple (accountQu ery);        
197          
198                         Console.Wr iteLine("R etrieved { 0} account -only conn ectionrole  instance( s).",        
199                             result s.Entities .Count);        
200          
201                         // Remove  the link f rom accoun t entity.        
202                         _servicePr oxy.Delete (Connectio nRoleObjec tTypeCode. EntityLogi calName,         
203                             setupA ccountConn ectionRole TypeCode.I d);        
204          
205                         Console.Wr iteLine("R emoved lin k from con nectionrol e to accou nt entity. ");        
206          
207                         // Run the  query to  find unass ociated co nnectionro les again.        
208                         results =  _servicePr oxy.Retrie veMultiple (allQuery) ;        
209          
210                         Console.Wr iteLine("R etrieved { 0} unassoc iated conn ectionrole  instance( s).",        
211                             result s.Entities .Count);        
212          
213                         // Run the  account-o nly query  again.        
214                         results =  _servicePr oxy.Retrie veMultiple (accountQu ery);        
215          
216                         Console.Wr iteLine("R etrieved { 0} account -only conn ectionrole  instance( s).",        
217                             result s.Entities .Count);        
218          
219                         DeleteRequ iredRecord s(promptFo rDelete);        
220                    }        
221                    //</ snippetQue ryConnecti onRolesByE ntityTypeC ode1>        
222                }        
223                // Catch  any servi ce fault e xceptions  that Micro soft Dynam ics CRM th rows.        
224                catch (F aultExcept ion<Micros oft.Xrm.Sd k.Organiza tionServic eFault>)        
225                {        
226                    // Y ou can han dle an exc eption her e or pass  it back to  the calli ng method.        
227                    thro w;        
228                }        
229           }        
230          
231           // / <summary >        
232           // / Deletes  any entity  records t hat were c reated for  this samp le.        
233           // / <param n ame="promp t">Indicat es whether  to prompt  the user         
234           // / to delet e the reco rds create d in this  sample.</p aram>        
235           // / </summar y>        
236           pu blic void  DeleteRequ iredRecord s(bool pro mpt)        
237           {        
238                bool toB eDeleted =  true;        
239          
240                if (prom pt)        
241                {        
242                    // A sk the use r if the c reated ent ities shou ld be dele ted.        
243                    Cons ole.Write( "\nDo you  want these  entity re cords dele ted? (y/n)  [y]: ");        
244                    Stri ng answer  = Console. ReadLine() ;        
245                    if ( answer.Sta rtsWith("y ") ||        
246                         answer.Sta rtsWith("Y ") ||        
247                         answer ==  String.Emp ty)        
248                    {        
249                         toBeDelete d = true;        
250                    }        
251                    else        
252                    {        
253                         toBeDelete d = false;        
254                    }        
255                }        
256          
257                if (toBe Deleted)        
258                {        
259                    // D elete all  records cr eated in t his sample .        
260                    _ser viceProxy. Delete(Con nectionRol e.EntityLo gicalName,  _connecti onRoleId);        
261          
262                    Cons ole.WriteL ine("Entit y record(s ) have bee n deleted. ");        
263                }        
264           }        
265          
266           #e ndregion H ow To Samp le Code        
267          
268           #r egion Main        
269           // / <summary >        
270           // / Standard  Main() me thod used  by most SD K samples.        
271           // / </summar y>        
272           // / <param n ame="args" ></param>        
273           st atic publi c void Mai n(string[]  args)        
274           {        
275                try        
276                {        
277                    // O btain the  target org anization' s Web addr ess and cl ient logon          
278                    // c redentials  from the  user.        
279                    Serv erConnecti on serverC onnect = n ew ServerC onnection( );        
280                    Serv erConnecti on.Configu ration con fig = serv erConnect. GetServerC onfigurati on();        
281          
282                    Quer yConnectio nRolesByEn tityTypeCo de app = n ew QueryCo nnectionRo lesByEntit yTypeCode( );        
283                    app. Run(config , true);        
284                }        
285          
286                catch (F aultExcept ion<Micros oft.Xrm.Sd k.Organiza tionServic eFault> ex )        
287                {        
288                    Cons ole.WriteL ine("The a pplication  terminate d with an  error.");        
289                    Cons ole.WriteL ine("Times tamp: {0}" , ex.Detai l.Timestam p);        
290                    Cons ole.WriteL ine("Code:  {0}", ex. Detail.Err orCode);        
291                    Cons ole.WriteL ine("Messa ge: {0}",  ex.Detail. Message);        
292                    Cons ole.WriteL ine("Plugi n Trace: { 0}", ex.De tail.Trace Text);        
293                    Cons ole.WriteL ine("Inner  Fault: {0 }",        
294                         null == ex .Detail.In nerFault ?  "No Inner  Fault" :  "Has Inner  Fault");        
295                }        
296                catch (S ystem.Time outExcepti on ex)        
297                {        
298                    Cons ole.WriteL ine("The a pplication  terminate d with an  error.");        
299                    Cons ole.WriteL ine("Messa ge: {0}",  ex.Message );        
300                    Cons ole.WriteL ine("Stack  Trace: {0 }", ex.Sta ckTrace);        
301                    Cons ole.WriteL ine("Inner  Fault: {0 }",        
302                         null == ex .InnerExce ption.Mess age ? "No  Inner Faul t" : ex.In nerExcepti on.Message );        
303                }        
304                catch (S ystem.Exce ption ex)        
305                {        
306                    Cons ole.WriteL ine("The a pplication  terminate d with an  error.");        
307                    Cons ole.WriteL ine(ex.Mes sage);        
308          
309                    // D isplay the  details o f the inne r exceptio n.        
310                    if ( ex.InnerEx ception !=  null)        
311                    {        
312                         Console.Wr iteLine(ex .InnerExce ption.Mess age);        
313          
314                         FaultExcep tion<Micro soft.Xrm.S dk.Organiz ationServi ceFault> f e        
315                             = ex.I nnerExcept ion        
316                             as Fau ltExceptio n<Microsof t.Xrm.Sdk. Organizati onServiceF ault>;        
317                         if (fe !=  null)        
318                         {        
319                             Consol e.WriteLin e("Timesta mp: {0}",  fe.Detail. Timestamp) ;        
320                             Consol e.WriteLin e("Code: { 0}", fe.De tail.Error Code);        
321                             Consol e.WriteLin e("Message : {0}", fe .Detail.Me ssage);        
322                             Consol e.WriteLin e("Plugin  Trace: {0} ", fe.Deta il.TraceTe xt);        
323                             Consol e.WriteLin e("Inner F ault: {0}" ,        
324                                nul l == fe.De tail.Inner Fault ? "N o Inner Fa ult" : "Ha s Inner Fa ult");        
325                         }        
326                    }        
327                }        
328                // Addit ional exce ptions to  catch: Sec urityToken Validation Exception,  ExpiredSe curityToke nException ,        
329                // Secur ityAccessD eniedExcep tion, Mess ageSecurit yException , and Secu rityNegoti ationExcep tion.        
330          
331                finally        
332                {        
333          
334                    Cons ole.WriteL ine("Press  <Enter> t o exit.");        
335                    Cons ole.ReadLi ne();        
336                }        
337          
338           }        
339           #e ndregion M ain        
340       }        
341   }        
342   //</snippe tQueryConn ectionRole sByEntityT ypeCode>