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

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

221.2 Comparison summary

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

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

221.4 Active regular expressions

No regular expressions were active.

221.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 UsingQueri esToTrackG oals>        
17   using Syst em;        
18   using Syst em.Service Model;        
19          
20   // These n amespaces  are found  in the Mic rosoft.Xrm .Sdk.dll a ssembly        
21   // located  in the SD K\bin fold er of the  SDK downlo ad.        
22   using Micr osoft.Xrm. Sdk;        
23   using Micr osoft.Xrm. Sdk.Query;        
24   using Micr osoft.Xrm. Sdk.Client ;        
25          
26   // This na mespace is  found in  Microsoft. Crm.Sdk.Pr oxy.dll as sembly        
27   // found i n the SDK\ bin folder .        
28   using Micr osoft.Crm. Sdk.Messag es;        
29          
30   namespace  Microsoft. Crm.Sdk.Sa mples        
31   {        
32       /// <s ummary>        
33       /// De monstrates  how to us e queries  to track g oals.</sum mary>        
34       /// <r emarks>        
35       /// At  run-time,  you will  be given t he option  to delete  all the        
36       /// da tabase rec ords creat ed by this  program.< /remarks>        
37       public  class Usi ngQueriesT oTrackGoal s        
38       {        
39           #r egion Clas s Level Me mbers        
40          
41           pr ivate Guid  _salesMan agerId;        
42           pr ivate Guid  _unitGrou pId;        
43           pr ivate Guid  _defaultU nitId;        
44           pr ivate Guid  _productI d;        
45           pr ivate Guid  _priceLis tId;        
46           pr ivate Guid  _priceLis tItemId;        
47           pr ivate Guid  _orderDet ailId;        
48           pr ivate Guid  _metricId ;        
49           pr ivate Guid  _actualId ;        
50           pr ivate Guid  _parentGo alId;        
51           pr ivate Guid  _firstChi ldGoalId;        
52           pr ivate Guid  _accountI d;        
53           pr ivate Guid  _rollupQu eryId;        
54           pr ivate Guid  _salesRep resentativ eId;        
55           pr ivate Guid  _orderId;        
56          
57           pr ivate Orga nizationSe rviceProxy  _serviceP roxy;        
58          
59           #e ndregion C lass Level  Members        
60          
61           #r egion How  To Sample  Code        
62           // / <summary >        
63           // / This met hod first  connects t o the Orga nization s ervice. Af terwards,         
64           // / rollup f ield and r ollup quer y are crea ted. The r ollup quer y is only        
65           // / associat ed with th e child go al. Then a  parent go al and chi ld goal        
66           // / are crea ted. The g oals are b oth rolled  up and th eir result s are disp layed.         
67           // / </summar y>        
68           // / <param n ame="serve rConfig">C ontains se rver conne ction info rmation.</ param>        
69           // / <param n ame="promp tforDelete ">When Tru e, the use r will be  prompted t o delete a ll        
70           // / created  entities.< /param>        
71           pu blic void  Run(Server Connection .Configura tion serve rConfig, b ool prompt forDelete)        
72           {        
73                try        
74                {        
75                    //<s nippetUsin gQueriesTo TrackGoals 1>        
76                    // C onnect to  the Organi zation ser vice.         
77                    // T he using s tatement a ssures tha t the serv ice proxy  will be pr operly dis posed.        
78                    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 ))        
79                    {        
80                         // This st atement is  required  to enable  early-boun d type sup port.        
81                         _servicePr oxy.Enable ProxyTypes ();        
82          
83                         CreateRequ iredRecord s();        
84          
85                         // Create  the revenu e metric,  setting th e Amount D ata Type t o 'Money'        
86                         // and the  Metric Ty pe to 'Amo unt'.        
87                         Metric sam pleMetric  = new Metr ic()        
88                         {        
89                             Name =  "Sample R evenue Met ric",        
90                             Amount DataType =  new Optio nSetValue( 0),        
91                             IsAmou nt = true,        
92                         };        
93                         _metricId  = _service Proxy.Crea te(sampleM etric);        
94                         sampleMetr ic.Id = _m etricId;        
95          
96                         Console.Wr ite("Creat ed revenue  metric, " );        
97          
98                         #region Cr eate Rollu pFields        
99          
100                         // Create  RollupFiel d which ta rgets the  actual tot als.        
101                         RollupFiel d actual =  new Rollu pField()        
102                         {        
103                             Source Entity = S alesOrder. EntityLogi calName,        
104                             Source Attribute  = "totalam ount",        
105                             GoalAt tribute =  "actualmon ey",        
106                             Source State = 1,        
107                             Entity ForDateAtt ribute = S alesOrder. EntityLogi calName,        
108                             DateAt tribute =  "datefulfi lled",        
109                             Metric Id = sampl eMetric.To EntityRefe rence()        
110                         };        
111                         _actualId  = _service Proxy.Crea te(actual) ;        
112          
113                         Console.Wr ite("creat ed actual  revenue Ro llupField,  ");        
114          
115                         #endregion        
116          
117                         #region Cr eate the g oal rollup  query        
118          
119                         // The que ry locates  sales ord ers in the  first sal es         
120                         // represe ntative's  area (zip  code: 6066 1) and wit h a value        
121                         // greater  than $1,0 00.        
122                         GoalRollup Query goal RollupQuer y = new Go alRollupQu ery()        
123                         {        
124                             Name =  "First Ex ample Goal  Rollup Qu ery",        
125                             QueryE ntityType  = SalesOrd er.EntityL ogicalName ,        
126                             FetchX ml = @"<fe tch mappin g=""logica l"" versio n=""1.0""> <entity na me=""sales order""><a ttribute n ame=""cust omerid"" / ><attribut e name=""n ame"" /><a ttribute n ame=""sale sorderid""  /><attrib ute name=" "statuscod e"" /><att ribute nam e=""totala mount"" /> <order att ribute=""n ame"" /><f ilter><con dition att ribute=""t otalamount "" operato r=""gt"" v alue=""100 0"" /><con dition att ribute=""b illto_post alcode"" o perator="" eq"" value =""60661""  /></filte r></entity ></fetch>"        
127                         };        
128                         _rollupQue ryId = _se rviceProxy .Create(go alRollupQu ery);        
129                         goalRollup Query.Id =  _rollupQu eryId;        
130          
131                         Console.Wr ite("creat ed rollup  query.");        
132                         Console.Wr iteLine();        
133          
134                         #endregion        
135          
136                         #region Cr eate two g oals: one  parent and  one child  goal        
137          
138                         // Create  the parent  goal.        
139                         Goal paren tGoal = ne w Goal()        
140                         {        
141                             Title  = "Parent  Goal Examp le",        
142                             Rollup OnlyFromCh ildGoals =  true,        
143                             Target Money = ne w Money(10 00.0M),        
144                             IsFisc alPeriodGo al = false ,        
145                             Metric Id = sampl eMetric.To EntityRefe rence(),        
146                             GoalOw nerId = ne w EntityRe ference        
147                             {        
148                                 Id  = _salesM anagerId,        
149                                 Lo gicalName  = SystemUs er.EntityL ogicalName        
150                             },        
151                             OwnerI d = new En tityRefere nce        
152                             {        
153                                 Id  = _salesM anagerId,        
154                                 Lo gicalName  = SystemUs er.EntityL ogicalName        
155                             },        
156                             GoalSt artDate =  DateTime.T oday.AddDa ys(-1),        
157                             GoalEn dDate = Da teTime.Tod ay.AddDays (30)        
158                         };        
159                         _parentGoa lId = _ser viceProxy. Create(par entGoal);        
160                         parentGoal .Id = _par entGoalId;        
161          
162                         Console.Wr iteLine("C reated par ent goal") ;        
163                         Console.Wr iteLine("- ---------- --------") ;        
164                         Console.Wr iteLine("T arget: {0} ", parentG oal.Target Money.Valu e);        
165                         Console.Wr iteLine("G oal owner:  {0}", par entGoal.Go alOwnerId. Id);        
166                         Console.Wr iteLine("G oal Start  Date: {0}" , parentGo al.GoalSta rtDate);        
167                         Console.Wr iteLine("G oal End Da te: {0}",  parentGoal .GoalEndDa te);        
168                         Console.Wr iteLine("< End of Lis ting>");        
169                         Console.Wr iteLine();        
170          
171                         // Create  the child  goal.        
172                         Goal first ChildGoal  = new Goal ()        
173                         {        
174                             Title  = "First C hild Goal  Example",        
175                             Consid erOnlyGoal OwnersReco rds = true ,        
176                             Target Money = ne w Money(10 00.0M),        
177                             IsFisc alPeriodGo al = false ,        
178                             Metric Id = sampl eMetric.To EntityRefe rence(),        
179                             Parent GoalId = p arentGoal. ToEntityRe ference(),        
180                             GoalOw nerId = ne w EntityRe ference        
181                             {        
182                                 Id  = _salesR epresentat iveId,        
183                                 Lo gicalName  = SystemUs er.EntityL ogicalName        
184                             },        
185                             OwnerI d = new En tityRefere nce        
186                             {        
187                                 Id  = _salesM anagerId,        
188                                 Lo gicalName  = SystemUs er.EntityL ogicalName        
189                             },        
190                             RollUp QueryActua lMoneyId =  goalRollu pQuery.ToE ntityRefer ence(),        
191                             GoalSt artDate =  DateTime.T oday.AddDa ys(-1),        
192                             GoalEn dDate = Da teTime.Tod ay.AddDays (30)        
193                         };        
194                         _firstChil dGoalId =  _servicePr oxy.Create (firstChil dGoal);        
195          
196                         Console.Wr iteLine("F irst child  goal");        
197                         Console.Wr iteLine("- ---------- -----");        
198                         Console.Wr iteLine("T arget: {0} ", firstCh ildGoal.Ta rgetMoney. Value);        
199                         Console.Wr iteLine("G oal owner:  {0}", fir stChildGoa l.GoalOwne rId.Id);        
200                         Console.Wr iteLine("G oal Start  Date: {0}" , firstChi ldGoal.Goa lStartDate );        
201                         Console.Wr iteLine("G oal End Da te: {0}",  firstChild Goal.GoalE ndDate);        
202                         Console.Wr iteLine("< End of Lis ting>");        
203                         Console.Wr iteLine();        
204          
205                         #endregion        
206          
207                         // Calcula te roll-up  of goals.        
208                         // Note: R ecalculate  can be ru n against  any goal i n the tree  to cause        
209                         // a rollu p of the w hole tree.        
210                         Recalculat eRequest r ecalculate Request =  new Recalc ulateReque st()        
211                         {        
212                             Target  = parentG oal.ToEnti tyReferenc e()        
213                         };        
214                         _servicePr oxy.Execut e(recalcul ateRequest );        
215          
216                         Console.Wr iteLine("C alculated  roll-up of  goals.");        
217                         Console.Wr iteLine();        
218          
219                         // Retriev e and repo rt 3 diffe rent compu ted values  for the g oals        
220                         // - Perce ntage        
221                         // - Compu tedTargetA sOfTodayPe rcentageAc hieved        
222                         // - Compu tedTargetA sOfTodayMo ney        
223                         QueryExpre ssion retr ieveValues  = new Que ryExpressi on()        
224                         {        
225                             Entity Name = Goa l.EntityLo gicalName,        
226                             Column Set = new  ColumnSet(        
227                                 "t itle",        
228                                 "c omputedtar getasoftod aypercenta geachieved ",        
229                                 "c omputedtar getasoftod aymoney")        
230                         };        
231                         EntityColl ection ec  = _service Proxy.Retr ieveMultip le(retriev eValues);        
232          
233                         // Compute  and displ ay the res ults        
234                         for (int i  = 0; i <  ec.Entitie s.Count; i ++)        
235                         {        
236                             Goal t emp = (Goa l)ec.Entit ies[i];        
237                             Consol e.WriteLin e("Roll-up  details f or goal: { 0}", temp. Title);        
238                             Consol e.WriteLin e("------- --------") ;        
239                             Consol e.WriteLin e("Compute dTargetAsO fTodayPerc entageAchi eved: {0}" ,        
240                                 te mp.Compute dTargetAsO fTodayPerc entageAchi eved);        
241                             Consol e.WriteLin e("Compute dTargetAsO fTodayMone y: {0}",        
242                                 te mp.Compute dTargetAsO fTodayMone y.Value);        
243                             Consol e.WriteLin e("<End of  Listing>" );        
244                         }        
245          
246                         DeleteRequ iredRecord s(promptfo rDelete);        
247                    }        
248                    //</ snippetUsi ngQueriesT oTrackGoal s1>        
249                }        
250          
251                // Catch  any servi ce fault e xceptions  that Micro soft Dynam ics CRM th rows.        
252                catch (F aultExcept ion<Micros oft.Xrm.Sd k.Organiza tionServic eFault>)        
253                {        
254                    // Y ou can han dle an exc eption her e or pass  it back to  the calli ng method.        
255                    thro w;        
256                }        
257           }        
258          
259           // / <summary >        
260           // / Creates  any entity  records t hat this s ample requ ires.        
261           // / </summar y>        
262           pu blic void  CreateRequ iredRecord s()        
263           {        
264          
265                #region  Create or  Retrieve t he necessa ry system  users        
266          
267                // Retri eve the ld apPath        
268                String l dapPath =  String.Emp ty;        
269                // Retri eve the sa les team -  1 sales m anager and  2 sales r epresentat ives.        
270                _salesMa nagerId =        
271                    Syst emUserProv ider.Retri eveSalesMa nager(_ser viceProxy,  ref ldapP ath);        
272                _salesRe presentati veId =        
273                    Syst emUserProv ider.Retri eveSalespe rsons(_ser viceProxy,  ref ldapP ath)[0];        
274          
275                #endregi on        
276          
277                #region  Create rec ords to su pport Sale sOrder rec ords        
278                // Creat e a unit g roup        
279                UoMSched ule newUni tGroup = n ew UoMSche dule        
280                {        
281                    Name  = "Exampl e Unit Gro up",        
282                    Base UoMName =  "Example P rimary Uni t"        
283                };        
284                _unitGro upId = _se rviceProxy .Create(ne wUnitGroup );        
285          
286                // Retri eve the de fault unit  id that w as automat ically cre ated        
287                // when  we created  the Unit  Group        
288                QueryExp ression un itQuery =  new QueryE xpression        
289                {        
290                    Enti tyName = U oM.EntityL ogicalName ,        
291                    Colu mnSet = ne w ColumnSe t("uomid",  "name"),        
292                    Crit eria = new  FilterExp ression        
293                    {        
294                         Conditions  =         
295                             {        
296                                 ne w Conditio nExpressio        
297                                 {        
298                                      Attribut eName = "u omschedule id",        
299                                      Operator  = Conditi onOperator .Equal,        
300                                      Values =  { _unitGr oupId }        
301                                 }        
302                             }        
303                    },        
304                    Page Info = new  PagingInf o        
305                    {        
306                         PageNumber  = 1,        
307                         Count = 1        
308                    }        
309                };        
310          
311                // Retri eve the un it.        
312                UoM unit  = (UoM)_s erviceProx y.Retrieve Multiple(u nitQuery). Entities[0 ];        
313                _default UnitId = u nit.UoMId. Value;        
314          
315                // Creat e a few pr oducts        
316                Product  newProduct  = new Pro duct        
317                {        
318                    Prod uctNumber  = "1",        
319                    Name  = "Exampl e Product" ,        
320                    Prod uctStructu re = new O ptionSetVa lue(1),        
321                    Quan tityDecima l = 2,        
322                    Defa ultUoMSche duleId =        
323                         new Entity Reference( UoMSchedul e.EntityLo gicalName,  _unitGrou pId),        
324                    Defa ultUoMId =  new Entit yReference (UoM.Entit yLogicalNa me, _defau ltUnitId)        
325                };        
326                _product Id = _serv iceProxy.C reate(newP roduct);        
327                newProdu ct.Id = _p roductId;        
328                Console. WriteLine( "Created { 0}", newPr oduct.Name );        
329          
330                // Creat e a price  list        
331                PriceLev el newPric eList = ne w PriceLev el        
332                {        
333                    Name  = "Exampl e Price Li st"        
334                };        
335                _priceLi stId = _se rviceProxy .Create(ne wPriceList );        
336          
337                // Creat e a price  list item  for the fi rst produc t and appl y volume d iscount        
338                ProductP riceLevel  newPriceLi stItem = n ew Product PriceLevel        
339                {        
340                    Pric eLevelId =        
341                         new Entity Reference( PriceLevel .EntityLog icalName,  _priceList Id),        
342                    Prod uctId =        
343                         new Entity Reference( Product.En tityLogica lName, _pr oductId),        
344                    UoMI d =        
345                         new Entity Reference( UoM.Entity LogicalNam e, _defaul tUnitId),        
346                    Amou nt = new M oney(20),        
347                };        
348                _priceLi stItemId =  _serviceP roxy.Creat e(newPrice ListItem);        
349          
350                // Publi sh the pro duct        
351                SetState Request pu blishReque st = new S etStateReq uest        
352                {        
353                    Enti tyMoniker  = new Enti tyReferenc e(Product. EntityLogi calName, _ productId) ,        
354                    Stat e = new Op tionSetVal ue((int)Pr oductState .Active),        
355                    Stat us = new O ptionSetVa lue(1)        
356                };        
357                _service Proxy.Exec ute(publis hRequest);        
358                Console. WriteLine( "Published  {0}", new Product.Na me);        
359          
360          
361                // Creat e an accou nt record  for the sa les order' s potentia l customer id         
362                Account  newAccount  = new Acc ount        
363                {        
364                    Name  = "Litwar e, Inc.",        
365                    Addr ess1_Posta lCode = "6 0661"        
366                };        
367                _account Id = _serv iceProxy.C reate(newA ccount);        
368                newAccou nt.Id = _a ccountId;        
369          
370                #endregi on Create  records to  support S alesOrder        
371          
372                #region  Create Sal esOrder re cord        
373          
374                // Creat e the sale s order.        
375                SalesOrd er order =  new Sales Order()        
376                {        
377                    Name  = "Faux O rder",        
378                    Date Fulfilled  = new Date Time(2010,  8, 1),        
379                    Pric eLevelId =        
380                         new Entity Reference( PriceLevel .EntityLog icalName,  _priceList Id),        
381                    Cust omerId =        
382                         new Entity Reference( Account.En tityLogica lName, _ac countId),        
383                    Frei ghtAmount  = new Mone y(20.0M)        
384                };        
385                _orderId  = _servic eProxy.Cre ate(order) ;        
386                order.Id  = _orderI d;        
387          
388                // Add t he product  to the or der with t he price o verriden w ith a        
389                // negat ive value.        
390                SalesOrd erDetail o rderDetail  = new Sal esOrderDet ail()        
391                {        
392                    Prod uctId = ne wProduct.T oEntityRef erence(),        
393                    Quan tity = 4,        
394                    Sale sOrderId =  order.ToE ntityRefer ence(),        
395                    IsPr iceOverrid den = true ,        
396                    Pric ePerUnit =  new Money (1000.0M),        
397                    UoMI d = new En tityRefere nce(UoM.En tityLogica lName, _de faultUnitI d)        
398                };        
399                _orderDe tailId = _ servicePro xy.Create( orderDetai l);        
400          
401                #endregi on Create  SalesOrder  record        
402           }        
403          
404           // / <summary >        
405           // / Deletes  any entity  records t hat were c reated for  this samp le.        
406           // / <param n ame="promp t">Indicat es whether  to prompt  the user         
407           // / to delet e the reco rds create d in this  sample.</p aram>        
408           // / </summar y>        
409           pu blic void  DeleteRequ iredRecord s(bool pro mpt)        
410           {        
411                // The t hree syste m users th at were cr eated by t his sample  will cont inue to         
412                // exist  on your s ystem beca use system  users can not be del eted in Mi crosoft        
413                // Dynam ics CRM.   They can o nly be ena bled or di sabled.        
414          
415                bool toB eDeleted =  true;        
416          
417                if (prom pt)        
418                {        
419                    // A sk the use r if the c reated ent ities shou ld be dele ted.        
420                    Cons ole.Write( "\nDo you  want these  entity re cords dele ted? (y/n)  [y]: ");        
421                    Stri ng answer  = Console. ReadLine() ;        
422                    if ( answer.Sta rtsWith("y ") ||        
423                         answer.Sta rtsWith("Y ") ||        
424                         answer ==  String.Emp ty)        
425                    {        
426                         toBeDelete d = true;        
427                    }        
428                    else        
429                    {        
430                         toBeDelete d = false;        
431                    }        
432                }        
433          
434                if (toBe Deleted)        
435                {        
436                    // D elete all  records cr eated in t his sample .        
437                    _ser viceProxy. Delete("go al", _firs tChildGoal Id);        
438                    _ser viceProxy. Delete("go al", _pare ntGoalId);        
439                    _ser viceProxy. Delete("go alrollupqu ery", _rol lupQueryId );        
440                    _ser viceProxy. Delete("sa lesorderde tail", _or derDetailI d);        
441                    _ser viceProxy. Delete("sa lesorder",  _orderId) ;        
442                    _ser viceProxy. Delete("ac count", _a ccountId);        
443                    _ser viceProxy. Delete("pr oductprice level", _p riceListIt emId);        
444                    _ser viceProxy. Delete("pr icelevel",  _priceLis tId);        
445                    _ser viceProxy. Delete("pr oduct", _p roductId);        
446                    _ser viceProxy. Delete("uo mschedule" , _unitGro upId);        
447                    _ser viceProxy. Delete("ro llupfield" , _actualI d);        
448                    _ser viceProxy. Delete("me tric", _me tricId);        
449          
450                    Cons ole.WriteL ine("Entit y record(s ) have bee n deleted. ");        
451                }        
452           }        
453          
454           #e ndregion H ow To Samp le Code        
455          
456           #r egion Main  method        
457          
458           // / <summary >        
459           // / Standard  Main() me thod used  by most SD K samples.        
460           // / </summar y>        
461           // / <param n ame="args" ></param>        
462           st atic publi c void Mai n(string[]  args)        
463           {        
464                try        
465                {        
466                    // O btain the  target org anization' s Web addr ess and cl ient logon          
467                    // c redentials  from the  user.        
468                    Serv erConnecti on serverC onnect = n ew ServerC onnection( );        
469                    Serv erConnecti on.Configu ration con fig = serv erConnect. GetServerC onfigurati on();        
470          
471                    Usin gQueriesTo TrackGoals  app = new  UsingQuer iesToTrack Goals();        
472                    app. Run(config , true);        
473                }        
474                catch (F aultExcept ion<Micros oft.Xrm.Sd k.Organiza tionServic eFault> ex )        
475                {        
476                    Cons ole.WriteL ine("The a pplication  terminate d with an  error.");        
477                    Cons ole.WriteL ine("Times tamp: {0}" , ex.Detai l.Timestam p);        
478                    Cons ole.WriteL ine("Code:  {0}", ex. Detail.Err orCode);        
479                    Cons ole.WriteL ine("Messa ge: {0}",  ex.Detail. Message);        
480                    Cons ole.WriteL ine("Plugi n Trace: { 0}", ex.De tail.Trace Text);        
481                    Cons ole.WriteL ine("Inner  Fault: {0 }",        
482                         null == ex .Detail.In nerFault ?  "No Inner  Fault" :  "Has Inner  Fault");        
483                }        
484                catch (S ystem.Time outExcepti on ex)        
485                {        
486                    Cons ole.WriteL ine("The a pplication  terminate d with an  error.");        
487                    Cons ole.WriteL ine("Messa ge: {0}",  ex.Message );        
488                    Cons ole.WriteL ine("Stack  Trace: {0 }", ex.Sta ckTrace);        
489                    Cons ole.WriteL ine("Inner  Fault: {0 }",        
490                         null == ex .InnerExce ption.Mess age ? "No  Inner Faul t" : ex.In nerExcepti on.Message );        
491                }        
492                catch (S ystem.Exce ption ex)        
493                {        
494                    Cons ole.WriteL ine("The a pplication  terminate d with an  error.");        
495                    Cons ole.WriteL ine(ex.Mes sage);        
496          
497                    // D isplay the  details o f the inne r exceptio n.        
498                    if ( ex.InnerEx ception !=  null)        
499                    {        
500                         Console.Wr iteLine(ex .InnerExce ption.Mess age);        
501          
502                         FaultExcep tion<Micro soft.Xrm.S dk.Organiz ationServi ceFault> f e = ex.Inn erExceptio n        
503                             as Fau ltExceptio n<Microsof t.Xrm.Sdk. Organizati onServiceF ault>;        
504                         if (fe !=  null)        
505                         {        
506                             Consol e.WriteLin e("Timesta mp: {0}",  fe.Detail. Timestamp) ;        
507                             Consol e.WriteLin e("Code: { 0}", fe.De tail.Error Code);        
508                             Consol e.WriteLin e("Message : {0}", fe .Detail.Me ssage);        
509                             Consol e.WriteLin e("Plugin  Trace: {0} ", fe.Deta il.TraceTe xt);        
510                             Consol e.WriteLin e("Inner F ault: {0}" ,        
511                                 nu ll == fe.D etail.Inne rFault ? " No Inner F ault" : "H as Inner F ault");        
512                         }        
513                    }        
514                }        
515                // Addit ional exce ptions to  catch: Sec urityToken Validation Exception,  ExpiredSe curityToke nException ,        
516                // Secur ityAccessD eniedExcep tion, Mess ageSecurit yException , and Secu rityNegoti ationExcep tion.        
517          
518                finally        
519                {        
520                    Cons ole.WriteL ine("Press  <Enter> t o exit.");        
521                    Cons ole.ReadLi ne();        
522                }        
523           }        
524           #e ndregion M ain method        
525       }        
526   }        
527   //</snippe tUsingQuer iesToTrack Goals>