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 | CRUDOperationsDE.cs | Tue Dec 20 19:51:46 2016 UTC |
| 2 | Wed Feb 1 19:56:33 2017 UTC |
| Description | Between Files 1 and 2 |
|
|---|---|---|
| Text Blocks | Lines | |
| Unchanged | 0 | 0 |
| Changed | 0 | 0 |
| Inserted | 0 | 0 |
| Removed | 1 | 214 |
| 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 CRUDOperat ionsDE> | |||||
| 18 | using Syst em; | |||||
| 19 | using Syst em.Service Model; | |||||
| 20 | using Syst em.Service Model.Desc ription; | |||||
| 21 | ||||||
| 22 | // These n amespaces are found in the Mic rosoft.Xrm .Sdk.dll a ssembly | |||||
| 23 | // found i n the SDK\ bin folder . | |||||
| 24 | using Micr osoft.Xrm. Sdk; | |||||
| 25 | using Micr osoft.Xrm. Sdk.Client ; | |||||
| 26 | using Micr osoft.Xrm. Sdk.Query; | |||||
| 27 | using Micr osoft.Xrm. Sdk.Discov ery; | |||||
| 28 | ||||||
| 29 | namespace Microsoft. Crm.Sdk.Sa mples | |||||
| 30 | { | |||||
| 31 | /// <s ummary> | |||||
| 32 | /// De monstrates how to do basic ent ity operat ions like create, re trieve, | |||||
| 33 | /// up date, and delete. | |||||
| 34 | /// If you want to run thi s sample r epeatedly, you have the option to | |||||
| 35 | /// de lete all t he records created a t the end of executi on. | |||||
| 36 | /// </ summary> | |||||
| 37 | public class CRU DOperation sDE | |||||
| 38 | { | |||||
| 39 | #r egion Clas s Level Me mbers | |||||
| 40 | // / <summary > | |||||
| 41 | // / Stores t he organiz ation serv ice proxy. | |||||
| 42 | // / </summar y> | |||||
| 43 | pr ivate Orga nizationSe rviceProxy _serviceP roxy; | |||||
| 44 | pr ivate IOrg anizationS ervice _se rvice; | |||||
| 45 | ||||||
| 46 | // Define th e IDs need ed for thi s sample. | |||||
| 47 | pr ivate Guid _accountI d; | |||||
| 48 | ||||||
| 49 | #e ndregion C lass Level Members | |||||
| 50 | ||||||
| 51 | #r egion How To Sample Code | |||||
| 52 | // / <summary > | |||||
| 53 | // / Create a nd configu re the org anization service pr oxy. | |||||
| 54 | // / Create a n account record | |||||
| 55 | // / Retrieve the accou nt record | |||||
| 56 | // / Update t he account record | |||||
| 57 | // / Optional ly delete any entity records t hat were c reated for this samp le. | |||||
| 58 | /// </summary > | |||||
| 59 | // / <param n ame="serve rConfig">C ontains se rver conne ction info rmation.</ param> | |||||
| 60 | // / <param n ame="promp tForDelete ">When Tru e, the use r will be prompted t o delete | |||||
| 61 | // / all crea ted entiti es.</param > | |||||
| 62 | pu blic void Run(Server Connection .Configura tion serve rConfig, b ool prompt ForDelete) | |||||
| 63 | { | |||||
| 64 | try | |||||
| 65 | { | |||||
| 66 | ||||||
| 67 | // C onnect to the Organi zation ser vice. | |||||
| 68 | // T he using s tatement a ssures tha t the serv ice proxy will be pr operly dis posed. | |||||
| 69 | 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 )) | |||||
| 70 | { | |||||
| 71 | _service = (IOrganiz ationServi ce)_servic eProxy; | |||||
| 72 | ||||||
| 73 | //<snippet CRUDOperat ionsDE1> | |||||
| 74 | // Instani ate an acc ount objec t. | |||||
| 75 | Entity acc ount = new Entity("a ccount"); | |||||
| 76 | ||||||
| 77 | // Set the required attributes . For acco unt, only the name i s required . | |||||
| 78 | // See the Entity Me tadata top ic in the SDK docume ntatio to determine | |||||
| 79 | // which a ttributes must be se t for each entity. | |||||
| 80 | account["n ame"] = "F ourth Coff ee"; | |||||
| 81 | ||||||
| 82 | // Create an account record na med Fourth Coffee. | |||||
| 83 | _accountId = _servic e.Create(a ccount); | |||||
| 84 | ||||||
| 85 | Console.Wr ite("{0} { 1} created , ", accou nt.Logical Name, acco unt.Attrib utes["name "]); | |||||
| 86 | ||||||
| 87 | // Create a column s et to defi ne which a ttributes should be retrieved. | |||||
| 88 | ColumnSet attributes = new Col umnSet(new string[] { "name", "ownerid" }); | |||||
| 89 | ||||||
| 90 | // Retriev e the acco unt and it s name and ownerid a ttributes. | |||||
| 91 | account = _service.R etrieve(ac count.Logi calName, _ accountId, attribute s); | |||||
| 92 | Console.Wr ite("retri eved, "); | |||||
| 93 | ||||||
| 94 | // Update the postal code attr ibute. | |||||
| 95 | account["a ddress1_po stalcode"] = "98052" ; | |||||
| 96 | ||||||
| 97 | // The add ress 2 pos tal code w as set acc identally, so set it to null. | |||||
| 98 | account["a ddress2_po stalcode"] = null; | |||||
| 99 | ||||||
| 100 | // Shows u se of Mone y. | |||||
| 101 | account["r evenue"] = new Money (5000000); | |||||
| 102 | ||||||
| 103 | // Shows u se of bool ean. | |||||
| 104 | account["c reditonhol d"] = fals e; | |||||
| 105 | ||||||
| 106 | // Update the accoun t. | |||||
| 107 | _service.U pdate(acco unt); | |||||
| 108 | Console.Wr iteLine("a nd updated ."); | |||||
| 109 | ||||||
| 110 | // Delete the accoun t. | |||||
| 111 | bool delet eRecords = true; | |||||
| 112 | ||||||
| 113 | if (prompt ForDelete) | |||||
| 114 | { | |||||
| 115 | Consol e.WriteLin e("\nDo yo u want the se entity records de leted? (y/ n) [y]: ") ; | |||||
| 116 | String answer = Console.Re adLine(); | |||||
| 117 | ||||||
| 118 | delete Records = (answer.St artsWith(" y") || ans wer.Starts With("Y") || answer == String. Empty); | |||||
| 119 | } | |||||
| 120 | ||||||
| 121 | if (delete Records) | |||||
| 122 | { | |||||
| 123 | _servi ce.Delete( "account", _accountI d); | |||||
| 124 | ||||||
| 125 | Consol e.WriteLin e("Entity record(s) have been deleted.") ; | |||||
| 126 | } | |||||
| 127 | ||||||
| 128 | //</snippe tCRUDOpera tionsDE1> | |||||
| 129 | } | |||||
| 130 | } | |||||
| 131 | ||||||
| 132 | // Catch any servi ce fault e xceptions that Micro soft Dynam ics CRM th rows. | |||||
| 133 | catch (F aultExcept ion<Micros oft.Xrm.Sd k.Organiza tionServic eFault>) | |||||
| 134 | { | |||||
| 135 | // Y ou can han dle an exc eption her e or pass it back to the calli ng method. | |||||
| 136 | thro w; | |||||
| 137 | } | |||||
| 138 | } | |||||
| 139 | ||||||
| 140 | #e ndregion H ow To Samp le Code | |||||
| 141 | ||||||
| 142 | #r egion Main | |||||
| 143 | // / <summary > | |||||
| 144 | // / Standard Main() me thod used by most SD K samples. | |||||
| 145 | // / </summar y> | |||||
| 146 | // / <param n ame="args" ></param> | |||||
| 147 | st atic publi c void Mai n(string[] args) | |||||
| 148 | { | |||||
| 149 | try | |||||
| 150 | { | |||||
| 151 | // O btain the target org anization' s Web addr ess and cl ient logon | |||||
| 152 | // c redentials from the user. | |||||
| 153 | Serv erConnecti on serverC onnect = n ew ServerC onnection( ); | |||||
| 154 | Serv erConnecti on.Configu ration con fig = serv erConnect. GetServerC onfigurati on(); | |||||
| 155 | ||||||
| 156 | CRUD Operations DE app = n ew CRUDOpe rationsDE( ); | |||||
| 157 | app. Run(config , true); | |||||
| 158 | } | |||||
| 159 | catch (F aultExcept ion<Micros oft.Xrm.Sd k.Organiza tionServic eFault> ex ) | |||||
| 160 | { | |||||
| 161 | Cons ole.WriteL ine("The a pplication terminate d with an error."); | |||||
| 162 | Cons ole.WriteL ine("Times tamp: {0}" , ex.Detai l.Timestam p); | |||||
| 163 | Cons ole.WriteL ine("Code: {0}", ex. Detail.Err orCode); | |||||
| 164 | Cons ole.WriteL ine("Messa ge: {0}", ex.Detail. Message); | |||||
| 165 | Cons ole.WriteL ine("Plugi n Trace: { 0}", ex.De tail.Trace Text); | |||||
| 166 | Cons ole.WriteL ine("Inner Fault: {0 }", | |||||
| 167 | null == ex .Detail.In nerFault ? "No Inner Fault" : "Has Inner Fault"); | |||||
| 168 | } | |||||
| 169 | catch (S ystem.Time outExcepti on ex) | |||||
| 170 | { | |||||
| 171 | Cons ole.WriteL ine("The a pplication terminate d with an error."); | |||||
| 172 | Cons ole.WriteL ine("Messa ge: {0}", ex.Message ); | |||||
| 173 | Cons ole.WriteL ine("Stack Trace: {0 }", ex.Sta ckTrace); | |||||
| 174 | Cons ole.WriteL ine("Inner Fault: {0 }", | |||||
| 175 | null == ex .InnerExce ption.Mess age ? "No Inner Faul t" : ex.In nerExcepti on.Message ); | |||||
| 176 | } | |||||
| 177 | catch (S ystem.Exce ption ex) | |||||
| 178 | { | |||||
| 179 | Cons ole.WriteL ine("The a pplication terminate d with an error."); | |||||
| 180 | Cons ole.WriteL ine(ex.Mes sage); | |||||
| 181 | ||||||
| 182 | // D isplay the details o f the inne r exceptio n. | |||||
| 183 | if ( ex.InnerEx ception != null) | |||||
| 184 | { | |||||
| 185 | Console.Wr iteLine(ex .InnerExce ption.Mess age); | |||||
| 186 | ||||||
| 187 | FaultExcep tion<Micro soft.Xrm.S dk.Organiz ationServi ceFault> f e = ex.Inn erExceptio n | |||||
| 188 | as Fau ltExceptio n<Microsof t.Xrm.Sdk. Organizati onServiceF ault>; | |||||
| 189 | if (fe != null) | |||||
| 190 | { | |||||
| 191 | Consol e.WriteLin e("Timesta mp: {0}", fe.Detail. Timestamp) ; | |||||
| 192 | Consol e.WriteLin e("Code: { 0}", fe.De tail.Error Code); | |||||
| 193 | Consol e.WriteLin e("Message : {0}", fe .Detail.Me ssage); | |||||
| 194 | Consol e.WriteLin e("Plugin Trace: {0} ", fe.Deta il.TraceTe xt); | |||||
| 195 | Consol e.WriteLin e("Inner F ault: {0}" , | |||||
| 196 | nu ll == fe.D etail.Inne rFault ? " No Inner F ault" : "H as Inner F ault"); | |||||
| 197 | } | |||||
| 198 | } | |||||
| 199 | } | |||||
| 200 | // Addit ional exce ptions to catch: Sec urityToken Validation Exception, ExpiredSe curityToke nException , | |||||
| 201 | // Secur ityAccessD eniedExcep tion, Mess ageSecurit yException , and Secu rityNegoti ationExcep tion. | |||||
| 202 | ||||||
| 203 | finally | |||||
| 204 | { | |||||
| 205 | ||||||
| 206 | Cons ole.WriteL ine("Press <Enter> t o exit."); | |||||
| 207 | Cons ole.ReadLi ne(); | |||||
| 208 | } | |||||
| 209 | ||||||
| 210 | } | |||||
| 211 | #e ndregion M ain | |||||
| 212 | } | |||||
| 213 | } | |||||
| 214 | //</snippe tCRUDOpera tionsDE> |
Araxis Merge (but not the data content of this report) is Copyright © 1993-2016 Araxis Ltd (www.araxis.com). All rights reserved.