Produced by Araxis Merge on 2/1/2017 2:56:28 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\UsersAndRoles | RetrieveRolesForOrg.cs | Tue Dec 20 19:51:44 2016 UTC |
| 2 | Wed Feb 1 19:56:28 2017 UTC |
| Description | Between Files 1 and 2 |
|
|---|---|---|
| Text Blocks | Lines | |
| Unchanged | 0 | 0 |
| Changed | 0 | 0 |
| Inserted | 0 | 0 |
| Removed | 1 | 162 |
| 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 RetrieveRo lesForOrg> | |||||
| 17 | using Syst em; | |||||
| 18 | using Syst em.Service Model; | |||||
| 19 | using Syst em.Service Model.Desc ription; | |||||
| 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 | using Micr osoft.Crm. Sdk.Messag es; | |||||
| 27 | ||||||
| 28 | namespace Microsoft. Crm.Sdk.Sa mples | |||||
| 29 | { | |||||
| 30 | /// <s ummary> | |||||
| 31 | /// De monstrates how to re trieve rol es from an organizat ion. | |||||
| 32 | /// </ summary> | |||||
| 33 | /// <r emarks> | |||||
| 34 | /// At run-time, you will be given t he option to revert the role | |||||
| 35 | /// as sociation created by this prog ram.</rema rks> | |||||
| 36 | public class Ret rieveRoles ForOrg | |||||
| 37 | { | |||||
| 38 | #r egion Clas s Level Me mbers | |||||
| 39 | ||||||
| 40 | // Define th e IDs need ed for thi s sample. | |||||
| 41 | ||||||
| 42 | pr ivate Orga nizationSe rviceProxy _serviceP roxy; | |||||
| 43 | ||||||
| 44 | #e ndregion C lass Level Members | |||||
| 45 | ||||||
| 46 | #r egion How To Sample Code | |||||
| 47 | // / <summary > | |||||
| 48 | // / This met hod first connects t o the Orga nization s ervice. Af terwards, it | |||||
| 49 | // / retrieve s roles. | |||||
| 50 | // / </summar y> | |||||
| 51 | // / <param n ame="serve rConfig">C ontains se rver conne ction info rmation.</ param> | |||||
| 52 | // / <param n ame="promp tforDelete ">When Tru e, the use r is promp ted to del ete all | |||||
| 53 | // / created entities.< /param> | |||||
| 54 | pu blic void Run(Server Connection .Configura tion serve rConfig, b ool prompt forDelete) | |||||
| 55 | { | |||||
| 56 | try | |||||
| 57 | { | |||||
| 58 | //<s nippetRetr ieveRolesF orOrg1> | |||||
| 59 | // C onnect to the Organi zation ser vice. | |||||
| 60 | // T he using s tatement a ssures tha t the serv ice proxy is properl y disposed . | |||||
| 61 | 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 )) | |||||
| 62 | { | |||||
| 63 | QueryExpre ssion quer y = new Qu eryExpress ion | |||||
| 64 | { | |||||
| 65 | Entity Name = Rol e.EntityLo gicalName, | |||||
| 66 | Column Set = new ColumnSet( "name", "r oleid") | |||||
| 67 | ||||||
| 68 | }; | |||||
| 69 | ||||||
| 70 | EntityColl ection ent ities = _s erviceProx y.Retrieve Multiple(q uery); | |||||
| 71 | // Write t he name an d ID of ea ch role to the conso le. | |||||
| 72 | foreach (E ntity item in entiti es.Entitie s) | |||||
| 73 | { | |||||
| 74 | Role r ole = item .ToEntity< Role>(); | |||||
| 75 | Consol e.WriteLin e("Name: { 0}. Id: {1 }", role.N ame, role. Id); | |||||
| 76 | } | |||||
| 77 | ||||||
| 78 | } | |||||
| 79 | //</ snippetRet rieveRoles ForOrg1> | |||||
| 80 | } | |||||
| 81 | // Catch any servi ce fault e xceptions that Micro soft Dynam ics CRM th rows. | |||||
| 82 | catch (F aultExcept ion<Micros oft.Xrm.Sd k.Organiza tionServic eFault>) | |||||
| 83 | { | |||||
| 84 | // Y ou can han dle an exc eption her e or pass it back to the calli ng method. | |||||
| 85 | thro w; | |||||
| 86 | } | |||||
| 87 | } | |||||
| 88 | ||||||
| 89 | #e ndregion H ow To Samp le Code | |||||
| 90 | ||||||
| 91 | #r egion Main method | |||||
| 92 | ||||||
| 93 | // / <summary > | |||||
| 94 | // / Standard Main() me thod used by most SD K samples. | |||||
| 95 | // / </summar y> | |||||
| 96 | // / <param n ame="args" ></param> | |||||
| 97 | st atic publi c void Mai n(string[] args) | |||||
| 98 | { | |||||
| 99 | try | |||||
| 100 | { | |||||
| 101 | // O btain the target org anization' s web addr ess and cl ient logon | |||||
| 102 | // c redentials from the user. | |||||
| 103 | Serv erConnecti on serverC onnect = n ew ServerC onnection( ); | |||||
| 104 | Serv erConnecti on.Configu ration con fig = serv erConnect. GetServerC onfigurati on(); | |||||
| 105 | ||||||
| 106 | Retr ieveRolesF orOrg app = new Retr ieveRolesF orOrg(); | |||||
| 107 | app. Run( confi g, true ); | |||||
| 108 | } | |||||
| 109 | catch (F aultExcept ion<Micros oft.Xrm.Sd k.Organiza tionServic eFault> ex ) | |||||
| 110 | { | |||||
| 111 | Cons ole.WriteL ine("The a pplication terminate d with an error."); | |||||
| 112 | Cons ole.WriteL ine("Times tamp: {0}" , ex.Detai l.Timestam p); | |||||
| 113 | Cons ole.WriteL ine("Code: {0}", ex. Detail.Err orCode); | |||||
| 114 | Cons ole.WriteL ine("Messa ge: {0}", ex.Detail. Message); | |||||
| 115 | Cons ole.WriteL ine("Trace : {0}", ex .Detail.Tr aceText); | |||||
| 116 | Cons ole.WriteL ine("Inner Fault: {0 }", | |||||
| 117 | null == ex .Detail.In nerFault ? "No Inner Fault" : "Has Inner Fault"); | |||||
| 118 | } | |||||
| 119 | catch (S ystem.Time outExcepti on ex) | |||||
| 120 | { | |||||
| 121 | Cons ole.WriteL ine("The a pplication terminate d with an error."); | |||||
| 122 | Cons ole.WriteL ine("Messa ge: {0}", ex.Message ); | |||||
| 123 | Cons ole.WriteL ine("Stack Trace: {0 }", ex.Sta ckTrace); | |||||
| 124 | Cons ole.WriteL ine("Inner Fault: {0 }", | |||||
| 125 | null == ex .InnerExce ption.Mess age ? "No Inner Faul t" : ex.In nerExcepti on.Message ); | |||||
| 126 | } | |||||
| 127 | catch (S ystem.Exce ption ex) | |||||
| 128 | { | |||||
| 129 | Cons ole.WriteL ine("The a pplication terminate d with an error."); | |||||
| 130 | Cons ole.WriteL ine(ex.Mes sage); | |||||
| 131 | ||||||
| 132 | // D isplay the details o f the inne r exceptio n. | |||||
| 133 | if ( ex.InnerEx ception != null) | |||||
| 134 | { | |||||
| 135 | Console.Wr iteLine(ex .InnerExce ption.Mess age); | |||||
| 136 | ||||||
| 137 | FaultExcep tion<Micro soft.Xrm.S dk.Organiz ationServi ceFault> f e = ex.Inn erExceptio n | |||||
| 138 | as Fau ltExceptio n<Microsof t.Xrm.Sdk. Organizati onServiceF ault>; | |||||
| 139 | if (fe != null) | |||||
| 140 | { | |||||
| 141 | Consol e.WriteLin e("Timesta mp: {0}", fe.Detail. Timestamp) ; | |||||
| 142 | Consol e.WriteLin e("Code: { 0}", fe.De tail.Error Code); | |||||
| 143 | Consol e.WriteLin e("Message : {0}", fe .Detail.Me ssage); | |||||
| 144 | Consol e.WriteLin e("Trace: {0}", fe.D etail.Trac eText); | |||||
| 145 | Consol e.WriteLin e("Inner F ault: {0}" , | |||||
| 146 | nu ll == fe.D etail.Inne rFault ? " No Inner F ault" : "H as Inner F ault"); | |||||
| 147 | } | |||||
| 148 | } | |||||
| 149 | } | |||||
| 150 | // Addit ional exce ptions to catch: Sec urityToken Validation Exception, ExpiredSe curityToke nException , | |||||
| 151 | // Secur ityAccessD eniedExcep tion, Mess ageSecurit yException , and Secu rityNegoti ationExcep tion. | |||||
| 152 | finally | |||||
| 153 | { | |||||
| 154 | Cons ole.WriteL ine("Press <Enter> t o exit."); | |||||
| 155 | Cons ole.ReadLi ne(); | |||||
| 156 | } | |||||
| 157 | } | |||||
| 158 | #e ndregion M ain method | |||||
| 159 | } | |||||
| 160 | } | |||||
| 161 | //</snippe tRetrieveR olesForOrg > | |||||
| 162 |
Araxis Merge (but not the data content of this report) is Copyright © 1993-2016 Araxis Ltd (www.araxis.com). All rights reserved.