Produced by Araxis Merge on 2/1/2017 2:56:24 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 | UpdateConnectionRole.cs | Tue Dec 20 19:51:44 2016 UTC |
| 2 | Wed Feb 1 19:56:24 2017 UTC |
| Description | Between Files 1 and 2 |
|
|---|---|---|
| Text Blocks | Lines | |
| Unchanged | 0 | 0 |
| Changed | 0 | 0 |
| Inserted | 0 | 0 |
| Removed | 1 | 243 |
| 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 UpdateConn ectionRole > | |||||
| 18 | using Syst em; | |||||
| 19 | using Syst em.Service Model; | |||||
| 20 | ||||||
| 21 | // These n amespaces are found in the Mic rosoft.Xrm .Sdk.dll a ssembly | |||||
| 22 | // found i n the SDK\ bin folder . | |||||
| 23 | using Micr osoft.Xrm. Sdk; | |||||
| 24 | using Micr osoft.Xrm. Sdk.Client ; | |||||
| 25 | using Micr osoft.Xrm. Sdk.Query; | |||||
| 26 | using Micr osoft.Xrm. Sdk.Discov ery; | |||||
| 27 | using Micr osoft.Xrm. Sdk.Messag es; | |||||
| 28 | ||||||
| 29 | // This na mespace is found in Microsoft. Crm.Sdk.Pr oxy.dll as sembly | |||||
| 30 | // found i n the SDK\ bin folder . | |||||
| 31 | using Micr osoft.Crm. Sdk.Messag es; | |||||
| 32 | ||||||
| 33 | namespace Microsoft. Crm.Sdk.Sa mples | |||||
| 34 | { | |||||
| 35 | /// <s ummary> | |||||
| 36 | /// Th is Sample shows how to update a connecti on role. | |||||
| 37 | /// </ summary> | |||||
| 38 | public class Upd ateConnect ionRole | |||||
| 39 | { | |||||
| 40 | #r egion Clas s Level Me mbers | |||||
| 41 | ||||||
| 42 | ||||||
| 43 | // / <summary > | |||||
| 44 | // / Stores t he organiz ation serv ice proxy. | |||||
| 45 | // / </summar y> | |||||
| 46 | Or ganization ServicePro xy _servi ceProxy; | |||||
| 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 | // / Call the method to create an y data tha t this sam ple requir es. | |||||
| 57 | // / Update t he connect ionrole in stance. | |||||
| 58 | // / Optional ly delete any entity records t hat were c reated for this samp le. | |||||
| 59 | // / </summar y> | |||||
| 60 | pu blic void Run(Server Connection .Configura tion serve rConfig, b ool prompt ForDelete) | |||||
| 61 | { | |||||
| 62 | try | |||||
| 63 | { | |||||
| 64 | // C onnect to the Organi zation ser vice. | |||||
| 65 | // T he using s tatement a ssures tha t the serv ice proxy will be pr operly dis posed. | |||||
| 66 | 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 )) | |||||
| 67 | { | |||||
| 68 | // This st atement is required to enable early-boun d type sup port. | |||||
| 69 | _servicePr oxy.Enable ProxyTypes (); | |||||
| 70 | ||||||
| 71 | CreateRequ iredRecord s(); | |||||
| 72 | ||||||
| 73 | //<snippet UpdateConn ectionRole 1> | |||||
| 74 | // Define some anony mous types to define the range | |||||
| 75 | // of poss ible conne ction prop erty value s. | |||||
| 76 | var Catego ries = new | |||||
| 77 | { | |||||
| 78 | Busine ss = 1, | |||||
| 79 | Family = 2, | |||||
| 80 | Social = 3, | |||||
| 81 | Sales = 4, | |||||
| 82 | Other = 5 | |||||
| 83 | }; | |||||
| 84 | ||||||
| 85 | // Update the connec tionrole i nstance. | |||||
| 86 | Connection Role conne ctionRole = new Conn ectionRole | |||||
| 87 | { | |||||
| 88 | Connec tionRoleId = _connec tionRoleId , | |||||
| 89 | Name = "Updated Connection Role", | |||||
| 90 | Descri ption = "T his is an updated co nnection r ole.", | |||||
| 91 | Catego ry = new O ptionSetVa lue(Catego ries.Other ) | |||||
| 92 | }; | |||||
| 93 | ||||||
| 94 | _servicePr oxy.Update (connectio nRole); | |||||
| 95 | ||||||
| 96 | //</snippe tUpdateCon nectionRol e1> | |||||
| 97 | ||||||
| 98 | Console.Wr iteLine("U pdated the connectio nrole inst ance."); | |||||
| 99 | ||||||
| 100 | DeleteRequ iredRecord s(promptFo rDelete); | |||||
| 101 | ||||||
| 102 | } | |||||
| 103 | } | |||||
| 104 | // Catch any servi ce fault e xceptions that Micro soft Dynam ics CRM th rows. | |||||
| 105 | catch (F aultExcept ion<Micros oft.Xrm.Sd k.Organiza tionServic eFault>) | |||||
| 106 | { | |||||
| 107 | // Y ou can han dle an exc eption her e or pass it back to the calli ng method. | |||||
| 108 | thro w; | |||||
| 109 | } | |||||
| 110 | } | |||||
| 111 | ||||||
| 112 | // / <summary > | |||||
| 113 | // / This met hod create s any enti ty records that this sample re quires. | |||||
| 114 | // / Create a new conne ctionrole instance. | |||||
| 115 | // / </summar y> | |||||
| 116 | pu blic void CreateRequ iredRecord s() | |||||
| 117 | { | |||||
| 118 | // Defin e some ano nymous typ es to defi ne the ran ge | |||||
| 119 | // of po ssible con nection pr operty val ues. | |||||
| 120 | var Cate gories = n ew | |||||
| 121 | { | |||||
| 122 | Busi ness = 1, | |||||
| 123 | Fami ly = 2, | |||||
| 124 | Soci al = 3, | |||||
| 125 | Sale s = 4, | |||||
| 126 | Othe r = 5 | |||||
| 127 | }; | |||||
| 128 | ||||||
| 129 | // Creat e a Connec tion Role | |||||
| 130 | Connecti onRole set upConnecti onRole = n ew Connect ionRole | |||||
| 131 | { | |||||
| 132 | Name = "Exampl e Connecti on Role", | |||||
| 133 | Desc ription = "This is a n example one sided connection role.", | |||||
| 134 | Cate gory = new OptionSet Value(Cate gories.Bus iness), | |||||
| 135 | }; | |||||
| 136 | ||||||
| 137 | _connect ionRoleId = _service Proxy.Crea te(setupCo nnectionRo le); | |||||
| 138 | Console. WriteLine( "Created { 0}.", setu pConnectio nRole.Name ); | |||||
| 139 | ||||||
| 140 | return; | |||||
| 141 | } | |||||
| 142 | ||||||
| 143 | // / <summary > | |||||
| 144 | // / Deletes any entity records t hat were c reated for this samp le. | |||||
| 145 | // / <param n ame="promp t">Indicat es whether to prompt the user | |||||
| 146 | // / to delet e the reco rds create d in this sample.</p aram> | |||||
| 147 | // / </summar y> | |||||
| 148 | pu blic void DeleteRequ iredRecord s(bool pro mpt) | |||||
| 149 | { | |||||
| 150 | bool del eteRecords = true; | |||||
| 151 | ||||||
| 152 | if (prom pt) | |||||
| 153 | { | |||||
| 154 | Cons ole.WriteL ine("\nDo you want t hese entit y records deleted? ( y/n)"); | |||||
| 155 | Stri ng answer = Console. ReadLine() ; | |||||
| 156 | ||||||
| 157 | dele teRecords = (answer. StartsWith ("y") || a nswer.Star tsWith("Y" )); | |||||
| 158 | } | |||||
| 159 | ||||||
| 160 | if (dele teRecords) | |||||
| 161 | { | |||||
| 162 | _ser viceProxy. Delete(Con nectionRol e.EntityLo gicalName, _connecti onRoleId); | |||||
| 163 | ||||||
| 164 | Cons ole.WriteL ine("Entit y records have been deleted.") ; | |||||
| 165 | } | |||||
| 166 | } | |||||
| 167 | ||||||
| 168 | #e ndregion H ow To Samp le Code | |||||
| 169 | ||||||
| 170 | #r egion Main | |||||
| 171 | // / <summary > | |||||
| 172 | // / Main. Ru ns the sam ple and pr ovides err or output. | |||||
| 173 | // / <param n ame="args" >Array of arguments to Main me thod.</par am> | |||||
| 174 | // / </summar y> | |||||
| 175 | st atic publi c void Mai n(string[] args) | |||||
| 176 | { | |||||
| 177 | try | |||||
| 178 | { | |||||
| 179 | // O btain the target org anization' s Web addr ess and cl ient logon | |||||
| 180 | // c redentials from the user. | |||||
| 181 | Serv erConnecti on serverC onnect = n ew ServerC onnection( ); | |||||
| 182 | Serv erConnecti on.Configu ration con fig = serv erConnect. GetServerC onfigurati on(); | |||||
| 183 | ||||||
| 184 | Upda teConnecti onRole app = new Upd ateConnect ionRole(); | |||||
| 185 | app. Run(config , true); | |||||
| 186 | ||||||
| 187 | } | |||||
| 188 | catch (F aultExcept ion<Micros oft.Xrm.Sd k.Organiza tionServic eFault> ex ) | |||||
| 189 | { | |||||
| 190 | Cons ole.WriteL ine("The a pplication terminate d with an error."); | |||||
| 191 | Cons ole.WriteL ine("Times tamp: {0}" , ex.Detai l.Timestam p); | |||||
| 192 | Cons ole.WriteL ine("Code: {0}", ex. Detail.Err orCode); | |||||
| 193 | Cons ole.WriteL ine("Messa ge: {0}", ex.Detail. Message); | |||||
| 194 | Cons ole.WriteL ine("Plugi n Trace: { 0}", ex.De tail.Trace Text); | |||||
| 195 | Cons ole.WriteL ine("Inner Fault: {0 }", | |||||
| 196 | null == ex .Detail.In nerFault ? "No Inner Fault" : "Has Inner Fault"); | |||||
| 197 | } | |||||
| 198 | catch (S ystem.Time outExcepti on ex) | |||||
| 199 | { | |||||
| 200 | Cons ole.WriteL ine("The a pplication terminate d with an error."); | |||||
| 201 | Cons ole.WriteL ine("Messa ge: {0}", ex.Message ); | |||||
| 202 | Cons ole.WriteL ine("Stack Trace: {0 }", ex.Sta ckTrace); | |||||
| 203 | Cons ole.WriteL ine("Inner Fault: {0 }", | |||||
| 204 | null == ex .InnerExce ption.Mess age ? "No Inner Faul t" : ex.In nerExcepti on.Message ); | |||||
| 205 | } | |||||
| 206 | catch (S ystem.Exce ption ex) | |||||
| 207 | { | |||||
| 208 | Cons ole.WriteL ine("The a pplication terminate d with an error."); | |||||
| 209 | Cons ole.WriteL ine(ex.Mes sage); | |||||
| 210 | ||||||
| 211 | // D isplay the details o f the inne r exceptio n. | |||||
| 212 | if ( ex.InnerEx ception != null) | |||||
| 213 | { | |||||
| 214 | Console.Wr iteLine(ex .InnerExce ption.Mess age); | |||||
| 215 | ||||||
| 216 | FaultExcep tion<Micro soft.Xrm.S dk.Organiz ationServi ceFault> f e | |||||
| 217 | = ex.I nnerExcept ion | |||||
| 218 | as Fau ltExceptio n<Microsof t.Xrm.Sdk. Organizati onServiceF ault>; | |||||
| 219 | if (fe != null) | |||||
| 220 | { | |||||
| 221 | Consol e.WriteLin e("Timesta mp: {0}", fe.Detail. Timestamp) ; | |||||
| 222 | Consol e.WriteLin e("Code: { 0}", fe.De tail.Error Code); | |||||
| 223 | Consol e.WriteLin e("Message : {0}", fe .Detail.Me ssage); | |||||
| 224 | Consol e.WriteLin e("Plugin Trace: {0} ", fe.Deta il.TraceTe xt); | |||||
| 225 | Consol e.WriteLin e("Inner F ault: {0}" , | |||||
| 226 | nu ll == fe.D etail.Inne rFault ? " No Inner F ault" : "H as Inner F ault"); | |||||
| 227 | } | |||||
| 228 | } | |||||
| 229 | } | |||||
| 230 | // Addit ional exce ptions to catch: Sec urityToken Validation Exception, ExpiredSe curityToke nException , | |||||
| 231 | // Secur ityAccessD eniedExcep tion, Mess ageSecurit yException , and Secu rityNegoti ationExcep tion. | |||||
| 232 | ||||||
| 233 | finally | |||||
| 234 | { | |||||
| 235 | Cons ole.WriteL ine("Press <Enter> t o exit."); | |||||
| 236 | Cons ole.ReadLi ne(); | |||||
| 237 | } | |||||
| 238 | ||||||
| 239 | } | |||||
| 240 | #e ndregion M ain | |||||
| 241 | } | |||||
| 242 | } | |||||
| 243 | //</snippe tUpdateCon nectionRol e> |
Araxis Merge (but not the data content of this report) is Copyright © 1993-2016 Araxis Ltd (www.araxis.com). All rights reserved.