Produced by Araxis Merge on 2/1/2017 2:56:31 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\DeploymentService | UseDeploymentServiceMessages.cs | Tue Dec 20 19:51:43 2016 UTC |
| 2 | Wed Feb 1 19:56:31 2017 UTC |
| Description | Between Files 1 and 2 |
|
|---|---|---|
| Text Blocks | Lines | |
| Unchanged | 0 | 0 |
| Changed | 0 | 0 |
| Inserted | 0 | 0 |
| Removed | 1 | 262 |
| 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 | // This f ile is par t of the M icrosoft D ynamics CR M SDK code samples. | |||||
| 3 | // | |||||
| 4 | // Copyri ght (C) Mi crosoft Co rporation. All righ ts reserve d. | |||||
| 5 | // | |||||
| 6 | // This s ource code is intend ed only as a supplem ent to Mic rosoft | |||||
| 7 | // Develo pment Tool s and/or o n-line doc umentation . See the se other | |||||
| 8 | // materi als for de tailed inf ormation r egarding M icrosoft c ode sample s. | |||||
| 9 | // | |||||
| 10 | // THIS C ODE AND IN FORMATION ARE PROVID ED "AS IS" WITHOUT W ARRANTY OF ANY | |||||
| 11 | // KIND, EITHER EXP RESSED OR IMPLIED, I NCLUDING B UT NOT LIM ITED TO TH E | |||||
| 12 | // IMPLIE D WARRANTI ES OF MERC HANTABILIT Y AND/OR F ITNESS FOR A | |||||
| 13 | // PARTIC ULAR PURPO SE. | |||||
| 14 | // ======= ========== ========== ========== ========== ========== ========== == | |||||
| 15 | ||||||
| 16 | //<snippet UseDeploym entService Messages> | |||||
| 17 | using Syst em; | |||||
| 18 | using Syst em.Net; | |||||
| 19 | using Syst em.Service Model; | |||||
| 20 | ||||||
| 21 | // These n amespaces are found in the Mic rosoft.Xrm .Sdk.dll a ssembly | |||||
| 22 | // located in the SD K\bin fold er of the SDK downlo ad. | |||||
| 23 | using Micr osoft.Xrm. Sdk.Query; | |||||
| 24 | using Micr osoft.Xrm. Sdk.Client ; | |||||
| 25 | ||||||
| 26 | // These n amespaces are found in the Mic rosoft.Xrm .Sdk.Deplo yment.dll assembly | |||||
| 27 | // located in the SD K\bin fold er of the SDK downlo ad. | |||||
| 28 | using Micr osoft.Xrm. Sdk.Deploy ment; | |||||
| 29 | using Depl oyment = M icrosoft.X rm.Sdk.Dep loyment; | |||||
| 30 | ||||||
| 31 | namespace Microsoft. Crm.Sdk.Sa mples | |||||
| 32 | { | |||||
| 33 | /// <s ummary> | |||||
| 34 | /// De monstrates how to re trieve dep loyment in formation programmat ically.</s ummary> | |||||
| 35 | /// <r emarks> | |||||
| 36 | /// NO TE: The de ployment s ervice onl y supports Active Di rectory, s o the user running | |||||
| 37 | /// th is sample must have a valid Ac tive Direc tory accou nt. | |||||
| 38 | /// </ remarks> | |||||
| 39 | public class Use Deployment ServiceMes sages | |||||
| 40 | { | |||||
| 41 | #r egion Clas s Level Me mbers | |||||
| 42 | ||||||
| 43 | pr ivate Orga nizationSe rviceProxy _serviceP roxy; | |||||
| 44 | ||||||
| 45 | #e ndregion C lass Level Members | |||||
| 46 | ||||||
| 47 | #r egion How To Sample Code | |||||
| 48 | // / <summary > | |||||
| 49 | // / This met hod first connects t o the Depl oyment ser vice. Then , | |||||
| 50 | // / a variet y of messa ges are us ed to retr ieve deplo yment info rmation. | |||||
| 51 | // / </summar y> | |||||
| 52 | // / <param n ame="serve rConfig">C ontains se rver conne ction info rmation.</ param> | |||||
| 53 | // / <param n ame="promp tforDelete ">When Tru e, the use r will be prompted t o delete | |||||
| 54 | // / all crea ted entiti es.</param > | |||||
| 55 | pu blic void Run(Server Connection .Configura tion serve rConfig, b ool prompt forDelete) | |||||
| 56 | { | |||||
| 57 | try | |||||
| 58 | { | |||||
| 59 | //<s nippetUseD eploymentS erviceMess ages1> | |||||
| 60 | // C onnect to the Organi zation ser vice. | |||||
| 61 | // T he using s tatement a ssures tha t the serv ice proxy will be pr operly dis posed. | |||||
| 62 | 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 )) | |||||
| 63 | { | |||||
| 64 | // This st atement is required to enable early-boun d type sup port. | |||||
| 65 | _servicePr oxy.Enable ProxyTypes (); | |||||
| 66 | ||||||
| 67 | // Instant iate Deplo ymentServi ceClient f or calling the servi ce. | |||||
| 68 | Deployment ServiceCli ent servic eClient = | |||||
| 69 | Deploy ment.Proxy .ProxyClie ntHelper.C reateClien t( | |||||
| 70 | new Ur i(serverCo nfig.Disco veryUri.To String() | |||||
| 71 | .R eplace("Se rvices", " Deployment ") | |||||
| 72 | .R eplace("Di scovery", "Deploymen t"))); | |||||
| 73 | ||||||
| 74 | // Setting credentia ls from th e current security c ontext. | |||||
| 75 | if (server Config.Cre dentials = = null) | |||||
| 76 | { | |||||
| 77 | servic eClient.Cl ientCreden tials.Wind ows.Client Credential = | |||||
| 78 | Cr edentialCa che.Defaul tNetworkCr edentials; | |||||
| 79 | } | |||||
| 80 | else | |||||
| 81 | { | |||||
| 82 | servic eClient.Cl ientCreden tials.Wind ows.Client Credential = | |||||
| 83 | se rverConfig .Credentia ls.Windows .ClientCre dential; | |||||
| 84 | } | |||||
| 85 | ||||||
| 86 | // Retriev e all depl oyed insta nces of Mi crosoft Dy namics CRM . | |||||
| 87 | var organi zations = | |||||
| 88 | servic eClient.Re trieveAll( Deployment EntityType .Organizat ion); | |||||
| 89 | ||||||
| 90 | // Print l ist of all retrieved organizat ions. | |||||
| 91 | Console.Wr iteLine("O rganizatio ns in your deploymen t"); | |||||
| 92 | Console.Wr iteLine("= ========== ========== ========== ="); | |||||
| 93 | foreach (v ar organiz ation in o rganizatio ns) | |||||
| 94 | { | |||||
| 95 | Consol e.WriteLin e(organiza tion.Name) ; | |||||
| 96 | } | |||||
| 97 | Console.Wr iteLine("< End of Lis ting>"); | |||||
| 98 | Console.Wr iteLine(); | |||||
| 99 | ||||||
| 100 | ||||||
| 101 | // Retriev e details of first o rganizatio n from pre vious call . | |||||
| 102 | Deployment .Organizat ion deploy ment = | |||||
| 103 | (Deplo yment.Orga nization)s erviceClie nt.Retriev e( | |||||
| 104 | De ploymentEn tityType.O rganizatio n, | |||||
| 105 | or ganization s[0]); | |||||
| 106 | ||||||
| 107 | // Print o ut retriev ed details about you r organiza tion. | |||||
| 108 | Console.Wr iteLine(St ring.Forma t( | |||||
| 109 | "Selec ted deploy ment detai ls for {0} ", | |||||
| 110 | server Config.Org anizationN ame)); | |||||
| 111 | Console.Wr iteLine("= ========== ========== ========== ========== "); | |||||
| 112 | Console.Wr ite("Frien dly Name: "); | |||||
| 113 | Console.Wr iteLine(de ployment.F riendlyNam e); | |||||
| 114 | Console.Wr ite("Uniqu e Name: ") ; | |||||
| 115 | Console.Wr iteLine(de ployment.U niqueName) ; | |||||
| 116 | Console.Wr ite("Organ ization Ve rsion: "); | |||||
| 117 | Console.Wr iteLine(de ployment.V ersion); | |||||
| 118 | Console.Wr ite("SQL S erver Name : "); | |||||
| 119 | Console.Wr iteLine(de ployment.S qlServerNa me); | |||||
| 120 | Console.Wr ite("SRS U RL: "); | |||||
| 121 | Console.Wr iteLine(de ployment.S rsUrl); | |||||
| 122 | Console.Wr iteLine("< End of Lis ting>"); | |||||
| 123 | Console.Wr iteLine(); | |||||
| 124 | ||||||
| 125 | // Retriev e license and user i nformation for your organizati on. | |||||
| 126 | TrackLicen seRequest licenseReq uest = new TrackLice nseRequest (); | |||||
| 127 | TrackLicen seResponse licenseRe sponse = | |||||
| 128 | (Track LicenseRes ponse)serv iceClient. Execute(li censeReque st); | |||||
| 129 | ||||||
| 130 | // Print o ut the num ber of ser vers and t he user li st. | |||||
| 131 | Console.Wr iteLine(St ring.Forma t( | |||||
| 132 | "Licen se and use r informat ion for {0 }", | |||||
| 133 | server Config.Org anizationN ame)); | |||||
| 134 | Console.Wr iteLine("= ========== ========== ========== ========== "); | |||||
| 135 | Console.Wr ite("Numbe r of serve rs: "); | |||||
| 136 | Console.Wr iteLine(li censeRespo nse.Server s != null | |||||
| 137 | ? lice nseRespons e.Servers. Count.ToSt ring() | |||||
| 138 | : "nul l"); | |||||
| 139 | Console.Wr iteLine("U sers:"); | |||||
| 140 | foreach (O rganizatio nUserInfo user in li censeRespo nse.Users. ToArray()) | |||||
| 141 | { | |||||
| 142 | Consol e.WriteLin e(user.Ful lName); | |||||
| 143 | } | |||||
| 144 | Console.Wr iteLine("< End of Lis ting>"); | |||||
| 145 | Console.Wr iteLine(); | |||||
| 146 | ||||||
| 147 | // Retriev e advanced settings for your o rganizatio n. | |||||
| 148 | // Note th at the col umnset mus t contain at least o ne column. Setting | |||||
| 149 | // AllColu mns to tru e results in an erro r. | |||||
| 150 | RetrieveAd vancedSett ingsReques t request = | |||||
| 151 | new Re trieveAdva ncedSettin gsRequest | |||||
| 152 | { | |||||
| 153 | Co nfiguratio nEntityNam e = "Serve r", | |||||
| 154 | Co lumnSet = new Column Set( | |||||
| 155 | new stri ng[] { "Id ", "FullNa me", "Name ", "Roles" , "State", "Version" }) | |||||
| 156 | }; | |||||
| 157 | Configurat ionEntity configurat ion = | |||||
| 158 | ((Retr ieveAdvanc edSettings Response)s erviceClie nt.Execute (request)) .Entity; | |||||
| 159 | ||||||
| 160 | // Print o ut all adv anced sett ings where IsWritabl e==true. | |||||
| 161 | Console.Wr iteLine("A dvanced de ployment s ettings th at can be updated"); | |||||
| 162 | Console.Wr iteLine("= ========== ========== ========== ========== ======="); | |||||
| 163 | foreach (v ar setting in config uration.At tributes) | |||||
| 164 | { | |||||
| 165 | if (se tting.Key != "Id") | |||||
| 166 | { | |||||
| 167 | Co nsole.Writ eLine( | |||||
| 168 | String.F ormat("{0} : {1}", | |||||
| 169 | sett ing.Key, | |||||
| 170 | sett ing.Value) ); | |||||
| 171 | } | |||||
| 172 | } | |||||
| 173 | Console.Wr iteLine("< End of Lis ting>"); | |||||
| 174 | Console.Wr iteLine(); | |||||
| 175 | ||||||
| 176 | } | |||||
| 177 | //</ snippetUse Deployment ServiceMes sages1> | |||||
| 178 | } | |||||
| 179 | ||||||
| 180 | // Catch any servi ce fault e xceptions that Micro soft Dynam ics CRM th rows. | |||||
| 181 | catch (F aultExcept ion<Micros oft.Xrm.Sd k.Organiza tionServic eFault>) | |||||
| 182 | { | |||||
| 183 | // Y ou can han dle an exc eption her e or pass it back to the calli ng method. | |||||
| 184 | thro w; | |||||
| 185 | } | |||||
| 186 | } | |||||
| 187 | ||||||
| 188 | #e ndregion H ow To Samp le Code | |||||
| 189 | ||||||
| 190 | #r egion Main method | |||||
| 191 | ||||||
| 192 | // / <summary > | |||||
| 193 | // / Standard Main() me thod used by most SD K samples. | |||||
| 194 | // / </summar y> | |||||
| 195 | // / <param n ame="args" ></param> | |||||
| 196 | st atic publi c void Mai n(string[] args) | |||||
| 197 | { | |||||
| 198 | try | |||||
| 199 | { | |||||
| 200 | // O btain the target org anization' s Web addr ess and cl ient logon | |||||
| 201 | // c redentials from the user. | |||||
| 202 | Serv erConnecti on serverC onnect = n ew ServerC onnection( ); | |||||
| 203 | Serv erConnecti on.Configu ration con fig = serv erConnect. GetServerC onfigurati on(); | |||||
| 204 | ||||||
| 205 | UseD eploymentS erviceMess ages app = new UseDe ploymentSe rviceMessa ges(); | |||||
| 206 | app. Run(config , true); | |||||
| 207 | } | |||||
| 208 | catch (F aultExcept ion<Micros oft.Xrm.Sd k.Organiza tionServic eFault> ex ) | |||||
| 209 | { | |||||
| 210 | Cons ole.WriteL ine("The a pplication terminate d with an error."); | |||||
| 211 | Cons ole.WriteL ine("Times tamp: {0}" , ex.Detai l.Timestam p); | |||||
| 212 | Cons ole.WriteL ine("Code: {0}", ex. Detail.Err orCode); | |||||
| 213 | Cons ole.WriteL ine("Messa ge: {0}", ex.Detail. Message); | |||||
| 214 | Cons ole.WriteL ine("Plugi n Trace: { 0}", ex.De tail.Trace Text); | |||||
| 215 | Cons ole.WriteL ine("Inner Fault: {0 }", | |||||
| 216 | null == ex .Detail.In nerFault ? "No Inner Fault" : "Has Inner Fault"); | |||||
| 217 | } | |||||
| 218 | catch (S ystem.Time outExcepti on ex) | |||||
| 219 | { | |||||
| 220 | Cons ole.WriteL ine("The a pplication terminate d with an error."); | |||||
| 221 | Cons ole.WriteL ine("Messa ge: {0}", ex.Message ); | |||||
| 222 | Cons ole.WriteL ine("Stack Trace: {0 }", ex.Sta ckTrace); | |||||
| 223 | Cons ole.WriteL ine("Inner Fault: {0 }", | |||||
| 224 | null == ex .InnerExce ption.Mess age ? "No Inner Faul t" : ex.In nerExcepti on.Message ); | |||||
| 225 | } | |||||
| 226 | catch (S ystem.Exce ption ex) | |||||
| 227 | { | |||||
| 228 | Cons ole.WriteL ine("The a pplication terminate d with an error."); | |||||
| 229 | Cons ole.WriteL ine(ex.Mes sage); | |||||
| 230 | ||||||
| 231 | // D isplay the details o f the inne r exceptio n. | |||||
| 232 | if ( ex.InnerEx ception != null) | |||||
| 233 | { | |||||
| 234 | Console.Wr iteLine(ex .InnerExce ption.Mess age); | |||||
| 235 | ||||||
| 236 | FaultExcep tion<Micro soft.Xrm.S dk.Organiz ationServi ceFault> f e = ex.Inn erExceptio n | |||||
| 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 | finally | |||||
| 253 | { | |||||
| 254 | Cons ole.WriteL ine("Press <Enter> t o exit."); | |||||
| 255 | Cons ole.ReadLi ne(); | |||||
| 256 | } | |||||
| 257 | } | |||||
| 258 | #e ndregion M ain method | |||||
| 259 | ||||||
| 260 | } | |||||
| 261 | } | |||||
| 262 | //</snippe tUseDeploy mentServic eMessages> |
Araxis Merge (but not the data content of this report) is Copyright © 1993-2016 Araxis Ltd (www.araxis.com). All rights reserved.