Produced by Araxis Merge on 2/1/2017 2:56:34 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\GeneralProgramming\LateBound | DumpSdkMessageToFileDE.cs | Tue Dec 20 19:51:46 2016 UTC |
| 2 | Wed Feb 1 19:56:34 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 | // | |||||
| 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 righ ts reserve d. | |||||
| 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 DumpSdkMes sageToFile DE> | |||||
| 18 | using Syst em; | |||||
| 19 | using Syst em.Service Model; | |||||
| 20 | using Syst em.Service Model.Chan nels; | |||||
| 21 | using Syst em.Service Model.Desc ription; | |||||
| 22 | using Syst em.IO; | |||||
| 23 | using Syst em.Xml; | |||||
| 24 | ||||||
| 25 | // These n amespaces are found in the Mic rosoft.Xrm .Sdk.dll a ssembly | |||||
| 26 | // found i n the SDK\ bin folder . | |||||
| 27 | using Micr osoft.Xrm. Sdk; | |||||
| 28 | using Micr osoft.Xrm. Sdk.Client ; | |||||
| 29 | using Micr osoft.Xrm. Sdk.Query; | |||||
| 30 | using Micr osoft.Xrm. Sdk.Discov ery; | |||||
| 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; | |||||
| 35 | ||||||
| 36 | ||||||
| 37 | namespace Microsoft. Crm.Sdk.Sa mples | |||||
| 38 | { | |||||
| 39 | /// <s ummary> | |||||
| 40 | /// De monstrates how to as sign a que ue to a te am. | |||||
| 41 | /// If you want to run thi s sample r epeatedly, you have the option to | |||||
| 42 | /// de lete all t he records created a t the end of executi on. | |||||
| 43 | /// </ summary> | |||||
| 44 | public class Dum pSdkMessag eToFileDE | |||||
| 45 | { | |||||
| 46 | #r egion Clas s Level Me mbers | |||||
| 47 | ||||||
| 48 | // / <summary > | |||||
| 49 | // / Stores t he organiz ation serv ice proxy. | |||||
| 50 | // / </summar y> | |||||
| 51 | pr ivate Orga nizationSe rviceProxy _serviceP roxy; | |||||
| 52 | pr ivate IOrg anizationS ervice _se rvice; | |||||
| 53 | ||||||
| 54 | #e ndregion C lass Level Members | |||||
| 55 | ||||||
| 56 | #r egion How To Sample Code | |||||
| 57 | // / <summary > | |||||
| 58 | // / Create a nd configu re the org anization service pr oxy. | |||||
| 59 | // / Create a team, a q ueue and a role. | |||||
| 60 | // / Add read queue pri vileges to the role. | |||||
| 61 | // / Assign t he role to the team so that th ey can rea d the queu e. | |||||
| 62 | // / Assign t he queue t o the team . | |||||
| 63 | // / Optional ly delete any entity records t hat were c reated for this samp le. | |||||
| 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 | |||||
| 67 | // / all crea ted entiti es.</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 | _service = (IOrganiz ationServi ce)_servic eProxy; | |||||
| 78 | ||||||
| 79 | //<snippet DumpSdkMes sageToFile DE1> | |||||
| 80 | // Retriev e all SDK Message Re cords. | |||||
| 81 | QueryExpre ssion sdkM essageQuer y = new Qu eryExpress ion | |||||
| 82 | { | |||||
| 83 | Entity Name = "sd kmessage", | |||||
| 84 | Column Set = new ColumnSet( "categoryn ame", | |||||
| 85 | "n ame", "isp rivate", " availabili ty", "cust omizationl evel", | |||||
| 86 | "e xpand", "t emplate", "sdkmessag eid"), | |||||
| 87 | //Crit eria = new FilterExp ression(), | |||||
| 88 | }; | |||||
| 89 | ||||||
| 90 | EntityColl ection sdk Messages = _service. RetrieveMu ltiple(sdk MessageQue ry); | |||||
| 91 | //</snippe tDumpSdkMe ssageToFil eDE1> | |||||
| 92 | ||||||
| 93 | //<snippet DumpSdkMes sageToFile DE2> | |||||
| 94 | // Write o ut SDK mes sages to a n XML file . | |||||
| 95 | // Create an instanc e of Strea mWriter to write tex t to a fil e. | |||||
| 96 | // The usi ng stateme nt also cl oses the S treamWrite r. | |||||
| 97 | ||||||
| 98 | String fil ename = "s dkmessages .xml"; | |||||
| 99 | using (Str eamWriter sw = new S treamWrite r(filename )) | |||||
| 100 | { | |||||
| 101 | // Cre ate Xml Wr iter. | |||||
| 102 | XmlTex tWriter me tadataWrit er = new X mlTextWrit er(sw); | |||||
| 103 | ||||||
| 104 | // Sta rt Xml Fil e. | |||||
| 105 | metada taWriter.W riteStartD ocument(); | |||||
| 106 | ||||||
| 107 | // Met adata Xml Node. | |||||
| 108 | metada taWriter.W riteStartE lement("Me ssages"); | |||||
| 109 | ||||||
| 110 | for (i nt j = 0; j < sdkMes sages.Enti ties.Count ; j++) | |||||
| 111 | { | |||||
| 112 | ||||||
| 113 | En tity curre ntRecord = sdkMessag es[j]; | |||||
| 114 | ||||||
| 115 | me tadataWrit er.WriteSt artElement ("Message" ); | |||||
| 116 | ||||||
| 117 | // Write the message i nformation . | |||||
| 118 | me tadataWrit er.WriteEl ementStrin g("message -name", | |||||
| 119 | (String) currentRec ord.Attrib utes["name "]); | |||||
| 120 | me tadataWrit er.WriteEl ementStrin g("categor yname", | |||||
| 121 | (String) currentRec ord.Attrib utes["cate goryname"] ); | |||||
| 122 | if ((bool)cu rrentRecor d.Attribut es["ispriv ate"]) | |||||
| 123 | metadata Writer.Wri teElementS tring("isp rivate", " Yes"); | |||||
| 124 | me tadataWrit er.WriteEl ementStrin g("message -availabil ity", | |||||
| 125 | currentR ecord.Attr ibutes["av ailability "].ToStrin g()); | |||||
| 126 | if ((bool)cu rrentRecor d.Attribut es["expand "]) | |||||
| 127 | metadata Writer.Wri teElementS tring("exp and", "Yes "); | |||||
| 128 | if ((bool)cu rrentRecor d.Attribut es["templa te"]) | |||||
| 129 | metadata Writer.Wri teElementS tring("tem plate", "Y es"); | |||||
| 130 | ||||||
| 131 | ||||||
| 132 | #r egion filt ers | |||||
| 133 | ||||||
| 134 | // Retrieve all SDK Me ssage filt er records for that entity. | |||||
| 135 | Qu eryByAttri bute sdkMe ssageFilte rQuery = n ew QueryBy Attribute | |||||
| 136 | { | |||||
| 137 | EntityNa me = "sdkm essagefilt er", | |||||
| 138 | ColumnSe t = new Co lumnSet( | |||||
| 139 | "isc ustomproce ssingstepa llowed", " availabili ty", | |||||
| 140 | "pri maryobject typecode", "secondar yobjecttyp ecode"), | |||||
| 141 | }; | |||||
| 142 | sd kMessageFi lterQuery. AddAttribu teValue("s dkmessagei d", | |||||
| 143 | currentR ecord.Attr ibutes["sd kmessageid "]); | |||||
| 144 | En tityCollec tion sdkFi lters = _s ervice.Ret rieveMulti ple( | |||||
| 145 | sdkMessa geFilterQu ery); | |||||
| 146 | me tadataWrit er.WriteSt artElement ("Filters" ); | |||||
| 147 | ||||||
| 148 | fo r (int i = 0; i < sd kFilters.E ntities.Co unt; i++) | |||||
| 149 | { | |||||
| 150 | ||||||
| 151 | Entity c urrentFilt er = sdkFi lters[i]; | |||||
| 152 | ||||||
| 153 | metadata Writer.Wri teStartEle ment("Filt er"); | |||||
| 154 | ||||||
| 155 | // Write the messa ge informa tion. | |||||
| 156 | metadata Writer.Wri teElementS tring("fil ter-availa bility", | |||||
| 157 | curr entFilter. Attributes ["availabi lity"].ToS tring()); | |||||
| 158 | metadata Writer.Wri teElementS tring("pri maryobject typecode", | |||||
| 159 | curr entFilter. Attributes ["primaryo bjecttypec ode"].ToSt ring()); | |||||
| 160 | metadata Writer.Wri teElementS tring("sec ondaryobje cttypecode ", | |||||
| 161 | curr entFilter. Attributes ["secondar yobjecttyp ecode"].To String()); | |||||
| 162 | metadata Writer.Wri teEndEleme nt(); | |||||
| 163 | ||||||
| 164 | } | |||||
| 165 | me tadataWrit er.WriteEn dElement() ; | |||||
| 166 | ||||||
| 167 | ||||||
| 168 | #e ndregion f ilters | |||||
| 169 | ||||||
| 170 | me tadataWrit er.WriteEn dElement() ; | |||||
| 171 | } | |||||
| 172 | ||||||
| 173 | ||||||
| 174 | // End Metadata Xml Node | |||||
| 175 | metada taWriter.W riteEndEle ment(); | |||||
| 176 | metada taWriter.W riteEndDoc ument(); | |||||
| 177 | ||||||
| 178 | // Clo se xml wri ter. | |||||
| 179 | metada taWriter.C lose(); | |||||
| 180 | } | |||||
| 181 | ||||||
| 182 | //</snippe tDumpSdkMe ssageToFil eDE2> | |||||
| 183 | ||||||
| 184 | Console.Wr iteLine("R etrieved a ll SDK mes sages."); | |||||
| 185 | ||||||
| 186 | ||||||
| 187 | ||||||
| 188 | // There a re no enti ty records to delete . | |||||
| 189 | //DeleteRe quiredReco rds(prompt ForDelete) ; | |||||
| 190 | } | |||||
| 191 | } | |||||
| 192 | ||||||
| 193 | // Catch any servi ce fault e xceptions that Micro soft Dynam ics CRM th rows. | |||||
| 194 | catch (F aultExcept ion<Micros oft.Xrm.Sd k.Organiza tionServic eFault>) | |||||
| 195 | { | |||||
| 196 | // Y ou can han dle an exc eption her e or pass it back to the calli ng method. | |||||
| 197 | thro w; | |||||
| 198 | } | |||||
| 199 | } | |||||
| 200 | ||||||
| 201 | // / <summary > | |||||
| 202 | // / This met hod create s any enti ty records that this sample re quires. | |||||
| 203 | // / Create a team, a q ueue and a role. | |||||
| 204 | // / Add read queue pri vileges to the role. | |||||
| 205 | // / Assign t he role to the team so that th ey can rea d the queu e. | |||||
| 206 | // / Assign t he queue t o the team . | |||||
| 207 | // / </summar y> | |||||
| 208 | pu blic void CreateRequ iredRecord s() | |||||
| 209 | { | |||||
| 210 | ||||||
| 211 | ||||||
| 212 | return; | |||||
| 213 | } | |||||
| 214 | ||||||
| 215 | // / <summary > | |||||
| 216 | // / Deletes any entity records t hat were c reated for this samp le. | |||||
| 217 | // / <param n ame="promp t">Indicat es whether to prompt the user | |||||
| 218 | // / to delet e the reco rds create d in this sample.</p aram> | |||||
| 219 | // / </summar y> | |||||
| 220 | pu blic void DeleteRequ iredRecord s(bool pro mpt) | |||||
| 221 | { | |||||
| 222 | bool del eteRecords = true; | |||||
| 223 | ||||||
| 224 | if (prom pt) | |||||
| 225 | { | |||||
| 226 | Cons ole.WriteL ine("\nDo you want t hese entit y records deleted? ( y/n) [y]: "); | |||||
| 227 | Stri ng answer = Console. ReadLine() ; | |||||
| 228 | ||||||
| 229 | dele teRecords = (answer. StartsWith ("y") || a nswer.Star tsWith("Y" ) || answe r == Strin g.Empty); | |||||
| 230 | } | |||||
| 231 | ||||||
| 232 | if (dele teRecords) | |||||
| 233 | { | |||||
| 234 | ||||||
| 235 | Cons ole.WriteL ine("No en tity recor ds need to be delete d."); | |||||
| 236 | ||||||
| 237 | } | |||||
| 238 | } | |||||
| 239 | ||||||
| 240 | #e ndregion H ow To Samp le Code | |||||
| 241 | ||||||
| 242 | #r egion Main | |||||
| 243 | // / <summary > | |||||
| 244 | // / Standard Main() me thod used by most SD K samples. | |||||
| 245 | // / </summar y> | |||||
| 246 | // / <param n ame="args" ></param> | |||||
| 247 | st atic publi c void Mai n(string[] args) | |||||
| 248 | { | |||||
| 249 | try | |||||
| 250 | { | |||||
| 251 | // O btain the target org anization' s Web addr ess and cl ient logon | |||||
| 252 | // c redentials from the user. | |||||
| 253 | Serv erConnecti on serverC onnect = n ew ServerC onnection( ); | |||||
| 254 | Serv erConnecti on.Configu ration con fig = serv erConnect. GetServerC onfigurati on(); | |||||
| 255 | ||||||
| 256 | Dump SdkMessage ToFileDE a pp = new D umpSdkMess ageToFileD E(); | |||||
| 257 | app. Run(config , true); | |||||
| 258 | } | |||||
| 259 | catch (F aultExcept ion<Micros oft.Xrm.Sd k.Organiza tionServic eFault> ex ) | |||||
| 260 | { | |||||
| 261 | Cons ole.WriteL ine("The a pplication terminate d with an error."); | |||||
| 262 | Cons ole.WriteL ine("Times tamp: {0}" , ex.Detai l.Timestam p); | |||||
| 263 | Cons ole.WriteL ine("Code: {0}", ex. Detail.Err orCode); | |||||
| 264 | Cons ole.WriteL ine("Messa ge: {0}", ex.Detail. Message); | |||||
| 265 | Cons ole.WriteL ine("Plugi n Trace: { 0}", ex.De tail.Trace Text); | |||||
| 266 | Cons ole.WriteL ine("Inner Fault: {0 }", | |||||
| 267 | null == ex .Detail.In nerFault ? "No Inner Fault" : "Has Inner Fault"); | |||||
| 268 | } | |||||
| 269 | catch (S ystem.Time outExcepti on ex) | |||||
| 270 | { | |||||
| 271 | Cons ole.WriteL ine("The a pplication terminate d with an error."); | |||||
| 272 | Cons ole.WriteL ine("Messa ge: {0}", ex.Message ); | |||||
| 273 | Cons ole.WriteL ine("Stack Trace: {0 }", ex.Sta ckTrace); | |||||
| 274 | Cons ole.WriteL ine("Inner Fault: {0 }", | |||||
| 275 | null == ex .InnerExce ption.Mess age ? "No Inner Faul t" : ex.In nerExcepti on.Message ); | |||||
| 276 | } | |||||
| 277 | catch (S ystem.Exce ption ex) | |||||
| 278 | { | |||||
| 279 | Cons ole.WriteL ine("The a pplication terminate d with an error."); | |||||
| 280 | Cons ole.WriteL ine(ex.Mes sage); | |||||
| 281 | ||||||
| 282 | // D isplay the details o f the inne r exceptio n. | |||||
| 283 | if ( ex.InnerEx ception != null) | |||||
| 284 | { | |||||
| 285 | Console.Wr iteLine(ex .InnerExce ption.Mess age); | |||||
| 286 | ||||||
| 287 | FaultExcep tion<Micro soft.Xrm.S dk.Organiz ationServi ceFault> f e = | |||||
| 288 | ex.Inn erExceptio n | |||||
| 289 | as Fau ltExceptio n<Microsof t.Xrm.Sdk. Organizati onServiceF ault>; | |||||
| 290 | if (fe != null) | |||||
| 291 | { | |||||
| 292 | Consol e.WriteLin e("Timesta mp: {0}", fe.Detail. Timestamp) ; | |||||
| 293 | Consol e.WriteLin e("Code: { 0}", fe.De tail.Error Code); | |||||
| 294 | Consol e.WriteLin e("Message : {0}", fe .Detail.Me ssage); | |||||
| 295 | Consol e.WriteLin e("Plugin Trace: {0} ", fe.Deta il.TraceTe xt); | |||||
| 296 | Consol e.WriteLin e("Inner F ault: {0}" , | |||||
| 297 | nu ll == fe.D etail.Inne rFault ? " No Inner F ault" : "H as Inner F ault"); | |||||
| 298 | } | |||||
| 299 | } | |||||
| 300 | } | |||||
| 301 | // Addit ional exce ptions to catch: Sec urityToken Validation Exception, ExpiredSe curityToke nException , | |||||
| 302 | // Secur ityAccessD eniedExcep tion, Mess ageSecurit yException , and Secu rityNegoti ationExcep tion. | |||||
| 303 | ||||||
| 304 | ||||||
| 305 | finally | |||||
| 306 | { | |||||
| 307 | ||||||
| 308 | Cons ole.WriteL ine("Press <Enter> t o exit."); | |||||
| 309 | Cons ole.ReadLi ne(); | |||||
| 310 | } | |||||
| 311 | ||||||
| 312 | } | |||||
| 313 | #e ndregion M ain | |||||
| 314 | ||||||
| 315 | } | |||||
| 316 | } | |||||
| 317 | //</snippe tDumpSdkMe ssageToFil eDE> |
Araxis Merge (but not the data content of this report) is Copyright © 1993-2016 Araxis Ltd (www.araxis.com). All rights reserved.