Produced by Araxis Merge on 2/1/2017 2:56:57 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\XRMTooling\QuickStartXRMToolingWPFClient | MainWindow.xaml.cs | Tue Dec 20 19:51:43 2016 UTC |
| 2 | Wed Feb 1 19:56:57 2017 UTC |
| Description | Between Files 1 and 2 |
|
|---|---|---|
| Text Blocks | Lines | |
| Unchanged | 0 | 0 |
| Changed | 0 | 0 |
| Inserted | 0 | 0 |
| Removed | 1 | 221 |
| 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 | // This s ample is c reated usi ng the CRM SDK Templ ate (WPF A pplication for CRM) | |||||
| 16 | // that p rovides a common log in control (LoginWin dow\CrmLog in.xaml)an d | |||||
| 17 | // built in authent ication an d credenti al-caching support. | |||||
| 18 | // For mo re informa tion, see http://go. microsoft. com/fwlink /?LinkId=5 21516. | |||||
| 19 | ||||||
| 20 | //<snippet CRUDOperat ionsusingX RMTooling> | |||||
| 21 | using Syst em; | |||||
| 22 | using Syst em.Collect ions.Gener ic; | |||||
| 23 | using Syst em.Linq; | |||||
| 24 | using Syst em.Text; | |||||
| 25 | using Syst em.Threadi ng.Tasks; | |||||
| 26 | using Syst em.Windows ; | |||||
| 27 | using Syst em.Windows .Controls; | |||||
| 28 | using Syst em.Windows .Data; | |||||
| 29 | using Syst em.Windows .Documents ; | |||||
| 30 | using Syst em.Windows .Input; | |||||
| 31 | using Syst em.Windows .Media; | |||||
| 32 | using Syst em.Windows .Media.Ima ging; | |||||
| 33 | using Syst em.Windows .Navigatio n; | |||||
| 34 | using Syst em.Windows .Shapes; | |||||
| 35 | ||||||
| 36 | // This na mespace is automatic ally added for using | |||||
| 37 | // compone nts in Log inWindow\C rmLogin.xa ml (common login con trol). | |||||
| 38 | using Quic kStartXRMT oolingWPFC lient.Logi nWindow; | |||||
| 39 | ||||||
| 40 | // Add thi s namespac e for perf orming | |||||
| 41 | // various operation s in CRM. | |||||
| 42 | using Micr osoft.Xrm. Tooling.Co nnector; | |||||
| 43 | ||||||
| 44 | namespace QuickStart XRMTooling WPFClient | |||||
| 45 | { | |||||
| 46 | /// <s ummary> | |||||
| 47 | /// In teraction logic for MainWindow .xaml | |||||
| 48 | /// </ summary> | |||||
| 49 | public partial c lass MainW indow : Wi ndow | |||||
| 50 | { | |||||
| 51 | // / <summary > | |||||
| 52 | // / Demonstr ates how t o do basic entity op erations l ike create , retrieve , | |||||
| 53 | // / update, and delete using the XRM Tooli ng APIs an d the comm on login | |||||
| 54 | // / control. </summary> | |||||
| 55 | // / <remarks > | |||||
| 56 | // / At run-t ime, you w ill be giv en the opt ion to del ete all th e | |||||
| 57 | // / database records c reated by this progr am.</remar ks> | |||||
| 58 | pu blic MainW indow() | |||||
| 59 | { | |||||
| 60 | Initiali zeComponen t(); | |||||
| 61 | btnDelet e.Visibili ty = Visib ility.Hidd en; // Hid e the Dele te button when the f orm loads. | |||||
| 62 | } | |||||
| 63 | ||||||
| 64 | #r egion Clas s Level Me mbers | |||||
| 65 | ||||||
| 66 | pr ivate CrmL ogin _ctrl = null; | |||||
| 67 | pr ivate Guid _accountI d; | |||||
| 68 | ||||||
| 69 | #e ndregion C lass Level Members | |||||
| 70 | ||||||
| 71 | #r egion How To Sample Code | |||||
| 72 | ||||||
| 73 | // / <summary > | |||||
| 74 | // / Connect to Microso ft Dynamic s CRM, and get an in stance of CRMService Client | |||||
| 75 | // / </summar y> | |||||
| 76 | ||||||
| 77 | pr ivate void LoginButt on_Click(o bject send er, Routed EventArgs e) | |||||
| 78 | { | |||||
| 79 | // Creat e an insta nce of the XRM Tooli ng common login cont rol | |||||
| 80 | _ctrl = new CrmLog in(); | |||||
| 81 | ||||||
| 82 | /// Wire event to the CRM si gn-in resp onse. | |||||
| 83 | _ctrl.Co nnectionTo CrmComplet ed += ctrl _Connectio nToCrmComp leted; | |||||
| 84 | UpdateSt atus("Init iating con nection to CRM..."); | |||||
| 85 | ||||||
| 86 | /// Show the XRM T ooling com mon login control. | |||||
| 87 | _ctrl.Sh owDialog() ; | |||||
| 88 | ||||||
| 89 | /// Vali date if yo u are conn ected to C RM | |||||
| 90 | if (_ctr l.CrmConne ctionMgr ! = null && _ctrl.CrmC onnectionM gr.CrmSvc != null && _ctrl.Crm Connection Mgr.CrmSvc .IsReady) | |||||
| 91 | { | |||||
| 92 | Upda teStatus(" Connected to CRM! (V ersion: " + _ctrl.Cr mConnectio nMgr.CrmSv c.Connecte dOrgVersio n.ToString () + | |||||
| 93 | "; Org: " + _ctrl.Cr mConnectio nMgr.CrmSv c.Connecte dOrgUnique Name.ToStr ing() + ") "); | |||||
| 94 | Upda teStatus(" ********** ********** ********** *********" ); | |||||
| 95 | Upda teStatus(" Click Star t to creat e, retriev e, update, and delet e (optiona l) an acco unt record ."); | |||||
| 96 | btnS ignIn.IsEn abled = fa lse; | |||||
| 97 | btnC RUD.IsEnab led = true ; | |||||
| 98 | } | |||||
| 99 | // If yo u are not connected to CRM; di splay the last error and last CRM excpti on | |||||
| 100 | else | |||||
| 101 | { | |||||
| 102 | Upda teStatus(" The connec tion to CR M failed o r was canc elled by t he user.") ; | |||||
| 103 | } | |||||
| 104 | } | |||||
| 105 | ||||||
| 106 | pr ivate void btnCRUD_C lick(objec t sender, RoutedEven tArgs e) | |||||
| 107 | { | |||||
| 108 | // Creat e an accou nt record | |||||
| 109 | Dictiona ry<string, CrmDataTy peWrapper> inData = new Dictio nary<strin g, CrmData TypeWrappe r>(); | |||||
| 110 | inData.A dd("name", new CrmDa taTypeWrap per("Sampl e Account Name", Crm FieldType. String)); | |||||
| 111 | inData.A dd("addres s1_city", new CrmDat aTypeWrapp er("Redmon d", CrmFie ldType.Str ing)); | |||||
| 112 | inData.A dd("teleph one1", new CrmDataTy peWrapper( "555-0160" , CrmField Type.Strin g)); | |||||
| 113 | _account Id = _ctrl .CrmConnec tionMgr.Cr mSvc.Creat eNewRecord ("account" , inData); | |||||
| 114 | ||||||
| 115 | // Valid ate if the account i s created, and then retrieve i t | |||||
| 116 | if (_acc ountId != Guid.Empty ) | |||||
| 117 | { | |||||
| 118 | Upda teStatus(" ********** ********** ********** *********" ); | |||||
| 119 | Upda teStatus(D ateTime.No w.ToString () + ": Cr eated an a ccount wit h the foll owing" + " \n" + "det ails, and retrieved it:"); | |||||
| 120 | Dict ionary<str ing, objec t> data = _ctrl.CrmC onnectionM gr.CrmSvc. GetEntityD ataById("a ccount", _ accountId, null); | |||||
| 121 | fore ach (var p air in dat a) | |||||
| 122 | { | |||||
| 123 | if ((pair. Key == "na me") || (p air.Key == "address1 _city") || (pair.Key == "telep hone1")) | |||||
| 124 | { | |||||
| 125 | Update Status(pai r.Key.ToUp per() + ": " + pair. Value); | |||||
| 126 | } | |||||
| 127 | } | |||||
| 128 | btnC RUD.IsEnab led = fals e; | |||||
| 129 | } | |||||
| 130 | else | |||||
| 131 | { | |||||
| 132 | Upda teStatus(" ********** ********** ********** *********" ); | |||||
| 133 | Upda teStatus(" Could not create the account." ); | |||||
| 134 | } | |||||
| 135 | ||||||
| 136 | ||||||
| 137 | // Updat e the acco unt record | |||||
| 138 | Dictiona ry<string, CrmDataTy peWrapper> updateDat a = new Di ctionary<s tring, Crm DataTypeWr apper>(); | |||||
| 139 | updateDa ta.Add("na me", new C rmDataType Wrapper("U pdated Sam ple Accoun t Name", C rmFieldTyp e.String)) ; | |||||
| 140 | updateDa ta.Add("ad dress1_cit y", new Cr mDataTypeW rapper("Bo ston", Crm FieldType. String)); | |||||
| 141 | updateDa ta.Add("te lephone1", new CrmDa taTypeWrap per("555-0 161", CrmF ieldType.S tring)); | |||||
| 142 | bool upd ateAccount Status = _ ctrl.CrmCo nnectionMg r.CrmSvc.U pdateEntit y("account ", "accoun tid", _acc ountId, up dateData); | |||||
| 143 | ||||||
| 144 | // Valid ate if the the accou nt record was update d successf ully, and then displ ay the upd ated infor mation | |||||
| 145 | if (upda teAccountS tatus == t rue) | |||||
| 146 | { | |||||
| 147 | Upda teStatus(" ********** ********** ********** *********" ); | |||||
| 148 | Upda teStatus(D ateTime.No w.ToString () + ": Up dated the account de tails as f ollows:"); | |||||
| 149 | Dict ionary<str ing, objec t> data = _ctrl.CrmC onnectionM gr.CrmSvc. GetEntityD ataById("a ccount", _ accountId, null); | |||||
| 150 | fore ach (var p air in dat a) | |||||
| 151 | { | |||||
| 152 | if ((pair. Key == "na me") || (p air.Key == "address1 _city") || (pair.Key == "telep hone1")) | |||||
| 153 | { | |||||
| 154 | Update Status(pai r.Key.ToUp per() + ": " + pair. Value); | |||||
| 155 | } | |||||
| 156 | } | |||||
| 157 | } | |||||
| 158 | else | |||||
| 159 | { | |||||
| 160 | Upda teStatus(" ********** ********** ********** *********" ); | |||||
| 161 | Upda teStatus(" Could not update the account." ); | |||||
| 162 | } | |||||
| 163 | ||||||
| 164 | // Promp t the user to delete the accou nt record created in the sampl e | |||||
| 165 | UpdateSt atus("**** ********** ********** ********** *****"); | |||||
| 166 | UpdateSt atus("To d elete the account re cord creat ed by the sample, cl ick Delete Record.") ; | |||||
| 167 | UpdateSt atus("Othe rwise, cli ck Exit to close the sample ap plication. "); | |||||
| 168 | btnDelet e.Visibili ty = Visib ility.Visi ble; | |||||
| 169 | } | |||||
| 170 | ||||||
| 171 | // Delete th e account record cre ated in th is sample. | |||||
| 172 | pr ivate void btnDelete _Click(obj ect sender , RoutedEv entArgs e) | |||||
| 173 | { | |||||
| 174 | btnDelet e.IsEnable d = false; | |||||
| 175 | _ctrl.Cr mConnectio nMgr.CrmSv c.DeleteEn tity("acco unt", _acc ountId); | |||||
| 176 | UpdateSt atus("**** ********** ********** ********** *****"); | |||||
| 177 | UpdateSt atus(DateT ime.Now.To String() + ": Delete d the acco unt record ."); | |||||
| 178 | UpdateSt atus("Clic k Exit to close the sample app lication." ); | |||||
| 179 | } | |||||
| 180 | ||||||
| 181 | // Exit the sample app lication | |||||
| 182 | pr ivate void btnExit_C lick(objec t sender, RoutedEven tArgs e) | |||||
| 183 | { | |||||
| 184 | this.Clo se(); | |||||
| 185 | } | |||||
| 186 | ||||||
| 187 | // / <summary > | |||||
| 188 | // / Progress ively disp lays the s tatus mess ages about the actio ns | |||||
| 189 | // / performe d during t he running of the sa mple. | |||||
| 190 | // / <param n ame="updat eText">Ind icates the status st ring that needs to b e | |||||
| 191 | // / displaye d to the u ser.</para m> | |||||
| 192 | // / </summar y> | |||||
| 193 | pu blic void UpdateStat us(string updateText ) | |||||
| 194 | { | |||||
| 195 | if (lblS tatus.Cont ent.ToStri ng() != St ring.Empty ) | |||||
| 196 | { | |||||
| 197 | lblS tatus.Cont ent = lblS tatus.Cont ent + "\n" + updateT ext; | |||||
| 198 | } | |||||
| 199 | else | |||||
| 200 | { | |||||
| 201 | lblS tatus.Cont ent = upda teText; | |||||
| 202 | } | |||||
| 203 | } | |||||
| 204 | ||||||
| 205 | // / <summary > | |||||
| 206 | // / Raised w hen the lo gin proces s is compl eted. | |||||
| 207 | // / </summar y> | |||||
| 208 | pr ivate void ctrl_Conn ectionToCr mCompleted (object se nder, Even tArgs e) | |||||
| 209 | { | |||||
| 210 | if (send er is CrmL ogin) | |||||
| 211 | { | |||||
| 212 | this .Dispatche r.Invoke(( ) => | |||||
| 213 | { | |||||
| 214 | ((CrmLogin )sender).C lose(); | |||||
| 215 | }); | |||||
| 216 | } | |||||
| 217 | } | |||||
| 218 | } | |||||
| 219 | #endre gion How T o Sample C ode | |||||
| 220 | } | |||||
| 221 | //</snippe tCRUDOpera tionsusing XRMTooling > |
Araxis Merge (but not the data content of this report) is Copyright © 1993-2016 Araxis Ltd (www.araxis.com). All rights reserved.