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\Other | ImportOrRemoveSampleData.cs | Tue Dec 20 19:51:45 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 | 177 |
| 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 | // This f ile is par t of the M icrosoft D ynamics CR M SDK Code Samples. | |||||
| 3 | // | |||||
| 4 | // Copyri ght (C) Mi crosoft Co rporation. All righ ts reserve d. | |||||
| 5 | // | |||||
| 6 | // This s ource code is intend ed only as a supplem ent to Mic rosoft | |||||
| 7 | // Develo pment Tool s and/or o n-line doc umentation . See the se other | |||||
| 8 | // materi als for de tailed inf ormation r egarding M icrosoft c ode sample s. | |||||
| 9 | // | |||||
| 10 | // THIS C ODE AND IN FORMATION ARE PROVID ED "AS IS" WITHOUT W ARRANTY OF ANY | |||||
| 11 | // KIND, EITHER EXP RESSED OR IMPLIED, I NCLUDING B UT NOT LIM ITED TO TH E | |||||
| 12 | // IMPLIE D WARRANTI ES OF MERC HANTABILIT Y AND/OR F ITNESS FOR A | |||||
| 13 | // PARTIC ULAR PURPO SE. | |||||
| 14 | // ======= ========== ========== ========== ========== ========== ========== ========== = | |||||
| 15 | ||||||
| 16 | //<snippet ImportOrRe moveSample Data> | |||||
| 17 | using Syst em; | |||||
| 18 | using Syst em.Service Model; | |||||
| 19 | ||||||
| 20 | // These n amespaces are found in the Mic rosoft.Xrm .Sdk.dll a ssembly | |||||
| 21 | // found i n the SDK\ bin folder . | |||||
| 22 | using Micr osoft.Xrm. Sdk.Client ; | |||||
| 23 | ||||||
| 24 | // This na mespace is found in Microsoft. Crm.Sdk.Pr oxy.dll as sembly | |||||
| 25 | // found i n the SDK\ bin folder . | |||||
| 26 | using Micr osoft.Crm. Sdk.Messag es; | |||||
| 27 | ||||||
| 28 | namespace Microsoft. Crm.Sdk.Sa mples | |||||
| 29 | { | |||||
| 30 | /// <s ummary> | |||||
| 31 | /// In stall or u ninstall t he Microso ft Dynamic s CRM samp le data re cords. | |||||
| 32 | /// </ summary> | |||||
| 33 | public class Imp ortOrRemov eSampleDat a | |||||
| 34 | { | |||||
| 35 | ||||||
| 36 | #r egion Clas s Level Me mbers | |||||
| 37 | ||||||
| 38 | pr ivate Orga nizationSe rviceProxy _serviceP roxy; | |||||
| 39 | ||||||
| 40 | #e ndregion C lass Level Members | |||||
| 41 | ||||||
| 42 | #r egion How- To Sample Code | |||||
| 43 | // / <summary > | |||||
| 44 | // / Demonstr ates how t o programm atically i nstall and uninstall the Micro soft | |||||
| 45 | // / Dynamics CRM sampl e data rec ords. | |||||
| 46 | // / </summar y> | |||||
| 47 | // / <param n ame="serve rConfig">C ontains se rver conne ction info rmation.</ param> | |||||
| 48 | // / <param n ame="promp tforDelete ">Not appl icable for this samp le.</param > | |||||
| 49 | pu blic void Run(Server Connection .Configura tion serve rConfig, b ool prompt forDelete) | |||||
| 50 | { | |||||
| 51 | try | |||||
| 52 | { | |||||
| 53 | // C onnect to the Organi zation ser vice. | |||||
| 54 | // T he using s tatement a ssures tha t the serv ice proxy will be pr operly dis posed. | |||||
| 55 | 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 )) | |||||
| 56 | { | |||||
| 57 | // This st atement is required to enable early-boun d type sup port. | |||||
| 58 | _servicePr oxy.Enable ProxyTypes (); | |||||
| 59 | //<snippet ImportOrRe moveSample Data1> | |||||
| 60 | ||||||
| 61 | // Prompt user to in stall/unin stall samp le data. | |||||
| 62 | Console.Wr iteLine("W ould you l ike to:"); | |||||
| 63 | Console.Wr iteLine("1 ) Install sample dat a for Micr osoft Dyna mics CRM?" ); | |||||
| 64 | Console.Wr iteLine("2 ) Uninstal l sample d ata for Mi crosoft Dy namics CRM ?"); | |||||
| 65 | Console.Wr ite("Press [1] to In stall, [2] to Uninst all: "); | |||||
| 66 | String ans wer = Cons ole.ReadLi ne(); | |||||
| 67 | ||||||
| 68 | // Update the sample data base d on the u ser's resp onse. | |||||
| 69 | switch (an swer) | |||||
| 70 | { | |||||
| 71 | case " 1": | |||||
| 72 | Co nsole.Writ eLine("Ins talling sa mple data. .."); | |||||
| 73 | In stallSampl eDataReque st request = | |||||
| 74 | new Inst allSampleD ataRequest (); | |||||
| 75 | In stallSampl eDataRespo nse respon se = | |||||
| 76 | (Install SampleData Response)_ servicePro xy.Execute (request); | |||||
| 77 | Co nsole.Writ eLine("Sam ple data s uccessfull y installe d."); | |||||
| 78 | br eak; | |||||
| 79 | case " 2": | |||||
| 80 | Co nsole.Writ eLine("Uni nstalling sample dat a..."); | |||||
| 81 | Un installSam pleDataReq uest reque st2 = | |||||
| 82 | new Unin stallSampl eDataReque st(); | |||||
| 83 | Un installSam pleDataRes ponse resp onse2 = | |||||
| 84 | (Uninsta llSampleDa taResponse )_serviceP roxy.Execu te(request 2); | |||||
| 85 | Co nsole.Writ eLine("Sam ple data s uccessfull y uninstal led."); | |||||
| 86 | br eak; | |||||
| 87 | defaul t: | |||||
| 88 | Co nsole.Writ eLine("Nei ther optio n was sele cted. No c hanges hav e been mad e to your records.") ; | |||||
| 89 | br eak; | |||||
| 90 | } | |||||
| 91 | ||||||
| 92 | } | |||||
| 93 | //</ snippetImp ortOrRemov eSampleDat a1> | |||||
| 94 | } | |||||
| 95 | ||||||
| 96 | // Catch any servi ce fault e xceptions that Micro soft Dynam ics CRM th rows. | |||||
| 97 | catch (F aultExcept ion<Micros oft.Xrm.Sd k.Organiza tionServic eFault>) | |||||
| 98 | { | |||||
| 99 | // Y ou can han dle an exc eption her e or pass it back to the calli ng method. | |||||
| 100 | thro w; | |||||
| 101 | } | |||||
| 102 | } | |||||
| 103 | ||||||
| 104 | #e ndregion H ow-To Samp le Code | |||||
| 105 | ||||||
| 106 | #r egion Main method | |||||
| 107 | ||||||
| 108 | // / <summary > | |||||
| 109 | // / Standard Main() me thod used by most SD K samples. | |||||
| 110 | // / </summar y> | |||||
| 111 | // / <param n ame="args" ></param> | |||||
| 112 | st atic publi c void Mai n(string[] args) | |||||
| 113 | { | |||||
| 114 | try | |||||
| 115 | { | |||||
| 116 | // O btain the target org anization' s Web addr ess and cl ient logon | |||||
| 117 | // c redentials from the user. | |||||
| 118 | Serv erConnecti on serverC onnect = n ew ServerC onnection( ); | |||||
| 119 | Serv erConnecti on.Configu ration con fig = serv erConnect. GetServerC onfigurati on(); | |||||
| 120 | ||||||
| 121 | Impo rtOrRemove SampleData app = new ImportOrR emoveSampl eData(); | |||||
| 122 | app. Run(config , true); | |||||
| 123 | } | |||||
| 124 | catch (F aultExcept ion<Micros oft.Xrm.Sd k.Organiza tionServic eFault> ex ) | |||||
| 125 | { | |||||
| 126 | Cons ole.WriteL ine("The a pplication terminate d with an error."); | |||||
| 127 | Cons ole.WriteL ine("Times tamp: {0}" , ex.Detai l.Timestam p); | |||||
| 128 | Cons ole.WriteL ine("Code: {0}", ex. Detail.Err orCode); | |||||
| 129 | Cons ole.WriteL ine("Messa ge: {0}", ex.Detail. Message); | |||||
| 130 | Cons ole.WriteL ine("Plugi n Trace: { 0}", ex.De tail.Trace Text); | |||||
| 131 | Cons ole.WriteL ine("Inner Fault: {0 }", | |||||
| 132 | null == ex .Detail.In nerFault ? "No Inner Fault" : "Has Inner Fault"); | |||||
| 133 | } | |||||
| 134 | catch (S ystem.Time outExcepti on ex) | |||||
| 135 | { | |||||
| 136 | Cons ole.WriteL ine("The a pplication terminate d with an error."); | |||||
| 137 | Cons ole.WriteL ine("Messa ge: {0}", ex.Message ); | |||||
| 138 | Cons ole.WriteL ine("Stack Trace: {0 }", ex.Sta ckTrace); | |||||
| 139 | Cons ole.WriteL ine("Inner Fault: {0 }", | |||||
| 140 | null == ex .InnerExce ption.Mess age ? "No Inner Faul t" : ex.In nerExcepti on.Message ); | |||||
| 141 | } | |||||
| 142 | catch (S ystem.Exce ption ex) | |||||
| 143 | { | |||||
| 144 | Cons ole.WriteL ine("The a pplication terminate d with an error."); | |||||
| 145 | Cons ole.WriteL ine(ex.Mes sage); | |||||
| 146 | ||||||
| 147 | // D isplay the details o f the inne r exceptio n. | |||||
| 148 | if ( ex.InnerEx ception != null) | |||||
| 149 | { | |||||
| 150 | Console.Wr iteLine(ex .InnerExce ption.Mess age); | |||||
| 151 | ||||||
| 152 | FaultExcep tion<Micro soft.Xrm.S dk.Organiz ationServi ceFault> f e = ex.Inn erExceptio n | |||||
| 153 | as Fau ltExceptio n<Microsof t.Xrm.Sdk. Organizati onServiceF ault>; | |||||
| 154 | if (fe != null) | |||||
| 155 | { | |||||
| 156 | Consol e.WriteLin e("Timesta mp: {0}", fe.Detail. Timestamp) ; | |||||
| 157 | Consol e.WriteLin e("Code: { 0}", fe.De tail.Error Code); | |||||
| 158 | Consol e.WriteLin e("Message : {0}", fe .Detail.Me ssage); | |||||
| 159 | Consol e.WriteLin e("Plugin Trace: {0} ", fe.Deta il.TraceTe xt); | |||||
| 160 | Consol e.WriteLin e("Inner F ault: {0}" , | |||||
| 161 | nu ll == fe.D etail.Inne rFault ? " No Inner F ault" : "H as Inner F ault"); | |||||
| 162 | } | |||||
| 163 | } | |||||
| 164 | } | |||||
| 165 | // Addit ional exce ptions to catch: Sec urityToken Validation Exception, ExpiredSe curityToke nException , | |||||
| 166 | // Secur ityAccessD eniedExcep tion, Mess ageSecurit yException , and Secu rityNegoti ationExcep tion. | |||||
| 167 | ||||||
| 168 | finally | |||||
| 169 | { | |||||
| 170 | Cons ole.WriteL ine("Press <Enter> t o exit."); | |||||
| 171 | Cons ole.ReadLi ne(); | |||||
| 172 | } | |||||
| 173 | } | |||||
| 174 | #e ndregion M ain method | |||||
| 175 | } | |||||
| 176 | } | |||||
| 177 | //</snippe tImportOrR emoveSampl eData> |
Araxis Merge (but not the data content of this report) is Copyright © 1993-2016 Araxis Ltd (www.araxis.com). All rights reserved.