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 | LinkCustomAttributesBetweenSeriesandInstances.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 | 264 |
| 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 LinkCustom Attributes BetweenSer iesandInst ances> | |||||
| 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.Query; | |||||
| 27 | using Micr osoft.Xrm. Sdk.Client ; | |||||
| 28 | using Micr osoft.Xrm. Sdk.Discov ery; | |||||
| 29 | using Micr osoft.Xrm. Sdk.Messag es; | |||||
| 30 | using Micr osoft.Xrm. Sdk.Metada ta; | |||||
| 31 | ||||||
| 32 | // This na mespace is found in Microsoft. Crm.Sdk.Pr oxy.dll as sembly | |||||
| 33 | // found i n the SDK\ bin folder . | |||||
| 34 | using Micr osoft.Crm. Sdk.Messag es; | |||||
| 35 | ||||||
| 36 | namespace Microsoft. Crm.Sdk.Sa mples | |||||
| 37 | { | |||||
| 38 | /// <s ummary> | |||||
| 39 | /// Th is sample shows how to custom attribute created fo r | |||||
| 40 | /// re curring ap pointment series wit h a custom attribute | |||||
| 41 | /// cr eated for the appoin tment inst ances. | |||||
| 42 | /// </ summary> | |||||
| 43 | public class Lin kCustomAtt ributesBet weenSeries andInstanc es | |||||
| 44 | { | |||||
| 45 | #r egion Clas s Level Me mbers | |||||
| 46 | ||||||
| 47 | // / <summary > | |||||
| 48 | // / Stores t he organiz ation serv ice proxy. | |||||
| 49 | // / </summar y> | |||||
| 50 | pr ivate Orga nizationSe rviceProxy _serviceP roxy; | |||||
| 51 | ||||||
| 52 | // Define th e IDs as w ell as str ings neede d for this sample. | |||||
| 53 | pu blic Guid _instanceA ttributeID ; | |||||
| 54 | pu blic Guid _seriesAtt ributeID; | |||||
| 55 | ||||||
| 56 | #e ndregion C lass Level Members | |||||
| 57 | ||||||
| 58 | #r egion How To Sample Code | |||||
| 59 | // / <summary > | |||||
| 60 | // / Create a nd configu re the org anization service pr oxy. | |||||
| 61 | // / Initiate the metho d to creat e any data that this sample re quires. | |||||
| 62 | // / Link the custom at tributes. | |||||
| 63 | // / Optional ly delete any entity records t hat were c reated for this samp le. | |||||
| 64 | // / </summar y> | |||||
| 65 | // / <param n ame="serve rConfig">C ontains se rver conne ction info rmation.</ param> | |||||
| 66 | // / <param n ame="promp tforDelete ">When Tru e, the use r will be prompted t o delete a ll | |||||
| 67 | // / created entities.< /param> | |||||
| 68 | pu blic void Run(Server Connection .Configura tion serve rConfig, b ool prompt ForDelete) | |||||
| 69 | { | |||||
| 70 | try | |||||
| 71 | { | |||||
| 72 | ||||||
| 73 | // C onnect to the Organi zation ser vice. | |||||
| 74 | // T he using s tatement a ssures tha t the serv ice proxy will be pr operly dis posed. | |||||
| 75 | 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 )) | |||||
| 76 | { | |||||
| 77 | // This st atement is required to enable early-boun d type sup port. | |||||
| 78 | _servicePr oxy.Enable ProxyTypes (); | |||||
| 79 | ||||||
| 80 | ||||||
| 81 | //<snippet LinkCustom Attributes BetweenSer iesandInst ances1> | |||||
| 82 | ||||||
| 83 | // Create a custom s tring attr ibute for the appoin tment inst ance | |||||
| 84 | StringAttr ibuteMetad ata custom Appointmen tInstanceA ttribute = new Strin gAttribute Metadata | |||||
| 85 | { | |||||
| 86 | Logica lName = "n ew_customA ppInstance Attribute" , | |||||
| 87 | Displa yName = ne w Label("C ustomAppIn stanceAttr ibute", 10 33), | |||||
| 88 | Descri ption = ne w Label("S ample Cust om Appoint ment Insta nce Attrib ute", 1033 ), | |||||
| 89 | MaxLen gth = 500, | |||||
| 90 | Requir edLevel = new Attrib uteRequire dLevelMana gedPropert y(Attribut eRequiredL evel.None) , | |||||
| 91 | Schema Name = "ne w_customAp pInstanceA ttribute" | |||||
| 92 | }; | |||||
| 93 | ||||||
| 94 | CreateAttr ibuteReque st instanc eAttribute Request = new Create AttributeR equest | |||||
| 95 | { | |||||
| 96 | Attrib ute = cust omAppointm entInstanc eAttribute , | |||||
| 97 | Entity Name = "ap pointment" | |||||
| 98 | }; | |||||
| 99 | ||||||
| 100 | CreateAttr ibuteRespo nse instan ceAttribut eResponse = (CreateA ttributeRe sponse)_se rviceProxy .Execute(i nstanceAtt ributeRequ est); | |||||
| 101 | _instanceA ttributeID = instanc eAttribute Response.A ttributeId ; | |||||
| 102 | ||||||
| 103 | // Create a custom s tring attr ibute for the recurr ing appoin tment mast er (series ) | |||||
| 104 | StringAttr ibuteMetad ata custom Appointmen tSeriesAtt ribute = n ew StringA ttributeMe tadata | |||||
| 105 | { | |||||
| 106 | Logica lName = "n ew_customA ppSeriesAt tribute", | |||||
| 107 | Displa yName = ne w Label("C ustomAppSe riesAttrib ute", 1033 ), | |||||
| 108 | Descri ption = ne w Label("S ample Cust om Appoint ment Serie s Attribut e", 1033), | |||||
| 109 | MaxLen gth = 500, | |||||
| 110 | Requir edLevel = new Attrib uteRequire dLevelMana gedPropert y(Attribut eRequiredL evel.None) , | |||||
| 111 | Schema Name = "ne w_customAp pSeriesAtt ribute", | |||||
| 112 | Linked AttributeI d = _insta nceAttribu teID // Li nk the cus tom attrib ute to the appointme nt’s custo m attribut e. | |||||
| 113 | }; | |||||
| 114 | ||||||
| 115 | CreateAttr ibuteReque st seriesA ttributeRe quest = ne w CreateAt tributeReq uest | |||||
| 116 | { | |||||
| 117 | Attrib ute = cust omAppointm entSeriesA ttribute, | |||||
| 118 | Entity Name = "re curringapp ointmentma ster" | |||||
| 119 | }; | |||||
| 120 | ||||||
| 121 | CreateAttr ibuteRespo nse series AttributeR esponse = (CreateAtt ributeResp onse)_serv iceProxy.E xecute(ser iesAttribu teRequest) ; | |||||
| 122 | _seriesAtt ributeID = seriesAtt ributeResp onse.Attri buteId; | |||||
| 123 | ||||||
| 124 | // Publish all the c hanges to the soluti on. | |||||
| 125 | PublishAll XmlRequest createReq uest = new PublishAl lXmlReques t(); | |||||
| 126 | _servicePr oxy.Execut e(createRe quest); | |||||
| 127 | ||||||
| 128 | Console.Wr iteLine("C reated a c ustom stri ng attribu te, {0}, f or the app ointment." , customAp pointmentI nstanceAtt ribute.Log icalName); | |||||
| 129 | Console.Wr iteLine("C reated a c ustom stri ng attribu te, {0}, f or the rec urring app ointment, and linked it with { 1}.", cust omAppointm entSeriesA ttribute.L ogicalName , customAp pointmentI nstanceAtt ribute.Log icalName); | |||||
| 130 | ||||||
| 131 | //</snippe tLinkCusto mAttribute sBetweenSe riesandIns tances1> | |||||
| 132 | ||||||
| 133 | DeleteRequ iredRecord s(promptFo rDelete); | |||||
| 134 | ||||||
| 135 | } | |||||
| 136 | } | |||||
| 137 | // Catch any servi ce fault e xceptions that Micro soft Dynam ics CRM th rows. | |||||
| 138 | catch (F aultExcept ion<Micros oft.Xrm.Sd k.Organiza tionServic eFault>) | |||||
| 139 | { | |||||
| 140 | // Y ou can han dle an exc eption her e or pass it back to the calli ng method. | |||||
| 141 | thro w; | |||||
| 142 | } | |||||
| 143 | } | |||||
| 144 | ||||||
| 145 | ||||||
| 146 | // / <summary > | |||||
| 147 | // / Deletes any entity records t hat were c reated for this samp le. | |||||
| 148 | // / <param n ame="promp t">Indicat es whether to prompt the user to delete | |||||
| 149 | // / the reco rds create d in this sample.</p aram> | |||||
| 150 | // / </summar y> | |||||
| 151 | pu blic void DeleteRequ iredRecord s(bool pro mpt) | |||||
| 152 | { | |||||
| 153 | bool del eteRecords = true; | |||||
| 154 | ||||||
| 155 | if (prom pt) | |||||
| 156 | { | |||||
| 157 | Cons ole.WriteL ine("\nDo you want t hese entit y records to be dele ted? (y/n) "); | |||||
| 158 | Stri ng answer = Console. ReadLine() ; | |||||
| 159 | ||||||
| 160 | dele teRecords = (answer. StartsWith ("y") || a nswer.Star tsWith("Y" )); | |||||
| 161 | } | |||||
| 162 | ||||||
| 163 | if (dele teRecords) | |||||
| 164 | { | |||||
| 165 | Dele teAttribut eRequest d elSeriesAt tribute = new Delete AttributeR equest | |||||
| 166 | { | |||||
| 167 | LogicalNam e = "new_c ustomappse riesattrib ute", | |||||
| 168 | EntityLogi calName = RecurringA ppointment Master.Ent ityLogical Name | |||||
| 169 | }; | |||||
| 170 | _ser viceProxy. Execute(de lSeriesAtt ribute); | |||||
| 171 | ||||||
| 172 | Dele teAttribut eRequest d elInstance Attribute = new Dele teAttribut eRequest | |||||
| 173 | { | |||||
| 174 | LogicalNam e = "new_c ustomappin stanceattr ibute", | |||||
| 175 | EntityLogi calName = Appointmen t.EntityLo gicalName | |||||
| 176 | }; | |||||
| 177 | _ser viceProxy. Execute(de lInstanceA ttribute); | |||||
| 178 | ||||||
| 179 | // P ublish all the chang es to the solution. | |||||
| 180 | Publ ishAllXmlR equest del Request = new Publis hAllXmlReq uest(); | |||||
| 181 | _ser viceProxy. Execute(de lRequest); | |||||
| 182 | ||||||
| 183 | Cons ole.WriteL ine("Entit y records have been deleted.") ; | |||||
| 184 | } | |||||
| 185 | } | |||||
| 186 | ||||||
| 187 | #e ndregion H ow To Samp le Code | |||||
| 188 | ||||||
| 189 | #r egion Main | |||||
| 190 | // / <summary > | |||||
| 191 | // / Standard Main() me thod used by most SD K samples. | |||||
| 192 | // / </summar y> | |||||
| 193 | // / <param n ame="args" ></param> | |||||
| 194 | st atic publi c void Mai n(string[] args) | |||||
| 195 | { | |||||
| 196 | try | |||||
| 197 | { | |||||
| 198 | // O btain the target org anization' s Web addr ess and cl ient logon | |||||
| 199 | // c redentials from the user. | |||||
| 200 | Serv erConnecti on serverC onnect = n ew ServerC onnection( ); | |||||
| 201 | Serv erConnecti on.Configu ration con fig = serv erConnect. GetServerC onfigurati on(); | |||||
| 202 | ||||||
| 203 | Link CustomAttr ibutesBetw eenSeriesa ndInstance s app = ne w LinkCust omAttribut esBetweenS eriesandIn stances(); | |||||
| 204 | app. Run(config , true); | |||||
| 205 | } | |||||
| 206 | ||||||
| 207 | catch (F aultExcept ion<Micros oft.Xrm.Sd k.Organiza tionServic eFault> ex ) | |||||
| 208 | { | |||||
| 209 | Cons ole.WriteL ine("The a pplication terminate d with an error."); | |||||
| 210 | Cons ole.WriteL ine("Times tamp: {0}" , ex.Detai l.Timestam p); | |||||
| 211 | Cons ole.WriteL ine("Code: {0}", ex. Detail.Err orCode); | |||||
| 212 | Cons ole.WriteL ine("Messa ge: {0}", ex.Detail. Message); | |||||
| 213 | Cons ole.WriteL ine("Plugi n Trace: { 0}", ex.De tail.Trace Text); | |||||
| 214 | Cons ole.WriteL ine("Inner Fault: {0 }", | |||||
| 215 | null == ex .Detail.In nerFault ? "No Inner Fault" : "Has Inner Fault"); | |||||
| 216 | } | |||||
| 217 | catch (S ystem.Time outExcepti on ex) | |||||
| 218 | { | |||||
| 219 | Cons ole.WriteL ine("The a pplication terminate d with an error."); | |||||
| 220 | Cons ole.WriteL ine("Messa ge: {0}", ex.Message ); | |||||
| 221 | Cons ole.WriteL ine("Stack Trace: {0 }", ex.Sta ckTrace); | |||||
| 222 | Cons ole.WriteL ine("Inner Fault: {0 }", | |||||
| 223 | null == ex .InnerExce ption.Mess age ? "No Inner Faul t" : ex.In nerExcepti on.Message ); | |||||
| 224 | } | |||||
| 225 | catch (S ystem.Exce ption ex) | |||||
| 226 | { | |||||
| 227 | Cons ole.WriteL ine("The a pplication terminate d with an error."); | |||||
| 228 | Cons ole.WriteL ine(ex.Mes sage); | |||||
| 229 | ||||||
| 230 | // D isplay the details o f the inne r exceptio n. | |||||
| 231 | if ( ex.InnerEx ception != null) | |||||
| 232 | { | |||||
| 233 | Console.Wr iteLine(ex .InnerExce ption.Mess age); | |||||
| 234 | ||||||
| 235 | FaultExcep tion<Micro soft.Xrm.S dk.Organiz ationServi ceFault> f e | |||||
| 236 | = ex.I nnerExcept ion | |||||
| 237 | as Fau ltExceptio n<Microsof t.Xrm.Sdk. Organizati onServiceF ault>; | |||||
| 238 | if (fe != null) | |||||
| 239 | { | |||||
| 240 | Consol e.WriteLin e("Timesta mp: {0}", fe.Detail. Timestamp) ; | |||||
| 241 | Consol e.WriteLin e("Code: { 0}", fe.De tail.Error Code); | |||||
| 242 | Consol e.WriteLin e("Message : {0}", fe .Detail.Me ssage); | |||||
| 243 | Consol e.WriteLin e("Plugin Trace: {0} ", fe.Deta il.TraceTe xt); | |||||
| 244 | Consol e.WriteLin e("Inner F ault: {0}" , | |||||
| 245 | nu ll == fe.D etail.Inne rFault ? " No Inner F ault" : "H as Inner F ault"); | |||||
| 246 | } | |||||
| 247 | } | |||||
| 248 | } | |||||
| 249 | // Addit ional exce ptions to catch: Sec urityToken Validation Exception, ExpiredSe curityToke nException , | |||||
| 250 | // Secur ityAccessD eniedExcep tion, Mess ageSecurit yException , and Secu rityNegoti ationExcep tion. | |||||
| 251 | ||||||
| 252 | ||||||
| 253 | finally | |||||
| 254 | { | |||||
| 255 | ||||||
| 256 | Cons ole.WriteL ine("Press <Enter> t o exit."); | |||||
| 257 | Cons ole.ReadLi ne(); | |||||
| 258 | } | |||||
| 259 | ||||||
| 260 | } | |||||
| 261 | #e ndregion M ain | |||||
| 262 | } | |||||
| 263 | } | |||||
| 264 | //</snippe tLinkCusto mAttribute sBetweenSe riesandIns tances> |
Araxis Merge (but not the data content of this report) is Copyright © 1993-2016 Araxis Ltd (www.araxis.com). All rights reserved.