371. Araxis Merge File Comparison Report

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

371.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\DeploymentService MoreDeploymentServiceMessages.cs Tue Dec 20 19:51:43 2016 UTC
2 Wed Feb 1 19:56:31 2017 UTC

371.2 Comparison summary

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

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

371.4 Active regular expressions

No regular expressions were active.

371.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 MoreDeploy mentServic eMessages>        
17   using Syst em;        
18   using Syst em.Collect ions.Gener ic;        
19   using Syst em.Net;        
20   using Syst em.Service Model;        
21   using Syst em.Linq;        
22          
23   // These n amespaces  are found  in the Mic rosoft.Xrm .Sdk.dll a ssembly        
24   // located  in the SD K\bin fold er of the  SDK downlo ad.        
25   using Micr osoft.Xrm. Sdk.Query;        
26   using Micr osoft.Xrm. Sdk.Client ;        
27          
28   // These n amespaces  are found  in the Mic rosoft.Xrm .Sdk.Deplo yment.dll  assembly        
29   // located  in the SD K\bin fold er of the  SDK downlo ad.        
30   using Micr osoft.Xrm. Sdk.Deploy ment;        
31   using Micr osoft.Xrm. Sdk.Deploy ment.Proxy ;        
32          
33   namespace  Microsoft. Crm.Sdk.Sa mples        
34   {        
35       /// <s ummary>        
36       /// De monstrates  how to us e the foll owing Depl oymentServ iceMessage s:        
37       /// Re trieveRequ est, Updat eRequest a nd UpdateA dvancedSet tingsReque st        
38       /// </ summary>        
39       /// <r emarks>        
40       /// NO TE: The de ployment s ervice onl y supports  Active Di rectory, s o the user  running        
41       /// th is sample  must have  a valid Ac tive Direc tory accou nt.        
42       /// Th is sample  demonstrat es its ful l function ality in a  multi-ser ver enviro nment.         
43       /// Du ring execu tion it ca n disable  one of the  server fo r demonstr ation.        
44       /// </ remarks>        
45       public  class Mor eDeploymen tServiceMe ssages        
46       {        
47           #r egion Clas s Level Me mbers        
48          
49           pr ivate Orga nizationSe rviceProxy  _serviceP roxy;        
50          
51           #e ndregion C lass Level  Members        
52          
53           #r egion How  To Sample  Code        
54           // / <summary >        
55           // / This met hod first  connects t o the Depl oyment ser vice. Then ,        
56           // / uses Ret rieveReque st, Update Request an d UpdateAd vancedSett ingsReques t.        
57           // / </summar y>        
58           // / <param n ame="serve rConfig">C ontains se rver conne ction info rmation.</ param>        
59           // / <param n ame="promp tforDelete ">When Tru e, the use r will be  prompted t o delete        
60           // / all crea ted entiti es.</param >        
61           pu blic void  Run(Server Connection .Configura tion serve rConfig, b ool prompt forDelete)        
62           {        
63                try        
64                {        
65                    // C onnect to  the Organi zation ser vice.         
66                    // T he using s tatement a ssures tha t the serv ice proxy  will be pr operly dis posed.        
67                    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 ))        
68                    {        
69          
70                         // Instant iate Deplo ymentServi ceClient f or calling  the servi ce.        
71                         Deployment ServiceCli ent servic eClient =        
72                             ProxyC lientHelpe r.CreateCl ient(        
73                             new Ur i(serverCo nfig.Disco veryUri.To String()        
74                                 .R eplace("Se rvices", " Deployment ")        
75                                 .R eplace("Di scovery",  "Deploymen t")));        
76          
77                         // Setting  credentia ls from th e current  security c ontext.         
78                         if (server Config.Cre dentials ! = null)        
79                         {        
80                             servic eClient.Cl ientCreden tials.Wind ows.Client Credential  =        
81                                 se rverConfig .Credentia ls.Windows .ClientCre dential;        
82                         }        
83                         else        
84                         {        
85                             servic eClient.Cl ientCreden tials.Wind ows.Client Credential  =        
86                                 Cr edentialCa che.Defaul tNetworkCr edentials;        
87                         }        
88          
89                         #region Re trieveRequ est        
90                                
91                         // Retriev e all serv ers availa ble in the  deploymen t        
92                         Console.Wr iteLine("\ nRetrievin g list of  servers... \n");        
93                         var server s =        
94                             servic eClient.Re trieveAll( Deployment EntityType .Server);        
95                                
96                         // Print l ist of all  retrieved  servers.        
97                         Console.Wr iteLine("S ervers in  your deplo yment");        
98                         Console.Wr iteLine("= ========== ========== ========== =");        
99                         foreach (v ar server  in servers )        
100                         {        
101                             Consol e.WriteLin e(server.N ame);        
102                         }        
103                         Console.Wr iteLine("< End of Lis ting>");        
104                         Console.Wr iteLine();                              
105          
106                         // Retriev e details  of first ( other than  current s erver) or  default se rver from  previous c all.        
107                         var server Id = serve rs.FirstOr Default(x  => x.Name. ToLowerInv ariant() ! = serverCo nfig.Serve rAddress.T oLowerInva riant());        
108                         // If no o ther serve r exists t hen defaul t to exist ing one.        
109                         if (server Id == null )        
110                             server Id = serve rs.FirstOr Default();        
111          
112                         Console.Wr iteLine("\ nRetrievin g details  of one ser ver...\n") ;        
113                         RetrieveRe quest retr ieveReqSer ver = new  RetrieveRe quest();        
114                         retrieveRe qServer.En tityType =  Deploymen tEntityTyp e.Server;        
115                         retrieveRe qServer.In stanceTag  = serverId ;        
116                         RetrieveRe sponse ret rieveRespS erver =         
117                             (Retri eveRespons e)serviceC lient.Exec ute(retrie veReqServe r);        
118                         Server ser verToUpdat e =         
119                             (Serve r)retrieve RespServer .Entity;        
120          
121                         Console.Wr iteLine("= ========== ========== ========== =");        
122                         Console.Wr iteLine("N ame: " + s erverToUpd ate.Name);        
123                         Console.Wr iteLine("S tate: " +  serverToUp date.State );        
124                         Console.Wr iteLine();        
125          
126                         #endregion  RetrieveR equest        
127          
128                         #region Up dateReques t        
129                         // Avoid u pdating cu rrent serv er as it w ould disru pt the fur ther sampl e executio n.        
130                         if (server s.Count >  1)        
131                         {        
132                             // Mod ified the  property w e want to  update        
133                             server ToUpdate.S tate = Ser verState.D isabled;        
134          
135                             // Upd ate the de ployment r ecord        
136                             Consol e.WriteLin e("\nUpdat ing server ...\n");        
137                             Update Request up dateReq =  new Update Request();        
138                             update Req.Entity  = serverT oUpdate;        
139                             Update Response u ptRes =        
140                                 (U pdateRespo nse)servic eClient.Ex ecute(upda teReq);        
141          
142                             // Ret rieve serv er details  again to  check if i t is updat ed        
143                             Retrie veResponse  retrieveR espServerU pdated =        
144                                 (R etrieveRes ponse)serv iceClient. Execute(re trieveReqS erver);        
145                             Server  serverUpd ated =        
146                                 (S erver)retr ieveRespSe rverUpdate d.Entity;        
147          
148                             Consol e.WriteLin e("Server  Updated");        
149                             Consol e.WriteLin e("======= ========== ========== =====");        
150                             Consol e.WriteLin e("Name: "  + serverU pdated.Nam e);        
151                             Consol e.WriteLin e("State:  " + server Updated.St ate);        
152                             Consol e.WriteLin e();        
153          
154                             // Rev ert change        
155                             server Updated.St ate = Serv erState.En abled;        
156          
157                             Consol e.WriteLin e("\nRever ting chang e made in  server...\ n");        
158                             Update Request up dateReqRev ert = new  UpdateRequ est();        
159                             update ReqRevert. Entity = s erverUpdat ed;        
160                             Update Response u ptResRev =        
161                                 (U pdateRespo nse)servic eClient.Ex ecute(upda teReqRever t);        
162          
163                             Retrie veResponse  retrieveR espServerR everted =        
164                                 (R etrieveRes ponse)serv iceClient. Execute(re trieveReqS erver);        
165                             Server  serverRev erted =        
166                                 (S erver)retr ieveRespSe rverRevert ed.Entity;        
167          
168                             Consol e.WriteLin e("Server  Reverted") ;        
169                             Consol e.WriteLin e("======= ========== ========== =====");        
170                             Consol e.WriteLin e("Name: "  + serverR everted.Na me);        
171                             Consol e.WriteLin e("State:  " + server Reverted.S tate);        
172                             Consol e.WriteLin e();        
173                         }        
174                         else        
175                             Consol e.WriteLin e("\nMulti -server en vironment  missing."         
176                                 +  "\nSkippin g server u pdate requ est to avo id disrupt ion in the  sample ex ecution.") ;        
177                         #endregion  UpdateReq uest        
178          
179                         #region Up dateAdvanc eRequest        
180                                
181                         // Retriev e Advanced  Settings  for your o rganizatio n.        
182                         Console.Wr iteLine("\ nRetrievin g Advanced  Settings. ..\n");        
183                         RetrieveAd vancedSett ingsReques t requestA dvSettings  =        
184                             new Re trieveAdva ncedSettin gsRequest        
185                             {        
186                                 Co nfiguratio nEntityNam e = "Deplo yment",        
187                                 Co lumnSet =  new Column Set("Id")        
188                             };        
189                         Configurat ionEntity  configurat ion =        
190                             ((Retr ieveAdvanc edSettings Response)        
191                             servic eClient.Ex ecute(requ estAdvSett ings)).Ent ity;        
192          
193                         // Print o ut all adv anced sett ings where  IsWritabl e==true.        
194                         Console.Wr iteLine("A dvanced de ployment s ettings th at can be  updated");        
195                         Console.Wr iteLine("= ========== ========== ========== ========== =======");        
196                         foreach (v ar setting  in config uration.At tributes)        
197                         {        
198                             if (se tting.Key  != "Id")        
199                             {        
200                                 Co nsole.Writ eLine(        
201                                      String.F ormat("{0} : {1}",        
202                                          sett ing.Key,        
203                                          sett ing.Value) );        
204                             }        
205                         }        
206                         Console.Wr iteLine();        
207          
208                         // Create  the Config uration En tity with  the values  to update        
209                         Configurat ionEntity  configEnti ty = new C onfigurati onEntity() ;        
210                         configEnti ty.Logical Name = "De ployment";        
211                         configEnti ty.Attribu tes = new  AttributeC ollection( );        
212                         configEnti ty.Attribu tes.Add        
213                             (new K eyValuePai r<string,  object>        
214                                 (" Automatica llyInstall DatabaseUp dates", tr ue));        
215          
216                         // Update  Advanced S ettings        
217                         Console.Wr iteLine("\ nUpdating  Advanced S ettings... \n");        
218                         UpdateAdva ncedSettin gsRequest  updateAdva nceReq =         
219                             new Up dateAdvanc edSettings Request();        
220                         updateAdva nceReq.Ent ity = conf igEntity;        
221                         serviceCli ent.Execut e(updateAd vanceReq);        
222          
223                         // Retriev e Advanced  Settings  to check i f they hav e been upd ated        
224                         Configurat ionEntity  configurat ionUpdated  =        
225                             ((Retr ieveAdvanc edSettings Response)        
226                             servic eClient.Ex ecute(requ estAdvSett ings)).Ent ity;        
227          
228                         Console.Wr iteLine("A dvanced de ployment s ettings up dated");        
229                         Console.Wr iteLine("= ========== ========== ========== ========== =======");        
230                         foreach (v ar setting  in config urationUpd ated.Attri butes)        
231                         {        
232                             if (se tting.Key  != "Id")        
233                             {        
234                                 Co nsole.Writ eLine(        
235                                      String.F ormat("{0} : {1}",        
236                                          sett ing.Key,        
237                                          sett ing.Value) );        
238                             }        
239                         }        
240                         Console.Wr iteLine();        
241          
242                         // Revert  change        
243                         Configurat ionEntity  entityReve rt = new C onfigurati onEntity() ;        
244                         entityReve rt.Logical Name = "De ployment";        
245                         entityReve rt.Attribu tes = new  AttributeC ollection( );        
246                         entityReve rt.Attribu tes.Add        
247                             (new K eyValuePai r<string,  object>        
248                                 (" Automatica llyInstall DatabaseUp dates", fa lse));        
249          
250                         Console.Wr iteLine("\ nReverting  Advanced  Settings.. .\n");        
251                         UpdateAdva ncedSettin gsRequest  requestRev ert =         
252                             new Up dateAdvanc edSettings Request();        
253                         requestRev ert.Entity  = entityR evert;        
254                         serviceCli ent.Execut e(requestR evert);        
255          
256                         Configurat ionEntity  configurat ionReverte d =        
257                             ((Retr ieveAdvanc edSettings Response)        
258                             servic eClient.Ex ecute(requ estAdvSett ings)).Ent ity;        
259                         Console.Wr iteLine("A dvanced de ployment s ettings re verted");        
260                         Console.Wr iteLine("= ========== ========== ========== ========== =======");        
261                         foreach (v ar setting  in config urationRev erted.Attr ibutes)        
262                         {        
263                             if (se tting.Key  != "Id")        
264                             {        
265                                 Co nsole.Writ eLine(        
266                                      String.F ormat("{0} : {1}",        
267                                          sett ing.Key,        
268                                          sett ing.Value) );        
269                             }        
270                         }        
271                         Console.Wr iteLine();        
272                         #endregion  UpdateAdv anceReques t        
273                    }        
274                }        
275                // Catch  any servi ce fault e xceptions  that Micro soft Dynam ics CRM th rows.        
276                catch (F aultExcept ion<Deploy mentServic eFault>)        
277                {        
278                    // Y ou can han dle an exc eption her e or pass  it back to  the calli ng method.        
279                    thro w;        
280                }        
281           }        
282          
283           #e ndregion H ow To Samp le Code        
284          
285           #r egion Main  method        
286          
287           // / <summary >        
288           // / Standard  Main() me thod used  by most SD K samples.        
289           // / </summar y>        
290           // / <param n ame="args" ></param>        
291           st atic publi c void Mai n(string[]  args)        
292           {        
293                try        
294                {        
295                    // O btain the  target org anization' s Web addr ess and cl ient logon          
296                    // c redentials  from the  user.        
297                    Serv erConnecti on serverC onnect = n ew ServerC onnection( );        
298                    Serv erConnecti on.Configu ration con fig = serv erConnect. GetServerC onfigurati on();        
299          
300                    More Deployment ServiceMes sages app  = new More Deployment ServiceMes sages();        
301                    app. Run(config , true);        
302                }        
303                catch (F aultExcept ion<Deploy mentServic eFault> ex )        
304                {        
305                    Cons ole.WriteL ine("The a pplication  terminate d with an  error.");        
306                    Cons ole.WriteL ine("Times tamp: {0}" , ex.Detai l.Timestam p);        
307                    Cons ole.WriteL ine("Code:  {0}", ex. Detail.Err orCode);        
308                    Cons ole.WriteL ine("Messa ge: {0}",  ex.Detail. Message);        
309                    Cons ole.WriteL ine("Inner  Fault: {0 }",        
310                         null == ex .Detail.In nerFault ?  "No Inner  Fault" :  "Has Inner  Fault");        
311                }        
312                catch (S ystem.Time outExcepti on ex)        
313                {        
314                    Cons ole.WriteL ine("The a pplication  terminate d with an  error.");        
315                    Cons ole.WriteL ine("Messa ge: {0}",  ex.Message );        
316                    Cons ole.WriteL ine("Stack  Trace: {0 }", ex.Sta ckTrace);        
317                    Cons ole.WriteL ine("Inner  Fault: {0 }",        
318                         null == ex .InnerExce ption.Mess age ? "No  Inner Faul t" : ex.In nerExcepti on.Message );        
319                }        
320                catch (S ystem.Exce ption ex)        
321                {        
322                    Cons ole.WriteL ine("The a pplication  terminate d with an  error.");        
323                    Cons ole.WriteL ine(ex.Mes sage);        
324          
325                    // D isplay the  details o f the inne r exceptio n.        
326                    if ( ex.InnerEx ception !=  null)        
327                    {        
328                         Console.Wr iteLine(ex .InnerExce ption.Mess age);        
329          
330                         FaultExcep tion<Deplo ymentServi ceFault> f e = ex.Inn erExceptio n        
331                             as Fau ltExceptio n<Deployme ntServiceF ault>;        
332                         if (fe !=  null)        
333                         {        
334                             Consol e.WriteLin e("Timesta mp: {0}",  fe.Detail. Timestamp) ;        
335                             Consol e.WriteLin e("Code: { 0}", fe.De tail.Error Code);        
336                             Consol e.WriteLin e("Message : {0}", fe .Detail.Me ssage);        
337                             Consol e.WriteLin e("Inner F ault: {0}" ,        
338                                 nu ll == fe.D etail.Inne rFault ? " No Inner F ault" : "H as Inner F ault");        
339                         }        
340                    }        
341                }        
342                // Addit ional exce ptions to  catch: Sec urityToken Validation Exception,  ExpiredSe curityToke nException ,        
343                // Secur ityAccessD eniedExcep tion, Mess ageSecurit yException , and Secu rityNegoti ationExcep tion.        
344          
345                finally        
346                {        
347                    Cons ole.WriteL ine("Press  <Enter> t o exit.");        
348                    Cons ole.ReadLi ne();        
349                }        
350           }        
351           #e ndregion M ain method        
352          
353       }        
354   }        
355   //</snippe tMoreDeplo ymentServi ceMessages >