Produced by Araxis Merge on 2/1/2017 2:56:48 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\Metadata\OptionSets | DumpOptionSetInfo.cs | Tue Dec 20 19:51:47 2016 UTC |
| 2 | Wed Feb 1 19:56:48 2017 UTC |
| Description | Between Files 1 and 2 |
|
|---|---|---|
| Text Blocks | Lines | |
| Unchanged | 0 | 0 |
| Changed | 0 | 0 |
| Inserted | 0 | 0 |
| Removed | 1 | 302 |
| 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 DumpOption SetInfo> | |||||
| 18 | using Syst em; | |||||
| 19 | using Syst em.Linq; | |||||
| 20 | using Syst em.Xml.Lin q; | |||||
| 21 | using Syst em.Service Model; | |||||
| 22 | using Syst em.Service Model.Desc ription; | |||||
| 23 | using Syst em.Collect ions.Gener ic; | |||||
| 24 | using Syst em.Xml.Ser ialization ; | |||||
| 25 | using Syst em.Xml; | |||||
| 26 | using Syst em.IO; | |||||
| 27 | ||||||
| 28 | // These n amespaces are found in the Mic rosoft.Xrm .Sdk.dll a ssembly | |||||
| 29 | // found i n the SDK\ bin folder . | |||||
| 30 | using Micr osoft.Xrm. Sdk; | |||||
| 31 | using Micr osoft.Xrm. Sdk.Query; | |||||
| 32 | using Micr osoft.Xrm. Sdk.Metada ta; | |||||
| 33 | using Micr osoft.Xrm. Sdk.Client ; | |||||
| 34 | using Micr osoft.Xrm. Sdk.Messag es; | |||||
| 35 | ||||||
| 36 | // This na mespace is found in Microsoft. Crm.Sdk.Pr oxy.dll as sembly | |||||
| 37 | // found i n the SDK\ bin folder . | |||||
| 38 | using Micr osoft.Crm. Sdk.Messag es; | |||||
| 39 | ||||||
| 40 | namespace Microsoft. Crm.Sdk.Sa mples | |||||
| 41 | { | |||||
| 42 | /// <s ummary> | |||||
| 43 | /// Th is sample shows how to retriev e and writ e out glob al option set values . | |||||
| 44 | /// </ summary> | |||||
| 45 | public class Dum pOptionSet Info | |||||
| 46 | { | |||||
| 47 | #r egion Clas s Level Me mbers | |||||
| 48 | ||||||
| 49 | // / <summary > | |||||
| 50 | // / Stores t he organiz ation serv ice proxy. | |||||
| 51 | // / </summar y> | |||||
| 52 | Or ganization ServicePro xy _servic eProxy; | |||||
| 53 | ||||||
| 54 | // Create st orage for new attrib utes being created | |||||
| 55 | pu blic List< AttributeM etadata> a ddedAttrib utes; | |||||
| 56 | ||||||
| 57 | // Specify w hich langu age code t o use in t he sample. If you ar e using a language | |||||
| 58 | // other tha n US Engli sh, you wi ll need to modify th is value a ccordingly . | |||||
| 59 | // See http: //msdn.mic rosoft.com /en-us/lib rary/0h88f ahh.aspx | |||||
| 60 | pu blic const int _lang uageCode = 1033; | |||||
| 61 | ||||||
| 62 | // Define th e IDs/vari ables need ed for thi s sample. | |||||
| 63 | pu blic int _ insertedSt atusValue; | |||||
| 64 | ||||||
| 65 | #e ndregion C lass Level Members | |||||
| 66 | ||||||
| 67 | #r egion How To Sample Code | |||||
| 68 | // / <summary > | |||||
| 69 | // / </summar y> | |||||
| 70 | // / <param n ame="serve rConfig">C ontains se rver conne ction info rmation.</ param> | |||||
| 71 | // / <param n ame="promp tForDelete ">When Tru e, the use r will be prompted t o delete a ll | |||||
| 72 | // / created entities.< /param> | |||||
| 73 | pu blic void Run(Server Connection .Configura tion serve rConfig, b ool prompt ForDelete) | |||||
| 74 | { | |||||
| 75 | try | |||||
| 76 | { | |||||
| 77 | ||||||
| 78 | // C onnect to the Organi zation ser vice. | |||||
| 79 | // T he using s tatement a ssures tha t the serv ice proxy will be pr operly dis posed. | |||||
| 80 | 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 )) | |||||
| 81 | { | |||||
| 82 | // This st atement is required to enable early-boun d type sup port. | |||||
| 83 | _servicePr oxy.Enable ProxyTypes (); | |||||
| 84 | ||||||
| 85 | //<snippet DumpOption SetInfo1> | |||||
| 86 | #region Ho w to dump option set info | |||||
| 87 | ||||||
| 88 | ||||||
| 89 | RetrieveAl lOptionSet sRequest r etrieveAll OptionSets Request = | |||||
| 90 | new R etrieveAll OptionSets Request(); | |||||
| 91 | ||||||
| 92 | // Execute the reque st | |||||
| 93 | RetrieveAl lOptionSet sResponse retrieveAl lOptionSet sResponse = | |||||
| 94 | (Retri eveAllOpti onSetsResp onse)_serv iceProxy.E xecute( | |||||
| 95 | retrie veAllOptio nSetsReque st); | |||||
| 96 | ||||||
| 97 | // Create an instanc e of Strea mWriter to write tex t to a fil e. | |||||
| 98 | // The usi ng stateme nt also cl oses the S treamWrite r. | |||||
| 99 | // To view this file , right cl ick the fi le and cho ose open w ith Excel. | |||||
| 100 | // Excel w ill figure out the s chema and display th e informat ion in col umns. | |||||
| 101 | ||||||
| 102 | String fil ename = St ring.Conca t("AllOpti onSetValue s.xml"); | |||||
| 103 | using (Str eamWriter sw = new S treamWrite r(filename )) | |||||
| 104 | { | |||||
| 105 | // Cre ate Xml Wr iter. | |||||
| 106 | XmlTex tWriter me tadataWrit er = new X mlTextWrit er(sw); | |||||
| 107 | ||||||
| 108 | // Sta rt Xml Fil e. | |||||
| 109 | metada taWriter.W riteStartD ocument(); | |||||
| 110 | ||||||
| 111 | // Met adata Xml Node. | |||||
| 112 | metada taWriter.W riteStartE lement("Me tadata"); | |||||
| 113 | ||||||
| 114 | if (re trieveAllO ptionSetsR esponse.Op tionSetMet adata.Coun t() > 0) | |||||
| 115 | { | |||||
| 116 | ||||||
| 117 | fo reach (Opt ionSetMeta dataBase o ptionSetMe tadataBase in | |||||
| 118 | retrieve AllOptionS etsRespons e.OptionSe tMetadata) | |||||
| 119 | { | |||||
| 120 | if (opti onSetMetad ataBase.Op tionSetTyp e != null) | |||||
| 121 | { | |||||
| 122 | if ( (OptionSet Type)optio nSetMetada taBase.Opt ionSetType == Option SetType.Pi cklist) | |||||
| 123 | { | |||||
| 124 | OptionSetM etadata op tionSetMet adata = (O ptionSetMe tadata)opt ionSetMeta dataBase; | |||||
| 125 | // Start O ptionSet N ode | |||||
| 126 | metadataWr iter.Write StartEleme nt("Option Set"); | |||||
| 127 | metadataWr iter.Write AttributeS tring("Opt ionSetType ", OptionS etType.Pic klist.ToSt ring()); | |||||
| 128 | metadataWr iter.Write ElementStr ing("Optio nSetDispla yName", | |||||
| 129 | (optio nSetMetada ta.Display Name.Local izedLabels .Count > 0 )? optionS etMetadata .DisplayNa me.Localiz edLabels[0 ].Label : String.Emp ty); | |||||
| 130 | ||||||
| 131 | // Writes the option s | |||||
| 132 | metadataWr iter.Write StartEleme nt("Option s"); | |||||
| 133 | ||||||
| 134 | foreach (O ptionMetad ata option in option SetMetadat a.Options) | |||||
| 135 | { | |||||
| 136 | metada taWriter.W riteStartE lement("Op tion"); | |||||
| 137 | metada taWriter.W riteElemen tString("O ptionValue ", option. Value.ToSt ring()); | |||||
| 138 | metada taWriter.W riteElemen tString("O ptionDescr iption", o ption.Labe l.UserLoca lizedLabel .Label.ToS tring()); | |||||
| 139 | metada taWriter.W riteEndEle ment(); | |||||
| 140 | } | |||||
| 141 | metadataWr iter.Write EndElement (); | |||||
| 142 | ||||||
| 143 | // End Opt ionSet Nod e | |||||
| 144 | metadataWr iter.Write EndElement (); | |||||
| 145 | } | |||||
| 146 | else if ((Opti onSetType) optionSetM etadataBas e.OptionSe tType == O ptionSetTy pe.Boolean ) | |||||
| 147 | { | |||||
| 148 | BooleanOpt ionSetMeta data optio nSetMetada ta = (Bool eanOptionS etMetadata )optionSet MetadataBa se; | |||||
| 149 | // Start O ptionSet N ode | |||||
| 150 | metadataWr iter.Write StartEleme nt("Option Set"); | |||||
| 151 | metadataWr iter.Write AttributeS tring("Opt ionSetType ", OptionS etType.Boo lean.ToStr ing()); | |||||
| 152 | if (option SetMetadat a.DisplayN ame.Locali zedLabels. Count != 0 ) | |||||
| 153 | metada taWriter.W riteElemen tString("O ptionSetDi splayName" , optionSe tMetadata. DisplayNam e.Localize dLabels[0] .Label); | |||||
| 154 | else | |||||
| 155 | metada taWriter.W riteElemen tString("O ptionSetDi splayName" , "UNDEFIN ED"); | |||||
| 156 | ||||||
| 157 | // Writes the TrueOp tion | |||||
| 158 | metadataWr iter.Write StartEleme nt("TrueOp tion"); | |||||
| 159 | metadataWr iter.Write ElementStr ing("Optio nValue", o ptionSetMe tadata.Tru eOption.Va lue.ToStri ng()); | |||||
| 160 | metadataWr iter.Write ElementStr ing("Optio nDescripti on", optio nSetMetada ta.TrueOpt ion.Label. UserLocali zedLabel.L abel.ToStr ing()); | |||||
| 161 | metadataWr iter.Write EndElement (); | |||||
| 162 | // Writes the FalseO ption | |||||
| 163 | metadataWr iter.Write StartEleme nt("FalseO ption"); | |||||
| 164 | metadataWr iter.Write ElementStr ing("Optio nValue", o ptionSetMe tadata.Fal seOption.V alue.ToStr ing()); | |||||
| 165 | metadataWr iter.Write ElementStr ing("Optio nDescripti on", optio nSetMetada ta.FalseOp tion.Label .UserLocal izedLabel. Label.ToSt ring()); | |||||
| 166 | metadataWr iter.Write EndElement (); | |||||
| 167 | ||||||
| 168 | // End Opt ionSet Nod e | |||||
| 169 | metadataWr iter.Write EndElement (); | |||||
| 170 | } | |||||
| 171 | } | |||||
| 172 | } | |||||
| 173 | } | |||||
| 174 | ||||||
| 175 | // End Metadata Xml Node | |||||
| 176 | metada taWriter.W riteEndEle ment(); | |||||
| 177 | metada taWriter.W riteEndDoc ument(); | |||||
| 178 | ||||||
| 179 | // Clo se xml wri ter. | |||||
| 180 | metada taWriter.C lose(); | |||||
| 181 | } | |||||
| 182 | ||||||
| 183 | ||||||
| 184 | #endregion How to du mp option set info | |||||
| 185 | ||||||
| 186 | ||||||
| 187 | ||||||
| 188 | Console.Wr iteLine("D one."); | |||||
| 189 | //</snippe tDumpOptio nSetInfo1> | |||||
| 190 | ||||||
| 191 | //DeleteRe quiredReco rds(prompt ForDelete) ; | |||||
| 192 | } | |||||
| 193 | } | |||||
| 194 | ||||||
| 195 | // Catch any servi ce fault e xceptions that Micro soft Dynam ics CRM th rows. | |||||
| 196 | catch (F aultExcept ion<Micros oft.Xrm.Sd k.Organiza tionServic eFault>) | |||||
| 197 | { | |||||
| 198 | // Y ou can han dle an exc eption her e or pass it back to the calli ng method. | |||||
| 199 | thro w; | |||||
| 200 | } | |||||
| 201 | } | |||||
| 202 | ||||||
| 203 | // / <summary > | |||||
| 204 | // / Deletes/ Reverts th e record t hat was cr eated/chan ged for th is sample. | |||||
| 205 | // / <param n ame="promp t">Indicat es whether to prompt the user to delete | |||||
| 206 | // / the reco rds create d in this sample.</p aram> | |||||
| 207 | // / </summar y> | |||||
| 208 | pu blic void DeleteRequ iredRecord s(bool pro mpt) | |||||
| 209 | { | |||||
| 210 | bool del eteRecords = true; | |||||
| 211 | ||||||
| 212 | if (prom pt) | |||||
| 213 | { | |||||
| 214 | Cons ole.WriteL ine( | |||||
| 215 | "\nDo you want these entity re cords to b e deleted? (y/n)"); | |||||
| 216 | Stri ng answer = Console. ReadLine() ; | |||||
| 217 | ||||||
| 218 | dele teRecords = (answer. StartsWith ("y") || a nswer.Star tsWith("Y" )); | |||||
| 219 | } | |||||
| 220 | ||||||
| 221 | if (dele teRecords) | |||||
| 222 | { | |||||
| 223 | ||||||
| 224 | } | |||||
| 225 | } | |||||
| 226 | #e ndregion H ow To Samp le Code | |||||
| 227 | ||||||
| 228 | #r egion Main | |||||
| 229 | // / <summary > | |||||
| 230 | // / Standard Main() me thod used by most SD K samples. | |||||
| 231 | // / </summar y> | |||||
| 232 | // / <param n ame="args" ></param> | |||||
| 233 | st atic publi c void Mai n(string[] args) | |||||
| 234 | { | |||||
| 235 | try | |||||
| 236 | { | |||||
| 237 | // O btain the target org anization' s Web addr ess and cl ient logon | |||||
| 238 | // c redentials from the user. | |||||
| 239 | Serv erConnecti on serverC onnect = n ew ServerC onnection( ); | |||||
| 240 | Serv erConnecti on.Configu ration con fig = serv erConnect. GetServerC onfigurati on(); | |||||
| 241 | ||||||
| 242 | Dump OptionSetI nfo app = new DumpOp tionSetInf o(); | |||||
| 243 | app. Run(config , false); | |||||
| 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 | } | |||||
| 302 | //</snippe tDumpOptio nSetInfo> |
Araxis Merge (but not the data content of this report) is Copyright © 1993-2016 Araxis Ltd (www.araxis.com). All rights reserved.