Produced by Araxis Merge on 2/1/2017 2:56:54 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 | DownloadReportDefinition.cs | Tue Dec 20 19:51:44 2016 UTC |
| 2 | Wed Feb 1 19:56:54 2017 UTC |
| Description | Between Files 1 and 2 |
|
|---|---|---|
| Text Blocks | Lines | |
| Unchanged | 0 | 0 |
| Changed | 0 | 0 |
| Inserted | 0 | 0 |
| Removed | 1 | 235 |
| 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 DownloadRe portDefini tion> | |||||
| 18 | using Syst em; | |||||
| 19 | using Syst em.IO; | |||||
| 20 | using Syst em.Xml; | |||||
| 21 | using Syst em.Service Model; | |||||
| 22 | using Syst em.Service Model.Desc ription; | |||||
| 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 downloa d the repo rt definit ion (RDL) file. | |||||
| 40 | /// </ summary> | |||||
| 41 | public class Dow nloadRepor tDefinitio n | |||||
| 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 | // Define th e variable s needed f or this sa mple. | |||||
| 51 | St ring _curr entDirecto ryPath; | |||||
| 52 | ||||||
| 53 | #e ndregion C lass Level Members | |||||
| 54 | ||||||
| 55 | #r egion How To Sample Code | |||||
| 56 | // / <summary > | |||||
| 57 | // / Create a nd configu re the org anization service pr oxy. | |||||
| 58 | // / Download the repor t definiti on. | |||||
| 59 | // / Optional ly delete any entity records t hat were c reated for this samp le. | |||||
| 60 | // / </summar y> | |||||
| 61 | // / <param n ame="serve rConfig">C ontains se rver conne ction info rmation.</ param> | |||||
| 62 | // / <param n ame="promp tforDelete ">When Tru e, the use r will be prompted t o delete a ll | |||||
| 63 | // / created entities.< /param> | |||||
| 64 | pu blic void Run(Server Connection .Configura tion serve rConfig, b ool prompt ForDelete) | |||||
| 65 | { | |||||
| 66 | try | |||||
| 67 | { | |||||
| 68 | ||||||
| 69 | // C onnect to the Organi zation ser vice. | |||||
| 70 | // T he using s tatement a ssures tha t the serv ice proxy will be pr operly dis posed. | |||||
| 71 | 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 )) | |||||
| 72 | { | |||||
| 73 | // This st atement is required to enable early-boun d type sup port. | |||||
| 74 | _servicePr oxy.Enable ProxyTypes (); | |||||
| 75 | ||||||
| 76 | // Call th e method t o create a ny data th at this sa mple requi res. | |||||
| 77 | CreateRequ iredRecord s(); | |||||
| 78 | ||||||
| 79 | //<snippet DownloadRe portDefini tion1> | |||||
| 80 | ||||||
| 81 | // Query f or an an e xisting re port: Acco unt Overvi ew. This i s a defaul t report i n Microsof t Dynamics CRM. | |||||
| 82 | QueryByAtt ribute rep ortQuery = new Query ByAttribut e(Report.E ntityLogic alName); | |||||
| 83 | reportQuer y.AddAttri buteValue( "name", "A ccount Ove rview"); | |||||
| 84 | reportQuer y.ColumnSe t = new Co lumnSet("r eportid"); | |||||
| 85 | ||||||
| 86 | // G et the rep ort. | |||||
| 87 | Enti tyCollecti on retriev eReports = _serviceP roxy.Retri eveMultipl e(reportQu ery); | |||||
| 88 | ||||||
| 89 | // C onvert ret rieved Ent ity to a r eport | |||||
| 90 | Repo rt retriev edReport = (Report)r etrieveRep orts.Entit ies[0]; | |||||
| 91 | Console.Wr iteLine("R etrieved t he 'Accoun t Overview ' report." ); | |||||
| 92 | ||||||
| 93 | // U se the Dow nload Repo rt Definit ion messag e. | |||||
| 94 | Down loadReport Definition Request rd lRequest = new Downl oadReportD efinitionR equest | |||||
| 95 | { | |||||
| 96 | Report Id = retri evedReport .ReportId. Value | |||||
| 97 | }; | |||||
| 98 | ||||||
| 99 | Down loadReport Definition Response r dlResponse = (Downlo adReportDe finitionRe sponse)_se rviceProxy .Execute(r dlRequest) ; | |||||
| 100 | ||||||
| 101 | // Get the current d irectory p ath. | |||||
| 102 | _currentDi rectoryPat h = Direct ory.GetCur rentDirect ory(); | |||||
| 103 | ||||||
| 104 | // A ccess the xml data a nd save to disk | |||||
| 105 | XmlT extWriter reportDefi nitionFile = new Xml TextWriter ( _current DirectoryP ath + "\\N ewReport.r dl", Syste m.Text.Enc oding.UTF8 ); | |||||
| 106 | repo rtDefiniti onFile.Wri teRaw(rdlR esponse.Bo dyText); | |||||
| 107 | repo rtDefiniti onFile.Clo se(); | |||||
| 108 | ||||||
| 109 | if (File.E xists(_cur rentDirect oryPath + "\\NewRepo rt.rdl")) | |||||
| 110 | { | |||||
| 111 | Consol e.WriteLin e("Downloa ded the re port defin ition (New Report.rdl ) to '{0}' .", _curre ntDirector yPath.ToSt ring()); | |||||
| 112 | } | |||||
| 113 | ||||||
| 114 | //</snippe tDownloadR eportDefin ition1> | |||||
| 115 | ||||||
| 116 | DeleteRequ iredRecord s(promptFo rDelete); | |||||
| 117 | } | |||||
| 118 | } | |||||
| 119 | // Catch any servi ce fault e xceptions that Micro soft Dynam ics CRM th rows. | |||||
| 120 | catch (F aultExcept ion<Micros oft.Xrm.Sd k.Organiza tionServic eFault>) | |||||
| 121 | { | |||||
| 122 | // Y ou can han dle an exc eption her e or pass it back to the calli ng method. | |||||
| 123 | thro w; | |||||
| 124 | } | |||||
| 125 | } | |||||
| 126 | ||||||
| 127 | // / <summary > | |||||
| 128 | // / This met hod create s any enti ty records that this sample re quires. | |||||
| 129 | // / </summar y> | |||||
| 130 | pu blic void CreateRequ iredRecord s() | |||||
| 131 | { | |||||
| 132 | // All t he entity records in this samp le are cre ated in th e Run() me thod. | |||||
| 133 | } | |||||
| 134 | ||||||
| 135 | // / <summary > | |||||
| 136 | // / Deletes any entity records t hat were c reated for this samp le. | |||||
| 137 | // / <param n ame="promp t">Indicat es whether to prompt the user to delete | |||||
| 138 | // / the reco rds create d in this sample.</p aram> | |||||
| 139 | // / </summar y> | |||||
| 140 | pu blic void DeleteRequ iredRecord s(bool pro mpt) | |||||
| 141 | { | |||||
| 142 | bool del eteRecords = true; | |||||
| 143 | ||||||
| 144 | if (prom pt) | |||||
| 145 | { | |||||
| 146 | Cons ole.WriteL ine("\nDo you want t he records to be del eted? (y/n )"); | |||||
| 147 | Stri ng answer = Console. ReadLine() ; | |||||
| 148 | ||||||
| 149 | dele teRecords = (answer. StartsWith ("y") || a nswer.Star tsWith("Y" )); | |||||
| 150 | } | |||||
| 151 | ||||||
| 152 | if (dele teRecords) | |||||
| 153 | { | |||||
| 154 | File .Delete(_c urrentDire ctoryPath + "\\NewRe port.rdl") ; | |||||
| 155 | Cons ole.WriteL ine("The d ownloaded report def inition ha s been del eted."); | |||||
| 156 | } | |||||
| 157 | } | |||||
| 158 | ||||||
| 159 | #e ndregion H ow To Samp le Code | |||||
| 160 | ||||||
| 161 | #r egion Main | |||||
| 162 | // / <summary > | |||||
| 163 | // / Standard Main() me thod used by most SD K samples. | |||||
| 164 | // / </summar y> | |||||
| 165 | // / <param n ame="args" ></param> | |||||
| 166 | st atic publi c void Mai n(string[] args) | |||||
| 167 | { | |||||
| 168 | try | |||||
| 169 | { | |||||
| 170 | // O btain the target org anization' s Web addr ess and cl ient logon | |||||
| 171 | // c redentials from the user. | |||||
| 172 | Serv erConnecti on serverC onnect = n ew ServerC onnection( ); | |||||
| 173 | Serv erConnecti on.Configu ration con fig = serv erConnect. GetServerC onfigurati on(); | |||||
| 174 | ||||||
| 175 | Down loadReport Definition app = new DownloadR eportDefin ition(); | |||||
| 176 | app. Run(config , true); | |||||
| 177 | } | |||||
| 178 | ||||||
| 179 | catch (F aultExcept ion<Micros oft.Xrm.Sd k.Organiza tionServic eFault> ex ) | |||||
| 180 | { | |||||
| 181 | Cons ole.WriteL ine("The a pplication terminate d with an error."); | |||||
| 182 | Cons ole.WriteL ine("Times tamp: {0}" , ex.Detai l.Timestam p); | |||||
| 183 | Cons ole.WriteL ine("Code: {0}", ex. Detail.Err orCode); | |||||
| 184 | Cons ole.WriteL ine("Messa ge: {0}", ex.Detail. Message); | |||||
| 185 | Cons ole.WriteL ine("Plugi n Trace: { 0}", ex.De tail.Trace Text); | |||||
| 186 | Cons ole.WriteL ine("Inner Fault: {0 }", | |||||
| 187 | null == ex .Detail.In nerFault ? "No Inner Fault" : "Has Inner Fault"); | |||||
| 188 | } | |||||
| 189 | catch (S ystem.Time outExcepti on ex) | |||||
| 190 | { | |||||
| 191 | Cons ole.WriteL ine("The a pplication terminate d with an error."); | |||||
| 192 | Cons ole.WriteL ine("Messa ge: {0}", ex.Message ); | |||||
| 193 | Cons ole.WriteL ine("Stack Trace: {0 }", ex.Sta ckTrace); | |||||
| 194 | Cons ole.WriteL ine("Inner Fault: {0 }", | |||||
| 195 | null == ex .InnerExce ption.Mess age ? "No Inner Faul t" : ex.In nerExcepti on.Message ); | |||||
| 196 | } | |||||
| 197 | catch (S ystem.Exce ption ex) | |||||
| 198 | { | |||||
| 199 | Cons ole.WriteL ine("The a pplication terminate d with an error."); | |||||
| 200 | Cons ole.WriteL ine(ex.Mes sage); | |||||
| 201 | ||||||
| 202 | // D isplay the details o f the inne r exceptio n. | |||||
| 203 | if ( ex.InnerEx ception != null) | |||||
| 204 | { | |||||
| 205 | Console.Wr iteLine(ex .InnerExce ption.Mess age); | |||||
| 206 | ||||||
| 207 | FaultExcep tion<Micro soft.Xrm.S dk.Organiz ationServi ceFault> f e | |||||
| 208 | = ex.I nnerExcept ion | |||||
| 209 | as Fau ltExceptio n<Microsof t.Xrm.Sdk. Organizati onServiceF ault>; | |||||
| 210 | if (fe != null) | |||||
| 211 | { | |||||
| 212 | Consol e.WriteLin e("Timesta mp: {0}", fe.Detail. Timestamp) ; | |||||
| 213 | Consol e.WriteLin e("Code: { 0}", fe.De tail.Error Code); | |||||
| 214 | Consol e.WriteLin e("Message : {0}", fe .Detail.Me ssage); | |||||
| 215 | Consol e.WriteLin e("Plugin Trace: {0} ", fe.Deta il.TraceTe xt); | |||||
| 216 | Consol e.WriteLin e("Inner F ault: {0}" , | |||||
| 217 | nu ll == fe.D etail.Inne rFault ? " No Inner F ault" : "H as Inner F ault"); | |||||
| 218 | } | |||||
| 219 | } | |||||
| 220 | } | |||||
| 221 | // Addit ional exce ptions to catch: Sec urityToken Validation Exception, ExpiredSe curityToke nException , | |||||
| 222 | // Secur ityAccessD eniedExcep tion, Mess ageSecurit yException , and Secu rityNegoti ationExcep tion. | |||||
| 223 | ||||||
| 224 | finally | |||||
| 225 | { | |||||
| 226 | ||||||
| 227 | Cons ole.WriteL ine("Press <Enter> t o exit."); | |||||
| 228 | Cons ole.ReadLi ne(); | |||||
| 229 | } | |||||
| 230 | ||||||
| 231 | } | |||||
| 232 | #e ndregion M ain | |||||
| 233 | } | |||||
| 234 | } | |||||
| 235 | //</snippe tDownloadR eportDefin ition> |
Araxis Merge (but not the data content of this report) is Copyright © 1993-2016 Araxis Ltd (www.araxis.com). All rights reserved.