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

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

213.2 Comparison summary

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

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

213.4 Active regular expressions

No regular expressions were active.

213.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 WorkingWit hTimeZones >        
17   using Syst em;        
18   using Syst em.Service Model;        
19   using Micr osoft.Crm. Sdk.Messag es;        
20   using Micr osoft.Xrm. Sdk;        
21   using Micr osoft.Xrm. Sdk.Client ;        
22   using Micr osoft.Xrm. Sdk.Messag es;        
23   using Micr osoft.Xrm. Sdk.Query;        
24          
25   namespace  Microsoft. Crm.Sdk.Sa mples        
26   {        
27       /// <s ummary>        
28       /// Th is sample  shows how  to use var ious SDK m essages wi th time zo nes.        
29       /// </ summary>        
30       /// <r emarks>        
31       /// At  run-time,  you will  be given t he option  to delete  all the        
32       /// da tabase rec ords creat ed by this  program.        
33       /// </ remarks>        
34       public  class Wor kingWithTi meZones        
35       {        
36           #r egion Clas s Level Me mbers        
37           pr ivate Orga nizationSe rviceProxy  _serviceP roxy;        
38           pr ivate stri ng _timeZo neName;        
39           pr ivate Guid ? _timeZon eId;        
40           pr ivate int?  _localeId ;        
41           pr ivate int?  _timeZone Code;        
42           #e ndregion        
43          
44           #r egion How  To Sample  Code        
45          
46           // / <summary >        
47           // / This met hod shows  how to ret rieve the  user's tim e zone, re trieve tim e zones        
48           // / on the s ystem and  convert ti me between  UTC and l ocal time  for a user .        
49           // / </summar y>        
50           // / <param n ame="serve rConfig">C ontains se rver conne ction info rmation.</ param>        
51           // / <param n ame="promp tforDelete ">When Tru e, the use r will be  prompted t o delete        
52           // / all crea ted entiti es.</param >        
53           pu blic void  Run(Server Connection .Configura tion serve rConfig,        
54                bool pro mptforDele te)        
55           {        
56                using (_ servicePro xy = new O rganizatio nServicePr oxy(server Config.Org anizationU ri, server Config.Hom eRealmUri, serverConf ig.Credent ials, serv erConfig.D eviceCrede ntials))        
57                {        
58                    // T his statem ent is req uired to e nable earl y-bound ty pe support .        
59                    _ser viceProxy. EnableProx yTypes();        
60          
61                    _tim eZoneId =  new Guid(" 42B2880D-B ED5-4AA3-B D69-418052 D38B7E");        
62                    _tim eZoneName  = "Central  Standard  Time";        
63                    Retr ieveCurren tUsersSett ings();        
64                                  
65                    Retr ieveAllTim eZonesForL ocale();        
66                    GetT imeZoneCod eByLocaleA ndName();        
67                    Retr ieveTimeZo neById();        
68                    Retr ieveTimeZo nesLessTha n50();        
69                    Retr ieveLocalT imeFromUTC Time(new D ateTime(19 81, 6, 6,  9, 5, 0));        
70                    Retr ieveUTCTim eFromLocal Time(new D ateTime(20 12, 1, 1,  0, 0, 0));        
71                }        
72           }        
73          
74           // / <summary >        
75           // / Retrieve s the curr ent users  timezone c ode and lo cale id        
76           // / </summar y>        
77           pr ivate void  RetrieveC urrentUser sSettings( )        
78           {        
79                var curr entUserSet tings = _s erviceProx y.Retrieve Multiple(        
80                    new  QueryExpre ssion(User Settings.E ntityLogic alName)        
81                    {        
82                         ColumnSet  = new Colu mnSet("loc aleid", "t imezonecod e"),        
83                         Criteria =  new Filte rExpressio n        
84                         {        
85                             Condit ions =        
86                             {        
87                                 ne w Conditio nExpressio n("systemu serid", Co nditionOpe rator.Equa lUserId)        
88                             }        
89                         }        
90                    }).E ntities[0] .ToEntity< UserSettin gs>();        
91          
92                _localeI d = curren tUserSetti ngs.Locale Id;        
93                _timeZon eCode = cu rrentUserS ettings.Ti meZoneCode ;        
94           }        
95          
96           // / <summary >        
97           // / Uses the  current l ocale id t o retrieve  all the t imezones         
98           // / </summar y>        
99           // <snippetGe tAllTimeZo nesWithDis playName>        
100           pr ivate void  RetrieveA llTimeZone sForLocale ()        
101           {        
102                if (!_lo caleId.Has Value)        
103                    retu rn;        
104                        
105                Console. WriteLine( String.Con cat("Retri eving time  zones for  locale id : ",        
106                    _loc aleId.Valu e));        
107          
108                var resp onse = (Ge tAllTimeZo nesWithDis playNameRe sponse) _s erviceProx y.Execute(        
109                    new  GetAllTime ZonesWithD isplayName Request        
110                    {        
111                         LocaleId =  _localeId .Value,        
112                    });        
113          
114                for (int  i = 0; i  < response .EntityCol lection.En tities.Cou nt; i++)        
115                {        
116                    var  timeZoneDe finition =  response. EntityColl ection        
117                         .Entities[ i].ToEntit y<TimeZone Definition >();        
118          
119                    Cons ole.WriteL ine(String .Concat(ti meZoneDefi nition.Use rInterface Name,        
120                         " found fo r ", _loca leId.Value ));        
121                }        
122           }        
123           // </snippetG etAllTimeZ onesWithDi splayName>        
124          
125           // / <summary >        
126           // / Retrieve s a timezo ne by the  name and t he locale  ID        
127           // / </summar y>        
128           // <snippetGe tTimeZoneC odeByLocal izedName>        
129           pr ivate void  GetTimeZo neCodeByLo caleAndNam e()        
130           {        
131                if (stri ng.IsNullO rWhiteSpac e(_timeZon eName) ||  !_localeId .HasValue)        
132                    retu rn;        
133          
134                var requ est = new  GetTimeZon eCodeByLoc alizedName Request        
135                {        
136                    Loca leId = _lo caleId.Val ue,        
137                    Loca lizedStand ardName =  _timeZoneN ame        
138                };        
139          
140                var resp onse = (Ge tTimeZoneC odeByLocal izedNameRe sponse)        
141                    _ser viceProxy. Execute(re quest);        
142          
143                Console. WriteLine( String.Con cat("Time  zone code:  ", respon se.TimeZon eCode,        
144                    " re trieved fo r locale i d: ", _loc aleId.Valu e, ", and  time zone  name: ",        
145                    _tim eZoneName) );        
146           }        
147           // </snippetG etTimeZone CodeByLoca lizedName>        
148          
149           // / <summary >        
150           // / Retieve  time zone  by id        
151           // / </summar y>        
152           pr ivate void  RetrieveT imeZoneByI d()        
153           {        
154                if (!_ti meZoneId.H asValue)        
155                    retu rn;        
156          
157                // In ad dition to  the Retrie veRequest  message,         
158                // you m ay use the  IOrganiza tionServic e.Retrieve  method        
159                var requ est = new  RetrieveRe quest        
160                {        
161                    Targ et = new E ntityRefer ence(        
162                         TimeZoneDe finition.E ntityLogic alName, _t imeZoneId. Value),        
163                    Colu mnSet = ne w ColumnSe t("standar dname")        
164                };        
165          
166                var resp onse = (Re trieveResp onse)_serv iceProxy.E xecute(req uest);        
167          
168                Console. WriteLine( String.Con cat("Retri eve reques t on time  zone ",        
169                    _tim eZoneId.Va lue, ".  N ame: ", re sponse.Ent ity.        
170                    ToEn tity<TimeZ oneDefinit ion>().Sta ndardName) );        
171           }        
172          
173           // / <summary >        
174           // / Retrieve  time zone s less tha n 50.        
175           // / </summar y>        
176           pr ivate void  RetrieveT imeZonesLe ssThan50()        
177           {        
178                // In ad dition to  the Retrie veMultiple Request me ssage,        
179                // you m ay use the  IOrganiza tionServic e.Retrieve Multiple m ethod.        
180                var requ est = new  RetrieveMu ltipleRequ est        
181                {        
182                    Quer y = new Qu eryExpress ion(TimeZo neDefiniti on.EntityL ogicalName )        
183                    {        
184                         ColumnSet  = new Colu mnSet("tim ezonecode" , "standar dname"),        
185                         Criteria =  new Filte rExpressio n        
186                         {        
187                             Condit ions =        
188                             {        
189                                 ne w Conditio nExpressio n("timezon ecode",         
190                                      Conditio nOperator. LessThan,  50)        
191                             }        
192                         }        
193                    }        
194                };        
195          
196                Console. WriteLine( "Retrievin g all time zones with  a timezon ecode less  than 50") ;        
197                var resp onse = (Re trieveMult ipleRespon se)_servic eProxy.Exe cute(reque st);        
198          
199                foreach  (var item  in respons e.EntityCo llection.E ntities)        
200                {        
201                    var  timeZone =  item.ToEn tity<TimeZ oneDefinit ion>();        
202          
203                    Cons ole.WriteL ine(String .Concat("T ime zone n ame: ",        
204                         timeZone.S tandardNam e, ", time  zone code : ",        
205                         !timeZone. TimeZoneCo de.HasValu e ? "null"  :        
206                         timeZone.T imeZoneCod e.Value.To String())) ;        
207                }        
208          
209           }        
210          
211           // / <summary >        
212           // / Retrive  the local  time from  the UTC ti me.        
213           // / </summar y>        
214           // / <param n ame="utcTi me"></para m>        
215           // <snippetLo calTimeFro mUTCTime>        
216           pr ivate void  RetrieveL ocalTimeFr omUTCTime( DateTime u tcTime)        
217           {        
218                if (!_ti meZoneCode .HasValue)        
219                    retu rn;                         
220          
221                var requ est = new  LocalTimeF romUtcTime Request        
222                {        
223                    Time ZoneCode =  _timeZone Code.Value ,        
224                    UtcT ime = utcT ime.ToUniv ersalTime( )        
225                };        
226          
227                var resp onse = (Lo calTimeFro mUtcTimeRe sponse)_se rviceProxy .Execute(r equest);        
228          
229                Console. WriteLine( String.Con cat("Calli ng LocalTi meFromUtcT imeRequest .  UTC tim e: ",        
230                    utcT ime.ToStri ng("MM/dd/ yyyy HH:mm :ss"), ".  Local time : ",        
231                    resp onse.Local Time.ToStr ing("MM/dd /yyyy HH:m m:ss")));        
232           }        
233           // </snippetL ocalTimeFr omUTCTime>        
234          
235           // / <summary >        
236           // / Retrieve s the utc  time from  the local  time        
237           // / </summar y>        
238           // / <param n ame="local Time"></pa ram>        
239           // <snippetUt cTimeFromL ocalTime>        
240           pr ivate void  RetrieveU TCTimeFrom LocalTime( DateTime l ocalTime)        
241           {        
242                if (!_ti meZoneCode .HasValue)        
243                    retu rn;           
244          
245                var requ est = new  UtcTimeFro mLocalTime Request        
246                {        
247                    Time ZoneCode =  _timeZone Code.Value ,        
248                    Loca lTime = lo calTime        
249                };        
250          
251                var resp onse = (Ut cTimeFromL ocalTimeRe sponse)_se rviceProxy .Execute(r equest);        
252          
253                Console. WriteLine( String.Con cat("Calli ng UtcTime FromLocalT imeRequest .  Local t ime: ",        
254                    loca lTime.ToSt ring("MM/d d/yyyy HH: mm:ss"), " . UTC time : ",        
255                    resp onse.UtcTi me.ToStrin g("MM/dd/y yyy HH:mm: ss")));        
256           }        
257           // </snippetU tcTimeFrom LocalTime>        
258           #e ndregion        
259          
260           #r egion Main  method        
261           // / <summary >        
262           // / Standard  Main() me thod used  by most SD K samples.        
263           // / </summar y>        
264           // / <param n ame="args" ></param>        
265           st atic publi c void Mai n(string[]  args)        
266           {        
267                try        
268                {        
269                    // O btain the  target org anization' s Web addr ess and cl ient logon          
270                    // c redentials  from the  user.        
271                    Serv erConnecti on serverC onnect = n ew ServerC onnection( );        
272                    Serv erConnecti on.Configu ration con fig = serv erConnect. GetServerC onfigurati on();        
273          
274                    var  app = new  WorkingWit hTimeZones ();        
275                    app. Run(config , true);        
276                }        
277                catch (F aultExcept ion<Micros oft.Xrm.Sd k.Organiza tionServic eFault> ex )        
278                {        
279                    Cons ole.WriteL ine("The a pplication  terminate d with an  error.");        
280                    Cons ole.WriteL ine("Times tamp: {0}" , ex.Detai l.Timestam p);        
281                    Cons ole.WriteL ine("Code:  {0}", ex. Detail.Err orCode);        
282                    Cons ole.WriteL ine("Messa ge: {0}",  ex.Detail. Message);        
283                    Cons ole.WriteL ine("Plugi n Trace: { 0}", ex.De tail.Trace Text);        
284                    Cons ole.WriteL ine("Inner  Fault: {0 }",        
285                         null == ex .Detail.In nerFault ?  "No Inner  Fault" :  "Has Inner  Fault");        
286                }        
287                catch (S ystem.Time outExcepti on ex)        
288                {        
289                    Cons ole.WriteL ine("The a pplication  terminate d with an  error.");        
290                    Cons ole.WriteL ine("Messa ge: {0}",  ex.Message );        
291                    Cons ole.WriteL ine("Stack  Trace: {0 }", ex.Sta ckTrace);        
292                    Cons ole.WriteL ine("Inner  Fault: {0 }",        
293                         null == ex .InnerExce ption.Mess age ? "No  Inner Faul t" : ex.In nerExcepti on.Message );        
294                }        
295                catch (S ystem.Exce ption ex)        
296                {        
297                    Cons ole.WriteL ine("The a pplication  terminate d with an  error.");        
298                    Cons ole.WriteL ine(ex.Mes sage);        
299          
300                    // D isplay the  details o f the inne r exceptio n.        
301                    if ( ex.InnerEx ception !=  null)        
302                    {        
303                         Console.Wr iteLine(ex .InnerExce ption.Mess age);        
304          
305                         FaultExcep tion<Micro soft.Xrm.S dk.Organiz ationServi ceFault> f e = ex.Inn erExceptio n        
306                             as Fau ltExceptio n<Microsof t.Xrm.Sdk. Organizati onServiceF ault>;        
307                         if (fe !=  null)        
308                         {        
309                             Consol e.WriteLin e("Timesta mp: {0}",  fe.Detail. Timestamp) ;        
310                             Consol e.WriteLin e("Code: { 0}", fe.De tail.Error Code);        
311                             Consol e.WriteLin e("Message : {0}", fe .Detail.Me ssage);        
312                             Consol e.WriteLin e("Plugin  Trace: {0} ", fe.Deta il.TraceTe xt);        
313                             Consol e.WriteLin e("Inner F ault: {0}" ,        
314                                 nu ll == fe.D etail.Inne rFault ? " No Inner F ault" : "H as Inner F ault");        
315                         }        
316                    }        
317                }        
318                // Addit ional exce ptions to  catch: Sec urityToken Validation Exception,  ExpiredSe curityToke nException ,        
319                // Secur ityAccessD eniedExcep tion, Mess ageSecurit yException , and Secu rityNegoti ationExcep tion.        
320          
321                finally        
322                {        
323                    Cons ole.WriteL ine("Press  <Enter> t o exit.");        
324                    Cons ole.ReadLi ne();        
325                }        
326           }        
327           #e ndregion        
328       }        
329   }        
330   //</snippe tWorkingWi thTimeZone s>