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 | CreateConnectionRole.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 | 239 |
| 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 | // | |||||
| 4 | // This f ile is par t of the M icrosoft D ynamics CR M SDK code samples. | |||||
| 5 | // | |||||
| 6 | // Copyri ght (C) Mi crosoft Co rporation. All righ ts reserve d. | |||||
| 7 | // | |||||
| 8 | // This s ource code is intend ed only as a supplem ent to Mic rosoft | |||||
| 9 | // Develo pment Tool s and/or o n-line doc umentation . See the se other | |||||
| 10 | // materi als for de tailed inf ormation r egarding M icrosoft c ode sample s. | |||||
| 11 | // | |||||
| 12 | // THIS C ODE AND IN FORMATION ARE PROVID ED "AS IS" WITHOUT W ARRANTY OF ANY | |||||
| 13 | // KIND, EITHER EXP RESSED OR IMPLIED, I NCLUDING B UT NOT LIM ITED TO TH E | |||||
| 14 | // IMPLIE D WARRANTI ES OF MERC HANTABILIT Y AND/OR F ITNESS FOR A | |||||
| 15 | // PARTIC ULAR PURPO SE. | |||||
| 16 | // | |||||
| 17 | // ======= ========== ========== ========== ========== ========== ========== == | |||||
| 18 | //<snippet CreateConn ectionRole > | |||||
| 19 | using Syst em; | |||||
| 20 | using Syst em.Service Model; | |||||
| 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 set the connectio n role obj ect type. | |||||
| 38 | /// </ summary> | |||||
| 39 | public class Cre ateConnect 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 | pr ivate Orga nizationSe rviceProxy _service Proxy; | |||||
| 47 | ||||||
| 48 | // Define th e IDs need ed for thi s sample. | |||||
| 49 | pu blic Guid _connectio nRoleId; | |||||
| 50 | ||||||
| 51 | #e ndregion C lass Level Members | |||||
| 52 | ||||||
| 53 | #r egion How To Sample Code | |||||
| 54 | // / <summary > | |||||
| 55 | // / Create a nd configu re the org anization service pr oxy. | |||||
| 56 | // / Create a new conne ctionrole instance a nd set the object ty pe. | |||||
| 57 | // / Optional ly delete any entity records t hat were c reated for this samp le. | |||||
| 58 | // / </summar y> | |||||
| 59 | // / <param n ame="serve rConfig">C ontains se rver conne ction info rmation.</ param> | |||||
| 60 | // / <param n ame="promp tforDelete ">When Tru e, the use r will be prompted t o delete a ll | |||||
| 61 | // / created entities.< /param> | |||||
| 62 | ||||||
| 63 | pu blic void Run(Server Connection .Configura tion serve rConfig, b ool prompt ForDelete) | |||||
| 64 | { | |||||
| 65 | try | |||||
| 66 | { | |||||
| 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, | |||||
| 71 | s erverConfi g.Credenti als, serve rConfig.De viceCreden tials)) | |||||
| 72 | { | |||||
| 73 | // This st atement is required to enable early-boun d type sup port. | |||||
| 74 | _servicePr oxy.Enable ProxyTypes (); | |||||
| 75 | ||||||
| 76 | ||||||
| 77 | //<snippet CreateConn ectionRole 1> | |||||
| 78 | // Define some anony mous types to define the range | |||||
| 79 | // of poss ible conne ction prop erty value s. | |||||
| 80 | var Catego ries = new | |||||
| 81 | { | |||||
| 82 | Busine ss = 1, | |||||
| 83 | Family = 2, | |||||
| 84 | Social = 3, | |||||
| 85 | Sales = 4, | |||||
| 86 | Other = 5 | |||||
| 87 | }; | |||||
| 88 | ||||||
| 89 | // Create a Connecti on Role fo r account and contac t | |||||
| 90 | Connection Role newCo nnectionRo le = new C onnectionR ole | |||||
| 91 | { | |||||
| 92 | Name = "Example Connection Role", | |||||
| 93 | Catego ry = new O ptionSetVa lue(Catego ries.Busin ess) | |||||
| 94 | }; | |||||
| 95 | ||||||
| 96 | _connectio nRoleId = _servicePr oxy.Create (newConnec tionRole); | |||||
| 97 | Console.Wr iteLine("C reated {0} .", newCon nectionRol e.Name); | |||||
| 98 | ||||||
| 99 | // Create a related Connection Role Obje ct Type Co de record for Accoun t | |||||
| 100 | Connection RoleObject TypeCode n ewAccountC onnectionR oleTypeCod e | |||||
| 101 | = new Connection RoleObject TypeCode | |||||
| 102 | { | |||||
| 103 | Co nnectionRo leId = new EntityRef erence( | |||||
| 104 | Connecti onRole.Ent ityLogical Name, _con nectionRol eId), | |||||
| 105 | As sociatedOb jectTypeCo de = Accou nt.EntityL ogicalName | |||||
| 106 | }; | |||||
| 107 | ||||||
| 108 | _servicePr oxy.Create (newAccoun tConnectio nRoleTypeC ode); | |||||
| 109 | Console.Wr iteLine( | |||||
| 110 | "Creat ed a relat ed Connect ion Role O bject Type Code reco rd for Acc ount."); | |||||
| 111 | ||||||
| 112 | // Create a related Connection Role Obje ct Type Co de record for Contac t | |||||
| 113 | Connection RoleObject TypeCode n ewContactC onnectionR oleTypeCod e | |||||
| 114 | = new Connection RoleObject TypeCode | |||||
| 115 | { | |||||
| 116 | Co nnectionRo leId = new EntityRef erence( | |||||
| 117 | Connecti onRole.Ent ityLogical Name, _con nectionRol eId), | |||||
| 118 | As sociatedOb jectTypeCo de = Conta ct.EntityL ogicalName | |||||
| 119 | }; | |||||
| 120 | ||||||
| 121 | _servicePr oxy.Create (newContac tConnectio nRoleTypeC ode); | |||||
| 122 | Console.Wr iteLine( | |||||
| 123 | "Creat ed a relat ed Connect ion Role O bject Type Code reco rd for Con tact."); | |||||
| 124 | //</snippe tCreateCon nectionRol e1> | |||||
| 125 | ||||||
| 126 | DeleteRequ iredRecord s(promptFo rDelete); | |||||
| 127 | ||||||
| 128 | } | |||||
| 129 | } | |||||
| 130 | // Catch any servi ce fault e xceptions that Micro soft Dynam ics CRM th rows. | |||||
| 131 | catch (F aultExcept ion<Micros oft.Xrm.Sd k.Organiza tionServic eFault>) | |||||
| 132 | { | |||||
| 133 | // Y ou can han dle an exc eption her e or pass it back to the calli ng method. | |||||
| 134 | thro w; | |||||
| 135 | } | |||||
| 136 | } | |||||
| 137 | ||||||
| 138 | // / <summary > | |||||
| 139 | // / Deletes any entity records t hat were c reated for this samp le. | |||||
| 140 | // / <param n ame="promp t">Indicat es whether to prompt the user | |||||
| 141 | // / to delet e the reco rds create d in this sample.</p aram> | |||||
| 142 | // / </summar y> | |||||
| 143 | pu blic void DeleteRequ iredRecord s(bool pro mpt) | |||||
| 144 | { | |||||
| 145 | bool del eteRecords = true; | |||||
| 146 | ||||||
| 147 | if (prom pt) | |||||
| 148 | { | |||||
| 149 | Cons ole.WriteL ine("\nDo you want t hese entit y records deleted? ( y/n)"); | |||||
| 150 | Stri ng answer = Console. ReadLine() ; | |||||
| 151 | ||||||
| 152 | dele teRecords = (answer. StartsWith ("y") || a nswer.Star tsWith("Y" )); | |||||
| 153 | } | |||||
| 154 | ||||||
| 155 | if (dele teRecords) | |||||
| 156 | { | |||||
| 157 | _ser viceProxy. Delete(Con nectionRol e.EntityLo gicalName, _connecti onRoleId); | |||||
| 158 | ||||||
| 159 | Cons ole.WriteL ine("Entit y records have been deleted.") ; | |||||
| 160 | } | |||||
| 161 | } | |||||
| 162 | ||||||
| 163 | #e ndregion H ow To Samp le Code | |||||
| 164 | ||||||
| 165 | #r egion Main | |||||
| 166 | // / <summary > | |||||
| 167 | // / Standard Main() me thod used by most SD K samples. | |||||
| 168 | // / </summar y> | |||||
| 169 | // / <param n ame="args" ></param> | |||||
| 170 | st atic publi c void Mai n(string[] args) | |||||
| 171 | { | |||||
| 172 | try | |||||
| 173 | { | |||||
| 174 | // O btain the target org anization' s Web addr ess and cl ient logon | |||||
| 175 | // c redentials from the user. | |||||
| 176 | Serv erConnecti on serverC onnect = n ew ServerC onnection( ); | |||||
| 177 | Serv erConnecti on.Configu ration con fig = serv erConnect. GetServerC onfigurati on(); | |||||
| 178 | ||||||
| 179 | Crea teConnecti onRole app = new Cre ateConnect ionRole(); | |||||
| 180 | app. Run(config , true); | |||||
| 181 | ||||||
| 182 | } | |||||
| 183 | catch (F aultExcept ion<Micros oft.Xrm.Sd k.Organiza tionServic eFault> ex ) | |||||
| 184 | { | |||||
| 185 | Cons ole.WriteL ine("The a pplication terminate d with an error."); | |||||
| 186 | Cons ole.WriteL ine("Times tamp: {0}" , ex.Detai l.Timestam p); | |||||
| 187 | Cons ole.WriteL ine("Code: {0}", ex. Detail.Err orCode); | |||||
| 188 | Cons ole.WriteL ine("Messa ge: {0}", ex.Detail. Message); | |||||
| 189 | Cons ole.WriteL ine("Plugi n Trace: { 0}", ex.De tail.Trace Text); | |||||
| 190 | Cons ole.WriteL ine("Inner Fault: {0 }", | |||||
| 191 | null == ex .Detail.In nerFault ? "No Inner Fault" : "Has Inner Fault"); | |||||
| 192 | } | |||||
| 193 | catch (S ystem.Time outExcepti on ex) | |||||
| 194 | { | |||||
| 195 | Cons ole.WriteL ine("The a pplication terminate d with an error."); | |||||
| 196 | Cons ole.WriteL ine("Messa ge: {0}", ex.Message ); | |||||
| 197 | Cons ole.WriteL ine("Stack Trace: {0 }", ex.Sta ckTrace); | |||||
| 198 | Cons ole.WriteL ine("Inner Fault: {0 }", | |||||
| 199 | null == ex .InnerExce ption.Mess age ? "No Inner Faul t" : ex.In nerExcepti on.Message ); | |||||
| 200 | } | |||||
| 201 | catch (S ystem.Exce ption ex) | |||||
| 202 | { | |||||
| 203 | Cons ole.WriteL ine("The a pplication terminate d with an error."); | |||||
| 204 | Cons ole.WriteL ine(ex.Mes sage); | |||||
| 205 | ||||||
| 206 | // D isplay the details o f the inne r exceptio n. | |||||
| 207 | if ( ex.InnerEx ception != null) | |||||
| 208 | { | |||||
| 209 | Console.Wr iteLine(ex .InnerExce ption.Mess age); | |||||
| 210 | ||||||
| 211 | FaultExcep tion<Micro soft.Xrm.S dk.Organiz ationServi ceFault> f e | |||||
| 212 | = ex.I nnerExcept ion | |||||
| 213 | as Fau ltExceptio n<Microsof t.Xrm.Sdk. Organizati onServiceF ault>; | |||||
| 214 | if (fe != null) | |||||
| 215 | { | |||||
| 216 | Consol e.WriteLin e("Timesta mp: {0}", fe.Detail. Timestamp) ; | |||||
| 217 | Consol e.WriteLin e("Code: { 0}", fe.De tail.Error Code); | |||||
| 218 | Consol e.WriteLin e("Message : {0}", fe .Detail.Me ssage); | |||||
| 219 | Consol e.WriteLin e("Plugin Trace: {0} ", fe.Deta il.TraceTe xt); | |||||
| 220 | Consol e.WriteLin e("Inner F ault: {0}" , | |||||
| 221 | nu ll == fe.D etail.Inne rFault ? " No Inner F ault" : "H as Inner F ault"); | |||||
| 222 | } | |||||
| 223 | } | |||||
| 224 | } | |||||
| 225 | // Addit ional exce ptions to catch: Sec urityToken Validation Exception, ExpiredSe curityToke nException , | |||||
| 226 | // Secur ityAccessD eniedExcep tion, Mess ageSecurit yException , and Secu rityNegoti ationExcep tion. | |||||
| 227 | ||||||
| 228 | finally | |||||
| 229 | { | |||||
| 230 | ||||||
| 231 | Cons ole.WriteL ine("Press <Enter> t o exit."); | |||||
| 232 | Cons ole.ReadLi ne(); | |||||
| 233 | } | |||||
| 234 | ||||||
| 235 | } | |||||
| 236 | #e ndregion M ain | |||||
| 237 | } | |||||
| 238 | } | |||||
| 239 | //</snippe tCreateCon nectionRol e> |
Araxis Merge (but not the data content of this report) is Copyright © 1993-2016 Araxis Ltd (www.araxis.com). All rights reserved.