168. Araxis Merge File Comparison Report

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

168.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\Activities SendBulkEmailAndMonitor.cs Tue Dec 20 19:51:44 2016 UTC
2 Wed Feb 1 19:56:22 2017 UTC

168.2 Comparison summary

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

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

168.4 Active regular expressions

No regular expressions were active.

168.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 SendBulkEm ailAndMoni tor>        
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          
27   // These n amespaces  are found  in the Mic rosoft.Crm .Sdk.Proxy .dll assem bly        
28   // located  in the SD K\bin fold er of the  SDK downlo ad.        
29   using Micr osoft.Crm. Sdk.Messag es;        
30          
31   namespace  Microsoft. Crm.Sdk.Sa mples        
32   {        
33       public  class Sen dBulkEmail AndMonitor        
34       {        
35           #r egion Clas s Level Me mbers        
36          
37           pr ivate Orga nizationSe rviceProxy  _serviceP roxy;        
38           pr ivate List <Guid> _co ntactsIds  = new List <Guid>();        
39           pr ivate cons t int ARBI TRARY_MAX_ POLLING_TI ME = 60;        
40          
41           #e ndregion C lass Level  Members        
42          
43           #r egion How  To Sample  Code        
44           // / <summary >        
45           // / This sam ple shows  how to sen d a bulk e mail and m onitor its  progress.        
46           // / </summar y>        
47           // / <param n ame="serve rConfig">C ontains se rver conne ction info rmation.</ param>        
48           // / <param n ame="promp tforDelete ">When Tru e, the use r is promp ted to del ete all        
49           // / created  entities.< /param>        
50           pu blic void  Run(Server Connection .Configura tion serve rConfig, b ool prompt forDelete)        
51           {        
52                try        
53                {        
54                    // C onnect to  the Organi zation ser vice.         
55                    // T he using s tatement a ssures tha t the serv ice proxy  is properl y disposed .        
56                    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 ))        
57                    {        
58                         // This st atement is  required  to enable  early-boun d type sup port.        
59                         _servicePr oxy.Enable ProxyTypes ();        
60          
61                         CreateRequ iredRecord s();        
62          
63                         #region Cr eate and s end SendBu lkEmail        
64          
65                         Console.Wr iteLine();        
66                         Console.Wr iteLine("C reating an d sending  SendBulkEm ail.");        
67          
68                         // Get a s ystem user  to use as  the sende r.        
69                         WhoAmIRequ est emailS enderReque st = new W hoAmIReque st();        
70                         WhoAmIResp onse email SenderResp onse =        
71                             _servi ceProxy.Ex ecute(emai lSenderReq uest) as W hoAmIRespo nse;        
72          
73                         // Set tra ckingId fo r bulk mai l request.        
74                         Guid track ingId = Gu id.NewGuid ();        
75          
76                         SendBulkMa ilRequest  bulkMailRe quest = ne w SendBulk MailReques t()        
77                         {        
78                             // Cre ate a quer y expressi on for the  bulk oper ation to u se to retr ieve         
79                             // the  contacts  in the ema il list.        
80                             Query  = new Quer yExpressio n()        
81                             {        
82                                 En tityName =  Contact.E ntityLogic alName,        
83                                 Co lumnSet =  new Column Set(new St ring[] { " contactid"  }),        
84                                 Cr iteria = n ew FilterE xpression( )        
85                                 {        
86                                      Conditio ns =         
87                                 {        
88                                      new Cond itionExpre ssion("con tactid",Co nditionOpe rator.In,  _contactsI ds)        
89                                 }        
90                                 }        
91                             },        
92                             // Set  the Sende r.        
93                             Sender  = new Ent ityReferen ce(SystemU ser.Entity LogicalNam e, emailSe nderRespon se.UserId) ,        
94                             // Set  the Regar dingId - t his field  is require d.        
95                             Regard ingId = Gu id.Empty,        
96                             Regard ingType =  SystemUser .EntityLog icalName,        
97                             // Use  a built-i n Microsof t Dynamics  CRM email  template.        
98                             // NOT E: The ema il templat e's "templ ate type"  must match  the type  of         
99                             // cus tomers in  the email  list.  Our  list cont ains conta cts, so ou        
100                             // tem plate must  be for co ntacts.        
101                             Templa teId = new  Guid("07B 94C1D-C85F -492F-B120 -F0A743C54 0E6"),        
102                             Reques tId = trac kingId        
103                         };        
104          
105                         // Execute  the async  bulk emai l request        
106                         SendBulkMa ilResponse  resp = (S endBulkMai lResponse)        
107                             _servi ceProxy.Ex ecute(bulk MailReques t);        
108          
109                         Console.Wr iteLine("   Sent Bulk  Email.");        
110                         #endregion        
111          
112                         #region Mo nitoring S endBulkEma il        
113          
114                         Console.Wr iteLine();        
115                         Console.Wr iteLine("S tarting mo nitoring p rocess..") ;        
116          
117                         // Now tha t we've ex ecuted the  bulk oper ation, we  need to re trieve it         
118                         // using o ur trackin g Id.        
119          
120                         QueryByAtt ribute bul kQuery = n ew QueryBy Attribute( )        
121                         {        
122                             Entity Name = Asy ncOperatio n.EntityLo gicalName,        
123                             Column Set = new  ColumnSet( new string [] { "requ estid", "s tatecode"  }),        
124                             Attrib utes = { " requestid"  },        
125                             Values  = { track ingId }        
126                         };        
127          
128                         // Retriev e the bulk  email asy nc operati on.        
129                         EntityColl ection aRe sponse = _ servicePro xy.Retriev eMultiple( bulkQuery) ;        
130          
131                         Console.Wr iteLine("   Retrieved  Bulk Emai l Async Op eration.") ;        
132          
133                         // Monitor  the async  operation  via polli ng.        
134                         int second sTicker =  ARBITRARY_ MAX_POLLIN G_TIME;        
135          
136                         AsyncOpera tion creat edBulkMail Operation  = null;        
137          
138                         Console.Wr iteLine("   Checking  operation' s state fo r " + ARBI TRARY_MAX_ POLLING_TI ME + " sec onds.");        
139                         Console.Wr iteLine();        
140          
141                         while (sec ondsTicker  > 0)        
142                         {        
143                             // Mak e sure the  async ope ration was  retrieved .        
144                             if (aR esponse.En tities.Cou nt > 0)        
145                             {        
146                                 //  Grab the  one bulk o peration t hat has be en created .        
147                                 cr eatedBulkM ailOperati on = (Asyn cOperation )aResponse .Entities[ 0];        
148          
149                                 //  Check the  operation 's state.        
150                                 if  (createdB ulkMailOpe ration.Sta teCode.Val ue !=        
151                                      AsyncOpe rationStat e.Complete d)        
152                                 {        
153                                      // The o peration h as not yet  completed        
154                                      // Wait  a second f or the sta tus to cha nge.        
155                                      System.T hreading.T hread.Slee p(1000);        
156                                      secondsT icker--;        
157          
158                                      // Retri eve a fres h version  the bulk d elete oper ation.        
159                                      aRespons e = _servi ceProxy.Re trieveMult iple(bulkQ uery);        
160                                 }        
161                                 el se        
162                                 {        
163                                      // Stop  polling be cause the  operation' s state is  now compl ete.        
164                                      secondsT icker = 0;        
165                                 }        
166                             }        
167                             else        
168                             {        
169                                 //  Wait a se cond for t he async o peration t o activate .        
170                                 Sy stem.Threa ding.Threa d.Sleep(10 00);        
171                                 se condsTicke r--;        
172          
173                                 //  Retrieve  the entity  again        
174                                 aR esponse =  _servicePr oxy.Retrie veMultiple (bulkQuery );        
175                             }        
176                         }        
177          
178                         // When th e bulk ema il operati on has com pleted, al l sent ema ils will         
179                         // have a  status of  "Pending S end" and w ill be pic ked up by  your email          
180                         // router.   Alternat ively, you  can then  use Backgr oundSendEm ail to dow nload        
181                         // all the  emails cr eated with  the SendB ulkEmail m essage.         
182                         // See the  Backgroun dSendEmail  sample fo r an examp le.        
183                         #endregion        
184          
185                         #region Ch eck succes s        
186          
187                         // Validat e async op eration su cceeded        
188                         if (create dBulkMailO peration.S tateCode.V alue == As yncOperati onState.Co mpleted)        
189                         {        
190                             Consol e.WriteLin e("Operati on Complet ed.");        
191                         }        
192                         else        
193                         {        
194                             Consol e.WriteLin e("Operati on not com pleted yet .");        
195                         }        
196          
197                         #endregion        
198          
199                         DeleteRequ iredRecord s(promptfo rDelete);        
200                    }        
201                }        
202                // Catch  any servi ce fault e xceptions  that Micro soft Dynam ics CRM th rows.        
203                catch (F aultExcept ion<Micros oft.Xrm.Sd k.Organiza tionServic eFault>)        
204                {        
205                    // Y ou can han dle an exc eption her e or pass  it back to  the calli ng method.        
206                    thro w;        
207                }        
208           }        
209          
210           // / <summary >        
211           // / Creates  any entity  records t hat this s ample requ ires.        
212           // / </summar y>        
213           pu blic void  CreateRequ iredRecord s()        
214           {        
215                Console. WriteLine( "Creating  contacts r ecords..." );        
216          
217                Contact  emailConta ct1 = new  Contact()        
218                {        
219                    Firs tName = "A dam",        
220                    Last Name = "Ca rter",        
221                    EMai lAddress1  = "someone @example.c om"        
222                };        
223          
224                // Creat e the cont act1.        
225                _contact sIds.Add(_ servicePro xy.Create( emailConta ct1));        
226                Console. WriteLine( "Contact1  created.") ;        
227          
228                Contact  emailConta ct2 = new  Contact()        
229                {        
230                    Firs tName = "A dina",        
231                    Last Name = "Ha gege",        
232                    EMai lAddress1  = "someone @example.c om"        
233                };        
234          
235                // Creat e the cont act2.        
236                _contact sIds.Add(_ servicePro xy.Create( emailConta ct2));        
237                Console. WriteLine( "Contact2  created.") ;        
238          
239           }        
240          
241           // / <summary >        
242           // / Deletes  any entity  records t hat were c reated for  this samp le.        
243           // / <param n ame="promp t">Indicat es whether  to prompt  the user         
244           // / to delet e the reco rds create d in this  sample.</p aram>        
245           // / </summar y>        
246           pu blic void  DeleteRequ iredRecord s(bool pro mpt)        
247           {        
248                bool toB eDeleted =  true;        
249          
250                if (prom pt)        
251                {        
252                    // A sk the use r if the c reated ent ities shou ld be dele ted.        
253                    Cons ole.Write( "\nDo you  want these  entity re cords dele ted? (y/n)  [y]: ");        
254                    Stri ng answer  = Console. ReadLine() ;        
255                    if ( answer.Sta rtsWith("y ") ||        
256                         answer.Sta rtsWith("Y ") ||        
257                         answer ==  String.Emp ty)        
258                    {        
259                         toBeDelete d = true;        
260                    }        
261                    else        
262                    {        
263                         toBeDelete d = false;        
264                    }        
265                }        
266          
267                if (toBe Deleted)        
268                {        
269                    // D elete the  contacts.        
270                    fore ach (var c ontactId i n _contact sIds)        
271                    {        
272                         _servicePr oxy.Delete (Contact.E ntityLogic alName, co ntactId);        
273                    }        
274                    Cons ole.WriteL ine("Conta cts have b een delete d.");        
275                }        
276           }        
277           #e ndregion H ow To Samp le Code        
278          
279           #r egion Main  method        
280          
281           // / <summary >        
282           // / Standard  Main() me thod used  by most SD K samples.        
283           // / </summar y>        
284           // / <param n ame="args" ></param>        
285           st atic publi c void Mai n(string[]  args)        
286           {        
287                try        
288                {        
289                    // O btain the  target org anization' s web addr ess and cl ient logon          
290                    // c redentials  from the  user.        
291                    Serv erConnecti on serverC onnect = n ew ServerC onnection( );        
292                    Serv erConnecti on.Configu ration con fig = serv erConnect. GetServerC onfigurati on();        
293          
294                    Send BulkEmailA ndMonitor  app = new  SendBulkEm ailAndMoni tor();        
295                    app. Run(config , true);        
296                }        
297          
298                catch (F aultExcept ion<Micros oft.Xrm.Sd k.Organiza tionServic eFault> ex )        
299                {        
300                    Cons ole.WriteL ine("The a pplication  terminate d with an  error.");        
301                    Cons ole.WriteL ine("Times tamp: {0}" , ex.Detai l.Timestam p);        
302                    Cons ole.WriteL ine("Code:  {0}", ex. Detail.Err orCode);        
303                    Cons ole.WriteL ine("Messa ge: {0}",  ex.Detail. Message);        
304                    Cons ole.WriteL ine("Trace : {0}", ex .Detail.Tr aceText);        
305                    Cons ole.WriteL ine("Inner  Fault: {0 }",        
306                         null == ex .Detail.In nerFault ?  "No Inner  Fault" :  "Has Inner  Fault");        
307                }        
308                catch (S ystem.Time outExcepti on ex)        
309                {        
310                    Cons ole.WriteL ine("The a pplication  terminate d with an  error.");        
311                    Cons ole.WriteL ine("Messa ge: {0}",  ex.Message );        
312                    Cons ole.WriteL ine("Stack  Trace: {0 }", ex.Sta ckTrace);        
313                    Cons ole.WriteL ine("Inner  Fault: {0 }",        
314                         null == ex .InnerExce ption.Mess age ? "No  Inner Faul t" : ex.In nerExcepti on.Message );        
315                }        
316                catch (S ystem.Exce ption ex)        
317                {        
318                    Cons ole.WriteL ine("The a pplication  terminate d with an  error.");        
319                    Cons ole.WriteL ine(ex.Mes sage);        
320          
321                    // D isplay the  details o f the inne r exceptio n.        
322                    if ( ex.InnerEx ception !=  null)        
323                    {        
324                         Console.Wr iteLine(ex .InnerExce ption.Mess age);        
325          
326                         FaultExcep tion<Micro soft.Xrm.S dk.Organiz ationServi ceFault> f e = ex.Inn erExceptio n        
327                             as Fau ltExceptio n<Microsof t.Xrm.Sdk. Organizati onServiceF ault>;        
328                         if (fe !=  null)        
329                         {        
330                             Consol e.WriteLin e("Timesta mp: {0}",  fe.Detail. Timestamp) ;        
331                             Consol e.WriteLin e("Code: { 0}", fe.De tail.Error Code);        
332                             Consol e.WriteLin e("Message : {0}", fe .Detail.Me ssage);        
333                             Consol e.WriteLin e("Trace:  {0}", fe.D etail.Trac eText);        
334                             Consol e.WriteLin e("Inner F ault: {0}" ,        
335                                 nu ll == fe.D etail.Inne rFault ? " No Inner F ault" : "H as Inner F ault");        
336                         }        
337                    }        
338                }        
339                // Addit ional exce ptions to  catch: Sec urityToken Validation Exception,  ExpiredSe curityToke nException ,        
340                // Secur ityAccessD eniedExcep tion, Mess ageSecurit yException , and Secu rityNegoti ationExcep tion.        
341          
342                finally        
343                {        
344                    Cons ole.WriteL ine("Press  <Enter> t o exit.");        
345                    Cons ole.ReadLi ne();        
346                }        
347           }        
348           #e ndregion M ain method        
349       }        
350   }        
351   //</snippe tSendBulkE mailAndMon itor>        
352