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 | CreateCustomActivityEntity.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 | 273 |
| 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 CreateCust omActivity Entity> | |||||
| 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.Metada ta; | |||||
| 28 | using Micr osoft.Xrm. Sdk.Messag es; | |||||
| 29 | ||||||
| 30 | // This na mespace is found in Microsoft. Crm.Sdk.Pr oxy.dll as sembly | |||||
| 31 | // found i n the SDK\ bin folder . | |||||
| 32 | using Micr osoft.Crm. Sdk.Messag es; | |||||
| 33 | ||||||
| 34 | ||||||
| 35 | namespace Microsoft. Crm.Sdk.Sa mples | |||||
| 36 | { | |||||
| 37 | /// <s ummary> | |||||
| 38 | /// Th is sample shows how to create a custom a ctivity. | |||||
| 39 | /// </ summary> | |||||
| 40 | public class Cre ateCustomA ctivityEnt ity | |||||
| 41 | { | |||||
| 42 | #r egion Clas s Level Me mbers | |||||
| 43 | // / <summary > | |||||
| 44 | // / Stores t he organiz ation serv ice proxy. | |||||
| 45 | // / </summar y> | |||||
| 46 | pr ivate Orga nizationSe rviceProxy _serviceP roxy; | |||||
| 47 | ||||||
| 48 | #e ndregion C lass Level Members | |||||
| 49 | ||||||
| 50 | #r egion How To Sample Code | |||||
| 51 | // / <summary > | |||||
| 52 | // / Create 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, | |||||
| 66 | s erverConfi g.Credenti als, serve rConfig.De viceCreden tials)) | |||||
| 67 | { | |||||
| 68 | // This st atement is required to enable early-boun d type sup port. | |||||
| 69 | _servicePr oxy.Enable ProxyTypes (); | |||||
| 70 | ||||||
| 71 | //<snippet CreateCust omActivity Entity1> | |||||
| 72 | // The cus tom prefix would typ ically be passed in as an argu ment or | |||||
| 73 | // determi ned by the publisher of the cu stom solut ion. | |||||
| 74 | //<snippet CreateCust omActivity Entity2> | |||||
| 75 | String pre fix = "new _"; | |||||
| 76 | ||||||
| 77 | String cus tomEntityN ame = pref ix + "inst antmessage "; | |||||
| 78 | ||||||
| 79 | // Create the custom activity entity. | |||||
| 80 | CreateEnti tyRequest request = new Create EntityRequ est | |||||
| 81 | { | |||||
| 82 | HasNot es = true, | |||||
| 83 | HasAct ivities = false, | |||||
| 84 | Primar yAttribute = new Str ingAttribu teMetadata | |||||
| 85 | { | |||||
| 86 | Sc hemaName = "Subject" , | |||||
| 87 | Re quiredLeve l = new At tributeReq uiredLevel ManagedPro perty(Attr ibuteRequi redLevel.N one), | |||||
| 88 | Ma xLength = 100, | |||||
| 89 | Di splayName = new Labe l("Subject ", 1033) | |||||
| 90 | }, | |||||
| 91 | Entity = new Ent ityMetadat a | |||||
| 92 | { | |||||
| 93 | Is Activity = true, | |||||
| 94 | Sc hemaName = customEnt ityName, | |||||
| 95 | Di splayName = new Labe l("Instant Message", 1033), | |||||
| 96 | Di splayColle ctionName = new Labe l("Instant Messages" , 1033), | |||||
| 97 | Ow nershipTyp e = Owners hipTypes.U serOwned, | |||||
| 98 | Is AvailableO ffline = t rue, | |||||
| 99 | ||||||
| 100 | } | |||||
| 101 | }; | |||||
| 102 | ||||||
| 103 | _servicePr oxy.Execut e(request) ; | |||||
| 104 | ||||||
| 105 | //Entity m ust be pub lished | |||||
| 106 | ||||||
| 107 | //</snippe tCreateCus tomActivit yEntity2> | |||||
| 108 | // Add few attribute s to the c ustom acti vity entit y. | |||||
| 109 | CreateAttr ibuteReque st fontFam ilyAttribu teRequest = | |||||
| 110 | new Cr eateAttrib uteRequest | |||||
| 111 | { | |||||
| 112 | EntityN ame = cust omEntityNa me, | |||||
| 113 | Attribu te = new S tringAttri buteMetada ta | |||||
| 114 | { | |||||
| 115 | Sch emaName = prefix + " fontfamily ", | |||||
| 116 | Dis playName = new Label ("Font Fam ily", 1033 ), | |||||
| 117 | Max Length = 1 00 | |||||
| 118 | } | |||||
| 119 | } ; | |||||
| 120 | CreateAttr ibuteRespo nse fontFa milyAttrib uteRespons e = | |||||
| 121 | (Creat eAttribute Response)_ servicePro xy.Execute ( | |||||
| 122 | fontFa milyAttrib uteRequest ); | |||||
| 123 | ||||||
| 124 | CreateAttr ibuteReque st fontCol orAttribut eRequest = | |||||
| 125 | new Cr eateAttrib uteRequest | |||||
| 126 | { | |||||
| 127 | Entity Name = cus tomEntityN ame, | |||||
| 128 | Attrib ute = new StringAttr ibuteMetad ata | |||||
| 129 | { | |||||
| 130 | Sc hemaName = prefix + "fontcolor ", | |||||
| 131 | Di splayName = new Labe l("Font Co lor", 1033 ), | |||||
| 132 | Ma xLength = 50 | |||||
| 133 | } | |||||
| 134 | }; | |||||
| 135 | CreateAttr ibuteRespo nse fontCo lorAttribu teResponse = | |||||
| 136 | (Creat eAttribute Response)_ servicePro xy.Execute ( | |||||
| 137 | fontCo lorAttribu teRequest) ; | |||||
| 138 | ||||||
| 139 | CreateAttr ibuteReque st fontSiz eAttribute Request = | |||||
| 140 | new Cr eateAttrib uteRequest | |||||
| 141 | { | |||||
| 142 | Entity Name = cus tomEntityN ame, | |||||
| 143 | Attrib ute = new IntegerAtt ributeMeta data | |||||
| 144 | { | |||||
| 145 | Sc hemaName = prefix + "fontSize" , | |||||
| 146 | Di splayName = new Labe l("Font Si ze", 1033) | |||||
| 147 | } | |||||
| 148 | }; | |||||
| 149 | CreateAttr ibuteRespo nse fontSi zeAttribut eResponse = | |||||
| 150 | (Creat eAttribute Response)_ servicePro xy.Execute ( | |||||
| 151 | fontSi zeAttribut eRequest); | |||||
| 152 | //</snippe tCreateCus tomActivit yEntity1> | |||||
| 153 | ||||||
| 154 | Console.Wr iteLine("T he custom activity h as been cr eated."); | |||||
| 155 | ||||||
| 156 | DeleteCust omEntity(p refix, pro mptForDele te); | |||||
| 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 | |||||
| 171 | // / to delet e the enti ty created in this s ample.</pa ram> | |||||
| 172 | // / </summar y> | |||||
| 173 | pu blic void DeleteCust omEntity(S tring pref ix, bool p rompt) | |||||
| 174 | { | |||||
| 175 | bool del eteEntity = true; | |||||
| 176 | ||||||
| 177 | if (prom pt) | |||||
| 178 | { | |||||
| 179 | Cons ole.WriteL ine("\nDo you want t his custom entity de leted? (y/ n)"); | |||||
| 180 | char answer = Convert.To Char(Conso le.ReadLin e().Substr ing(0, 1)) ; | |||||
| 181 | ||||||
| 182 | dele teEntity = (answer = = 'y' || a nswer == ' Y'); | |||||
| 183 | } | |||||
| 184 | ||||||
| 185 | if (dele teEntity) | |||||
| 186 | { | |||||
| 187 | Dele teEntityRe quest requ est = new DeleteEnti tyRequest( ) | |||||
| 188 | { | |||||
| 189 | LogicalNam e = prefix + "instan tmessage", | |||||
| 190 | }; | |||||
| 191 | _ser viceProxy. Execute(re quest); | |||||
| 192 | ||||||
| 193 | Cons ole.WriteL ine("Entit y has been deleted." ); | |||||
| 194 | } | |||||
| 195 | } | |||||
| 196 | ||||||
| 197 | #e ndregion H ow To Samp le Code | |||||
| 198 | ||||||
| 199 | #r egion Main | |||||
| 200 | // / <summary > | |||||
| 201 | // / Standard Main() me thod used by most SD K samples. | |||||
| 202 | // / </summar y> | |||||
| 203 | // / <param n ame="args" ></param> | |||||
| 204 | st atic publi c void Mai n(string[] args) | |||||
| 205 | { | |||||
| 206 | try | |||||
| 207 | { | |||||
| 208 | // O btain the target org anization' s Web addr ess and cl ient logon | |||||
| 209 | // c redentials from the user. | |||||
| 210 | Serv erConnecti on serverC onnect = n ew ServerC onnection( ); | |||||
| 211 | Serv erConnecti on.Configu ration con fig = serv erConnect. GetServerC onfigurati on(); | |||||
| 212 | ||||||
| 213 | Crea teCustomAc tivityEnti ty app = n ew CreateC ustomActiv ityEntity( ); | |||||
| 214 | app. Run(config , true); | |||||
| 215 | } | |||||
| 216 | catch (F aultExcept ion<Micros oft.Xrm.Sd k.Organiza tionServic eFault> ex ) | |||||
| 217 | { | |||||
| 218 | Cons ole.WriteL ine("The a pplication terminate d with an error."); | |||||
| 219 | Cons ole.WriteL ine("Times tamp: {0}" , ex.Detai l.Timestam p); | |||||
| 220 | Cons ole.WriteL ine("Code: {0}", ex. Detail.Err orCode); | |||||
| 221 | Cons ole.WriteL ine("Messa ge: {0}", ex.Detail. Message); | |||||
| 222 | Cons ole.WriteL ine("Plugi n Trace: { 0}", ex.De tail.Trace Text); | |||||
| 223 | Cons ole.WriteL ine("Inner Fault: {0 }", | |||||
| 224 | null == ex .Detail.In nerFault ? "No Inner Fault" : "Has Inner Fault"); | |||||
| 225 | } | |||||
| 226 | catch (S ystem.Time outExcepti on ex) | |||||
| 227 | { | |||||
| 228 | Cons ole.WriteL ine("The a pplication terminate d with an error."); | |||||
| 229 | Cons ole.WriteL ine("Messa ge: {0}", ex.Message ); | |||||
| 230 | Cons ole.WriteL ine("Stack Trace: {0 }", ex.Sta ckTrace); | |||||
| 231 | Cons ole.WriteL ine("Inner Fault: {0 }", | |||||
| 232 | null == ex .InnerExce ption.Mess age ? "No Inner Faul t" : ex.In nerExcepti on.Message ); | |||||
| 233 | } | |||||
| 234 | catch (S ystem.Exce ption ex) | |||||
| 235 | { | |||||
| 236 | Cons ole.WriteL ine("The a pplication terminate d with an error."); | |||||
| 237 | Cons ole.WriteL ine(ex.Mes sage); | |||||
| 238 | ||||||
| 239 | // D isplay the details o f the inne r exceptio n. | |||||
| 240 | if ( ex.InnerEx ception != null) | |||||
| 241 | { | |||||
| 242 | Console.Wr iteLine(ex .InnerExce ption.Mess age); | |||||
| 243 | ||||||
| 244 | FaultExcep tion<Micro soft.Xrm.S dk.Organiz ationServi ceFault> f e = | |||||
| 245 | ex.Inn erExceptio n | |||||
| 246 | as Fau ltExceptio n<Microsof t.Xrm.Sdk. Organizati onServiceF ault>; | |||||
| 247 | if (fe != null) | |||||
| 248 | { | |||||
| 249 | Consol e.WriteLin e("Timesta mp: {0}", fe.Detail. Timestamp) ; | |||||
| 250 | Consol e.WriteLin e("Code: { 0}", fe.De tail.Error Code); | |||||
| 251 | Consol e.WriteLin e("Message : {0}", fe .Detail.Me ssage); | |||||
| 252 | Consol e.WriteLin e("Plugin Trace: {0} ", fe.Deta il.TraceTe xt); | |||||
| 253 | Consol e.WriteLin e("Inner F ault: {0}" , | |||||
| 254 | nu ll == fe.D etail.Inne rFault ? " No Inner F ault" : "H as Inner F ault"); | |||||
| 255 | } | |||||
| 256 | } | |||||
| 257 | } | |||||
| 258 | // Addit ional exce ptions to catch: Sec urityToken Validation Exception, ExpiredSe curityToke nException , | |||||
| 259 | // Secur ityAccessD eniedExcep tion, Mess ageSecurit yException , and Secu rityNegoti ationExcep tion. | |||||
| 260 | ||||||
| 261 | finally | |||||
| 262 | { | |||||
| 263 | ||||||
| 264 | Cons ole.WriteL ine("Press <Enter> t o exit."); | |||||
| 265 | Cons ole.ReadLi ne(); | |||||
| 266 | } | |||||
| 267 | ||||||
| 268 | } | |||||
| 269 | #e ndregion M ain | |||||
| 270 | ||||||
| 271 | } | |||||
| 272 | } | |||||
| 273 | //</snippe tCreateCus tomActivit yEntity> |
Araxis Merge (but not the data content of this report) is Copyright © 1993-2016 Araxis Ltd (www.araxis.com). All rights reserved.