Produced by Araxis Merge on 2/1/2017 2:56:33 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\GeneralProgramming\EarlyBound | License.cs | Tue Dec 20 19:51:45 2016 UTC |
| 2 | Wed Feb 1 19:56:33 2017 UTC |
| Description | Between Files 1 and 2 |
|
|---|---|---|
| Text Blocks | Lines | |
| Unchanged | 0 | 0 |
| Changed | 0 | 0 |
| Inserted | 0 | 0 |
| Removed | 1 | 215 |
| 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 License> | |||||
| 17 | using Syst em; | |||||
| 18 | using Syst em.Linq; | |||||
| 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; | |||||
| 24 | using Micr osoft.Xrm. Sdk.Query; | |||||
| 25 | using Micr osoft.Xrm. Sdk.Client ; | |||||
| 26 | ||||||
| 27 | // This na mespace is found in Microsoft. Crm.Sdk.Pr oxy.dll as sembly | |||||
| 28 | // found i n the SDK\ bin folder . | |||||
| 29 | using Micr osoft.Crm. Sdk.Messag es; | |||||
| 30 | ||||||
| 31 | namespace Microsoft. Crm.Sdk.Sa mples | |||||
| 32 | { | |||||
| 33 | /// <s ummary> | |||||
| 34 | /// De monstrates how to is sue the Re trieveDepl oymentLice nseTypeReq uest and | |||||
| 35 | /// Re trieveLice nseInfoReq uest. | |||||
| 36 | /// </ summary> | |||||
| 37 | /// <p aram name= "serverCon fig">Conta ins server connectio n informat ion.</para m> | |||||
| 38 | /// <p aram name= "promptfor Delete">Wh en True, t he user wi ll be prom pted to de lete all | |||||
| 39 | /// cr eated enti ties.</par am> | |||||
| 40 | public class Lic ense | |||||
| 41 | { | |||||
| 42 | #r egion Clas s Level Me mbers | |||||
| 43 | ||||||
| 44 | pr ivate Orga nizationSe rviceProxy _serviceP roxy; | |||||
| 45 | ||||||
| 46 | #e ndregion C lass Level Members | |||||
| 47 | ||||||
| 48 | #r egion How To Sample Code | |||||
| 49 | // / <summary > | |||||
| 50 | // / This met hod first executes a RetrieveD eploymentL icenseType Request an d | |||||
| 51 | // / displays the type of license for this deployment to the co nsole, the n | |||||
| 52 | // / executes a Retriev eLicenseIn foRequest and displa ys the num ber of use d | |||||
| 53 | // / and avai lable Read -Write lic enses ther e are. | |||||
| 54 | // / </summar y> | |||||
| 55 | // / <param n ame="serve rConfig">C ontains se rver conne ction info rmation.</ param> | |||||
| 56 | // / <param n ame="promp tforDelete ">When Tru e, the use r will be prompted t o delete a ll | |||||
| 57 | // / created entities.< /param> | |||||
| 58 | ||||||
| 59 | pu blic void Run(Server Connection .Configura tion serve rConfig, b ool prompt forDelete) | |||||
| 60 | { | |||||
| 61 | try | |||||
| 62 | { | |||||
| 63 | //<s nippetLice nse1> | |||||
| 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 | #region Re trieveDepl oymentLice nseTypeReq uest | |||||
| 72 | ||||||
| 73 | // Create the reques t | |||||
| 74 | var deploy mentTypeRe quest = ne w Retrieve Deployment LicenseTyp eRequest() ; | |||||
| 75 | ||||||
| 76 | // Execute the reque st | |||||
| 77 | Console.Wr iteLine(" Fetching the licens e type for this depl oyment"); | |||||
| 78 | var deploy mentTypeRe sponse = | |||||
| 79 | (Retri eveDeploym entLicense TypeRespon se)_servic eProxy.Exe cute(deplo ymentTypeR equest); | |||||
| 80 | ||||||
| 81 | // Validat e results | |||||
| 82 | if (String .IsNullOrE mpty(deplo ymentTypeR esponse.li censeType) ) | |||||
| 83 | throw new Except ion("The r equest did not retur n any resu lts"); | |||||
| 84 | ||||||
| 85 | string lic enseId = | |||||
| 86 | new Gu id(deploym entTypeRes ponse.lice nseType).T oString(). ToUpper(); | |||||
| 87 | switch (li censeId) | |||||
| 88 | { | |||||
| 89 | case " 9436EA66-8 262-4168-9 B6C-21DF47 D1D121": | |||||
| 90 | Co nsole.Writ eLine(" L icense typ e: SmallBu siness"); | |||||
| 91 | br eak; | |||||
| 92 | case " 5BEEA2E8-8 F82-40E8-A E0F-6D8C13 5E1397": | |||||
| 93 | Co nsole.Writ eLine(" L icense typ e: Profess ional"); | |||||
| 94 | br eak; | |||||
| 95 | case " CB96BDD5-5 F74-4EA5-8 323-9D7E20 079002": | |||||
| 96 | Co nsole.Writ eLine(" L icense typ e: Enterpr ise"); | |||||
| 97 | br eak; | |||||
| 98 | case " 66AE2919-D D58-40CA-A 980-AEF733 0B2745": | |||||
| 99 | Co nsole.Writ eLine(" L icense typ e: Live"); | |||||
| 100 | br eak; | |||||
| 101 | case " 722E9E15-6 2DC-48A7-9 5CF-93131B E27273": | |||||
| 102 | Co nsole.Writ eLine(" L icense typ e: SPLA (S ervice Pro vider)"); | |||||
| 103 | br eak; | |||||
| 104 | defaul t: | |||||
| 105 | Co nsole.Writ eLine(" U nknown lic ense type with id {0 }", licens eId); | |||||
| 106 | br eak; | |||||
| 107 | } | |||||
| 108 | ||||||
| 109 | #endregion | |||||
| 110 | ||||||
| 111 | #region Re trieveLice nseInfoReq uest | |||||
| 112 | ||||||
| 113 | // create the reques t | |||||
| 114 | var licens eInfoReque st = new R etrieveLic enseInfoRe quest(); | |||||
| 115 | ||||||
| 116 | // execute the reque st | |||||
| 117 | Console.Wr iteLine(" Fetching license in fo"); | |||||
| 118 | var licens eInfoRespo nse = | |||||
| 119 | (Retri eveLicense InfoRespon se)_servic eProxy.Exe cute(licen seInfoRequ est); | |||||
| 120 | ||||||
| 121 | // output the result s | |||||
| 122 | Console.Wr iteLine(" Number of licenses available: {0}", | |||||
| 123 | licens eInfoRespo nse.Availa bleCount); | |||||
| 124 | Console.Wr iteLine(" Number of licenses used: {0}" , | |||||
| 125 | licens eInfoRespo nse.Grante dLicenseCo unt); | |||||
| 126 | ||||||
| 127 | #endregion | |||||
| 128 | } | |||||
| 129 | //</ snippetLic ense1> | |||||
| 130 | ||||||
| 131 | } | |||||
| 132 | ||||||
| 133 | // Catch any servi ce fault e xceptions that Micro soft Dynam ics CRM th rows. | |||||
| 134 | catch (F aultExcept ion<Micros oft.Xrm.Sd k.Organiza tionServic eFault>) | |||||
| 135 | { | |||||
| 136 | // Y ou can han dle an exc eption her e or pass it back to the calli ng method. | |||||
| 137 | thro w; | |||||
| 138 | } | |||||
| 139 | } | |||||
| 140 | ||||||
| 141 | #e ndregion H ow To Samp le Code | |||||
| 142 | ||||||
| 143 | #r egion Main method | |||||
| 144 | ||||||
| 145 | // / <summary > | |||||
| 146 | // / Standard Main() me thod used by most SD K samples. | |||||
| 147 | // / </summar y> | |||||
| 148 | // / <param n ame="args" ></param> | |||||
| 149 | st atic publi c void Mai n(string[] args) | |||||
| 150 | { | |||||
| 151 | try | |||||
| 152 | { | |||||
| 153 | // O btain the target org anization' s Web addr ess and cl ient logon | |||||
| 154 | // c redentials from the user. | |||||
| 155 | Serv erConnecti on serverC onnect = n ew ServerC onnection( ); | |||||
| 156 | Serv erConnecti on.Configu ration con fig = serv erConnect. GetServerC onfigurati on(); | |||||
| 157 | ||||||
| 158 | Lice nse app = new Licens e(); | |||||
| 159 | app. Run(config , true); | |||||
| 160 | } | |||||
| 161 | catch (F aultExcept ion<Micros oft.Xrm.Sd k.Organiza tionServic eFault> ex ) | |||||
| 162 | { | |||||
| 163 | Cons ole.WriteL ine("The a pplication terminate d with an error."); | |||||
| 164 | Cons ole.WriteL ine("Times tamp: {0}" , ex.Detai l.Timestam p); | |||||
| 165 | Cons ole.WriteL ine("Code: {0}", ex. Detail.Err orCode); | |||||
| 166 | Cons ole.WriteL ine("Messa ge: {0}", ex.Detail. Message); | |||||
| 167 | Cons ole.WriteL ine("Plugi n Trace: { 0}", ex.De tail.Trace Text); | |||||
| 168 | Cons ole.WriteL ine("Inner Fault: {0 }", | |||||
| 169 | null == ex .Detail.In nerFault ? "No Inner Fault" : "Has Inner Fault"); | |||||
| 170 | } | |||||
| 171 | catch (S ystem.Time outExcepti on ex) | |||||
| 172 | { | |||||
| 173 | Cons ole.WriteL ine("The a pplication terminate d with an error."); | |||||
| 174 | Cons ole.WriteL ine("Messa ge: {0}", ex.Message ); | |||||
| 175 | Cons ole.WriteL ine("Stack Trace: {0 }", ex.Sta ckTrace); | |||||
| 176 | Cons ole.WriteL ine("Inner Fault: {0 }", | |||||
| 177 | null == ex .InnerExce ption.Mess age ? "No Inner Faul t" : ex.In nerExcepti on.Message ); | |||||
| 178 | } | |||||
| 179 | catch (S ystem.Exce ption ex) | |||||
| 180 | { | |||||
| 181 | Cons ole.WriteL ine("The a pplication terminate d with an error."); | |||||
| 182 | Cons ole.WriteL ine(ex.Mes sage); | |||||
| 183 | ||||||
| 184 | // D isplay the details o f the inne r exceptio n. | |||||
| 185 | if ( ex.InnerEx ception != null) | |||||
| 186 | { | |||||
| 187 | Console.Wr iteLine(ex .InnerExce ption.Mess age); | |||||
| 188 | ||||||
| 189 | FaultExcep tion<Micro soft.Xrm.S dk.Organiz ationServi ceFault> f e = ex.Inn erExceptio n | |||||
| 190 | as Fau ltExceptio n<Microsof t.Xrm.Sdk. Organizati onServiceF ault>; | |||||
| 191 | if (fe != null) | |||||
| 192 | { | |||||
| 193 | Consol e.WriteLin e("Timesta mp: {0}", fe.Detail. Timestamp) ; | |||||
| 194 | Consol e.WriteLin e("Code: { 0}", fe.De tail.Error Code); | |||||
| 195 | Consol e.WriteLin e("Message : {0}", fe .Detail.Me ssage); | |||||
| 196 | Consol e.WriteLin e("Plugin Trace: {0} ", fe.Deta il.TraceTe xt); | |||||
| 197 | Consol e.WriteLin e("Inner F ault: {0}" , | |||||
| 198 | nu ll == fe.D etail.Inne rFault ? " No Inner F ault" : "H as Inner F ault"); | |||||
| 199 | } | |||||
| 200 | } | |||||
| 201 | } | |||||
| 202 | // Addit ional exce ptions to catch: Sec urityToken Validation Exception, ExpiredSe curityToke nException , | |||||
| 203 | // Secur ityAccessD eniedExcep tion, Mess ageSecurit yException , and Secu rityNegoti ationExcep tion. | |||||
| 204 | ||||||
| 205 | finally | |||||
| 206 | { | |||||
| 207 | Cons ole.WriteL ine("Press <Enter> t o exit."); | |||||
| 208 | Cons ole.ReadLi ne(); | |||||
| 209 | } | |||||
| 210 | } | |||||
| 211 | ||||||
| 212 | #e ndregion M ain method | |||||
| 213 | } | |||||
| 214 | } | |||||
| 215 | //</snippe tLicense> |
Araxis Merge (but not the data content of this report) is Copyright © 1993-2016 Araxis Ltd (www.araxis.com). All rights reserved.