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\Reporting | PublishReport.cs | Tue Dec 20 19:51:44 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 | 301 |
| 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 | // | |||||
| 3 | // This f ile is par t of the M icrosoft D ynamics CR M SDK code samples. | |||||
| 4 | // | |||||
| 5 | // Copyri ght (C) Mi crosoft Co rporation. All right s reserved . | |||||
| 6 | // | |||||
| 7 | // This s ource code is intend ed only as a supplem ent to Mic rosoft | |||||
| 8 | // Develo pment Tool s and/or o n-line doc umentation . See the se other | |||||
| 9 | // materi als for de tailed inf ormation r egarding M icrosoft c ode sample s. | |||||
| 10 | // | |||||
| 11 | // THIS C ODE AND IN FORMATION ARE PROVID ED "AS IS" WITHOUT W ARRANTY OF ANY | |||||
| 12 | // KIND, EITHER EXP RESSED OR IMPLIED, I NCLUDING B UT NOT LIM ITED TO TH E | |||||
| 13 | // IMPLIE D WARRANTI ES OF MERC HANTABILIT Y AND/OR F ITNESS FOR A | |||||
| 14 | // PARTIC ULAR PURPO SE. | |||||
| 15 | // | |||||
| 16 | // ======= ========== ========== ========== ========== ========== ========== == | |||||
| 17 | //<snippet PublishRep ort> | |||||
| 18 | using Syst em; | |||||
| 19 | using Syst em.Xml; | |||||
| 20 | using Syst em.Service Model; | |||||
| 21 | using Syst em.Service Model.Desc ription; | |||||
| 22 | using Syst em.IO; | |||||
| 23 | ||||||
| 24 | // These n amespaces are found in the Mic rosoft.Xrm .Sdk.dll a ssembly | |||||
| 25 | // found i n the SDK\ bin folder . | |||||
| 26 | using Micr osoft.Xrm. Sdk; | |||||
| 27 | using Micr osoft.Xrm. Sdk.Client ; | |||||
| 28 | using Micr osoft.Xrm. Sdk.Query; | |||||
| 29 | using Micr osoft.Xrm. Sdk.Discov ery; | |||||
| 30 | using Micr osoft.Xrm. Sdk.Messag es; | |||||
| 31 | ||||||
| 32 | // This na mespace is found in Microsoft. Crm.Sdk.Pr oxy.dll as sembly | |||||
| 33 | // found i n the SDK\ bin folder . | |||||
| 34 | using Micr osoft.Crm. Sdk.Messag es; | |||||
| 35 | ||||||
| 36 | namespace Microsoft. Crm.Sdk.Sa mples | |||||
| 37 | { | |||||
| 38 | /// <s ummary> | |||||
| 39 | /// Th is sample shows how to retriev e the hist ory limit of a repor t. | |||||
| 40 | /// </ summary> | |||||
| 41 | public class Pub lishReport | |||||
| 42 | { | |||||
| 43 | #r egion Clas s Level Me mbers | |||||
| 44 | ||||||
| 45 | // / <summary > | |||||
| 46 | // / Stores t he organiz ation serv ice proxy. | |||||
| 47 | // / </summar y> | |||||
| 48 | pr ivate Orga nizationSe rviceProxy _serviceP roxy; | |||||
| 49 | ||||||
| 50 | Gu id _report Id; | |||||
| 51 | Gu id _report CategoryId ; | |||||
| 52 | Gu id _report Visibility Id1; | |||||
| 53 | Gu id _report Visibility Id2; | |||||
| 54 | Gu id _report Visibility Id3; | |||||
| 55 | Gu id _report EntityId; | |||||
| 56 | // Guid _repo rtLinkId; | |||||
| 57 | ||||||
| 58 | #e ndregion C lass Level Members | |||||
| 59 | ||||||
| 60 | #r egion How To Sample Code | |||||
| 61 | // / <summary > | |||||
| 62 | // / Create a nd configu re the org anization service pr oxy. | |||||
| 63 | // / Retrieve the histo ry limit o f a report . | |||||
| 64 | // / </summar y> | |||||
| 65 | // / <param n ame="serve rConfig">C ontains se rver conne ction info rmation.</ param> | |||||
| 66 | // / <param n ame="promp tforDelete ">When Tru e, the use r will be prompted t o delete a ll | |||||
| 67 | // / created entities.< /param> | |||||
| 68 | pu blic void Run(Server Connection .Configura tion serve rConfig, b ool prompt ForDelete) | |||||
| 69 | { | |||||
| 70 | try | |||||
| 71 | { | |||||
| 72 | ||||||
| 73 | // C onnect to the Organi zation ser vice. | |||||
| 74 | // T he using s tatement a ssures tha t the serv ice proxy will be pr operly dis posed. | |||||
| 75 | 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 )) | |||||
| 76 | { | |||||
| 77 | // This st atement is required to enable early-boun d type sup port. | |||||
| 78 | _servicePr oxy.Enable ProxyTypes (); | |||||
| 79 | ||||||
| 80 | // Call th e method t o create a ny data th at this sa mple requi res. | |||||
| 81 | CreateRequ iredRecord s(); | |||||
| 82 | ||||||
| 83 | //<snippet PublishRep ort1> | |||||
| 84 | ||||||
| 85 | // Define an anonymo us type to define th e possible values fo r | |||||
| 86 | // report type. | |||||
| 87 | var Report TypeCode = new | |||||
| 88 | { | |||||
| 89 | Report ingService sReport = 1, | |||||
| 90 | OtherR eport = 2, | |||||
| 91 | Linked Report = 3 | |||||
| 92 | }; | |||||
| 93 | ||||||
| 94 | // Define an anonymo us type to define th e possible values fo r | |||||
| 95 | // report category. | |||||
| 96 | var Report CategoryCo de = new | |||||
| 97 | { | |||||
| 98 | SalesR eports = 1 , | |||||
| 99 | Servic eReports = 2, | |||||
| 100 | Market ingReports = 3, | |||||
| 101 | Admini strativeRe ports = 4 | |||||
| 102 | }; | |||||
| 103 | ||||||
| 104 | // Define an anonymo us type to define th e possible values fo r | |||||
| 105 | // report visibility | |||||
| 106 | var Report Visibility Code = new | |||||
| 107 | { | |||||
| 108 | Report sGrid = 1, | |||||
| 109 | Form = 2, | |||||
| 110 | Grid = 3, | |||||
| 111 | }; | |||||
| 112 | ||||||
| 113 | // Instant iate a rep ort object . | |||||
| 114 | // See the Entity Me tadata top ic in the SDK docume ntation to determine | |||||
| 115 | // which a ttributes must be se t for each entity. | |||||
| 116 | ||||||
| 117 | Report sam pleReport = new Repo rt | |||||
| 118 | { | |||||
| 119 | Name = "Sample R eport", | |||||
| 120 | BodyTe xt = File. ReadAllTex t("SampleR eport.rdl" ), | |||||
| 121 | FileNa me = "Samp leReport.r dl", | |||||
| 122 | Langua geCode = 1 033, // US English | |||||
| 123 | Report TypeCode = new Optio nSetValue( ReportType Code.Repor tingServic esReport) | |||||
| 124 | }; | |||||
| 125 | // Create a report r ecord name d Sample R eport. | |||||
| 126 | _reportId = _service Proxy.Crea te(sampleR eport); | |||||
| 127 | ||||||
| 128 | ||||||
| 129 | // Set the report ca tegory. | |||||
| 130 | ReportCate gory sampl eReportCat egory = ne w ReportCa tegory | |||||
| 131 | { | |||||
| 132 | Report Id = new E ntityRefer ence(Repor t.EntityLo gicalName, _reportId ), | |||||
| 133 | Catego ryCode = n ew OptionS etValue(Re portCatego ryCode.Adm inistrativ eReports) | |||||
| 134 | }; | |||||
| 135 | _reportCat egoryId = _servicePr oxy.Create (sampleRep ortCategor y); | |||||
| 136 | ||||||
| 137 | // Define which enti ty this re port uses. | |||||
| 138 | ReportEnti ty reportE ntity = ne w ReportEn tity | |||||
| 139 | { | |||||
| 140 | Report Id = new E ntityRefer ence(Repor t.EntityLo gicalName, _reportId ), | |||||
| 141 | Object TypeCode = Account.E ntityLogic alName | |||||
| 142 | }; | |||||
| 143 | _reportEnt ityId = _s erviceProx y.Create(r eportEntit y); | |||||
| 144 | ||||||
| 145 | ||||||
| 146 | // Set the report vi sibility. | |||||
| 147 | ReportVisi bility rv = new Repo rtVisibili ty | |||||
| 148 | { | |||||
| 149 | Report Id = new E ntityRefer ence(Repor t.EntityLo gicalName, _reportId ), | |||||
| 150 | Visibi lityCode = new Optio nSetValue( ReportVisi bilityCode .Form) | |||||
| 151 | }; | |||||
| 152 | _reportVis ibilityId1 = _servic eProxy.Cre ate(rv); | |||||
| 153 | ||||||
| 154 | rv = new R eportVisib ility | |||||
| 155 | { | |||||
| 156 | Report Id = new E ntityRefer ence(Repor t.EntityLo gicalName, _reportId ), | |||||
| 157 | Visibi lityCode = new Optio nSetValue( ReportVisi bilityCode .Grid) | |||||
| 158 | }; | |||||
| 159 | _reportVis ibilityId2 = _servic eProxy.Cre ate(rv); | |||||
| 160 | ||||||
| 161 | rv = new R eportVisib ility | |||||
| 162 | { | |||||
| 163 | Report Id = new E ntityRefer ence(Repor t.EntityLo gicalName, _reportId ), | |||||
| 164 | Visibi lityCode = new Optio nSetValue( ReportVisi bilityCode .ReportsGr id) | |||||
| 165 | }; | |||||
| 166 | _reportVis ibilityId3 = _servic eProxy.Cre ate(rv); | |||||
| 167 | ||||||
| 168 | Console.Wr iteLine("{ 0} publish ed in Micr osoft Dyna mics CRM." , sampleRe port.Name) ; | |||||
| 169 | ||||||
| 170 | ||||||
| 171 | //</snippe tPublishRe port1> | |||||
| 172 | ||||||
| 173 | DeleteRequ iredRecord s(promptFo rDelete); | |||||
| 174 | } | |||||
| 175 | } | |||||
| 176 | // Catch any servi ce fault e xceptions that Micro soft Dynam ics CRM th rows. | |||||
| 177 | catch (F aultExcept ion<Micros oft.Xrm.Sd k.Organiza tionServic eFault>) | |||||
| 178 | { | |||||
| 179 | // Y ou can han dle an exc eption her e or pass it back to the calli ng method. | |||||
| 180 | thro w; | |||||
| 181 | } | |||||
| 182 | } | |||||
| 183 | ||||||
| 184 | // / <summary > | |||||
| 185 | // / This met hod create s any enti ty records that this sample re quires. | |||||
| 186 | // / </summar y> | |||||
| 187 | pu blic void CreateRequ iredRecord s() | |||||
| 188 | { | |||||
| 189 | // No en tity recor ds are req uired for this sampl e. | |||||
| 190 | } | |||||
| 191 | ||||||
| 192 | // / <summary > | |||||
| 193 | // / Deletes any entity records t hat were c reated for this samp le. | |||||
| 194 | // / <param n ame="promp t">Indicat es whether to prompt the user to delete | |||||
| 195 | // / the reco rds create d in this sample.</p aram> | |||||
| 196 | // / </summar y> | |||||
| 197 | pu blic void DeleteRequ iredRecord s(bool pro mpt) | |||||
| 198 | { | |||||
| 199 | bool del eteRecords = true; | |||||
| 200 | ||||||
| 201 | if (prom pt) | |||||
| 202 | { | |||||
| 203 | Cons ole.WriteL ine("\nDo you want t he records to be del eted? (y/n )"); | |||||
| 204 | Stri ng answer = Console. ReadLine() ; | |||||
| 205 | ||||||
| 206 | dele teRecords = (answer. StartsWith ("y") || a nswer.Star tsWith("Y" )); | |||||
| 207 | } | |||||
| 208 | ||||||
| 209 | if (dele teRecords) | |||||
| 210 | { | |||||
| 211 | _ser viceProxy. Delete(Rep ort.Entity LogicalNam e, _report Id); | |||||
| 212 | /* T here is no need to d elete thes e records because de leting the report wi ll delete all relate d records. | |||||
| 213 | _ser viceProxy. Delete(Rep ortCategor y.EntityLo gicalName, _reportCa tegoryId); | |||||
| 214 | _ser viceProxy. Delete(Rep ortEntity. EntityLogi calName, _ reportEnti tyId); | |||||
| 215 | _ser viceProxy. Delete(Rep ortLink.En tityLogica lName, _re portLinkId ); | |||||
| 216 | _ser viceProxy. Delete(Rep ortVisibil ity.Entity LogicalNam e, _report Visibility Id1); | |||||
| 217 | _ser viceProxy. Delete(Rep ortVisibil ity.Entity LogicalNam e, _report Visibility Id2); | |||||
| 218 | _ser viceProxy. Delete(Rep ortVisibil ity.Entity LogicalNam e, _report Visibility Id3); | |||||
| 219 | */ | |||||
| 220 | Cons ole.WriteL ine("Entit y records have been deleted.") ; | |||||
| 221 | ||||||
| 222 | } | |||||
| 223 | } | |||||
| 224 | ||||||
| 225 | #e ndregion H ow To Samp le Code | |||||
| 226 | ||||||
| 227 | #r egion Main | |||||
| 228 | // / <summary > | |||||
| 229 | // / Standard Main() me thod used by most SD K samples. | |||||
| 230 | // / </summar y> | |||||
| 231 | // / <param n ame="args" ></param> | |||||
| 232 | st atic publi c void Mai n(string[] args) | |||||
| 233 | { | |||||
| 234 | try | |||||
| 235 | { | |||||
| 236 | // O btain the target org anization' s Web addr ess and cl ient logon | |||||
| 237 | // c redentials from the user. | |||||
| 238 | Serv erConnecti on serverC onnect = n ew ServerC onnection( ); | |||||
| 239 | Serv erConnecti on.Configu ration con fig = serv erConnect. GetServerC onfigurati on(); | |||||
| 240 | ||||||
| 241 | Publ ishReport app = new PublishRep ort(); | |||||
| 242 | app. Run(config , true); | |||||
| 243 | } | |||||
| 244 | ||||||
| 245 | catch (F aultExcept ion<Micros oft.Xrm.Sd k.Organiza tionServic eFault> ex ) | |||||
| 246 | { | |||||
| 247 | Cons ole.WriteL ine("The a pplication terminate d with an error."); | |||||
| 248 | Cons ole.WriteL ine("Times tamp: {0}" , ex.Detai l.Timestam p); | |||||
| 249 | Cons ole.WriteL ine("Code: {0}", ex. Detail.Err orCode); | |||||
| 250 | Cons ole.WriteL ine("Messa ge: {0}", ex.Detail. Message); | |||||
| 251 | Cons ole.WriteL ine("Plugi n Trace: { 0}", ex.De tail.Trace Text); | |||||
| 252 | Cons ole.WriteL ine("Inner Fault: {0 }", | |||||
| 253 | null == ex .Detail.In nerFault ? "No Inner Fault" : "Has Inner Fault"); | |||||
| 254 | } | |||||
| 255 | catch (S ystem.Time outExcepti on ex) | |||||
| 256 | { | |||||
| 257 | Cons ole.WriteL ine("The a pplication terminate d with an error."); | |||||
| 258 | Cons ole.WriteL ine("Messa ge: {0}", ex.Message ); | |||||
| 259 | Cons ole.WriteL ine("Stack Trace: {0 }", ex.Sta ckTrace); | |||||
| 260 | Cons ole.WriteL ine("Inner Fault: {0 }", | |||||
| 261 | null == ex .InnerExce ption.Mess age ? "No Inner Faul t" : ex.In nerExcepti on.Message ); | |||||
| 262 | } | |||||
| 263 | catch (S ystem.Exce ption ex) | |||||
| 264 | { | |||||
| 265 | Cons ole.WriteL ine("The a pplication terminate d with an error."); | |||||
| 266 | Cons ole.WriteL ine(ex.Mes sage); | |||||
| 267 | ||||||
| 268 | // D isplay the details o f the inne r exceptio n. | |||||
| 269 | if ( ex.InnerEx ception != null) | |||||
| 270 | { | |||||
| 271 | Console.Wr iteLine(ex .InnerExce ption.Mess age); | |||||
| 272 | ||||||
| 273 | FaultExcep tion<Micro soft.Xrm.S dk.Organiz ationServi ceFault> f e | |||||
| 274 | = ex.I nnerExcept ion | |||||
| 275 | as Fau ltExceptio n<Microsof t.Xrm.Sdk. Organizati onServiceF ault>; | |||||
| 276 | if (fe != null) | |||||
| 277 | { | |||||
| 278 | Consol e.WriteLin e("Timesta mp: {0}", fe.Detail. Timestamp) ; | |||||
| 279 | Consol e.WriteLin e("Code: { 0}", fe.De tail.Error Code); | |||||
| 280 | Consol e.WriteLin e("Message : {0}", fe .Detail.Me ssage); | |||||
| 281 | Consol e.WriteLin e("Plugin Trace: {0} ", fe.Deta il.TraceTe xt); | |||||
| 282 | Consol e.WriteLin e("Inner F ault: {0}" , | |||||
| 283 | nu ll == fe.D etail.Inne rFault ? " No Inner F ault" : "H as Inner F ault"); | |||||
| 284 | } | |||||
| 285 | } | |||||
| 286 | } | |||||
| 287 | // Addit ional exce ptions to catch: Sec urityToken Validation Exception, ExpiredSe curityToke nException , | |||||
| 288 | // Secur ityAccessD eniedExcep tion, Mess ageSecurit yException , and Secu rityNegoti ationExcep tion. | |||||
| 289 | ||||||
| 290 | finally | |||||
| 291 | { | |||||
| 292 | ||||||
| 293 | Cons ole.WriteL ine("Press <Enter> t o exit."); | |||||
| 294 | Cons ole.ReadLi ne(); | |||||
| 295 | } | |||||
| 296 | ||||||
| 297 | } | |||||
| 298 | #e ndregion M ain | |||||
| 299 | } | |||||
| 300 | } | |||||
| 301 | //</snippe tPublishRe port> |
Araxis Merge (but not the data content of this report) is Copyright © 1993-2016 Araxis Ltd (www.araxis.com). All rights reserved.