276. Araxis Merge File Comparison Report

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

276.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\UsersAndRoles RemoveRoleFromUser.cs Tue Dec 20 19:51:44 2016 UTC
2 Wed Feb 1 19:56:28 2017 UTC

276.2 Comparison summary

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

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

276.4 Active regular expressions

No regular expressions were active.

276.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 RemoveRole FromUser>        
17   using Syst em;        
18   using Syst em.Service Model;        
19   using Syst em.Service Model.Desc ription;        
20          
21   // These n amespaces  are found  in the Mic rosoft.Xrm .Sdk.dll a ssembly        
22   // located  in the SD K\bin fold er of the  SDK downlo ad.        
23   using Micr osoft.Xrm. Sdk;        
24   using Micr osoft.Xrm. Sdk.Query;        
25   using Micr osoft.Xrm. Sdk.Client ;        
26   using Micr osoft.Crm. Sdk.Messag es;        
27          
28   namespace  Microsoft. Crm.Sdk.Sa mples        
29   {        
30       /// <s ummary>        
31       /// De monstrates  how to do  basic rol e associat ion with t he system  user.        
32       /// </ summary>        
33       /// <r emarks>        
34       /// At  run-time,  you will  be given t he option  to revert  the role         
35       /// as sociation  created by  this prog ram.</rema rks>        
36       public  class Rem oveRoleFro mUser        
37       {        
38           #r egion Clas s Level Me mbers        
39          
40           //  Define th e IDs need ed for thi s sample.        
41           pr ivate Guid  _userId;        
42           pr ivate Stri ng _givenR ole = "sal esperson";        
43           pr ivate Orga nizationSe rviceProxy  _serviceP roxy;        
44          
45           #e ndregion C lass Level  Members        
46          
47           #r egion How  To Sample  Code        
48           // / <summary >        
49           // / This met hod first  connects t o the Orga nization s ervice. Af terwards,  it        
50           // / creates/ retrieves  a system u ser, and        
51           // / updates  the system  user to a ssociate w ith the sa lesperson  role.         
52           // / Note: Cr eating a u ser is onl y supporte d        
53           // / in an on -premises/ active dir ectory env ironment.        
54           // / </summar y>        
55           // / <param n ame="serve rConfig">C ontains se rver conne ction info rmation.</ param>        
56           // / <param n ame="promp tforDelete ">When Tru e, the use r will be  prompted t o delete a ll        
57           // / created  entities.< /param>        
58           pu blic void  Run(Server Connection .Configura tion serve rConfig, b ool prompt forDelete)        
59           {        
60                try        
61                {        
62                    //<s nippetRemo veRoleFrom User1>        
63                    // C onnect to  the Organi zation ser vice.         
64                    // T he using s tatement a ssures tha t the serv ice proxy  is properl y disposed .        
65                    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 ))        
66                    {        
67                         _servicePr oxy.Enable ProxyTypes ();        
68          
69                         CreateRequ iredRecord s();        
70          
71                         // Retriev e a user.        
72                         SystemUser  user = _s erviceProx y.Retrieve (SystemUse r.EntityLo gicalName,        
73                             _userI d, new Col umnSet(new  String[]  { "systemu serid", "f irstname",  "lastname " })).ToEn tity<Syste mUser>();        
74          
75                         if (user ! = null)        
76                         {        
77                             Consol e.WriteLin e("{1} {0}  user acco unt is ret rieved.",  user.First Name, user .LastName) ;        
78                             // Fin d the role .        
79                             QueryE xpression  query = ne w QueryExp ression        
80                             {        
81                                 En tityName =  "role",        
82                                 Co lumnSet =  new Column Set("rolei d"),        
83                                 Cr iteria = n ew FilterE xpression        
84                                 {        
85                                      Conditio ns =        
86                                      {        
87               
88                                          new  ConditionE xpression        
89                                          {        
90                                               AttributeN ame = "nam e",        
91                                               Operator =  Condition Operator.E qual,        
92                                               Values = { _givenRole }        
93                                          }        
94                                      }        
95                                 }        
96                             };        
97          
98                             // Get  the role.        
99                             Entity Collection  roles = _ servicePro xy.Retriev eMultiple( query);        
100          
101                             // Dis associate  the role.        
102                             if (ro les.Entiti es.Count >  0)        
103                             {        
104                                 Ro le salesRo le = _serv iceProxy.R etrieveMul tiple(quer y).Entitie s[0].ToEnt ity<Role>( );        
105          
106                                 Co nsole.Writ eLine("Rol e {0} is r etrieved." , _givenRo le);        
107          
108                                 _s erviceProx y.Disassoc iate(        
109                                               "systemuse r",        
110                                               user.Id,        
111                                               new Relati onship("sy stemuserro les_associ ation"),        
112                                               new Entity ReferenceC ollection( ) { new En tityRefere nce("role" , salesRol e.Id) });        
113                                 Co nsole.Writ eLine("Rol e {0} is d isassociat ed from us er {1} {2} .", _given Role, user .FirstName , user.Las tName);        
114                             }        
115                         }        
116          
117                    }        
118                    //</ snippetRem oveRoleFro mUser1>        
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           // / Creates  any entity  records t hat this s ample requ ires.        
130           // / </summar y>        
131           pu blic void  CreateRequ iredRecord s()        
132           {        
133                // For t his sample , all requ ired entit ies are cr eated in t he Run() m ethod.        
134                // Creat e/retrieve  a user an d associat e a role.        
135          
136                _userId  = SystemUs erProvider .RetrieveA UserWithou tAnyRoleAs signed(_se rviceProxy );        
137                // Find  the role.        
138                QueryExp ression qu ery = new  QueryExpre ssion        
139                {        
140                    Enti tyName = R ole.Entity LogicalNam e,        
141                    Colu mnSet = ne w ColumnSe t("roleid" ),        
142                    Crit eria = new  FilterExp ression        
143                    {        
144                         Conditions  =        
145                                      {        
146               
147                                          new  ConditionE xpression        
148                                          {        
149                                               AttributeN ame = "nam e",        
150                                               Operator =  Condition Operator.E qual,        
151                                               Values = { _givenRole }        
152                                          }        
153                                      }        
154                    }        
155                };        
156          
157                // Get t he role.        
158                EntityCo llection r oles = _se rviceProxy .RetrieveM ultiple(qu ery);        
159                if (role s.Entities .Count > 0 )        
160                {        
161                    Role  salesRole  = _servic eProxy.Ret rieveMulti ple(query) .Entities[ 0].ToEntit y<Role>();        
162          
163                    // A ssociate t he user wi th the rol e for this  sample.        
164                    if ( salesRole  != null &&  _userId ! = Guid.Emp ty)        
165                    {        
166                         _servicePr oxy.Associ ate(        
167                                      "systemu ser",        
168                                      _userId,        
169                                      new Rela tionship(" systemuser roles_asso ciation"),        
170                                      new Enti tyReferenc eCollectio n() { new  EntityRefe rence(Role .EntityLog icalName,  salesRole. Id) });        
171                    }        
172                }                     
173           }        
174                 
175           #e ndregion H ow To Samp le Code        
176          
177           #r egion Main  method        
178          
179           // / <summary >        
180           // / Standard  Main() me thod used  by most SD K samples.        
181           // / </summar y>        
182           // / <param n ame="args" ></param>        
183           st atic publi c void Mai n(string[]  args)        
184           {        
185                try        
186                {        
187                    // O btain the  target org anization' s Web addr ess and cl ient logon          
188                    // c redentials  from the  user.        
189                    Serv erConnecti on serverC onnect = n ew ServerC onnection( );        
190                    Serv erConnecti on.Configu ration con fig = serv erConnect. GetServerC onfigurati on();        
191          
192                    Remo veRoleFrom User app =  new Remov eRoleFromU ser();        
193                    app. Run( confi g, true );        
194                }        
195                catch (F aultExcept ion<Micros oft.Xrm.Sd k.Organiza tionServic eFault> ex )        
196                {        
197                    Cons ole.WriteL ine("The a pplication  terminate d with an  error.");        
198                    Cons ole.WriteL ine("Times tamp: {0}" , ex.Detai l.Timestam p);        
199                    Cons ole.WriteL ine("Code:  {0}", ex. Detail.Err orCode);        
200                    Cons ole.WriteL ine("Messa ge: {0}",  ex.Detail. Message);        
201                    Cons ole.WriteL ine("Trace : {0}", ex .Detail.Tr aceText);        
202                    Cons ole.WriteL ine("Inner  Fault: {0 }",        
203                         null == ex .Detail.In nerFault ?  "No Inner  Fault" :  "Has Inner  Fault");        
204                }        
205                catch (S ystem.Time outExcepti on ex)        
206                {        
207                    Cons ole.WriteL ine("The a pplication  terminate d with an  error.");        
208                    Cons ole.WriteL ine("Messa ge: {0}",  ex.Message );        
209                    Cons ole.WriteL ine("Stack  Trace: {0 }", ex.Sta ckTrace);        
210                    Cons ole.WriteL ine("Inner  Fault: {0 }",        
211                         null == ex .InnerExce ption.Mess age ? "No  Inner Faul t" : ex.In nerExcepti on.Message );        
212                }        
213                catch (S ystem.Exce ption ex)        
214                {        
215                    Cons ole.WriteL ine("The a pplication  terminate d with an  error.");        
216                    Cons ole.WriteL ine(ex.Mes sage);        
217          
218                    // D isplay the  details o f the inne r exceptio n.        
219                    if ( ex.InnerEx ception !=  null)        
220                    {        
221                         Console.Wr iteLine(ex .InnerExce ption.Mess age);        
222          
223                         FaultExcep tion<Micro soft.Xrm.S dk.Organiz ationServi ceFault> f e = ex.Inn erExceptio n        
224                             as Fau ltExceptio n<Microsof t.Xrm.Sdk. Organizati onServiceF ault>;        
225                         if (fe !=  null)        
226                         {        
227                             Consol e.WriteLin e("Timesta mp: {0}",  fe.Detail. Timestamp) ;        
228                             Consol e.WriteLin e("Code: { 0}", fe.De tail.Error Code);        
229                             Consol e.WriteLin e("Message : {0}", fe .Detail.Me ssage);        
230                             Consol e.WriteLin e("Trace:  {0}", fe.D etail.Trac eText);        
231                             Consol e.WriteLin e("Inner F ault: {0}" ,        
232                                 nu ll == fe.D etail.Inne rFault ? " No Inner F ault" : "H as Inner F ault");        
233                         }        
234                    }        
235                }        
236                // Addit ional exce ptions to  catch: Sec urityToken Validation Exception,  ExpiredSe curityToke nException ,        
237                // Secur ityAccessD eniedExcep tion, Mess ageSecurit yException , and Secu rityNegoti ationExcep tion.        
238                finally        
239                {        
240                    Cons ole.WriteL ine("Press  <Enter> t o exit.");        
241                    Cons ole.ReadLi ne();        
242                }        
243           }        
244           #e ndregion M ain method        
245       }        
246   }        
247   //</snippe tRemoveRol eFromUser>