Produced by Araxis Merge on 2/1/2017 2:56:24 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 | WorkingWithNegativePrices.cs | Tue Dec 20 19:51:44 2016 UTC |
| 2 | Wed Feb 1 19:56:24 2017 UTC |
| Description | Between Files 1 and 2 |
|
|---|---|---|
| Text Blocks | Lines | |
| Unchanged | 0 | 0 |
| Changed | 0 | 0 |
| Inserted | 0 | 0 |
| Removed | 1 | 470 |
| 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 WorkingWit hNegativeP rices> | |||||
| 17 | using Syst em; | |||||
| 18 | using Syst em.Collect ions.Gener ic; | |||||
| 19 | using Syst em.Service Model; | |||||
| 20 | ||||||
| 21 | // These n amespaces are found in the Mic rosoft.Xrm .Sdk.dll a ssembly | |||||
| 22 | // located in the SD K\bin fold er of the SDK downlo ad. | |||||
| 23 | using Micr osoft.Xrm. Sdk; | |||||
| 24 | using Micr osoft.Xrm. Sdk.Client ; | |||||
| 25 | using Micr osoft.Xrm. Sdk.Query; | |||||
| 26 | using Micr osoft.Xrm. Sdk.Discov ery; | |||||
| 27 | ||||||
| 28 | // This na mespace is found in Microsoft. Crm.Sdk.Pr oxy.dll as sembly | |||||
| 29 | // found i n the SDK\ bin folder . | |||||
| 30 | using Micr osoft.Crm. Sdk.Messag es; | |||||
| 31 | ||||||
| 32 | namespace Microsoft. Crm.Sdk.Sa mples | |||||
| 33 | { | |||||
| 34 | /// <s ummary> | |||||
| 35 | /// S how how to set negat ive values for amoun t and numb er attribu tes in | |||||
| 36 | /// o pportuniti es, quotes , sales or ders. | |||||
| 37 | /// </ summary> | |||||
| 38 | /// <r emarks> | |||||
| 39 | /// At run-time, you will be given t he option to delete all the | |||||
| 40 | /// da tabase rec ords creat ed by this program.< /remarks> | |||||
| 41 | public class Wor kingWithNe gativePric es | |||||
| 42 | { | |||||
| 43 | #r egion Clas s Level Me mbers | |||||
| 44 | ||||||
| 45 | pr ivate Guid _salesMan agerId; | |||||
| 46 | pr ivate Guid _unitGrou pId; | |||||
| 47 | pr ivate Guid _defaultU nitId; | |||||
| 48 | pr ivate Guid _product1 Id; | |||||
| 49 | pr ivate Guid _product2 Id; | |||||
| 50 | pr ivate Guid _priceLis tId; | |||||
| 51 | pr ivate Guid _priceLis tItem1Id; | |||||
| 52 | pr ivate Guid _priceLis tItem2Id; | |||||
| 53 | pr ivate Guid _catalogP roductId; | |||||
| 54 | pr ivate Guid _quoteId; | |||||
| 55 | pr ivate Guid _quoteDet ailId; | |||||
| 56 | pr ivate Guid _orderId; | |||||
| 57 | pr ivate Guid _orderDet ailId; | |||||
| 58 | pr ivate Guid _opportun ityId; | |||||
| 59 | pr ivate Guid _accountI d; | |||||
| 60 | pr ivate List <Guid> _sa lesReprese ntativeIds = new Lis t<Guid>(); | |||||
| 61 | pr ivate Orga nizationSe rviceProxy _serviceP roxy; | |||||
| 62 | ||||||
| 63 | #e ndregion C lass Level Members | |||||
| 64 | ||||||
| 65 | #r egion How To Sample Code | |||||
| 66 | // / <summary > | |||||
| 67 | // / This met hod first connects t o the Orga nization s ervice. Af terwards, an | |||||
| 68 | // / opportun ity is cre ated to de monstrate a negative estimated value. Th is is | |||||
| 69 | // / followed by the cr eation of a quote wi th a negat ive produc t quantity . | |||||
| 70 | // / Finally, a sales o rder with a negative product p rice is sh own. | |||||
| 71 | // / </summar y> | |||||
| 72 | // / <param n ame="serve rConfig">C ontains se rver conne ction info rmation.</ param> | |||||
| 73 | // / <param n ame="promp tforDelete ">When Tru e, the use r will be prompted t o delete a ll | |||||
| 74 | // / created entities.< /param> | |||||
| 75 | pu blic void Run(Server Connection .Configura tion serve rConfig, b ool prompt forDelete) | |||||
| 76 | { | |||||
| 77 | try | |||||
| 78 | { | |||||
| 79 | //<s nippetWork ingWithNeg ativePrice s1> | |||||
| 80 | // C onnect to the Organi zation ser vice. | |||||
| 81 | // T he using s tatement a ssures tha t the serv ice proxy will be pr operly dis posed. | |||||
| 82 | 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 )) | |||||
| 83 | { | |||||
| 84 | // This st atement is required to enable early-boun d type sup port. | |||||
| 85 | _servicePr oxy.Enable ProxyTypes (); | |||||
| 86 | ||||||
| 87 | CreateRequ iredRecord s(); | |||||
| 88 | ||||||
| 89 | #region Op portunity with negat ive estima ted value | |||||
| 90 | ||||||
| 91 | // Create a new oppo rtunity wi th user-sp ecified ne gative | |||||
| 92 | // estimat ed value. | |||||
| 93 | Opportunit y opportun ity = new Opportunit y | |||||
| 94 | { | |||||
| 95 | Name = "Example Opportunit y", | |||||
| 96 | Custom erId = new EntityRef erence(Acc ount.Entit yLogicalNa me, | |||||
| 97 | _a ccountId), | |||||
| 98 | PriceL evelId = n ew EntityR eference(P riceLevel. EntityLogi calName, | |||||
| 99 | _p riceListId ), | |||||
| 100 | IsReve nueSystemC alculated = false, | |||||
| 101 | Estima tedValue = new Money (-400.00m) , | |||||
| 102 | Freigh tAmount = new Money( 10.00m), | |||||
| 103 | Actual Value = ne w Money(-3 90.00m), | |||||
| 104 | OwnerI d = new En tityRefere nce | |||||
| 105 | { | |||||
| 106 | Id = _salesR epresentat iveIds[0], | |||||
| 107 | Lo gicalName = SystemUs er.EntityL ogicalName | |||||
| 108 | } | |||||
| 109 | }; | |||||
| 110 | _opportuni tyId = _se rviceProxy .Create(op portunity) ; | |||||
| 111 | opportunit y.Id = _op portunityI d; | |||||
| 112 | ||||||
| 113 | // Create a catalog product fo r the oppo rtunity. | |||||
| 114 | Opportunit yProduct c atalogProd uct = new Opportunit yProduct | |||||
| 115 | { | |||||
| 116 | Opport unityId = opportunit y.ToEntity Reference( ), | |||||
| 117 | Produc tId = new EntityRefe rence(Prod uct.Entity LogicalNam e, | |||||
| 118 | _p roduct1Id) , | |||||
| 119 | UoMId = new Enti tyReferenc e(UoM.Enti tyLogicalN ame, | |||||
| 120 | _d efaultUnit Id), | |||||
| 121 | Quanti ty = 8, | |||||
| 122 | Tax = new Money( 12.42m), | |||||
| 123 | }; | |||||
| 124 | _catalogPr oductId = _servicePr oxy.Create (catalogPr oduct); | |||||
| 125 | ||||||
| 126 | Console.Wr iteLine("C reated opp ortunity w ith negati ve estimat ed value." ); | |||||
| 127 | ||||||
| 128 | #endregion | |||||
| 129 | ||||||
| 130 | #region Qu ote with n egative qu antity | |||||
| 131 | ||||||
| 132 | // Create the quote. | |||||
| 133 | Quote quot e = new Qu ote() | |||||
| 134 | { | |||||
| 135 | Custom erId = new EntityRef erence(Acc ount.Entit yLogicalNa me, | |||||
| 136 | _a ccountId), | |||||
| 137 | Name = "Sample Q uote", | |||||
| 138 | PriceL evelId = n ew EntityR eference(P riceLevel. EntityLogi calName, | |||||
| 139 | _p riceListId ) | |||||
| 140 | }; | |||||
| 141 | _quoteId = _serviceP roxy.Creat e(quote); | |||||
| 142 | quote.Id = _quoteId; | |||||
| 143 | ||||||
| 144 | // Set the quote's p roduct qua ntity to a negative value. | |||||
| 145 | QuoteDetai l quoteDet ail = new QuoteDetai l() | |||||
| 146 | { | |||||
| 147 | Produc tId = new EntityRefe rence(Prod uct.Entity LogicalNam e, | |||||
| 148 | _p roduct1Id) , | |||||
| 149 | Quanti ty = -4, | |||||
| 150 | QuoteI d = quote. ToEntityRe ference(), | |||||
| 151 | UoMId = new Enti tyReferenc e(UoM.Enti tyLogicalN ame, | |||||
| 152 | _d efaultUnit Id) | |||||
| 153 | }; | |||||
| 154 | _quoteDeta ilId = _se rviceProxy .Create(qu oteDetail) ; | |||||
| 155 | ||||||
| 156 | Console.Wr iteLine("C reated quo te with ne gative qua ntity."); | |||||
| 157 | ||||||
| 158 | #endregion | |||||
| 159 | ||||||
| 160 | #region Sa les Order with negat ive price | |||||
| 161 | ||||||
| 162 | // Create the sales order. | |||||
| 163 | SalesOrder order = n ew SalesOr der() | |||||
| 164 | { | |||||
| 165 | Name = "Faux Ord er", | |||||
| 166 | DateFu lfilled = new DateTi me(2010, 8 , 1), | |||||
| 167 | PriceL evelId = n ew EntityR eference(P riceLevel. EntityLogi calName, | |||||
| 168 | _p riceListId ), | |||||
| 169 | Custom erId = new EntityRef erence(Acc ount.Entit yLogicalNa me, | |||||
| 170 | _a ccountId), | |||||
| 171 | Freigh tAmount = new Money( 20.0M) | |||||
| 172 | }; | |||||
| 173 | _orderId = _serviceP roxy.Creat e(order); | |||||
| 174 | order.Id = _orderId; | |||||
| 175 | ||||||
| 176 | // Add the product t o the orde r with the price ove rriden wit h a | |||||
| 177 | // negativ e value. | |||||
| 178 | SalesOrder Detail ord erDetail = new Sales OrderDetai l() | |||||
| 179 | { | |||||
| 180 | Produc tId = new EntityRefe rence(Prod uct.Entity LogicalNam e, | |||||
| 181 | _p roduct1Id) , | |||||
| 182 | Quanti ty = 4, | |||||
| 183 | SalesO rderId = o rder.ToEnt ityReferen ce(), | |||||
| 184 | IsPric eOverridde n = true, | |||||
| 185 | PriceP erUnit = n ew Money(- 40.0M), | |||||
| 186 | UoMId = new Enti tyReferenc e(UoM.Enti tyLogicalN ame, | |||||
| 187 | _d efaultUnit Id) | |||||
| 188 | }; | |||||
| 189 | _orderDeta ilId = _se rviceProxy .Create(or derDetail) ; | |||||
| 190 | ||||||
| 191 | Console.Wr iteLine("C reated ord er with ne gative pri ce per uni t."); | |||||
| 192 | ||||||
| 193 | #endregion | |||||
| 194 | ||||||
| 195 | DeleteRequ iredRecord s(promptfo rDelete); | |||||
| 196 | } | |||||
| 197 | //</ snippetWor kingWithNe gativePric es1> | |||||
| 198 | } | |||||
| 199 | ||||||
| 200 | // Catch any servi ce fault e xceptions that Micro soft Dynam ics CRM th rows. | |||||
| 201 | catch (F aultExcept ion<Micros oft.Xrm.Sd k.Organiza tionServic eFault>) | |||||
| 202 | { | |||||
| 203 | // Y ou can han dle an exc eption her e or pass it back to the calli ng method. | |||||
| 204 | thro w; | |||||
| 205 | } | |||||
| 206 | } | |||||
| 207 | ||||||
| 208 | // / <summary > | |||||
| 209 | // / Creates any entity records t hat this s ample requ ires. | |||||
| 210 | // / </summar y> | |||||
| 211 | pu blic void CreateRequ iredRecord s() | |||||
| 212 | { | |||||
| 213 | #region C reate or R etrieve th e necessar y system u sers | |||||
| 214 | ||||||
| 215 | // Retri eve the ld apPath | |||||
| 216 | String l dapPath = String.Emp ty; | |||||
| 217 | // Retri eve the sa les team - 1 sales m anager and 2 sales r epresentat ives. | |||||
| 218 | _salesMa nagerId = | |||||
| 219 | Syst emUserProv ider.Retri eveSalesMa nager(_ser viceProxy, ref ldapP ath); | |||||
| 220 | _salesRe presentati veIds = | |||||
| 221 | Syst emUserProv ider.Retri eveSalespe rsons(_ser viceProxy, ref ldapP ath); | |||||
| 222 | ||||||
| 223 | #endregi on | |||||
| 224 | ||||||
| 225 | #region Create rec ords to su pport Oppo rtunity re cords | |||||
| 226 | // Creat e a unit g roup | |||||
| 227 | UoMSched ule newUni tGroup = n ew UoMSche dule | |||||
| 228 | { | |||||
| 229 | Name = "Exampl e Unit Gro up", | |||||
| 230 | Base UoMName = "Example P rimary Uni t" | |||||
| 231 | }; | |||||
| 232 | _unitGro upId = _se rviceProxy .Create(ne wUnitGroup ); | |||||
| 233 | ||||||
| 234 | // Retri eve the de fault unit id that w as automat ically cre ated | |||||
| 235 | // when we created the Unit Group | |||||
| 236 | QueryExp ression un itQuery = new QueryE xpression | |||||
| 237 | { | |||||
| 238 | Enti tyName = U oM.EntityL ogicalName , | |||||
| 239 | Colu mnSet = ne w ColumnSe t("uomid", "name"), | |||||
| 240 | Crit eria = new FilterExp ression | |||||
| 241 | { | |||||
| 242 | Conditions = | |||||
| 243 | { | |||||
| 244 | ne w Conditio nExpressio n | |||||
| 245 | { | |||||
| 246 | Attribut eName = "u omschedule id", | |||||
| 247 | Operator = Conditi onOperator .Equal, | |||||
| 248 | Values = { _unitGr oupId } | |||||
| 249 | } | |||||
| 250 | } | |||||
| 251 | }, | |||||
| 252 | Page Info = new PagingInf o | |||||
| 253 | { | |||||
| 254 | PageNumber = 1, | |||||
| 255 | Count = 1 | |||||
| 256 | } | |||||
| 257 | }; | |||||
| 258 | ||||||
| 259 | // Retri eve the un it. | |||||
| 260 | UoM unit = (UoM)_s erviceProx y.Retrieve Multiple(u nitQuery). Entities[0 ]; | |||||
| 261 | _default UnitId = u nit.UoMId. Value; | |||||
| 262 | ||||||
| 263 | // Creat e a few pr oducts | |||||
| 264 | Product newProduct 1 = new Pr oduct | |||||
| 265 | { | |||||
| 266 | Prod uctNumber = "1", | |||||
| 267 | Name = "Exampl e Product 1", | |||||
| 268 | Prod uctStructu re = new O ptionSetVa lue(1), | |||||
| 269 | Quan tityDecima l = 2, | |||||
| 270 | Defa ultUoMSche duleId = n ew EntityR eference(U oMSchedule .EntityLog icalName, | |||||
| 271 | _unitGroup Id), | |||||
| 272 | Defa ultUoMId = new Entit yReference (UoM.Entit yLogicalNa me, _defau ltUnitId) | |||||
| 273 | }; | |||||
| 274 | _product 1Id = _ser viceProxy. Create(new Product1); | |||||
| 275 | Console. WriteLine( "Created { 0}", newPr oduct1.Nam e); | |||||
| 276 | ||||||
| 277 | Product newProduct 2 = new Pr oduct | |||||
| 278 | { | |||||
| 279 | Prod uctNumber = "2", | |||||
| 280 | Name = "Exampl e Product 2", | |||||
| 281 | Prod uctStructu re = new O ptionSetVa lue(1), | |||||
| 282 | Quan tityDecima l = 3, | |||||
| 283 | Defa ultUoMSche duleId = n ew EntityR eference(U oMSchedule .EntityLog icalName, | |||||
| 284 | _unitGroup Id), | |||||
| 285 | Defa ultUoMId = new Entit yReference (UoM.Entit yLogicalNa me, _defau ltUnitId) | |||||
| 286 | }; | |||||
| 287 | _product 2Id = _ser viceProxy. Create(new Product2); | |||||
| 288 | Console. WriteLine( "Created { 0}", newPr oduct2.Nam e); | |||||
| 289 | ||||||
| 290 | // Creat e a price list | |||||
| 291 | PriceLev el newPric eList = ne w PriceLev el | |||||
| 292 | { | |||||
| 293 | Name = "Exampl e Price Li st" | |||||
| 294 | }; | |||||
| 295 | _priceLi stId = _se rviceProxy .Create(ne wPriceList ); | |||||
| 296 | ||||||
| 297 | // Creat e a price list item for the fi rst produc t and appl y volume d iscount | |||||
| 298 | ProductP riceLevel newPriceLi stItem1 = new Produc tPriceLeve l | |||||
| 299 | { | |||||
| 300 | Pric eLevelId = new Entit yReference (PriceLeve l.EntityLo gicalName, _priceLis tId), | |||||
| 301 | Prod uctId = ne w EntityRe ference(Pr oduct.Enti tyLogicalN ame, _prod uct1Id), | |||||
| 302 | UoMI d = new En tityRefere nce(UoM.En tityLogica lName, _de faultUnitI d), | |||||
| 303 | Amou nt = new M oney(20) | |||||
| 304 | }; | |||||
| 305 | _priceLi stItem1Id = _service Proxy.Crea te(newPric eListItem1 ); | |||||
| 306 | ||||||
| 307 | // Creat e a price list item for the se cond produ ct | |||||
| 308 | ProductP riceLevel newPriceLi stItem2 = new Produc tPriceLeve l | |||||
| 309 | { | |||||
| 310 | Pric eLevelId = new Entit yReference (PriceLeve l.EntityLo gicalName, _priceLis tId), | |||||
| 311 | Prod uctId = ne w EntityRe ference(Pr oduct.Enti tyLogicalN ame, _prod uct2Id), | |||||
| 312 | UoMI d = new En tityRefere nce(UoM.En tityLogica lName, _de faultUnitI d), | |||||
| 313 | Amou nt = new M oney(15) | |||||
| 314 | }; | |||||
| 315 | _priceLi stItem2Id = _service Proxy.Crea te(newPric eListItem2 ); | |||||
| 316 | ||||||
| 317 | //Publis h Product1 | |||||
| 318 | SetState Request pu blishReque st1 = new SetStateRe quest | |||||
| 319 | { | |||||
| 320 | Enti tyMoniker = new Enti tyReferenc e(Product. EntityLogi calName, _ product1Id ), | |||||
| 321 | Stat e = new Op tionSetVal ue((int)Pr oductState .Active), | |||||
| 322 | Stat us = new O ptionSetVa lue(1) | |||||
| 323 | }; | |||||
| 324 | _service Proxy.Exec ute(publis hRequest1) ; | |||||
| 325 | ||||||
| 326 | //Publis h Product2 | |||||
| 327 | SetState Request pu blishReque st2 = new SetStateRe quest | |||||
| 328 | { | |||||
| 329 | Enti tyMoniker = new Enti tyReferenc e(Product. EntityLogi calName, _ product2Id ), | |||||
| 330 | Stat e = new Op tionSetVal ue((int)Pr oductState .Active), | |||||
| 331 | Stat us = new O ptionSetVa lue(1) | |||||
| 332 | }; | |||||
| 333 | _service Proxy.Exec ute(publis hRequest2) ; | |||||
| 334 | Console. WriteLine( "Published both the products") ; | |||||
| 335 | ||||||
| 336 | // Creat e an accou nt record for the op portunity' s potentia l customer id | |||||
| 337 | Account newAccount = new Acc ount | |||||
| 338 | { | |||||
| 339 | Name = "Margie 's Travel" , | |||||
| 340 | Addr ess1_Posta lCode = "9 9999" | |||||
| 341 | }; | |||||
| 342 | _account Id = (_ser viceProxy. Create(new Account)); | |||||
| 343 | ||||||
| 344 | #endregi on Create records to support O pportunity records | |||||
| 345 | ||||||
| 346 | } | |||||
| 347 | ||||||
| 348 | // / <summary > | |||||
| 349 | // / Deletes any entity records t hat were c reated for this samp le. | |||||
| 350 | // / <param n ame="promp t">Indicat es whether to prompt the user | |||||
| 351 | // / to delet e the reco rds create d in this sample.</p aram> | |||||
| 352 | // / </summar y> | |||||
| 353 | pu blic void DeleteRequ iredRecord s(bool pro mpt) | |||||
| 354 | { | |||||
| 355 | // Two o f the cont racts, the ir associa ted accoun t and the contract t emplate | |||||
| 356 | // recor ds that we re created and used in this sa mple will continue t o exist | |||||
| 357 | // on yo ur system because co ntracts th at have be en invoice d cannot b e deleted | |||||
| 358 | // in Mi crosoft Dy namics CRM . They can only be p ut on hold or cancel ed. | |||||
| 359 | ||||||
| 360 | bool toB eDeleted = true; | |||||
| 361 | ||||||
| 362 | if (prom pt) | |||||
| 363 | { | |||||
| 364 | // A sk the use r if the c reated ent ities shou ld be dele ted. | |||||
| 365 | Cons ole.Write( "\nDo you want these entity re cords dele ted? (y/n) [y]: "); | |||||
| 366 | Stri ng answer = Console. ReadLine() ; | |||||
| 367 | if ( answer.Sta rtsWith("y ") || | |||||
| 368 | answer.Sta rtsWith("Y ") || | |||||
| 369 | answer == String.Emp ty) | |||||
| 370 | { | |||||
| 371 | toBeDelete d = true; | |||||
| 372 | } | |||||
| 373 | else | |||||
| 374 | { | |||||
| 375 | toBeDelete d = false; | |||||
| 376 | } | |||||
| 377 | } | |||||
| 378 | ||||||
| 379 | if (toBe Deleted) | |||||
| 380 | { | |||||
| 381 | _ser viceProxy. Delete(Sal esOrderDet ail.Entity LogicalNam e, _orderD etailId); | |||||
| 382 | _ser viceProxy. Delete(Sal esOrder.En tityLogica lName, _or derId); | |||||
| 383 | _ser viceProxy. Delete(Quo teDetail.E ntityLogic alName, _q uoteDetail Id); | |||||
| 384 | _ser viceProxy. Delete(Quo te.EntityL ogicalName , _quoteId ); | |||||
| 385 | _ser viceProxy. Delete(Opp ortunity.E ntityLogic alName, _o pportunity Id); | |||||
| 386 | _ser viceProxy. Delete(Pro ductPriceL evel.Entit yLogicalNa me, _price ListItem1I d); | |||||
| 387 | _ser viceProxy. Delete(Pro ductPriceL evel.Entit yLogicalNa me, _price ListItem2I d); | |||||
| 388 | _ser viceProxy. Delete(Pri ceLevel.En tityLogica lName, _pr iceListId) ; | |||||
| 389 | _ser viceProxy. Delete(Pro duct.Entit yLogicalNa me, _produ ct1Id); | |||||
| 390 | _ser viceProxy. Delete(Pro duct.Entit yLogicalNa me, _produ ct2Id); | |||||
| 391 | _ser viceProxy. Delete(UoM Schedule.E ntityLogic alName, _u nitGroupId ); | |||||
| 392 | _ser viceProxy. Delete(Acc ount.Entit yLogicalNa me, _accou ntId); | |||||
| 393 | Cons ole.WriteL ine("Entit y record(s ) have bee n deleted. "); | |||||
| 394 | } | |||||
| 395 | } | |||||
| 396 | ||||||
| 397 | #e ndregion H ow To Samp le Code | |||||
| 398 | ||||||
| 399 | #r egion Main method | |||||
| 400 | ||||||
| 401 | // / <summary > | |||||
| 402 | // / Standard Main() me thod used by most SD K samples. | |||||
| 403 | // / </summar y> | |||||
| 404 | // / <param n ame="args" ></param> | |||||
| 405 | st atic publi c void Mai n(string[] args) | |||||
| 406 | { | |||||
| 407 | try | |||||
| 408 | { | |||||
| 409 | // O btain the target org anization' s Web addr ess and cl ient logon | |||||
| 410 | // c redentials from the user. | |||||
| 411 | Serv erConnecti on serverC onnect = n ew ServerC onnection( ); | |||||
| 412 | Serv erConnecti on.Configu ration con fig = serv erConnect. GetServerC onfigurati on(); | |||||
| 413 | ||||||
| 414 | Work ingWithNeg ativePrice s app = ne w WorkingW ithNegativ ePrices(); | |||||
| 415 | app. Run(config , true); | |||||
| 416 | } | |||||
| 417 | catch (F aultExcept ion<Micros oft.Xrm.Sd k.Organiza tionServic eFault> ex ) | |||||
| 418 | { | |||||
| 419 | Cons ole.WriteL ine("The a pplication terminate d with an error."); | |||||
| 420 | Cons ole.WriteL ine("Times tamp: {0}" , ex.Detai l.Timestam p); | |||||
| 421 | Cons ole.WriteL ine("Code: {0}", ex. Detail.Err orCode); | |||||
| 422 | Cons ole.WriteL ine("Messa ge: {0}", ex.Detail. Message); | |||||
| 423 | Cons ole.WriteL ine("Plugi n Trace: { 0}", ex.De tail.Trace Text); | |||||
| 424 | Cons ole.WriteL ine("Inner Fault: {0 }", | |||||
| 425 | null == ex .Detail.In nerFault ? "No Inner Fault" : "Has Inner Fault"); | |||||
| 426 | } | |||||
| 427 | catch (S ystem.Time outExcepti on ex) | |||||
| 428 | { | |||||
| 429 | Cons ole.WriteL ine("The a pplication terminate d with an error."); | |||||
| 430 | Cons ole.WriteL ine("Messa ge: {0}", ex.Message ); | |||||
| 431 | Cons ole.WriteL ine("Stack Trace: {0 }", ex.Sta ckTrace); | |||||
| 432 | Cons ole.WriteL ine("Inner Fault: {0 }", | |||||
| 433 | null == ex .InnerExce ption.Mess age ? "No Inner Faul t" : ex.In nerExcepti on.Message ); | |||||
| 434 | } | |||||
| 435 | catch (S ystem.Exce ption ex) | |||||
| 436 | { | |||||
| 437 | Cons ole.WriteL ine("The a pplication terminate d with an error."); | |||||
| 438 | Cons ole.WriteL ine(ex.Mes sage); | |||||
| 439 | ||||||
| 440 | // D isplay the details o f the inne r exceptio n. | |||||
| 441 | if ( ex.InnerEx ception != null) | |||||
| 442 | { | |||||
| 443 | Console.Wr iteLine(ex .InnerExce ption.Mess age); | |||||
| 444 | ||||||
| 445 | FaultExcep tion<Micro soft.Xrm.S dk.Organiz ationServi ceFault> f e = ex.Inn erExceptio n | |||||
| 446 | as Fau ltExceptio n<Microsof t.Xrm.Sdk. Organizati onServiceF ault>; | |||||
| 447 | if (fe != null) | |||||
| 448 | { | |||||
| 449 | Consol e.WriteLin e("Timesta mp: {0}", fe.Detail. Timestamp) ; | |||||
| 450 | Consol e.WriteLin e("Code: { 0}", fe.De tail.Error Code); | |||||
| 451 | Consol e.WriteLin e("Message : {0}", fe .Detail.Me ssage); | |||||
| 452 | Consol e.WriteLin e("Plugin Trace: {0} ", fe.Deta il.TraceTe xt); | |||||
| 453 | Consol e.WriteLin e("Inner F ault: {0}" , | |||||
| 454 | nu ll == fe.D etail.Inne rFault ? " No Inner F ault" : "H as Inner F ault"); | |||||
| 455 | } | |||||
| 456 | } | |||||
| 457 | } | |||||
| 458 | // Addit ional exce ptions to catch: Sec urityToken Validation Exception, ExpiredSe curityToke nException , | |||||
| 459 | // Secur ityAccessD eniedExcep tion, Mess ageSecurit yException , and Secu rityNegoti ationExcep tion. | |||||
| 460 | ||||||
| 461 | finally | |||||
| 462 | { | |||||
| 463 | Cons ole.WriteL ine("Press <Enter> t o exit."); | |||||
| 464 | Cons ole.ReadLi ne(); | |||||
| 465 | } | |||||
| 466 | } | |||||
| 467 | #e ndregion M ain method | |||||
| 468 | } | |||||
| 469 | } | |||||
| 470 | //</snippe tWorkingWi thNegative Prices> |
Araxis Merge (but not the data content of this report) is Copyright © 1993-2016 Araxis Ltd (www.araxis.com). All rights reserved.