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\DiscoveryService | DiscoveryService.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 | 214 |
| 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 DiscoveryS ervice> | |||||
| 17 | using Syst em; | |||||
| 18 | using Syst em.Collect ions.Gener ic; | |||||
| 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.Client ; | |||||
| 24 | using Micr osoft.Xrm. Sdk.Discov ery; | |||||
| 25 | ||||||
| 26 | namespace Microsoft. Crm.Sdk.Sa mples | |||||
| 27 | { | |||||
| 28 | /// <s ummary> | |||||
| 29 | /// De monstrates useful me ssages of the Discov ery servic e. | |||||
| 30 | /// </ summary> | |||||
| 31 | public class Dis coveryServ ice | |||||
| 32 | { | |||||
| 33 | ||||||
| 34 | #r egion Clas s Level Me mbers | |||||
| 35 | ||||||
| 36 | pr ivate Disc overyServi ceProxy _s erviceProx y; | |||||
| 37 | ||||||
| 38 | #e ndregion C lass Level Members | |||||
| 39 | ||||||
| 40 | #r egion How- To Sample Code | |||||
| 41 | // / <summary > | |||||
| 42 | // / Demonstr ates the R etrieveOrg anization and Retrie veOrganiza tions mess ages | |||||
| 43 | // / of the D iscovery s ervice. | |||||
| 44 | // / </summar y> | |||||
| 45 | // / <param n ame="serve rConfig">C ontains se rver conne ction info rmation.</ param> | |||||
| 46 | // / <param n ame="promp tforDelete ">When Tru e, the use r will be prompted t o delete a ll | |||||
| 47 | // / created entities.< /param> | |||||
| 48 | pu blic void Run(Server Connection .Configura tion serve rConfig, b ool prompt forDelete) | |||||
| 49 | { | |||||
| 50 | try | |||||
| 51 | { | |||||
| 52 | //<s nippetDisc overyServi ce1> | |||||
| 53 | // C onnect to the Discov ery servic e. | |||||
| 54 | // T he using s tatement a ssures tha t the serv ice proxy will be pr operly dis posed. | |||||
| 55 | usin g (_servic eProxy = n ew Discove ryServiceP roxy(serve rConfig.Di scoveryUri , | |||||
| 56 | se rverConfig .HomeRealm Uri, | |||||
| 57 | se rverConfig .Credentia ls, | |||||
| 58 | se rverConfig .DeviceCre dentials)) | |||||
| 59 | { | |||||
| 60 | // You can choose to use the i nterface i nstead of the proxy. | |||||
| 61 | IDiscovery Service se rvice = _s erviceProx y; | |||||
| 62 | ||||||
| 63 | #region Re trieveOrga nizations Message | |||||
| 64 | ||||||
| 65 | //<snippet DiscoveryS ervice2> | |||||
| 66 | // Retriev e details about all organizati ons discov erable via the | |||||
| 67 | // Discove ry service . | |||||
| 68 | RetrieveOr ganization sRequest o rgsRequest = | |||||
| 69 | new Re trieveOrga nizationsR equest() | |||||
| 70 | { | |||||
| 71 | Ac cessType = EndpointA ccessType. Default, | |||||
| 72 | Re lease = Or ganization Release.Cu rrent | |||||
| 73 | }; | |||||
| 74 | RetrieveOr ganization sResponse organizati ons = | |||||
| 75 | (Retri eveOrganiz ationsResp onse)servi ce.Execute (orgsReque st); | |||||
| 76 | //</snippe tDiscovery Service2> | |||||
| 77 | ||||||
| 78 | // Print e ach organi zation's f riendly na me, unique name and URLs | |||||
| 79 | // for eac h of its e ndpoints. | |||||
| 80 | Console.Wr iteLine(); | |||||
| 81 | Console.Wr iteLine("R etrieving details of each orga nization:" ); | |||||
| 82 | foreach (O rganizatio nDetail or ganization in organi zations.De tails) | |||||
| 83 | { | |||||
| 84 | Consol e.WriteLin e("Organiz ation Name : {0}", or ganization .FriendlyN ame); | |||||
| 85 | Consol e.WriteLin e("Unique Name: {0}" , organiza tion.Uniqu eName); | |||||
| 86 | Consol e.WriteLin e("Endpoin ts:"); | |||||
| 87 | foreac h (var end point in o rganizatio n.Endpoint s) | |||||
| 88 | { | |||||
| 89 | Co nsole.Writ eLine(" N ame: {0}", endpoint. Key); | |||||
| 90 | Co nsole.Writ eLine(" U RL: {0}", endpoint.V alue); | |||||
| 91 | } | |||||
| 92 | } | |||||
| 93 | Console.Wr iteLine("E nd of list ing"); | |||||
| 94 | Console.Wr iteLine(); | |||||
| 95 | ||||||
| 96 | #endregion RetrieveO rganizatio ns Message | |||||
| 97 | ||||||
| 98 | #region Re trieveOrga nization M essage | |||||
| 99 | ||||||
| 100 | //<snippet DiscoveryS ervice3> | |||||
| 101 | // Retriev e details about a si ngle organ ization di scoverable via the D iscovery s ervice. | |||||
| 102 | // | |||||
| 103 | RetrieveOr ganization Request or gRequest = | |||||
| 104 | new Re trieveOrga nizationRe quest() | |||||
| 105 | { | |||||
| 106 | Un iqueName = organizat ions.Detai ls[organiz ations.Det ails.Count -1].Uniqu eName, | |||||
| 107 | Ac cessType = EndpointA ccessType. Default, | |||||
| 108 | Re lease = Or ganization Release.Cu rrent | |||||
| 109 | }; | |||||
| 110 | RetrieveOr ganization Response o rg = | |||||
| 111 | (Retri eveOrganiz ationRespo nse)servic e.Execute( orgRequest ); | |||||
| 112 | //</snippe tDiscovery Service3> | |||||
| 113 | ||||||
| 114 | // Print t he organiz ation's fr iendly nam e, unique name and U RLs | |||||
| 115 | // for eac h of its e ndpoints. | |||||
| 116 | Console.Wr iteLine(); | |||||
| 117 | Console.Wr iteLine("R etrieving details of specific organizati on:"); | |||||
| 118 | Console.Wr iteLine("O rganizatio n Name: {0 }", org.De tail.Frien dlyName); | |||||
| 119 | Console.Wr iteLine("U nique Name : {0}", or g.Detail.U niqueName) ; | |||||
| 120 | Console.Wr iteLine("E ndpoints:" ); | |||||
| 121 | foreach (K eyValuePai r<Endpoint Type, stri ng> endpoi nt in org. Detail.End points) | |||||
| 122 | { | |||||
| 123 | Consol e.WriteLin e(" Name: {0}", end point.Key) ; | |||||
| 124 | Consol e.WriteLin e(" URL: {0}", endp oint.Value ); | |||||
| 125 | } | |||||
| 126 | Console.Wr iteLine("E nd of list ing"); | |||||
| 127 | Console.Wr iteLine(); | |||||
| 128 | ||||||
| 129 | #endregion RetrieveO rganizatio n Message | |||||
| 130 | ||||||
| 131 | } | |||||
| 132 | //</ snippetDis coveryServ ice1> | |||||
| 133 | } | |||||
| 134 | ||||||
| 135 | // Catch any servi ce fault e xceptions that Micro soft Dynam ics CRM th rows. | |||||
| 136 | catch (F aultExcept ion<Micros oft.Xrm.Sd k.Discover yServiceFa ult>) | |||||
| 137 | { | |||||
| 138 | // Y ou can han dle an exc eption her e or pass it back to the calli ng method. | |||||
| 139 | thro w; | |||||
| 140 | } | |||||
| 141 | } | |||||
| 142 | ||||||
| 143 | #e ndregion H ow-To Samp le Code | |||||
| 144 | ||||||
| 145 | #r egion Main method | |||||
| 146 | ||||||
| 147 | // / <summary > | |||||
| 148 | // / Standard Main() me thod used by most SD K samples. | |||||
| 149 | // / </summar y> | |||||
| 150 | // / <param n ame="args" ></param> | |||||
| 151 | st atic publi c void Mai n(string[] args) | |||||
| 152 | { | |||||
| 153 | try | |||||
| 154 | { | |||||
| 155 | // O btain the target org anization' s Web addr ess and cl ient logon | |||||
| 156 | // c redentials from the user. | |||||
| 157 | Serv erConnecti on serverC onnect = n ew ServerC onnection( ); | |||||
| 158 | Serv erConnecti on.Configu ration con fig = serv erConnect. GetServerC onfigurati on(); | |||||
| 159 | ||||||
| 160 | Disc overyServi ce app = n ew Discove ryService( ); | |||||
| 161 | app. Run(config , true); | |||||
| 162 | } | |||||
| 163 | catch (F aultExcept ion<Micros oft.Xrm.Sd k.Discover yServiceFa ult> ex) | |||||
| 164 | { | |||||
| 165 | Cons ole.WriteL ine("The a pplication terminate d with an error."); | |||||
| 166 | Cons ole.WriteL ine("Times tamp: {0}" , ex.Detai l.Timestam p); | |||||
| 167 | Cons ole.WriteL ine("Code: {0}", ex. Detail.Err orCode); | |||||
| 168 | Cons ole.WriteL ine("Messa ge: {0}", ex.Detail. Message); | |||||
| 169 | Cons ole.WriteL ine("Inner Fault: {0 }", | |||||
| 170 | null == ex .Detail.In nerFault ? "No Inner Fault" : "Has Inner Fault"); | |||||
| 171 | } | |||||
| 172 | catch (S ystem.Time outExcepti on ex) | |||||
| 173 | { | |||||
| 174 | Cons ole.WriteL ine("The a pplication terminate d with an error."); | |||||
| 175 | Cons ole.WriteL ine("Messa ge: {0}", ex.Message ); | |||||
| 176 | Cons ole.WriteL ine("Stack Trace: {0 }", ex.Sta ckTrace); | |||||
| 177 | Cons ole.WriteL ine("Inner Fault: {0 }", | |||||
| 178 | null == ex .InnerExce ption.Mess age ? "No Inner Faul t" : ex.In nerExcepti on.Message ); | |||||
| 179 | } | |||||
| 180 | catch (S ystem.Exce ption ex) | |||||
| 181 | { | |||||
| 182 | Cons ole.WriteL ine("The a pplication terminate d with an error."); | |||||
| 183 | Cons ole.WriteL ine(ex.Mes sage); | |||||
| 184 | ||||||
| 185 | // D isplay the details o f the inne r exceptio n. | |||||
| 186 | if ( ex.InnerEx ception != null) | |||||
| 187 | { | |||||
| 188 | Console.Wr iteLine(ex .InnerExce ption.Mess age); | |||||
| 189 | ||||||
| 190 | FaultExcep tion<Micro soft.Xrm.S dk.Discove ryServiceF ault> fe = ex.InnerE xception | |||||
| 191 | as Fau ltExceptio n<Microsof t.Xrm.Sdk. DiscoveryS erviceFaul t>; | |||||
| 192 | if (fe != null) | |||||
| 193 | { | |||||
| 194 | Consol e.WriteLin e("Timesta mp: {0}", fe.Detail. Timestamp) ; | |||||
| 195 | Consol e.WriteLin e("Code: { 0}", fe.De tail.Error Code); | |||||
| 196 | Consol e.WriteLin e("Message : {0}", fe .Detail.Me ssage); | |||||
| 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 | #e ndregion M ain method | |||||
| 212 | } | |||||
| 213 | } | |||||
| 214 | //</snippe tDiscovery Service> |
Araxis Merge (but not the data content of this report) is Copyright © 1993-2016 Araxis Ltd (www.araxis.com). All rights reserved.