Produced by Araxis Merge on 2/1/2017 2:56:27 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\ScheduleAndAppointment | ConvertAnAppointmenttoRecurringAppointment.cs | Tue Dec 20 19:51:43 2016 UTC |
| 2 | Wed Feb 1 19:56:27 2017 UTC |
| Description | Between Files 1 and 2 |
|
|---|---|---|
| Text Blocks | Lines | |
| Unchanged | 0 | 0 |
| Changed | 0 | 0 |
| Inserted | 0 | 0 |
| Removed | 1 | 295 |
| 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 thes e 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 | //<snippet ConvertAnA ppointment toRecurrin gAppointme nt> | |||||
| 18 | using Syst em; | |||||
| 19 | using Syst em.Linq; | |||||
| 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 | using Micr osoft.Xrm. Sdk.Messag es; | |||||
| 30 | ||||||
| 31 | // This na mespace is found in Microsoft. Crm.Sdk.Pr oxy.dll as sembly | |||||
| 32 | // found i n the SDK\ bin folder . | |||||
| 33 | using Micr osoft.Crm. Sdk.Messag es; | |||||
| 34 | ||||||
| 35 | namespace Microsoft. Crm.Sdk.Sa mples | |||||
| 36 | { | |||||
| 37 | /// <s ummary> | |||||
| 38 | /// Th is sample shows how to convert an appoin tment to a | |||||
| 39 | /// re curring ap pointment. | |||||
| 40 | /// </ summary> | |||||
| 41 | public class Con vertAnAppo intmenttoR ecurringAp pointment | |||||
| 42 | { | |||||
| 43 | #r egion Clas s Level Me mbers | |||||
| 44 | ||||||
| 45 | // / <summary > | |||||
| 46 | // / Stores t he organiz ation serv ice proxy. | |||||
| 47 | // / </summar y> | |||||
| 48 | pr ivate Orga nizationSe rviceProxy _serviceP roxy; | |||||
| 49 | ||||||
| 50 | // Define th e IDs as w ell as str ings neede d for this sample. | |||||
| 51 | pu blic Guid _appointme ntId; | |||||
| 52 | pu blic Guid __recurrin gAppointme ntMasterId ; | |||||
| 53 | ||||||
| 54 | #e ndregion C lass Level Members | |||||
| 55 | ||||||
| 56 | #r egion How To Sample Code | |||||
| 57 | // / <summary > | |||||
| 58 | // / Create a nd configu re the org anization service pr oxy. | |||||
| 59 | // / Initiate the metho d to creat e any data that this sample re quires. | |||||
| 60 | // / Convert an appoint ment to a recurring appointmen t. | |||||
| 61 | // / Optional ly delete any entity records t hat were c reated for this samp le. | |||||
| 62 | // / </summar y> | |||||
| 63 | // / <param n ame="serve rConfig">C ontains se rver conne ction info rmation.</ param> | |||||
| 64 | // / <param n ame="promp tforDelete ">When Tru e, the use r will be prompted t o delete a ll | |||||
| 65 | // / created entities.< /param> | |||||
| 66 | pu blic void Run(Server Connection .Configura tion serve rConfig, b ool prompt ForDelete) | |||||
| 67 | { | |||||
| 68 | try | |||||
| 69 | { | |||||
| 70 | ||||||
| 71 | // C onnect to the Organi zation ser vice. | |||||
| 72 | // T he using s tatement a ssures tha t the serv ice proxy will be pr operly dis posed. | |||||
| 73 | usin g (_servic eProxy = n ew Organiz ationServi ceProxy(se rverConfig .Organizat ionUri, se rverConfig .HomeRealm Uri, | |||||
| 74 | s erverConfi g.Credenti als, serve rConfig.De viceCreden tials)) | |||||
| 75 | { | |||||
| 76 | // This st atement is required to enable early-boun d type sup port. | |||||
| 77 | _servicePr oxy.Enable ProxyTypes (); | |||||
| 78 | ||||||
| 79 | ||||||
| 80 | // Call th e method t o create a ny data th at this sa mple requi res. | |||||
| 81 | CreateRequ iredRecord s(); | |||||
| 82 | ||||||
| 83 | //<snippet ConvertAnA ppointment toRecurrin gAppointme nt1> | |||||
| 84 | ||||||
| 85 | // Specify the recur rence info rmation th at needs t o be added to the | |||||
| 86 | // existin g appointm ent. | |||||
| 87 | // 1. Def ine an ano nymous typ e to defin e the poss ible recur rence patt ern values . | |||||
| 88 | var Recurr encePatter nTypes = n ew | |||||
| 89 | { | |||||
| 90 | Daily = 0, | |||||
| 91 | Weekly = 1, | |||||
| 92 | Monthl y = 2, | |||||
| 93 | Yearly = 3 | |||||
| 94 | }; | |||||
| 95 | ||||||
| 96 | // 2. Def ine an ano nymous typ e to defin e the poss ible value s for days | |||||
| 97 | // of the week | |||||
| 98 | var DayOfW eek = new | |||||
| 99 | { | |||||
| 100 | Sunday = 0x01, | |||||
| 101 | Monday = 0x02, | |||||
| 102 | Tuesda y = 0x04, | |||||
| 103 | Wednes day = 0x08 , | |||||
| 104 | Thursd ay = 0x10, | |||||
| 105 | Friday = 0x20, | |||||
| 106 | Saturd ay = 0x40 | |||||
| 107 | }; | |||||
| 108 | ||||||
| 109 | // 3. Def ine an ano nymous typ e to defin e the poss ible value s | |||||
| 110 | // for the recurrenc e rule pat tern end t ype. | |||||
| 111 | var Recurr enceRulePa tternEndTy pe = new | |||||
| 112 | { | |||||
| 113 | NoEndD ate = 1, | |||||
| 114 | Occurr ences = 2, | |||||
| 115 | Patter nEndDate = 3 | |||||
| 116 | }; | |||||
| 117 | ||||||
| 118 | // 4. Fin ally, use a recurrin g appointm ent master object to specify | |||||
| 119 | // the recurrenc e informat ion. Other appointme nt details such as | |||||
| 120 | // 'su bject' and 'location ' are copi ed from th e existing appointme nt | |||||
| 121 | // to the recurr ing appoin tment mast er object. | |||||
| 122 | ||||||
| 123 | RecurringA ppointment Master new RecurringA ppointment Info = new Recurring Appointmen tMaster | |||||
| 124 | { | |||||
| 125 | St artTime = DateTime.N ow.AddHour s(2), | |||||
| 126 | En dTime = Da teTime.Now .AddHours( 3), | |||||
| 127 | Re currencePa tternType = new Opti onSetValue (Recurrenc ePatternTy pes.Weekly ), | |||||
| 128 | In terval = 1 , | |||||
| 129 | Da ysOfWeekMa sk = DayOf Week.Thurs day, | |||||
| 130 | Pa tternStart Date = Dat eTime.Toda y, | |||||
| 131 | Pa tternEndTy pe = new O ptionSetVa lue(Recurr enceRulePa tternEndTy pe.Occurre nces), | |||||
| 132 | Oc currences = 5 | |||||
| 133 | }; | |||||
| 134 | ||||||
| 135 | ||||||
| 136 | // Use the AddRecurr ence messa ge to conv ert the ex isting app ointment | |||||
| 137 | // object to a recur ring appoi ntment mas ter object . The exis ting | |||||
| 138 | // appoint ment objec t is delet ed thereaf ter. | |||||
| 139 | ||||||
| 140 | AddRecurre nceRequest recurring InfoReques t = new Ad dRecurrenc eRequest | |||||
| 141 | { | |||||
| 142 | Target = newRecu rringAppoi ntmentInfo , | |||||
| 143 | Appoin tmentId = _appointme ntId | |||||
| 144 | }; | |||||
| 145 | ||||||
| 146 | AddRecurre nceRespons e recurrin gInfoRespo nse = (Add Recurrence Response)_ servicePro xy.Execute (recurring InfoReques t); | |||||
| 147 | __recurrin gAppointme ntMasterId = recurri ngInfoResp onse.id; | |||||
| 148 | ||||||
| 149 | // Verify that the n ewly creat ed recurri ng appoint ment maste r has same 'subject' | |||||
| 150 | // as the existing a ppointment . | |||||
| 151 | ||||||
| 152 | RecurringA ppointment Master ret rievedMast erAppointm ent = (Rec urringAppo intmentMas ter)_servi ceProxy.Re trieve(Rec urringAppo intmentMas ter.Entity LogicalNam e, __recur ringAppoin tmentMaste rId, new C olumnSet(t rue)); | |||||
| 153 | if (retrie vedMasterA ppointment .Subject = = "Sample Appointmen t") | |||||
| 154 | { | |||||
| 155 | Consol e.WriteLin e("Sample Appointmen t is conve rted to a recurring appointmen t."); | |||||
| 156 | } | |||||
| 157 | ||||||
| 158 | //</snippe tConvertAn Appointmen ttoRecurri ngAppointm ent1> | |||||
| 159 | ||||||
| 160 | DeleteRequ iredRecord s(promptFo rDelete); | |||||
| 161 | ||||||
| 162 | } | |||||
| 163 | } | |||||
| 164 | // Catch any servi ce fault e xceptions that Micro soft Dynam ics CRM th rows. | |||||
| 165 | catch (F aultExcept ion<Micros oft.Xrm.Sd k.Organiza tionServic eFault>) | |||||
| 166 | { | |||||
| 167 | // Y ou can han dle an exc eption her e or pass it back to the calli ng method. | |||||
| 168 | thro w; | |||||
| 169 | } | |||||
| 170 | } | |||||
| 171 | ||||||
| 172 | // / <summary > | |||||
| 173 | // / This met hod create s any enti ty records that this sample re quires. | |||||
| 174 | // / Create a new recur ring appoi ntment. | |||||
| 175 | // / </summar y> | |||||
| 176 | pu blic void CreateRequ iredRecord s() | |||||
| 177 | { | |||||
| 178 | // Creat e an appoi ntment | |||||
| 179 | Appointm ent newApp ointment = new Appoi ntment | |||||
| 180 | { | |||||
| 181 | Subject = "Sample Ap pointment" , | |||||
| 182 | Location = "Office", | |||||
| 183 | ScheduledS tart = Dat eTime.Now. AddHours(1 ), | |||||
| 184 | ScheduledE nd = DateT ime.Now.Ad dHours(2), | |||||
| 185 | }; | |||||
| 186 | ||||||
| 187 | _appoint mentId = _ servicePro xy.Create( newAppoint ment); | |||||
| 188 | Console. WriteLine( "Created { 0}", newAp pointment. Subject); | |||||
| 189 | ||||||
| 190 | return; | |||||
| 191 | } | |||||
| 192 | ||||||
| 193 | // / <summary > | |||||
| 194 | // / Deletes any entity records t hat were c reated for this samp le. | |||||
| 195 | // / <param n ame="promp t">Indicat es whether to prompt the user to delete | |||||
| 196 | // / the reco rds create d in this sample.</p aram> | |||||
| 197 | // / </summar y> | |||||
| 198 | pu blic void DeleteRequ iredRecord s(bool pro mpt) | |||||
| 199 | { | |||||
| 200 | bool del eteRecords = true; | |||||
| 201 | ||||||
| 202 | if (prom pt) | |||||
| 203 | { | |||||
| 204 | Cons ole.WriteL ine("\nDo you want t hese entit y records to be dele ted? (y/n) "); | |||||
| 205 | Stri ng answer = Console. ReadLine() ; | |||||
| 206 | ||||||
| 207 | dele teRecords = (answer. StartsWith ("y") || a nswer.Star tsWith("Y" )); | |||||
| 208 | } | |||||
| 209 | ||||||
| 210 | if (dele teRecords) | |||||
| 211 | { | |||||
| 212 | _ser viceProxy. Delete(Rec urringAppo intmentMas ter.Entity LogicalNam e, | |||||
| 213 | __recurrin gAppointme ntMasterId ); | |||||
| 214 | ||||||
| 215 | Cons ole.WriteL ine("Entit y records have been deleted.") ; | |||||
| 216 | } | |||||
| 217 | } | |||||
| 218 | ||||||
| 219 | #e ndregion H ow To Samp le Code | |||||
| 220 | ||||||
| 221 | #r egion Main | |||||
| 222 | // / <summary > | |||||
| 223 | // / Standard Main() me thod used by most SD K samples. | |||||
| 224 | // / </summar y> | |||||
| 225 | // / <param n ame="args" ></param> | |||||
| 226 | st atic publi c void Mai n(string[] args) | |||||
| 227 | { | |||||
| 228 | try | |||||
| 229 | { | |||||
| 230 | // O btain the target org anization' s Web addr ess and cl ient logon | |||||
| 231 | // c redentials from the user. | |||||
| 232 | Serv erConnecti on serverC onnect = n ew ServerC onnection( ); | |||||
| 233 | Serv erConnecti on.Configu ration con fig = serv erConnect. GetServerC onfigurati on(); | |||||
| 234 | ||||||
| 235 | Conv ertAnAppoi ntmenttoRe curringApp ointment a pp = new C onvertAnAp pointmentt oRecurring Appointmen t(); | |||||
| 236 | app. Run(config , true); | |||||
| 237 | } | |||||
| 238 | ||||||
| 239 | catch (F aultExcept ion<Micros oft.Xrm.Sd k.Organiza tionServic eFault> ex ) | |||||
| 240 | { | |||||
| 241 | Cons ole.WriteL ine("The a pplication terminate d with an error."); | |||||
| 242 | Cons ole.WriteL ine("Times tamp: {0}" , ex.Detai l.Timestam p); | |||||
| 243 | Cons ole.WriteL ine("Code: {0}", ex. Detail.Err orCode); | |||||
| 244 | Cons ole.WriteL ine("Messa ge: {0}", ex.Detail. Message); | |||||
| 245 | Cons ole.WriteL ine("Plugi n Trace: { 0}", ex.De tail.Trace Text); | |||||
| 246 | Cons ole.WriteL ine("Inner Fault: {0 }", | |||||
| 247 | null == ex .Detail.In nerFault ? "No Inner Fault" : "Has Inner Fault"); | |||||
| 248 | } | |||||
| 249 | catch (S ystem.Time outExcepti on ex) | |||||
| 250 | { | |||||
| 251 | Cons ole.WriteL ine("The a pplication terminate d with an error."); | |||||
| 252 | Cons ole.WriteL ine("Messa ge: {0}", ex.Message ); | |||||
| 253 | Cons ole.WriteL ine("Stack Trace: {0 }", ex.Sta ckTrace); | |||||
| 254 | Cons ole.WriteL ine("Inner Fault: {0 }", | |||||
| 255 | null == ex .InnerExce ption.Mess age ? "No Inner Faul t" : ex.In nerExcepti on.Message ); | |||||
| 256 | } | |||||
| 257 | catch (S ystem.Exce ption ex) | |||||
| 258 | { | |||||
| 259 | Cons ole.WriteL ine("The a pplication terminate d with an error."); | |||||
| 260 | Cons ole.WriteL ine(ex.Mes sage); | |||||
| 261 | ||||||
| 262 | // D isplay the details o f the inne r exceptio n. | |||||
| 263 | if ( ex.InnerEx ception != null) | |||||
| 264 | { | |||||
| 265 | Console.Wr iteLine(ex .InnerExce ption.Mess age); | |||||
| 266 | ||||||
| 267 | FaultExcep tion<Micro soft.Xrm.S dk.Organiz ationServi ceFault> f e | |||||
| 268 | = ex.I nnerExcept ion | |||||
| 269 | as Fau ltExceptio n<Microsof t.Xrm.Sdk. Organizati onServiceF ault>; | |||||
| 270 | if (fe != null) | |||||
| 271 | { | |||||
| 272 | Consol e.WriteLin e("Timesta mp: {0}", fe.Detail. Timestamp) ; | |||||
| 273 | Consol e.WriteLin e("Code: { 0}", fe.De tail.Error Code); | |||||
| 274 | Consol e.WriteLin e("Message : {0}", fe .Detail.Me ssage); | |||||
| 275 | Consol e.WriteLin e("Plugin Trace: {0} ", fe.Deta il.TraceTe xt); | |||||
| 276 | Consol e.WriteLin e("Inner F ault: {0}" , | |||||
| 277 | nu ll == fe.D etail.Inne rFault ? " No Inner F ault" : "H as Inner F ault"); | |||||
| 278 | } | |||||
| 279 | } | |||||
| 280 | } | |||||
| 281 | // Addit ional exce ptions to catch: Sec urityToken Validation Exception, ExpiredSe curityToke nException , | |||||
| 282 | // Secur ityAccessD eniedExcep tion, Mess ageSecurit yException , and Secu rityNegoti ationExcep tion. | |||||
| 283 | ||||||
| 284 | finally | |||||
| 285 | { | |||||
| 286 | ||||||
| 287 | Cons ole.WriteL ine("Press <Enter> t o exit."); | |||||
| 288 | Cons ole.ReadLi ne(); | |||||
| 289 | } | |||||
| 290 | ||||||
| 291 | } | |||||
| 292 | #e ndregion M ain | |||||
| 293 | } | |||||
| 294 | } | |||||
| 295 | //</snippe tConvertAn Appointmen ttoRecurri ngAppointm ent> |
Araxis Merge (but not the data content of this report) is Copyright © 1993-2016 Araxis Ltd (www.araxis.com). All rights reserved.