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\Goals | RollupAllGoalsForCustomPeriodAgainstTargetRevenue.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 | 765 |
| 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 RollupAllG oalsForCus tomPeriodA gainstTarg etRevenue> | |||||
| 17 | using Syst em; | |||||
| 18 | using Syst em.Service Model; | |||||
| 19 | using Syst em.Collect ions.Gener ic; | |||||
| 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.Query; | |||||
| 25 | using Micr osoft.Xrm. Sdk.Client ; | |||||
| 26 | ||||||
| 27 | // This na mespace is found in Microsoft. Crm.Sdk.Pr oxy.dll as sembly | |||||
| 28 | // found i n the SDK\ bin folder . | |||||
| 29 | using Micr osoft.Crm. Sdk.Messag es; | |||||
| 30 | ||||||
| 31 | namespace Microsoft. Crm.Sdk.Sa mples | |||||
| 32 | { | |||||
| 33 | /// <s ummary> | |||||
| 34 | /// De monstrates how to wo rk with Go als and re lated enti ties.</sum mary> | |||||
| 35 | /// <r emarks> | |||||
| 36 | /// At run-time, you will be given t he option to delete all the | |||||
| 37 | /// da tabase rec ords creat ed by this program.< /remarks> | |||||
| 38 | public class Rol lupAllGoal sForCustom PeriodAgai nstTargetR evenue | |||||
| 39 | { | |||||
| 40 | #r egion Clas s Level Me mbers | |||||
| 41 | ||||||
| 42 | pr ivate Guid _salesMan agerId; | |||||
| 43 | pr ivate Guid _unitGrou pId; | |||||
| 44 | pr ivate Guid _defaultU nitId; | |||||
| 45 | pr ivate Guid _product1 Id; | |||||
| 46 | pr ivate Guid _product2 Id; | |||||
| 47 | pr ivate Guid _discount TypeId; | |||||
| 48 | pr ivate Guid _discount Id; | |||||
| 49 | pr ivate Guid _priceLis tId; | |||||
| 50 | pr ivate Guid _priceLis tItem1Id; | |||||
| 51 | pr ivate Guid _priceLis tItem2Id; | |||||
| 52 | pr ivate Guid _catalogP roductId; | |||||
| 53 | pr ivate Guid _catalogP roductPric eOverrideI d; | |||||
| 54 | pr ivate Guid _writeInP roductId; | |||||
| 55 | pr ivate Guid _metricId ; | |||||
| 56 | pr ivate Guid _inProgre ssId; | |||||
| 57 | pr ivate Guid _actualId ; | |||||
| 58 | pr ivate Guid _parentGo alId; | |||||
| 59 | pr ivate Guid _firstChi ldGoalId; | |||||
| 60 | pr ivate Guid _secondCh ildGoalId; | |||||
| 61 | pr ivate List <Guid> _ac countIds = new List< Guid>(); | |||||
| 62 | pr ivate List <Guid> _ro llupQueryI ds = new L ist<Guid>( ); | |||||
| 63 | pr ivate List <Guid> _sa lesReprese ntativeIds = new Lis t<Guid>(); | |||||
| 64 | pr ivate List <Guid> _op portunityI ds = new L ist<Guid>( ); | |||||
| 65 | ||||||
| 66 | pr ivate Orga nizationSe rviceProxy _serviceP roxy; | |||||
| 67 | ||||||
| 68 | #e ndregion C lass Level Members | |||||
| 69 | ||||||
| 70 | #r egion How To Sample Code | |||||
| 71 | // / <summary > | |||||
| 72 | // / This met hod first connects t o the Orga nization s ervice. Af terwards, | |||||
| 73 | // / several actions on Goal reco rds are ex ecuted. | |||||
| 74 | // / </summar y> | |||||
| 75 | // / <param n ame="serve rConfig">C ontains se rver conne ction info rmation.</ param> | |||||
| 76 | // / <param n ame="promp tforDelete ">When Tru e, the use r will be prompted t o delete a ll | |||||
| 77 | // / created entities.< /param> | |||||
| 78 | pu blic void Run(Server Connection .Configura tion serve rConfig, b ool prompt forDelete) | |||||
| 79 | { | |||||
| 80 | try | |||||
| 81 | { | |||||
| 82 | //<s nippetRoll upAllGoals ForCustomP eriodAgain stTargetRe venue1> | |||||
| 83 | // C onnect to the Organi zation ser vice. | |||||
| 84 | // T he using s tatement a ssures tha t the serv ice proxy will be pr operly dis posed. | |||||
| 85 | 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 )) | |||||
| 86 | { | |||||
| 87 | // This st atement is required to enable early-boun d type sup port. | |||||
| 88 | _servicePr oxy.Enable ProxyTypes (); | |||||
| 89 | ||||||
| 90 | CreateRequ iredRecord s(); | |||||
| 91 | ||||||
| 92 | // Create the revenu e metric, setting th e Amount D ata Type t o 'Money' | |||||
| 93 | // and the Metric Ty pe to 'Amo unt'. | |||||
| 94 | Metric sam pleMetric = new Metr ic() | |||||
| 95 | { | |||||
| 96 | Name = "Sample R evenue Met ric", | |||||
| 97 | Amount DataType = new Optio nSetValue( 0), | |||||
| 98 | IsAmou nt = true, | |||||
| 99 | }; | |||||
| 100 | _metricId = _service Proxy.Crea te(sampleM etric); | |||||
| 101 | ||||||
| 102 | Console.Wr ite("Creat ed revenue metric, " ); | |||||
| 103 | ||||||
| 104 | // Create first Roll upField wh ich target s the esti mated valu es. | |||||
| 105 | RollupFiel d inProgre ss = new R ollupField () | |||||
| 106 | { | |||||
| 107 | Source Entity = O pportunity .EntityLog icalName, | |||||
| 108 | Source Attribute = "estimat edvalue", | |||||
| 109 | GoalAt tribute = "inprogres smoney", | |||||
| 110 | Source State = 0, | |||||
| 111 | Entity ForDateAtt ribute = O pportunity .EntityLog icalName, | |||||
| 112 | DateAt tribute = "estimated closedate" , | |||||
| 113 | Metric Id = new E ntityRefer ence(Metri c.EntityLo gicalName, _metricId ), | |||||
| 114 | }; | |||||
| 115 | _inProgres sId = _ser viceProxy. Create(inP rogress); | |||||
| 116 | ||||||
| 117 | Console.Wr ite("creat ed in-prog ress Rollu pField, ") ; | |||||
| 118 | ||||||
| 119 | // Create second Rol lupField w hich targe ts the act ual values . | |||||
| 120 | RollupFiel d actual = new Rollu pField() | |||||
| 121 | { | |||||
| 122 | Source Entity = O pportunity .EntityLog icalName, | |||||
| 123 | Source Attribute = "actualv alue", | |||||
| 124 | GoalAt tribute = "actualmon ey", | |||||
| 125 | Source State = 1, | |||||
| 126 | Entity ForDateAtt ribute = O pportunity .EntityLog icalName, | |||||
| 127 | DateAt tribute = "actualclo sedate", | |||||
| 128 | Metric Id = new E ntityRefer ence(Metri c.EntityLo gicalName, _metricId ) | |||||
| 129 | }; | |||||
| 130 | _actualId = _service Proxy.Crea te(actual) ; | |||||
| 131 | ||||||
| 132 | Console.Wr ite("creat ed actual revenue Ro llupField, "); | |||||
| 133 | ||||||
| 134 | // Create the goal r ollup quer ies. | |||||
| 135 | // Note: F ormatting the FetchX ml onto mu ltiple lin es in the following | |||||
| 136 | // rollup queries ca uses the l enth prope rty to be greater th an 1,000 | |||||
| 137 | // chars a nd will ca use an exc eption. | |||||
| 138 | ||||||
| 139 | // The fir st query l ocates opp ortunities in the fi rst sales | |||||
| 140 | // represe ntative's area (zip code: 6066 1). | |||||
| 141 | GoalRollup Query goal RollupQuer y = new Go alRollupQu ery() | |||||
| 142 | { | |||||
| 143 | Name = "First Ex ample Goal Rollup Qu ery", | |||||
| 144 | QueryE ntityType = Opportun ity.Entity LogicalNam e, | |||||
| 145 | FetchX ml = @"<fe tch versio n=""1.0"" output-for mat=""xml- platform"" mapping=" "logical"" distinct= ""false""> <entity na me=""oppor tunity"">< attribute name=""tot alamount"" /><attribu te name="" name""/><a ttribute n ame=""cust omerid""/> <attribute name=""es timatedval ue""/><att ribute nam e=""status code""/><a ttribute n ame=""oppo rtunityid" "/><order attribute= ""name"" d escending= ""false""/ ><link-ent ity name=" "account"" from=""ac countid"" to=""custo merid"" al ias=""aa"" ><filter t ype=""and" "><conditi on attribu te=""addre ss1_postal code"" ope rator=""eq "" value=" "60661""/> </filter>< /link-enti ty></entit y></fetch> " | |||||
| 146 | }; | |||||
| 147 | _rollupQue ryIds.Add( _servicePr oxy.Create (goalRollu pQuery)); | |||||
| 148 | ||||||
| 149 | Console.Wr ite("creat ed first r ollup quer y for zip code 60661 , "); | |||||
| 150 | ||||||
| 151 | // The sec ond query locates op portunitie s in the s econd sale s | |||||
| 152 | // represe ntative's area (zip code: 9999 9). | |||||
| 153 | goalRollup Query = ne w GoalRoll upQuery() | |||||
| 154 | { | |||||
| 155 | Name = "Second E xample Goa l Rollup Q uery", | |||||
| 156 | QueryE ntityType = Opportun ity.Entity LogicalNam e, | |||||
| 157 | FetchX ml = @"<fe tch versio n=""1.0"" output-for mat=""xml- platform"" mapping=" "logical"" distinct= ""false""> <entity na me=""oppor tunity"">< attribute name=""tot alamount"" /><attribu te name="" customerid ""/><attri bute name= ""estimate dvalue""/> <attribute name=""st atuscode"" /><attribu te name="" opportunit yid""/><or der attrib ute=""name "" descend ing=""fals e""/><link -entity na me=""accou nt"" from= ""accounti d"" to=""c ustomerid" " alias="" aa""><filt er type="" and""><con dition att ribute=""a ddress1_po stalcode"" operator= ""eq"" val ue=""99999 ""/></filt er></link- entity></e ntity></fe tch>" | |||||
| 158 | }; | |||||
| 159 | _rollupQue ryIds.Add( _servicePr oxy.Create (goalRollu pQuery)); | |||||
| 160 | ||||||
| 161 | Console.Wr iteLine("c reated sec ond rollup query for zip code 99999."); | |||||
| 162 | Console.Wr iteLine(); | |||||
| 163 | ||||||
| 164 | // Create three goal s: one par ent goal a nd two chi ld goals. | |||||
| 165 | Goal paren tGoal = ne w Goal() | |||||
| 166 | { | |||||
| 167 | Title = "Parent Goal Examp le", | |||||
| 168 | Rollup OnlyFromCh ildGoals = true, | |||||
| 169 | Consid erOnlyGoal OwnersReco rds = true , | |||||
| 170 | Target Money = ne w Money(30 0.0M), | |||||
| 171 | IsFisc alPeriodGo al = false , | |||||
| 172 | Metric Id = new E ntityRefer ence | |||||
| 173 | { | |||||
| 174 | Id = _metric Id, | |||||
| 175 | Lo gicalName = Metric.E ntityLogic alName | |||||
| 176 | }, | |||||
| 177 | GoalOw nerId = ne w EntityRe ference | |||||
| 178 | { | |||||
| 179 | Id = _salesM anagerId, | |||||
| 180 | Lo gicalName = SystemUs er.EntityL ogicalName | |||||
| 181 | }, | |||||
| 182 | OwnerI d = new En tityRefere nce | |||||
| 183 | { | |||||
| 184 | Id = _salesM anagerId, | |||||
| 185 | Lo gicalName = SystemUs er.EntityL ogicalName | |||||
| 186 | }, | |||||
| 187 | GoalSt artDate = DateTime.T oday.AddDa ys(-1), | |||||
| 188 | GoalEn dDate = Da teTime.Tod ay.AddDays (30) | |||||
| 189 | }; | |||||
| 190 | _parentGoa lId = _ser viceProxy. Create(par entGoal); | |||||
| 191 | ||||||
| 192 | Console.Wr iteLine("C reated par ent goal") ; | |||||
| 193 | Console.Wr iteLine("- ---------- --------") ; | |||||
| 194 | Console.Wr iteLine("T arget: {0} ", parentG oal.Target Money.Valu e); | |||||
| 195 | Console.Wr iteLine("G oal owner: {0}", par entGoal.Go alOwnerId. Id); | |||||
| 196 | Console.Wr iteLine("G oal Start Date: {0}" , parentGo al.GoalSta rtDate); | |||||
| 197 | Console.Wr iteLine("G oal End Da te: {0}", parentGoal .GoalEndDa te); | |||||
| 198 | Console.Wr iteLine("< End of Lis ting>"); | |||||
| 199 | Console.Wr iteLine(); | |||||
| 200 | ||||||
| 201 | Goal first ChildGoal = new Goal () | |||||
| 202 | { | |||||
| 203 | Title = "First C hild Goal Example", | |||||
| 204 | Consid erOnlyGoal OwnersReco rds = true , | |||||
| 205 | Target Money = ne w Money(10 0.0M), | |||||
| 206 | IsFisc alPeriodGo al = false , | |||||
| 207 | Metric Id = new E ntityRefer ence | |||||
| 208 | { | |||||
| 209 | Id = _metric Id, | |||||
| 210 | Lo gicalName = Metric.E ntityLogic alName | |||||
| 211 | }, | |||||
| 212 | Parent GoalId = n ew EntityR eference | |||||
| 213 | { | |||||
| 214 | Id = _parent GoalId, | |||||
| 215 | Lo gicalName = Goal.Ent ityLogical Name | |||||
| 216 | }, | |||||
| 217 | GoalOw nerId = ne w EntityRe ference | |||||
| 218 | { | |||||
| 219 | Id = _salesR epresentat iveIds[0], | |||||
| 220 | Lo gicalName = SystemUs er.EntityL ogicalName | |||||
| 221 | }, | |||||
| 222 | OwnerI d = new En tityRefere nce | |||||
| 223 | { | |||||
| 224 | Id = _salesM anagerId, | |||||
| 225 | Lo gicalName = SystemUs er.EntityL ogicalName | |||||
| 226 | }, | |||||
| 227 | RollUp QueryActua lMoneyId = new Entit yReference | |||||
| 228 | { | |||||
| 229 | Id = _rollup QueryIds[0 ], | |||||
| 230 | Lo gicalName = GoalRoll upQuery.En tityLogica lName | |||||
| 231 | }, | |||||
| 232 | GoalSt artDate = DateTime.T oday.AddDa ys(-1), | |||||
| 233 | GoalEn dDate = Da teTime.Tod ay.AddDays (30) | |||||
| 234 | }; | |||||
| 235 | _firstChil dGoalId = _servicePr oxy.Create (firstChil dGoal); | |||||
| 236 | ||||||
| 237 | Console.Wr iteLine("F irst child goal"); | |||||
| 238 | Console.Wr iteLine("- ---------- -----"); | |||||
| 239 | Console.Wr iteLine("T arget: {0} ", firstCh ildGoal.Ta rgetMoney. Value); | |||||
| 240 | Console.Wr iteLine("G oal owner: {0}", fir stChildGoa l.GoalOwne rId.Id); | |||||
| 241 | Console.Wr iteLine("G oal Start Date: {0}" , firstChi ldGoal.Goa lStartDate ); | |||||
| 242 | Console.Wr iteLine("G oal End Da te: {0}", firstChild Goal.GoalE ndDate); | |||||
| 243 | Console.Wr iteLine(); | |||||
| 244 | ||||||
| 245 | Goal secon dChildGoal = new Goa l() | |||||
| 246 | { | |||||
| 247 | Title = "Second Child Goal Example", | |||||
| 248 | Consid erOnlyGoal OwnersReco rds = true , | |||||
| 249 | Target Money = ne w Money(20 0.0M), | |||||
| 250 | IsFisc alPeriodGo al = false , | |||||
| 251 | Metric Id = new E ntityRefer ence | |||||
| 252 | { | |||||
| 253 | Id = _metric Id, | |||||
| 254 | Lo gicalName = Metric.E ntityLogic alName | |||||
| 255 | }, | |||||
| 256 | Parent GoalId = n ew EntityR eference | |||||
| 257 | { | |||||
| 258 | Id = _parent GoalId, | |||||
| 259 | Lo gicalName = Goal.Ent ityLogical Name | |||||
| 260 | }, | |||||
| 261 | GoalOw nerId = ne w EntityRe ference | |||||
| 262 | { | |||||
| 263 | Id = _salesR epresentat iveIds[1], | |||||
| 264 | Lo gicalName = SystemUs er.EntityL ogicalName | |||||
| 265 | }, | |||||
| 266 | OwnerI d = new En tityRefere nce | |||||
| 267 | { | |||||
| 268 | Id = _salesM anagerId, | |||||
| 269 | Lo gicalName = SystemUs er.EntityL ogicalName | |||||
| 270 | }, | |||||
| 271 | RollUp QueryActua lMoneyId = new Entit yReference | |||||
| 272 | { | |||||
| 273 | Id = _rollup QueryIds[1 ], | |||||
| 274 | Lo gicalName = GoalRoll upQuery.En tityLogica lName | |||||
| 275 | }, | |||||
| 276 | GoalSt artDate = DateTime.T oday.AddDa ys(-1), | |||||
| 277 | GoalEn dDate = Da teTime.Tod ay.AddDays (30) | |||||
| 278 | }; | |||||
| 279 | _secondChi ldGoalId = _serviceP roxy.Creat e(secondCh ildGoal); | |||||
| 280 | ||||||
| 281 | Console.Wr iteLine("S econd chil d goal"); | |||||
| 282 | Console.Wr iteLine("- ---------- ------"); | |||||
| 283 | Console.Wr iteLine("T arget: {0} ", secondC hildGoal.T argetMoney .Value); | |||||
| 284 | Console.Wr iteLine("G oal owner: {0}", sec ondChildGo al.GoalOwn erId.Id); | |||||
| 285 | Console.Wr iteLine("G oal Start Date: {0}" , secondCh ildGoal.Go alStartDat e); | |||||
| 286 | Console.Wr iteLine("G oal End Da te: {0}", secondChil dGoal.Goal EndDate); | |||||
| 287 | Console.Wr iteLine(); | |||||
| 288 | ||||||
| 289 | // <snippe tRecalcula te1> | |||||
| 290 | // Calcula te roll-up of goals. | |||||
| 291 | Recalculat eRequest r ecalculate Request = new Recalc ulateReque st() | |||||
| 292 | { | |||||
| 293 | Target = new Ent ityReferen ce(Goal.En tityLogica lName, _pa rentGoalId ) | |||||
| 294 | }; | |||||
| 295 | _servicePr oxy.Execut e(recalcul ateRequest ); | |||||
| 296 | ||||||
| 297 | //</snippe tRecalcula te1> | |||||
| 298 | Console.Wr iteLine("C alculated roll-up of goals."); | |||||
| 299 | ||||||
| 300 | // Retriev e and repo rt 3 diffe rent compu ted values for the g oals | |||||
| 301 | // - Perce ntage | |||||
| 302 | // - Compu tedTargetA sOfTodayPe rcentageAc hieved | |||||
| 303 | // - Compu tedTargetA sOfTodayMo ney | |||||
| 304 | QueryExpre ssion retr ieveValues = new Que ryExpressi on() | |||||
| 305 | { | |||||
| 306 | Entity Name = Goa l.EntityLo gicalName, | |||||
| 307 | Column Set = new ColumnSet( | |||||
| 308 | "t itle", | |||||
| 309 | "p ercentage" , | |||||
| 310 | "c omputedtar getasoftod aypercenta geachieved ", | |||||
| 311 | "c omputedtar getasoftod aymoney") | |||||
| 312 | }; | |||||
| 313 | EntityColl ection ec = _service Proxy.Retr ieveMultip le(retriev eValues); | |||||
| 314 | ||||||
| 315 | // Compute and displ ay the res ults | |||||
| 316 | for (int i = 0; i < ec.Entitie s.Count; i ++) | |||||
| 317 | { | |||||
| 318 | Goal t emp = (Goa l)ec.Entit ies[i]; | |||||
| 319 | Consol e.WriteLin e("Roll-up details f or goal: { 0}", temp. Title); | |||||
| 320 | Consol e.WriteLin e("------- --------") ; | |||||
| 321 | Consol e.WriteLin e("Percent age: {0}", temp.Perc entage); | |||||
| 322 | Consol e.WriteLin e("Compute dTargetAsO fTodayPerc entageAchi eved: {0}" , | |||||
| 323 | te mp.Compute dTargetAsO fTodayPerc entageAchi eved); | |||||
| 324 | Consol e.WriteLin e("Compute dTargetAsO fTodayMone y: {0}", | |||||
| 325 | te mp.Compute dTargetAsO fTodayMone y.Value); | |||||
| 326 | Consol e.WriteLin e("<End of Listing>" ); | |||||
| 327 | } | |||||
| 328 | ||||||
| 329 | DeleteRequ iredRecord s(promptfo rDelete); | |||||
| 330 | } | |||||
| 331 | //</ snippetRol lupAllGoal sForCustom PeriodAgai nstTargetR evenue1> | |||||
| 332 | } | |||||
| 333 | ||||||
| 334 | // Catch any servi ce fault e xceptions that Micro soft Dynam ics CRM th rows. | |||||
| 335 | catch (F aultExcept ion<Micros oft.Xrm.Sd k.Organiza tionServic eFault>) | |||||
| 336 | { | |||||
| 337 | // Y ou can han dle an exc eption her e or pass it back to the calli ng method. | |||||
| 338 | thro w; | |||||
| 339 | } | |||||
| 340 | } | |||||
| 341 | ||||||
| 342 | // / <summary > | |||||
| 343 | // / Creates any entity records t hat this s ample requ ires. | |||||
| 344 | // / </summar y> | |||||
| 345 | pu blic void CreateRequ iredRecord s() | |||||
| 346 | { | |||||
| 347 | ||||||
| 348 | #region Create or Retrieve t he necessa ry system users | |||||
| 349 | ||||||
| 350 | // Retri eve the ld apPath | |||||
| 351 | String l dapPath = String.Emp ty; | |||||
| 352 | // Retri eve the sa les team - 1 sales m anager and 2 sales r epresentat ives. | |||||
| 353 | _salesMa nagerId = SystemUser Provider.R etrieveSal esManager( _servicePr oxy, ref l dapPath); | |||||
| 354 | _salesRe presentati veIds = Sy stemUserPr ovider.Ret rieveSales persons(_s erviceProx y, ref lda pPath); | |||||
| 355 | ||||||
| 356 | #endregi on | |||||
| 357 | ||||||
| 358 | #region Create rec ords to su pport Oppo rtunity re cords | |||||
| 359 | // Creat e a unit g roup | |||||
| 360 | UoMSched ule newUni tGroup = n ew UoMSche dule | |||||
| 361 | { | |||||
| 362 | Name = "Exampl e Unit Gro up", | |||||
| 363 | Base UoMName = "Example P rimary Uni t" | |||||
| 364 | }; | |||||
| 365 | _unitGro upId = _se rviceProxy .Create(ne wUnitGroup ); | |||||
| 366 | ||||||
| 367 | // Retri eve the de fault unit id that w as automat ically cre ated | |||||
| 368 | // when we created the Unit Group | |||||
| 369 | QueryExp ression un itQuery = new QueryE xpression | |||||
| 370 | { | |||||
| 371 | Enti tyName = U oM.EntityL ogicalName , | |||||
| 372 | Colu mnSet = ne w ColumnSe t("uomid", "name"), | |||||
| 373 | Crit eria = new FilterExp ression | |||||
| 374 | { | |||||
| 375 | Conditions = | |||||
| 376 | { | |||||
| 377 | ne w Conditio nExpressio n | |||||
| 378 | { | |||||
| 379 | Attribut eName = "u omschedule id", | |||||
| 380 | Operator = Conditi onOperator .Equal, | |||||
| 381 | Values = { _unitGr oupId } | |||||
| 382 | } | |||||
| 383 | } | |||||
| 384 | }, | |||||
| 385 | Page Info = new PagingInf o | |||||
| 386 | { | |||||
| 387 | PageNumber = 1, | |||||
| 388 | Count = 1 | |||||
| 389 | } | |||||
| 390 | }; | |||||
| 391 | ||||||
| 392 | // Retri eve the un it. | |||||
| 393 | UoM unit = (UoM)_s erviceProx y.Retrieve Multiple(u nitQuery). Entities[0 ]; | |||||
| 394 | _default UnitId = u nit.UoMId. Value; | |||||
| 395 | ||||||
| 396 | // Creat e a few pr oducts | |||||
| 397 | Product newProduct 1 = new Pr oduct | |||||
| 398 | { | |||||
| 399 | Prod uctNumber = "1", | |||||
| 400 | Name = "Exampl e Product 1", | |||||
| 401 | Prod uctStructu re = new O ptionSetVa lue(1), | |||||
| 402 | Quan tityDecima l = 2, | |||||
| 403 | Defa ultUoMSche duleId = n ew EntityR eference(U oMSchedule .EntityLog icalName, | |||||
| 404 | _unitGroup Id), | |||||
| 405 | Defa ultUoMId = new Entit yReference (UoM.Entit yLogicalNa me, _defau ltUnitId) | |||||
| 406 | }; | |||||
| 407 | _product 1Id = _ser viceProxy. Create(new Product1); | |||||
| 408 | Console. WriteLine( "Created { 0}", newPr oduct1.Nam e); | |||||
| 409 | ||||||
| 410 | ||||||
| 411 | Product newProduct 2 = new Pr oduct | |||||
| 412 | { | |||||
| 413 | Prod uctNumber = "2", | |||||
| 414 | Name = "Exampl e Product 2", | |||||
| 415 | Prod uctStructu re = new O ptionSetVa lue(1), | |||||
| 416 | Quan tityDecima l = 3, | |||||
| 417 | Defa ultUoMSche duleId = n ew EntityR eference(U oMSchedule .EntityLog icalName, | |||||
| 418 | _unitGroup Id), | |||||
| 419 | Defa ultUoMId = new Entit yReference (UoM.Entit yLogicalNa me, _defau ltUnitId) | |||||
| 420 | }; | |||||
| 421 | _product 2Id = _ser viceProxy. Create(new Product2); | |||||
| 422 | Console. WriteLine( "Created { 0}", newPr oduct2.Nam e); | |||||
| 423 | ||||||
| 424 | // Creat e a new di scount lis t | |||||
| 425 | Discount Type newDi scountType = new Dis countType | |||||
| 426 | { | |||||
| 427 | Name = "Exampl e Discount List", | |||||
| 428 | IsAm ountType = false | |||||
| 429 | }; | |||||
| 430 | _discoun tTypeId = _servicePr oxy.Create (newDiscou ntType); | |||||
| 431 | ||||||
| 432 | // Creat e a new di scount | |||||
| 433 | Discount newDiscou nt = new D iscount | |||||
| 434 | { | |||||
| 435 | Disc ountTypeId = new Ent ityReferen ce(Discoun tType.Enti tyLogicalN ame, | |||||
| 436 | _discountT ypeId), | |||||
| 437 | LowQ uantity = 5, | |||||
| 438 | High Quantity = 10, | |||||
| 439 | Perc entage = 3 | |||||
| 440 | }; | |||||
| 441 | _discoun tId = _ser viceProxy. Create(new Discount); | |||||
| 442 | ||||||
| 443 | // Creat e a price list | |||||
| 444 | PriceLev el newPric eList = ne w PriceLev el | |||||
| 445 | { | |||||
| 446 | Name = "Exampl e Price Li st" | |||||
| 447 | }; | |||||
| 448 | _priceLi stId = _se rviceProxy .Create(ne wPriceList ); | |||||
| 449 | ||||||
| 450 | // Creat e a price list item for the fi rst produc t and appl y volume d iscount | |||||
| 451 | ProductP riceLevel newPriceLi stItem1 = new Produc tPriceLeve l | |||||
| 452 | { | |||||
| 453 | Pric eLevelId = new Entit yReference (PriceLeve l.EntityLo gicalName, _priceLis tId), | |||||
| 454 | Prod uctId = ne w EntityRe ference(Pr oduct.Enti tyLogicalN ame, _prod uct1Id), | |||||
| 455 | UoMI d = new En tityRefere nce(UoM.En tityLogica lName, _de faultUnitI d), | |||||
| 456 | Amou nt = new M oney(20), | |||||
| 457 | Disc ountTypeId = new Ent ityReferen ce(Discoun tType.Enti tyLogicalN ame, | |||||
| 458 | _discountT ypeId) | |||||
| 459 | }; | |||||
| 460 | _priceLi stItem1Id = _service Proxy.Crea te(newPric eListItem1 ); | |||||
| 461 | ||||||
| 462 | // Creat e a price list item for the se cond produ ct | |||||
| 463 | ProductP riceLevel newPriceLi stItem2 = new Produc tPriceLeve l | |||||
| 464 | { | |||||
| 465 | Pric eLevelId = new Entit yReference (PriceLeve l.EntityLo gicalName, _priceLis tId), | |||||
| 466 | Prod uctId = ne w EntityRe ference(Pr oduct.Enti tyLogicalN ame, _prod uct2Id), | |||||
| 467 | UoMI d = new En tityRefere nce(UoM.En tityLogica lName, _de faultUnitI d), | |||||
| 468 | Amou nt = new M oney(15) | |||||
| 469 | }; | |||||
| 470 | _priceLi stItem2Id = _service Proxy.Crea te(newPric eListItem2 ); | |||||
| 471 | ||||||
| 472 | // Publi sh Product 1 | |||||
| 473 | SetState Request pu blishReque st1 = new SetStateRe quest | |||||
| 474 | { | |||||
| 475 | Enti tyMoniker = new Enti tyReferenc e(Product. EntityLogi calName, _ product1Id ), | |||||
| 476 | Stat e = new Op tionSetVal ue((int)Pr oductState .Active), | |||||
| 477 | Stat us = new O ptionSetVa lue(1) | |||||
| 478 | }; | |||||
| 479 | _service Proxy.Exec ute(publis hRequest1) ; | |||||
| 480 | ||||||
| 481 | // Publi sh Product 2 | |||||
| 482 | SetState Request pu blishReque st2 = new SetStateRe quest | |||||
| 483 | { | |||||
| 484 | Enti tyMoniker = new Enti tyReferenc e(Product. EntityLogi calName, _ product2Id ), | |||||
| 485 | Stat e = new Op tionSetVal ue((int)Pr oductState .Active), | |||||
| 486 | Stat us = new O ptionSetVa lue(1) | |||||
| 487 | }; | |||||
| 488 | _service Proxy.Exec ute(publis hRequest2) ; | |||||
| 489 | Console. WriteLine( "Published {0} and { 1}", newPr oduct1.Nam e, newProd uct2.Name) ; | |||||
| 490 | ||||||
| 491 | // Creat e an accou nt record for the op portunity' s potentia l customer id | |||||
| 492 | Account newAccount = new Acc ount | |||||
| 493 | { | |||||
| 494 | Name = "Litwar e, Inc.", | |||||
| 495 | Addr ess1_Posta lCode = "6 0661" | |||||
| 496 | }; | |||||
| 497 | _account Ids.Add(_s erviceProx y.Create(n ewAccount) ); | |||||
| 498 | ||||||
| 499 | newAccou nt = new A ccount | |||||
| 500 | { | |||||
| 501 | Name = "Margie 's Travel" , | |||||
| 502 | Addr ess1_Posta lCode = "9 9999" | |||||
| 503 | }; | |||||
| 504 | _account Ids.Add(_s erviceProx y.Create(n ewAccount) ); | |||||
| 505 | ||||||
| 506 | #endregi on Create records to support O pportunity records | |||||
| 507 | ||||||
| 508 | #region Create Opp ortunity r ecords | |||||
| 509 | // Creat e a new op portunity with user specified estimated revenue | |||||
| 510 | Opportun ity newOpp ortunity = new Oppor tunity | |||||
| 511 | { | |||||
| 512 | Name = "Exampl e Opportun ity", | |||||
| 513 | Cust omerId = n ew EntityR eference(A ccount.Ent ityLogical Name, | |||||
| 514 | _accountId s[0]), | |||||
| 515 | Pric eLevelId = new Entit yReference (PriceLeve l.EntityLo gicalName, | |||||
| 516 | _priceList Id), | |||||
| 517 | IsRe venueSyste mCalculate d = false, | |||||
| 518 | Esti matedValue = new Mon ey(400.00m ), | |||||
| 519 | Frei ghtAmount = new Mone y(10.00m), | |||||
| 520 | Disc ountAmount = new Mon ey(0.10m), | |||||
| 521 | Disc ountPercen tage = 0.2 0m, | |||||
| 522 | Actu alValue = new Money( 400.00m), | |||||
| 523 | Owne rId = new EntityRefe rence | |||||
| 524 | { | |||||
| 525 | Id = _sale sRepresent ativeIds[0 ], | |||||
| 526 | LogicalNam e = System User.Entit yLogicalNa me | |||||
| 527 | } | |||||
| 528 | }; | |||||
| 529 | _opportu nityIds.Ad d(_service Proxy.Crea te(newOppo rtunity)); | |||||
| 530 | ||||||
| 531 | Opportun ity second Opportunit y = new Op portunity | |||||
| 532 | { | |||||
| 533 | Name = "Exampl e Opportun ity 2", | |||||
| 534 | Cust omerId = n ew EntityR eference(A ccount.Ent ityLogical Name, | |||||
| 535 | _accountId s[1]), | |||||
| 536 | Pric eLevelId = new Entit yReference (PriceLeve l.EntityLo gicalName, | |||||
| 537 | _priceList Id), | |||||
| 538 | IsRe venueSyste mCalculate d = false, | |||||
| 539 | Esti matedValue = new Mon ey(400.00m ), | |||||
| 540 | Frei ghtAmount = new Mone y(10.00m), | |||||
| 541 | Disc ountAmount = new Mon ey(0.10m), | |||||
| 542 | Disc ountPercen tage = 0.2 0m, | |||||
| 543 | Actu alValue = new Money( 400.00m), | |||||
| 544 | Owne rId = new EntityRefe rence | |||||
| 545 | { | |||||
| 546 | Id = _sale sRepresent ativeIds[1 ], | |||||
| 547 | LogicalNam e = System User.Entit yLogicalNa me | |||||
| 548 | } | |||||
| 549 | }; | |||||
| 550 | _opportu nityIds.Ad d(_service Proxy.Crea te(secondO pportunity )); | |||||
| 551 | ||||||
| 552 | // Creat e a catalo g product | |||||
| 553 | Opportun ityProduct catalogPr oduct = ne w Opportun ityProduct | |||||
| 554 | { | |||||
| 555 | Oppo rtunityId = new Enti tyReferenc e(Opportun ity.Entity LogicalNam e, | |||||
| 556 | _opportuni tyIds[0]), | |||||
| 557 | Prod uctId = ne w EntityRe ference(Pr oduct.Enti tyLogicalN ame, | |||||
| 558 | _product1I d), | |||||
| 559 | UoMI d = new En tityRefere nce(UoM.En tityLogica lName, _de faultUnitI d), | |||||
| 560 | Quan tity = 8, | |||||
| 561 | Tax = new Mone y(12.42m), | |||||
| 562 | }; | |||||
| 563 | _catalog ProductId = _service Proxy.Crea te(catalog Product); | |||||
| 564 | ||||||
| 565 | // Creat e another catalog pr oduct and override t he list pr ice | |||||
| 566 | Opportun ityProduct catalogPr oductPrice Override = new Oppor tunityProd uct | |||||
| 567 | { | |||||
| 568 | Oppo rtunityId = new Enti tyReferenc e(Opportun ity.Entity LogicalNam e, | |||||
| 569 | _opportuni tyIds[1]), | |||||
| 570 | Prod uctId = ne w EntityRe ference(Pr oduct.Enti tyLogicalN ame, | |||||
| 571 | _product2I d), | |||||
| 572 | UoMI d = new En tityRefere nce(UoM.En tityLogica lName, _de faultUnitI d), | |||||
| 573 | Quan tity = 3, | |||||
| 574 | Tax = new Mone y(2.88m), | |||||
| 575 | IsPr iceOverrid den = true , | |||||
| 576 | Pric ePerUnit = new Money (12) | |||||
| 577 | }; | |||||
| 578 | _catalog ProductPri ceOverride Id = _serv iceProxy.C reate( | |||||
| 579 | cata logProduct PriceOverr ide); | |||||
| 580 | ||||||
| 581 | // creat e a new wr ite-in opp ortunity p roduct wit h a manual discount applied | |||||
| 582 | Opportun ityProduct writeInPr oduct = ne w Opportun ityProduct | |||||
| 583 | { | |||||
| 584 | Oppo rtunityId = new Enti tyReferenc e(Opportun ity.Entity LogicalNam e, | |||||
| 585 | _opportuni tyIds[1]), | |||||
| 586 | IsPr oductOverr idden = tr ue, | |||||
| 587 | Prod uctDescrip tion = "Ex ample Writ e-in Produ ct", | |||||
| 588 | Pric ePerUnit = new Money (20.00m), | |||||
| 589 | Quan tity = 5, | |||||
| 590 | Manu alDiscount Amount = n ew Money(1 0.50m), | |||||
| 591 | Tax = new Mone y(7.16m) | |||||
| 592 | }; | |||||
| 593 | _writeIn ProductId = _service Proxy.Crea te(writeIn Product); | |||||
| 594 | ||||||
| 595 | // Close the oppor tunities a s 'Won' | |||||
| 596 | WinOppor tunityRequ est winReq uest = new WinOpport unityReque st() | |||||
| 597 | { | |||||
| 598 | Oppo rtunityClo se = new O pportunity Close() | |||||
| 599 | { | |||||
| 600 | Opportunit yId = new EntityRefe rence | |||||
| 601 | { | |||||
| 602 | Id = _ opportunit yIds[0], | |||||
| 603 | Logica lName = Op portunity. EntityLogi calName | |||||
| 604 | }, | |||||
| 605 | ActualReve nue = new Money(400. 00M), | |||||
| 606 | ActualEnd = DateTime .Today | |||||
| 607 | }, | |||||
| 608 | Stat us = new O ptionSetVa lue(3) | |||||
| 609 | }; | |||||
| 610 | _service Proxy.Exec ute(winReq uest); | |||||
| 611 | ||||||
| 612 | winReque st = new W inOpportun ityRequest () | |||||
| 613 | { | |||||
| 614 | Oppo rtunityClo se = new O pportunity Close() | |||||
| 615 | { | |||||
| 616 | Opportunit yId = new EntityRefe rence | |||||
| 617 | { | |||||
| 618 | Id = _ opportunit yIds[1], | |||||
| 619 | Logica lName = Op portunity. EntityLogi calName | |||||
| 620 | }, | |||||
| 621 | ActualReve nue = new Money(400. 00M), | |||||
| 622 | ActualEnd = DateTime .Today | |||||
| 623 | }, | |||||
| 624 | Stat us = new O ptionSetVa lue(3) | |||||
| 625 | }; | |||||
| 626 | _service Proxy.Exec ute(winReq uest); | |||||
| 627 | ||||||
| 628 | #endregi on Create Opportunit y records | |||||
| 629 | } | |||||
| 630 | ||||||
| 631 | // / <summary > | |||||
| 632 | // / Deletes any entity records t hat were c reated for this samp le. | |||||
| 633 | // / <param n ame="promp t">Indicat es whether to prompt the user | |||||
| 634 | // / to delet e the reco rds create d in this sample.</p aram> | |||||
| 635 | // / </summar y> | |||||
| 636 | pu blic void DeleteRequ iredRecord s(bool pro mpt) | |||||
| 637 | { | |||||
| 638 | // The t hree syste m users th at were cr eated by t his sample will cont inue to | |||||
| 639 | // exist on your s ystem beca use system users can not be del eted in Mi crosoft | |||||
| 640 | // Dynam ics CRM. They can o nly be ena bled or di sabled. | |||||
| 641 | ||||||
| 642 | bool toB eDeleted = true; | |||||
| 643 | ||||||
| 644 | if (prom pt) | |||||
| 645 | { | |||||
| 646 | // A sk the use r if the c reated ent ities shou ld be dele ted. | |||||
| 647 | Cons ole.Write( "\nDo you want these entity re cords dele ted? (y/n) [y]: "); | |||||
| 648 | Stri ng answer = Console. ReadLine() ; | |||||
| 649 | if ( answer.Sta rtsWith("y ") || | |||||
| 650 | answer.Sta rtsWith("Y ") || | |||||
| 651 | answer == String.Emp ty) | |||||
| 652 | { | |||||
| 653 | toBeDelete d = true; | |||||
| 654 | } | |||||
| 655 | else | |||||
| 656 | { | |||||
| 657 | toBeDelete d = false; | |||||
| 658 | } | |||||
| 659 | } | |||||
| 660 | ||||||
| 661 | if (toBe Deleted) | |||||
| 662 | { | |||||
| 663 | // D elete all records cr eated in t his sample . | |||||
| 664 | _ser viceProxy. Delete("go al", _firs tChildGoal Id); | |||||
| 665 | _ser viceProxy. Delete("go al", _seco ndChildGoa lId); | |||||
| 666 | _ser viceProxy. Delete("go al", _pare ntGoalId); | |||||
| 667 | _ser viceProxy. Delete("go alrollupqu ery", _rol lupQueryId s[0]); | |||||
| 668 | _ser viceProxy. Delete("go alrollupqu ery", _rol lupQueryId s[1]); | |||||
| 669 | _ser viceProxy. Delete("op portunityp roduct", _ writeInPro ductId); | |||||
| 670 | _ser viceProxy. Delete("op portunityp roduct", _ catalogPro ductPriceO verrideId) ; | |||||
| 671 | _ser viceProxy. Delete("op portunityp roduct", _ catalogPro ductId); | |||||
| 672 | _ser viceProxy. Delete("op portunity" , _opportu nityIds[0] ); | |||||
| 673 | _ser viceProxy. Delete("op portunity" , _opportu nityIds[1] ); | |||||
| 674 | _ser viceProxy. Delete("ac count", _a ccountIds[ 0]); | |||||
| 675 | _ser viceProxy. Delete("ac count", _a ccountIds[ 1]); | |||||
| 676 | _ser viceProxy. Delete("pr oductprice level", _p riceListIt em1Id); | |||||
| 677 | _ser viceProxy. Delete("pr oductprice level", _p riceListIt em2Id); | |||||
| 678 | _ser viceProxy. Delete("pr icelevel", _priceLis tId); | |||||
| 679 | _ser viceProxy. Delete("pr oduct", _p roduct1Id) ; | |||||
| 680 | _ser viceProxy. Delete("pr oduct", _p roduct2Id) ; | |||||
| 681 | _ser viceProxy. Delete("di scount", _ discountId ); | |||||
| 682 | _ser viceProxy. Delete("di scounttype ", _discou ntTypeId); | |||||
| 683 | _ser viceProxy. Delete("uo mschedule" , _unitGro upId); | |||||
| 684 | _ser viceProxy. Delete("ro llupfield" , _inProgr essId); | |||||
| 685 | _ser viceProxy. Delete("ro llupfield" , _actualI d); | |||||
| 686 | _ser viceProxy. Delete("me tric", _me tricId); | |||||
| 687 | ||||||
| 688 | Cons ole.WriteL ine("Entit y record(s ) have bee n deleted. "); | |||||
| 689 | } | |||||
| 690 | } | |||||
| 691 | ||||||
| 692 | #e ndregion H ow To Samp le Code | |||||
| 693 | ||||||
| 694 | #r egion Main method | |||||
| 695 | ||||||
| 696 | // / <summary > | |||||
| 697 | // / Standard Main() me thod used by most SD K samples. | |||||
| 698 | // / </summar y> | |||||
| 699 | // / <param n ame="args" ></param> | |||||
| 700 | st atic publi c void Mai n(string[] args) | |||||
| 701 | { | |||||
| 702 | try | |||||
| 703 | { | |||||
| 704 | // O btain the target org anization' s Web addr ess and cl ient logon | |||||
| 705 | // c redentials from the user. | |||||
| 706 | Serv erConnecti on serverC onnect = n ew ServerC onnection( ); | |||||
| 707 | Serv erConnecti on.Configu ration con fig = serv erConnect. GetServerC onfigurati on(); | |||||
| 708 | ||||||
| 709 | Roll upAllGoals ForCustomP eriodAgain stTargetRe venue app = new Roll upAllGoals ForCustomP eriodAgain stTargetRe venue(); | |||||
| 710 | app. Run(config , true); | |||||
| 711 | } | |||||
| 712 | catch (F aultExcept ion<Micros oft.Xrm.Sd k.Organiza tionServic eFault> ex ) | |||||
| 713 | { | |||||
| 714 | Cons ole.WriteL ine("The a pplication terminate d with an error."); | |||||
| 715 | Cons ole.WriteL ine("Times tamp: {0}" , ex.Detai l.Timestam p); | |||||
| 716 | Cons ole.WriteL ine("Code: {0}", ex. Detail.Err orCode); | |||||
| 717 | Cons ole.WriteL ine("Messa ge: {0}", ex.Detail. Message); | |||||
| 718 | Cons ole.WriteL ine("Plugi n Trace: { 0}", ex.De tail.Trace Text); | |||||
| 719 | Cons ole.WriteL ine("Inner Fault: {0 }", | |||||
| 720 | null == ex .Detail.In nerFault ? "No Inner Fault" : "Has Inner Fault"); | |||||
| 721 | } | |||||
| 722 | catch (S ystem.Time outExcepti on ex) | |||||
| 723 | { | |||||
| 724 | Cons ole.WriteL ine("The a pplication terminate d with an error."); | |||||
| 725 | Cons ole.WriteL ine("Messa ge: {0}", ex.Message ); | |||||
| 726 | Cons ole.WriteL ine("Stack Trace: {0 }", ex.Sta ckTrace); | |||||
| 727 | Cons ole.WriteL ine("Inner Fault: {0 }", | |||||
| 728 | null == ex .InnerExce ption.Mess age ? "No Inner Faul t" : ex.In nerExcepti on.Message ); | |||||
| 729 | } | |||||
| 730 | catch (S ystem.Exce ption ex) | |||||
| 731 | { | |||||
| 732 | Cons ole.WriteL ine("The a pplication terminate d with an error."); | |||||
| 733 | Cons ole.WriteL ine(ex.Mes sage); | |||||
| 734 | ||||||
| 735 | // D isplay the details o f the inne r exceptio n. | |||||
| 736 | if ( ex.InnerEx ception != null) | |||||
| 737 | { | |||||
| 738 | Console.Wr iteLine(ex .InnerExce ption.Mess age); | |||||
| 739 | ||||||
| 740 | FaultExcep tion<Micro soft.Xrm.S dk.Organiz ationServi ceFault> f e = ex.Inn erExceptio n | |||||
| 741 | as Fau ltExceptio n<Microsof t.Xrm.Sdk. Organizati onServiceF ault>; | |||||
| 742 | if (fe != null) | |||||
| 743 | { | |||||
| 744 | Consol e.WriteLin e("Timesta mp: {0}", fe.Detail. Timestamp) ; | |||||
| 745 | Consol e.WriteLin e("Code: { 0}", fe.De tail.Error Code); | |||||
| 746 | Consol e.WriteLin e("Message : {0}", fe .Detail.Me ssage); | |||||
| 747 | Consol e.WriteLin e("Plugin Trace: {0} ", fe.Deta il.TraceTe xt); | |||||
| 748 | Consol e.WriteLin e("Inner F ault: {0}" , | |||||
| 749 | nu ll == fe.D etail.Inne rFault ? " No Inner F ault" : "H as Inner F ault"); | |||||
| 750 | } | |||||
| 751 | } | |||||
| 752 | } | |||||
| 753 | // Addit ional exce ptions to catch: Sec urityToken Validation Exception, ExpiredSe curityToke nException , | |||||
| 754 | // Secur ityAccessD eniedExcep tion, Mess ageSecurit yException , and Secu rityNegoti ationExcep tion. | |||||
| 755 | ||||||
| 756 | finally | |||||
| 757 | { | |||||
| 758 | Cons ole.WriteL ine("Press <Enter> t o exit."); | |||||
| 759 | Cons ole.ReadLi ne(); | |||||
| 760 | } | |||||
| 761 | } | |||||
| 762 | #e ndregion M ain method | |||||
| 763 | } | |||||
| 764 | } | |||||
| 765 | //</snippe tRollupAll GoalsForCu stomPeriod AgainstTar getRevenue > |
Araxis Merge (but not the data content of this report) is Copyright © 1993-2016 Araxis Ltd (www.araxis.com). All rights reserved.