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

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

217.2 Comparison summary

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

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

217.4 Active regular expressions

No regular expressions were active.

217.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 OverrideGo alTotalCou nt>        
17   using Syst em;        
18   using Syst em.Service Model;        
19   using Syst em.Collect ions.Gener ic;        
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.Xrm. Sdk.Messag es;        
27          
28   // This na mespace is  found in  Microsoft. Crm.Sdk.Pr oxy.dll as sembly        
29   // found i n the SDK\ bin folder .        
30   using Micr osoft.Crm. Sdk.Messag es;        
31          
32   namespace  Microsoft. Crm.Sdk.Sa mples        
33   {        
34       /// <s ummary>        
35       /// De monstrates  how to ov erride the  goal tota l count an d close a  goal.</sum mary>        
36       /// <r emarks>        
37       /// At  run-time,  you will  be given t he option  to delete  all the        
38       /// da tabase rec ords creat ed by this  program.< /remarks>        
39       public  class Ove rrideGoalT otalCount        
40       {        
41           #r egion Clas s Level Me mbers        
42          
43           pr ivate Guid  _metricId ;        
44           pr ivate Guid  _actualId ;        
45           pr ivate Guid  _inprogre ssId;        
46           pr ivate Guid  _goalId;        
47           pr ivate Guid  _accountI d;        
48           pr ivate Guid  _salesMan agerId;        
49           pr ivate Guid  _phoneCal lId;        
50           pr ivate Guid  _phoneCal l2Id;        
51           pr ivate List <Guid> _ro llupQueryI ds = new L ist<Guid>( );        
52          
53           pr ivate Orga nizationSe rviceProxy  _serviceP roxy;        
54          
55           #e ndregion C lass Level  Members        
56          
57           #r egion How  To Sample  Code        
58           // / <summary >        
59           // / This met hod first  connects t o the Orga nization s ervice. Af terwards,        
60           // / a goal i s created  specifying  the targe t count. T he goal is  then        
61           // / rolled u p, the act ual and in -progress  values are  overridde n and fina lly the         
62           // / goal is  closed.        
63           // / </summar y>        
64           // / <param n ame="serve rConfig">C ontains se rver conne ction info rmation.</ param>        
65           // / <param n ame="promp tforDelete ">When Tru e, the use r will be  prompted t o delete a ll        
66           // / created  entities.< /param>        
67           pu blic void  Run(Server Connection .Configura tion serve rConfig, b ool prompt forDelete)        
68           {        
69                try        
70                {        
71                    //<s nippetOver rideGoalTo talCount1>        
72                    // C onnect to  the Organi zation ser vice.         
73                    // T he using s tatement a ssures tha t the serv ice proxy  will be pr operly dis posed.        
74                    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 ))        
75                    {        
76                         // This st atement is  required  to enable  early-boun d type sup port.        
77                         _servicePr oxy.Enable ProxyTypes ();        
78          
79                         CreateRequ iredRecord s();        
80          
81                         // Create  the count  metric, se tting the  Metric Typ e to 'Coun t' by        
82                         // setting  IsAmount  to false.        
83                         Metric sam pleMetric  = new Metr ic()        
84                         {        
85                             Name =  "Sample C ount Metri c",        
86                             IsAmou nt = false ,        
87                         };        
88                         _metricId  = _service Proxy.Crea te(sampleM etric);        
89                         sampleMetr ic.Id = _m etricId;        
90          
91                         Console.Wr ite("Creat ed phone c all metric , ");        
92          
93                         #region Cr eate Rollu pFields        
94          
95                         // Create  RollupFiel d which ta rgets comp leted (rec eived) pho ne calls.        
96                         RollupFiel d actual =  new Rollu pField()        
97                         {        
98                             Source Entity = P honeCall.E ntityLogic alName,        
99                             GoalAt tribute =  "actualint eger",        
100                             Source State = 1,        
101                             Source Status = 4 ,        
102                             Entity ForDateAtt ribute = P honeCall.E ntityLogic alName,        
103                             DateAt tribute =  "actualend ",        
104                             Metric Id = sampl eMetric.To EntityRefe rence()        
105                         };        
106                         _actualId  = _service Proxy.Crea te(actual) ;        
107          
108                         Console.Wr ite("creat ed actual  revenue Ro llupField,  ");        
109          
110                         // Create  RollupFiel d which ta rgets open  (in-progr ess) phone  calls.        
111                         RollupFiel d inprogre ss = new R ollupField ()        
112                         {        
113                             Source Entity = P honeCall.E ntityLogic alName,        
114                             GoalAt tribute =  "inprogres sinteger",        
115                             Source State = 0,        
116                             Entity ForDateAtt ribute = P honeCall.E ntityLogic alName,        
117                             DateAt tribute =  "createdon ",        
118                             Metric Id = sampl eMetric.To EntityRefe rence()        
119                         };        
120                         _inprogres sId = _ser viceProxy. Create(inp rogress);        
121          
122                         Console.Wr ite("creat ed in-prog ress reven ue RollupF ield, ");        
123          
124                         #endregion        
125          
126                         #region Cr eate the g oal rollup  queries        
127          
128                         // Note: F ormatting  the FetchX ml onto mu ltiple lin es in the  following         
129                         // rollup  queries ca uses the l ength prop erty to be  greater t han 1,000        
130                         // chars a nd will ca use an exc eption.        
131          
132                         // The fol lowing que ry locates  closed in coming pho ne calls.        
133                         GoalRollup Query goal RollupQuer y = new Go alRollupQu ery()        
134                         {        
135                             Name =  "Example  Goal Rollu p Query -  Actual",        
136                             QueryE ntityType  = PhoneCal l.EntityLo gicalName,        
137                             FetchX ml = @"<fe tch versio n='1.0' ou tput-forma t='xml-pla tform' map ping='logi cal' disti nct='false '><entity  name='phon ecall'><at tribute na me='subjec t'/><attri bute name= 'statecode '/><attrib ute name=' priorityco de'/><attr ibute name ='schedule dend'/><at tribute na me='create dby'/><att ribute nam e='regardi ngobjectid '/><attrib ute name=' activityid '/><order  attribute= 'subject'  descending ='false'/> <filter ty pe='and'>< condition  attribute= 'direction code' oper ator='eq'  value='0'/ ><conditio n attribut e='stateco de' operat or='eq' va lue='1' /> </filter>< /entity></ fetch>"        
138                         };        
139                         _rollupQue ryIds.Add( _servicePr oxy.Create (goalRollu pQuery));        
140                         goalRollup Query.Id =  _rollupQu eryIds[0];        
141          
142                         // The fol lowing que ry locates  open inco ming phone  calls.        
143                         GoalRollup Query inPr ogressGoal RollupQuer y = new Go alRollupQu ery()        
144                         {        
145                             Name =  "Example  Goal Rollu p Query -  InProgress ",        
146                             QueryE ntityType  = PhoneCal l.EntityLo gicalName,        
147                             FetchX ml = @"<fe tch versio n='1.0' ou tput-forma t='xml-pla tform' map ping='logi cal' disti nct='false '><entity  name='phon ecall'><at tribute na me='subjec t'/><attri bute name= 'statecode '/><attrib ute name=' priorityco de'/><attr ibute name ='schedule dend'/><at tribute na me='create dby'/><att ribute nam e='regardi ngobjectid '/><attrib ute name=' activityid '/><order  attribute= 'subject'  descending ='false'/> <filter ty pe='and'>< condition  attribute= 'direction code' oper ator='eq'  value='0'/ ><conditio n attribut e='stateco de' operat or='eq' va lue='0' /> </filter>< /entity></ fetch>"        
148                         };        
149                         _rollupQue ryIds.Add( _servicePr oxy.Create (inProgres sGoalRollu pQuery));        
150                         inProgress GoalRollup Query.Id =  _rollupQu eryIds[1];        
151          
152                         Console.Wr ite("creat ed rollup  queries fo r incoming  phone cal ls.\n");        
153                         Console.Wr iteLine();        
154          
155                         #endregion        
156          
157                         #region Cr eate a goa l to track  the open  incoming p hone calls .        
158          
159                         // Create  the goal.        
160                         Goal goal  = new Goal ()        
161                         {        
162                             Title  = "Sample  Goal",        
163                             Rollup OnlyFromCh ildGoals =  false,        
164                             Consid erOnlyGoal OwnersReco rds = fals e,        
165                             Target Integer =  5,        
166                             Rollup QueryActua lIntegerId  = goalRol lupQuery.T oEntityRef erence(),        
167                             RollUp QueryInpro gressInteg erId =         
168                                 in ProgressGo alRollupQu ery.ToEnti tyReferenc e(),        
169                             IsFisc alPeriodGo al = false ,        
170                             Metric Id = sampl eMetric.To EntityRefe rence(),        
171                             GoalOw nerId = ne w EntityRe ference        
172                             {        
173                                 Id  = _salesM anagerId,        
174                                 Lo gicalName  = SystemUs er.EntityL ogicalName        
175                             },        
176                             OwnerI d = new En tityRefere nce        
177                             {        
178                                 Id  = _salesM anagerId,        
179                                 Lo gicalName  = SystemUs er.EntityL ogicalName        
180                             },        
181                             GoalSt artDate =  DateTime.T oday.AddDa ys(-1),        
182                             GoalEn dDate = Da teTime.Tod ay.AddDays (30)        
183                         };        
184                         _goalId =  _servicePr oxy.Create (goal);        
185                         goal.Id =  _goalId;        
186          
187                         Console.Wr iteLine("C reated goa l");        
188                         Console.Wr iteLine("- ---------- --------") ;        
189                         Console.Wr iteLine("T arget: {0} ", goal.Ta rgetIntege r.Value);        
190                         Console.Wr iteLine("G oal owner:  {0}", goa l.GoalOwne rId.Id);        
191                         Console.Wr iteLine("G oal Start  Date: {0}" , goal.Goa lStartDate );        
192                         Console.Wr iteLine("G oal End Da te: {0}",  goal.GoalE ndDate);        
193                         Console.Wr iteLine("< End of Lis ting>");        
194                         Console.Wr iteLine();        
195          
196                         #endregion        
197          
198                         #region Ca lculate ro llup and d isplay res ult        
199          
200                         // Calcula te roll-up  of the go al.        
201                         Recalculat eRequest r ecalculate Request =  new Recalc ulateReque st()        
202                         {        
203                             Target  = goal.To EntityRefe rence()        
204                         };        
205                         _servicePr oxy.Execut e(recalcul ateRequest );        
206          
207                         Console.Wr iteLine("C alculated  roll-up of  goal.");        
208                         Console.Wr iteLine();        
209          
210                         // Retriev e and repo rt 3 diffe rent compu ted values  for the g oal        
211                         // - Perce ntage        
212                         // - Actua l (Integer )        
213                         // - In-Pr ogress (In teger)        
214                         QueryExpre ssion retr ieveValues  = new Que ryExpressi on()        
215                         {        
216                             Entity Name = Goa l.EntityLo gicalName,        
217                             Column Set = new  ColumnSet(        
218                                 "t itle",        
219                                 "p ercentage" ,        
220                                 "a ctualinteg er",        
221                                 "i nprogressi nteger")        
222                         };        
223                         EntityColl ection ec  = _service Proxy.Retr ieveMultip le(retriev eValues);        
224          
225                         // Compute  and displ ay the res ults.        
226                         for (int i  = 0; i <  ec.Entitie s.Count; i ++)        
227                         {        
228                             Goal t emp = (Goa l)ec.Entit ies[i];        
229                             Consol e.WriteLin e("Roll-up  details f or goal: { 0}", temp. Title);        
230                             Consol e.WriteLin e("------- --------") ;        
231                             Consol e.WriteLin e("Percent age Achiev ed: {0}",        
232                                 te mp.Percent age);        
233                             Consol e.WriteLin e("Actual  (Integer):  {0}",        
234                                 te mp.ActualI nteger.Val ue);        
235                             Consol e.WriteLin e("In-Prog ress (Inte ger): {0}" ,        
236                                 te mp.InProgr essInteger .Value);        
237                             Consol e.WriteLin e("<End of  Listing>" );        
238                         }        
239          
240                         Console.Wr iteLine();        
241          
242                         #endregion        
243          
244                         #region Up date goal  to overrid e the actu al rollup  value        
245          
246                         // Overrid e the actu al and in- progress v alues of t he goal.        
247                         // To prev ent rollup  values to  be overwr itten duri ng next Re calculate  operation,          
248                         // set: go al.IsOverr idden = tr ue;        
249          
250                         goal.IsOve rride = tr ue;        
251                         goal.Actua lInteger =  10;        
252                         goal.InPro gressInteg er = 5;        
253          
254                         // Update  the goal.        
255                         UpdateRequ est update  = new Upd ateRequest ()        
256                         {        
257                             Target  = goal        
258                         };        
259                         _servicePr oxy.Execut e(update);        
260          
261                         Console.Wr iteLine("G oal actual  and in-pr ogress val ues overri dden.");        
262                         Console.Wr iteLine();        
263          
264                         #endregion        
265          
266                         #region Re trieve res ult of man ual overri de        
267          
268                         // Retriev e and repo rt 3 diffe rent compu ted values  for the g oal        
269                         // - Perce ntage        
270                         // - Actua l (Integer )        
271                         // - In-Pr ogress (In teger)        
272                         retrieveVa lues = new  QueryExpr ession()        
273                         {        
274                             Entity Name = Goa l.EntityLo gicalName,        
275                             Column Set = new  ColumnSet(        
276                                 "t itle",        
277                                 "p ercentage" ,        
278                                 "a ctualinteg er",        
279                                 "i nprogressi nteger")        
280                         };        
281                         ec = _serv iceProxy.R etrieveMul tiple(retr ieveValues );        
282          
283                         // Compute  and displ ay the res ults.        
284                         for (int i  = 0; i <  ec.Entitie s.Count; i ++)        
285                         {        
286                             Goal t emp = (Goa l)ec.Entit ies[i];        
287                             Consol e.WriteLin e("Roll-up  details f or goal: { 0}", temp. Title);        
288                             Consol e.WriteLin e("------- --------") ;        
289                             Consol e.WriteLin e("Percent age Achiev ed: {0}",        
290                                 te mp.Percent age);        
291                             Consol e.WriteLin e("Actual  (Integer):  {0}",        
292                                 te mp.ActualI nteger.Val ue);        
293                             Consol e.WriteLin e("In-Prog ress (Inte ger): {0}" ,        
294                                 te mp.InProgr essInteger .Value);        
295                             Consol e.WriteLin e("<End of  Listing>" );        
296                         }        
297          
298                         Console.Wr iteLine();        
299          
300                         #endregion        
301          
302                         #region Cl ose the go al        
303          
304                         // Close t he goal.        
305                         SetStateRe quest clos eGoal = ne w SetState Request()        
306                         {        
307                             Entity Moniker =  goal.ToEnt ityReferen ce(),        
308                             State  = new Opti onSetValue (1),        
309                             Status  = new Opt ionSetValu e(1)        
310                         };        
311          
312                         Console.Wr iteLine("G oal closed .");        
313          
314                         #endregion        
315          
316                         DeleteRequ iredRecord s(promptfo rDelete);        
317                    }        
318                    //</ snippetOve rrideGoalT otalCount1 >        
319                }        
320          
321                // Catch  any servi ce fault e xceptions  that Micro soft Dynam ics CRM th rows.        
322                catch (F aultExcept ion<Micros oft.Xrm.Sd k.Organiza tionServic eFault>)        
323                {        
324                    // Y ou can han dle an exc eption her e or pass  it back to  the calli ng method.        
325                    thro w;        
326                }        
327           }        
328          
329           // / <summary >        
330           // / Creates  any entity  records t hat this s ample requ ires.        
331           // / </summar y>        
332           pu blic void  CreateRequ iredRecord s()        
333           {        
334          
335                #region  Create or  Retrieve t he necessa ry system  users        
336          
337                // Retri eve a sale s manager.        
338                _salesMa nagerId =         
339                    Syst emUserProv ider.Retri eveMarketi ngManager( _servicePr oxy);        
340          
341                #endregi on        
342          
343                #region  Create Pho neCall rec ord and su pporting a ccount        
344          
345                Account  newAccount  = new Acc ount        
346                {        
347                    Name  = "Margie 's Travel" ,        
348                    Addr ess1_Posta lCode = "9 9999"        
349                };        
350                _account Id = (_ser viceProxy. Create(new Account));        
351                newAccou nt.Id = _a ccountId;        
352          
353                // Creat e Guids fo r PhoneCal ls        
354                _phoneCa llId = Gui d.NewGuid( );        
355                _phoneCa ll2Id = Gu id.NewGuid ();        
356          
357                // Creat e Activity Partys for  the phone  calls' "F rom" field .        
358                Activity Party acti vityParty  = new Acti vityParty( )        
359                {        
360                    Part yId = newA ccount.ToE ntityRefer ence(),        
361                    Acti vityId = n ew EntityR eference        
362                    {        
363                         Id = _phon eCallId,        
364                         LogicalNam e = PhoneC all.Entity LogicalNam e,        
365                    },        
366                    Part icipationT ypeMask =  new Option SetValue(9 )        
367                };        
368          
369                Activity Party acti vityPartyC losed = ne w Activity Party()        
370                {        
371                    Part yId = newA ccount.ToE ntityRefer ence(),        
372                    Acti vityId = n ew EntityR eference        
373                    {        
374                         Id = _phon eCall2Id,        
375                         LogicalNam e = PhoneC all.Entity LogicalNam e,        
376                    },        
377                    Part icipationT ypeMask =  new Option SetValue(9 )        
378                };        
379          
380                // Creat e an open  phone call .        
381                PhoneCal l phoneCal l = new Ph oneCall()        
382                {        
383                    Id =  _phoneCal lId,        
384                    Subj ect = "Sam ple Phone  Call",        
385                    Dire ctionCode  = false,        
386                    To =  new Activ ityParty[]  { activit yParty }        
387                };        
388                _service Proxy.Crea te(phoneCa ll);        
389          
390                // Creat e a second  phone cal l to close        
391                phoneCal l = new Ph oneCall()        
392                {        
393                    Id =  _phoneCal l2Id,        
394                    Subj ect = "Sam ple Phone  Call 2",        
395                    Dire ctionCode  = false,        
396                    To =  new Activ ityParty[]  { activit yParty },        
397                    Actu alEnd = Da teTime.Now        
398                };        
399                _service Proxy.Crea te(phoneCa ll);        
400          
401                // Close  the secon d phone ca ll.        
402                SetState Request cl osePhoneCa ll = new S etStateReq uest()        
403                {        
404                    Enti tyMoniker  = phoneCal l.ToEntity Reference( ),        
405                    Stat e = new Op tionSetVal ue(1),        
406                    Stat us = new O ptionSetVa lue(4)        
407                };        
408                _service Proxy.Exec ute(closeP honeCall);        
409          
410                #endregi on        
411           }        
412          
413           // / <summary >        
414           // / Deletes  any entity  records t hat were c reated for  this samp le.        
415           // / <param n ame="promp t">Indicat es whether  to prompt  the user         
416           // / to delet e the reco rds create d in this  sample.</p aram>        
417           // / </summar y>        
418           pu blic void  DeleteRequ iredRecord s(bool pro mpt)        
419           {        
420                // The t hree syste m users th at were cr eated by t his sample  will cont inue to         
421                // exist  on your s ystem beca use system  users can not be del eted in Mi crosoft        
422                // Dynam ics CRM.   They can o nly be ena bled or di sabled.        
423          
424                bool toB eDeleted =  true;        
425          
426                if (prom pt)        
427                {        
428                    // A sk the use r if the c reated ent ities shou ld be dele ted.        
429                    Cons ole.Write( "\nDo you  want these  entity re cords dele ted? (y/n)  [y]: ");        
430                    Stri ng answer  = Console. ReadLine() ;        
431                    if ( answer.Sta rtsWith("y ") ||        
432                         answer.Sta rtsWith("Y ") ||        
433                         answer ==  String.Emp ty)        
434                    {        
435                         toBeDelete d = true;        
436                    }        
437                    else        
438                    {        
439                         toBeDelete d = false;        
440                    }        
441                }        
442          
443                if (toBe Deleted)        
444                {        
445                    // D elete all  records cr eated in t his sample .        
446                    _ser viceProxy. Delete("ph onecall",  _phoneCall Id);        
447                    _ser viceProxy. Delete("ph onecall",  _phoneCall 2Id);        
448                    _ser viceProxy. Delete("go al", _goal Id);        
449                    _ser viceProxy. Delete("go alrollupqu ery", _rol lupQueryId s[1]);        
450                    _ser viceProxy. Delete("go alrollupqu ery", _rol lupQueryId s[0]);        
451                    _ser viceProxy. Delete("ac count", _a ccountId);        
452                    _ser viceProxy. Delete("ro llupfield" , _actualI d);        
453                    _ser viceProxy. Delete("ro llupfield" , _inprogr essId);        
454                    _ser viceProxy. Delete("me tric", _me tricId);        
455          
456                    Cons ole.WriteL ine("Entit y record(s ) have bee n deleted. ");        
457                }        
458           }        
459          
460           #e ndregion H ow To Samp le Code        
461          
462           #r egion Main  method        
463          
464           // / <summary >        
465           // / Standard  Main() me thod used  by most SD K samples.        
466           // / </summar y>        
467           // / <param n ame="args" ></param>        
468           st atic publi c void Mai n(string[]  args)        
469           {        
470                try        
471                {        
472                    // O btain the  target org anization' s Web addr ess and cl ient logon          
473                    // c redentials  from the  user.        
474                    Serv erConnecti on serverC onnect = n ew ServerC onnection( );        
475                    Serv erConnecti on.Configu ration con fig = serv erConnect. GetServerC onfigurati on();        
476          
477                    Over rideGoalTo talCount a pp = new O verrideGoa lTotalCoun t();        
478                    app. Run(config , true);        
479                }        
480                catch (F aultExcept ion<Micros oft.Xrm.Sd k.Organiza tionServic eFault> ex )        
481                {        
482                    Cons ole.WriteL ine("The a pplication  terminate d with an  error.");        
483                    Cons ole.WriteL ine("Times tamp: {0}" , ex.Detai l.Timestam p);        
484                    Cons ole.WriteL ine("Code:  {0}", ex. Detail.Err orCode);        
485                    Cons ole.WriteL ine("Messa ge: {0}",  ex.Detail. Message);        
486                    Cons ole.WriteL ine("Plugi n Trace: { 0}", ex.De tail.Trace Text);        
487                    Cons ole.WriteL ine("Inner  Fault: {0 }",        
488                         null == ex .Detail.In nerFault ?  "No Inner  Fault" :  "Has Inner  Fault");        
489                }        
490                catch (S ystem.Time outExcepti on ex)        
491                {        
492                    Cons ole.WriteL ine("The a pplication  terminate d with an  error.");        
493                    Cons ole.WriteL ine("Messa ge: {0}",  ex.Message );        
494                    Cons ole.WriteL ine("Stack  Trace: {0 }", ex.Sta ckTrace);        
495                    Cons ole.WriteL ine("Inner  Fault: {0 }",        
496                         null == ex .InnerExce ption.Mess age ? "No  Inner Faul t" : ex.In nerExcepti on.Message );        
497                }        
498                catch (S ystem.Exce ption ex)        
499                {        
500                    Cons ole.WriteL ine("The a pplication  terminate d with an  error.");        
501                    Cons ole.WriteL ine(ex.Mes sage);        
502          
503                    // D isplay the  details o f the inne r exceptio n.        
504                    if ( ex.InnerEx ception !=  null)        
505                    {        
506                         Console.Wr iteLine(ex .InnerExce ption.Mess age);        
507          
508                         FaultExcep tion<Micro soft.Xrm.S dk.Organiz ationServi ceFault> f e = ex.Inn erExceptio n        
509                             as Fau ltExceptio n<Microsof t.Xrm.Sdk. Organizati onServiceF ault>;        
510                         if (fe !=  null)        
511                         {        
512                             Consol e.WriteLin e("Timesta mp: {0}",  fe.Detail. Timestamp) ;        
513                             Consol e.WriteLin e("Code: { 0}", fe.De tail.Error Code);        
514                             Consol e.WriteLin e("Message : {0}", fe .Detail.Me ssage);        
515                             Consol e.WriteLin e("Plugin  Trace: {0} ", fe.Deta il.TraceTe xt);        
516                             Consol e.WriteLin e("Inner F ault: {0}" ,        
517                                 nu ll == fe.D etail.Inne rFault ? " No Inner F ault" : "H as Inner F ault");        
518                         }        
519                    }        
520                }        
521                // Addit ional exce ptions to  catch: Sec urityToken Validation Exception,  ExpiredSe curityToke nException ,        
522                // Secur ityAccessD eniedExcep tion, Mess ageSecurit yException , and Secu rityNegoti ationExcep tion.        
523          
524                finally        
525                {        
526                    Cons ole.WriteL ine("Press  <Enter> t o exit.");        
527                    Cons ole.ReadLi ne();        
528                }        
529           }        
530           #e ndregion M ain method        
531       }        
532   }        
533   //</snippe tOverrideG oalTotalCo unt>