Produced by Araxis Merge on 2/1/2017 2:56:47 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\Entities | DumpEntityInfo.cs | Tue Dec 20 19:51:46 2016 UTC |
| 2 | Wed Feb 1 19:56:47 2017 UTC |
| Description | Between Files 1 and 2 |
|
|---|---|---|
| Text Blocks | Lines | |
| Unchanged | 0 | 0 |
| Changed | 0 | 0 |
| Inserted | 0 | 0 |
| Removed | 1 | 309 |
| 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 DumpEntity Info> | |||||
| 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 enti ty metadat a. | |||||
| 44 | /// </ summary> | |||||
| 45 | public class Dum pEntityInf o | |||||
| 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 DumpEntity Info1> | |||||
| 86 | RetrieveAl lEntitiesR equest req uest = new RetrieveA llEntities Request() | |||||
| 87 | { | |||||
| 88 | Entity Filters = EntityFilt ers.Entity , | |||||
| 89 | Retrie veAsIfPubl ished = tr ue | |||||
| 90 | }; | |||||
| 91 | ||||||
| 92 | // Retriev e the Meta Data. | |||||
| 93 | RetrieveAl lEntitiesR esponse re sponse = ( RetrieveAl lEntitiesR esponse)_s erviceProx y.Execute( request); | |||||
| 94 | ||||||
| 95 | ||||||
| 96 | // Create an instanc e of Strea mWriter to write tex t to a fil e. | |||||
| 97 | // The usi ng stateme nt also cl oses the S treamWrite r. | |||||
| 98 | // To view this file , right cl ick the fi le and cho ose open w ith Excel. | |||||
| 99 | // Excel w ill figure out the s chema and display th e informat ion in col umns. | |||||
| 100 | ||||||
| 101 | String fil ename = St ring.Conca t("EntityI nfo.xml"); | |||||
| 102 | using (Str eamWriter sw = new S treamWrite r(filename )) | |||||
| 103 | { | |||||
| 104 | // Cre ate Xml Wr iter. | |||||
| 105 | XmlTex tWriter me tadataWrit er = new X mlTextWrit er(sw); | |||||
| 106 | ||||||
| 107 | // Sta rt Xml Fil e. | |||||
| 108 | metada taWriter.W riteStartD ocument(); | |||||
| 109 | ||||||
| 110 | // Met adata Xml Node. | |||||
| 111 | metada taWriter.W riteStartE lement("Me tadata"); | |||||
| 112 | ||||||
| 113 | foreac h (EntityM etadata cu rrentEntit y in respo nse.Entity Metadata) | |||||
| 114 | { | |||||
| 115 | // if (curren tEntity.Is Intersect. Value == f alse) | |||||
| 116 | if (true) | |||||
| 117 | { | |||||
| 118 | // Start Entity No de | |||||
| 119 | metadata Writer.Wri teStartEle ment("Enti ty"); | |||||
| 120 | ||||||
| 121 | // Write the Entit y's Inform ation. | |||||
| 122 | metadata Writer.Wri teElementS tring("Ent itySchemaN ame", curr entEntity. SchemaName ); | |||||
| 123 | metadata Writer.Wri teElementS tring("OTC ", current Entity.Obj ectTypeCod e.ToString ()); | |||||
| 124 | metadata Writer.Wri teElementS tring("Own ershipType ", current Entity.Own ershipType .Value.ToS tring()); | |||||
| 125 | if (curr entEntity. DisplayNam e.UserLoca lizedLabel != null) | |||||
| 126 | meta dataWriter .WriteElem entString( "DisplayNa me", curre ntEntity.D isplayName .UserLocal izedLabel. Label); | |||||
| 127 | if (curr entEntity. DisplayCol lectionNam e.UserLoca lizedLabel != null) | |||||
| 128 | meta dataWriter .WriteElem entString( "DisplayCo llectionNa me", curre ntEntity.D isplayColl ectionName .UserLocal izedLabel. Label); | |||||
| 129 | metadata Writer.Wri teElementS tring("Int roducedVer sion", cur rentEntity .Introduce dVersion.T oString()) ; | |||||
| 130 | metadata Writer.Wri teElementS tring("Aut oRouteToOw nerQueue", currentEn tity.AutoR outeToOwne rQueue.ToS tring()); | |||||
| 131 | metadata Writer.Wri teElementS tring("Can BeInManyTo Many", cur rentEntity .CanBeInMa nyToMany.V alue.ToStr ing()); | |||||
| 132 | metadata Writer.Wri teElementS tring("Can BePrimaryE ntityInRel ationship" , currentE ntity.CanB ePrimaryEn tityInRela tionship.V alue.ToStr ing()); | |||||
| 133 | metadata Writer.Wri teElementS tring("Can BeRelatedE ntityInRel ationship" , currentE ntity.CanB eRelatedEn tityInRela tionship.V alue.ToStr ing()); | |||||
| 134 | metadata Writer.Wri teElementS tring("Can CreateAttr ibutes", c urrentEnti ty.CanCrea teAttribut es.Value.T oString()) ; | |||||
| 135 | metadata Writer.Wri teElementS tring("Can CreateChar ts", curre ntEntity.C anCreateCh arts.Value .ToString( )); | |||||
| 136 | metadata Writer.Wri teElementS tring("Can CreateForm s", curren tEntity.Ca nCreateFor ms.Value.T oString()) ; | |||||
| 137 | metadata Writer.Wri teElementS tring("Can CreateView s", curren tEntity.Ca nCreateVie ws.Value.T oString()) ; | |||||
| 138 | metadata Writer.Wri teElementS tring("Can ModifyAddi tionalSett ings", cur rentEntity .CanModify Additional Settings.V alue.ToStr ing()); | |||||
| 139 | metadata Writer.Wri teElementS tring("Can TriggerWor kflow", cu rrentEntit y.CanTrigg erWorkflow .Value.ToS tring()); | |||||
| 140 | ||||||
| 141 | metadata Writer.Wri teElementS tring("IsA ctivity", currentEnt ity.IsActi vity.Value .ToString( )); | |||||
| 142 | //metada taWriter.W riteElemen tString("A ctivityTyp eMask", cu rrentEntit y.Activity TypeMask.T oString()) ; | |||||
| 143 | ||||||
| 144 | metadata Writer.Wri teElementS tring("IsA ctivityPar ty", curre ntEntity.I sActivityP arty.Value .ToString( )); | |||||
| 145 | ||||||
| 146 | metadata Writer.Wri teElementS tring("IsA uditEnable d", curren tEntity.Is AuditEnabl ed.Value.T oString()) ; | |||||
| 147 | metadata Writer.Wri teElementS tring("IsA vailableOf fline", cu rrentEntit y.IsAvaila bleOffline .ToString( )); | |||||
| 148 | metadata Writer.Wri teElementS tring("IsC hildEntity ", current Entity.IsC hildEntity .ToString( )); | |||||
| 149 | metadata Writer.Wri teElementS tring("IsC onnections Enabled", currentEnt ity.IsConn ectionsEna bled.Manag edProperty LogicalNam e.ToString ()); | |||||
| 150 | metadata Writer.Wri teElementS tring("IsC ustomEntit y", curren tEntity.Is CustomEnti ty.Value.T oString()) ; | |||||
| 151 | metadata Writer.Wri teElementS tring("IsC ustomizabl e", curren tEntity.Is Customizab le.Value.T oString()) ; | |||||
| 152 | ||||||
| 153 | metadata Writer.Wri teElementS tring("IsD ocumentMan agementEna bled", cur rentEntity .IsDocumen tManagemen tEnabled.V alue.ToStr ing()); | |||||
| 154 | metadata Writer.Wri teElementS tring("IsD uplicateDe tectionEna bled", cur rentEntity .IsDuplica teDetectio nEnabled.V alue.ToStr ing()); | |||||
| 155 | if (curr entEntity. IsEnabledF orCharts ! = null) | |||||
| 156 | meta dataWriter .WriteElem entString( "IsEnabled ForCharts" , currentE ntity.IsEn abledForCh arts.Value .ToString( )); | |||||
| 157 | metadata Writer.Wri teElementS tring("IsI mportable" , currentE ntity.IsIm portable.V alue.ToStr ing()); | |||||
| 158 | metadata Writer.Wri teElementS tring("IsI ntersect", currentEn tity.IsInt ersect.Val ue.ToStrin g()); | |||||
| 159 | ||||||
| 160 | metadata Writer.Wri teElementS tring("IsM ailMergeEn abled", cu rrentEntit y.IsMailMe rgeEnabled .Value.ToS tring()); | |||||
| 161 | metadata Writer.Wri teElementS tring("IsM anaged", c urrentEnti ty.IsManag ed.Value.T oString()) ; | |||||
| 162 | metadata Writer.Wri teElementS tring("IsM appable", currentEnt ity.IsMapp able.Value .ToString( )); | |||||
| 163 | ||||||
| 164 | metadata Writer.Wri teElementS tring("IsR eadingPane Enabled", currentEnt ity.IsRead ingPaneEna bled.Value .ToString( )); | |||||
| 165 | metadata Writer.Wri teElementS tring("IsR enameable" , currentE ntity.IsRe nameable.V alue.ToStr ing()); | |||||
| 166 | metadata Writer.Wri teElementS tring("IsV alidForAdv ancedFind" , currentE ntity.IsVa lidForAdva ncedFind.V alue.ToStr ing()); | |||||
| 167 | metadata Writer.Wri teElementS tring("IsV alidForQue ue", curre ntEntity.I sValidForQ ueue.Value .ToString( )); | |||||
| 168 | metadata Writer.Wri teElementS tring("IsV isibleInMo bile", cur rentEntity .IsVisible InMobile.V alue.ToStr ing()); | |||||
| 169 | ||||||
| 170 | metadata Writer.Wri teElementS tring("Pri maryIdAttr ibute", cu rrentEntit y.PrimaryI dAttribute ); | |||||
| 171 | metadata Writer.Wri teElementS tring("Pri maryNameAt tribute", currentEnt ity.Primar yNameAttri bute); | |||||
| 172 | metadata Writer.Wri teElementS tring("Rep ortViewNam e", curren tEntity.Re portViewNa me); | |||||
| 173 | metadata Writer.Wri teElementS tring("Rec urrenceBas eEntityLog icalName", currentEn tity.Recur renceBaseE ntityLogic alName); | |||||
| 174 | if (curr entEntity. Descriptio n.UserLoca lizedLabel != null) | |||||
| 175 | meta dataWriter .WriteElem entString( "Descripti on", curre ntEntity.D escription .UserLocal izedLabel. Label); | |||||
| 176 | ||||||
| 177 | ||||||
| 178 | ||||||
| 179 | // End E ntity Node | |||||
| 180 | metadata Writer.Wri teEndEleme nt(); | |||||
| 181 | } | |||||
| 182 | } | |||||
| 183 | ||||||
| 184 | // End Metadata Xml Node | |||||
| 185 | metada taWriter.W riteEndEle ment(); | |||||
| 186 | metada taWriter.W riteEndDoc ument(); | |||||
| 187 | ||||||
| 188 | // Clo se xml wri ter. | |||||
| 189 | metada taWriter.C lose(); | |||||
| 190 | } | |||||
| 191 | ||||||
| 192 | ||||||
| 193 | ||||||
| 194 | ||||||
| 195 | C onsole.Wri teLine("Do ne."); | |||||
| 196 | //</snippe tDumpEntit yInfo1> | |||||
| 197 | ||||||
| 198 | //DeleteRe quiredReco rds(prompt ForDelete) ; | |||||
| 199 | } | |||||
| 200 | } | |||||
| 201 | ||||||
| 202 | // Catch any servi ce fault e xceptions that Micro soft Dynam ics CRM th rows. | |||||
| 203 | catch (F aultExcept ion<Micros oft.Xrm.Sd k.Organiza tionServic eFault>) | |||||
| 204 | { | |||||
| 205 | // Y ou can han dle an exc eption her e or pass it back to the calli ng method. | |||||
| 206 | thro w; | |||||
| 207 | } | |||||
| 208 | } | |||||
| 209 | ||||||
| 210 | // / <summary > | |||||
| 211 | // / Deletes/ Reverts th e record t hat was cr eated/chan ged for th is sample. | |||||
| 212 | // / <param n ame="promp t">Indicat es whether to prompt the user to delete | |||||
| 213 | // / the reco rds create d in this sample.</p aram> | |||||
| 214 | // / </summar y> | |||||
| 215 | pu blic void DeleteRequ iredRecord s(bool pro mpt) | |||||
| 216 | { | |||||
| 217 | bool del eteRecords = true; | |||||
| 218 | ||||||
| 219 | if (prom pt) | |||||
| 220 | { | |||||
| 221 | Cons ole.WriteL ine( | |||||
| 222 | "\nDo you want these entity re cords to b e deleted? (y/n)"); | |||||
| 223 | Stri ng answer = Console. ReadLine() ; | |||||
| 224 | ||||||
| 225 | dele teRecords = (answer. StartsWith ("y") || a nswer.Star tsWith("Y" )); | |||||
| 226 | } | |||||
| 227 | ||||||
| 228 | if (dele teRecords) | |||||
| 229 | { | |||||
| 230 | ||||||
| 231 | } | |||||
| 232 | } | |||||
| 233 | #e ndregion H ow To Samp le Code | |||||
| 234 | ||||||
| 235 | #r egion Main | |||||
| 236 | // / <summary > | |||||
| 237 | // / Standard Main() me thod used by most SD K samples. | |||||
| 238 | // / </summar y> | |||||
| 239 | // / <param n ame="args" ></param> | |||||
| 240 | st atic publi c void Mai n(string[] args) | |||||
| 241 | { | |||||
| 242 | try | |||||
| 243 | { | |||||
| 244 | // O btain the target org anization' s Web addr ess and cl ient logon | |||||
| 245 | // c redentials from the user. | |||||
| 246 | Serv erConnecti on serverC onnect = n ew ServerC onnection( ); | |||||
| 247 | Serv erConnecti on.Configu ration con fig = serv erConnect. GetServerC onfigurati on(); | |||||
| 248 | ||||||
| 249 | Dump EntityInfo app = new DumpEntit yInfo(); | |||||
| 250 | app. Run(config , false); | |||||
| 251 | } | |||||
| 252 | catch (F aultExcept ion<Micros oft.Xrm.Sd k.Organiza tionServic eFault> ex ) | |||||
| 253 | { | |||||
| 254 | Cons ole.WriteL ine("The a pplication terminate d with an error."); | |||||
| 255 | Cons ole.WriteL ine("Times tamp: {0}" , ex.Detai l.Timestam p); | |||||
| 256 | Cons ole.WriteL ine("Code: {0}", ex. Detail.Err orCode); | |||||
| 257 | Cons ole.WriteL ine("Messa ge: {0}", ex.Detail. Message); | |||||
| 258 | Cons ole.WriteL ine("Plugi n Trace: { 0}", ex.De tail.Trace Text); | |||||
| 259 | Cons ole.WriteL ine("Inner Fault: {0 }", | |||||
| 260 | null == ex .Detail.In nerFault ? "No Inner Fault" : "Has Inner Fault"); | |||||
| 261 | } | |||||
| 262 | catch (S ystem.Time outExcepti on ex) | |||||
| 263 | { | |||||
| 264 | Cons ole.WriteL ine("The a pplication terminate d with an error."); | |||||
| 265 | Cons ole.WriteL ine("Messa ge: {0}", ex.Message ); | |||||
| 266 | Cons ole.WriteL ine("Stack Trace: {0 }", ex.Sta ckTrace); | |||||
| 267 | Cons ole.WriteL ine("Inner Fault: {0 }", | |||||
| 268 | null == ex .InnerExce ption.Mess age ? "No Inner Faul t" : ex.In nerExcepti on.Message ); | |||||
| 269 | } | |||||
| 270 | catch (S ystem.Exce ption ex) | |||||
| 271 | { | |||||
| 272 | Cons ole.WriteL ine("The a pplication terminate d with an error."); | |||||
| 273 | Cons ole.WriteL ine(ex.Mes sage); | |||||
| 274 | ||||||
| 275 | // D isplay the details o f the inne r exceptio n. | |||||
| 276 | if ( ex.InnerEx ception != null) | |||||
| 277 | { | |||||
| 278 | Console.Wr iteLine(ex .InnerExce ption.Mess age); | |||||
| 279 | ||||||
| 280 | FaultExcep tion<Micro soft.Xrm.S dk.Organiz ationServi ceFault> f e | |||||
| 281 | = ex.I nnerExcept ion | |||||
| 282 | as Fau ltExceptio n<Microsof t.Xrm.Sdk. Organizati onServiceF ault>; | |||||
| 283 | if (fe != null) | |||||
| 284 | { | |||||
| 285 | Consol e.WriteLin e("Timesta mp: {0}", fe.Detail. Timestamp) ; | |||||
| 286 | Consol e.WriteLin e("Code: { 0}", fe.De tail.Error Code); | |||||
| 287 | Consol e.WriteLin e("Message : {0}", fe .Detail.Me ssage); | |||||
| 288 | Consol e.WriteLin e("Plugin Trace: {0} ", fe.Deta il.TraceTe xt); | |||||
| 289 | Consol e.WriteLin e("Inner F ault: {0}" , | |||||
| 290 | nu ll == fe.D etail.Inne rFault ? " No Inner F ault" : "H as Inner F ault"); | |||||
| 291 | } | |||||
| 292 | } | |||||
| 293 | } | |||||
| 294 | // Addit ional exce ptions to catch: Sec urityToken Validation Exception, ExpiredSe curityToke nException , | |||||
| 295 | // Secur ityAccessD eniedExcep tion, Mess ageSecurit yException , and Secu rityNegoti ationExcep tion. | |||||
| 296 | ||||||
| 297 | finally | |||||
| 298 | { | |||||
| 299 | ||||||
| 300 | Cons ole.WriteL ine("Press <Enter> t o exit."); | |||||
| 301 | Cons ole.ReadLi ne(); | |||||
| 302 | } | |||||
| 303 | ||||||
| 304 | } | |||||
| 305 | #e ndregion M ain | |||||
| 306 | ||||||
| 307 | } | |||||
| 308 | } | |||||
| 309 | //</snippe tDumpEntit yInfo> |
Araxis Merge (but not the data content of this report) is Copyright © 1993-2016 Araxis Ltd (www.araxis.com). All rights reserved.