606. Araxis Merge File Comparison Report

Produced by Araxis Merge on 2/1/2017 2:56:52 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.

606.1 Files compared

# 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\Process\CustomWorkflowActivities\TestNet4Activity ReleaseISVActivities.cs Tue Dec 20 19:51:45 2016 UTC
2 Wed Feb 1 19:56:52 2017 UTC

606.2 Comparison summary

Description Between
Files 1 and 2
Text Blocks Lines
Unchanged 0 0
Changed 0 0
Inserted 0 0
Removed 1 283

606.3 Comparison options

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

606.4 Active regular expressions

No regular expressions were active.

606.5 Comparison detail

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   // ======= ========== ========== ========== ========== ========== ========== ========== =        
16          
17   //<snippet ReleaseISV Activities >        
18   using Syst em;        
19   using Syst em.Activit ies;        
20   using Syst em.Collect ions;        
21   using Syst em.Reflect ion;        
22          
23   using Micr osoft.Xrm. Sdk;        
24   using Micr osoft.Xrm. Sdk.Messag es;        
25   using Micr osoft.Xrm. Sdk.Query;        
26   using Micr osoft.Xrm. Sdk.Workfl ow;        
27          
28   namespace  Microsoft. Crm.Sdk.Sa mples        
29   {        
30       //<sni ppetReleas eISVActivi ties2>        
31       /// <s ummary>        
32       /// Ac tivity wil l return t he next up coming bir thday that  has just  passed        
33       ///         
34       /// If  this year 's birthda y has not  yet occurr ed, it wil l return t his year's  birthday        
35       /// Ot herwise, i t will ret urn the bi rthday for  next year        
36       ///         
37       /// A  workflow c an timeout  when on t his date        
38       /// </ summary>        
39       [Persi st]        
40       public  sealed pa rtial clas s ReleaseS cenario_Up dateNextBi rthday : C odeActivit y        
41       {        
42           pr otected ov erride voi d Execute( CodeActivi tyContext  executionC ontext)        
43           {        
44                IWorkflo wContext c ontext = e xecutionCo ntext.GetE xtension<I WorkflowCo ntext>();        
45          
46                //Create  an Organi zation Ser vice        
47                IOrganiz ationServi ceFactory  serviceFac tory = exe cutionCont ext.GetExt ension<IOr ganization ServiceFac tory>();        
48                IOrganiz ationServi ce service  = service Factory.Cr eateOrgani zationServ ice(contex t.Initiati ngUserId);        
49          
50                //Retrie ve the con tact id        
51                Guid con tactId = t his.Contac t.Get(exec utionConte xt).Id;        
52          
53                //<snipp etReleaseI SVActiviti es1>        
54                //Create  the reque st        
55                Retrieve Request re quest = ne w Retrieve Request();        
56                request. ColumnSet  = new Colu mnSet(new  string[] {  "birthdat e" });        
57                request. Target = n ew EntityR eference(E ntityName. Contact, c ontactId);        
58          
59                //Retrie ve the ent ity to det ermine wha t the birt hdate is s et at        
60                Entity e ntity = (E ntity)((Re trieveResp onse)servi ce.Execute (request)) .Entity;        
61                //</snip petRelease ISVActivit ies1>        
62          
63                //Extrac t the date  out of th e entity        
64                DateTime ? birthdat e;        
65                if (enti ty.Contain s(ContactA ttributes. Birthdate) )        
66                {        
67                    birt hdate = (D ateTime?)e ntity[Cont actAttribu tes.Birthd ate];        
68                }        
69                else        
70                {        
71                    birt hdate = nu ll;        
72                }        
73          
74                //Check  to see if  the curren t birthday  is set. W e don't wa nt the act ivity to f ail if the  birthdate  is not se t        
75                if (birt hdate == n ull)        
76                {        
77                    retu rn;        
78                }        
79          
80                //Calcul ate the ne xt birthda te. Encaps ulated in  a methdo s o that the  method ca n be used  in the tes t case for  verificat ion purpos es        
81                DateTime  nextBirth date = Cal culateNext Birthday(b irthdate.V alue);        
82          
83                //Update  the next  birthday f ield on th e entity        
84                Entity u pdateEntit y = new En tity(Entit yName.Cont act);        
85                updateEn tity.Id =  contactId;        
86                updateEn tity["new_ nextbirthd ay"] = nex tBirthdate ;        
87          
88                service. Update(upd ateEntity) ;        
89           }        
90          
91           // Define the  propertie s        
92           [R equiredArg ument]        
93           [I nput("Upda te Next Bi rthdate fo r")]        
94           [R eferenceTa rget("cont act")]        
95           pu blic InArg ument<Enti tyReferenc e> Contact  { get; se t; }        
96          
97           pr ivate Date Time Calcu lateNextBi rthday(Dat eTime birt hdate)        
98           {        
99                DateTime  nextBirth day = new  DateTime(b irthdate.Y ear, birth date.Month , birthdat e.Day);        
100          
101                //Check  to see if  this birth day occurr ed on a le ap year        
102                bool lea pYearAdjus t = false;        
103                if (next Birthday.M onth == 2  && nextBir thday.Day  == 29)        
104                {        
105                    //Sa nity check , was that  year a le ap year        
106                    if ( DateTime.I sLeapYear( nextBirthd ay.Year))        
107                    {        
108                         //Check to  see if th e current  year is a  leap year        
109                         if (!DateT ime.IsLeap Year(DateT ime.Now.Ye ar))        
110                         {        
111                             //Push  the date  to March 1 st so that  the date  arithmetic  will func tion corre ctly        
112                             nextBi rthday = n extBirthda y.AddDays( 1);        
113                             leapYe arAdjust =  true;        
114                         }        
115                    }        
116                    else        
117                    {        
118                         throw new  Exception( "Invalid B irthdate s pecified",  new Argum entExcepti on("Birthd ate"));        
119                    }        
120                }        
121          
122                //Calcul ate the ye ar differe nce        
123                nextBirt hday = nex tBirthday. AddYears(D ateTime.No w.Year - n extBirthda y.Year);        
124          
125                //Check  to see if  the date w as adjuste d        
126                if (leap YearAdjust  && DateTi me.IsLeapY ear(nextBi rthday.Yea r))        
127                {        
128                    next Birthday =  nextBirth day.AddDay s(-1);        
129                }        
130          
131                return n extBirthda y;        
132           }        
133       }        
134       //</sn ippetRelea seISVActiv ities2>        
135          
136       //<sni ppetReleas eISVActivi ties3>        
137       public  sealed pa rtial clas s ReleaseS cenario_Me ssageName  : CodeActi vity        
138       {        
139           pr otected ov erride voi d Execute( CodeActivi tyContext  executionC ontext)        
140           {        
141                IWorkflo wContext c ontext = e xecutionCo ntext.GetE xtension<I WorkflowCo ntext>();        
142          
143                //Set th e variable        
144                MessageN ame.Set(ex ecutionCon text, cont ext.Messag eName);        
145           }        
146          
147           // Define the  propertie s        
148           [O utput("Mes sage Name" )]        
149           pu blic OutAr gument<str ing> Messa geName { g et; set; }        
150       }        
151       //</sn ippetRelea seISVActiv ities3>        
152          
153       //<sni ppetReleas eISVActivi ties4>        
154       /// <s ummary>        
155       /// Ca lculates t he credit  score base d on the S SN and nam e.         
156       /// </ summary>        
157       /// <r emarks>        
158       /// Th is depends  on a cust om entity  called Loa n Applicat ion and cu stomizatio ns to Cont act.        
159       ///         
160       /// Lo an Applica tion requi res the fo llowing pr operties:        
161       /// <l ist>        
162       ///          <ite m>Schema N ame: new_l oanapplica tion</item >        
163       ///          <ite m>Attribut e: new_loa napplicati onid as th e primary  key</item>        
164       ///          <ite m>Attribut e: new_cre ditscore o f type int  with min  of 0 and m ax of 1000  (if it is  to be upd ated)</ite m>        
165       ///          <ite m>Attribut e: new_loa namount of  type mone y with def ault min/m ax</item>        
166       ///          <ite m>Customiz e the form  to includ e the attr ibute new_ loanapplic antid</ite m>        
167       /// </ list>        
168       ///         
169       /// Co ntact Requ ires the f ollowing c ustomizati ons        
170       /// <l ist>        
171       ///          <ite m>Attribut e: new_ssn  as nvarch ar with ma x length o f 15</item >        
172       ///          <ite m>One-To-M any Relati onship wit h these pr operties:        
173       ///                   <list>        
174       ///                            <item>Re lationship  Definitio n Schema N ame: new_l oanapplica nt</item>        
175       ///                            <item>Re lationship  Definitio n Related  Entity Nam e: Loan Ap plication< /item>        
176       ///                            <item>Re lationship  Atttribut e Schema N ame: new_l oanapplica ntid</item >        
177       ///                            <item>Re lationship  Behavior  Type: Refe rential</i tem>        
178       ///                   </list >        
179       ///          </it em>        
180       /// </ list>        
181       ///         
182       /// Th e activity  takes, as  input, a  EntityRefe rence to t he Loan Ap plication  and a bool ean indica ting wheth er new_cre ditscore s hould be u pdated to  the credit  score.        
183       /// </ remarks>        
184       /// <e xception c ref=">Argu mentNullEx ception">T hrown when  LoanAppli cation is  null</exce ption>        
185       /// <e xception c ref=">Argu mentExcept ion">Throw n when Loa nApplicati on is not  a EntityRe ference to  a LoanApp lication e ntity</exc eption>        
186       public  sealed pa rtial clas s Retrieve CreditScor e : CodeAc tivity        
187       {        
188           pr ivate cons t string C ustomEntit y = "new_l oanapplica tion";        
189          
190           pr otected ov erride voi d Execute( CodeActivi tyContext  executionC ontext)        
191           {        
192                //Check  to see if  the Entity Reference  has been s et        
193                EntityRe ference lo anApplicat ion = this .LoanAppli cation.Get (execution Context);        
194                if (loan Applicatio n == null)        
195                {        
196                    thro w new Inva lidOperati onExceptio n("Loan Ap plication  has not be en specifi ed", new A rgumentNul lException ("Loan App lication") );        
197                }        
198                else if  (loanAppli cation.Log icalName ! = CustomEn tity)        
199                {        
200                    thro w new Inva lidOperati onExceptio n("Loan Ap plication  must refer ence a Loa n Applicat ion entity ",        
201                         new Argume ntExceptio n("Loan Ap plication  must be of  type Loan  Applicati on", "Loan  Applicati on"));        
202                }        
203          
204                //Retrie ve the Crm Service so  that we c an retriev e the loan  applicati on        
205                IWorkflo wContext c ontext = e xecutionCo ntext.GetE xtension<I WorkflowCo ntext>();        
206                IOrganiz ationServi ceFactory  serviceFac tory = exe cutionCont ext.GetExt ension<IOr ganization ServiceFac tory>();        
207                IOrganiz ationServi ce service  = service Factory.Cr eateOrgani zationServ ice(contex t.Initiati ngUserId);        
208          
209                //Retrie ve the Loa n Applicat ion Entity        
210                Entity l oanEntity;        
211                {        
212                    //Cr eate a req uest        
213                    Retr ieveReques t retrieve Request =  new Retrie veRequest( );        
214                    retr ieveReques t.ColumnSe t = new Co lumnSet(ne w string[]  { "new_lo anapplicat ionid", "n ew_loanapp licantid"  });        
215                    retr ieveReques t.Target =  loanAppli cation;        
216          
217                    //Ex ecute the  request        
218                    Retr ieveRespon se retriev eResponse  = (Retriev eResponse) service.Ex ecute(retr ieveReques t);        
219          
220                    //Re trieve the  Loan Appl ication En tity        
221                    loan Entity = r etrieveRes ponse.Enti ty as Enti ty;        
222                }        
223          
224                //Retrie ve the Con tact Entit y        
225                Entity c ontactEnti ty;        
226                {        
227                    //Cr eate a req uest        
228                    Enti tyReferenc e loanAppl icantId =  (EntityRef erence)loa nEntity["n ew_loanapp licantid"] ;        
229          
230                    Retr ieveReques t retrieve Request =  new Retrie veRequest( );        
231                    retr ieveReques t.ColumnSe t = new Co lumnSet(ne w string[]  { "fullna me", "new_ ssn", "bir thdate" }) ;        
232                    retr ieveReques t.Target =  loanAppli cantId;        
233          
234                    //Ex ecute the  request        
235                    Retr ieveRespon se retriev eResponse  = (Retriev eResponse) service.Ex ecute(retr ieveReques t);        
236          
237                    //Re trieve the  Loan Appl ication En tity        
238                    cont actEntity  = retrieve Response.E ntity as E ntity;        
239                }        
240          
241                //Retrie ve the nee ded proper ties        
242                string s sn = (stri ng)contact Entity["ne w_ssn"];        
243                string n ame = (str ing)contac tEntity[Co ntactAttri butes.Full Name];        
244                DateTime ? birthdat e = (DateT ime?)conta ctEntity[C ontactAttr ibutes.Bir thdate];        
245                int cred itScore;        
246          
247                //This i s where th e logic fo r retrievi ng the cre dit score  would be i nserted        
248                //We are  simply go ing to ret urn a rand om number        
249                creditSc ore = (new  Random()) .Next(0, 1 000);        
250          
251                //Set th e credit s core prope rty        
252                this.Cre ditScore.S et(executi onContext,  creditSco re);        
253          
254                //Check  to see if  the credit  score sho uld be sav ed to the  entity        
255                //If the  value of  the proper ty has not  been set  or it is s et to true        
256                if (null  != this.U pdateEntit y && this. UpdateEnti ty.Get(exe cutionCont ext))        
257                {        
258                    //Cr eate the e ntity        
259                    Enti ty updateE ntity = ne w Entity(l oanApplica tion.Logic alName);        
260                    upda teEntity[" new_loanap plicationi d"] = loan Entity["ne w_loanappl icationid" ];        
261                    upda teEntity[" new_credit score"] =  this.Credi tScore.Get (execution Context);        
262          
263                    //Up date the e ntity        
264                    serv ice.Update (updateEnt ity);        
265                }        
266           }        
267          
268           // Define the  propertie s        
269           [I nput("Loan  Applicati on")]        
270           [R eferenceTa rget(Custo mEntity)]        
271           pu blic InArg ument<Enti tyReferenc e> LoanApp lication {  get; set;  }        
272          
273           [I nput("Upda te Entity' s Credit S core")]        
274           [D efault("tr ue")]        
275           pu blic InArg ument<bool > UpdateEn tity { get ; set; }        
276          
277           [O utput("Cre dit Score" )]        
278           [A ttributeTa rget(Custo mEntity, " new_credit score")]        
279           pu blic OutAr gument<int > CreditSc ore { get;  set; }        
280       }        
281       //</sn ippetRelea seISVActiv ities4>        
282   }        
283   //</snippe tReleaseIS VActivitie s>