404. Araxis Merge File Comparison Report

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

404.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\GeneralProgramming\EarlyBound CreateAndShareAccessTeam.cs Tue Dec 20 19:51:45 2016 UTC
2 Wed Feb 1 19:56:33 2017 UTC

404.2 Comparison summary

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

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

404.4 Active regular expressions

No regular expressions were active.

404.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 CreateAndS hareAccess Team>        
17   using Syst em;        
18   using Syst em.Collect ions.Gener ic;        
19   using Syst em.Service Model;        
20          
21   // These n amespaces  are found  in the Mic rosoft.Xrm .Sdk.dll a ssembly.        
22   using Micr osoft.Crm. Sdk.Messag es;        
23   using Micr osoft.Xrm. Sdk;        
24   using Micr osoft.Xrm. Sdk.Client ;        
25          
26   namespace  Microsoft. Crm.Sdk.Sa mples        
27   {        
28       /// <s ummary>        
29       /// De monstrates  creating  an access  team and g ranting th at team pr ivileges t o        
30       /// ac cess an ac count reco rd. All me mbers of t hat team r eceive acc ess to tha t record.        
31       ///         
32       /// At  run-time,  you will  be given t he option  to delete  all the        
33       /// da tabase rec ords creat ed by this  program.        
34       /// </ summary>        
35       /// <r emarks>Imp ortant mes sages used  in this s ample:         
36       /// Ad dMembersTe am, Remove MembersTea m, GrantAc cessReques t.</remark s>        
37       public  class Cre ateAndShar eAccessTea m        
38       {        
39           #r egion Clas s Level Me mbers        
40           // / <summary >        
41           // / Stores t he organiz ation serv ice interf ace.        
42           // / </summar y>        
43           pr ivate Orga nizationSe rviceProxy  _serviceP roxy;        
44          
45           //  Define th e IDs need ed for thi s sample.        
46           pr ivate Guid  _accountI d;        
47           pr ivate Guid  _teamId;        
48           pr ivate Guid  _currentU serId;                 
49          
50           //  System us ers in the  team.        
51           pu blic List< Guid> sale sPersons;                
52           #e ndregion C lass Level  Members        
53          
54           #r egion How  To Sample  Code        
55           pu blic void  Run(Server Connection .Configura tion serve rConfig, b ool prompt ForDelete)        
56           {        
57                try        
58                {        
59                    // C onnect to  the Organi zation ser vice.         
60                    // T he using s tatement a ssures tha t the serv ice proxy  will be pr operly dis posed.        
61                    usin g (_servic eProxy = n ew Organiz ationServi ceProxy(se rverConfig .Organizat ionUri, se rverConfig .HomeRealm Uri,        
62                                                                              s erverConfi g.Credenti als, serve rConfig.De viceCreden tials))        
63                    {        
64                         String lda pPath = St ring.Empty ;        
65                         Guid busin essUnitId;        
66          
67                         // This st atement is  required  to enable  early-boun d type sup port.        
68                         _servicePr oxy.Enable ProxyTypes ();        
69          
70                         // Call th is method  to create  any data t hat this s ample requ ires.        
71                         CreateRequ iredRecord s();        
72          
73                         // Retriev e the sale s people t hat will b e added to  the team.        
74                         salesPerso ns = Syste mUserProvi der.Retrie veSalesper sons(_serv iceProxy,  ref ldapPa th);        
75          
76                         // Get the  ID's of t he current  user and  business u nit.        
77                         var who =  new WhoAmI Request();        
78                         var whoRes ponse = (W hoAmIRespo nse)_servi ceProxy.Ex ecute(who) ;        
79                         _currentUs erId = who Response.U serId;        
80                         businessUn itId = who Response.B usinessUni tId;        
81          
82                         //<snippet CreateAndS hareAccess Team1>        
83                         // Create  a access t eam.        
84                         var team =  new Team        
85                         {        
86                             Admini stratorId  = new Enti tyReferenc e(        
87                                 "s ystemuser" , _current UserId),        
88                             Name =  "UserAcce ss Test Te am",        
89                             Busine ssUnitId =  new Entit yReference (        
90                                 "b usinessuni t", busine ssUnitId),        
91                             TeamTy pe = new O ptionSetVa lue((int)T eamTeamTyp e.Access),        
92                         };        
93          
94                         _teamId =  _servicePr oxy.Create (team);        
95                         Console.Wr iteLine("C reated an  access tea m named '{ 0}'.", tea m.Name);        
96          
97                         // Add two  sales peo ple to the  access te am.        
98                         var addToT eamRequest  = new Add MembersTea mRequest        
99                         {        
100                             TeamId  = _teamId ,        
101                             Member Ids = new[ ] { salesP ersons[0],  salesPers ons[1] }        
102                         };        
103                         _servicePr oxy.Execut e(addToTea mRequest);        
104                         Console.Wr iteLine("A dded two s ales peopl e to the t eam.");        
105                                
106                         // Grant t he team re ad/write a ccess to a n account.        
107                         var accoun tReference  = new Ent ityReferen ce(Account .EntityLog icalName,  _accountId );        
108                         var teamRe ference =  new Entity Reference( Team.Entit yLogicalNa me, _teamI d);        
109                         var grantA ccessReque st = new G rantAccess Request        
110                         {        
111                             Princi palAccess  = new Prin cipalAcces s        
112                             {        
113                                 Ac cessMask =  AccessRig hts.ReadAc cess | Acc essRights. WriteAcces s,        
114                                 Pr incipal =  teamRefere nce        
115                             },        
116                             Target  = account Reference        
117                         };        
118                         _servicePr oxy.Execut e(grantAcc essRequest );        
119                         Console.Wr iteLine("G ranted rea d/write ac cess on th e account  record to  the team." );        
120                         //</snippe tCreateAnd ShareAcces sTeam1>        
121          
122                         // Retriev e and disp lay access  informati on for the  account.        
123                         RetrieveAn dDisplayEn tityAccess (accountRe ference);        
124          
125                         // Display  the accou nt access  for the te am and its  members.        
126                         var curren tUserRefer ence = new  EntityRef erence(        
127                             System User.Entit yLogicalNa me, _curre ntUserId);        
128                         RetrieveAn dDisplayPr incipalAcc ess(accoun tReference , currentU serReferen ce,        
129                             "Curre nt User");        
130                         var firstS alesPerson Reference  = new Enti tyReferenc e(        
131                             System User.Entit yLogicalNa me, salesP ersons[0]) ;        
132                         RetrieveAn dDisplayPr incipalAcc ess(accoun tReference , firstSal esPersonRe ference,        
133                             "Sales  Person");        
134                         var second SalesPerso nReference  = new Ent ityReferen ce(        
135                             System User.Entit yLogicalNa me, salesP ersons[1]) ;        
136                         RetrieveAn dDisplayPr incipalAcc ess(accoun tReference , secondSa lesPersonR eference,        
137                             "Sales  Person");        
138                                
139                         // Delete  all record s created  by this sa mple.        
140                         DeleteRequ iredRecord s(promptFo rDelete);        
141                    }        
142                }        
143          
144                // Catch  any servi ce fault e xceptions  that Micro soft Dynam ics CRM th rows.        
145                catch (F aultExcept ion<Micros oft.Xrm.Sd k.Organiza tionServic eFault>)        
146                {        
147                    // Y ou can han dle an exc eption her e or pass  it back to  the calli ng method.        
148                    thro w;        
149                }        
150           }        
151          
152           // / <summary >        
153           // / Retrieve  and displ ay entity  access inf ormation.        
154           // / </summar y>        
155           // / <param n ame="entit yReference "></param>        
156           pr ivate void  RetrieveA ndDisplayE ntityAcces s(EntityRe ference en tityRefere nce)        
157           {        
158                var acce ssRequest  = new Retr ieveShared Principals AndAccessR equest        
159                {        
160                    Targ et = entit yReference        
161                };        
162          
163                // The R etrieveSha redPrincip alsAndAcce ssResponse  returns a n entity r eference        
164                // that  has a Logi calName of  "user" wh en returni ng access  informatio n for a        
165                // team.        
166                var acce ssResponse  = (Retrie veSharedPr incipalsAn dAccessRes ponse)        
167                    _ser viceProxy. Execute(ac cessReques t);        
168          
169                Console. WriteLine( "The follo wing have  the specif ied grante d access t o the enti ty.");        
170          
171                foreach  (var princ ipalAccess  in access Response.P rincipalAc cesses)        
172                {        
173                    Cons ole.WriteL ine("\t{0} :\r\n\t\t{ 1}",        
174                         String.For mat("{0} w ith GUID { 1}", princ ipalAccess .Principal .LogicalNa me,        
175                    prin cipalAcces s.Principa l.Id), pri ncipalAcce ss.AccessM ask);        
176                }        
177                Console. WriteLine( );        
178           }        
179          
180           // / <summary >        
181           // / Retrives  and displ ay princip al access  informatio n.        
182           // / </summar y>        
183           // / <param n ame="entit yReference "></param>        
184           // / <param n ame="princ ipal"></pa ram>        
185           // / <param n ame="addit ionalIdent ifier"></p aram>        
186           pr ivate void  RetrieveA ndDisplayP rincipalAc cess(Entit yReference  entityRef erence,        
187                EntityRe ference pr incipal, S tring addi tionalIden tifier)        
188           {        
189                var prin cipalAcces sReq = new  RetrieveP rincipalAc cessReques t        
190                {        
191                    Prin cipal = pr incipal,        
192                    Targ et = entit yReference        
193                };        
194                var prin cipalAcces sRes = (Re trievePrin cipalAcces sResponse)        
195                    _ser viceProxy. Execute(pr incipalAcc essReq);        
196          
197                Console. WriteLine( "Access ri ghts of {0 } ({1}) on  the entit y: {2}\r\n ",        
198                    Stri ng.Format( "{0} with  GUID {1}",  principal .LogicalNa me,        
199                    prin cipal.Id),  additiona lIdentifie r,        
200                    prin cipalAcces sRes.Acces sRights);        
201           }        
202                            
203           // / <summary >        
204           // / Create a ny entity  records th at this sa mple requi res.        
205           // / </summar y>        
206           pu blic void  CreateRequ iredRecord s()        
207           {        
208                // Creat e an accou nt named F ourth Coff ee.        
209                Account  testAccoun t = new Ac count        
210                {        
211                    Name  = "Fourth  Coffee"        
212                };        
213          
214                _account Id = _serv iceProxy.C reate(test Account);        
215          
216                Console. WriteLine( "Created a n account  named '{0} '.", testA ccount.Nam e);        
217                return;        
218           }        
219          
220           // / <summary >        
221           // / Deletes  any entity  records t hat were c reated for  this samp le.        
222           // / <param n ame="promp t">Indicat es whether  to prompt  the user         
223           // / to delet e the reco rds create d in this  sample.</p aram>        
224           // / </summar y>        
225           pu blic void  DeleteRequ iredRecord s(bool pro mpt)        
226           {        
227                bool toB eDeleted =  true;        
228          
229                if (prom pt)        
230                {        
231                    // A sk the use r if the c reated ent ities shou ld be dele ted.        
232                    Cons ole.Write( "\nDo you  want these  entity re cords dele ted? (y/n)  [y]: ");        
233                    Stri ng answer  = Console. ReadLine() ;        
234                    if ( answer.Sta rtsWith("y ") ||        
235                         answer.Sta rtsWith("Y ") ||        
236                         answer ==  String.Emp ty)        
237                    {        
238                         toBeDelete d = true;        
239                    }        
240                    else        
241                    {        
242                         toBeDelete d = false;        
243                    }        
244                }        
245          
246                if (toBe Deleted)        
247                {        
248                    // R emove all  the users  from the t eam before  deleting  the team.        
249                    var  deleteFrom TeamReques t = new Re moveMember sTeamReque st        
250                    {        
251                         TeamId = _ teamId,        
252                         MemberIds  = new[] {  _currentUs erId, sale sPersons[0 ], salesPe rsons[1] }        
253                    };        
254                    _ser viceProxy. Execute(de leteFromTe amRequest) ;        
255          
256                    // D elete reco rds create d in this  sample.        
257                    _ser viceProxy. Delete(Acc ount.Entit yLogicalNa me, _accou ntId);        
258                    _ser viceProxy. Delete(Tea m.EntityLo gicalName,  _teamId);        
259          
260                    Cons ole.WriteL ine("Entit y record(s ) have bee n deleted. ");        
261                }        
262           }        
263          
264           #e ndregion H ow To Samp le Code        
265          
266           #r egion Main        
267           // / <summary >        
268           // / Main. Ru ns the sam ple and pr ovides err or output.        
269           // / <param n ame="args" >Array of  arguments  to Main me thod.</par am>        
270           // / </summar y>        
271           st atic publi c void Mai n(string[]  args)        
272           {        
273          
274                try        
275                {        
276                    // O btain the  target org anization' s Web addr ess and cl ient logon          
277                    // c redentials  from the  user.        
278                    Serv erConnecti on serverC onnect = n ew ServerC onnection( );        
279                    Serv erConnecti on.Configu ration con fig = serv erConnect. GetServerC onfigurati on();        
280          
281                    Crea teAndShare AccessTeam  app = new  CreateAnd ShareAcces sTeam();        
282                    app. Run(config , true);        
283                }        
284                catch (F aultExcept ion<Micros oft.Xrm.Sd k.Organiza tionServic eFault> ex )        
285                {        
286                    Cons ole.WriteL ine("The a pplication  terminate d with an  error.");        
287                    Cons ole.WriteL ine("Times tamp: {0}" , ex.Detai l.Timestam p);        
288                    Cons ole.WriteL ine("Code:  {0}", ex. Detail.Err orCode);        
289                    Cons ole.WriteL ine("Messa ge: {0}",  ex.Detail. Message);        
290                    Cons ole.WriteL ine("Plugi n Trace: { 0}", ex.De tail.Trace Text);        
291                    Cons ole.WriteL ine("Inner  Fault: {0 }",        
292                         null == ex .Detail.In nerFault ?  "No Inner  Fault" :  "Has Inner  Fault");        
293                }        
294                catch (S ystem.Time outExcepti on ex)        
295                {        
296                    Cons ole.WriteL ine("The a pplication  terminate d with an  error.");        
297                    Cons ole.WriteL ine("Messa ge: {0}",  ex.Message );        
298                    Cons ole.WriteL ine("Stack  Trace: {0 }", ex.Sta ckTrace);        
299                    Cons ole.WriteL ine("Inner  Fault: {0 }",        
300                         null == ex .InnerExce ption.Mess age ? "No  Inner Faul t" : ex.In nerExcepti on.Message );        
301                }        
302                catch (S ystem.Exce ption ex)        
303                {        
304                    Cons ole.WriteL ine("The a pplication  terminate d with an  error.");        
305                    Cons ole.WriteL ine(ex.Mes sage);        
306          
307                    // D isplay the  details o f the inne r exceptio n.        
308                    if ( ex.InnerEx ception !=  null)        
309                    {        
310                         Console.Wr iteLine(ex .InnerExce ption.Mess age);        
311          
312                         FaultExcep tion<Micro soft.Xrm.S dk.Organiz ationServi ceFault> f e =        
313                             ex.Inn erExceptio n        
314                             as Fau ltExceptio n<Microsof t.Xrm.Sdk. Organizati onServiceF ault>;        
315                         if (fe !=  null)        
316                         {        
317                             Consol e.WriteLin e("Timesta mp: {0}",  fe.Detail. Timestamp) ;        
318                             Consol e.WriteLin e("Code: { 0}", fe.De tail.Error Code);        
319                             Consol e.WriteLin e("Message : {0}", fe .Detail.Me ssage);        
320                             Consol e.WriteLin e("Plugin  Trace: {0} ", fe.Deta il.TraceTe xt);        
321                             Consol e.WriteLin e("Inner F ault: {0}" ,        
322                                 nu ll == fe.D etail.Inne rFault ? " No Inner F ault" : "H as Inner F ault");        
323                         }        
324                    }        
325                }        
326                finally        
327                {        
328                    Cons ole.WriteL ine("Press  <Enter> t o exit.");        
329                    Cons ole.ReadLi ne();        
330                }        
331          
332           }        
333           #e ndregion M ain        
334          
335       }        
336   }        
337   //</snippe tCreateAnd ShareAcces sTeam>