Produced by Araxis Merge on 2/1/2017 2:56:55 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\SharePointIntegration | RetrieveAbsoluteAndSiteCollectionURLs.cs | Tue Dec 20 19:51:45 2016 UTC |
| 2 | Wed Feb 1 19:56:55 2017 UTC |
| Description | Between Files 1 and 2 |
|
|---|---|---|
| Text Blocks | Lines | |
| Unchanged | 0 | 0 |
| Changed | 0 | 0 |
| Inserted | 0 | 0 |
| Removed | 1 | 233 |
| 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 2011 SDK code samp les. | |||||
| 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 RetrieveAb soluteAndS iteCollect ionURLs> | |||||
| 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 | ||||||
| 27 | // This na mespace is found in the Micros oft.Crm.Sd k.Proxy.dl l assembly | |||||
| 28 | // located in the SD K\bin fold er of the SDK downlo ad. | |||||
| 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 re trieve the absolute URL and th e parent | |||||
| 35 | /// si te collect ion URL of a SharePo int locati on record. </summary> | |||||
| 36 | /// <r emarks> | |||||
| 37 | /// At run-time, you will be given t he option to delete all the | |||||
| 38 | /// da tabase rec ords creat ed by this program.< /remarks> | |||||
| 39 | public class Ret rieveAbsol uteAndSite Collection URLs | |||||
| 40 | { | |||||
| 41 | #r egion Clas s Level Me mbers | |||||
| 42 | ||||||
| 43 | pr ivate Guid _spSiteId ; | |||||
| 44 | pr ivate Guid _spDocLoc Id; | |||||
| 45 | pr ivate Orga nizationSe rviceProxy _serviceP roxy; | |||||
| 46 | ||||||
| 47 | // TODO: App ropriately change th e absolute URL of th e SharePoi nt site | |||||
| 48 | // record. | |||||
| 49 | pr ivate Stri ng _siteAb soluteURL = "http:// www.exampl e.com"; | |||||
| 50 | ||||||
| 51 | #e ndregion C lass Level Members | |||||
| 52 | ||||||
| 53 | #r egion How- To Sample Code | |||||
| 54 | // / <summary > | |||||
| 55 | // / This met hod first connects t o the Orga nization s ervice. Af terwards, | |||||
| 56 | // / retrieve s the abso lute URL a nd the par ent site c ollection URL of a | |||||
| 57 | // / SharePoi nt documen t location record. | |||||
| 58 | // / </summar y> | |||||
| 59 | // / <param n ame="serve rConfig">C ontains se rver conne ction info rmation.</ param> | |||||
| 60 | // / <param n ame="promp tforDelete ">When Tru e, the use r will be prompted t o delete a ll | |||||
| 61 | // / created entities.< /param> | |||||
| 62 | pu blic void Run(Server Connection .Configura tion serve rConfig, b ool prompt forDelete) | |||||
| 63 | { | |||||
| 64 | try | |||||
| 65 | { | |||||
| 66 | //<s nippetRetr ieveAbsolu teAndSiteC ollectionU RLs1> | |||||
| 67 | // C onnect to the Organi zation ser vice. | |||||
| 68 | // T he using s tatement a ssures tha t the serv ice proxy will be pr operly dis posed. | |||||
| 69 | 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 )) | |||||
| 70 | { | |||||
| 71 | // This st atement is required to enable early-boun d type sup port. | |||||
| 72 | _servicePr oxy.Enable ProxyTypes (); | |||||
| 73 | ||||||
| 74 | CreateRequ iredRecord s(); | |||||
| 75 | //<snippet RetrieveAb soluteAndS iteCollect ionURLs2> | |||||
| 76 | // Retriev e the abso lute URL a nd the Sit e Collecti on URL | |||||
| 77 | // of the SharePoint document location r ecord. | |||||
| 78 | RetrieveAb soluteAndS iteCollect ionUrlRequ est retrie veRequest = new Retr ieveAbsolu teAndSiteC ollectionU rlRequest | |||||
| 79 | { | |||||
| 80 | Target = new Ent ityReferen ce(SharePo intDocumen tLocation. EntityLogi calName, _ spDocLocId ) | |||||
| 81 | }; | |||||
| 82 | RetrieveAb soluteAndS iteCollect ionUrlResp onse retri veResponse = (Retrie veAbsolute AndSiteCol lectionUrl Response)_ servicePro xy.Execute (retrieveR equest); | |||||
| 83 | ||||||
| 84 | Console.Wr iteLine("A bsolute UR L of docum ent locati on record is '{0}'." , retriveR esponse.Ab soluteUrl. ToString() ); | |||||
| 85 | Console.Wr iteLine("S ite Collec tion URL o f document location record is '{0}'.", r etriveResp onse.SiteC ollectionU rl.ToStrin g()); | |||||
| 86 | //</snippe tRetrieveA bsoluteAnd SiteCollec tionURLs2> | |||||
| 87 | DeleteRequ iredRecord s(promptfo rDelete); | |||||
| 88 | } | |||||
| 89 | //</ snippetRet rieveAbsol uteAndSite Collection URLs1> | |||||
| 90 | } | |||||
| 91 | ||||||
| 92 | // Catch any servi ce fault e xceptions that Micro soft Dynam ics CRM th rows. | |||||
| 93 | catch (F aultExcept ion<Micros oft.Xrm.Sd k.Organiza tionServic eFault>) | |||||
| 94 | { | |||||
| 95 | // Y ou can han dle an exc eption her e or pass it back to the calli ng method. | |||||
| 96 | thro w; | |||||
| 97 | } | |||||
| 98 | } | |||||
| 99 | ||||||
| 100 | // / <summary > | |||||
| 101 | // / Creates any entity records t hat this s ample requ ires. | |||||
| 102 | // / </summar y> | |||||
| 103 | pu blic void CreateRequ iredRecord s() | |||||
| 104 | { | |||||
| 105 | // Insta ntiate a S harePoint site objec t. | |||||
| 106 | // See t he Entity Metadata t opic in th e SDK docu mentation to determi ne | |||||
| 107 | // which attribute s must be set for ea ch entity. | |||||
| 108 | SharePoi ntSite spS ite = new SharePoint Site | |||||
| 109 | { | |||||
| 110 | Name = "Sample SharePoin t Site", | |||||
| 111 | Desc ription = "Sample Sh arePoint S ite Locati on record" , | |||||
| 112 | Abso luteURL = _siteAbsol uteURL, | |||||
| 113 | IsGr idPresent = true | |||||
| 114 | }; | |||||
| 115 | ||||||
| 116 | // Creat e a ShareP oint site record nam ed Sample SharePoint Site. | |||||
| 117 | _spSiteI d = _servi ceProxy.Cr eate(spSit e); | |||||
| 118 | Console. WriteLine( "{0} creat ed.", spSi te.Name); | |||||
| 119 | ||||||
| 120 | // Insta ntiate a S harePoint document l ocation ob ject. | |||||
| 121 | // See t he Entity Metadata t opic in th e SDK docu mentation to determi ne | |||||
| 122 | // which attribute s must be set for ea ch entity. | |||||
| 123 | SharePoi ntDocument Location s pDocLoc = new ShareP ointDocume ntLocation | |||||
| 124 | { | |||||
| 125 | Name = "Sample SharePoin t Document Location" , | |||||
| 126 | Desc ription = "Sample Sh arePoint D ocument Lo cation rec ord", | |||||
| 127 | ||||||
| 128 | // S et the Sam ple ShareP oint Site created ea rlier as t he parent site. | |||||
| 129 | Pare ntSiteOrLo cation = n ew EntityR eference(S harePointS ite.Entity LogicalNam e, _spSite Id), | |||||
| 130 | Rela tiveUrl = "spdocloc" | |||||
| 131 | }; | |||||
| 132 | ||||||
| 133 | // Creat e a ShareP oint docum ent locati on record named Samp le SharePo int Docume nt Locatio n. | |||||
| 134 | _spDocLo cId = _ser viceProxy. Create(spD ocLoc); | |||||
| 135 | Console. WriteLine( "{0} creat ed.", spDo cLoc.Name) ; | |||||
| 136 | } | |||||
| 137 | ||||||
| 138 | // / <summary > | |||||
| 139 | // / Deletes any entity records t hat were c reated for this samp le. | |||||
| 140 | // / <param n ame="promp t">Indicat es whether to prompt the user | |||||
| 141 | // / to delet e the reco rds create d in this sample.</p aram> | |||||
| 142 | // / </summar y> | |||||
| 143 | pu blic void DeleteRequ iredRecord s(bool pro mpt) | |||||
| 144 | { | |||||
| 145 | bool del eteRecords = true; | |||||
| 146 | ||||||
| 147 | if (prom pt) | |||||
| 148 | { | |||||
| 149 | Cons ole.WriteL ine("\nDo you want t hese entit y records deleted? ( y/n) [y]: "); | |||||
| 150 | Stri ng answer = Console. ReadLine() ; | |||||
| 151 | ||||||
| 152 | dele teRecords = (answer. StartsWith ("y") || a nswer.Star tsWith("Y" ) || answe r == Strin g.Empty); | |||||
| 153 | } | |||||
| 154 | ||||||
| 155 | if (dele teRecords) | |||||
| 156 | { | |||||
| 157 | _ser viceProxy. Delete(Sha rePointDoc umentLocat ion.Entity LogicalNam e, _spDocL ocId); | |||||
| 158 | _ser viceProxy. Delete(Sha rePointSit e.EntityLo gicalName, _spSiteId ); | |||||
| 159 | Cons ole.WriteL ine("Entit y records have been deleted.") ; | |||||
| 160 | } | |||||
| 161 | } | |||||
| 162 | ||||||
| 163 | #e ndregion H ow-To Samp le Code | |||||
| 164 | ||||||
| 165 | #r egion Main method | |||||
| 166 | ||||||
| 167 | // / <summary > | |||||
| 168 | // / Standard Main() me thod used by most SD K samples. | |||||
| 169 | // / </summar y> | |||||
| 170 | // / <param n ame="args" ></param> | |||||
| 171 | st atic publi c void Mai n(string[] args) | |||||
| 172 | { | |||||
| 173 | try | |||||
| 174 | { | |||||
| 175 | // O btain the target org anization' s Web addr ess and cl ient logon | |||||
| 176 | // c redentials from the user. | |||||
| 177 | Serv erConnecti on serverC onnect = n ew ServerC onnection( ); | |||||
| 178 | Serv erConnecti on.Configu ration con fig = serv erConnect. GetServerC onfigurati on(); | |||||
| 179 | ||||||
| 180 | Retr ieveAbsolu teAndSiteC ollectionU RLs app = new Retrie veAbsolute AndSiteCol lectionURL s(); | |||||
| 181 | app. Run(config , true); | |||||
| 182 | } | |||||
| 183 | catch (F aultExcept ion<Micros oft.Xrm.Sd k.Organiza tionServic eFault> ex ) | |||||
| 184 | { | |||||
| 185 | Cons ole.WriteL ine("The a pplication terminate d with an error."); | |||||
| 186 | Cons ole.WriteL ine("Times tamp: {0}" , ex.Detai l.Timestam p); | |||||
| 187 | Cons ole.WriteL ine("Code: {0}", ex. Detail.Err orCode); | |||||
| 188 | Cons ole.WriteL ine("Messa ge: {0}", ex.Detail. Message); | |||||
| 189 | Cons ole.WriteL ine("Plugi n Trace: { 0}", ex.De tail.Trace Text); | |||||
| 190 | Cons ole.WriteL ine("Inner Fault: {0 }", | |||||
| 191 | null == ex .Detail.In nerFault ? "No Inner Fault" : "Has Inner Fault"); | |||||
| 192 | } | |||||
| 193 | catch (S ystem.Time outExcepti on ex) | |||||
| 194 | { | |||||
| 195 | Cons ole.WriteL ine("The a pplication terminate d with an error."); | |||||
| 196 | Cons ole.WriteL ine("Messa ge: {0}", ex.Message ); | |||||
| 197 | Cons ole.WriteL ine("Stack Trace: {0 }", ex.Sta ckTrace); | |||||
| 198 | Cons ole.WriteL ine("Inner Fault: {0 }", | |||||
| 199 | null == ex .InnerExce ption.Mess age ? "No Inner Faul t" : ex.In nerExcepti on.Message ); | |||||
| 200 | } | |||||
| 201 | catch (S ystem.Exce ption ex) | |||||
| 202 | { | |||||
| 203 | Cons ole.WriteL ine("The a pplication terminate d with an error."); | |||||
| 204 | Cons ole.WriteL ine(ex.Mes sage); | |||||
| 205 | ||||||
| 206 | // D isplay the details o f the inne r exceptio n. | |||||
| 207 | if ( ex.InnerEx ception != null) | |||||
| 208 | { | |||||
| 209 | Console.Wr iteLine(ex .InnerExce ption.Mess age); | |||||
| 210 | ||||||
| 211 | FaultExcep tion<Micro soft.Xrm.S dk.Organiz ationServi ceFault> f e = ex.Inn erExceptio n | |||||
| 212 | as Fau ltExceptio n<Microsof t.Xrm.Sdk. Organizati onServiceF ault>; | |||||
| 213 | if (fe != null) | |||||
| 214 | { | |||||
| 215 | Consol e.WriteLin e("Timesta mp: {0}", fe.Detail. Timestamp) ; | |||||
| 216 | Consol e.WriteLin e("Code: { 0}", fe.De tail.Error Code); | |||||
| 217 | Consol e.WriteLin e("Message : {0}", fe .Detail.Me ssage); | |||||
| 218 | Consol e.WriteLin e("Plugin Trace: {0} ", fe.Deta il.TraceTe xt); | |||||
| 219 | Consol e.WriteLin e("Inner F ault: {0}" , | |||||
| 220 | nu ll == fe.D etail.Inne rFault ? " No Inner F ault" : "H as Inner F ault"); | |||||
| 221 | } | |||||
| 222 | } | |||||
| 223 | } | |||||
| 224 | finally | |||||
| 225 | { | |||||
| 226 | Cons ole.WriteL ine("Press <Enter> t o exit."); | |||||
| 227 | Cons ole.ReadLi ne(); | |||||
| 228 | } | |||||
| 229 | } | |||||
| 230 | #e ndregion M ain method | |||||
| 231 | } | |||||
| 232 | } | |||||
| 233 | //</snippe tRetrieveA bsoluteAnd SiteCollec tionURLs> |
Araxis Merge (but not the data content of this report) is Copyright © 1993-2016 Araxis Ltd (www.araxis.com). All rights reserved.