266. Araxis Merge File Comparison Report

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

266.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\Templates GetEmailTemplateAttachments.cs Tue Dec 20 19:51:43 2016 UTC
2 Wed Feb 1 19:56:28 2017 UTC

266.2 Comparison summary

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

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

266.4 Active regular expressions

No regular expressions were active.

266.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 GetEmailTe mplateAtta chments>        
18   using Syst em;        
19   using Syst em.Service Model;        
20   using Syst em.Service Model.Desc ription;        
21          
22   // These n amespaces  are found  in the Mic rosoft.Xrm .Sdk.dll a ssembly        
23   // found i n the SDK\ bin folder .        
24   using Micr osoft.Xrm. Sdk;        
25   using Micr osoft.Xrm. Sdk.Client ;        
26   using Micr osoft.Xrm. Sdk.Query;        
27   using Micr osoft.Xrm. Sdk.Discov ery;        
28          
29   // This na mespace is  found in  Microsoft. Crm.Sdk.Pr oxy.dll as sembly        
30   // found i n the SDK\ bin folder .        
31   using Micr osoft.Crm. Sdk.Messag es;        
32   using Syst em.Collect ions.Gener ic;        
33          
34          
35   namespace  Microsoft. Crm.Sdk.Sa mples        
36   {        
37          
38       /// <s ummary>        
39       /// De monstrates  how to re trieve ema il attachm ents assoc iated with  an email  template.        
40       /// If  you want  to run thi s sample r epeatedly,  you have  the option  to         
41       /// de lete all t he records  created a t the end  of executi on.        
42       /// </ summary>        
43       public  class Get EmailTempl ateAttachm ents        
44       {        
45           #r egion Clas s Level Me mbers        
46           // / <summary >        
47           // / Stores t he organiz ation serv ice proxy.        
48           // / </summar y>        
49           pr ivate Orga nizationSe rviceProxy  _serviceP roxy;        
50          
51           //  Define th e IDs need ed for thi s sample.        
52           pu blic Guid  _emailTemp lateId;        
53           pu blic List< Guid> _tem plateAttac hmentIds =  new List< Guid>();        
54          
55           #e ndregion C lass Level  Members        
56          
57           #r egion How  To Sample  Code        
58           // / <summary >        
59           // / Create a nd configu re the org anization  service pr oxy.        
60           // / Create a n email te mplate and  several a ttachments .        
61           // / Retrieve  the email  attachmen ts        
62           // / Optional ly delete  template a nd attachm ents.        
63           // / </summar y>        
64           // / <param n ame="serve rConfig">C ontains se rver conne ction info rmation.</ param>        
65           // / <param n ame="promp tforDelete ">When Tru e, the use r will be  prompted t o delete a ll        
66           // / created  entities.< /param>        
67           pu blic void  Run(Server Connection .Configura tion serve rConfig, b ool prompt ForDelete)        
68           {        
69                try        
70                {        
71          
72                    // C onnect to  the Organi zation ser vice.         
73                    // T he using s tatement a ssures tha t the serv ice proxy  will be pr operly dis posed.        
74                    usin g (_servic eProxy = n ew Organiz ationServi ceProxy(se rverConfig .Organizat ionUri, se rverConfig .HomeRealm Uri,server Config.Cre dentials,  serverConf ig.DeviceC redentials ))        
75                    {        
76                         // This st atement is  required  to enable  early-boun d type sup port.        
77                         _servicePr oxy.Enable ProxyTypes ();        
78          
79                         // Call th e method t o create a ny data th at this sa mple requi res.        
80                         CreateRequ iredRecord s();        
81          
82                         //<snippet GetEmailTe mplateAtta chments1>        
83          
84                         //Create a  query to  retrieve a ttachments .        
85                         QueryExpre ssion quer y = new Qu eryExpress ion        
86                         {        
87                             Entity Name = Act ivityMimeA ttachment. EntityLogi calName,        
88                             Column Set = new  ColumnSet( "filename" ),        
89          
90                             //Defi ne the con ditions fo r each att achment.        
91                             Criter ia =        
92                             {        
93                                 Fi lterOperat or = Logic alOperator .And,        
94                                 Co nditions =        
95                             {        
96                                 // The Object TypeCode m ust be spe cified, or  else the  query        
97                                 // defaults t o "email"  instead of  "template ".        
98                                 ne w Conditio nExpressio n        
99                                 {        
100                                      Attribut eName = "o bjecttypec ode",        
101                                      Operator  = Conditi onOperator .Equal,        
102                                      Values =  {Template .EntityTyp eCode}        
103                                 },        
104                                 // Specify wh ich templa te we need .        
105                                 ne w Conditio nExpressio n        
106                                 {        
107                                      Attribut eName = "o bjectid",        
108                                      Operator  = Conditi onOperator .Equal,        
109                                      Values =  {_emailTe mplateId}        
110                                 }        
111                             }        
112                             }        
113                         };        
114          
115                         //Write ou t the file name of ea ch attachm ent retrie ved.        
116                         foreach (A ctivityMim eAttachmen t attachme nt in _ser viceProxy. RetrieveMu ltiple(que ry).Entiti es)        
117                         {        
118                             Consol e.WriteLin e("Retriev ed attachm ent {0}",  attachment .FileName) ;        
119                         }        
120          
121                         //</snippe tGetEmailT emplateAtt achments1>        
122          
123                         DeleteRequ iredRecord s(promptFo rDelete);        
124                    }        
125                }        
126          
127                // Catch  any servi ce fault e xceptions  that Micro soft Dynam ics CRM th rows.        
128                catch (F aultExcept ion<Micros oft.Xrm.Sd k.Organiza tionServic eFault>)        
129                {        
130                    // Y ou can han dle an exc eption her e or pass  it back to  the calli ng method.        
131                    thro w;        
132                }        
133           }        
134          
135           // / <summary >        
136           // / This met hod create s any enti ty records  that this  sample re quires.        
137           // / </summar y>        
138           pu blic void  CreateRequ iredRecord s()        
139           {        
140                //Define  the email  template  to create.        
141                Template  emailTemp late = new  Template        
142                {        
143                    Titl e = "An ex ample emai l template ",        
144                    Subj ect = "Thi s is an ex ample emai l.",        
145                    IsPe rsonal = f alse,        
146                    Temp lateTypeCo de = "lead ",        
147          
148                    //10 33 is the  code for U S English  - you may  need to ch ange this  value        
149                    //de pending on  your loca le.        
150                    Lang uageCode =  1033        
151                           
152                };        
153          
154                _emailTe mplateId =  _serviceP roxy.Creat e(emailTem plate);        
155          
156                for (int  i = 0; i  < 3; i++ )        
157                {        
158                    Acti vityMimeAt tachment a ttachment  = new Acti vityMimeAt tachment        
159                    {        
160                         Subject =  String.For mat("Attac hment {0}" ,i),        
161                         FileName =  String.Fo rmat("Exam pleAttachm ent{0}.txt ", i),        
162                         Body = "So me Text",        
163                         ObjectId =  new Entit yReference (Template. EntityLogi calName, _ emailTempl ateId),        
164                         ObjectType Code = Tem plate.Enti tyLogicalN ame        
165                    };        
166          
167                    _tem plateAttac hmentIds.A dd(_servic eProxy.Cre ate(attach ment));        
168                }        
169          
170                Console. WriteLine( "An email  template a nd {0} att achments w ere create d.", _temp lateAttach mentIds.Co unt);        
171          
172                return;        
173           }        
174          
175           // / <summary >        
176           // / Deletes  any entity  records t hat were c reated for  this samp le.        
177           // / <param n ame="promp t">Indicat es whether  to prompt  the user  to delete  the record s created  in this sa mple.</par am>        
178           // / </summar y>        
179           pu blic void  DeleteRequ iredRecord s(bool pro mpt)        
180           {        
181                bool del eteRecords  = true;        
182          
183                if (prom pt)        
184                {        
185                    Cons ole.WriteL ine("\nDo  you want t hese entit y records  deleted? ( y/n)");        
186                    Stri ng answer  = Console. ReadLine() ;        
187          
188                    dele teRecords  = (answer. StartsWith ("y") || a nswer.Star tsWith("Y" ));        
189                }        
190          
191                if (dele teRecords)        
192                {        
193                    fore ach(Guid a ttachmentI d in _temp lateAttach mentIds)        
194                    {        
195                         _servicePr oxy.Delete (ActivityM imeAttachm ent.Entity LogicalNam e, attachm entId);        
196                    }        
197          
198                    _ser viceProxy. Delete(Tem plate.Enti tyLogicalN ame, _emai lTemplateI d);        
199          
200                    Cons ole.WriteL ine("Entit y records  have been  deleted.") ;        
201                }        
202           }        
203                   
204           #e ndregion H ow To Samp le Code        
205          
206           #r egion Main        
207           // / <summary >        
208           // / Standard  Main() me thod used  by most SD K samples.        
209           // / </summar y>        
210           // / <param n ame="args" ></param>        
211           st atic publi c void Mai n(string[]  args)        
212           {        
213                try        
214                {        
215                    // O btain the  target org anization' s Web addr ess and cl ient logon          
216                    // c redentials  from the  user.        
217                    Serv erConnecti on serverC onnect = n ew ServerC onnection( );        
218                    Serv erConnecti on.Configu ration con fig = serv erConnect. GetServerC onfigurati on();        
219          
220                    GetE mailTempla teAttachme nts app =  new GetEma ilTemplate Attachment s();        
221                    app. Run(config , true);        
222                }        
223                catch (F aultExcept ion<Micros oft.Xrm.Sd k.Organiza tionServic eFault> ex )        
224                {        
225                    Cons ole.WriteL ine("The a pplication  terminate d with an  error.");        
226                    Cons ole.WriteL ine("Times tamp: {0}" , ex.Detai l.Timestam p);        
227                    Cons ole.WriteL ine("Code:  {0}", ex. Detail.Err orCode);        
228                    Cons ole.WriteL ine("Messa ge: {0}",  ex.Detail. Message);        
229                    Cons ole.WriteL ine("Plugi n Trace: { 0}", ex.De tail.Trace Text);        
230                    Cons ole.WriteL ine("Inner  Fault: {0 }",        
231                         null == ex .Detail.In nerFault ?  "No Inner  Fault" :  "Has Inner  Fault");        
232                }        
233                catch (S ystem.Time outExcepti on ex)        
234                {        
235                    Cons ole.WriteL ine("The a pplication  terminate d with an  error.");        
236                    Cons ole.WriteL ine("Messa ge: {0}",  ex.Message );        
237                    Cons ole.WriteL ine("Stack  Trace: {0 }", ex.Sta ckTrace);        
238                    Cons ole.WriteL ine("Inner  Fault: {0 }",        
239                         null == ex .InnerExce ption.Mess age ? "No  Inner Faul t" : ex.In nerExcepti on.Message );        
240                }        
241                catch (S ystem.Exce ption ex)        
242                {        
243                    Cons ole.WriteL ine("The a pplication  terminate d with an  error.");        
244                    Cons ole.WriteL ine(ex.Mes sage);        
245          
246                    // D isplay the  details o f the inne r exceptio n.        
247                    if ( ex.InnerEx ception !=  null)        
248                    {        
249                         Console.Wr iteLine(ex .InnerExce ption.Mess age);        
250          
251                         FaultExcep tion<Micro soft.Xrm.S dk.Organiz ationServi ceFault> f e = ex.Inn erExceptio n        
252                             as Fau ltExceptio n<Microsof t.Xrm.Sdk. Organizati onServiceF ault>;        
253                         if (fe !=  null)        
254                         {        
255                             Consol e.WriteLin e("Timesta mp: {0}",  fe.Detail. Timestamp) ;        
256                             Consol e.WriteLin e("Code: { 0}", fe.De tail.Error Code);        
257                             Consol e.WriteLin e("Message : {0}", fe .Detail.Me ssage);        
258                             Consol e.WriteLin e("Plugin  Trace: {0} ", fe.Deta il.TraceTe xt);        
259                             Consol e.WriteLin e("Inner F ault: {0}" ,        
260                                 nu ll == fe.D etail.Inne rFault ? " No Inner F ault" : "H as Inner F ault");        
261                         }        
262                    }        
263                }        
264          
265                // Addit ional exce ptions to  catch: Sec urityToken Validation Exception,  ExpiredSe curityToke nException ,        
266                // Secur ityAccessD eniedExcep tion, Mess ageSecurit yException , and Secu rityNegoti ationExcep tion.        
267                finally        
268                {        
269                    Cons ole.WriteL ine("Press  <Enter> t o exit.");        
270                    Cons ole.ReadLi ne();        
271                }        
272          
273           }        
274           #e ndregion M ain        
275          
276       }        
277   }        
278   //</snippe tGetEmailT emplateAtt achments>