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.
| # | 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\BusinessManagement | ConvertOpportunityToQuote.cs | Tue Dec 20 19:51:44 2016 UTC |
| 2 | Wed Feb 1 19:56:23 2017 UTC |
| Description | Between Files 1 and 2 |
|
|---|---|---|
| Text Blocks | Lines | |
| Unchanged | 0 | 0 |
| Changed | 0 | 0 |
| Inserted | 0 | 0 |
| Removed | 1 | 410 |
| 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 | // | |||||
| 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 | ||||||
| 18 | //<snippet ConvertOpp ortunityTo Quote> | |||||
| 19 | using Syst em; | |||||
| 20 | using Syst em.Service Model; | |||||
| 21 | using Syst em.Service Model.Desc ription; | |||||
| 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.Client ; | |||||
| 27 | using Micr osoft.Xrm. Sdk.Query; | |||||
| 28 | using Micr osoft.Xrm. Sdk.Discov ery; | |||||
| 29 | ||||||
| 30 | // This na mespace is found in Microsoft. Crm.Sdk.Pr oxy.dll as sembly | |||||
| 31 | // found i n the SDK\ bin folder . | |||||
| 32 | using Micr osoft.Crm. Sdk.Messag es; | |||||
| 33 | ||||||
| 34 | namespace Microsoft. Crm.Sdk.Sa mples | |||||
| 35 | { | |||||
| 36 | // / <summary > | |||||
| 37 | // / This sam ple shows how to con vert an op porutnity to a quote . | |||||
| 38 | // / </summar y> | |||||
| 39 | pu blic class ConvertOp portunityT oQuote | |||||
| 40 | { | |||||
| 41 | #r egion Clas s Level Me mbers | |||||
| 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 | pu blic Guid _unitGroup Id; | |||||
| 50 | pu blic Guid _product1I d; | |||||
| 51 | pu blic Guid _product2I d; | |||||
| 52 | pu blic Guid _priceList Id; | |||||
| 53 | pu blic Guid _priceList Item1Id; | |||||
| 54 | pu blic Guid _priceList Item2Id; | |||||
| 55 | pu blic Guid _accountId ; | |||||
| 56 | pu blic Guid _opportuni tyId; | |||||
| 57 | pu blic Guid _opportuni tyProduct1 Id; | |||||
| 58 | pu blic Guid _opportuni tyProduct2 Id; | |||||
| 59 | pu blic Guid _writeInPr oductId; | |||||
| 60 | pu blic Guid _quoteId; | |||||
| 61 | ||||||
| 62 | #e ndregion C lass Level Members | |||||
| 63 | ||||||
| 64 | #r egion How To Sample Code | |||||
| 65 | // / <summary > | |||||
| 66 | // / Create a nd configu re the org anization service pr oxy. | |||||
| 67 | // / Initiate creating all entity records t hat this s ample requ ires. | |||||
| 68 | // / Convert an opportu nity to qu ote | |||||
| 69 | // / Optional ly delete any entity records t hat were c reated for this samp le. | |||||
| 70 | // / </summar y> | |||||
| 71 | /// <param nam e="serverC onfig">Con tains serv er connect ion inform ation.</pa ram> | |||||
| 72 | // / <param n ame="promp tforDelete ">When Tru e, the use r will be prompted t o delete a ll | |||||
| 73 | // / created entities.< /param> | |||||
| 74 | pu blic void Run(Server Connection .Configura tion serve rConfig, b ool prompt ForDelete) | |||||
| 75 | { | |||||
| 76 | try | |||||
| 77 | { | |||||
| 78 | // C onnect to the Organi zation ser vice. | |||||
| 79 | // T he using s tatement a ssures tha t the serv ice proxy will be pr operly dis posed. | |||||
| 80 | usin g (_servic eProxy = n ew Organiz ationServi ceProxy(se rverConfig .Organizat ionUri, se rverConfig .HomeRealm Uri, | |||||
| 81 | s erverConfi g.Credenti als, serve rConfig.De viceCreden tials)) | |||||
| 82 | { | |||||
| 83 | // This st atement is required to enable early-boun d type sup port. | |||||
| 84 | _servicePr oxy.Enable ProxyTypes (); | |||||
| 85 | ||||||
| 86 | // Call th e method t o create a ny data th at this sa mple requi res. | |||||
| 87 | CreateRequ iredRecord s(); | |||||
| 88 | ||||||
| 89 | //<snippet ConvertOpp ortunityTo Quote1> | |||||
| 90 | // Convert an opport unity to q uote. | |||||
| 91 | GenerateQu oteFromOpp ortunityRe quest quot eRequest = new Gener ateQuoteFr omOpportun ityRequest () | |||||
| 92 | { | |||||
| 93 | // Col umns that will be tr ansferred | |||||
| 94 | Column Set = new ColumnSet( "name", "c ustomerid" ), | |||||
| 95 | Opport unityId = _opportuni tyId | |||||
| 96 | }; | |||||
| 97 | ||||||
| 98 | GenerateQu oteFromOpp ortunityRe sponse quo teResponse = | |||||
| 99 | (Gener ateQuoteFr omOpportun ityRespons e)_service Proxy.Exec ute(quoteR equest); | |||||
| 100 | ||||||
| 101 | _quoteId = quoteResp onse.Entit y.Id; | |||||
| 102 | //</snippe tConvertOp portunityT oQuote1> | |||||
| 103 | Console.Wr iteLine("C reated the quote fro m an oppor tunity."); | |||||
| 104 | ||||||
| 105 | DeleteRequ iredRecord s(promptFo rDelete); | |||||
| 106 | } | |||||
| 107 | } | |||||
| 108 | catch | |||||
| 109 | { | |||||
| 110 | // Y ou can han dle an exc eption her e or pass it back to the calli ng method. | |||||
| 111 | thro w; | |||||
| 112 | } | |||||
| 113 | } | |||||
| 114 | ||||||
| 115 | // / <summary > | |||||
| 116 | // / This met hod create s any enti ty records that this sample re quires. | |||||
| 117 | // / Create a unit grou p, few pro ducts, pri ce list an d price li st items. | |||||
| 118 | // / Create a n account record. | |||||
| 119 | // / Create f ew opportu nities, op portunity products a nd a write -in produc t. | |||||
| 120 | // / </summar y> | |||||
| 121 | pu blic void CreateRequ iredRecord s() | |||||
| 122 | { | |||||
| 123 | // Creat e a unit g roup. | |||||
| 124 | UoMSched ule newUni tGroup = n ew UoMSche dule | |||||
| 125 | { | |||||
| 126 | Name = "Exampl e Unit Gro up", | |||||
| 127 | Base UoMName = "Example P rimary Uni t" | |||||
| 128 | }; | |||||
| 129 | ||||||
| 130 | _unitGro upId = _se rviceProxy .Create(ne wUnitGroup ); | |||||
| 131 | ||||||
| 132 | Console. WriteLine( "Created { 0}", newUn itGroup.Na me); | |||||
| 133 | ||||||
| 134 | // retri eve the un it id. | |||||
| 135 | QueryExp ression un itQuery = new QueryE xpression | |||||
| 136 | { | |||||
| 137 | Enti tyName = U oM.EntityL ogicalName , | |||||
| 138 | Colu mnSet = ne w ColumnSe t("uomid", "name"), | |||||
| 139 | Crit eria = new FilterExp ression(), | |||||
| 140 | Page Info = new PagingInf o | |||||
| 141 | { | |||||
| 142 | PageNumber = 1, | |||||
| 143 | Count = 1 | |||||
| 144 | } | |||||
| 145 | }; | |||||
| 146 | unitQuer y.Criteria .AddCondit ion("uomsc heduleid", Condition Operator.E qual, _uni tGroupId); | |||||
| 147 | ||||||
| 148 | // Retri eve the un it. | |||||
| 149 | UoM unit = (UoM)_s erviceProx y.Retrieve Multiple(u nitQuery). Entities[0 ]; | |||||
| 150 | ||||||
| 151 | Console. WriteLine( "Retrieved {0}", uni t.Name); | |||||
| 152 | ||||||
| 153 | ||||||
| 154 | // Creat e a few pr oducts | |||||
| 155 | Product newProduct 1 = new Pr oduct | |||||
| 156 | { | |||||
| 157 | Prod uctNumber = "1", | |||||
| 158 | Name = "Exampl e Product 1", | |||||
| 159 | Prod uctStructu re = new O ptionSetVa lue(1), | |||||
| 160 | Quan tityDecima l = 2, | |||||
| 161 | Defa ultUoMSche duleId = n ew EntityR eference(U oMSchedule .EntityLog icalName, _unitGroup Id), | |||||
| 162 | Defa ultUoMId = new Entit yReference (UoM.Entit yLogicalNa me, unit.I d) | |||||
| 163 | }; | |||||
| 164 | _product1 Id = _serv iceProxy.C reate(newP roduct1); | |||||
| 165 | ||||||
| 166 | Console.W riteLine(" Created {0 }", newPro duct1.Name ); | |||||
| 167 | ||||||
| 168 | Product newProduct 2 = new Pr oduct | |||||
| 169 | { | |||||
| 170 | Prod uctNumber = "2", | |||||
| 171 | Name = "Exampl e Product 2", | |||||
| 172 | Prod uctStructu re = new O ptionSetVa lue(1), | |||||
| 173 | Quan tityDecima l = 2, | |||||
| 174 | Defa ultUoMSche duleId = n ew EntityR eference(U oMSchedule .EntityLog icalName, _unitGroup Id), | |||||
| 175 | Defa ultUoMId = new Entit yReference (UoM.Entit yLogicalNa me, unit.I d) | |||||
| 176 | }; | |||||
| 177 | _product 2Id = _ser viceProxy. Create(new Product2); | |||||
| 178 | ||||||
| 179 | Console. WriteLine( "Created { 0}", newPr oduct2.Nam e); | |||||
| 180 | ||||||
| 181 | // Creat e a price list | |||||
| 182 | PriceLev el newPric eList = ne w PriceLev el | |||||
| 183 | { | |||||
| 184 | Name = "Exampl e Price Li st" | |||||
| 185 | }; | |||||
| 186 | _priceLi stId = _se rviceProxy .Create(ne wPriceList ); | |||||
| 187 | ||||||
| 188 | Console. WriteLine( "Created { 0}", newPr iceList.Na me); | |||||
| 189 | ||||||
| 190 | // Creat e a price list items for the p roducts | |||||
| 191 | ProductP riceLevel newPriceLi stItem1 = new Produc tPriceLeve l | |||||
| 192 | { | |||||
| 193 | Pric eLevelId = new Entit yReference (PriceLeve l.EntityLo gicalName, _priceLis tId), | |||||
| 194 | Prod uctId = ne w EntityRe ference(Pr oduct.Enti tyLogicalN ame, _prod uct1Id), | |||||
| 195 | UoMI d = new En tityRefere nce(UoM.En tityLogica lName, uni t.Id), | |||||
| 196 | Amou nt = new M oney(20) | |||||
| 197 | }; | |||||
| 198 | _priceLi stItem1Id = _service Proxy.Crea te(newPric eListItem1 ); | |||||
| 199 | ||||||
| 200 | Console. WriteLine( "Created p rice list for {0}", newProduct 1.Name); | |||||
| 201 | ||||||
| 202 | ProductP riceLevel newPriceLi stItem2 = new Produc tPriceLeve l | |||||
| 203 | { | |||||
| 204 | Pric eLevelId = new Entit yReference (PriceLeve l.EntityLo gicalName, _priceLis tId), | |||||
| 205 | Prod uctId = ne w EntityRe ference(Pr oduct.Enti tyLogicalN ame, _prod uct2Id), | |||||
| 206 | UoMI d = new En tityRefere nce(UoM.En tityLogica lName, uni t.Id), | |||||
| 207 | Amou nt = new M oney(20) | |||||
| 208 | }; | |||||
| 209 | _priceLi stItem2Id = _service Proxy.Crea te(newPric eListItem2 ); | |||||
| 210 | ||||||
| 211 | Console. WriteLine( "Created p rice list for {0}", newProduct 2.Name); | |||||
| 212 | ||||||
| 213 | //Publis h Product1 | |||||
| 214 | SetState Request pu blishReque st1 = new SetStateRe quest | |||||
| 215 | { | |||||
| 216 | Enti tyMoniker = new Enti tyReferenc e(Product. EntityLogi calName, _ product1Id ), | |||||
| 217 | Stat e = new Op tionSetVal ue((int)Pr oductState .Active), | |||||
| 218 | Stat us = new O ptionSetVa lue(1) | |||||
| 219 | }; | |||||
| 220 | _service Proxy.Exec ute(publis hRequest1) ; | |||||
| 221 | ||||||
| 222 | //Publis h Product2 | |||||
| 223 | SetState Request pu blishReque st2 = new SetStateRe quest | |||||
| 224 | { | |||||
| 225 | Enti tyMoniker = new Enti tyReferenc e(Product. EntityLogi calName, _ product2Id ), | |||||
| 226 | Stat e = new Op tionSetVal ue((int)Pr oductState .Active), | |||||
| 227 | Stat us = new O ptionSetVa lue(1) | |||||
| 228 | }; | |||||
| 229 | _service Proxy.Exec ute(publis hRequest2) ; | |||||
| 230 | Console. WriteLine( "Published both the products") ; | |||||
| 231 | ||||||
| 232 | ||||||
| 233 | // Creat e an accou nt record for the op portunity' s potentia l customer id | |||||
| 234 | Account newAccount = new Acc ount | |||||
| 235 | { | |||||
| 236 | Name = "Exampl e Account" | |||||
| 237 | }; | |||||
| 238 | _account Id = _serv iceProxy.C reate(newA ccount); | |||||
| 239 | ||||||
| 240 | Console. WriteLine( "Created { 0}", newAc count.Name ); | |||||
| 241 | ||||||
| 242 | // Creat e a new op portunity | |||||
| 243 | Opportun ity newOpp ortunity = new Oppor tunity | |||||
| 244 | { | |||||
| 245 | Name = "Exampl e Opportun ity", | |||||
| 246 | Cust omerId = n ew EntityR eference(A ccount.Ent ityLogical Name, _acc ountId), | |||||
| 247 | Pric eLevelId = new Entit yReference (PriceLeve l.EntityLo gicalName, _priceLis tId), | |||||
| 248 | Frei ghtAmount = new Mone y(10.00m) | |||||
| 249 | }; | |||||
| 250 | _opportu nityId = _ servicePro xy.Create( newOpportu nity); | |||||
| 251 | ||||||
| 252 | Console. WriteLine( "Created { 0}", newOp portunity. Name); | |||||
| 253 | ||||||
| 254 | // Creat e an oppor tunity pro duct | |||||
| 255 | Opportun ityProduct newOpport unityProdu ct1 = new Opportunit yProduct | |||||
| 256 | { | |||||
| 257 | Oppo rtunityId = new Enti tyReferenc e(Opportun ity.Entity LogicalNam e, _opport unityId), | |||||
| 258 | Prod uctId = ne w EntityRe ference(Pr oduct.Enti tyLogicalN ame, _prod uct1Id), | |||||
| 259 | UoMI d = new En tityRefere nce(UoM.En tityLogica lName, uni t.Id), | |||||
| 260 | Quan tity = 3, | |||||
| 261 | Tax = new Mone y(4.80m) | |||||
| 262 | }; | |||||
| 263 | _opportu nityProduc t1Id = _se rviceProxy .Create(ne wOpportuni tyProduct1 ); | |||||
| 264 | ||||||
| 265 | Console. WriteLine( "Created o pportunity product f or {0} and {1}", new Opportunit y.Name, ne wProduct1. Name); | |||||
| 266 | ||||||
| 267 | // Creat e a catalo g product and overri de the pri ce per uni t | |||||
| 268 | Opportun ityProduct newOpport unityProdu ct2 = new Opportunit yProduct | |||||
| 269 | { | |||||
| 270 | Oppor tunityId = new Entit yReference (Opportuni ty.EntityL ogicalName , _opportu nityId), | |||||
| 271 | Produ ctId = new EntityRef erence(Pro duct.Entit yLogicalNa me, _produ ct2Id), | |||||
| 272 | UoMId = new Ent ityReferen ce(UoM.Ent ityLogical Name, unit .Id), | |||||
| 273 | Quant ity = 1, | |||||
| 274 | IsPri ceOverridd en = true, | |||||
| 275 | Price PerUnit = new Money( 12), | |||||
| 276 | Tax = new Money (0.96m) | |||||
| 277 | }; | |||||
| 278 | _opportu nityProduc t2Id = _se rviceProxy .Create(ne wOpportuni tyProduct2 ); | |||||
| 279 | ||||||
| 280 | Console. WriteLine( "Created o pportunity product f or {0} and {1}", new Opportunit y.Name, ne wProduct2. Name); | |||||
| 281 | ||||||
| 282 | // Creat e a write- in product with a ma nual disco unt | |||||
| 283 | Opportun ityProduct newWriteI nProduct = new Oppor tunityProd uct | |||||
| 284 | { | |||||
| 285 | Oppo rtunityId = new Enti tyReferenc e(Opportun ity.Entity LogicalNam e, _opport unityId), | |||||
| 286 | // s et this at tribute to make it a write-in product | |||||
| 287 | IsPr oductOverr idden = tr ue, | |||||
| 288 | Prod uctDescrip tion = "Ex ample Writ e-in Produ ct", | |||||
| 289 | Pric ePerUnit = new Money (20.00m), | |||||
| 290 | Quan tity = 5, | |||||
| 291 | Manu alDiscount Amount = n ew Money(1 0.50m), | |||||
| 292 | Tax = new Mone y(7.16m) | |||||
| 293 | }; | |||||
| 294 | _writeIn ProductId = _service Proxy.Crea te(newWrit eInProduct ); | |||||
| 295 | ||||||
| 296 | Console. WriteLine( "Created { 0}", newWr iteInProdu ct.Product Descriptio n); | |||||
| 297 | ||||||
| 298 | return; | |||||
| 299 | } | |||||
| 300 | ||||||
| 301 | // / <summary > | |||||
| 302 | // / Deletes any entity records t hat were c reated for this samp le. | |||||
| 303 | // / <param n ame="promp t">Indicat es whether to prompt the user to delete the record s created in this sa mple.</par am> | |||||
| 304 | // / </summar y> | |||||
| 305 | pu blic void DeleteRequ iredRecord s(bool pro mpt) | |||||
| 306 | { | |||||
| 307 | bool del eteRecords = true; | |||||
| 308 | ||||||
| 309 | if (prom pt) | |||||
| 310 | { | |||||
| 311 | Cons ole.WriteL ine("\nDo you want t hese entit y records deleted? ( y/n)"); | |||||
| 312 | Stri ng answer = Console. ReadLine() ; | |||||
| 313 | ||||||
| 314 | dele teRecords = (answer. StartsWith ("y") || a nswer.Star tsWith("Y" )); | |||||
| 315 | } | |||||
| 316 | ||||||
| 317 | if (dele teRecords) | |||||
| 318 | { | |||||
| 319 | _ser viceProxy. Delete(Quo te.EntityL ogicalName , _quoteId ); | |||||
| 320 | _ser viceProxy. Delete(Opp ortunityPr oduct.Enti tyLogicalN ame, _writ eInProduct Id); | |||||
| 321 | _ser viceProxy. Delete(Opp ortunityPr oduct.Enti tyLogicalN ame, _oppo rtunityPro duct1Id); | |||||
| 322 | _ser viceProxy. Delete(Opp ortunityPr oduct.Enti tyLogicalN ame, _oppo rtunityPro duct2Id); | |||||
| 323 | _ser viceProxy. Delete(Opp ortunity.E ntityLogic alName, _o pportunity Id); | |||||
| 324 | _ser viceProxy. Delete(Acc ount.Entit yLogicalNa me, _accou ntId); | |||||
| 325 | _ser viceProxy. Delete(Pro ductPriceL evel.Entit yLogicalNa me, _price ListItem1I d); | |||||
| 326 | _ser viceProxy. Delete(Pro ductPriceL evel.Entit yLogicalNa me, _price ListItem2I d); | |||||
| 327 | _ser viceProxy. Delete(Pro duct.Entit yLogicalNa me, _produ ct1Id); | |||||
| 328 | _ser viceProxy. Delete(Pro duct.Entit yLogicalNa me, _produ ct2Id); | |||||
| 329 | _ser viceProxy. Delete(Pri ceLevel.En tityLogica lName, _pr iceListId) ; | |||||
| 330 | _ser viceProxy. Delete(UoM Schedule.E ntityLogic alName, _u nitGroupId ); | |||||
| 331 | ||||||
| 332 | Cons ole.WriteL ine("Entit y records have been deleted.") ; | |||||
| 333 | } | |||||
| 334 | } | |||||
| 335 | ||||||
| 336 | #e ndregion H ow To Samp le Code | |||||
| 337 | ||||||
| 338 | #r egion Main | |||||
| 339 | // / <summary > | |||||
| 340 | // / Standard Main() me thod used by most SD K samples. | |||||
| 341 | // / </summar y> | |||||
| 342 | // / <param n ame="args" ></param> | |||||
| 343 | st atic publi c void Mai n(string[] args) | |||||
| 344 | { | |||||
| 345 | try | |||||
| 346 | { | |||||
| 347 | // O btain the target org anization' s Web addr ess and cl ient logon | |||||
| 348 | // c redentials from the user. | |||||
| 349 | Serv erConnecti on serverC onnect = n ew ServerC onnection( ); | |||||
| 350 | Serv erConnecti on.Configu ration con fig = serv erConnect. GetServerC onfigurati on(); | |||||
| 351 | ||||||
| 352 | Conv ertOpportu nityToQuot e app = n ew Convert Opportunit yToQuote() ; | |||||
| 353 | app. Run(config , true); | |||||
| 354 | } | |||||
| 355 | ||||||
| 356 | catch (F aultExcept ion<Micros oft.Xrm.Sd k.Organiza tionServic eFault> ex ) | |||||
| 357 | { | |||||
| 358 | Cons ole.WriteL ine("The a pplication terminate d with an error."); | |||||
| 359 | Cons ole.WriteL ine("Times tamp: {0}" , ex.Detai l.Timestam p); | |||||
| 360 | Cons ole.WriteL ine("Code: {0}", ex. Detail.Err orCode); | |||||
| 361 | Cons ole.WriteL ine("Messa ge: {0}", ex.Detail. Message); | |||||
| 362 | Cons ole.WriteL ine("Plugi n Trace: { 0}", ex.De tail.Trace Text); | |||||
| 363 | Cons ole.WriteL ine("Inner Fault: {0 }", | |||||
| 364 | null == ex .Detail.In nerFault ? "No Inner Fault" : "Has Inner Fault"); | |||||
| 365 | } | |||||
| 366 | catch (S ystem.Time outExcepti on ex) | |||||
| 367 | { | |||||
| 368 | Cons ole.WriteL ine("The a pplication terminate d with an error."); | |||||
| 369 | Cons ole.WriteL ine("Messa ge: {0}", ex.Message ); | |||||
| 370 | Cons ole.WriteL ine("Stack Trace: {0 }", ex.Sta ckTrace); | |||||
| 371 | Cons ole.WriteL ine("Inner Fault: {0 }", | |||||
| 372 | null == ex .InnerExce ption.Mess age ? "No Inner Faul t" : ex.In nerExcepti on.Message ); | |||||
| 373 | } | |||||
| 374 | catch (S ystem.Exce ption ex) | |||||
| 375 | { | |||||
| 376 | Cons ole.WriteL ine("The a pplication terminate d with an error."); | |||||
| 377 | Cons ole.WriteL ine(ex.Mes sage); | |||||
| 378 | ||||||
| 379 | // D isplay the details o f the inne r exceptio n. | |||||
| 380 | if ( ex.InnerEx ception != null) | |||||
| 381 | { | |||||
| 382 | Console.Wr iteLine(ex .InnerExce ption.Mess age); | |||||
| 383 | ||||||
| 384 | FaultExcep tion<Micro soft.Xrm.S dk.Organiz ationServi ceFault> f e = ex.Inn erExceptio n | |||||
| 385 | as Fau ltExceptio n<Microsof t.Xrm.Sdk. Organizati onServiceF ault>; | |||||
| 386 | if (fe != null) | |||||
| 387 | { | |||||
| 388 | Consol e.WriteLin e("Timesta mp: {0}", fe.Detail. Timestamp) ; | |||||
| 389 | Consol e.WriteLin e("Code: { 0}", fe.De tail.Error Code); | |||||
| 390 | Consol e.WriteLin e("Message : {0}", fe .Detail.Me ssage); | |||||
| 391 | Consol e.WriteLin e("Plugin Trace: {0} ", fe.Deta il.TraceTe xt); | |||||
| 392 | Consol e.WriteLin e("Inner F ault: {0}" , | |||||
| 393 | nu ll == fe.D etail.Inne rFault ? " No Inner F ault" : "H as Inner F ault"); | |||||
| 394 | } | |||||
| 395 | } | |||||
| 396 | } | |||||
| 397 | // Addit ional exce ptions to catch: Sec urityToken Validation Exception, ExpiredSe curityToke nException , | |||||
| 398 | // Secur ityAccessD eniedExcep tion, Mess ageSecurit yException , and Secu rityNegoti ationExcep tion. | |||||
| 399 | ||||||
| 400 | finally | |||||
| 401 | { | |||||
| 402 | Cons ole.WriteL ine("Press <Enter> t o exit."); | |||||
| 403 | Cons ole.ReadLi ne(); | |||||
| 404 | } | |||||
| 405 | ||||||
| 406 | } | |||||
| 407 | #e ndregion M ain | |||||
| 408 | } | |||||
| 409 | } | |||||
| 410 | //</snippe tConvertOp portunityT oQuote> |
Araxis Merge (but not the data content of this report) is Copyright © 1993-2016 Araxis Ltd (www.araxis.com). All rights reserved.