Produced by Araxis Merge on 2/1/2017 2:56:47 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\Metadata\Entities | CreateUpdateEmailableEntity.cs | Tue Dec 20 19:51:46 2016 UTC |
| 2 | Wed Feb 1 19:56:47 2017 UTC |
| Description | Between Files 1 and 2 |
|
|---|---|---|
| Text Blocks | Lines | |
| Unchanged | 0 | 0 |
| Changed | 0 | 0 |
| Inserted | 0 | 0 |
| Removed | 1 | 271 |
| 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 CreateUpda teEmailabl eEntity> | |||||
| 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 | using Micr osoft.Xrm. Sdk.Messag es; | |||||
| 29 | using Micr osoft.Xrm. Sdk.Metada ta; | |||||
| 30 | ||||||
| 31 | // This na mespace is found in Microsoft. Crm.Sdk.Pr oxy.dll as sembly | |||||
| 32 | // found i n the SDK\ bin folder . | |||||
| 33 | using Micr osoft.Crm. Sdk.Messag es; | |||||
| 34 | ||||||
| 35 | namespace Microsoft. Crm.Sdk.Sa mples | |||||
| 36 | { | |||||
| 37 | public class Cre ateUpdateE mailableEn tity | |||||
| 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 | ||||||
| 45 | pr ivate cons t String _ customEnti tyName = " new_agent" ; | |||||
| 46 | ||||||
| 47 | #e ndregion C lass Level Members | |||||
| 48 | ||||||
| 49 | #r egion How To Sample Code | |||||
| 50 | // / <summary > | |||||
| 51 | // / Create a custom en tity that can be use d in the T o field of an email activity. | |||||
| 52 | // / Update t he custom entity. | |||||
| 53 | // / Optional ly delete the custom entity. | |||||
| 54 | // / </summar y> | |||||
| 55 | // / <param n ame="serve rConfig">C ontains se rver conne ction info rmation.</ param> | |||||
| 56 | // / <param n ame="promp tForDelete ">When Tru e, the use r will be prompted t o delete a ll | |||||
| 57 | // / created entities.< /param> | |||||
| 58 | pu blic void Run(Server Connection .Configura tion serve rConfig, b ool prompt ForDelete) | |||||
| 59 | { | |||||
| 60 | try | |||||
| 61 | { | |||||
| 62 | ||||||
| 63 | // C onnect to the Organi zation ser vice. | |||||
| 64 | // T he using s tatement a ssures tha t the serv ice proxy will be pr operly dis posed. | |||||
| 65 | 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 )) | |||||
| 66 | { | |||||
| 67 | // This st atement is required to enable early-boun d type sup port. | |||||
| 68 | _servicePr oxy.Enable ProxyTypes (); | |||||
| 69 | ||||||
| 70 | ||||||
| 71 | //<snippet CreateUpda teEmailabl eEntity1> | |||||
| 72 | ||||||
| 73 | // Create the custom entity. | |||||
| 74 | CreateEnti tyRequest createrequ est = new CreateEnti tyRequest | |||||
| 75 | { | |||||
| 76 | // Def ine an ent ity to ena ble for em ailing. In order to do so, | |||||
| 77 | // IsA ctivityPar ty must be set. | |||||
| 78 | Entity = new Ent ityMetadat a | |||||
| 79 | { | |||||
| 80 | Sc hemaName = _customEn tityName, | |||||
| 81 | Di splayName = new Labe l("Agent", 1033), | |||||
| 82 | Di splayColle ctionName = new Labe l("Agents" , 1033), | |||||
| 83 | De scription = new Labe l("Insuran ce Agents" , 1033), | |||||
| 84 | Ow nershipTyp e = Owners hipTypes.U serOwned, | |||||
| 85 | Is Activity = false, | |||||
| 86 | ||||||
| 87 | // Unless th is flag is set, this entity ca nnot be pa rty to an | |||||
| 88 | // activity. | |||||
| 89 | Is ActivityPa rty = true | |||||
| 90 | }, | |||||
| 91 | ||||||
| 92 | // As with built -in emaila ble entiti es, the Pr imary Attr ibute will | |||||
| 93 | // be used in th e activity party scr eens. Be s ure to cho ose descri ptive | |||||
| 94 | // att ributes. | |||||
| 95 | Primar yAttribute = new Str ingAttribu teMetadata | |||||
| 96 | { | |||||
| 97 | Sc hemaName = "new_full name", | |||||
| 98 | Re quiredLeve l = new At tributeReq uiredLevel ManagedPro perty(Attr ibuteRequi redLevel.N one), | |||||
| 99 | Ma xLength = 100, | |||||
| 100 | Fo rmatName = StringFor matName.Te xt, | |||||
| 101 | Di splayName = new Labe l("Agent N ame", 1033 ), | |||||
| 102 | De scription = new Labe l("Agent N ame", 1033 ) | |||||
| 103 | } | |||||
| 104 | }; | |||||
| 105 | ||||||
| 106 | _servicePr oxy.Execut e(createre quest); | |||||
| 107 | Console.Wr iteLine("T he emailab le entity has been c reated."); | |||||
| 108 | ||||||
| 109 | // The ent ity will n ot be sele ctable as an activit y party un til its cu stomizatio ns | |||||
| 110 | // have be en publish ed. Otherw ise, the e -mail acti vity dialo g cannot f ind | |||||
| 111 | // a corre ct default view. | |||||
| 112 | PublishAll XmlRequest publishRe quest = ne w PublishA llXmlReque st(); | |||||
| 113 | _servicePr oxy.Execut e(publishR equest); | |||||
| 114 | ||||||
| 115 | // Before any emails can be cr eated for this entit y, an Emai l attribut e | |||||
| 116 | // must be defined. | |||||
| 117 | CreateAttr ibuteReque st createF irstEmailA ttributeRe quest = ne w CreateAt tributeReq uest | |||||
| 118 | { | |||||
| 119 | Entity Name = _cu stomEntity Name, | |||||
| 120 | Attrib ute = new StringAttr ibuteMetad ata | |||||
| 121 | { | |||||
| 122 | Sc hemaName = "new_emai laddress", | |||||
| 123 | Re quiredLeve l = new At tributeReq uiredLevel ManagedPro perty(Attr ibuteRequi redLevel.N one), | |||||
| 124 | Ma xLength = 100, | |||||
| 125 | Fo rmatName = StringFor matName.Em ail, | |||||
| 126 | Di splayName = new Labe l("Email A ddress", 1 033), | |||||
| 127 | De scription = new Labe l("Email A ddress", 1 033) | |||||
| 128 | } | |||||
| 129 | }; | |||||
| 130 | ||||||
| 131 | _servicePr oxy.Execut e(createFi rstEmailAt tributeReq uest); | |||||
| 132 | Console.Wr iteLine("A n email at tribute ha s been add ed to the emailable entity."); | |||||
| 133 | ||||||
| 134 | // Create a second, alternate email addr ess. Since there is already on e | |||||
| 135 | // email a ttribute o n the enti ty, this w ill never be used fo r emailing | |||||
| 136 | // even if the first one is no t populate d. | |||||
| 137 | CreateAttr ibuteReque st createS econdEmail AttributeR equest = n ew CreateA ttributeRe quest | |||||
| 138 | { | |||||
| 139 | Entity Name = _cu stomEntity Name, | |||||
| 140 | Attrib ute = new StringAttr ibuteMetad ata | |||||
| 141 | { | |||||
| 142 | Sc hemaName = "new_seco ndaryaddre ss", | |||||
| 143 | Re quiredLeve l = new At tributeReq uiredLevel ManagedPro perty(Attr ibuteRequi redLevel.N one), | |||||
| 144 | Ma xLength = 100, | |||||
| 145 | Fo rmatName = StringFor matName.Em ail, | |||||
| 146 | Di splayName = new Labe l("Seconda ry Email A ddress", 1 033), | |||||
| 147 | De scription = new Labe l("Seconda ry Email A ddress", 1 033) | |||||
| 148 | } | |||||
| 149 | }; | |||||
| 150 | ||||||
| 151 | _servicePr oxy.Execut e(createSe condEmailA ttributeRe quest); | |||||
| 152 | ||||||
| 153 | Console.Wr iteLine("A second em ail attrib ute has be en added t o the emai lable enti ty."); | |||||
| 154 | //</snippe tCreateUpd ateEmailab leEntity1> | |||||
| 155 | ||||||
| 156 | DeleteRequ iredRecord s(promptFo rDelete); | |||||
| 157 | } | |||||
| 158 | } | |||||
| 159 | ||||||
| 160 | // Catch any servi ce fault e xceptions that Micro soft Dynam ics CRM th rows. | |||||
| 161 | catch (F aultExcept ion<Micros oft.Xrm.Sd k.Organiza tionServic eFault>) | |||||
| 162 | { | |||||
| 163 | // Y ou can han dle an exc eption her e or pass it back to the calli ng method. | |||||
| 164 | thro w; | |||||
| 165 | } | |||||
| 166 | } | |||||
| 167 | ||||||
| 168 | // / <summary > | |||||
| 169 | // / Deletes the custom entity th at was cre ated for t his sample . | |||||
| 170 | // / <param n ame="promp t">Indicat es whether to prompt the user to delete the record s created in this sa mple.</par am> | |||||
| 171 | // / </summar y> | |||||
| 172 | pu blic void DeleteRequ iredRecord s(bool pro mpt) | |||||
| 173 | { | |||||
| 174 | bool del eteEntity = true; | |||||
| 175 | ||||||
| 176 | if (prom pt) | |||||
| 177 | { | |||||
| 178 | Cons ole.WriteL ine("\nDo you want t his custom entity de leted? (y/ n)"); | |||||
| 179 | Stri ng answer = Console. ReadLine() ; | |||||
| 180 | ||||||
| 181 | dele teEntity = (answer.S tartsWith( "y") || an swer.Start sWith("Y") ); | |||||
| 182 | } | |||||
| 183 | ||||||
| 184 | if (dele teEntity) | |||||
| 185 | { | |||||
| 186 | Dele teEntityRe quest requ est = new DeleteEnti tyRequest( ) | |||||
| 187 | { | |||||
| 188 | LogicalNam e = _custo mEntityNam e, | |||||
| 189 | }; | |||||
| 190 | _ser viceProxy. Execute(re quest); | |||||
| 191 | ||||||
| 192 | Cons ole.WriteL ine("The r ecords hav e been del eted."); | |||||
| 193 | } | |||||
| 194 | } | |||||
| 195 | ||||||
| 196 | #e ndregion H ow To Samp le Code | |||||
| 197 | ||||||
| 198 | #r egion Main | |||||
| 199 | // / <summary > | |||||
| 200 | // / Standard Main() me thod used by most SD K samples. | |||||
| 201 | // / </summar y> | |||||
| 202 | // / <param n ame="args" ></param> | |||||
| 203 | st atic publi c void Mai n(string[] args) | |||||
| 204 | { | |||||
| 205 | try | |||||
| 206 | { | |||||
| 207 | // O btain the target org anization' s Web addr ess and cl ient logon | |||||
| 208 | // c redentials from the user. | |||||
| 209 | Serv erConnecti on serverC onnect = n ew ServerC onnection( ); | |||||
| 210 | Serv erConnecti on.Configu ration con fig = serv erConnect. GetServerC onfigurati on(); | |||||
| 211 | ||||||
| 212 | Crea teUpdateEm ailableEnt ity app = new Create UpdateEmai lableEntit y(); | |||||
| 213 | app. Run(config , true); | |||||
| 214 | } | |||||
| 215 | catch (F aultExcept ion<Micros oft.Xrm.Sd k.Organiza tionServic eFault> ex ) | |||||
| 216 | { | |||||
| 217 | Cons ole.WriteL ine("The a pplication terminate d with an error."); | |||||
| 218 | Cons ole.WriteL ine("Times tamp: {0}" , ex.Detai l.Timestam p); | |||||
| 219 | Cons ole.WriteL ine("Code: {0}", ex. Detail.Err orCode); | |||||
| 220 | Cons ole.WriteL ine("Messa ge: {0}", ex.Detail. Message); | |||||
| 221 | Cons ole.WriteL ine("Plugi n Trace: { 0}", ex.De tail.Trace Text); | |||||
| 222 | Cons ole.WriteL ine("Inner Fault: {0 }", | |||||
| 223 | null == ex .Detail.In nerFault ? "No Inner Fault" : "Has Inner Fault"); | |||||
| 224 | } | |||||
| 225 | catch (S ystem.Time outExcepti on ex) | |||||
| 226 | { | |||||
| 227 | Cons ole.WriteL ine("The a pplication terminate d with an error."); | |||||
| 228 | Cons ole.WriteL ine("Messa ge: {0}", ex.Message ); | |||||
| 229 | Cons ole.WriteL ine("Stack Trace: {0 }", ex.Sta ckTrace); | |||||
| 230 | Cons ole.WriteL ine("Inner Fault: {0 }", | |||||
| 231 | null == ex .InnerExce ption.Mess age ? "No Inner Faul t" : ex.In nerExcepti on.Message ); | |||||
| 232 | } | |||||
| 233 | catch (S ystem.Exce ption ex) | |||||
| 234 | { | |||||
| 235 | Cons ole.WriteL ine("The a pplication terminate d with an error."); | |||||
| 236 | Cons ole.WriteL ine(ex.Mes sage); | |||||
| 237 | ||||||
| 238 | // D isplay the details o f the inne r exceptio n. | |||||
| 239 | if ( ex.InnerEx ception != null) | |||||
| 240 | { | |||||
| 241 | Console.Wr iteLine(ex .InnerExce ption.Mess age); | |||||
| 242 | ||||||
| 243 | FaultExcep tion<Micro soft.Xrm.S dk.Organiz ationServi ceFault> f e = ex.Inn erExceptio n | |||||
| 244 | as Fau ltExceptio n<Microsof t.Xrm.Sdk. Organizati onServiceF ault>; | |||||
| 245 | if (fe != null) | |||||
| 246 | { | |||||
| 247 | Consol e.WriteLin e("Timesta mp: {0}", fe.Detail. Timestamp) ; | |||||
| 248 | Consol e.WriteLin e("Code: { 0}", fe.De tail.Error Code); | |||||
| 249 | Consol e.WriteLin e("Message : {0}", fe .Detail.Me ssage); | |||||
| 250 | Consol e.WriteLin e("Plugin Trace: {0} ", fe.Deta il.TraceTe xt); | |||||
| 251 | Consol e.WriteLin e("Inner F ault: {0}" , | |||||
| 252 | nu ll == fe.D etail.Inne rFault ? " No Inner F ault" : "H as Inner F ault"); | |||||
| 253 | } | |||||
| 254 | } | |||||
| 255 | } | |||||
| 256 | // Addit ional exce ptions to catch: Sec urityToken Validation Exception, ExpiredSe curityToke nException , | |||||
| 257 | // Secur ityAccessD eniedExcep tion, Mess ageSecurit yException , and Secu rityNegoti ationExcep tion. | |||||
| 258 | ||||||
| 259 | finally | |||||
| 260 | { | |||||
| 261 | ||||||
| 262 | Cons ole.WriteL ine("Press <Enter> t o exit."); | |||||
| 263 | Cons ole.ReadLi ne(); | |||||
| 264 | } | |||||
| 265 | ||||||
| 266 | } | |||||
| 267 | #e ndregion M ain | |||||
| 268 | ||||||
| 269 | } | |||||
| 270 | } | |||||
| 271 | //</snippe tCreateUpd ateEmailab leEntity> |
Araxis Merge (but not the data content of this report) is Copyright © 1993-2016 Araxis Ltd (www.araxis.com). All rights reserved.