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 | EnableDocumentManagement.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 | 253 |
| 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 EnableDocu mentManage ment> | |||||
| 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.Client ; | |||||
| 25 | using Micr osoft.Xrm. Sdk.Query; | |||||
| 26 | using Micr osoft.Xrm. Sdk.Messag es; | |||||
| 27 | using Micr osoft.Xrm. Sdk.Metada ta; | |||||
| 28 | ||||||
| 29 | // This na mespace is found in the Micros oft.Crm.Sd k.Proxy.dl l assembly | |||||
| 30 | // located in the SD K\bin fold er of the SDK downlo ad. | |||||
| 31 | using Micr osoft.Crm. Sdk.Messag es; | |||||
| 32 | ||||||
| 33 | namespace Microsoft. Crm.Sdk.Sa mples | |||||
| 34 | { | |||||
| 35 | /// <s ummary> | |||||
| 36 | /// De monstrates how to en able docum ent manage ment | |||||
| 37 | /// fo r an entit y.</summar y> | |||||
| 38 | /// <r emarks> | |||||
| 39 | /// At run-time, you will be given t he option to revert | |||||
| 40 | /// th e changes done by th is program .</remarks > | |||||
| 41 | public class Ena bleDocumen tManagemen t | |||||
| 42 | { | |||||
| 43 | #r egion Clas s Level Me mbers | |||||
| 44 | ||||||
| 45 | pr ivate Orga nizationSe rviceProxy _serviceP roxy; | |||||
| 46 | ||||||
| 47 | #e ndregion C lass Level Members | |||||
| 48 | ||||||
| 49 | #r egion How- To Sample Code | |||||
| 50 | // / <summary > | |||||
| 51 | // / This met hod first connects t o the Orga nization s ervice. Af terwards, | |||||
| 52 | // / retrieve s the Cont act entity record, a nd then en ables the document m anagement | |||||
| 53 | // / for the entity. | |||||
| 54 | // / </summar y> | |||||
| 55 | // / <param n ame="serve rConfig">C ontains se rver conne ction info rmation.</ param> | |||||
| 56 | // / <param n ame="promp tforRevert ">When Tru e, the use r will be prompted t o revert a ll | |||||
| 57 | // / the chan ges done i n this sam ple.</para m> | |||||
| 58 | pu blic void Run(Server Connection .Configura tion serve rConfig, b ool prompt forRevert) | |||||
| 59 | { | |||||
| 60 | try | |||||
| 61 | { | |||||
| 62 | // C onnect to the Organi zation ser vice. | |||||
| 63 | // T he using s tatement a ssures tha t the serv ice proxy will be pr operly dis posed. | |||||
| 64 | 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 )) | |||||
| 65 | { | |||||
| 66 | // This st atement is required to enable early-boun d type sup port. | |||||
| 67 | _servicePr oxy.Enable ProxyTypes (); | |||||
| 68 | ||||||
| 69 | CreateRequ iredRecord s(); | |||||
| 70 | ||||||
| 71 | //<snippet EnableDocu mentManage ment1> | |||||
| 72 | // Retriev e an entit y for whic h you want to enable document management . | |||||
| 73 | // In this sample, w e will ret rieve and enable doc ument mana gement | |||||
| 74 | // for the Contact e ntity beca use by def ault, docu ment manag ement is | |||||
| 75 | // not ena bled for t his entity . | |||||
| 76 | ||||||
| 77 | RetrieveEn tityReques t entityRe quest = ne w Retrieve EntityRequ est | |||||
| 78 | { | |||||
| 79 | Entity Filters = EntityFilt ers.All, | |||||
| 80 | Logica lName = Co ntact.Enti tyLogicalN ame, | |||||
| 81 | ||||||
| 82 | // Ret rieve only the curre ntly publi shed chang es, ignori ng the cha nges | |||||
| 83 | // tha t have not been publ ished. | |||||
| 84 | Retrie veAsIfPubl ished = fa lse | |||||
| 85 | }; | |||||
| 86 | RetrieveEn tityRespon se entityR esponse = (RetrieveE ntityRespo nse)_servi ceProxy.Ex ecute(enti tyRequest) ; | |||||
| 87 | Console.Wr iteLine("R etrieved t he contact entity.") ; | |||||
| 88 | ||||||
| 89 | // Get the entity fr om the res ponse. | |||||
| 90 | EntityMeta data conta ctEntity = entityRes ponse.Enti tyMetadata ; | |||||
| 91 | ||||||
| 92 | // Enable document m anagement for the re trieved en tity. | |||||
| 93 | contactEnt ity.IsDocu mentManage mentEnable d = true; | |||||
| 94 | ||||||
| 95 | // Create an update request. | |||||
| 96 | UpdateEnti tyRequest updateRequ est = new UpdateEnti tyRequest | |||||
| 97 | { | |||||
| 98 | Entity = contact Entity | |||||
| 99 | }; | |||||
| 100 | _servicePr oxy.Execut e(updateRe quest); | |||||
| 101 | ||||||
| 102 | // Publish the entit y. | |||||
| 103 | // All cus tomization s must be published before the y can be u sed. | |||||
| 104 | PublishAll XmlRequest enableReq uest = new PublishAl lXmlReques t(); | |||||
| 105 | _servicePr oxy.Execut e(enableRe quest); | |||||
| 106 | ||||||
| 107 | // Retriev e the cont act entity , and veri fy that do cument man agement is enabled. | |||||
| 108 | entityResp onse = (Re trieveEnti tyResponse )_serviceP roxy.Execu te(entityR equest); | |||||
| 109 | contactEnt ity = enti tyResponse .EntityMet adata; | |||||
| 110 | if (contac tEntity.Is DocumentMa nagementEn abled.Valu e == true) | |||||
| 111 | { | |||||
| 112 | Consol e.WriteLin e("Enabled document management for the c ontact ent ity."); | |||||
| 113 | } | |||||
| 114 | ||||||
| 115 | RevertChan ges(prompt forRevert) ; | |||||
| 116 | / /</snippet EnableDocu mentManage ment1> | |||||
| 117 | } | |||||
| 118 | ||||||
| 119 | } | |||||
| 120 | ||||||
| 121 | // Catch any servi ce fault e xceptions that Micro soft Dynam ics CRM th rows. | |||||
| 122 | catch (F aultExcept ion<Micros oft.Xrm.Sd k.Organiza tionServic eFault>) | |||||
| 123 | { | |||||
| 124 | // Y ou can han dle an exc eption her e or pass it back to the calli ng method. | |||||
| 125 | thro w; | |||||
| 126 | } | |||||
| 127 | } | |||||
| 128 | ||||||
| 129 | // / <summary > | |||||
| 130 | // / Creates any entity records t hat this s ample requ ires. | |||||
| 131 | // / </summar y> | |||||
| 132 | pu blic void CreateRequ iredRecord s() | |||||
| 133 | { | |||||
| 134 | // For t his sample , no entit ies are cr eated. | |||||
| 135 | } | |||||
| 136 | ||||||
| 137 | // / <summary > | |||||
| 138 | // / Reverts any change s that wer e done by this sampl e. | |||||
| 139 | // / <param n ame="promp t">Indicat es whether to prompt the user | |||||
| 140 | // / to rever t the chan ges done b y this sam ple.</para m> | |||||
| 141 | // / </summar y> | |||||
| 142 | pu blic void RevertChan ges(bool p rompt) | |||||
| 143 | { | |||||
| 144 | bool rev ertChanges = true; | |||||
| 145 | ||||||
| 146 | if (prom pt) | |||||
| 147 | { | |||||
| 148 | Cons ole.WriteL ine("\nDo you want t hese chang es reverte d? (y/n) [ y]: "); | |||||
| 149 | Stri ng answer = Console. ReadLine() ; | |||||
| 150 | ||||||
| 151 | reve rtChanges = (answer. StartsWith ("y") || a nswer.Star tsWith("Y" ) || answe r == Strin g.Empty); | |||||
| 152 | } | |||||
| 153 | ||||||
| 154 | if (reve rtChanges) | |||||
| 155 | { | |||||
| 156 | Retr ieveEntity Request en tityReques t = new Re trieveEnti tyRequest | |||||
| 157 | { | |||||
| 158 | EntityFilt ers = Enti tyFilters. All, | |||||
| 159 | LogicalNam e = Contac t.EntityLo gicalName, | |||||
| 160 | RetrieveAs IfPublishe d = false | |||||
| 161 | }; | |||||
| 162 | Retr ieveEntity Response e ntityRespo nse = (Ret rieveEntit yResponse) _servicePr oxy.Execut e(entityRe quest); | |||||
| 163 | ||||||
| 164 | Enti tyMetadata contactEn tity = ent ityRespons e.EntityMe tadata; | |||||
| 165 | ||||||
| 166 | // D isable doc ument mana gement for the retri eved entit y. | |||||
| 167 | cont actEntity. IsDocument Management Enabled = false; | |||||
| 168 | ||||||
| 169 | Upda teEntityRe quest upda teRequest = new Upda teEntityRe quest | |||||
| 170 | { | |||||
| 171 | Entity = c ontactEnti ty | |||||
| 172 | }; | |||||
| 173 | _ser viceProxy. Execute(up dateReques t); | |||||
| 174 | ||||||
| 175 | // P ublish the customiza tions to t he entity. | |||||
| 176 | Publ ishAllXmlR equest dis ableReques t = new Pu blishAllXm lRequest() ; | |||||
| 177 | _ser viceProxy. Execute(di sableReque st); | |||||
| 178 | ||||||
| 179 | Cons ole.WriteL ine("Chang es have be en reverte d."); | |||||
| 180 | } | |||||
| 181 | } | |||||
| 182 | ||||||
| 183 | #e ndregion H ow-To Samp le Code | |||||
| 184 | ||||||
| 185 | #r egion Main method | |||||
| 186 | ||||||
| 187 | // / <summary > | |||||
| 188 | // / Standard Main() me thod used by most SD K samples. | |||||
| 189 | // / </summar y> | |||||
| 190 | // / <param n ame="args" ></param> | |||||
| 191 | st atic publi c void Mai n(string[] args) | |||||
| 192 | { | |||||
| 193 | try | |||||
| 194 | { | |||||
| 195 | // O btain the target org anization' s Web addr ess and cl ient logon | |||||
| 196 | // c redentials from the user. | |||||
| 197 | Serv erConnecti on serverC onnect = n ew ServerC onnection( ); | |||||
| 198 | Serv erConnecti on.Configu ration con fig = serv erConnect. GetServerC onfigurati on(); | |||||
| 199 | ||||||
| 200 | Enab leDocument Management app = new EnableDoc umentManag ement(); | |||||
| 201 | app. Run(config , true); | |||||
| 202 | } | |||||
| 203 | catch (F aultExcept ion<Micros oft.Xrm.Sd k.Organiza tionServic eFault> ex ) | |||||
| 204 | { | |||||
| 205 | Cons ole.WriteL ine("The a pplication terminate d with an error."); | |||||
| 206 | Cons ole.WriteL ine("Times tamp: {0}" , ex.Detai l.Timestam p); | |||||
| 207 | Cons ole.WriteL ine("Code: {0}", ex. Detail.Err orCode); | |||||
| 208 | Cons ole.WriteL ine("Messa ge: {0}", ex.Detail. Message); | |||||
| 209 | Cons ole.WriteL ine("Plugi n Trace: { 0}", ex.De tail.Trace Text); | |||||
| 210 | Cons ole.WriteL ine("Inner Fault: {0 }", | |||||
| 211 | null == ex .Detail.In nerFault ? "No Inner Fault" : "Has Inner Fault"); | |||||
| 212 | } | |||||
| 213 | catch (S ystem.Time outExcepti on ex) | |||||
| 214 | { | |||||
| 215 | Cons ole.WriteL ine("The a pplication terminate d with an error."); | |||||
| 216 | Cons ole.WriteL ine("Messa ge: {0}", ex.Message ); | |||||
| 217 | Cons ole.WriteL ine("Stack Trace: {0 }", ex.Sta ckTrace); | |||||
| 218 | Cons ole.WriteL ine("Inner Fault: {0 }", | |||||
| 219 | null == ex .InnerExce ption.Mess age ? "No Inner Faul t" : ex.In nerExcepti on.Message ); | |||||
| 220 | } | |||||
| 221 | catch (S ystem.Exce ption ex) | |||||
| 222 | { | |||||
| 223 | Cons ole.WriteL ine("The a pplication terminate d with an error."); | |||||
| 224 | Cons ole.WriteL ine(ex.Mes sage); | |||||
| 225 | ||||||
| 226 | // D isplay the details o f the inne r exceptio n. | |||||
| 227 | if ( ex.InnerEx ception != null) | |||||
| 228 | { | |||||
| 229 | Console.Wr iteLine(ex .InnerExce ption.Mess age); | |||||
| 230 | ||||||
| 231 | FaultExcep tion<Micro soft.Xrm.S dk.Organiz ationServi ceFault> f e = ex.Inn erExceptio n | |||||
| 232 | as Fau ltExceptio n<Microsof t.Xrm.Sdk. Organizati onServiceF ault>; | |||||
| 233 | if (fe != null) | |||||
| 234 | { | |||||
| 235 | Consol e.WriteLin e("Timesta mp: {0}", fe.Detail. Timestamp) ; | |||||
| 236 | Consol e.WriteLin e("Code: { 0}", fe.De tail.Error Code); | |||||
| 237 | Consol e.WriteLin e("Message : {0}", fe .Detail.Me ssage); | |||||
| 238 | Consol e.WriteLin e("Plugin Trace: {0} ", fe.Deta il.TraceTe xt); | |||||
| 239 | Consol e.WriteLin e("Inner F ault: {0}" , | |||||
| 240 | nu ll == fe.D etail.Inne rFault ? " No Inner F ault" : "H as Inner F ault"); | |||||
| 241 | } | |||||
| 242 | } | |||||
| 243 | } | |||||
| 244 | finally | |||||
| 245 | { | |||||
| 246 | Cons ole.WriteL ine("Press <Enter> t o exit."); | |||||
| 247 | Cons ole.ReadLi ne(); | |||||
| 248 | } | |||||
| 249 | } | |||||
| 250 | #e ndregion M ain method | |||||
| 251 | } | |||||
| 252 | } | |||||
| 253 | //</snippe tEnableDoc umentManag ement> |
Araxis Merge (but not the data content of this report) is Copyright © 1993-2016 Araxis Ltd (www.araxis.com). All rights reserved.