181. Araxis Merge File Comparison Report

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

181.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\Annotation UploadAndDownloadAttachment.cs Tue Dec 20 19:51:44 2016 UTC
2 Wed Feb 1 19:56:23 2017 UTC

181.2 Comparison summary

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

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

181.4 Active regular expressions

No regular expressions were active.

181.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          
17   //<snippet UploadAndD ownloadAtt achment>        
18   using Syst em;        
19   using Syst em.IO;        
20   using Syst em.Text;        
21   using Syst em.Service Model;        
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.Client ;        
26   using Micr osoft.Xrm. Sdk.Query;        
27          
28   namespace  Microsoft. Crm.Sdk.Sa mples        
29   {        
30       /// <s ummary>        
31       /// De monstrates  how to up load attac hments to  an annotat ion and ho w to downl oad attach ments.        
32       /// </ summary>        
33       public  class Upl oadAndDown loadAttach ment        
34       {        
35          
36           #r egion Clas s Level Me mbers        
37          
38           pr ivate Guid  _annotati onId;        
39           pr ivate Orga nizationSe rviceProxy  _serviceP roxy;        
40           pr ivate Stri ng _fileNa me;        
41          
42           #e ndregion C lass Level  Members        
43          
44           #r egion How- To Sample  Code        
45           // / <summary >        
46           // / This met hod first  connects t o the Orga nization s ervice. Af terwards,        
47           // / an annot ation is c reated, up loaded, th en finally  downloade d.        
48           // / </summar y>        
49           // / <param n ame="serve rConfig">C ontains se rver conne ction info rmation.</ param>        
50           // / <param n ame="promp tforDelete ">When Tru e, the use r will be  prompted t o delete a ll        
51           // / created  entities.< /param>        
52           pu blic void  Run(Server Connection .Configura tion serve rConfig, b ool prompt forDelete)        
53           {        
54                try        
55                {        
56                    //<s nippetUplo adAndDownl oadAttachm ent1>        
57                    // C onnect to  the Organi zation ser vice.         
58                    // T he using s tatement a ssures tha t the serv ice proxy  will be pr operly dis posed.        
59                    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 ))        
60                    {        
61                         // This st atement is  required  to enable  early-boun d type sup port.        
62                         _servicePr oxy.Enable ProxyTypes ();        
63          
64                         #region Cr eate and U pload anno tation att achment        
65          
66                         // Instant iate an An notation o bject.        
67                         // See the  Entity Me tadata top ic in the  SDK docume ntation to  determine        
68                         // which a ttributes  must be se t for each  entity.        
69                         Annotation  setupAnno tation = n ew Annotat ion()        
70                         {        
71                             Subjec t = "Examp le Annotat ion",        
72                             FileNa me = "Exam pleAnnotat ionAttachm ent.txt",        
73                             Docume ntBody = C onvert.ToB ase64Strin g(        
74                                 ne w UnicodeE ncoding(). GetBytes(" Sample Ann otation Te xt")),        
75                             MimeTy pe = "text /plain"        
76                         };        
77          
78                         // Create  the Annota tion objec t.        
79                         _annotatio nId = _ser viceProxy. Create(set upAnnotati on);        
80          
81                         Console.Wr ite("{0} c reated wit h an attac hment", se tupAnnotat ion.Subjec t);        
82          
83                         #endregion  Create an d Upload a nnotation  attachment        
84          
85                         #region Do wnload att achment fr om annotat ion record        
86          
87                         // Define  columns to  retrieve  from the a nnotation  record.        
88                         ColumnSet  cols = new  ColumnSet ("filename ", "docume ntbody");        
89                               
90          
91                         // Retriev e the anno tation rec ord.        
92                         Annotation  retrieved Annotation  =         
93                             (Annot ation)_ser viceProxy. Retrieve(" annotation ", _annota tionId, co ls);        
94                         Console.Wr iteLine(",  and retri eved.");        
95                         _fileName  = retrieve dAnnotatio n.FileName ;        
96          
97                         // Downloa d the atta chment in  the curren t executio n folder.        
98                         using (Fil eStream fi leStream =  new FileS tream(retr ievedAnnot ation.File Name, File Mode.OpenO rCreate))        
99                         {        
100                             byte[]  fileConte nt = Conve rt.FromBas e64String( retrievedA nnotation. DocumentBo dy);        
101                             fileSt ream.Write (fileConte nt, 0, fil eContent.L ength);        
102                         }        
103          
104                         Console.Wr iteLine("A ttachment  downloaded .");        
105          
106                         #endregion  Download  attachment  from anno tation rec ord        
107          
108                         DeleteRequ iredRecord s(promptfo rDelete);        
109                    }        
110                    //</ snippetUpl oadAndDown loadAttach ment1>        
111                }        
112          
113                // Catch  any servi ce fault e xceptions  that Micro soft Dynam ics CRM th rows.        
114                catch (F aultExcept ion<Micros oft.Xrm.Sd k.Organiza tionServic eFault>)        
115                {        
116                    // Y ou can han dle an exc eption her e or pass  it back to  the calli ng method.        
117                    thro w;        
118                }        
119           }        
120          
121           // / <summary >        
122           // / Deletes  any entity  records a nd files t hat were c reated for  this samp le.        
123           // / <param n ame="promp t">Indicat es whether  to prompt  the user         
124           // / to delet e the reco rds create d in this  sample.</p aram>        
125           // / </summar y>        
126           pu blic void  DeleteRequ iredRecord s(bool pro mpt)        
127           {        
128                bool del eteRecords  = true;        
129          
130                if (prom pt)        
131                {        
132                    Cons ole.WriteL ine("\nDo  you want t hese entit y records  deleted? ( y/n) [y]:  ");        
133                    Stri ng answer  = Console. ReadLine() ;        
134          
135                    dele teRecords  = (answer. StartsWith ("y") || a nswer.Star tsWith("Y" ) || answe r == Strin g.Empty);        
136                }        
137          
138                if (dele teRecords)        
139                {        
140                    _ser viceProxy. Delete(Ann otation.En tityLogica lName, _an notationId );        
141                    File .Delete(_f ileName);        
142                    Cons ole.WriteL ine("Entit y records  have been  deleted.") ;        
143                }        
144           }        
145          
146           #e ndregion H ow-To Samp le Code        
147          
148           #r egion Main  method        
149          
150           // / <summary >        
151           // / Standard  Main() me thod used  by most SD K samples.        
152           // / </summar y>        
153           // / <param n ame="args" ></param>        
154           st atic publi c void Mai n(string[]  args)        
155           {        
156                try        
157                {        
158                    // O btain the  target org anization' s Web addr ess and cl ient logon          
159                    // c redentials  from the  user.        
160                    Serv erConnecti on serverC onnect = n ew ServerC onnection( );        
161                    Serv erConnecti on.Configu ration con fig = serv erConnect. GetServerC onfigurati on();        
162          
163                    Uplo adAndDownl oadAttachm ent app =  new Upload AndDownloa dAttachmen t();        
164                    app. Run(config , true);        
165                }        
166                catch (F aultExcept ion<Micros oft.Xrm.Sd k.Organiza tionServic eFault> ex )        
167                {        
168                    Cons ole.WriteL ine("The a pplication  terminate d with an  error.");        
169                    Cons ole.WriteL ine("Times tamp: {0}" , ex.Detai l.Timestam p);        
170                    Cons ole.WriteL ine("Code:  {0}", ex. Detail.Err orCode);        
171                    Cons ole.WriteL ine("Messa ge: {0}",  ex.Detail. Message);        
172                    Cons ole.WriteL ine("Plugi n Trace: { 0}", ex.De tail.Trace Text);        
173                    Cons ole.WriteL ine("Inner  Fault: {0 }",        
174                         null == ex .Detail.In nerFault ?  "No Inner  Fault" :  "Has Inner  Fault");        
175                }        
176                catch (S ystem.Time outExcepti on ex)        
177                {        
178                    Cons ole.WriteL ine("The a pplication  terminate d with an  error.");        
179                    Cons ole.WriteL ine("Messa ge: {0}",  ex.Message );        
180                    Cons ole.WriteL ine("Stack  Trace: {0 }", ex.Sta ckTrace);        
181                    Cons ole.WriteL ine("Inner  Fault: {0 }",        
182                         null == ex .InnerExce ption.Mess age ? "No  Inner Faul t" : ex.In nerExcepti on.Message );        
183                }        
184                catch (S ystem.Exce ption ex)        
185                {        
186                    Cons ole.WriteL ine("The a pplication  terminate d with an  error.");        
187                    Cons ole.WriteL ine(ex.Mes sage);        
188          
189                    // D isplay the  details o f the inne r exceptio n.        
190                    if ( ex.InnerEx ception !=  null)        
191                    {        
192                         Console.Wr iteLine(ex .InnerExce ption.Mess age);        
193          
194                         FaultExcep tion<Micro soft.Xrm.S dk.Organiz ationServi ceFault> f e = ex.Inn erExceptio n        
195                             as Fau ltExceptio n<Microsof t.Xrm.Sdk. Organizati onServiceF ault>;        
196                         if (fe !=  null)        
197                         {        
198                             Consol e.WriteLin e("Timesta mp: {0}",  fe.Detail. Timestamp) ;        
199                             Consol e.WriteLin e("Code: { 0}", fe.De tail.Error Code);        
200                             Consol e.WriteLin e("Message : {0}", fe .Detail.Me ssage);        
201                             Consol e.WriteLin e("Plugin  Trace: {0} ", fe.Deta il.TraceTe xt);        
202                             Consol e.WriteLin e("Inner F ault: {0}" ,        
203                                 nu ll == fe.D etail.Inne rFault ? " No Inner F ault" : "H as Inner F ault");        
204                         }        
205                    }        
206                }        
207                // Addit ional exce ptions to  catch: Sec urityToken Validation Exception,  ExpiredSe curityToke nException ,        
208                // Secur ityAccessD eniedExcep tion, Mess ageSecurit yException , and Secu rityNegoti ationExcep tion.        
209          
210                finally        
211                {        
212                    Cons ole.WriteL ine("Press  <Enter> t o exit.");        
213                    Cons ole.ReadLi ne();        
214                }        
215           }        
216           #e ndregion M ain method        
217       }        
218   }        
219   //</snippe tUploadAnd DownloadAt tachment>