340. Araxis Merge File Comparison Report

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

340.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\DataManagement\BulkDelete BulkDeleteOperations.cs Tue Dec 20 19:51:43 2016 UTC
2 Wed Feb 1 19:56:30 2017 UTC

340.2 Comparison summary

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

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

340.4 Active regular expressions

No regular expressions were active.

340.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 BulkDelete Operations >        
17   using Syst em;        
18   using Syst em.Linq;        
19   using Syst em.Service Model;        
20   using Micr osoft.Crm. Sdk.Messag es;        
21   using Micr osoft.Xrm. Sdk;        
22   using Micr osoft.Xrm. Sdk.Client ;        
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 perform  a bulk de lete reque st to remo ve the rec ords in        
29       /// Mi crosoft Dy namics CRM  that matc h certain  criteria.        
30       /// </ summary>        
31       public  class Bul kDeleteOpe rations        
32       {        
33           #r egion Clas s Level Me mbers        
34           pr ivate Orga nizationSe rviceProxy  _serviceP roxy;        
35           pr ivate Serv iceContext  _context;        
36           pr ivate Guid  _bulkDele teOperatio nId;        
37           pr ivate Guid  _asyncOpe rationId;        
38           #e ndregion        
39          
40           #r egion How  To Sample  Code        
41          
42           // / <summary >        
43           // / Run the  sample.        
44           // / </summar y>        
45           // / <param n ame="serve rConfig">c onfigurati on for the  server.</ param>        
46           // / <param n ame="promp tToDelete" >        
47           // / whether  or not to  prompt the  user to d elete crea ted record s.        
48           // / </param>        
49           pu blic void  Run(Server Connection .Configura tion serve rConfig, b ool prompt ToDelete)        
50           {        
51                using (_ servicePro xy = new O rganizatio nServicePr oxy(server Config.Org anizationU ri, server Config.Hom eRealmUri,        
52                                                                              s erverConfi g.Credenti als, serve rConfig.De viceCreden tials))        
53                {        
54                    usin g (_contex t = new Se rviceConte xt(_servic eProxy))        
55                    {        
56                         // This st atement is  required  to enable  early-boun d type sup port.        
57                         _servicePr oxy.Enable ProxyTypes ();        
58          
59                         // This st atments ch ecks wheth er Standar d Email te mplates ar e present        
60                         var emailT emplateId  = (        
61                                             f rom emailT emplate in  _context. TemplateSe t        
62                                             w here email Template.T itle == "C ontact Rec onnect"        
63                                             s elect emai lTemplate. Id        
64                                            ). FirstOrDef ault();                      
65                                        
66                         if (emailT emplateId  != Guid.Em pty)        
67                         {        
68                             Create RequiredRe cords();        
69          
70                             // Per form the b ulk delete .  If you  want to pe rform a re curring de lete        
71                             // ope ration, th en leave t his as it  is.  Other wise, pass  in false  as the        
72                             // fir st paramet er.        
73                             Perfor mBulkDelet e(true, pr omptToDele te);        
74                         }        
75                         else        
76                         {        
77                             throw  new Argume ntExceptio n("Standar d Email Te mplates ar e missing" );        
78                         }        
79                    }        
80                }        
81           }        
82          
83           // / <summary >        
84           // / Create a n account  that will  be deleted  in the ma in portion  of the sa mple.        
85           // / </summar y>        
86           pr ivate void  CreateReq uiredRecor ds()        
87           {        
88                var acco unt = new  Account        
89                {        
90                    Name  = "Fourth  Coffee",        
91                    WebS iteURL = " http://www .fourthcof fee.com/"        
92                };        
93                _service Proxy.Crea te(account );        
94           }        
95          
96           // / <summary >        
97           // / Perform  the main a ction of t he sample  - issuing  a BulkDele teRequest.        
98           // / </summar y>        
99           // / <param n ame="useRe currence">        
100           // / whether  or not to  create a r ecurring B ulkDeleteR equest.        
101           // / </param>        
102           pr ivate void  PerformBu lkDelete(b ool useRec urrence, b ool prompt ToDelete)        
103           {        
104                try        
105                {        
106                    Cons ole.WriteL ine("Perfo rming Bulk  Delete Op eration");        
107          
108                    // Q uery for a  system us er to send  an email  to after t he bulk de lete        
109                    // o peration c ompletes.        
110                    var  userReques t = new Wh oAmIReques t();        
111                    var  userRespon se = (WhoA mIResponse )_serviceP roxy.Execu te(userReq uest);        
112                    Guid  currentUs erId = use rResponse. UserId;        
113          
114                    Cons ole.WriteL ine("  Req uesting us er retriev ed.");        
115          
116                    // C reate a co ndition fo r a bulk d elete requ est.        
117                    // N OTE: If no  records a re found t hat match  this condi tion, the  bulk delet e        
118                    // w ill not fa il.  It wi ll succeed  with 0 su ccesses an d 0 failur es.        
119                    var  deleteCond ition = ne w Conditio nExpressio n(        
120                         "name", Co nditionOpe rator.Equa l, "Fourth  Coffee");        
121          
122                    // C reate a fi ter expres sion for t he bulk de lete reque st.        
123                    var  deleteFilt er = new F ilterExpre ssion();        
124                    dele teFilter.C onditions. Add(delete Condition) ;        
125          
126                    // C reate the  bulk delet e query se t.        
127                    var  bulkDelete Query = ne w QueryExp ression        
128                    {        
129                         EntityName  = Account .EntityLog icalName,        
130                         Distinct =  false,        
131                         Criteria =  deleteFil ter        
132                    };        
133          
134                    // C reate the  bulk delet e request.        
135                    var  bulkDelete Request =  new BulkDe leteReques t        
136                    {        
137                         JobName =  "Sample Bu lk Delete" ,        
138                         QuerySet =  new[] { b ulkDeleteQ uery },        
139                         StartDateT ime = Date Time.Now,        
140                         ToRecipien ts = new[]  { current UserId },        
141                         CCRecipien ts = new G uid[] {},        
142                         SendEmailN otificatio n = true,        
143                         Recurrence Pattern =  String.Emp ty        
144                                
145                    };        
146          
147                    // C reate a re curring Bu lkDeleteOp eration.        
148                    if ( useRecurre nce)        
149                    {        
150                         bulkDelete Request.Re currencePa ttern = "F REQ=DAILY; INTERVAL=1 ;";        
151                    }        
152          
153                    // S ubmit the  bulk delet e job.        
154                    // N OTE: Becau se this is  an asynch ronous ope ration, th e response  will be        
155                    // i mmediate.        
156                    var  bulkDelete Response =        
157                         (BulkDelet eResponse) _servicePr oxy.Execut e(bulkDele teRequest) ;        
158                    _asy ncOperatio nId = bulk DeleteResp onse.JobId ;        
159          
160                    Cons ole.WriteL ine("  The  Bulk Dele te Request  was made  and the Bu lk\n" +        
161                                        "    D elete Oper ation shou ld be crea ted.");        
162          
163                    // T o monitor  the asynch ronous ope ration, re trieve the        
164                    // b ulkdeleteo peration o bject.        
165                    // N OTE: There  will be a  period of  time from  when the  async oper ation        
166                    // r equest was  submitted  to the ti me when a  successful  query for  that        
167                    // a sync opera tion can b e made.  W hen using  plug-ins,  events can  be        
168                    // s ubscribed  to that wi ll fire wh en the asy nc operati on status  changes.        
169                    var  bulkQuery  = new Quer yByAttribu te();        
170                    bulk Query.Colu mnSet = ne w ColumnSe t(true);        
171                    bulk Query.Enti tyName = B ulkDeleteO peration.E ntityLogic alName;        
172          
173                    // N OTE: When  the bulk d elete oper ation was  submitted,  the GUID  that was        
174                    // r eturned wa s the asyn coperation id, not th e bulkdele teoperatio nid.        
175                    bulk Query.Attr ibutes.Add ("asyncope rationid") ;        
176                    bulk Query.Valu es.Add(bul kDeleteRes ponse.JobI d);        
177          
178                    // W ith only t he asyncop erationid  at this po int, a Ret rieveMulti ple is        
179                    // r equired to  get the b ulk delete  operation  created a bove.        
180                    var  entityColl ection =        
181                         _servicePr oxy.Retrie veMultiple (bulkQuery );        
182                    Bulk DeleteOper ation crea tedBulkDel eteOperati on = null;        
183                            
184                    // W hen creati ng a recur ring BulkD eleteOpera tion, the  BulkDelete Operation        
185                    // w ill be in  suspended  status aft er the cur rent insta nce has co mpleted.        
186                    // W hen creati ng a non-r ecurring B ulkDeleteO peration,  it will be  in        
187                    // C ompleted s tatus when  it is fin ished.        
188                    var  bulkOperat ionEnded =  useRecurr ence        
189                         ? BulkDele teOperatio nState.Sus pended        
190                         : BulkDele teOperatio nState.Com pleted;        
191          
192                    crea tedBulkDel eteOperati on = Retri eveBulkDel eteOperati on(        
193                         bulkQuery,  entityCol lection, b ulkOperati onEnded);        
194                    _bul kDeleteOpe rationId =  createdBu lkDeleteOp eration.Id ;        
195          
196                    if ( createdBul kDeleteOpe ration !=  null)        
197                    {        
198                         // If the  BulkDelete Operation  is recurri ng, the st atus will  be        
199                         // "Waitin g" after t he operati on complet es this in stance.  I f it is        
200                         // non-rec urring, th e status w ill be "Su cceeded".        
201                         var bulkOp erationSuc cess = use Recurrence        
202                             ? bulk deleteoper ation_stat uscode.Wai ting        
203                             : bulk deleteoper ation_stat uscode.Suc ceeded;        
204          
205                         InspectBul kDeleteOpe ration(cre atedBulkDe leteOperat ion,        
206                             bulkOp erationEnd ed, bulkOp erationSuc cess, useR ecurrence) ;        
207          
208                         DeleteReco rds(prompt ToDelete);        
209                    }        
210                    else        
211                    {        
212                         Console.Wr iteLine("   The Bulk  Delete Ope ration cou ld not be  retrieved. ");        
213                    }        
214                }        
215                catch (S ystem.Web. Services.P rotocols.S oapExcepti on)        
216                {        
217                    // P erform err or handlin g here.        
218                    thro w;        
219                }        
220           }        
221          
222           // / <summary >        
223           // / Inspect  and displa y informat ion about  the create d BulkDele teOperatio n.        
224           // / </summar y>        
225           // / <param n ame="creat edBulkDele teOperatio n">        
226           // / the Bulk DeleteOper ation to i nspect.        
227           // / </param>        
228           // / <param n ame="bulkO perationEn ded">        
229           // / the stat ecode that  will tell  us if the  BulkDelet eOperation  is ended.        
230           // / </param>        
231           // / <param n ame="bulkO perationSu ccess">        
232           // / the stat uscode tha t will tel l us if th e BulkDele teOperatio n was succ essful.        
233           // / </param>        
234           // / <param n ame="useRe currence">        
235           // / whether  or not the  BulkDelet eOperation  is a recu rring oper ation.        
236           // / </param>        
237           pr ivate void  InspectBu lkDeleteOp eration(        
238                BulkDele teOperatio n createdB ulkDeleteO peration,        
239                BulkDele teOperatio nState bul kOperation Ended,        
240                bulkdele teoperatio n_statusco de bulkOpe rationSucc ess,        
241                bool use Recurrence )        
242           {        
243                // Valid ate that t he operati on was com pleted.        
244                if (crea tedBulkDel eteOperati on.StateCo de != bulk OperationE nded)        
245                {        
246                    // T his will h appen if i t took lon ger than t he polling  time allo wed         
247                    // f or this op eration to  complete.        
248                    Cons ole.WriteL ine("  Com pletion of  the Bulk  Delete too k longer\n " +        
249                                        "    t han the po lling time  allotted. ");        
250                }        
251                else if  (createdBu lkDeleteOp eration.St atusCode.V alue        
252                          != (int)b ulkOperati onSuccess)        
253                {        
254                    Cons ole.WriteL ine("  The  Bulk Dele te operati on failed. ");        
255                }        
256                else if  (!useRecur rence)        
257                {        
258                    // C heck for t he number  of success ful delete s.        
259                    var  successful Deletes =  createdBul kDeleteOpe ration.Suc cessCount  ?? 0;        
260                    Cons ole.WriteL ine("  {0}  records w ere succes sfully del eted",        
261                                        succes sfulDelete s);        
262          
263                    // C heck for a ny failure s that may  have occu rred durin g the bulk        
264                    // d elete oper ation.        
265                    if ( createdBul kDeleteOpe ration.Fai lureCount  > 0)        
266                    {        
267                         Console.Wr iteLine("   {0} recor ds failed  to be dele ted:",        
268                                            cr eatedBulkD eleteOpera tion.Failu reCount);        
269          
270                         // Query f or all the  failures.        
271                         var failur eQuery = n ew QueryBy Attribute( );        
272                         failureQue ry.ColumnS et = new C olumnSet(t rue);        
273                         failureQue ry.EntityN ame = Bulk DeleteFail ure.Entity LogicalNam e;        
274                         failureQue ry.Attribu tes.Add("b ulkdeleteo perationid ");        
275                         var bulkDe leteOperat ionId =        
276                             create dBulkDelet eOperation .BulkDelet eOperation Id ?? Guid .Empty;        
277                         failureQue ry.Values. Add(bulkDe leteOperat ionId);        
278          
279                         // Retriev e the bulk deletefail ure object s.        
280                         EntityColl ection ent ityCollect ion = _ser viceProxy. RetrieveMu ltiple(        
281                             failur eQuery);        
282          
283                         // Examine  each fail ure for in formation  regarding  the failur e.        
284                         foreach (B ulkDeleteF ailure fai lureOperat ion in        
285                             entity Collection .Entities)        
286                         {        
287                             // Pro cess failu re informa tion.        
288                             Consol e.WriteLin e(String.F ormat(        
289                                 "     {0}, {1 }",        
290                                 fa ilureOpera tion.Regar dingObject Id.Name,        
291                                 fa ilureOpera tion.Regar dingObject Id.Id));        
292                         }        
293                    }        
294                }        
295                else        
296                {        
297                    // N OTE: If re currence i s used, we  cannot re liably ret rieve data        
298                    // a bout the r ecords tha t were del eted, sinc e a sub-Bu lkDeleteOp eration        
299                    // i s created  by Microso ft Dynamic s CRM that  does not  have any f ields tyin g it back  to the        
300                    // A synchronou s operatio n or the B ulkDeleteO peration.  This makes  it        
301                    // u nreliable  to know wh ich subpro cess to re trieve.        
302                    Cons ole.WriteL ine("  The  recurring  Bulk Dele te Operati on was cre ated succe ssfully.") ;        
303                }        
304           }        
305          
306           // / <summary >        
307           // / Retrieve s the Bulk DeleteOper ation, but  it's not  necessaril y created        
308           // / immediat ely, so th is method  uses polli ng.        
309           // / </summar y>        
310           // / <param n ame="bulkQ uery">the  query to f ind the Bu lkDeleteOp eration.</ param>        
311           // / <param n ame="entit yCollectio n">the ini tial resul ts of the  query.</pa ram>        
312           // / <param n ame="opera tionEndedS tatus">        
313           // / the stat ecode that  will indi cate that  the operat ion has en ded.        
314           // / </param>        
315           pr ivate Bulk DeleteOper ation Retr ieveBulkDe leteOperat ion(        
316                QueryByA ttribute b ulkQuery,  EntityColl ection ent ityCollect ion,        
317                BulkDele teOperatio nState ope rationEnde dStatus)        
318           {        
319                BulkDele teOperatio n createdB ulkDeleteO peration =  null;        
320                // Monit or the asy nc operati on via pol ling until  it is com plete or m ax        
321                // polli ng time ex pires.        
322                const in t ARBITRAR Y_MAX_POLL ING_TIME =  60;        
323                int seco ndsTicker  = ARBITRAR Y_MAX_POLL ING_TIME;        
324                while (s econdsTick er > 0)        
325                {        
326                    // M ake sure t he async o peration w as retriev ed.        
327                    if ( entityColl ection.Ent ities.Coun t > 0)        
328                    {        
329                         // Grab th e one bulk  operation  that has  been creat ed.        
330                         createdBul kDeleteOpe ration =        
331                             (BulkD eleteOpera tion) enti tyCollecti on.Entitie s[0];        
332          
333                         // Check t he operati on's state .        
334                         // NOTE: I f a recurr ence for t he BulkDel eteOperati on was        
335                         // specifi ed, the st ate of the  operation  will be S uspended,        
336                         // not Com pleted, si nce the op eration wi ll run aga in in the        
337                         // future.        
338                         if (create dBulkDelet eOperation .StateCode  !=        
339                             operat ionEndedSt atus)        
340                         {        
341                             // The  operation  has not y et complet ed.  Wait  a second f or        
342                             // the  status to  change.        
343                             System .Threading .Thread.Sl eep(1000);        
344                             second sTicker--;        
345          
346                             // Ret rieve a fr esh versio n of the b ulk delete  operation .        
347                             entity Collection  = _servic eProxy.Ret rieveMulti ple(bulkQu ery);        
348                         }        
349                         else        
350                         {        
351                             // Sto p polling  as the ope ration's s tate is no w complete .        
352                             second sTicker =  0;        
353                             Consol e.WriteLin e(        
354                                 "   The BulkD eleteOpera tion recor d has been  retrieved .");        
355                         }        
356                    }        
357                    else        
358                    {        
359                         // Wait a  second for  async ope ration to  activate.        
360                         System.Thr eading.Thr ead.Sleep( 1000);        
361                         secondsTic ker--;        
362          
363                         // Retriev e the enti ty again.        
364                         entityColl ection = _ servicePro xy.Retriev eMultiple( bulkQuery) ;        
365                    }        
366                }        
367                return c reatedBulk DeleteOper ation;        
368           }        
369          
370           // / <summary >        
371           // / Deletes  records th at were cr eated in t he sample.        
372           // / </summar y>        
373           // / <param n ame="promp t">whether  or not to  prompt th e user for  deletion. </param>        
374           pr ivate void  DeleteRec ords(bool  prompt)        
375           {        
376                var toBe Deleted =  true;        
377                if (prom pt)        
378                {        
379                    // A sk the use r if the c reated ent ities shou ld be dele ted.        
380                    Cons ole.Write( "\nDo you  want these  entity re cords dele ted? (y/n)  [y]: ");        
381                    Stri ng answer  = Console. ReadLine() ;        
382                    if ( answer.Sta rtsWith("y ") ||        
383                         answer.Sta rtsWith("Y ") ||        
384                         answer ==  String.Emp ty)        
385                    {        
386                         toBeDelete d = true;        
387                    }        
388                    else        
389                    {        
390                         toBeDelete d = false;        
391                    }        
392                }        
393          
394                if (toBe Deleted)        
395                {        
396                    // D elete the  bulk delet e operatio n so that  it won't c lutter the        
397                    // d atabase.        
398                    _ser viceProxy. Delete(        
399                         BulkDelete Operation. EntityLogi calName, _ bulkDelete OperationI d);        
400          
401                    var  asyncOpera tionEntity  = _servic eProxy.Ret rieve(        
402                         AsyncOpera tion.Entit yLogicalNa me,        
403                         _asyncOper ationId,        
404                         new Column Set("state code", "as yncoperati onid"));        
405                    var  asyncOpera tion = asy ncOperatio nEntity.To Entity<Asy ncOperatio n>();        
406          
407                    if ( asyncOpera tion.State Code != As yncOperati onState.Co mpleted)        
408                    {        
409                         // We have  to update  the Async Operation  to be in a  Completed  state        
410                         // before  we can del ete it.        
411                         asyncOpera tion.State Code = Asy ncOperatio nState.Com pleted;        
412                         _servicePr oxy.Update (asyncOper ation);        
413                    }        
414          
415                    _ser viceProxy. Delete(        
416                         AsyncOpera tion.Entit yLogicalNa me, _async OperationI d);        
417          
418                    Cons ole.WriteL ine("  The  AsyncOper ation and  BulkDelete Operation  have been  deleted.") ;        
419                }        
420           }        
421          
422           #e ndregion H ow To Samp le Code        
423          
424           #r egion Main  method        
425          
426           // / <summary >        
427           // / Standard  Main() me thod used  by most SD K samples.        
428           // / </summar y>        
429           // / <param n ame="args" ></param>        
430           st atic publi c void Mai n(string[]  args)        
431           {        
432                try        
433                {        
434                    // O btain the  target org anization' s web addr ess and cl ient logon          
435                    // c redentials  from the  user.        
436                    Serv erConnecti on serverC onnect = n ew ServerC onnection( );        
437                    Serv erConnecti on.Configu ration con fig = serv erConnect. GetServerC onfigurati on();        
438          
439                    var  app = new  BulkDelete Operations ();        
440                    app. Run(config , true);        
441                }        
442                catch (F aultExcept ion<Micros oft.Xrm.Sd k.Organiza tionServic eFault> ex )        
443                {        
444                    Cons ole.WriteL ine("The a pplication  terminate d with an  error.");        
445                    Cons ole.WriteL ine("Times tamp: {0}" , ex.Detai l.Timestam p);        
446                    Cons ole.WriteL ine("Code:  {0}", ex. Detail.Err orCode);        
447                    Cons ole.WriteL ine("Messa ge: {0}",  ex.Detail. Message);        
448                    Cons ole.WriteL ine("Plugi n Trace: { 0}", ex.De tail.Trace Text);        
449                    Cons ole.WriteL ine("Inner  Fault: {0 }",        
450                         null == ex .Detail.In nerFault ?  "No Inner  Fault" :  "Has Inner  Fault");        
451                }        
452                catch (S ystem.Time outExcepti on ex)        
453                {        
454                    Cons ole.WriteL ine("The a pplication  terminate d with an  error.");        
455                    Cons ole.WriteL ine("Messa ge: {0}",  ex.Message );        
456                    Cons ole.WriteL ine("Stack  Trace: {0 }", ex.Sta ckTrace);        
457                    Cons ole.WriteL ine("Inner  Fault: {0 }",        
458                         null == ex .InnerExce ption.Mess age ? "No  Inner Faul t" : ex.In nerExcepti on.Message );        
459                }        
460                catch (S ystem.Exce ption ex)        
461                {        
462                    Cons ole.WriteL ine("The a pplication  terminate d with an  error.");        
463                    Cons ole.WriteL ine(ex.Mes sage);        
464          
465                    // D isplay the  details o f the inne r exceptio n.        
466                    if ( ex.InnerEx ception !=  null)        
467                    {        
468                         Console.Wr iteLine(ex .InnerExce ption.Mess age);        
469          
470                         FaultExcep tion<Micro soft.Xrm.S dk.Organiz ationServi ceFault> f e = ex.Inn erExceptio n        
471                             as Fau ltExceptio n<Microsof t.Xrm.Sdk. Organizati onServiceF ault>;        
472                         if (fe !=  null)        
473                         {        
474                             Consol e.WriteLin e("Timesta mp: {0}",  fe.Detail. Timestamp) ;        
475                             Consol e.WriteLin e("Code: { 0}", fe.De tail.Error Code);        
476                             Consol e.WriteLin e("Message : {0}", fe .Detail.Me ssage);        
477                             Consol e.WriteLin e("Plugin  Trace: {0} ", fe.Deta il.TraceTe xt);        
478                             Consol e.WriteLin e("Inner F ault: {0}" ,        
479                                 nu ll == fe.D etail.Inne rFault ? " No Inner F ault" : "H as Inner F ault");        
480                         }        
481                    }        
482                }        
483                // Addit ional exce ptions to  catch: Sec urityToken Validation Exception,  ExpiredSe curityToke nException ,        
484                // Secur ityAccessD eniedExcep tion, Mess ageSecurit yException , and Secu rityNegoti ationExcep tion.        
485          
486                finally        
487                {        
488                    Cons ole.WriteL ine("Press  <Enter> t o exit.");        
489                    Cons ole.ReadLi ne();        
490                }        
491           }        
492           #e ndregion M ain method        
493       }        
494   }        
495   //</snippe tBulkDelet eOperation s>