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

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

165.2 Comparison summary

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

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

165.4 Active regular expressions

No regular expressions were active.

165.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 CRUDEmailA ttachments >        
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       public  class CRU DEmailAtta chments        
39       {        
40           #r egion Clas s Level Me mbers        
41          
42          
43           // / <summary >        
44           // / Stores t he organiz ation serv ice proxy.        
45           // / </summar y>        
46           pr ivate Orga nizationSe rviceProxy  _serviceP roxy;        
47          
48           //  Define th e IDs need ed for thi s sample.        
49           pr ivate Guid  _emailId;        
50           pr ivate Guid [] _emailA ttachmentI d = new Gu id[3];        
51                   
52          
53           #e ndregion C lass Level  Members        
54          
55           #r egion How  To Sample  Code        
56           // / <summary >        
57           // / Create,  Retrieve,  Update and  Delete an  e-mail at tachment.        
58           // / <param n ame="serve rConfig">C ontains se rver conne ction info rmation.</ param>        
59           // / <param n ame="promp tforDelete ">When Tru e, the use r will be  prompted t o delete a ll        
60           // / created  entities.< /param>        
61           // / </summar y>        
62           pu blic void  Run(Server Connection .Configura tion serve rConfig, b ool prompt ForDelete)        
63           {        
64                try        
65                {        
66                    // C onnect to  the Organi zation ser vice.         
67                    // T he using s tatement a ssures tha t the serv ice proxy  will be pr operly dis posed.        
68                    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 ))        
69                    {        
70                         // This st atement is  required  to enable  early-boun d type sup port.        
71                         _servicePr oxy.Enable ProxyTypes ();        
72          
73                         CreateRequ iredRecord s();        
74          
75                         //<snippet CRUDEmailA ttachments 1>        
76          
77                         // Create  three e-ma il attachm ents        
78                         for (int i  = 0; i <  3; i++)        
79                         {        
80                             Activi tyMimeAtta chment _sa mpleAttach ment = new  ActivityM imeAttachm ent        
81                             {        
82                                 Ob jectId = n ew EntityR eference(E mail.Entit yLogicalNa me, _email Id),        
83                                 Ob jectTypeCo de = Email .EntityLog icalName,        
84                                 Su bject = St ring.Forma t("Sample  Attachment  {0}", i),        
85                                 Bo dy = Syste m.Convert. ToBase64St ring(        
86                                          new  ASCIIEncod ing().GetB ytes("Exam ple Attach ment")),        
87                                 Fi leName = S tring.Form at("Exampl eAttachmen t{0}.txt",  i)        
88                             };        
89          
90                             _email Attachment Id[i] = _s erviceProx y.Create(_ sampleAtta chment);        
91                         }        
92          
93                         Console.Wr iteLine("C reated thr ee e-mail  attachment s for the  e-mail act ivity.");        
94          
95                         // Retriev e an attac hment incl uding its  id, subjec t, filenam e and body .        
96                         ActivityMi meAttachme nt _single Attachment  =        
97                             (Activ ityMimeAtt achment)_s erviceProx y.Retrieve (        
98                                                            Activity MimeAttach ment.Entit yLogicalNa me,        
99                                                            _emailAt tachmentId [0],        
100                                                            new Colu mnSet("act ivitymimea ttachmenti d",        
101                                                                "sub ject",        
102                                                                "fil ename",        
103                                                                "bod y"));        
104          
105                         Console.Wr iteLine("R etrieved a n email at tachment,  {0}.", _si ngleAttach ment.FileN ame);        
106          
107                         // Update  attachment        
108                         _singleAtt achment.Fi leName = " ExampleAtt achmentUpd ated.txt";        
109                         _servicePr oxy.Update (_singleAt tachment);        
110          
111                         Console.Wr iteLine("U pdated the  retrieved  e-mail at tachment t o {0}.", _ singleAtta chment.Fil eName);        
112          
113                         // Retriev e all atta chments as sociated w ith the em ail activi ty.        
114                         QueryExpre ssion _att achmentQue ry = new Q ueryExpres sion        
115                         {        
116                             Entity Name = Act ivityMimeA ttachment. EntityLogi calName,        
117                             Column Set = new  ColumnSet( "activitym imeattachm entid"),        
118                             Criter ia = new F ilterExpre ssion        
119                             {        
120                                 Co nditions =        
121                             {        
122                                 ne w Conditio nExpressio n        
123                                 {        
124                                      Attribut eName = "o bjectid",        
125                                      Operator  = Conditi onOperator .Equal,        
126                                      Values =  {_emailId }        
127                                 },        
128                                 ne w Conditio nExpressio n        
129                                 {        
130                                      Attribut eName = "o bjecttypec ode",        
131                                      Operator  = Conditi onOperator .Equal,        
132                                      Values =  {Email.En tityLogica lName}        
133                                 }        
134                             }        
135                             }        
136                         };        
137          
138                         EntityColl ection res ults = _se rviceProxy .RetrieveM ultiple(        
139                             _attac hmentQuery );        
140          
141                         Console.Wr iteLine("R etrieved a ll the e-m ail attach ments.");        
142          
143                         //</snippe tCRUDEmail Attachment s1>        
144          
145                         DeleteRequ iredRecord s(promptFo rDelete);        
146                    }        
147                }        
148          
149                // Catch  any servi ce fault e xceptions  that Micro soft Dynam ics CRM th rows.        
150                catch (F aultExcept ion<Micros oft.Xrm.Sd k.Organiza tionServic eFault>)        
151                {        
152                    // Y ou can han dle an exc eption her e or pass  it back to  the calli ng method.        
153                    thro w;        
154                }        
155           }        
156          
157           // / <summary >        
158           // / This met hod create s any enti ty records  that this  sample re quires.        
159           // / Creates  the email  activity.        
160           // / </summar y>        
161           pu blic void  CreateRequ iredRecord s()        
162           {        
163                // Creat e Email Ac tivity        
164                Email em ail = new  Email        
165                {        
166                    Subj ect = "Thi s is an ex ample emai l",        
167                    Acti vityId = G uid.NewGui d()        
168                };        
169          
170                _emailId  = _servic eProxy.Cre ate(email) ;        
171          
172                Console. WriteLine( "An e-mail  activity  is created .");        
173           }        
174          
175          
176           // / <summary >        
177           // / Deletes  the custom  entity re cord that  was create d for this  sample.        
178           // / <param n ame="promp t">Indicat es whether  to prompt  the user         
179           // / to delet e the enti ty created  in this s ample.</pa ram>        
180           // / </summar y>        
181           pu blic void  DeleteRequ iredRecord s(bool pro mpt)        
182           {        
183                bool del eteRecords  = true;        
184          
185                if (prom pt)        
186                {        
187                    Cons ole.WriteL ine("\nDo  you want t hese entit y records  deleted? ( y/n)");        
188                    Stri ng answer  = Console. ReadLine() ;        
189          
190                    dele teRecords  = (answer. StartsWith ("y") || a nswer.Star tsWith("Y" ));        
191                }        
192          
193                if (dele teRecords)        
194                {        
195                    for  (int j = 0 ; j < 3; j ++)        
196                    {        
197                         _servicePr oxy.Delete (ActivityM imeAttachm ent.Entity LogicalNam e, _emailA ttachmentI d[j]);        
198                    }        
199                    _ser viceProxy. Delete(Ema il.EntityL ogicalName , _emailId );                                              
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           // / Main. Ru ns the sam ple and pr ovides err or output.        
209           // / <param n ame="args" >Array of  arguments  to Main me thod.</par am>        
210           // / </summar y>        
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                    CRUD EmailAttac hments app  = new CRU DEmailAtta chments();        
221                    app. Run(config , true);        
222          
223                }        
224                catch (F aultExcept ion<Micros oft.Xrm.Sd k.Organiza tionServic eFault> ex )        
225                {        
226                    Cons ole.WriteL ine("The a pplication  terminate d with an  error.");        
227                    Cons ole.WriteL ine("Times tamp: {0}" , ex.Detai l.Timestam p);        
228                    Cons ole.WriteL ine("Code:  {0}", ex. Detail.Err orCode);        
229                    Cons ole.WriteL ine("Messa ge: {0}",  ex.Detail. Message);        
230                    Cons ole.WriteL ine("Plugi n Trace: { 0}", ex.De tail.Trace Text);        
231                    Cons ole.WriteL ine("Inner  Fault: {0 }",        
232                         null == ex .Detail.In nerFault ?  "No Inner  Fault" :  "Has Inner  Fault");        
233                }        
234                catch (S ystem.Time outExcepti on ex)        
235                {        
236                    Cons ole.WriteL ine("The a pplication  terminate d with an  error.");        
237                    Cons ole.WriteL ine("Messa ge: {0}",  ex.Message );        
238                    Cons ole.WriteL ine("Stack  Trace: {0 }", ex.Sta ckTrace);        
239                    Cons ole.WriteL ine("Inner  Fault: {0 }",        
240                         null == ex .InnerExce ption.Mess age ? "No  Inner Faul t" : ex.In nerExcepti on.Message );        
241                }        
242                catch (S ystem.Exce ption ex)        
243                {        
244                    Cons ole.WriteL ine("The a pplication  terminate d with an  error.");        
245                    Cons ole.WriteL ine(ex.Mes sage);        
246          
247                    // D isplay the  details o f the inne r exceptio n.        
248                    if ( ex.InnerEx ception !=  null)        
249                    {        
250                         Console.Wr iteLine(ex .InnerExce ption.Mess age);        
251          
252                         FaultExcep tion<Micro soft.Xrm.S dk.Organiz ationServi ceFault> f e =        
253                             ex.Inn erExceptio n        
254                             as Fau ltExceptio n<Microsof t.Xrm.Sdk. Organizati onServiceF ault>;        
255                         if (fe !=  null)        
256                         {        
257                             Consol e.WriteLin e("Timesta mp: {0}",  fe.Detail. Timestamp) ;        
258                             Consol e.WriteLin e("Code: { 0}", fe.De tail.Error Code);        
259                             Consol e.WriteLin e("Message : {0}", fe .Detail.Me ssage);        
260                             Consol e.WriteLin e("Plugin  Trace: {0} ", fe.Deta il.TraceTe xt);        
261                             Consol e.WriteLin e("Inner F ault: {0}" ,        
262                                 nu ll == fe.D etail.Inne rFault ? " No Inner F ault" : "H as Inner F ault");        
263                         }        
264                    }        
265                }        
266                // Addit ional exce ptions to  catch: Sec urityToken Validation Exception,  ExpiredSe curityToke nException ,        
267                // Secur ityAccessD eniedExcep tion, Mess ageSecurit yException , and Secu rityNegoti ationExcep tion.        
268          
269                finally        
270                {        
271                    Cons ole.WriteL ine("Press  <Enter> t o exit.");        
272                    Cons ole.ReadLi ne();        
273                }        
274          
275           }        
276           #e ndregion M ain        
277          
278       }        
279   }        
280   //</snippe tCRUDEmail Attachment s>