Produced by Araxis Merge on 2/1/2017 2:56:23 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 | CreateReciprocalConnectionRole.cs | Tue Dec 20 19:51:44 2016 UTC |
| 2 | Wed Feb 1 19:56:23 2017 UTC |
| Description | Between Files 1 and 2 |
|
|---|---|---|
| Text Blocks | Lines | |
| Unchanged | 0 | 0 |
| Changed | 0 | 0 |
| Inserted | 0 | 0 |
| Removed | 1 | 298 |
| 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 the se 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 CreateReci procalConn ectionRole > | |||||
| 18 | using Syst em; | |||||
| 19 | using Syst em.Service Model; | |||||
| 20 | using Syst em.Service Model.Desc ription; | |||||
| 21 | ||||||
| 22 | // These n amespaces are found in the Mic rosoft.Xrm .Sdk.dll a ssembly | |||||
| 23 | // found i n the SDK\ bin folder . | |||||
| 24 | using Micr osoft.Xrm. Sdk; | |||||
| 25 | using Micr osoft.Xrm. Sdk.Client ; | |||||
| 26 | using Micr osoft.Xrm. Sdk.Query; | |||||
| 27 | using Micr osoft.Xrm. Sdk.Discov ery; | |||||
| 28 | using Micr osoft.Xrm. Sdk.Messag es; | |||||
| 29 | ||||||
| 30 | // This na mespace is found in Microsoft. Crm.Sdk.Pr oxy.dll as sembly | |||||
| 31 | // found i n the SDK\ bin folder . | |||||
| 32 | using Micr osoft.Crm. Sdk.Messag es; | |||||
| 33 | ||||||
| 34 | namespace Microsoft. Crm.Sdk.Sa mples | |||||
| 35 | { | |||||
| 36 | /// <s ummary> | |||||
| 37 | /// Th is Sample shows how to create a reciproc al connect ion role. | |||||
| 38 | /// </ summary> | |||||
| 39 | public class Cre ateRecipro calConnect ionRole | |||||
| 40 | { | |||||
| 41 | #r egion Clas s Level Me mbers | |||||
| 42 | ||||||
| 43 | // / <summary > | |||||
| 44 | // / Stores t he organiz ation serv ice proxy. | |||||
| 45 | // / </summar y> | |||||
| 46 | Or ganization ServicePro xy _servic eProxy; | |||||
| 47 | ||||||
| 48 | // Define th e IDs need ed for thi s sample. | |||||
| 49 | pu blic Guid _connectio nRole1Id; | |||||
| 50 | pu blic Guid _connectio nRole2Id; | |||||
| 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 | // / Create t he connect ion role i nstances. | |||||
| 58 | // / Associat e the conn ection rol es. | |||||
| 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 | // Create the Connec tion Role 1 | |||||
| 76 | Connection Role newCo nnectionRo le1 = new Connection Role | |||||
| 77 | { | |||||
| 78 | Name = "Example Connection Role 1", | |||||
| 79 | Catego ry = new O ptionSetVa lue((int)c onnectionr ole_catego ry.Busines s), | |||||
| 80 | }; | |||||
| 81 | ||||||
| 82 | _connectio nRole1Id = _serviceP roxy.Creat e(newConne ctionRole1 ); | |||||
| 83 | Console.Wr iteLine("C reated {0} .", newCon nectionRol e1.Name); | |||||
| 84 | ||||||
| 85 | // Create a related Connection Role Obje ct Type Co de record for Accoun t | |||||
| 86 | Connection RoleObject TypeCode n ewAccountC onnectionR ole1TypeCo de | |||||
| 87 | = new Connection RoleObject TypeCode | |||||
| 88 | { | |||||
| 89 | Co nnectionRo leId = new EntityRef erence( | |||||
| 90 | Connecti onRole.Ent ityLogical Name, _con nectionRol e1Id), | |||||
| 91 | As sociatedOb jectTypeCo de = Accou nt.EntityL ogicalName | |||||
| 92 | }; | |||||
| 93 | ||||||
| 94 | _servicePr oxy.Create (newAccoun tConnectio nRole1Type Code); | |||||
| 95 | Console.Wr iteLine( | |||||
| 96 | "Creat ed a relat ed Connect ion Role 1 Object Ty pe Code re cord for A ccount." | |||||
| 97 | ); | |||||
| 98 | ||||||
| 99 | // Create a related Connection Role Obje ct Type Co de record for Contac t | |||||
| 100 | Connection RoleObject TypeCode n ewContactC onnectionR ole1TypeCo de | |||||
| 101 | = new Connection RoleObject TypeCode | |||||
| 102 | { | |||||
| 103 | Co nnectionRo leId = new EntityRef erence( | |||||
| 104 | Connecti onRole.Ent ityLogical Name, _con nectionRol e1Id), | |||||
| 105 | As sociatedOb jectTypeCo de = Conta ct.EntityL ogicalName | |||||
| 106 | }; | |||||
| 107 | ||||||
| 108 | _servicePr oxy.Create (newContac tConnectio nRole1Type Code); | |||||
| 109 | Console.Wr iteLine( | |||||
| 110 | "Creat ed a relat ed Connect ion Role 1 Object Ty pe Code re cord for C ontact." | |||||
| 111 | ); | |||||
| 112 | ||||||
| 113 | // Create the Connec tion Role 2 | |||||
| 114 | Connection Role newCo nnectionRo le2 = new Connection Role | |||||
| 115 | { | |||||
| 116 | Name = "Example Connection Role 2", | |||||
| 117 | Catego ry = new O ptionSetVa lue((int)c onnectionr ole_catego ry.Busines s), | |||||
| 118 | }; | |||||
| 119 | ||||||
| 120 | _connectio nRole2Id = _serviceP roxy.Creat e(newConne ctionRole2 ); | |||||
| 121 | Console.Wr iteLine("C reated {0} .", newCon nectionRol e2.Name); | |||||
| 122 | ||||||
| 123 | // Create a related Connection Role 2 Ob ject Type Code recor d for Acco unt | |||||
| 124 | Connection RoleObject TypeCode n ewAccountC onnectionR ole2TypeCo de | |||||
| 125 | = new Connection RoleObject TypeCode | |||||
| 126 | { | |||||
| 127 | Co nnectionRo leId = new EntityRef erence( | |||||
| 128 | Connecti onRole.Ent ityLogical Name, _con nectionRol e2Id), | |||||
| 129 | As sociatedOb jectTypeCo de = Accou nt.EntityL ogicalName | |||||
| 130 | }; | |||||
| 131 | ||||||
| 132 | _servicePr oxy.Create (newAccoun tConnectio nRole2Type Code); | |||||
| 133 | Console.Wr iteLine( | |||||
| 134 | "Creat ed a relat ed Connect ion Role 2 Object Ty pe Code re cord for A ccount." | |||||
| 135 | ); | |||||
| 136 | ||||||
| 137 | // Create a related Connection Role 2 Ob ject Type Code recor d for Cont act | |||||
| 138 | Connection RoleObject TypeCode n ewContactC onnectionR ole2TypeCo de | |||||
| 139 | = new Connection RoleObject TypeCode | |||||
| 140 | { | |||||
| 141 | Co nnectionRo leId = new EntityRef erence( | |||||
| 142 | Connecti onRole.Ent ityLogical Name, _con nectionRol e2Id), | |||||
| 143 | As sociatedOb jectTypeCo de = Conta ct.EntityL ogicalName | |||||
| 144 | }; | |||||
| 145 | ||||||
| 146 | _servicePr oxy.Create (newContac tConnectio nRole2Type Code); | |||||
| 147 | Console.Wr iteLine( | |||||
| 148 | "Creat ed a relat ed Connect ion Role 2 Object Ty pe Code re cord for C ontact." | |||||
| 149 | ); | |||||
| 150 | //<snippet AssociateR eciprocalC onnectionR oles> | |||||
| 151 | // Associa te the con nection ro les | |||||
| 152 | Associate Request as sociateCon nectionRol es = new A ssociateRe quest | |||||
| 153 | { | |||||
| 154 | Target = new Ent ityReferen ce(Connect ionRole.En tityLogica lName, | |||||
| 155 | _c onnectionR ole1Id), | |||||
| 156 | Relate dEntities = new Enti tyReferenc eCollectio n() | |||||
| 157 | { | |||||
| 158 | ne w EntityRe ference(Co nnectionRo le.EntityL ogicalName , | |||||
| 159 | _connect ionRole2Id ) | |||||
| 160 | }, | |||||
| 161 | // The name of t he relatio nship conn ection rol e associat ion | |||||
| 162 | // rel ationship in MS CRM | |||||
| 163 | Relati onship = n ew Relatio nship() | |||||
| 164 | { | |||||
| 165 | Pr imaryEntit yRole = En tityRole.R eferencing , // Refer encing or Referenced based on N:1 or 1:N reflexive relations hip. | |||||
| 166 | Sc hemaName = "connecti onroleasso ciation_as sociation" | |||||
| 167 | } | |||||
| 168 | }; | |||||
| 169 | ||||||
| 170 | _servicePr oxy.Execut e(associat eConnectio nRoles); | |||||
| 171 | Console.Wr iteLine("A ssociated the connec tion roles ."); | |||||
| 172 | //</snippe tAssociate Reciprocal Connection Roles> | |||||
| 173 | ||||||
| 174 | DeleteRequ iredRecord s(promptFo rDelete); | |||||
| 175 | ||||||
| 176 | } | |||||
| 177 | } | |||||
| 178 | // Catch any servi ce fault e xceptions that Micro soft Dynam ics CRM th rows. | |||||
| 179 | catch (F aultExcept ion<Micros oft.Xrm.Sd k.Organiza tionServic eFault>) | |||||
| 180 | { | |||||
| 181 | // Y ou can han dle an exc eption her e or pass it back to the calli ng method. | |||||
| 182 | thro w; | |||||
| 183 | } | |||||
| 184 | } | |||||
| 185 | ||||||
| 186 | // / <summary > | |||||
| 187 | // / Deletes any entity records t hat were c reated for this samp le. | |||||
| 188 | // / <param n ame="promp t">Indicat es whether to prompt the user | |||||
| 189 | // / to delet e the reco rds create d in this sample.</p aram> | |||||
| 190 | // / </summar y> | |||||
| 191 | p ublic void DeleteReq uiredRecor ds(bool pr ompt) | |||||
| 192 | { | |||||
| 193 | bool toB eDeleted = true; | |||||
| 194 | ||||||
| 195 | if (prom pt) | |||||
| 196 | { | |||||
| 197 | // A sk the use r if the c reated ent ities shou ld be dele ted. | |||||
| 198 | Cons ole.Write( "\nDo you want these entity re cords dele ted? (y/n) [y]: "); | |||||
| 199 | Stri ng answer = Console. ReadLine() ; | |||||
| 200 | if ( answer.Sta rtsWith("y ") || | |||||
| 201 | answer.Sta rtsWith("Y ") || | |||||
| 202 | answer == String.Emp ty) | |||||
| 203 | { | |||||
| 204 | toBeDelete d = true; | |||||
| 205 | } | |||||
| 206 | else | |||||
| 207 | { | |||||
| 208 | toBeDelete d = false; | |||||
| 209 | } | |||||
| 210 | } | |||||
| 211 | ||||||
| 212 | if (toBe Deleted) | |||||
| 213 | { | |||||
| 214 | _ser viceProxy. Delete(Con nectionRol e.EntityLo gicalName, _connecti onRole1Id) ; | |||||
| 215 | _ser viceProxy. Delete(Con nectionRol e.EntityLo gicalName, _connecti onRole2Id) ; | |||||
| 216 | ||||||
| 217 | Cons ole.WriteL ine("Entit y records have been deleted.") ; | |||||
| 218 | } | |||||
| 219 | } | |||||
| 220 | ||||||
| 221 | #e ndregion H ow To Samp le Code | |||||
| 222 | ||||||
| 223 | #r egion Main | |||||
| 224 | // / <summary > | |||||
| 225 | // / Standard Main() me thod used by most SD K samples. | |||||
| 226 | // / </summar y> | |||||
| 227 | // / <param n ame="args" ></param> | |||||
| 228 | st atic publi c void Mai n(string[] args) | |||||
| 229 | { | |||||
| 230 | try | |||||
| 231 | { | |||||
| 232 | // O btain the target org anization' s Web addr ess and cl ient logon | |||||
| 233 | // c redentials from the user. | |||||
| 234 | Serv erConnecti on serverC onnect = n ew ServerC onnection( ); | |||||
| 235 | Serv erConnecti on.Configu ration con fig = serv erConnect. GetServerC onfigurati on(); | |||||
| 236 | ||||||
| 237 | Crea teReciproc alConnecti onRole app = new Cre ateRecipro calConnect ionRole(); | |||||
| 238 | app. Run(config , true); | |||||
| 239 | } | |||||
| 240 | ||||||
| 241 | catch (F aultExcept ion<Micros oft.Xrm.Sd k.Organiza tionServic eFault> ex ) | |||||
| 242 | { | |||||
| 243 | Cons ole.WriteL ine("The a pplication terminate d with an error."); | |||||
| 244 | Cons ole.WriteL ine("Times tamp: {0}" , ex.Detai l.Timestam p); | |||||
| 245 | Cons ole.WriteL ine("Code: {0}", ex. Detail.Err orCode); | |||||
| 246 | Cons ole.WriteL ine("Messa ge: {0}", ex.Detail. Message); | |||||
| 247 | Cons ole.WriteL ine("Plugi n Trace: { 0}", ex.De tail.Trace Text); | |||||
| 248 | Cons ole.WriteL ine("Inner Fault: {0 }", | |||||
| 249 | null == ex .Detail.In nerFault ? "No Inner Fault" : "Has Inner Fault"); | |||||
| 250 | } | |||||
| 251 | catch (S ystem.Time outExcepti on ex) | |||||
| 252 | { | |||||
| 253 | Cons ole.WriteL ine("The a pplication terminate d with an error."); | |||||
| 254 | Cons ole.WriteL ine("Messa ge: {0}", ex.Message ); | |||||
| 255 | Cons ole.WriteL ine("Stack Trace: {0 }", ex.Sta ckTrace); | |||||
| 256 | Cons ole.WriteL ine("Inner Fault: {0 }", | |||||
| 257 | null == ex .InnerExce ption.Mess age ? "No Inner Faul t" : ex.In nerExcepti on.Message ); | |||||
| 258 | } | |||||
| 259 | catch (S ystem.Exce ption ex) | |||||
| 260 | { | |||||
| 261 | Cons ole.WriteL ine("The a pplication terminate d with an error."); | |||||
| 262 | Cons ole.WriteL ine(ex.Mes sage); | |||||
| 263 | ||||||
| 264 | // D isplay the details o f the inne r exceptio n. | |||||
| 265 | if ( ex.InnerEx ception != null) | |||||
| 266 | { | |||||
| 267 | Console.Wr iteLine(ex .InnerExce ption.Mess age); | |||||
| 268 | ||||||
| 269 | FaultExcep tion<Micro soft.Xrm.S dk.Organiz ationServi ceFault> f e | |||||
| 270 | = ex.I nnerExcept ion | |||||
| 271 | as Fau ltExceptio n<Microsof t.Xrm.Sdk. Organizati onServiceF ault>; | |||||
| 272 | if (fe != null) | |||||
| 273 | { | |||||
| 274 | Consol e.WriteLin e("Timesta mp: {0}", fe.Detail. Timestamp) ; | |||||
| 275 | Consol e.WriteLin e("Code: { 0}", fe.De tail.Error Code); | |||||
| 276 | Consol e.WriteLin e("Message : {0}", fe .Detail.Me ssage); | |||||
| 277 | Consol e.WriteLin e("Plugin Trace: {0} ", fe.Deta il.TraceTe xt); | |||||
| 278 | Consol e.WriteLin e("Inner F ault: {0}" , | |||||
| 279 | nu ll == fe.D etail.Inne rFault ? " No Inner F ault" : "H as Inner F ault"); | |||||
| 280 | } | |||||
| 281 | } | |||||
| 282 | } | |||||
| 283 | // Addit ional exce ptions to catch: Sec urityToken Validation Exception, ExpiredSe curityToke nException , | |||||
| 284 | // Secur ityAccessD eniedExcep tion, Mess ageSecurit yException , and Secu rityNegoti ationExcep tion. | |||||
| 285 | ||||||
| 286 | ||||||
| 287 | ||||||
| 288 | finally | |||||
| 289 | { | |||||
| 290 | Cons ole.WriteL ine("Press <Enter> t o exit."); | |||||
| 291 | Cons ole.ReadLi ne(); | |||||
| 292 | } | |||||
| 293 | ||||||
| 294 | } | |||||
| 295 | #e ndregion M ain | |||||
| 296 | } | |||||
| 297 | } | |||||
| 298 | //</snippe tCreateRec iprocalCon nectionRol e> |
Araxis Merge (but not the data content of this report) is Copyright © 1993-2016 Araxis Ltd (www.araxis.com). All rights reserved.