Produced by Araxis Merge on 2/1/2017 2:56:34 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.
| # | 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\GeneralProgramming\LateBound | EntityImages.cs | Tue Dec 20 19:51:46 2016 UTC |
| 2 | Wed Feb 1 19:56:34 2017 UTC |
| Description | Between Files 1 and 2 |
|
|---|---|---|
| Text Blocks | Lines | |
| Unchanged | 0 | 0 |
| Changed | 0 | 0 |
| Inserted | 0 | 0 |
| Removed | 1 | 398 |
| 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 |
No regular expressions were active.
| 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 EntityImag es> | |||||
| 17 | using Syst em; | |||||
| 18 | using Syst em.Service Model; | |||||
| 19 | using Syst em.Service Model.Desc ription; | |||||
| 20 | using Syst em.Diagnos tics; | |||||
| 21 | using Syst em.Xml.Lin q; | |||||
| 22 | using Syst em.IO; | |||||
| 23 | ||||||
| 24 | // These n amespaces are found in the Mic rosoft.Xrm .Sdk.dll a ssembly | |||||
| 25 | // located in the SD K\bin fold er of the SDK downlo ad. | |||||
| 26 | using Micr osoft.Xrm. Sdk; | |||||
| 27 | using Micr osoft.Xrm. Sdk.Query; | |||||
| 28 | using Micr osoft.Xrm. Sdk.Client ; | |||||
| 29 | using Micr osoft.Xrm. Sdk.Discov ery; | |||||
| 30 | using Micr osoft.Xrm. Sdk.Messag es; | |||||
| 31 | using Micr osoft.Xrm. Sdk.Metada ta; | |||||
| 32 | ||||||
| 33 | // This na mespace is found in Microsoft. Crm.Sdk.Pr oxy.dll as sembly | |||||
| 34 | // found i n the SDK\ bin folder . | |||||
| 35 | using Micr osoft.Crm. Sdk.Messag es; | |||||
| 36 | ||||||
| 37 | namespace Microsoft. Crm.Sdk.Sa mples | |||||
| 38 | { | |||||
| 39 | /// <summ ary> | |||||
| 40 | /// Demon strates ho w to do cr eate and r etrieve re cords with image dat a | |||||
| 41 | /// </sum mary> | |||||
| 42 | /// <rema rks> | |||||
| 43 | /// At ru n-time, yo u will be given the option to delete all the | |||||
| 44 | /// datab ase record s created by this pr ogram.</re marks> | |||||
| 45 | public cl ass Entity Images | |||||
| 46 | { | |||||
| 47 | #region Class Leve l Members | |||||
| 48 | private Organizati onServiceP roxy _serv iceProxy; | |||||
| 49 | private const Stri ng _custom EntityName = "sample _ImageAttr ibuteDemo" ; | |||||
| 50 | #endregi on Class L evel Membe rs | |||||
| 51 | ||||||
| 52 | #region How To Sam ple Code | |||||
| 53 | /// <sum mary> | |||||
| 54 | /// This method fi rst connec ts to the Organizati on service . Afterwar ds, | |||||
| 55 | /// a cu stom entit y is creat ed and con figured to support e ntity imag es. | |||||
| 56 | /// Then records a re created using thi s custom e ntity with image dat a. | |||||
| 57 | /// The records ar e then ret rieved and the resiz ed images are saved. | |||||
| 58 | /// Fina lly, the c ustom enti ty can be deleted. | |||||
| 59 | /// </su mmary> | |||||
| 60 | /// <par am name="s erverConfi g">Contain s server c onnection informatio n.</param> | |||||
| 61 | /// <par am name="p romptforDe lete">When True, the user will be prompt ed to dele te all | |||||
| 62 | /// crea ted entiti es.</param > | |||||
| 63 | public v oid Run(Se rverConnec tion.Confi guration s erverConfi g, bool pr omptforDel ete) | |||||
| 64 | { | |||||
| 65 | try | |||||
| 66 | { | |||||
| 67 | //<sni ppetEntity Images1> | |||||
| 68 | // Con nect to th e Organiza tion servi ce. | |||||
| 69 | // The using sta tement ass ures that the servic e proxy wi ll be prop erly dispo sed. | |||||
| 70 | using (_serviceP roxy = Ser verConnect ion.GetOrg anizationP roxy(serve rConfig)) | |||||
| 71 | { | |||||
| 72 | // Th is stateme nt is requ ired to en able early -bound typ e support. | |||||
| 73 | _serv iceProxy.E nableProxy Types(); | |||||
| 74 | ||||||
| 75 | Conso le.WriteLi ne("Please wait whil e the cust om Image A ttribute D emo entity used by t his sample is create d."); | |||||
| 76 | //Cre ates the I mage Attri bute Demo entity use d in this sample | |||||
| 77 | Creat eImageAttr ibuteDemoE ntity(); | |||||
| 78 | ||||||
| 79 | //Cre ate 5 reco rds using different sized imag es. | |||||
| 80 | /* | |||||
| 81 | ||||||
| 82 | This sample us es late-bi nding beca use the en tity was j ust create d and is | |||||
| 83 | not included i n the 'MyO rganizatio nsCrmSdkTy pes.cs' fi le created by the | |||||
| 84 | code generatio n tool (Cr mSvcUtil.e xe) | |||||
| 85 | ||||||
| 86 | */ | |||||
| 87 | //<sn ippetEntit yImages2> | |||||
| 88 | //Use a 144x144 pixel ima ge | |||||
| 89 | Entit y imageEnt ity1 = new Entity(_c ustomEntit yName.ToLo wer()); | |||||
| 90 | image Entity1["s ample_name "] = "144x 144.png"; | |||||
| 91 | image Entity1["e ntityimage "] = File. ReadAllByt es("Images \\144x144. png"); | |||||
| 92 | Guid imageEntit y1Id = _se rviceProxy .Create(im ageEntity1 ); | |||||
| 93 | ShowE ntityFormI nBrowser(p romptforDe lete, "144 x144.png", imageEnti ty1Id); | |||||
| 94 | ||||||
| 95 | //Use a 144x400 pixel ima ge | |||||
| 96 | Entit y imageEnt ity2 = new Entity(_c ustomEntit yName.ToLo wer()); | |||||
| 97 | image Entity2["s ample_name "] = "144x 400.png"; | |||||
| 98 | image Entity2["e ntityimage "] = File. ReadAllByt es("Images \\144x400. png"); | |||||
| 99 | Guid imageEntit y2Id = _se rviceProxy .Create(im ageEntity2 ); | |||||
| 100 | ShowE ntityFormI nBrowser(p romptforDe lete, "144 x400.png", imageEnti ty2Id); | |||||
| 101 | ||||||
| 102 | //Use a 400x144 pixel ima ge | |||||
| 103 | Entit y imageEnt ity3 = new Entity(_c ustomEntit yName.ToLo wer()); | |||||
| 104 | image Entity3["s ample_name "] = "400x 144.png"; | |||||
| 105 | image Entity3["e ntityimage "] = File. ReadAllByt es("Images \\400x144. png"); | |||||
| 106 | Guid imageEntit y3Id = _se rviceProxy .Create(im ageEntity3 ); | |||||
| 107 | ShowE ntityFormI nBrowser(p romptforDe lete, "400 x144.png", imageEnti ty3Id); | |||||
| 108 | ||||||
| 109 | //Use a 400x500 pixel ima ge | |||||
| 110 | Entit y imageEnt ity4 = new Entity(_c ustomEntit yName.ToLo wer()); | |||||
| 111 | image Entity4["s ample_name "] = "400x 500.png"; | |||||
| 112 | image Entity4["e ntityimage "] = File. ReadAllByt es("Images \\400x500. png"); | |||||
| 113 | Guid imageEntit y4Id = _se rviceProxy .Create(im ageEntity4 ); | |||||
| 114 | ShowE ntityFormI nBrowser(p romptforDe lete, "400 x500.png", imageEnti ty4Id); | |||||
| 115 | ||||||
| 116 | //Use a 60x80 p ixel image | |||||
| 117 | Entit y imageEnt ity5 = new Entity(_c ustomEntit yName.ToLo wer()); | |||||
| 118 | image Entity5["s ample_name "] = "60x8 0.png"; | |||||
| 119 | image Entity5["e ntityimage "] = File. ReadAllByt es("Images \\60x80.pn g"); | |||||
| 120 | Guid imageEntit y5Id = _se rviceProxy .Create(im ageEntity5 ); | |||||
| 121 | ShowE ntityFormI nBrowser(p romptforDe lete, "60x 80.png", i mageEntity 5Id); | |||||
| 122 | //</s nippetEnti tyImages2> | |||||
| 123 | Conso le.WriteLi ne(); | |||||
| 124 | //<sn ippetEntit yImages3> | |||||
| 125 | //Ret rieve and download t he binary images | |||||
| 126 | strin g binaryIm ageQuery = | |||||
| 127 | String.For mat(@"<fet ch mapping ='logical' > | |||||
| 128 | <entity name='{0}' > | |||||
| 129 | <attri bute name= 'sample_na me' /> | |||||
| 130 | <attri bute name= 'entityima ge' /> | |||||
| 131 | </entity > | |||||
| 132 | </fetch>", _customEnt ityName.To Lower()); | |||||
| 133 | ||||||
| 134 | Entit yCollectio n binaryIm ageResults = _servic eProxy.Ret rieveMulti ple(new Fe tchExpress ion(binary ImageQuery )); | |||||
| 135 | ||||||
| 136 | ||||||
| 137 | Conso le.WriteLi ne("Record s retrieve d and imag e files sa ved to: {0 }", Direct ory.GetCur rentDirect ory()); | |||||
| 138 | forea ch (Entity record in binaryIma geResults. Entities) | |||||
| 139 | { | |||||
| 140 | Stri ng recordN ame = reco rd["sample _name"] as String; | |||||
| 141 | Stri ng downloa dedFileNam e = String .Format("D ownloaded_ {0}", reco rdName); | |||||
| 142 | byte [] imageBy tes = reco rd["entity image"] as byte[]; | |||||
| 143 | var fs = new B inaryWrite r(new File Stream(dow nloadedFil eName, Fil eMode.Appe nd, FileAc cess.Write )); | |||||
| 144 | fs.W rite(image Bytes); | |||||
| 145 | fs.C lose(); | |||||
| 146 | Cons ole.WriteL ine(downlo adedFileNa me); | |||||
| 147 | } | |||||
| 148 | //</s nippetEnti tyImages3> | |||||
| 149 | Conso le.WriteLi ne(); | |||||
| 150 | //<sn ippetEntit yImages4> | |||||
| 151 | //Ret rieve and the record s with jus t the url | |||||
| 152 | strin g imageUrl Query = | |||||
| 153 | String.For mat(@"<fet ch mapping ='logical' > | |||||
| 154 | <entity name='{0}' > | |||||
| 155 | <attri bute name= 'sample_na me' /> | |||||
| 156 | <attri bute name= 'entityima ge_url' /> | |||||
| 157 | </entity > | |||||
| 158 | </fetch>", _customEn tityName.T oLower()); | |||||
| 159 | ||||||
| 160 | Entit yCollectio n imageUrl Results = _servicePr oxy.Retrie veMultiple (new Fetch Expression (imageUrlQ uery)); | |||||
| 161 | ||||||
| 162 | ||||||
| 163 | Conso le.WriteLi ne("These are the re lative URL s for the images ret rieved:"); | |||||
| 164 | forea ch (Entity record in imageUrlR esults.Ent ities) | |||||
| 165 | { | |||||
| 166 | Stri ng imageUr l = record ["entityim age_url"] as String; | |||||
| 167 | Cons ole.WriteL ine(imageU rl); | |||||
| 168 | } | |||||
| 169 | //</s nippetEnti tyImages4> | |||||
| 170 | ||||||
| 171 | ||||||
| 172 | Delet eImageAttr ibuteDemoE ntity(prom ptforDelet e); | |||||
| 173 | } | |||||
| 174 | //</sn ippetEntit yImages1> | |||||
| 175 | } | |||||
| 176 | ||||||
| 177 | // Catc h any serv ice fault exceptions that Micr osoft Dyna mics CRM t hrows. | |||||
| 178 | catch ( FaultExcep tion<Micro soft.Xrm.S dk.Organiz ationServi ceFault>) | |||||
| 179 | { | |||||
| 180 | // You can handl e an excep tion here or pass it back to t he calling method. | |||||
| 181 | throw; | |||||
| 182 | } | |||||
| 183 | } | |||||
| 184 | ||||||
| 185 | /// <sum mary> | |||||
| 186 | /// Crea tes any en tity recor ds that th is sample requires. | |||||
| 187 | /// </su mmary> | |||||
| 188 | public v oid Create ImageAttri buteDemoEn tity() | |||||
| 189 | { | |||||
| 190 | //Creat e a Custom entity | |||||
| 191 | CreateE ntityReque st creater equest = n ew CreateE ntityReque st | |||||
| 192 | { | |||||
| 193 | ||||||
| 194 | //Defi ne the ent ity | |||||
| 195 | Entity = new Ent ityMetadat a | |||||
| 196 | { | |||||
| 197 | Schem aName = _c ustomEntit yName, | |||||
| 198 | Displ ayName = n ew Label(" Image Attr ibute Demo ", 1033), | |||||
| 199 | Displ ayCollecti onName = n ew Label(" Image Attr ibute Demo s", 1033), | |||||
| 200 | Descr iption = n ew Label(" An entity created by an SDK sa mple to de monstrate how to upl oad and re trieve ent ity images .", 1033), | |||||
| 201 | Owner shipType = Ownership Types.User Owned, | |||||
| 202 | IsAct ivity = fa lse, | |||||
| 203 | ||||||
| 204 | }, | |||||
| 205 | ||||||
| 206 | // Def ine the pr imary attr ibute for the entity | |||||
| 207 | Primar yAttribute = new Str ingAttribu teMetadata | |||||
| 208 | { | |||||
| 209 | Schem aName = "s ample_Name ", | |||||
| 210 | Requi redLevel = new Attri buteRequir edLevelMan agedProper ty(Attribu teRequired Level.None ), | |||||
| 211 | MaxLe ngth = 100 , | |||||
| 212 | Forma tName = St ringFormat Name.Text, | |||||
| 213 | Displ ayName = n ew Label(" Name", 103 3), | |||||
| 214 | Descr iption = n ew Label(" The primar y attribut e for the Image Attr ibute Demo entity.", 1033) | |||||
| 215 | } | |||||
| 216 | ||||||
| 217 | }; | |||||
| 218 | _servic eProxy.Exe cute(creat erequest); | |||||
| 219 | Console .WriteLine ("The Imag e Attribut e Demo ent ity has be en created ."); | |||||
| 220 | ||||||
| 221 | //Creat e an Image attribute for the c ustom enti ty | |||||
| 222 | // Only one Image attribute can be ad ded to an entity tha t doesn't already ha ve one. | |||||
| 223 | CreateA ttributeRe quest crea teEntityIm ageRequest = new Cre ateAttribu teRequest | |||||
| 224 | { | |||||
| 225 | Entity Name = _cu stomEntity Name.ToLow er(), | |||||
| 226 | Attrib ute = new ImageAttri buteMetada ta | |||||
| 227 | { | |||||
| 228 | Schem aName = "E ntityImage ", //The n ame is alw ays Entity Image | |||||
| 229 | //Req uired leve l must be AttributeR equiredLev el.None | |||||
| 230 | Requi redLevel = new Attri buteRequir edLevelMan agedProper ty(Attribu teRequired Level.None ), | |||||
| 231 | Displ ayName = n ew Label(" Image", 10 33), | |||||
| 232 | Descr iption = n ew Label(" An image t o show wit h this dem onstration .", 1033) | |||||
| 233 | ||||||
| 234 | } | |||||
| 235 | }; | |||||
| 236 | _servic eProxy.Exe cute(creat eEntityIma geRequest) ; | |||||
| 237 | Console .WriteLine ("The Imag e attribut e has been created." ); | |||||
| 238 | ||||||
| 239 | //<snip petEntityI mages5> | |||||
| 240 | QueryEx pression q e = new Qu eryExpress ion("syste mform"); | |||||
| 241 | qe.Crit eria.AddCo ndition("t ype", Cond itionOpera tor.Equal, 2); //mai n form | |||||
| 242 | qe.Crit eria.AddCo ndition("o bjecttypec ode", Cond itionOpera tor.Equal, _customEn tityName.T oLower()); | |||||
| 243 | qe.Colu mnSet.AddC olumn("for mxml"); | |||||
| 244 | ||||||
| 245 | SystemF orm ImageA ttributeDe moMainForm = (System Form)_serv iceProxy.R etrieveMul tiple(qe). Entities[0 ]; | |||||
| 246 | ||||||
| 247 | XDocume nt ImageAt tributeDem oMainFormX ml = XDocu ment.Parse (ImageAttr ibuteDemoM ainForm.Fo rmXml); | |||||
| 248 | //Set t he showIma ge attribu te so the entity ima ge will be displayed | |||||
| 249 | ImageAt tributeDem oMainFormX ml.Root.Se tAttribute Value("sho wImage", t rue); | |||||
| 250 | ||||||
| 251 | //Updat ing the en tity form definition | |||||
| 252 | ImageAt tributeDem oMainForm. FormXml = ImageAttri buteDemoMa inFormXml. ToString() ; | |||||
| 253 | ||||||
| 254 | _servic eProxy.Upd ate(ImageA ttributeDe moMainForm ); | |||||
| 255 | //</sni ppetEntity Images5> | |||||
| 256 | Console .WriteLine ("The Imag e Attribut e Demo mai n form has been upda ted to sho w images." ); | |||||
| 257 | ||||||
| 258 | ||||||
| 259 | Publish XmlRequest pxReq1 = new Publis hXmlReques t { Parame terXml = S tring.Form at(@" | |||||
| 260 | <import exportxml> | |||||
| 261 | <entit ies> | |||||
| 262 | <enti ty>{0}</en tity> | |||||
| 263 | </enti ties> | |||||
| 264 | </impor texportxml >", _custo mEntityNam e.ToLower( )) }; | |||||
| 265 | _servic eProxy.Exe cute(pxReq 1); | |||||
| 266 | ||||||
| 267 | Console .WriteLine ("The Imag e Attribut e Demo ent ity was pu blished"); | |||||
| 268 | } | |||||
| 269 | ||||||
| 270 | ||||||
| 271 | public v oid ShowEn tityFormIn Browser(bo ol prompt, String na me, Guid i d) | |||||
| 272 | { | |||||
| 273 | if (pro mpt) | |||||
| 274 | { | |||||
| 275 | Consol e.WriteLin e("\nDo yo u want to view recor d '{0}' fo rm? (y/n)" , name); | |||||
| 276 | String viewFormA nswer = Co nsole.Read Line(); | |||||
| 277 | if (vi ewFormAnsw er.StartsW ith("y") | | viewForm Answer.Sta rtsWith("Y ")) | |||||
| 278 | { | |||||
| 279 | try | |||||
| 280 | { | |||||
| 281 | Stri ng webServ iceURL = _ servicePro xy.Endpoin tSwitch.Pr imaryEndpo int.Absolu teUri; | |||||
| 282 | Stri ng entityI nDefaultSo lutionUrl = webServi ceURL.Repl ace("XRMSe rvices/201 1/Organiza tion.svc", | |||||
| 283 | Str ing.Format ("main.asp x?etn={0}& pagetype=e ntityrecor d&id=%7B{1 }%7D", _cu stomEntity Name.ToLow er(),id.To String())) ; | |||||
| 284 | ||||||
| 285 | Proc essStartIn fo browser Process = new Proces sStartInfo ("iexplore .exe"); | |||||
| 286 | brow serProcess .Arguments = entityI nDefaultSo lutionUrl; | |||||
| 287 | Proc ess.Start( browserPro cess); | |||||
| 288 | ||||||
| 289 | } | |||||
| 290 | catch (SystemEx ception) | |||||
| 291 | { | |||||
| 292 | Cons ole.WriteL ine("\nThe re was a p roblem ope ning Inter net Explor er."); | |||||
| 293 | } | |||||
| 294 | } | |||||
| 295 | } | |||||
| 296 | } | |||||
| 297 | ||||||
| 298 | /// <sum mary> | |||||
| 299 | /// Dele tes any en tity recor ds that we re created for this sample. | |||||
| 300 | /// <par am name="p rompt">Ind icates whe ther to pr ompt the u ser | |||||
| 301 | /// to d elete the records cr eated in t his sample .</param> | |||||
| 302 | /// </su mmary> | |||||
| 303 | public v oid Delete ImageAttri buteDemoEn tity(bool prompt) | |||||
| 304 | { | |||||
| 305 | bool de leteRecord s = true; | |||||
| 306 | ||||||
| 307 | if (pro mpt) | |||||
| 308 | { | |||||
| 309 | Consol e.WriteLin e("\nDo yo u want to delete the entity cr eated for this sampl e? (y/n) [ y]: "); | |||||
| 310 | String answer = Console.Re adLine(); | |||||
| 311 | ||||||
| 312 | delete Records = (answer.St artsWith(" y") || ans wer.Starts With("Y") || answer == String. Empty); | |||||
| 313 | } | |||||
| 314 | ||||||
| 315 | if (del eteRecords ) | |||||
| 316 | { | |||||
| 317 | Delete EntityRequ est der = new Delete EntityRequ est() { Lo gicalName = _customE ntityName. ToLower() }; | |||||
| 318 | _servi ceProxy.Ex ecute(der) ; | |||||
| 319 | Consol e.WriteLin e("The Ima ge Attribu te Demo en tity has b een delete d."); | |||||
| 320 | } | |||||
| 321 | } | |||||
| 322 | ||||||
| 323 | #endregi on How To Sample Cod e | |||||
| 324 | ||||||
| 325 | #region Main metho d | |||||
| 326 | ||||||
| 327 | /// <sum mary> | |||||
| 328 | /// Stan dard Main( ) method u sed by mos t SDK samp les. | |||||
| 329 | /// </su mmary> | |||||
| 330 | /// <par am name="a rgs"></par am> | |||||
| 331 | static p ublic void Main(stri ng[] args) | |||||
| 332 | { | |||||
| 333 | try | |||||
| 334 | { | |||||
| 335 | // Obt ain the ta rget organ ization's Web addres s and clie nt logon | |||||
| 336 | // cre dentials f rom the us er. | |||||
| 337 | Server Connection serverCon nect = new ServerCon nection(); | |||||
| 338 | Server Connection .Configura tion confi g = server Connect.Ge tServerCon figuration (); | |||||
| 339 | ||||||
| 340 | Entity Images app = new Ent ityImages( ); | |||||
| 341 | app.Ru n(config, true); | |||||
| 342 | } | |||||
| 343 | ||||||
| 344 | ||||||
| 345 | catch ( FaultExcep tion<Micro soft.Xrm.S dk.Organiz ationServi ceFault> e x) | |||||
| 346 | { | |||||
| 347 | Consol e.WriteLin e("The app lication t erminated with an er ror."); | |||||
| 348 | Consol e.WriteLin e("Timesta mp: {0}", ex.Detail. Timestamp) ; | |||||
| 349 | Consol e.WriteLin e("Code: { 0}", ex.De tail.Error Code); | |||||
| 350 | Consol e.WriteLin e("Message : {0}", ex .Detail.Me ssage); | |||||
| 351 | Consol e.WriteLin e("Inner F ault: {0}" , | |||||
| 352 | nu ll == ex.D etail.Inne rFault ? " No Inner F ault" : "H as Inner F ault"); | |||||
| 353 | } | |||||
| 354 | catch ( System.Tim eoutExcept ion ex) | |||||
| 355 | { | |||||
| 356 | Consol e.WriteLin e("The app lication t erminated with an er ror."); | |||||
| 357 | Consol e.WriteLin e("Message : {0}", ex .Message); | |||||
| 358 | Consol e.WriteLin e("Stack T race: {0}" , ex.Stack Trace); | |||||
| 359 | Consol e.WriteLin e("Inner F ault: {0}" , | |||||
| 360 | nu ll == ex.I nnerExcept ion.Messag e ? "No In ner Fault" : ex.Inne rException .Message); | |||||
| 361 | } | |||||
| 362 | catch ( System.Exc eption ex) | |||||
| 363 | { | |||||
| 364 | Consol e.WriteLin e("The app lication t erminated with an er ror."); | |||||
| 365 | Consol e.WriteLin e(ex.Messa ge); | |||||
| 366 | ||||||
| 367 | // Dis play the d etails of the inner exception. | |||||
| 368 | if (ex .InnerExce ption != n ull) | |||||
| 369 | { | |||||
| 370 | Conso le.WriteLi ne(ex.Inne rException .Message); | |||||
| 371 | ||||||
| 372 | Fault Exception< Microsoft. Xrm.Sdk.Or ganization ServiceFau lt> fe = e x.InnerExc eption | |||||
| 373 | a s FaultExc eption<Mic rosoft.Xrm .Sdk.Organ izationSer viceFault> ; | |||||
| 374 | if (f e != null) | |||||
| 375 | { | |||||
| 376 | Cons ole.WriteL ine("Times tamp: {0}" , fe.Detai l.Timestam p); | |||||
| 377 | Cons ole.WriteL ine("Code: {0}", fe. Detail.Err orCode); | |||||
| 378 | Cons ole.WriteL ine("Messa ge: {0}", fe.Detail. Message); | |||||
| 379 | Cons ole.WriteL ine("Trace : {0}", fe .Detail.Tr aceText); | |||||
| 380 | Cons ole.WriteL ine("Inner Fault: {0 }", | |||||
| 381 | null == fe .Detail.In nerFault ? "No Inner Fault" : "Has Inner Fault"); | |||||
| 382 | } | |||||
| 383 | } | |||||
| 384 | } | |||||
| 385 | ||||||
| 386 | // Addi tional exc eptions to catch: Se curityToke nValidatio nException , ExpiredS ecurityTok enExceptio n, | |||||
| 387 | // Secu rityAccess DeniedExce ption, Mes sageSecuri tyExceptio n, and Sec urityNegot iationExce ption. | |||||
| 388 | ||||||
| 389 | finally | |||||
| 390 | { | |||||
| 391 | Consol e.WriteLin e("Press < Enter> to exit."); | |||||
| 392 | Consol e.ReadLine (); | |||||
| 393 | } | |||||
| 394 | } | |||||
| 395 | #endregi on Main me thod | |||||
| 396 | } | |||||
| 397 | } | |||||
| 398 | //</snippe tEntityIma ges> |
Araxis Merge (but not the data content of this report) is Copyright © 1993-2016 Araxis Ltd (www.araxis.com). All rights reserved.