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

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

202.2 Comparison summary

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

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

202.4 Active regular expressions

No regular expressions were active.

202.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 ctionRoles ByReciproc alRole>        
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 find co nnection r oles by a  reciprocal  connectio nrole.        
38       /// </ summary>        
39       public  class Que ryConnecti onRolesByR eciprocalR ole        
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  _primaryCo nnectionRo leId;        
50           pu blic Guid  _reciproca lConnectio nRoleId;        
51          
52           #e ndregion C lass Level  Members        
53          
54           #r egion How  To Sample  Code        
55           // / <summary >        
56           // / Create a nd configu re the org anization  service pr oxy.        
57           // / Call the  method to  create an y data tha t this sam ple requir es.        
58           // / Query al l connecti on roles t hat have t his role l isted as a  reciproca l role.        
59           // / Optional ly delete  any entity  records t hat were c reated for  this samp le.        
60           // / </summar y>        
61           // / <param n ame="serve rConfig">C ontains se rver conne ction info rmation.</ param>        
62           // / <param n ame="promp tforDelete ">When Tru e, the use r will be  prompted t o delete a ll        
63           // / created  entities.< /param>        
64           pu blic void  Run(Server Connection .Configura tion serve rConfig, b ool prompt ForDelete)        
65           {        
66                try        
67                {        
68                    // C onnect to  the Organi zation ser vice.         
69                    // T he using s tatement a ssures tha t the serv ice proxy  will be pr operly dis posed.        
70                    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 ))        
71                    {        
72                         // This st atement is  required  to enable  early-boun d type sup port.        
73                         _servicePr oxy.Enable ProxyTypes ();        
74          
75                         // Call th e method t o create a ny data th at this sa mple requi res.        
76                         CreateRequ iredRecord s();        
77          
78                         //<snippet QueryConne ctionRoles ByReciproc alRole1>        
79                         // This qu ery retrie ves all co nnection r oles that  have this  role        
80                         // listed  as a recip rocal role .        
81                         QueryExpre ssion quer y = new Qu eryExpress ion        
82                         {        
83                             Entity Name = Con nectionRol e.EntityLo gicalName,        
84                             Column Set = new  ColumnSet( "connectio nroleid"),        
85                             LinkEn tities =         
86                         {        
87                             new Li nkEntity        
88                             {        
89                                 Jo inOperator  = JoinOpe rator.Inne r,        
90                                 Li nkFromEnti tyName =   Connection Role.Entit yLogicalNa me,        
91                                 Li nkFromAttr ibuteName  = "connect ionroleid" ,        
92                                 Li nkToEntity Name = "co nnectionro leassociat ion",        
93                                 Li nkToAttrib uteName =  "connectio nroleid",        
94                                 Li nkCriteria  = new Fil terExpress ion        
95                                 {        
96                                      FilterOp erator = L ogicalOper ator.And,        
97                                      Conditio ns =         
98                                      {        
99                                          new  ConditionE xpression        
100                                          {        
101                                               AttributeN ame = "ass ociatedcon nectionrol eid",        
102                                               Operator =  Condition Operator.E qual,        
103                                               Values = {  _reciproc alConnecti onRoleId }                                                    
104                                          }        
105                                      }        
106                                 }        
107                             }        
108                         }        
109                         };        
110          
111                         EntityColl ection res ults = _se rviceProxy .RetrieveM ultiple(qu ery);        
112          
113                         // TODO: H ere you wo uld perfor m some ope ration on  the retrie ved        
114                         // roles.         
115                         //</snippe tQueryConn ectionRole sByRecipro calRole1>           
116          
117                         Console.Wr iteLine("R etrieved { 0} connect ionrole in stance.",  results.En tities.Cou nt);        
118          
119                         DeleteRequ iredRecord s(promptFo rDelete);        
120          
121                    }        
122                }        
123                // Catch  any servi ce fault e xceptions  that Micro soft Dynam ics CRM th rows.        
124                catch (F aultExcept ion<Micros oft.Xrm.Sd k.Organiza tionServic eFault>)        
125                {        
126                    // Y ou can han dle an exc eption her e or pass  it back to  the calli ng method.        
127                    thro w;        
128                }        
129           }        
130          
131           // / <summary >        
132           // / This met hod create s any enti ty records  that this  sample re quires.        
133           // / Create a  primary c onnection  role insta nce.         
134           // / Create a  reciproca l connecti on role in stance.        
135           // / Associat e the conn ection rol es.        
136           // / </summar y>        
137           pu blic void  CreateRequ iredRecord s()        
138           {        
139                // Defin e some ano nymous typ es to defi ne the ran ge         
140                // of po ssible con nection pr operty val ues.        
141                var Cate gories = n ew        
142                {        
143                    Busi ness = 1,        
144                    Fami ly = 2,        
145                    Soci al = 3,        
146                    Sale s = 4,        
147                    Othe r = 5        
148                };        
149          
150                // Creat e the Conn ection Rol es.         
151                // Creat e the prim ary connec tion Role  instance.        
152                Connecti onRole set upPrimaryC onnectionR ole = new  Connection Role        
153                {        
154                    Name  = "Exampl e Primary  Connection  Role",        
155                    Cate gory = new  OptionSet Value(Cate gories.Bus iness),        
156                };        
157          
158                _primary Connection RoleId = _ servicePro xy.Create( setupPrima ryConnecti onRole);        
159                Console. WriteLine( "Created { 0}.", setu pPrimaryCo nnectionRo le.Name);        
160          
161                // Creat e a relate d Connecti on Role Ob ject Type  Code recor d for Acco unt        
162                // on th e primary  role.        
163                Connecti onRoleObje ctTypeCode  accountPr imaryConne ctionRoleT ypeCode        
164                    = ne w Connecti onRoleObje ctTypeCode        
165                    {        
166                         Connection RoleId = n ew EntityR eference(        
167                             Connec tionRole.E ntityLogic alName, _p rimaryConn ectionRole Id),        
168                         Associated ObjectType Code = Acc ount.Entit yLogicalNa me        
169                    };        
170          
171                _service Proxy.Crea te(account PrimaryCon nectionRol eTypeCode) ;        
172                Console. WriteLine( @"Created  a related  Connection  Role Obje ct Type Co de         
173                                      record f or Account  on the pr imary role .");        
174                        
175                // Creat e another  Connection  Role.        
176                Connecti onRole set upReciproc alConnecti onRole = n ew Connect ionRole        
177                {        
178                    Name  = "Exampl e Reciproc al Connect ion Role",        
179                    Cate gory = new  OptionSet Value(Cate gories.Bus iness),        
180                };        
181          
182                _recipro calConnect ionRoleId  = _service Proxy.Crea te(setupRe ciprocalCo nnectionRo le);        
183                Console. WriteLine( "Created { 0}.", setu pReciproca lConnectio nRole.Name );        
184          
185                // Creat e a relate d Connecti on Role Ob ject Type  Code recor d for Acco unt        
186                // on th e related  role.        
187                Connecti onRoleObje ctTypeCode  accountRe ciprocalCo nnectionRo leTypeCode        
188                    = ne w Connecti onRoleObje ctTypeCode        
189                    {        
190                         Connection RoleId = n ew EntityR eference(        
191                             Connec tionRole.E ntityLogic alName, _r eciprocalC onnectionR oleId),        
192                         Associated ObjectType Code = Acc ount.Entit yLogicalNa me        
193                    };        
194          
195                _service Proxy.Crea te(account Reciprocal Connection RoleTypeCo de);        
196                Console. WriteLine( @"Created  a related  Connection  Role Obje ct Type Co de         
197                                      record f or Account  on the re lated role .");        
198          
199                // Assoc iate the c onnection  roles.        
200                Associat eRequest a ssociateCo nnectionRo les =        
201                    new  AssociateR equest        
202                    {        
203                         Target = n ew EntityR eference(C onnectionR ole.Entity LogicalNam e,        
204                             _prima ryConnecti onRoleId),        
205                         RelatedEnt ities = ne w EntityRe ferenceCol lection()        
206                         {        
207                             new En tityRefere nce(Connec tionRole.E ntityLogic alName,        
208                             _recip rocalConne ctionRoleI d)        
209                         },        
210                         // The nam e of the r elationshi p connecti on role as sociation         
211                         // relatio nship in M S CRM        
212                         Relationsh ip = new R elationshi p()        
213                         {        
214                             Primar yEntityRol e = Entity Role.Refer encing, //  Referenci ng or Refe renced bas ed on N:1  or 1:N ref lexive rel ationship.        
215                             Schema Name = "co nnectionro leassociat ion_associ ation"        
216                         }        
217                    };        
218          
219                _service Proxy.Exec ute(associ ateConnect ionRoles);        
220          
221                return;        
222           }        
223          
224           // / <summary >        
225           // / Deletes  any entity  records t hat were c reated for  this samp le.        
226           // / <param n ame="promp t">Indicat es whether  to prompt  the user         
227           // / to delet e the reco rds create d in this  sample.</p aram>        
228           // / </summar y>        
229           pu blic void  DeleteRequ iredRecord s(bool pro mpt)        
230           {        
231                bool del eteRecords  = true;        
232          
233                if (prom pt)        
234                {        
235                    Cons ole.WriteL ine("\nDo  you want t hese entit y records  deleted? ( y/n)");        
236                    Stri ng answer  = Console. ReadLine() ;        
237          
238                    dele teRecords  = (answer. StartsWith ("y") || a nswer.Star tsWith("Y" ));        
239                }        
240          
241                if (dele teRecords)        
242                {        
243                    _ser viceProxy. Delete(Con nectionRol e.EntityLo gicalName,  _primaryC onnectionR oleId);        
244                    _ser viceProxy. Delete(Con nectionRol e.EntityLo gicalName,  _reciproc alConnecti onRoleId);        
245          
246                    Cons ole.WriteL ine("Entit y records  have been  deleted.") ;        
247                }        
248           }        
249          
250           #e ndregion H ow To Samp le Code        
251          
252           #r egion Main        
253           // / <summary >        
254           // / Standard  Main() me thod used  by most SD K samples.        
255           // / </summar y>        
256           // / <param n ame="args" ></param>        
257           st atic publi c void Mai n(string[]  args)        
258           {        
259                try        
260                {        
261                    // O btain the  target org anization' s Web addr ess and cl ient logon          
262                    // c redentials  from the  user.        
263                    Serv erConnecti on serverC onnect = n ew ServerC onnection( );        
264                    Serv erConnecti on.Configu ration con fig = serv erConnect. GetServerC onfigurati on();        
265          
266                    Quer yConnectio nRolesByRe ciprocalRo le app = n ew QueryCo nnectionRo lesByRecip rocalRole( );        
267                    app. Run(config , true);        
268                }        
269          
270                catch (F aultExcept ion<Micros oft.Xrm.Sd k.Organiza tionServic eFault> ex )        
271                {        
272                    Cons ole.WriteL ine("The a pplication  terminate d with an  error.");        
273                    Cons ole.WriteL ine("Times tamp: {0}" , ex.Detai l.Timestam p);        
274                    Cons ole.WriteL ine("Code:  {0}", ex. Detail.Err orCode);        
275                    Cons ole.WriteL ine("Messa ge: {0}",  ex.Detail. Message);        
276                    Cons ole.WriteL ine("Plugi n Trace: { 0}", ex.De tail.Trace Text);        
277                    Cons ole.WriteL ine("Inner  Fault: {0 }",        
278                         null == ex .Detail.In nerFault ?  "No Inner  Fault" :  "Has Inner  Fault");        
279                }        
280                catch (S ystem.Time outExcepti on ex)        
281                {        
282                    Cons ole.WriteL ine("The a pplication  terminate d with an  error.");        
283                    Cons ole.WriteL ine("Messa ge: {0}",  ex.Message );        
284                    Cons ole.WriteL ine("Stack  Trace: {0 }", ex.Sta ckTrace);        
285                    Cons ole.WriteL ine("Inner  Fault: {0 }",        
286                         null == ex .InnerExce ption.Mess age ? "No  Inner Faul t" : ex.In nerExcepti on.Message );        
287                }        
288                catch (S ystem.Exce ption ex)        
289                {        
290                    Cons ole.WriteL ine("The a pplication  terminate d with an  error.");        
291                    Cons ole.WriteL ine(ex.Mes sage);        
292          
293                    // D isplay the  details o f the inne r exceptio n.        
294                    if ( ex.InnerEx ception !=  null)        
295                    {        
296                         Console.Wr iteLine(ex .InnerExce ption.Mess age);        
297          
298                         FaultExcep tion<Micro soft.Xrm.S dk.Organiz ationServi ceFault> f e        
299                             = ex.I nnerExcept ion        
300                             as Fau ltExceptio n<Microsof t.Xrm.Sdk. Organizati onServiceF ault>;        
301                         if (fe !=  null)        
302                         {        
303                             Consol e.WriteLin e("Timesta mp: {0}",  fe.Detail. Timestamp) ;        
304                             Consol e.WriteLin e("Code: { 0}", fe.De tail.Error Code);        
305                             Consol e.WriteLin e("Message : {0}", fe .Detail.Me ssage);        
306                             Consol e.WriteLin e("Plugin  Trace: {0} ", fe.Deta il.TraceTe xt);        
307                             Consol e.WriteLin e("Inner F ault: {0}" ,        
308                                 nu ll == fe.D etail.Inne rFault ? " No Inner F ault" : "H as Inner F ault");        
309                         }        
310                    }        
311                }        
312                // Addit ional exce ptions to  catch: Sec urityToken Validation Exception,  ExpiredSe curityToke nException ,        
313                // Secur ityAccessD eniedExcep tion, Mess ageSecurit yException , and Secu rityNegoti ationExcep tion.        
314          
315                finally        
316                {        
317                    Cons ole.WriteL ine("Press  <Enter> t o exit.");        
318                    Cons ole.ReadLi ne();        
319                }        
320          
321           }        
322           #e ndregion M ain        
323       }        
324   }        
325   //</snippe tQueryConn ectionRole sByRecipro calRole>