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 | EndRecurringAppointmentSeries.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 | 278 |
| 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 EndRecurri ngAppointm entSeries> | |||||
| 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 end a r ecurring a ppointment series. | |||||
| 39 | /// </ summary> | |||||
| 40 | public class End RecurringA ppointment Series | |||||
| 41 | { | |||||
| 42 | #r egion Clas s Level Me mbers | |||||
| 43 | ||||||
| 44 | // / <summary > | |||||
| 45 | // / Stores t he organiz ation serv ice proxy. | |||||
| 46 | // / </summar y> | |||||
| 47 | Or ganization ServicePro xy _servic eProxy; | |||||
| 48 | ||||||
| 49 | // Define th e IDs as w ell as str ings neede d for this sample. | |||||
| 50 | pu blic Guid _recurring Appointmen tMasterId; | |||||
| 51 | ||||||
| 52 | #e ndregion C lass Level Members | |||||
| 53 | ||||||
| 54 | #r egion How To Sample Code | |||||
| 55 | // / <summary > | |||||
| 56 | // / Create a nd configu re the org anization service pr oxy. | |||||
| 57 | // / Initiate the metho d to creat e any data that this sample re quires. | |||||
| 58 | // / End the recurring appointmen t series. | |||||
| 59 | // / Optional ly delete any entity records t hat were c reated for this samp le. | |||||
| 60 | // / </summar y> | |||||
| 61 | // / <param n ame="serve rConfig">C ontains se rver conne ction info rmation.</ param> | |||||
| 62 | // / <param n ame="promp tforDelete ">When Tru e, the use r will be prompted t o delete a ll | |||||
| 63 | // / created entities.< /param> | |||||
| 64 | pu blic void Run(Server Connection .Configura tion serve rConfig, b ool prompt ForDelete) | |||||
| 65 | { | |||||
| 66 | try | |||||
| 67 | { | |||||
| 68 | // C onnect to the Organi zation ser vice. | |||||
| 69 | // T he using s tatement a ssures tha t the serv ice proxy will be pr operly dis posed. | |||||
| 70 | 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 )) | |||||
| 71 | { | |||||
| 72 | // This st atement is required to enable early-boun d type sup port. | |||||
| 73 | _servicePr oxy.Enable ProxyTypes (); | |||||
| 74 | ||||||
| 75 | ||||||
| 76 | // Call th e method t o create a ny data th at this sa mple requi res. | |||||
| 77 | CreateRequ iredRecord s(); | |||||
| 78 | ||||||
| 79 | //<snippet EndRecurri ngAppointm entSeries1 > | |||||
| 80 | ||||||
| 81 | // Retriev e a recurr ing appoin tment seri es | |||||
| 82 | RecurringA ppointment Master ret rievedRecu rringAppoi ntmentSeri es = (Recu rringAppoi ntmentMast er)_servic eProxy.Ret rieve(Recu rringAppoi ntmentMast er.EntityL ogicalName , _recurri ngAppointm entMasterI d, new Col umnSet(tru e)); | |||||
| 83 | ||||||
| 84 | // Use the DeleteOpe nInstances message t o end the series to the | |||||
| 85 | // last oc curring pa st instanc e date w.r .t. the se ries end d ate | |||||
| 86 | // (i.e., 20 days fr om today). Effective ly, that m eans that the | |||||
| 87 | // series will end a fter the t hird insta nce (day 1 4) as this | |||||
| 88 | // instanc e is the l ast occuri ng past in stance w.r .t the spe cified | |||||
| 89 | // series end date ( 20 days fr om today). | |||||
| 90 | // Also sp ecify that the state of past i nstances ( w.r.t. the series | |||||
| 91 | // end dat e) be set to 'comple ted'. | |||||
| 92 | DeleteOpen InstancesR equest end Appointmen tSeries = new Delete OpenInstan cesRequest | |||||
| 93 | { | |||||
| 94 | Target = retriev edRecurrin gAppointme ntSeries, | |||||
| 95 | Series EndDate = DateTime.T oday.AddDa ys(20), | |||||
| 96 | StateO fPastInsta nces = (in t)Appointm entState.C ompleted | |||||
| 97 | }; | |||||
| 98 | _servicePr oxy.Execut e(endAppoi ntmentSeri es); | |||||
| 99 | ||||||
| 100 | Console.Wr iteLine("T he recurri ng appoint ment serie s has been ended aft er the thi rd occurre nce."); | |||||
| 101 | ||||||
| 102 | //</snippe tEndRecurr ingAppoint mentSeries 1> | |||||
| 103 | ||||||
| 104 | DeleteRequ iredRecord s(promptFo rDelete); | |||||
| 105 | ||||||
| 106 | } | |||||
| 107 | } | |||||
| 108 | // Catch any servi ce fault e xceptions that Micro soft Dynam ics CRM th rows. | |||||
| 109 | catch (F aultExcept ion<Micros oft.Xrm.Sd k.Organiza tionServic eFault>) | |||||
| 110 | { | |||||
| 111 | // Y ou can han dle an exc eption her e or pass it back to the calli ng method. | |||||
| 112 | thro w; | |||||
| 113 | } | |||||
| 114 | } | |||||
| 115 | ||||||
| 116 | // / <summary > | |||||
| 117 | // / This met hod create s any enti ty records that this sample re quires. | |||||
| 118 | // / Create a new recur ring appoi ntment. | |||||
| 119 | // / </summar y> | |||||
| 120 | pu blic void CreateRequ iredRecord s() | |||||
| 121 | { | |||||
| 122 | // Defin e an anony mous type to define the possib le recurre nce patter n values. | |||||
| 123 | var Recu rrencePatt ernTypes = new | |||||
| 124 | { | |||||
| 125 | Dail y = 0, | |||||
| 126 | Week ly = 1, | |||||
| 127 | Mont hly = 2, | |||||
| 128 | Year ly = 3 | |||||
| 129 | }; | |||||
| 130 | ||||||
| 131 | // Defin e an anony mous type to define the possib le values for days | |||||
| 132 | // of th e week | |||||
| 133 | var DayO fWeek = ne w | |||||
| 134 | { | |||||
| 135 | Sund ay = 0x01, | |||||
| 136 | Mond ay = 0x02, | |||||
| 137 | Tues day = 0x04 , | |||||
| 138 | Wedn esday = 0x 08, | |||||
| 139 | Thur sday = 0x1 0, | |||||
| 140 | Frid ay = 0x20, | |||||
| 141 | Satu rday = 0x4 0 | |||||
| 142 | }; | |||||
| 143 | ||||||
| 144 | // Defin e an anony mous type to define the possib le values | |||||
| 145 | // for t he recurre nce rule p attern end type. | |||||
| 146 | var Recu rrenceRule PatternEnd Type = new | |||||
| 147 | { | |||||
| 148 | NoEn dDate = 1, | |||||
| 149 | Occu rrences = 2, | |||||
| 150 | Patt ernEndDate = 3, | |||||
| 151 | }; | |||||
| 152 | ||||||
| 153 | // Creat e a new re curring ap pointment | |||||
| 154 | Recurrin gAppointme ntMaster n ewRecurrin gAppointme nt = | |||||
| 155 | new RecurringA ppointment Master | |||||
| 156 | { | |||||
| 157 | Subject = "Sample Re curring Ap pointment" , | |||||
| 158 | StartTime = DateTime .Now.AddHo urs(1), | |||||
| 159 | EndTime = DateTime.N ow.AddHour s(2), | |||||
| 160 | Recurrence PatternTyp e = new Op tionSetVal ue( | |||||
| 161 | Recurr encePatter nTypes.Wee kly), | |||||
| 162 | Interval = 1, | |||||
| 163 | DaysOfWeek Mask = Day OfWeek.Thu rsday, | |||||
| 164 | PatternSta rtDate = D ateTime.To day, | |||||
| 165 | Occurrence s = 5, | |||||
| 166 | PatternEnd Type = new OptionSet Value( | |||||
| 167 | Recurr enceRulePa tternEndTy pe.Occurre nces) | |||||
| 168 | ||||||
| 169 | }; | |||||
| 170 | ||||||
| 171 | _recurri ngAppointm entMasterI d = _servi ceProxy.Cr eate(newRe curringApp ointment); | |||||
| 172 | Console. WriteLine( "Created { 0} with {1 } occurren ces.", new RecurringA ppointment .Subject, newRecurri ngAppointm ent.Occurr ences); | |||||
| 173 | ||||||
| 174 | return; | |||||
| 175 | } | |||||
| 176 | ||||||
| 177 | // / <summary > | |||||
| 178 | // / Deletes any entity records t hat were c reated for this samp le. | |||||
| 179 | // / <param n ame="promp t">Indicat es whether to prompt the user to delete | |||||
| 180 | // / the reco rds create d in this sample.</p aram> | |||||
| 181 | // / </summar y> | |||||
| 182 | pu blic void DeleteRequ iredRecord s(bool pro mpt) | |||||
| 183 | { | |||||
| 184 | bool del eteRecords = true; | |||||
| 185 | ||||||
| 186 | if (prom pt) | |||||
| 187 | { | |||||
| 188 | Cons ole.WriteL ine("\nDo you want t hese entit y records to be dele ted? (y/n) "); | |||||
| 189 | Stri ng answer = Console. ReadLine() ; | |||||
| 190 | ||||||
| 191 | dele teRecords = (answer. StartsWith ("y") || a nswer.Star tsWith("Y" )); | |||||
| 192 | } | |||||
| 193 | ||||||
| 194 | if (dele teRecords) | |||||
| 195 | { | |||||
| 196 | _ser viceProxy. Delete(Rec urringAppo intmentMas ter.Entity LogicalNam e, | |||||
| 197 | _recurring Appointmen tMasterId) ; | |||||
| 198 | ||||||
| 199 | Cons ole.WriteL ine("Entit y records have been deleted.") ; | |||||
| 200 | } | |||||
| 201 | } | |||||
| 202 | ||||||
| 203 | #e ndregion H ow To Samp le Code | |||||
| 204 | ||||||
| 205 | #r egion Main | |||||
| 206 | // / <summary > | |||||
| 207 | // / Standard Main() me thod used by most SD K samples. | |||||
| 208 | // / </summar y> | |||||
| 209 | // / <param n ame="args" ></param> | |||||
| 210 | st atic publi c void Mai n(string[] args) | |||||
| 211 | { | |||||
| 212 | try | |||||
| 213 | { | |||||
| 214 | // O btain the target org anization' s Web addr ess and cl ient logon | |||||
| 215 | // c redentials from the user. | |||||
| 216 | Serv erConnecti on serverC onnect = n ew ServerC onnection( ); | |||||
| 217 | Serv erConnecti on.Configu ration con fig = serv erConnect. GetServerC onfigurati on(); | |||||
| 218 | ||||||
| 219 | EndR ecurringAp pointmentS eries app = new EndR ecurringAp pointmentS eries(); | |||||
| 220 | app. Run(config , true); | |||||
| 221 | } | |||||
| 222 | ||||||
| 223 | catch (F aultExcept ion<Micros oft.Xrm.Sd k.Organiza tionServic eFault> ex ) | |||||
| 224 | { | |||||
| 225 | Cons ole.WriteL ine("The a pplication terminate d with an error."); | |||||
| 226 | Cons ole.WriteL ine("Times tamp: {0}" , ex.Detai l.Timestam p); | |||||
| 227 | Cons ole.WriteL ine("Code: {0}", ex. Detail.Err orCode); | |||||
| 228 | Cons ole.WriteL ine("Messa ge: {0}", ex.Detail. Message); | |||||
| 229 | Cons ole.WriteL ine("Plugi n Trace: { 0}", ex.De tail.Trace Text); | |||||
| 230 | Cons ole.WriteL ine("Inner Fault: {0 }", | |||||
| 231 | null == ex .Detail.In nerFault ? "No Inner Fault" : "Has Inner Fault"); | |||||
| 232 | } | |||||
| 233 | catch (S ystem.Time outExcepti on ex) | |||||
| 234 | { | |||||
| 235 | Cons ole.WriteL ine("The a pplication terminate d with an error."); | |||||
| 236 | Cons ole.WriteL ine("Messa ge: {0}", ex.Message ); | |||||
| 237 | Cons ole.WriteL ine("Stack Trace: {0 }", ex.Sta ckTrace); | |||||
| 238 | Cons ole.WriteL ine("Inner Fault: {0 }", | |||||
| 239 | null == ex .InnerExce ption.Mess age ? "No Inner Faul t" : ex.In nerExcepti on.Message ); | |||||
| 240 | } | |||||
| 241 | catch (S ystem.Exce ption ex) | |||||
| 242 | { | |||||
| 243 | Cons ole.WriteL ine("The a pplication terminate d with an error."); | |||||
| 244 | Cons ole.WriteL ine(ex.Mes sage); | |||||
| 245 | ||||||
| 246 | // D isplay the details o f the inne r exceptio n. | |||||
| 247 | if ( ex.InnerEx ception != null) | |||||
| 248 | { | |||||
| 249 | Console.Wr iteLine(ex .InnerExce ption.Mess age); | |||||
| 250 | ||||||
| 251 | FaultExcep tion<Micro soft.Xrm.S dk.Organiz ationServi ceFault> f e | |||||
| 252 | = ex.I nnerExcept ion | |||||
| 253 | as Fau ltExceptio n<Microsof t.Xrm.Sdk. Organizati onServiceF ault>; | |||||
| 254 | if (fe != null) | |||||
| 255 | { | |||||
| 256 | Consol e.WriteLin e("Timesta mp: {0}", fe.Detail. Timestamp) ; | |||||
| 257 | Consol e.WriteLin e("Code: { 0}", fe.De tail.Error Code); | |||||
| 258 | Consol e.WriteLin e("Message : {0}", fe .Detail.Me ssage); | |||||
| 259 | Consol e.WriteLin e("Plugin Trace: {0} ", fe.Deta il.TraceTe xt); | |||||
| 260 | Consol e.WriteLin e("Inner F ault: {0}" , | |||||
| 261 | nu ll == fe.D etail.Inne rFault ? " No Inner F ault" : "H as Inner F ault"); | |||||
| 262 | } | |||||
| 263 | } | |||||
| 264 | } | |||||
| 265 | // Addit ional exce ptions to catch: Sec urityToken Validation Exception, ExpiredSe curityToke nException , | |||||
| 266 | // Secur ityAccessD eniedExcep tion, Mess ageSecurit yException , and Secu rityNegoti ationExcep tion. | |||||
| 267 | ||||||
| 268 | finally | |||||
| 269 | { | |||||
| 270 | Cons ole.WriteL ine("Press <Enter> t o exit."); | |||||
| 271 | Cons ole.ReadLi ne(); | |||||
| 272 | } | |||||
| 273 | ||||||
| 274 | } | |||||
| 275 | #e ndregion M ain | |||||
| 276 | } | |||||
| 277 | } | |||||
| 278 | //</snippe tEndRecurr ingAppoint mentSeries > |
Araxis Merge (but not the data content of this report) is Copyright © 1993-2016 Araxis Ltd (www.araxis.com). All rights reserved.