Produced by Araxis Merge on 2/1/2017 2:56:23 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\BusinessDataModel\BusinessManagement | Merge.cs | Tue Dec 20 19:51:44 2016 UTC |
| 2 | Wed Feb 1 19:56:23 2017 UTC |
| Description | Between Files 1 and 2 |
|
|---|---|---|
| Text Blocks | Lines | |
| Unchanged | 0 | 0 |
| Changed | 0 | 0 |
| Inserted | 0 | 0 |
| Removed | 1 | 244 |
| 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 Merge> | |||||
| 17 | ||||||
| 18 | using Syst em; | |||||
| 19 | using Syst em.Service Model; | |||||
| 20 | using Micr osoft.Crm. Sdk.Messag es; | |||||
| 21 | using Micr osoft.Xrm. Sdk; | |||||
| 22 | using Micr osoft.Xrm. Sdk.Client ; | |||||
| 23 | using Micr osoft.Xrm. Sdk.Query; | |||||
| 24 | ||||||
| 25 | namespace Microsoft. Crm.Sdk.Sa mples | |||||
| 26 | { | |||||
| 27 | /// <s ummary> | |||||
| 28 | /// Th is sample shows how to merge t wo entity records. | |||||
| 29 | /// </ summary> | |||||
| 30 | /// <r emarks> | |||||
| 31 | /// At run-time, you will be given t he option to delete all the | |||||
| 32 | /// da tabase rec ords creat ed by this program. | |||||
| 33 | /// </ remarks> | |||||
| 34 | public class Mer ge | |||||
| 35 | { | |||||
| 36 | #r egion Clas s Level Me mbers | |||||
| 37 | pr ivate Orga nizationSe rviceProxy _serviceP roxy; | |||||
| 38 | pr ivate Guid _account1 Id; | |||||
| 39 | pr ivate Guid _account2 Id; | |||||
| 40 | #e ndregion | |||||
| 41 | ||||||
| 42 | #r egion How To Sample Code | |||||
| 43 | // / <summary > | |||||
| 44 | // / This met hod shows how to mer ge two ent ity record s with the Merge mes sage. | |||||
| 45 | // / </summar y> | |||||
| 46 | // / <param n ame="serve rConfig">C ontains se rver conne ction info rmation.</ param> | |||||
| 47 | // / <param n ame="promp tForDelete ">When Tru e, the use r will be prompted t o delete | |||||
| 48 | // / all crea ted entiti es.</param > | |||||
| 49 | pu blic void Run(Server Connection .Configura tion serve rConfig,bo ol promptF orDelete) | |||||
| 50 | { | |||||
| 51 | using (_ servicePro xy = new O rganizatio nServicePr oxy(server Config.Org anizationU ri, server Config.Hom eRealmUri, serverConf ig.Credent ials, serv erConfig.D eviceCrede ntials)) | |||||
| 52 | { | |||||
| 53 | // T his statem ent is req uired to e nable earl y-bound ty pe support . | |||||
| 54 | _ser viceProxy. EnableProx yTypes(); | |||||
| 55 | ||||||
| 56 | //Cr eate the C ontact and Incident required f or this sa mple. | |||||
| 57 | Crea teRequired Records(); | |||||
| 58 | ||||||
| 59 | //<s nippetMerg e1> | |||||
| 60 | // C reate the target for the reque st. | |||||
| 61 | En tityRefere nce target = new Ent ityReferen ce(); | |||||
| 62 | ||||||
| 63 | // Id is the GUID of t he account that is b eing merge d into. | |||||
| 64 | // L ogicalName is the ty pe of the entity bei ng merged to, as a s tring | |||||
| 65 | ta rget.Id = _account1I d; | |||||
| 66 | targ et.Logical Name = Acc ount.Entit yLogicalNa me; | |||||
| 67 | ||||||
| 68 | // C reate the request. | |||||
| 69 | Merg eRequest m erge = new MergeRequ est(); | |||||
| 70 | // S ubordinate Id is the GUID of th e account merging. | |||||
| 71 | merg e.Subordin ateId = _a ccount2Id; | |||||
| 72 | merg e.Target = target; | |||||
| 73 | merg e.PerformP arentingCh ecks = fal se; | |||||
| 74 | ||||||
| 75 | Cons ole.WriteL ine("\nMer ging accou nt2 into a ccount1 an d adding " + | |||||
| 76 | "\"test\" as Address 1 Line 1" ); | |||||
| 77 | ||||||
| 78 | // C reate anot her accoun t to hold new data t o merge in to the ent ity. | |||||
| 79 | // I f you use the subord inate acco unt object , its data will be m erged. | |||||
| 80 | Acco unt update Content = new Accoun t(); | |||||
| 81 | upda teContent. Address1_L ine1 = "te st"; | |||||
| 82 | ||||||
| 83 | // S et the con tent you w ant update d on the m erged acco unt | |||||
| 84 | merg e.UpdateCo ntent = up dateConten t; | |||||
| 85 | ||||||
| 86 | // E xecute the request. | |||||
| 87 | Merg eResponse merged = ( MergeRespo nse)_servi ceProxy.Ex ecute(merg e); | |||||
| 88 | //</ snippetMer ge1> | |||||
| 89 | ||||||
| 90 | Acco unt mergee Account = | |||||
| 91 | (Account)_ servicePro xy.Retriev e(Account. EntityLogi calName, | |||||
| 92 | _account2I d, new Col umnSet(all Columns:tr ue)); | |||||
| 93 | ||||||
| 94 | if(m ergeeAccou nt.Merged == true) | |||||
| 95 | { | |||||
| 96 | Account me rgedAccoun t = | |||||
| 97 | (Accou nt)_servic eProxy.Ret rieve(Acco unt.Entity LogicalNam e, | |||||
| 98 | _accou nt1Id, new ColumnSet (allColumn s: true)); | |||||
| 99 | ||||||
| 100 | Console.Wr iteLine("\ nAccounts merged suc cessfully into accou nt1"); | |||||
| 101 | Console.Wr iteLine(" Name: {0} ", mergedA ccount.Nam e); | |||||
| 102 | Console.Wr iteLine(" Descripti on: {0}", mergedAcco unt.Descri ption); | |||||
| 103 | Console.Wr iteLine(" Number of Employees : {0}", | |||||
| 104 | merged Account.Nu mberOfEmpl oyees); | |||||
| 105 | Console.Wr iteLine(" Address 1 Line 1: { 0}", | |||||
| 106 | merged Account.Ad dress1_Lin e1); | |||||
| 107 | } | |||||
| 108 | ||||||
| 109 | Dele teRequired Records(pr omptForDel ete); | |||||
| 110 | } | |||||
| 111 | } | |||||
| 112 | ||||||
| 113 | // / <summary > | |||||
| 114 | // / Creates any entity records t hat this s ample requ ires. | |||||
| 115 | // / </summar y> | |||||
| 116 | pu blic void CreateRequ iredRecord s() | |||||
| 117 | { | |||||
| 118 | // Creat e the firs t account, which wil l be merge d into | |||||
| 119 | Account account1 = new Accou nt(); | |||||
| 120 | account1 .Name = "F ourth Coff ee"; | |||||
| 121 | account1 .Descripti on = "Coff ee House"; | |||||
| 122 | ||||||
| 123 | _account 1Id = _ser viceProxy. Create(acc ount1); | |||||
| 124 | Console. WriteLine( "Account 1 created w ith GUID { {{0}}}", _ account1Id ); | |||||
| 125 | Console. WriteLine( " Name: { 0}", accou nt1.Name); | |||||
| 126 | Console. WriteLine( " Descrip tion: {0}" , account1 .Descripti on); | |||||
| 127 | ||||||
| 128 | // Creat e the seco nd account , which wi ll be merg ed from | |||||
| 129 | Account account2 = new Accou nt(); | |||||
| 130 | ||||||
| 131 | account2 .Name = "F ourth Coff ee"; | |||||
| 132 | account2 .NumberOfE mployees = 55; | |||||
| 133 | ||||||
| 134 | _account 2Id = _ser viceProxy. Create(acc ount2); | |||||
| 135 | Console. WriteLine( "Account 2 created w ith GUID { {{0}}}", _ account2Id ); | |||||
| 136 | Console. WriteLine( " Name: { 0}", accou nt2.Name); | |||||
| 137 | Console. WriteLine( " Number of Employe es: {0}", account2.N umberOfEmp loyees); | |||||
| 138 | } | |||||
| 139 | ||||||
| 140 | // / <summary > | |||||
| 141 | // / Deletes any entity records t hat were c reated for this samp le. | |||||
| 142 | // / <param n ame="promp t">Indicat es whether to prompt the user | |||||
| 143 | // / to delet e the reco rds create d in this sample.</p aram> | |||||
| 144 | // / </summar y> | |||||
| 145 | pu blic void DeleteRequ iredRecord s(bool pro mpt) | |||||
| 146 | { | |||||
| 147 | bool del eteRecords = true; | |||||
| 148 | ||||||
| 149 | if (prom pt) | |||||
| 150 | { | |||||
| 151 | Cons ole.Write( "\nDo you want these entity re cords dele ted? (y/n) [y]: "); | |||||
| 152 | Stri ng answer = Console. ReadLine() ; | |||||
| 153 | Cons ole.WriteL ine(); | |||||
| 154 | ||||||
| 155 | dele teRecords = (answer. StartsWith ("y") || a nswer.Star tsWith("Y" ) || | |||||
| 156 | answer == String.Emp ty); | |||||
| 157 | } | |||||
| 158 | ||||||
| 159 | if (dele teRecords) | |||||
| 160 | { | |||||
| 161 | _ser viceProxy. Delete(Acc ount.Entit yLogicalNa me, _accou nt1Id); | |||||
| 162 | _ser viceProxy. Delete(Acc ount.Entit yLogicalNa me, _accou nt2Id); | |||||
| 163 | Cons ole.WriteL ine("Entit y records have been deleted.") ; | |||||
| 164 | } | |||||
| 165 | } | |||||
| 166 | ||||||
| 167 | #e ndregion H ow To Samp le Code | |||||
| 168 | ||||||
| 169 | #r egion Main method | |||||
| 170 | ||||||
| 171 | // / <summary > | |||||
| 172 | // / Standard Main() me thod used by most SD K samples. | |||||
| 173 | // / </summar y> | |||||
| 174 | // / <param n ame="args" ></param> | |||||
| 175 | st atic publi c void Mai n(string[] args) | |||||
| 176 | { | |||||
| 177 | try | |||||
| 178 | { | |||||
| 179 | // O btain the target org anization' s Web addr ess and cl ient logon | |||||
| 180 | // c redentials from the user. | |||||
| 181 | Serv erConnecti on serverC onnect = n ew ServerC onnection( ); | |||||
| 182 | Serv erConnecti on.Configu ration con fig = | |||||
| 183 | serverConn ect.GetSer verConfigu ration(); | |||||
| 184 | ||||||
| 185 | var app = new Merge(); | |||||
| 186 | app. Run(config , true); | |||||
| 187 | } | |||||
| 188 | catch (F aultExcept ion<Micros oft.Xrm.Sd k.Organiza tionServic eFault> ex ) | |||||
| 189 | { | |||||
| 190 | Cons ole.WriteL ine("The a pplication terminate d with an error."); | |||||
| 191 | Cons ole.WriteL ine("Times tamp: {0}" , ex.Detai l.Timestam p); | |||||
| 192 | Cons ole.WriteL ine("Code: {0}", ex. Detail.Err orCode); | |||||
| 193 | Cons ole.WriteL ine("Messa ge: {0}", ex.Detail. Message); | |||||
| 194 | Cons ole.WriteL ine("Plugi n Trace: { 0}", ex.De tail.Trace Text); | |||||
| 195 | Cons ole.WriteL ine("Inner Fault: {0 }", | |||||
| 196 | null == ex .Detail.In nerFault ? "No Inner Fault" : "Has Inner Fault"); | |||||
| 197 | } | |||||
| 198 | catch (S ystem.Time outExcepti on ex) | |||||
| 199 | { | |||||
| 200 | Cons ole.WriteL ine("The a pplication terminate d with an error."); | |||||
| 201 | Cons ole.WriteL ine("Messa ge: {0}", ex.Message ); | |||||
| 202 | Cons ole.WriteL ine("Stack Trace: {0 }", ex.Sta ckTrace); | |||||
| 203 | Cons ole.WriteL ine("Inner Fault: {0 }", | |||||
| 204 | null == ex .InnerExce ption.Mess age ? "No Inner Faul t" : ex.In nerExcepti on.Message ); | |||||
| 205 | } | |||||
| 206 | catch (S ystem.Exce ption ex) | |||||
| 207 | { | |||||
| 208 | Cons ole.WriteL ine("The a pplication terminate d with an error."); | |||||
| 209 | Cons ole.WriteL ine(ex.Mes sage); | |||||
| 210 | ||||||
| 211 | // D isplay the details o f the inne r exceptio n. | |||||
| 212 | if ( ex.InnerEx ception != null) | |||||
| 213 | { | |||||
| 214 | Console.Wr iteLine(ex .InnerExce ption.Mess age); | |||||
| 215 | ||||||
| 216 | FaultExcep tion<Micro soft.Xrm.S dk.Organiz ationServi ceFault> f e = | |||||
| 217 | ex.Inn erExceptio n | |||||
| 218 | as Fau ltExceptio n<Microsof t.Xrm.Sdk. Organizati onServiceF ault>; | |||||
| 219 | if (fe != null) | |||||
| 220 | { | |||||
| 221 | Consol e.WriteLin e("Timesta mp: {0}", fe.Detail. Timestamp) ; | |||||
| 222 | Consol e.WriteLin e("Code: { 0}", fe.De tail.Error Code); | |||||
| 223 | Consol e.WriteLin e("Message : {0}", fe .Detail.Me ssage); | |||||
| 224 | Consol e.WriteLin e("Plugin Trace: {0} ", fe.Deta il.TraceTe xt); | |||||
| 225 | Consol e.WriteLin e("Inner F ault: {0}" , | |||||
| 226 | nu ll == fe.D etail.Inne rFault ? " No Inner F ault" : "H as Inner F ault"); | |||||
| 227 | } | |||||
| 228 | } | |||||
| 229 | } | |||||
| 230 | // Addit ional exce ptions to catch: Sec urityToken Validation Exception, | |||||
| 231 | // Expir edSecurity TokenExcep tion, Secu rityAccess DeniedExce ption, | |||||
| 232 | // Messa geSecurity Exception, and Secur ityNegotia tionExcept ion. | |||||
| 233 | ||||||
| 234 | finally | |||||
| 235 | { | |||||
| 236 | Cons ole.WriteL ine("Press <Enter> t o exit."); | |||||
| 237 | Cons ole.ReadLi ne(); | |||||
| 238 | } | |||||
| 239 | } | |||||
| 240 | #e ndregion M ain method | |||||
| 241 | } | |||||
| 242 | } | |||||
| 243 | ||||||
| 244 | //</snippe tMerge> |
Araxis Merge (but not the data content of this report) is Copyright © 1993-2016 Araxis Ltd (www.araxis.com). All rights reserved.