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

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

170.2 Comparison summary

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

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

170.4 Active regular expressions

No regular expressions were active.

170.5 Comparison detail

1   // ======= ========== ========== ========== ========== ========== ========== ==        
2   //        
3   //  This f ile is par t of the M icrosoft D ynamics CR M SDK code  samples.        
4   //        
5   //  Copyri ght (C) Mi crosoft Co rporation.   All righ ts reserve d.        
6   //        
7   //  This s ource code  is intend ed only as  a supplem ent to Mic rosoft        
8   //  Develo pment Tool s and/or o n-line doc umentation .  See the se other        
9   //  materi als for de tailed inf ormation r egarding M icrosoft c ode sample s.        
10   //        
11   //  THIS C ODE AND IN FORMATION  ARE PROVID ED "AS IS"  WITHOUT W ARRANTY OF  ANY        
12   //  KIND,  EITHER EXP RESSED OR  IMPLIED, I NCLUDING B UT NOT LIM ITED TO TH E        
13   //  IMPLIE D WARRANTI ES OF MERC HANTABILIT Y AND/OR F ITNESS FOR  A        
14   //  PARTIC ULAR PURPO SE.        
15   //        
16   // ======= ========== ========== ========== ========== ========== ========== ==        
17   //<snippet SendEmailU singTempla te>        
18   using Syst em;        
19   using Syst em.Service Model;        
20   using Syst em.Service Model.Desc ription;        
21   using Syst em.Text;        
22          
23   // These n amespaces  are found  in the Mic rosoft.Xrm .Sdk.dll a ssembly        
24   // found i n the SDK\ bin folder .        
25   using Micr osoft.Xrm. Sdk;        
26   using Micr osoft.Xrm. Sdk.Query;        
27   using Micr osoft.Xrm. Sdk.Discov ery;        
28   using Micr osoft.Xrm. Sdk.Messag es;        
29   using Micr osoft.Xrm. Sdk.Client ;        
30          
31          
32   // This na mespace is  found in  Microsoft. Crm.Sdk.Pr oxy.dll as sembly        
33   // found i n the SDK\ bin folder .        
34   using Micr osoft.Crm. Sdk.Messag es;        
35          
36   namespace  Microsoft. Crm.Sdk.Sa mples        
37   {        
38       /// <s ummary>        
39       /// Se nd an e-ma il using a  template.        
40       /// </ summary>        
41       /// <r emarks>Thi s sample r equires th at the use r account  running th e program  have        
42       /// a  primary e- mail addre ss defined  in Micros oft Dynami cs CRM.</r emarks>        
43       public  class Sen dEmailUsin gTemplate        
44       {        
45           #r egion Clas s Level Me mbers        
46          
47           // / <summary >        
48           // / Stores t he organiz ation serv ice proxy.        
49           // / </summar y>        
50           pr ivate Orga nizationSe rviceProxy  _serviceP roxy;        
51          
52           //  Define th e IDs need ed for thi s sample.        
53           pr ivate Guid  _emailId;        
54           pr ivate Guid  _contactI d;        
55           pr ivate Guid  _userId;        
56           pr ivate Guid  _template Id;        
57          
58           #e ndregion C lass Level  Members        
59          
60           #r egion How  To Sample  Code        
61           // / <summary >        
62           // / Send an  e-mail usi ng a templ ate.        
63           // / <param n ame="serve rConfig">C ontains se rver conne ction info rmation.</ param>        
64           // / <param n ame="promp tforDelete ">When Tru e, the use r will be  prompted t o delete a ll        
65           // / created  entities.< /param>        
66           // / </summar y>        
67           pu blic void  Run(Server Connection .Configura tion serve rConfig, b ool prompt ForDelete)        
68           {        
69                try        
70                {        
71                    // C onnect to  the Organi zation ser vice.         
72                    // T he using s tatement a ssures tha t the serv ice proxy  will be pr operly dis posed.        
73                    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 ))        
74                    {        
75                         // This st atement is  required  to enable  early-boun d type sup port.        
76                         _servicePr oxy.Enable ProxyTypes ();                              
77          
78                         // Call th e method t o create a ny data th at this sa mple requi res.        
79                         CreateRequ iredRecord s();        
80          
81                         //<snippet SendEmailU singTempla te1>        
82          
83                         // Create  the 'From: ' activity  party for  the email        
84                         ActivityPa rty fromPa rty = new  ActivityPa rty        
85                         {        
86                             PartyI d = new En tityRefere nce(System User.Entit yLogicalNa me, _userI d)        
87                         };        
88          
89                         // Create  the 'To:'  activity p arty for t he email        
90                         ActivityPa rty toPart y = new Ac tivityPart y        
91                         {        
92                             PartyI d = new En tityRefere nce(Contac t.EntityLo gicalName,  _contactI d)        
93                         };        
94          
95                         Console.Wr iteLine("C reated act ivity part ies.");        
96          
97                         // Create  an e-mail  message.        
98                         Email emai l = new Em ail        
99                         {        
100                             To = n ew Activit yParty[] {  toParty } ,        
101                             From =  new Activ ityParty[]  { fromPar ty },        
102                             Subjec t = "SDK S ample e-ma il",        
103                             Descri ption = "S DK Sample  for SendEm ailFromTem plate Mess age.",        
104                             Direct ionCode =  true        
105                         };        
106          
107                         //Create a  query exp ression to  get one o f Email Te mplate of  type "cont act"        
108          
109                         QueryExpre ssion quer yBuildInTe mplates =  new QueryE xpression{        
110                             Entity Name = "te mplate",        
111                             Column Set = new  ColumnSet( "templatei d", "templ atetypecod e"),        
112                             Criter ia = new F ilterExpre ssion()        
113                         };        
114                         queryBuild InTemplate s.Criteria .AddCondit ion("templ atetypecod e",        
115                             Condit ionOperato r.Equal, " contact");        
116                         EntityColl ection tem plateEntit yCollectio n = _servi ceProxy.Re trieveMult iple(query BuildInTem plates);        
117          
118                         if (templa teEntityCo llection.E ntities.Co unt > 0)         
119                         {        
120                             _templ ateId = (G uid)templa teEntityCo llection.E ntities[0] .Attribute s["templat eid"];        
121                         }        
122                         else        
123                         {        
124                             throw  new Argume ntExceptio n("Standar d Email Te mplates ar e missing" );        
125                         }                      
126          
127                         // Create  the reques t        
128                         SendEmailF romTemplat eRequest e mailUsingT emplateReq  = new Sen dEmailFrom TemplateRe quest        
129                         {        
130                             Target  = email,        
131          
132                             // Use  a built-i n Email Te mplate of  type "cont act".        
133                             Templa teId = _te mplateId,        
134          
135                             // The  regarding  Id is req uired, and  must be o f the same  type as t he Email T emplate.        
136                             Regard ingId = _c ontactId,        
137                             Regard ingType =  Contact.En tityLogica lName        
138                         };        
139          
140                         SendEmailF romTemplat eResponse  emailUsing TemplateRe sp = (Send EmailFromT emplateRes ponse)_ser viceProxy. Execute(em ailUsingTe mplateReq) ;        
141          
142                         // Verify  that the e -mail has  been creat ed        
143                         _emailId =  emailUsin gTemplateR esp.Id;        
144                         if (!_emai lId.Equals (Guid.Empt y))        
145                         {        
146                             Consol e.WriteLin e("Success fully sent  an e-mail  message u sing the t emplate.") ;        
147                         }        
148          
149                         //</snippe tSendEmail UsingTempl ate1>        
150          
151                         DeleteRequ iredRecord s(promptFo rDelete);        
152                    }        
153                }        
154          
155                // Catch  any servi ce fault e xceptions  that Micro soft Dynam ics CRM th rows.        
156                catch (F aultExcept ion<Micros oft.Xrm.Sd k.Organiza tionServic eFault>)        
157                {        
158                    // Y ou can han dle an exc eption her e or pass  it back to  the calli ng method.        
159                    thro w;        
160                }        
161           }        
162          
163           // / <summary >        
164           // / This met hod create s any enti ty records  that this  sample re quires.                 
165           // / </summar y>        
166           pu blic void  CreateRequ iredRecord s()        
167           {        
168                // Creat e a contac t to send  an email t o (To: fie ld)        
169                Contact  emailConta ct = new C ontact        
170                {        
171                    Firs tName = "D avid",        
172                    Last Name = "Pe lton",        
173                    EMai lAddress1  = "david@c ontoso.com ",        
174                    DoNo tEMail = f alse        
175                };        
176                _contact Id = _serv iceProxy.C reate(emai lContact);        
177                Console. WriteLine( "Created a  sample co ntact.");        
178          
179                // Get a  system us er to send  the email  (From: fi eld)        
180                WhoAmIRe quest syst emUserRequ est = new  WhoAmIRequ est();        
181                WhoAmIRe sponse sys temUserRes ponse = (W hoAmIRespo nse)_servi ceProxy.Ex ecute(syst emUserRequ est);        
182                _userId  = systemUs erResponse .UserId;        
183           }        
184          
185          
186           // / <summary >        
187           // / Deletes  the custom  entity re cord that  was create d for this  sample.        
188           // / <param n ame="promp t">Indicat es whether  to prompt  the user         
189           // / to delet e the enti ty created  in this s ample.</pa ram>        
190           // / </summar y>        
191           pu blic void  DeleteRequ iredRecord s(bool pro mpt)        
192           {        
193                bool del eteRecords  = true;        
194          
195                if (prom pt)        
196                {        
197                    Cons ole.WriteL ine("\nDo  you want t hese entit y records  deleted? ( y/n)");        
198                    Stri ng answer  = Console. ReadLine() ;        
199          
200                    dele teRecords  = (answer. StartsWith ("y") || a nswer.Star tsWith("Y" ));        
201                }        
202          
203                if (dele teRecords)        
204                {        
205                    _ser viceProxy. Delete(Ema il.EntityL ogicalName , _emailId );        
206                    _ser viceProxy. Delete(Con tact.Entit yLogicalNa me, _conta ctId); ;        
207          
208                    Cons ole.WriteL ine("Entit y records  have been  deleted.") ;        
209                }        
210           }        
211          
212           #e ndregion H ow To Samp le Code        
213          
214           #r egion Main        
215           // / <summary >        
216           // / Main. Ru ns the sam ple and pr ovides err or output.        
217           // / <param n ame="args" >Array of  arguments  to Main me thod.</par am>        
218           // / </summar y>        
219           st atic publi c void Mai n(string[]  args)        
220           {        
221                try        
222                {        
223                    // O btain the  target org anization' s Web addr ess and cl ient logon          
224                    // c redentials  from the  user.        
225                    Serv erConnecti on serverC onnect = n ew ServerC onnection( );        
226                    Serv erConnecti on.Configu ration con fig = serv erConnect. GetServerC onfigurati on();        
227          
228                    Send EmailUsing Template a pp = new S endEmailUs ingTemplat e();        
229                    app. Run(config , true);        
230          
231                }        
232                catch (F aultExcept ion<Micros oft.Xrm.Sd k.Organiza tionServic eFault> ex )        
233                {        
234                    Cons ole.WriteL ine("The a pplication  terminate d with an  error.");        
235                    Cons ole.WriteL ine("Times tamp: {0}" , ex.Detai l.Timestam p);        
236                    Cons ole.WriteL ine("Code:  {0}", ex. Detail.Err orCode);        
237                    Cons ole.WriteL ine("Messa ge: {0}",  ex.Detail. Message);        
238                    Cons ole.WriteL ine("Plugi n Trace: { 0}", ex.De tail.Trace Text);        
239                    Cons ole.WriteL ine("Inner  Fault: {0 }",        
240                         null == ex .Detail.In nerFault ?  "No Inner  Fault" :  "Has Inner  Fault");        
241                }        
242                catch (S ystem.Time outExcepti on ex)        
243                {        
244                    Cons ole.WriteL ine("The a pplication  terminate d with an  error.");        
245                    Cons ole.WriteL ine("Messa ge: {0}",  ex.Message );        
246                    Cons ole.WriteL ine("Stack  Trace: {0 }", ex.Sta ckTrace);        
247                    Cons ole.WriteL ine("Inner  Fault: {0 }",        
248                         null == ex .InnerExce ption.Mess age ? "No  Inner Faul t" : ex.In nerExcepti on.Message );        
249                }        
250                catch (S ystem.Exce ption ex)        
251                {        
252                    Cons ole.WriteL ine("The a pplication  terminate d with an  error.");        
253                    Cons ole.WriteL ine(ex.Mes sage);        
254          
255                    // D isplay the  details o f the inne r exceptio n.        
256                    if ( ex.InnerEx ception !=  null)        
257                    {        
258                         Console.Wr iteLine(ex .InnerExce ption.Mess age);        
259          
260                         FaultExcep tion<Micro soft.Xrm.S dk.Organiz ationServi ceFault> f e =        
261                             ex.Inn erExceptio n        
262                             as Fau ltExceptio n<Microsof t.Xrm.Sdk. Organizati onServiceF ault>;        
263                         if (fe !=  null)        
264                         {        
265                             Consol e.WriteLin e("Timesta mp: {0}",  fe.Detail. Timestamp) ;        
266                             Consol e.WriteLin e("Code: { 0}", fe.De tail.Error Code);        
267                             Consol e.WriteLin e("Message : {0}", fe .Detail.Me ssage);        
268                             Consol e.WriteLin e("Plugin  Trace: {0} ", fe.Deta il.TraceTe xt);        
269                             Consol e.WriteLin e("Inner F ault: {0}" ,        
270                                 nu ll == fe.D etail.Inne rFault ? " No Inner F ault" : "H as Inner F ault");        
271                         }        
272                    }        
273                }        
274                // Addit ional exce ptions to  catch: Sec urityToken Validation Exception,  ExpiredSe curityToke nException ,        
275                // Secur ityAccessD eniedExcep tion, Mess ageSecurit yException , and Secu rityNegoti ationExcep tion.        
276          
277                finally        
278                {        
279                    Cons ole.WriteL ine("Press  <Enter> t o exit.");        
280                    Cons ole.ReadLi ne();        
281                }        
282          
283           }        
284           #e ndregion M ain        
285          
286       }        
287   }        
288   //</snippe tSendEmail UsingTempl ate>