578. Araxis Merge File Comparison Report

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

578.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\AutoRouteLead AutoRouteLead.cs Tue Dec 20 19:51:45 2016 UTC
2 Wed Feb 1 19:56:51 2017 UTC

578.2 Comparison summary

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

578.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

578.4 Active regular expressions

No regular expressions were active.

578.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   //<snippet AutoRouteL ead>        
17   using Syst em;        
18   using Syst em.Activit ies;        
19          
20   // These n amespaces  are found  in the Mic rosoft.Xrm .Sdk.dll a ssembly        
21   // located  in the SD K\bin fold er of the  SDK downlo ad.        
22   using Micr osoft.Xrm. Sdk;        
23   using Micr osoft.Xrm. Sdk.Messag es;        
24   using Micr osoft.Xrm. Sdk.Query;        
25          
26   // These n amespaces  are found  in the Mic rosoft.Xrm .Sdk.Workf low.dll as sembly        
27   // located  in the SD K\bin fold er of the  SDK downlo ad.        
28   using Micr osoft.Xrm. Sdk.Workfl ow;        
29          
30   // These n amespaces  are found  in the Mic rosoft.Crm .Sdk.Proxy .dll assem bly        
31   // located  in the SD K\bin fold er of the  SDK downlo ad.        
32   using Micr osoft.Crm. Sdk.Messag es;        
33          
34   namespace  Microsoft. Crm.Sdk.Sa mples        
35   {        
36       /// <s ummary>        
37       /// As signs the  lead to th e user wit h the fewe st lead re cords assi gned.        
38       /// In put argume nts:        
39       ///    "Lead". Ty pe: Entity Reference.  Is the le ad entity.        
40       /// Ou tput argum ent:        
41       ///    None.        
42       /// </ summary>        
43       public  sealed pa rtial clas s AutoRout eLead : Co deActivity        
44       {        
45           // / <summary >        
46           // / This met hod first  retrieves  the lead.  Afterwards , it check s the valu e of        
47           // / the new_ autoroute  field, and  if it is  True, it r etrieves a ll the use rs         
48           // / with 'Cu stomer Ser vice Repre sentative'  role, and  assigns t his lead t o        
49           // / the user  with the  fewest lea d records  assigned.        
50           // / </summar y>        
51           pr otected ov erride voi d Execute( CodeActivi tyContext  executionC ontext)        
52           {        
53                IWorkflo wContext c ontext = e xecutionCo ntext.GetE xtension<I WorkflowCo ntext>();        
54                IOrganiz ationServi ceFactory  serviceFac tory =         
55                    exec utionConte xt.GetExte nsion<IOrg anizationS erviceFact ory>();        
56                IOrganiz ationServi ce service  =         
57                    serv iceFactory .CreateOrg anizationS ervice(con text.UserI d);        
58          
59                #region  Retrieve t he lead        
60                        
61                // Get t he lead ID        
62                Guid lea dId = this .lead_inpu t.Get(exec utionConte xt).Id;        
63                        
64                //Reques t for Enti ty        
65                Retrieve Request re quest = ne w Retrieve Request();        
66                request. ColumnSet  = new Colu mnSet(true );        
67                request. Target = n ew EntityR eference(" lead", lea dId);        
68                        
69                //Execut e request        
70                Entity t argetReque st =         
71                    (Ent ity)((Retr ieveRespon se)service .Execute(r equest)).E ntity;        
72          
73                #endregi on Retriev e the lead        
74          
75                bool aut oroute = f alse;        
76                autorout e = (bool) targetRequ est.Attrib utes["new_ autoroute" ];        
77          
78                if (auto route)        
79                {        
80                    // G et user's  BusinessUn it        
81                    Retr ieveReques t userrequ est = new  RetrieveRe quest();        
82                    user request.Co lumnSet =  new Column Set("busin essunitid" );        
83                    user request.Ta rget = new  EntityRef erence("sy stemuser",  context.U serId);        
84          
85                    Enti ty userEnt ity =         
86                         (Entity)(( RetrieveRe sponse)ser vice.Execu te(userreq uest)).Ent ity;        
87                    Enti tyReferenc e bu = (En tityRefere nce)userEn tity["busi nessunitid "];        
88                            
89                    // G et roleid  for 'Custo mer Servic e Represen tative' wi th that BU        
90                    Quer yExpressio n queryRol e = new Qu eryExpress ion();        
91                    quer yRole.Colu mnSet = ne w ColumnSe t("roleid" );        
92                    quer yRole.Enti tyName = " role";        
93                    quer yRole.Crit eria.AddCo ndition(ne w Conditio nExpressio n        
94                    {        
95                         AttributeN ame = "nam e",        
96                         Operator =  Condition Operator.E qual,        
97                         Values = {  "Customer  Service R epresentat ive" }        
98                    });        
99                    quer yRole.Crit eria.AddCo ndition(ne w Conditio nExpressio n        
100                    {        
101                         AttributeN ame = "bus inessuniti d",        
102                         Operator =  Condition Operator.E qual,        
103                         Values = {  bu.Id }        
104                    });        
105          
106                    var  roles = se rvice.Retr ieveMultip le(queryRo le);        
107          
108                    if ( roles.Enti ties.Count  > 0)        
109                    {        
110                         Guid roleI d = (Guid) roles.Enti ties[0]["r oleid"];        
111          
112                         // Create  the query  to get all  the users  with that  role        
113                         QueryExpre ssion quer yUsers = n ew QueryEx pression() ;        
114          
115                         // Set the  propertie s of the q uery.        
116                         queryUsers .EntityNam e = "syste muserroles ";        
117                         queryUsers .ColumnSet  = new Col umnSet("sy stemuserid ");        
118                         queryUsers .Criteria. AddConditi on        
119                             ("role id", Condi tionOperat or.Equal,  roleId);        
120          
121                         // Get the  list of u sers.        
122                         var users  = service. RetrieveMu ltiple(que ryUsers);        
123          
124                         if (users. Entities.C ount > 0)        
125                         {        
126                             #regio n Get User  with lowe st number  of leads a ssigned        
127          
128                             // Ini tialize va riables        
129                             int lo wLeadCount  = -1;        
130                             int cu rrentLeadC ount = 0;        
131                             Guid l owUserId =  new Guid( );        
132          
133                             // Cre ate the qu ery to fin d out how  many leads          
134                             // eac h retrieve d user has        
135                             QueryE xpression  queryUsers Leads = ne w QueryExp ression();        
136          
137                             // Set  the prope rties of t he query.        
138                             queryU sersLeads. EntityName  = "lead";        
139                             queryU sersLeads. ColumnSet  = new Colu mnSet("lea did", "own erid");        
140                                     
141                             foreac h (var use r in users .Entities)        
142                             {        
143                                 qu eryUsersLe ads.Criter ia.AddCond ition        
144                                      ("owneri d", Condit ionOperato r.Equal, u ser["syste muserid"]) ;        
145                                 En tityCollec tion curre ntUserLead s =         
146                                      service. RetrieveMu ltiple(que ryUsersLea ds);        
147                                 cu rrentLeadC ount = cur rentUserLe ads.Entiti es.Count;        
148          
149                                 //  If is the  first tim e or the n umber of l eads is lo west,         
150                                 //  the curre nt User is  marked lo west.        
151                                 if  ((lowLead Count == - 1) || (cur rentLeadCo unt < lowL eadCount))        
152                                 {        
153                                      lowLeadC ount = cur rentLeadCo unt;        
154                                      lowUserI d = (Guid) user["syst emuserid"] ;        
155                                 }        
156                                         
157                             }        
158                             #endre gion Get U ser with L owest Numb er of lead s assigned        
159          
160                             #regio n Assign n ew lead to  identifie d user        
161          
162                             // Ass ign the le ad to the  user         
163                             // wit h the fewe st lead re cords assi gned        
164                             Assign Request as signReques t = new As signReques t()        
165                             {        
166                                 Ta rget = new  EntityRef erence("le ad", leadI d),        
167                                 As signee = n ew EntityR eference(" systemuser ", lowUser Id)        
168                             };        
169                             servic e.Execute( assignRequ est);        
170                                     
171                             #endre gion Assig n new lead  to identi fied user        
172                         }        
173                    }        
174                }        
175           }        
176                   
177           [R equiredArg ument]        
178           [I nput("Lead ")]        
179           [R eferenceTa rget("lead ")]        
180           pu blic InArg ument<Enti tyReferenc e> lead_in put { get;  set; }        
181       }        
182   }        
183   //</snippe tAutoRoute Lead>