Produced by Araxis Merge on 2/1/2017 2:56:50 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\Plug-ins | AccountNumberPlugin.cs | Tue Dec 20 19:51:42 2016 UTC |
| 2 | Wed Feb 1 19:56:50 2017 UTC |
| Description | Between Files 1 and 2 |
|
|---|---|---|
| Text Blocks | Lines | |
| Unchanged | 0 | 0 |
| Changed | 0 | 0 |
| Inserted | 0 | 0 |
| Removed | 1 | 73 |
| 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 C RM SDK Cod e 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 AccountNum berPlugin> | |||||
| 17 | using Syst em; | |||||
| 18 | ||||||
| 19 | // Microso ft Dynamic s CRM name space(s) | |||||
| 20 | using Micr osoft.Xrm. Sdk; | |||||
| 21 | ||||||
| 22 | namespace Microsoft. Crm.Sdk.Sa mples | |||||
| 23 | { | |||||
| 24 | pu blic class AccountNu mberPlugin : IPlugin | |||||
| 25 | { | |||||
| 26 | /// <summary> | |||||
| 27 | // / A plug-i n that aut o generate s an accou nt number when an | |||||
| 28 | // / account is created . | |||||
| 29 | /// </summary> | |||||
| 30 | // / <remarks >Register this plug- in on the Create mes sage, acco unt entity , | |||||
| 31 | // / and pre- operation stage. | |||||
| 32 | // / </remark s> | |||||
| 33 | // <snippetAc countNumbe rPlugin2> | |||||
| 34 | pu blic void Execute(IS erviceProv ider servi ceProvider ) | |||||
| 35 | { | |||||
| 36 | // Obtai n the exec ution cont ext from t he service provider. | |||||
| 37 | Microsof t.Xrm.Sdk. IPluginExe cutionCont ext contex t = (Micro soft.Xrm.S dk.IPlugin ExecutionC ontext) | |||||
| 38 | serv iceProvide r.GetServi ce(typeof( Microsoft. Xrm.Sdk.IP luginExecu tionContex t)); | |||||
| 39 | ||||||
| 40 | // The I nputParame ters colle ction cont ains all t he data pa ssed in th e message request. | |||||
| 41 | if (co ntext.Inpu tParameter s.Contains ("Target") && | |||||
| 42 | context. InputParam eters["Tar get"] is E ntity) | |||||
| 43 | { | |||||
| 44 | // O btain the target ent ity from t he input p arameters. | |||||
| 45 | Entity e ntity = (E ntity)cont ext.InputP arameters[ "Target"]; | |||||
| 46 | //</ snippetAcc ountNumber Plugin2> | |||||
| 47 | ||||||
| 48 | // V erify that the targe t entity r epresents an account . | |||||
| 49 | // I f not, thi s plug-in was not re gistered c orrectly. | |||||
| 50 | if ( entity.Log icalName = = "account ") | |||||
| 51 | { | |||||
| 52 | // An acco untnumber attribute should not already e xist becau se | |||||
| 53 | // it is s ystem gene rated. | |||||
| 54 | if (entity .Attribute s.Contains ("accountn umber") == false) | |||||
| 55 | { | |||||
| 56 | // Cre ate a new accountnum ber attrib ute, set i ts value, and add | |||||
| 57 | // the attribute to the en tity's att ribute col lection. | |||||
| 58 | Ra ndom rndge n = new Ra ndom(); | |||||
| 59 | entity .Attribute s.Add("acc ountnumber ", rndgen. Next().ToS tring()); | |||||
| 60 | } | |||||
| 61 | else | |||||
| 62 | { | |||||
| 63 | // Throw an error, bec ause accou nt numbers must be s ystem gene rated. | |||||
| 64 | // Thr owing an I nvalidPlug inExecutio nException will caus e the erro r message | |||||
| 65 | // to be display ed in a di alog of th e Web appl ication. | |||||
| 66 | throw new Invali dPluginExe cutionExce ption("The account n umber can only be se t by the s ystem."); | |||||
| 67 | } | |||||
| 68 | } | |||||
| 69 | } | |||||
| 70 | } | |||||
| 71 | } | |||||
| 72 | } | |||||
| 73 | //</snippe tAccountNu mberPlugin > |
Araxis Merge (but not the data content of this report) is Copyright © 1993-2016 Araxis Ltd (www.araxis.com). All rights reserved.