Produced by Araxis Merge on 2/1/2017 2:56:29 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\Client\Ribbon\ExportRibbonXml | ExportRibbonXml.cs | Tue Dec 20 19:51:45 2016 UTC |
| 2 | Wed Feb 1 19:56:29 2017 UTC |
| Description | Between Files 1 and 2 |
|
|---|---|---|
| Text Blocks | Lines | |
| Unchanged | 0 | 0 |
| Changed | 0 | 0 |
| Inserted | 0 | 0 |
| Removed | 1 | 317 |
| 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 ExportRibb onXml> | |||||
| 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.Xrm. Sdk.Messag es; | |||||
| 27 | using Micr osoft.Xrm. Sdk.Metada ta; | |||||
| 28 | ||||||
| 29 | ||||||
| 30 | ||||||
| 31 | using Micr osoft.Crm. Sdk.Messag es; | |||||
| 32 | ||||||
| 33 | //These re ferences a re require d for this sample | |||||
| 34 | using Syst em.IO; | |||||
| 35 | using Syst em.IO.Pack aging; | |||||
| 36 | ||||||
| 37 | namespace Microsoft. Crm.Sdk.Sa mples | |||||
| 38 | { | |||||
| 39 | /// <summ ary> | |||||
| 40 | /// Demon strates ho w to expor t the Ribb onXml defi nitions.</ summary> | |||||
| 41 | /// <rema rks> | |||||
| 42 | /// The g enerated X ML files w ill be cre ated in th e Exported RibbonXml folder of this proje ct.</remar ks> | |||||
| 43 | public cl ass Export RibbonXml | |||||
| 44 | { | |||||
| 45 | #region Class Leve l Members | |||||
| 46 | ||||||
| 47 | ||||||
| 48 | private Organizati onServiceP roxy _serv iceProxy; | |||||
| 49 | //<snipp etExportRi bbonXml6> | |||||
| 50 | //This a rray conta ins all of the syste m entities that use the ribbon . | |||||
| 51 | public S ystem.Stri ng[] entit iesWithRib bons = {"a ccount", | |||||
| 52 | "activitym imeattachm ent", | |||||
| 53 | "activityp ointer", | |||||
| 54 | "appointme nt", | |||||
| 55 | "bulkopera tion", | |||||
| 56 | "calendar" , | |||||
| 57 | "campaign" , | |||||
| 58 | "campaigna ctivity", | |||||
| 59 | "campaignr esponse", | |||||
| 60 | "competito r", | |||||
| 61 | "connectio n", | |||||
| 62 | "contact", | |||||
| 63 | "contract" , | |||||
| 64 | "contractd etail", | |||||
| 65 | "convertru le", | |||||
| 66 | "convertru leitem", | |||||
| 67 | "customera ddress", | |||||
| 68 | "discount" , | |||||
| 69 | "discountt ype", | |||||
| 70 | "email", | |||||
| 71 | "emailserv erprofile" , | |||||
| 72 | "entitleme nt", | |||||
| 73 | "entitleme ntchannel" , | |||||
| 74 | "entitleme nttemplate ", | |||||
| 75 | "entitleme nttemplate channel", | |||||
| 76 | "fax", | |||||
| 77 | "goal", | |||||
| 78 | "goalrollu pquery", | |||||
| 79 | "importfil e", | |||||
| 80 | "incident" , | |||||
| 81 | "invoice", | |||||
| 82 | "invoicede tail", | |||||
| 83 | "kbarticle ", | |||||
| 84 | "kbarticle comment", | |||||
| 85 | "lead", | |||||
| 86 | "letter", | |||||
| 87 | "list", | |||||
| 88 | "listmembe r", | |||||
| 89 | "mailbox", | |||||
| 90 | "metric", | |||||
| 91 | "opportuni ty", | |||||
| 92 | "opportuni typroduct" , | |||||
| 93 | "partnerap plication" , | |||||
| 94 | "phonecall ", | |||||
| 95 | "postfollo w", | |||||
| 96 | "priceleve l", | |||||
| 97 | "product", | |||||
| 98 | "productpr icelevel", | |||||
| 99 | "queue", | |||||
| 100 | "queueitem ", | |||||
| 101 | "quote", | |||||
| 102 | "quotedeta il", | |||||
| 103 | "recurring appointmen tmaster", | |||||
| 104 | "report", | |||||
| 105 | "rollupfie ld", | |||||
| 106 | "routingru le", | |||||
| 107 | "routingru leitem", | |||||
| 108 | "saleslite rature", | |||||
| 109 | "saleslite ratureitem ", | |||||
| 110 | "salesorde r", | |||||
| 111 | "salesorde rdetail", | |||||
| 112 | "service", | |||||
| 113 | "serviceap pointment" , | |||||
| 114 | "sharepoin tdocument" , | |||||
| 115 | "sharepoin tdocumentl ocation", | |||||
| 116 | "sharepoin tsite", | |||||
| 117 | "site", | |||||
| 118 | "sla", | |||||
| 119 | "slaitem", | |||||
| 120 | "socialact ivity", | |||||
| 121 | "socialpro file", | |||||
| 122 | "systemuse r", | |||||
| 123 | "task", | |||||
| 124 | "team", | |||||
| 125 | "teamtempl ate", | |||||
| 126 | "territory ", | |||||
| 127 | "uom", | |||||
| 128 | "uomschedu le", | |||||
| 129 | "userquery "}; | |||||
| 130 | //</snip petExportR ibbonXml6> | |||||
| 131 | //Folder name for exported r ibbon xml files. | |||||
| 132 | public S tring expo rtFolder = "Exported RibbonXml" ; | |||||
| 133 | ||||||
| 134 | #endregi on Class L evel Membe rs | |||||
| 135 | ||||||
| 136 | #region How To Sam ple Code | |||||
| 137 | /// <sum mary> | |||||
| 138 | /// This method fi rst connec ts to the Organizati on service . Afterwar ds, | |||||
| 139 | /// basi c create, retrieve, update, an d delete e ntity oper ations are performed . | |||||
| 140 | /// </su mmary> | |||||
| 141 | /// <par am name="s erverConfi g">Contain s server c onnection informatio n.</param> | |||||
| 142 | /// <par am name="p romptforDe lete">When True, the user will be prompt ed to dele te all | |||||
| 143 | /// crea ted entiti es.</param > | |||||
| 144 | public v oid Run(Se rverConnec tion.Confi guration s erverConfi g, bool pr omptforDel ete) | |||||
| 145 | { | |||||
| 146 | try | |||||
| 147 | { | |||||
| 148 | //<sni ppetExport RibbonXml1 > | |||||
| 149 | // Con nect to th e Organiza tion servi ce. | |||||
| 150 | // The using sta tement ass ures that the servic e proxy wi ll be prop erly dispo sed. | |||||
| 151 | using (_serviceP roxy = new Organizat ionService Proxy(serv erConfig.O rganizatio nUri, serv erConfig.H omeRealmUr i,serverCo nfig.Crede ntials, se rverConfig .DeviceCre dentials)) | |||||
| 152 | { | |||||
| 153 | // Th is stateme nt is requ ired to en able early -bound typ e support. | |||||
| 154 | _serv iceProxy.E nableProxy Types(); | |||||
| 155 | ||||||
| 156 | //Cre ate export folder fo r ribbon x ml files i f not alre ady exist. | |||||
| 157 | if (! Directory. Exists(exp ortFolder) ) | |||||
| 158 | D irectory.C reateDirec tory(expor tFolder); | |||||
| 159 | ||||||
| 160 | //<sn ippetExpor tRibbonXml 3> | |||||
| 161 | //Ret rieve the Appliation Ribbon | |||||
| 162 | Retri eveApplica tionRibbon Request ap pribReq = new Retrie veApplicat ionRibbonR equest(); | |||||
| 163 | Retri eveApplica tionRibbon Response a ppribResp = (Retriev eApplicati onRibbonRe sponse)_se rviceProxy .Execute(a ppribReq); | |||||
| 164 | ||||||
| 165 | Syste m.String a pplication RibbonPath = Path.Ge tFullPath( exportFold er + "\\ap plicationR ibbon.xml" ); | |||||
| 166 | File. WriteAllBy tes(applic ationRibbo nPath, unz ipRibbon(a ppribResp. Compressed Applicatio nRibbonXml )); | |||||
| 167 | //</s nippetExpo rtRibbonXm l3> | |||||
| 168 | //Wri te the pat h where th e file has been save d. | |||||
| 169 | Conso le.WriteLi ne(applica tionRibbon Path); | |||||
| 170 | //<sn ippetExpor tRibbonXml 4> | |||||
| 171 | //Ret rieve syst em Entity Ribbons | |||||
| 172 | Retri eveEntityR ibbonReque st entRibR eq = new R etrieveEnt ityRibbonR equest() { RibbonLoc ationFilte r = Ribbon LocationFi lters.All }; | |||||
| 173 | ||||||
| 174 | forea ch (System .String en tityName i n entities WithRibbon s) | |||||
| 175 | { | |||||
| 176 | entR ibReq.Enti tyName = e ntityName; | |||||
| 177 | Retr ieveEntity RibbonResp onse entRi bResp = (R etrieveEnt ityRibbonR esponse)_s erviceProx y.Execute( entRibReq) ; | |||||
| 178 | ||||||
| 179 | Syst em.String entityRibb onPath = P ath.GetFul lPath(expo rtFolder + "\\" + en tityName + "Ribbon.x ml"); | |||||
| 180 | File .WriteAllB ytes(entit yRibbonPat h, unzipRi bbon(entRi bResp.Comp ressedEnti tyXml)); | |||||
| 181 | //Wr ite the pa th where t he file ha s been sav ed. | |||||
| 182 | Cons ole.WriteL ine(entity RibbonPath ); | |||||
| 183 | } | |||||
| 184 | //</s nippetExpo rtRibbonXm l4> | |||||
| 185 | ||||||
| 186 | //<sn ippetExpor tRibbonXml 5> | |||||
| 187 | //Che ck for cus tom entiti es | |||||
| 188 | Retri eveAllEnti tiesReques t raer = n ew Retriev eAllEntiti esRequest( ) { Entity Filters = EntityFilt ers.Entity }; | |||||
| 189 | ||||||
| 190 | Retri eveAllEnti tiesRespon se resp = (RetrieveA llEntities Response)_ servicePro xy.Execute (raer); | |||||
| 191 | ||||||
| 192 | forea ch (Entity Metadata e m in resp. EntityMeta data) | |||||
| 193 | { | |||||
| 194 | if ( em.IsCusto mEntity == true && e m.IsInters ect == fal se) | |||||
| 195 | { | |||||
| 196 | ent RibReq.Ent ityName = em.Logical Name; | |||||
| 197 | Ret rieveEntit yRibbonRes ponse entR ibResp = ( RetrieveEn tityRibbon Response)_ servicePro xy.Execute (entRibReq ); | |||||
| 198 | ||||||
| 199 | Sys tem.String entityRib bonPath = Path.GetFu llPath(exp ortFolder + "\\" + e m.LogicalN ame + "Rib bon.xml"); | |||||
| 200 | Fil e.WriteAll Bytes(enti tyRibbonPa th, unzipR ibbon(entR ibResp.Com pressedEnt ityXml)); | |||||
| 201 | //W rite the p ath where the file h as been sa ved. | |||||
| 202 | Con sole.Write Line(entit yRibbonPat h); | |||||
| 203 | } | |||||
| 204 | } | |||||
| 205 | } | |||||
| 206 | //</sn ippetExpor tRibbonXml 5> | |||||
| 207 | //</sn ippetExpor tRibbonXml 1> | |||||
| 208 | } | |||||
| 209 | ||||||
| 210 | // Catc h any serv ice fault exceptions that Micr osoft Dyna mics CRM t hrows. | |||||
| 211 | catch ( FaultExcep tion<Micro soft.Xrm.S dk.Organiz ationServi ceFault>) | |||||
| 212 | { | |||||
| 213 | // You can handl e an excep tion here or pass it back to t he calling method. | |||||
| 214 | throw; | |||||
| 215 | } | |||||
| 216 | } | |||||
| 217 | ||||||
| 218 | //<snipp etExportRi bbonXml2> | |||||
| 219 | /// <sum mary> | |||||
| 220 | /// A he lper metho d that dec ompresses the the Ri bbon data returned | |||||
| 221 | /// </su mmary> | |||||
| 222 | /// <par am name="d ata">The c ompressed ribbon dat a</param> | |||||
| 223 | /// <ret urns></ret urns> | |||||
| 224 | public b yte[] unzi pRibbon(by te[] data) | |||||
| 225 | { | |||||
| 226 | System. IO.Packagi ng.ZipPack age packag e = null; | |||||
| 227 | MemoryS tream memS tream = nu ll; | |||||
| 228 | ||||||
| 229 | memStre am = new M emoryStrea m(); | |||||
| 230 | memStre am.Write(d ata, 0, da ta.Length) ; | |||||
| 231 | package = (ZipPac kage)ZipPa ckage.Open (memStream , FileMode .Open); | |||||
| 232 | ||||||
| 233 | ZipPack agePart pa rt = (ZipP ackagePart )package.G etPart(new Uri("/Rib bonXml.xml ", UriKind .Relative) ); | |||||
| 234 | using ( Stream str m = part.G etStream() ) | |||||
| 235 | { | |||||
| 236 | long l en = strm. Length; | |||||
| 237 | byte[] buff = ne w byte[len ]; | |||||
| 238 | strm.R ead(buff, 0, (int)le n); | |||||
| 239 | return buff; | |||||
| 240 | } | |||||
| 241 | } | |||||
| 242 | //</snip petExportR ibbonXml2> | |||||
| 243 | ||||||
| 244 | #endregi on How To Sample Cod e | |||||
| 245 | ||||||
| 246 | #region Main metho d | |||||
| 247 | ||||||
| 248 | /// <sum mary> | |||||
| 249 | /// Stan dard Main( ) method u sed by mos t SDK samp les. | |||||
| 250 | /// </su mmary> | |||||
| 251 | /// <par am name="a rgs"></par am> | |||||
| 252 | static p ublic void Main(stri ng[] args) | |||||
| 253 | { | |||||
| 254 | try | |||||
| 255 | { | |||||
| 256 | // Obt ain the ta rget organ ization's Web addres s and clie nt logon | |||||
| 257 | // cre dentials f rom the us er. | |||||
| 258 | Server Connection serverCon nect = new ServerCon nection(); | |||||
| 259 | Server Connection .Configura tion confi g = server Connect.Ge tServerCon figuration (); | |||||
| 260 | ||||||
| 261 | Export RibbonXml app = new ExportRibb onXml(); | |||||
| 262 | app.Ru n(config, true); | |||||
| 263 | } | |||||
| 264 | catch ( FaultExcep tion<Micro soft.Xrm.S dk.Organiz ationServi ceFault> e x) | |||||
| 265 | { | |||||
| 266 | Consol e.WriteLin e("The app lication t erminated with an er ror."); | |||||
| 267 | Consol e.WriteLin e("Timesta mp: {0}", ex.Detail. Timestamp) ; | |||||
| 268 | Consol e.WriteLin e("Code: { 0}", ex.De tail.Error Code); | |||||
| 269 | Consol e.WriteLin e("Message : {0}", ex .Detail.Me ssage); | |||||
| 270 | Consol e.WriteLin e("Plugin Trace: {0} ", ex.Deta il.TraceTe xt); | |||||
| 271 | Consol e.WriteLin e("Inner F ault: {0}" , | |||||
| 272 | nu ll == ex.D etail.Inne rFault ? " No Inner F ault" : "H as Inner F ault"); | |||||
| 273 | } | |||||
| 274 | catch ( System.Tim eoutExcept ion ex) | |||||
| 275 | { | |||||
| 276 | Consol e.WriteLin e("The app lication t erminated with an er ror."); | |||||
| 277 | Consol e.WriteLin e("Message : {0}", ex .Message); | |||||
| 278 | Consol e.WriteLin e("Stack T race: {0}" , ex.Stack Trace); | |||||
| 279 | Consol e.WriteLin e("Inner F ault: {0}" , | |||||
| 280 | nu ll == ex.I nnerExcept ion.Messag e ? "No In ner Fault" : ex.Inne rException .Message); | |||||
| 281 | } | |||||
| 282 | catch ( System.Exc eption ex) | |||||
| 283 | { | |||||
| 284 | Consol e.WriteLin e("The app lication t erminated with an er ror."); | |||||
| 285 | Consol e.WriteLin e(ex.Messa ge); | |||||
| 286 | ||||||
| 287 | // Dis play the d etails of the inner exception. | |||||
| 288 | if (ex .InnerExce ption != n ull) | |||||
| 289 | { | |||||
| 290 | Conso le.WriteLi ne(ex.Inne rException .Message); | |||||
| 291 | ||||||
| 292 | Fault Exception< Microsoft. Xrm.Sdk.Or ganization ServiceFau lt> fe = e x.InnerExc eption | |||||
| 293 | a s FaultExc eption<Mic rosoft.Xrm .Sdk.Organ izationSer viceFault> ; | |||||
| 294 | if (f e != null) | |||||
| 295 | { | |||||
| 296 | Cons ole.WriteL ine("Times tamp: {0}" , fe.Detai l.Timestam p); | |||||
| 297 | Cons ole.WriteL ine("Code: {0}", fe. Detail.Err orCode); | |||||
| 298 | Cons ole.WriteL ine("Messa ge: {0}", fe.Detail. Message); | |||||
| 299 | Cons ole.WriteL ine("Plugi n Trace: { 0}", fe.De tail.Trace Text); | |||||
| 300 | Cons ole.WriteL ine("Inner Fault: {0 }", | |||||
| 301 | null == fe .Detail.In nerFault ? "No Inner Fault" : "Has Inner Fault"); | |||||
| 302 | } | |||||
| 303 | } | |||||
| 304 | } | |||||
| 305 | // Addi tional exc eptions to catch: Se curityToke nValidatio nException , ExpiredS ecurityTok enExceptio n, | |||||
| 306 | // Secu rityAccess DeniedExce ption, Mes sageSecuri tyExceptio n, and Sec urityNegot iationExce ption. | |||||
| 307 | ||||||
| 308 | finally | |||||
| 309 | { | |||||
| 310 | Consol e.WriteLin e("Press < Enter> to exit."); | |||||
| 311 | Consol e.ReadLine (); | |||||
| 312 | } | |||||
| 313 | } | |||||
| 314 | #endregi on Main me thod | |||||
| 315 | } | |||||
| 316 | } | |||||
| 317 | //</snippe tExportRib bonXml> |
Araxis Merge (but not the data content of this report) is Copyright © 1993-2016 Araxis Ltd (www.araxis.com). All rights reserved.