Produced by Araxis Merge on 2/1/2017 2:56:22 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\Activities | ConvertFaxToTask.cs | Tue Dec 20 19:51:44 2016 UTC |
| 2 | Wed Feb 1 19:56:22 2017 UTC |
| Description | Between Files 1 and 2 |
|
|---|---|---|
| Text Blocks | Lines | |
| Unchanged | 0 | 0 |
| Changed | 0 | 0 |
| Inserted | 0 | 0 |
| Removed | 1 | 240 |
| 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 ConvertFax ToTask> | |||||
| 18 | using Syst em; | |||||
| 19 | using Syst em.Service Model; | |||||
| 20 | using Syst em.Service Model.Desc ription; | |||||
| 21 | using Syst em.Text; | |||||
| 22 | ||||||
| 23 | // These n amespaces are found in the Mic rosoft.Xrm .Sdk.dll a ssembly | |||||
| 24 | // found i n the SDK\ bin folder . | |||||
| 25 | using Micr osoft.Xrm. Sdk; | |||||
| 26 | using Micr osoft.Xrm. Sdk.Query; | |||||
| 27 | using Micr osoft.Xrm. Sdk.Discov ery; | |||||
| 28 | using Micr osoft.Xrm. Sdk.Messag es; | |||||
| 29 | using Micr osoft.Xrm. Sdk.Client ; | |||||
| 30 | ||||||
| 31 | ||||||
| 32 | // This na mespace is found in Microsoft. Crm.Sdk.Pr oxy.dll as sembly | |||||
| 33 | // found i n the SDK\ bin folder . | |||||
| 34 | using Micr osoft.Crm. Sdk.Messag es; | |||||
| 35 | ||||||
| 36 | namespace Microsoft. Crm.Sdk.Sa mples | |||||
| 37 | { | |||||
| 38 | public class Con vertFaxToT ask | |||||
| 39 | { | |||||
| 40 | #r egion Clas s Level Me mbers | |||||
| 41 | ||||||
| 42 | // / <summary > | |||||
| 43 | // / Stores t he organiz ation serv ice proxy. | |||||
| 44 | // / </summar y> | |||||
| 45 | pr ivate Orga nizationSe rviceProxy _serviceP roxy; | |||||
| 46 | ||||||
| 47 | // Define th e IDs need ed for thi s sample. | |||||
| 48 | pr ivate Guid _faxId; | |||||
| 49 | pr ivate Guid _taskId; | |||||
| 50 | pr ivate Guid _userId; | |||||
| 51 | ||||||
| 52 | #e ndregion C lass Level Members | |||||
| 53 | ||||||
| 54 | #r egion How To Sample Code | |||||
| 55 | // / <summary > | |||||
| 56 | // / Convert a fax to a task. | |||||
| 57 | // / <param n ame="serve rConfig">C ontains se rver conne ction info rmation.</ param> | |||||
| 58 | // / <param n ame="promp tforDelete ">When Tru e, the use r will be prompted t o delete a ll | |||||
| 59 | // / created entities.< /param> | |||||
| 60 | // / </summar y> | |||||
| 61 | pu blic void Run(Server Connection .Configura tion serve rConfig, b ool prompt ForDelete) | |||||
| 62 | { | |||||
| 63 | try | |||||
| 64 | { | |||||
| 65 | // C onnect to the Organi zation ser vice. | |||||
| 66 | // T he using s tatement a ssures tha t the serv ice proxy will be pr operly dis posed. | |||||
| 67 | usin g (_servic eProxy = n ew Organiz ationServi ceProxy(se rverConfig .Organizat ionUri, se rverConfig .HomeRealm Uri, | |||||
| 68 | s erverConfi g.Credenti als, serve rConfig.De viceCreden tials)) | |||||
| 69 | { | |||||
| 70 | // This st atement is required to enable early-boun d type sup port. | |||||
| 71 | _servicePr oxy.Enable ProxyTypes (); | |||||
| 72 | ||||||
| 73 | // Call th e method t o create a ny data th at this sa mple requi res. | |||||
| 74 | CreateRequ iredRecord s(); | |||||
| 75 | ||||||
| 76 | //<snippet ConvertFax ToTask1> | |||||
| 77 | ||||||
| 78 | // Retriev e the fax. | |||||
| 79 | Fax retrie vedFax = ( Fax)_servi ceProxy.Re trieve(Fax .EntityLog icalName, _faxId, ne w ColumnSe t(true)); | |||||
| 80 | ||||||
| 81 | // Create a task. | |||||
| 82 | Task task = new Task () | |||||
| 83 | { | |||||
| 84 | Subjec t = "Follo w Up: " + retrievedF ax.Subject , | |||||
| 85 | Schedu ledEnd = r etrievedFa x.CreatedO n.Value.Ad dDays(7), | |||||
| 86 | }; | |||||
| 87 | _taskId = _servicePr oxy.Create (task); | |||||
| 88 | ||||||
| 89 | // Verify that the t ask has be en created | |||||
| 90 | if (_taskI d != Guid. Empty) | |||||
| 91 | { | |||||
| 92 | Consol e.WriteLin e("Created a task fo r the fax: '{0}'.", task.Subje ct); | |||||
| 93 | } | |||||
| 94 | ||||||
| 95 | //</snippe tConvertFa xToTask1> | |||||
| 96 | ||||||
| 97 | DeleteRequ iredRecord s(promptFo rDelete); | |||||
| 98 | } | |||||
| 99 | } | |||||
| 100 | ||||||
| 101 | // Catch any servi ce fault e xceptions that Micro soft Dynam ics CRM th rows. | |||||
| 102 | catch (F aultExcept ion<Micros oft.Xrm.Sd k.Organiza tionServic eFault>) | |||||
| 103 | { | |||||
| 104 | // Y ou can han dle an exc eption her e or pass it back to the calli ng method. | |||||
| 105 | thro w; | |||||
| 106 | } | |||||
| 107 | } | |||||
| 108 | ||||||
| 109 | ||||||
| 110 | // / <summary > | |||||
| 111 | // / This met hod create s any enti ty records that this sample re quires. | |||||
| 112 | // / </summar y> | |||||
| 113 | pu blic void CreateRequ iredRecord s() | |||||
| 114 | { | |||||
| 115 | // Get t he current user. | |||||
| 116 | WhoAmIRe quest user Request = new WhoAmI Request(); | |||||
| 117 | WhoAmIRe sponse use rResponse = (WhoAmIR esponse)_s erviceProx y.Execute( userReques t); | |||||
| 118 | _userId = userResp onse.UserI d; | |||||
| 119 | ||||||
| 120 | // Creat e the acti vity party for sendi ng and rec eiving the fax. | |||||
| 121 | Activity Party part y = new Ac tivityPart y | |||||
| 122 | { | |||||
| 123 | Part yId = new EntityRefe rence(Syst emUser.Ent ityLogical Name, _use rId) | |||||
| 124 | }; | |||||
| 125 | ||||||
| 126 | // Creat e the fax object. | |||||
| 127 | Fax fax = new Fax | |||||
| 128 | { | |||||
| 129 | Subj ect = "Sam ple Fax", | |||||
| 130 | From = new Act ivityParty [] { party }, | |||||
| 131 | To = new Activ ityParty[] { party } | |||||
| 132 | }; | |||||
| 133 | _faxId = _serviceP roxy.Creat e(fax); | |||||
| 134 | Console. WriteLine( "Created a fax: '{0} '.", fax.S ubject); | |||||
| 135 | } | |||||
| 136 | ||||||
| 137 | // / <summary > | |||||
| 138 | // / Deletes the custom entity re cord that was create d for this sample. | |||||
| 139 | // / <param n ame="promp t">Indicat es whether to prompt the user | |||||
| 140 | // / to delet e the enti ty created in this s ample.</pa ram> | |||||
| 141 | // / </summar y> | |||||
| 142 | pu blic void DeleteRequ iredRecord s(bool pro mpt) | |||||
| 143 | { | |||||
| 144 | bool del eteRecords = true; | |||||
| 145 | ||||||
| 146 | if (prom pt) | |||||
| 147 | { | |||||
| 148 | Cons ole.WriteL ine("\nDo you want t hese entit y records deleted? ( y/n)"); | |||||
| 149 | Stri ng answer = Console. ReadLine() ; | |||||
| 150 | ||||||
| 151 | dele teRecords = (answer. StartsWith ("y") || a nswer.Star tsWith("Y" )); | |||||
| 152 | } | |||||
| 153 | ||||||
| 154 | if (dele teRecords) | |||||
| 155 | { | |||||
| 156 | ||||||
| 157 | _ser viceProxy. Delete(Fax .EntityLog icalName, _faxId); | |||||
| 158 | _ser viceProxy. Delete(Tas k.EntityLo gicalName, _taskId); | |||||
| 159 | ||||||
| 160 | Cons ole.WriteL ine("Entit y records have been deleted.") ; | |||||
| 161 | } | |||||
| 162 | } | |||||
| 163 | ||||||
| 164 | #e ndregion H ow To Samp le Code | |||||
| 165 | ||||||
| 166 | #r egion Main | |||||
| 167 | // / <summary > | |||||
| 168 | // / Main. Ru ns the sam ple and pr ovides err or output. | |||||
| 169 | // / <param n ame="args" >Array of arguments to Main me thod.</par am> | |||||
| 170 | // / </summar y> | |||||
| 171 | st atic publi c void Mai n(string[] args) | |||||
| 172 | { | |||||
| 173 | try | |||||
| 174 | { | |||||
| 175 | // O btain the target org anization' s Web addr ess and cl ient logon | |||||
| 176 | // c redentials from the user. | |||||
| 177 | Serv erConnecti on serverC onnect = n ew ServerC onnection( ); | |||||
| 178 | Serv erConnecti on.Configu ration con fig = serv erConnect. GetServerC onfigurati on(); | |||||
| 179 | ||||||
| 180 | Conv ertFaxToTa sk app = n ew Convert FaxToTask( ); | |||||
| 181 | app. Run(config , true); | |||||
| 182 | ||||||
| 183 | } | |||||
| 184 | catch (F aultExcept ion<Micros oft.Xrm.Sd k.Organiza tionServic eFault> ex ) | |||||
| 185 | { | |||||
| 186 | Cons ole.WriteL ine("The a pplication terminate d with an error."); | |||||
| 187 | Cons ole.WriteL ine("Times tamp: {0}" , ex.Detai l.Timestam p); | |||||
| 188 | Cons ole.WriteL ine("Code: {0}", ex. Detail.Err orCode); | |||||
| 189 | Cons ole.WriteL ine("Messa ge: {0}", ex.Detail. Message); | |||||
| 190 | Cons ole.WriteL ine("Plugi n Trace: { 0}", ex.De tail.Trace Text); | |||||
| 191 | Cons ole.WriteL ine("Inner Fault: {0 }", | |||||
| 192 | null == ex .Detail.In nerFault ? "No Inner Fault" : "Has Inner Fault"); | |||||
| 193 | } | |||||
| 194 | catch (S ystem.Time outExcepti on ex) | |||||
| 195 | { | |||||
| 196 | Cons ole.WriteL ine("The a pplication terminate d with an error."); | |||||
| 197 | Cons ole.WriteL ine("Messa ge: {0}", ex.Message ); | |||||
| 198 | Cons ole.WriteL ine("Stack Trace: {0 }", ex.Sta ckTrace); | |||||
| 199 | Cons ole.WriteL ine("Inner Fault: {0 }", | |||||
| 200 | null == ex .InnerExce ption.Mess age ? "No Inner Faul t" : ex.In nerExcepti on.Message ); | |||||
| 201 | } | |||||
| 202 | catch (S ystem.Exce ption ex) | |||||
| 203 | { | |||||
| 204 | Cons ole.WriteL ine("The a pplication terminate d with an error."); | |||||
| 205 | Cons ole.WriteL ine(ex.Mes sage); | |||||
| 206 | ||||||
| 207 | // D isplay the details o f the inne r exceptio n. | |||||
| 208 | if ( ex.InnerEx ception != null) | |||||
| 209 | { | |||||
| 210 | Console.Wr iteLine(ex .InnerExce ption.Mess age); | |||||
| 211 | ||||||
| 212 | FaultExcep tion<Micro soft.Xrm.S dk.Organiz ationServi ceFault> f e = | |||||
| 213 | ex.Inn erExceptio n | |||||
| 214 | as Fau ltExceptio n<Microsof t.Xrm.Sdk. Organizati onServiceF ault>; | |||||
| 215 | if (fe != null) | |||||
| 216 | { | |||||
| 217 | Consol e.WriteLin e("Timesta mp: {0}", fe.Detail. Timestamp) ; | |||||
| 218 | Consol e.WriteLin e("Code: { 0}", fe.De tail.Error Code); | |||||
| 219 | Consol e.WriteLin e("Message : {0}", fe .Detail.Me ssage); | |||||
| 220 | Consol e.WriteLin e("Plugin Trace: {0} ", fe.Deta il.TraceTe xt); | |||||
| 221 | Consol e.WriteLin e("Inner F ault: {0}" , | |||||
| 222 | nu ll == fe.D etail.Inne rFault ? " No Inner F ault" : "H as Inner F ault"); | |||||
| 223 | } | |||||
| 224 | } | |||||
| 225 | } | |||||
| 226 | // Addit ional exce ptions to catch: Sec urityToken Validation Exception, ExpiredSe curityToke nException , | |||||
| 227 | // Secur ityAccessD eniedExcep tion, Mess ageSecurit yException , and Secu rityNegoti ationExcep tion. | |||||
| 228 | ||||||
| 229 | finally | |||||
| 230 | { | |||||
| 231 | Cons ole.WriteL ine("Press <Enter> t o exit."); | |||||
| 232 | Cons ole.ReadLi ne(); | |||||
| 233 | } | |||||
| 234 | ||||||
| 235 | } | |||||
| 236 | #e ndregion M ain | |||||
| 237 | ||||||
| 238 | } | |||||
| 239 | } | |||||
| 240 | //</snippe tConvertFa xToTask> |
Araxis Merge (but not the data content of this report) is Copyright © 1993-2016 Araxis Ltd (www.araxis.com). All rights reserved.