618. Araxis Merge File Comparison Report

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

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

618.2 Comparison summary

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

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

618.4 Active regular expressions

No regular expressions were active.

618.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 CreateAWor kflow>        
17   using Syst em;        
18   using Syst em.Service Model;        
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.Client ;        
24          
25   // These n amespaces  are found  in the Mic rosoft.Crm .Sdk.Proxy .dll assem bly        
26   // located  in the SD K\bin fold er of the  SDK downlo ad.        
27   using Micr osoft.Crm. Sdk.Messag es;        
28          
29   namespace  Microsoft. Crm.Sdk.Sa mples        
30   {        
31       /// <s ummary>        
32       /// Th is sample  shows how  to use C#  code to de fine a new  workflow  in Microso ft Dynamic s CRM.        
33       /// </ summary>        
34       /// <r emarks>        
35       /// At  run-time,  you will  be given t he option  to delete  all the        
36       /// da tabase rec ords creat ed by this  program.< /remarks>        
37       public  class Cre ateAWorkfl ow        
38       {        
39           #r egion Clas s Level Me mbers        
40          
41           pr ivate Guid  _workflow Id;        
42           pr ivate Orga nizationSe rviceProxy  _serviceP roxy;        
43          
44           #e ndregion C lass Level  Members        
45          
46           // / <summary >        
47           // / This met hod first  creates XA ML to defi ne the cus tom workfl ow. Afterw ards,         
48           // / it creat es the wor kflow reco rd with th is XAML an d then act ivates it.        
49           // / </summar y>        
50           // / <remarks >        
51           // / Visit ht tp://msdn. microsoft. com/en-us/ library/gg 309458.asp        
52           // / for inst ructions o n enabling  XAML work flows on t he Microso ft Dynamic s CRM serv er.        
53           // / </remark s>        
54           // / <param n ame="serve rConfig">C ontains se rver conne ction info rmation.</ param>        
55           // / <param n ame="promp tforDelete ">When Tru e, the use r will be  prompted t o delete a ll        
56           // / created  entities.< /param>        
57           pu blic void  Run(Server Connection .Configura tion serve rConfig, b ool prompt forDelete)        
58           {        
59                try        
60                {        
61                    // C onnect to  the Organi zation ser vice.         
62                    // T he using s tatement a ssures tha t the serv ice proxy  will be pr operly dis posed.        
63                    usin g (_servic eProxy = n ew Organiz ationServi ceProxy(se rverConfig .Organizat ionUri, se rverConfig .HomeRealm Uri,        
64                                                                              s erverConfi g.Credenti als, serve rConfig.De viceCreden tials))        
65                    {        
66                         // This st atement is  required  to enable  early-boun d type sup port.        
67                         _servicePr oxy.Enable ProxyTypes ();        
68                            
69                         CreateRequ iredRecord s();        
70          
71                         #region Cr eate XAML        
72          
73                         // Define  the workfl ow XAML.        
74                         string xam lWF;        
75          
76                         xamlWF = @ "<?xml ver sion=""1.0 "" encodin g=""utf-16 ""?>        
77                             <Activ ity x:Clas s=""Sample WF""         
78                                        xmlns= ""http://s chemas.mic rosoft.com /netfx/200 9/xaml/act ivities""         
79                                        xmlns: mva=""clr- namespace: Microsoft. VisualBasi c.Activiti es;assembl y=System.A ctivities,  Version=4 .0.0.0, Cu lture=neut ral, Publi cKeyToken= 31bf3856ad 364e35""         
80                                        xmlns: mxs=""clr- namespace: Microsoft. Xrm.Sdk;as sembly=Mic rosoft.Xrm .Sdk, Vers ion=5.0.0. 0, Culture =neutral,  PublicKeyT oken=31bf3 856ad364e3 5""         
81                                        xmlns: mxswa=""cl r-namespac e:Microsof t.Xrm.Sdk. Workflow.A ctivities; assembly=M icrosoft.X rm.Sdk.Wor kflow, Ver sion=5.0.0 .0, Cultur e=neutral,  PublicKey Token=31bf 3856ad364e 35""         
82                                        xmlns: s=""clr-na mespace:Sy stem;assem bly=mscorl ib, Versio n=4.0.0.0,  Culture=n eutral, Pu blicKeyTok en=b77a5c5 61934e089"        
83                                        xmlns: scg=""clr- namespace: System.Col lections.G eneric;ass embly=msco rlib, Vers ion=4.0.0. 0, Culture =neutral,  PublicKeyT oken=b77a5 c561934e08 9""         
84                                        xmlns: srs=""clr- namespace: System.Run time.Seria lization;a ssembly=Sy stem.Runti me.Seriali zation, Ve rsion=4.0. 0.0, Cultu re=neutral , PublicKe yToken=b77 a5c561934e 089""                                             
85                                        xmlns: this=""clr -namespace :"" xmlns: x=""http:/ /schemas.m icrosoft.c om/winfx/2 006/xaml"" >        
86                                 <x :Members>        
87                                      <x:Prope rty Name=" "InputEnti ties"" Typ e=""InArgu ment(scg:I Dictionary (x:String,  mxs:Entit y))"" />        
88                                      <x:Prope rty Name=" "CreatedEn tities"" T ype=""InAr gument(scg :IDictiona ry(x:Strin g, mxs:Ent ity))"" />        
89                                 </ x:Members>        
90                                 <t his:Sample WF.InputEn tities>        
91                                      <InArgum ent x:Type Arguments= ""scg:IDic tionary(x: String, mx s:Entity)" " />        
92                                 </ this:Sampl eWF.InputE ntities>        
93                                 <t his:Sample WF.Created Entities>        
94                                    <InArgumen t x:TypeAr guments="" scg:IDicti onary(x:St ring, mxs: Entity)""  />        
95                                </t his:Sample WF.Created Entities>        
96                                 <m va:VisualB asic.Setti ngs>Assemb ly referen ces and im ported nam espaces fo r internal  implement ation</mva :VisualBas ic.Setting s>        
97                                 <m xswa:Workf low>        
98                                      <Sequenc e>        
99                                          <Seq uence.Vari ables>        
100                                               <Variable  x:TypeArgu ments=""x: Int32"" De fault=""[4 0]"" Name= ""probabil ity_value" " />        
101                                               <Variable  x:TypeArgu ments=""mx s:Entity""  Default=" "[CreatedE ntities(&q uot;primar yEntity#Te mp&quot;)] "" Name="" CreatedEnt ity"" />        
102                                          </Se quence.Var iables>        
103                                          <Ass ign x:Type Arguments= ""mxs:Enti ty"" To="" [CreatedEn tity]"" Va lue=""[New  Entity(&q uot;opport unity&quot ;)]"" />        
104                                          <Ass ign x:Type Arguments= ""s:Guid""  To=""[Cre atedEntity .Id]"" Val ue=""[Inpu tEntities( &quot;prim aryEntity& quot;).Id] "" />        
105                                          <mxs wa:SetEnti tyProperty  Attribute =""closepr obability" " Entity=" "[CreatedE ntity]""         
106                                               EntityName =""opportu nity"" Tar getType="" [Type.GetT ype(&quot; probabilit y_value&qu ot;)]""         
107                                                               Value =""[probab ility_valu e]"">        
108                                          </mx swa:SetEnt ityPropert y>        
109                                          <mxs wa:UpdateE ntity Enti ty=""[Crea tedEntity] "" EntityN ame=""oppo rtunity""  />        
110                                          <Ass ign x:Type Arguments= ""mxs:Enti ty"" To="" [InputEnti ties(&quot ;primaryEn tity&quot; )]"" Value =""[Create dEntity]""  />        
111                                          <Per sist />        
112                                      </Sequen ce>        
113                                 </ mxswa:Work flow>        
114                             </Acti vity>";        
115          
116                         #endregion  Create XA ML        
117          
118                         #region Cr eate Workf low        
119          
120                         //<snippet CreateAWor kflow1>        
121                         // Create  an asynchr onous work flow.        
122                         // The wor kflow shou ld execute  after a n ew opportu nity is cr eated.        
123                         Workflow w orkflow =  new Workfl ow()        
124                         {        
125                             // The se propert ies map to  the New P rocess for m settings  in the we b applicat ion.        
126                             Name =  "Set clos eprobabili ty on oppo rtunity cr eate (asyn c)",        
127                             Type =  new Optio nSetValue( (int)Workf lowType.De finition),        
128                             Catego ry = new O ptionSetVa lue((int)W orkflowCat egory.Work flow),        
129                             Primar yEntity =  Opportunit y.EntityLo gicalName,        
130                             Mode =  new Optio nSetValue( (int)Workf lowMode.Ba ckground),        
131          
132                             // Add itional se ttings fro m the seco nd New Pro cess form.        
133                             Descri ption = @" When an op portunity  is created , this wor kflow" +        
134                                 "  sets the c loseprobab ility fiel d of the o pportunity  record to  40%.",        
135                             OnDema nd = false ,        
136                             Subpro cess = fal se,        
137                             Scope  = new Opti onSetValue ((int)Work flowScope. User),        
138                             Trigge rOnCreate  = true,        
139                             AsyncA utoDelete  = true,        
140                             Xaml =  xamlWF,        
141          
142                             // Oth er propert ies not in  the web f orms.        
143                             Langua geCode = 1 033,  // U .S. Englis h                                  
144                         };        
145                         _workflowI d = _servi ceProxy.Cr eate(workf low);        
146                         //</snippe tCreateAWo rkflow1>        
147          
148                         Console.Wr iteLine("C reated Wor kflow: " +  workflow. Name);        
149          
150                         #endregion  Create Wo rkflow        
151          
152                         #region Ac tivate Wor kflow        
153          
154                         // Activat e the work flow.        
155                         var activa teRequest  = new SetS tateReques t        
156                         {        
157                             Entity Moniker =  new Entity Reference        
158                                 (W orkflow.En tityLogica lName, _wo rkflowId),        
159                             State  = new Opti onSetValue ((int)Work flowState. Activated) ,        
160                             Status  = new Opt ionSetValu e((int)wor kflow_stat uscode.Act ivated)        
161                         };        
162                         _servicePr oxy.Execut e(activate Request);        
163                         Console.Wr iteLine("A ctivated W orkflow: "  + workflo w.Name);        
164                                
165                         #endregion  Activate  Workflow        
166                                
167                         DeleteRequ iredRecord s(promptfo rDelete);        
168                    }        
169                }        
170          
171                // Catch  any servi ce fault e xceptions  that Micro soft Dynam ics CRM th rows.        
172                catch (F aultExcept ion<Micros oft.Xrm.Sd k.Organiza tionServic eFault>)        
173                {        
174                    // Y ou can han dle an exc eption her e or pass  it back to  the calli ng method.        
175                    thro w;        
176                }        
177           }        
178          
179           #r egion Clas s methods        
180          
181           // / <summary >        
182           // / Creates  any entity  records t hat this s ample requ ires.        
183           // / </summar y>        
184           pu blic void  CreateRequ iredRecord s()        
185           {        
186          
187           }        
188          
189           // / <summary >        
190           // / Deletes  any entity  records t hat were c reated for  this samp le.        
191           // / <param n ame="promp t">Indicat es whether  to prompt  the user         
192           // / to delet e the reco rds create d in this  sample.</p aram>        
193           // / </summar y>        
194           pu blic void  DeleteRequ iredRecord s(bool pro mpt)        
195           {        
196                bool toB eDeleted =  true;        
197          
198                if (prom pt)        
199                {        
200                    // A sk the use r if the c reated ent ities shou ld be dele ted.        
201                    Cons ole.Write( "\nDo you  want these  entity re cords dele ted? (y/n)  [y]: ");        
202                    Stri ng answer  = Console. ReadLine() ;        
203                    if ( answer.Sta rtsWith("y ") ||        
204                         answer.Sta rtsWith("Y ") ||        
205                         answer ==  String.Emp ty)        
206                    {        
207                         toBeDelete d = true;        
208                    }        
209                    else        
210                    {        
211                         toBeDelete d = false;        
212                    }        
213                }        
214          
215                if (toBe Deleted)        
216                {        
217          
218                    // D eactivate  and delete  workflow        
219                    SetS tateReques t deactiva teRequest  = new SetS tateReques t        
220                    {        
221                         EntityMoni ker = new  EntityRefe rence(Work flow.Entit yLogicalNa me, _workf lowId),        
222                         State = ne w OptionSe tValue((in t)Workflow State.Draf t),        
223                         Status = n ew OptionS etValue((i nt)workflo w_statusco de.Draft)        
224                    };        
225                    _ser viceProxy. Execute(de activateRe quest);        
226                    _ser viceProxy. Delete(Wor kflow.Enti tyLogicalN ame, _work flowId);        
227                    Cons ole.WriteL ine("Workf low has be en deactiv ated and d eleted.");        
228          
229                }        
230           }        
231          
232           #e ndregion C lass metho ds        
233          
234           #r egion Main  method        
235          
236           // / <summary >        
237           // / Standard  Main() me thod used  by most SD K samples.        
238           // / </summar y>        
239           // / <param n ame="args" ></param>        
240           st atic publi c void Mai n(string[]  args)        
241           {        
242                try        
243                {        
244                    // O btain the  target org anization' s Web addr ess and cl ient logon          
245                    // c redentials  from the  user.        
246                    Serv erConnecti on serverC onnect = n ew ServerC onnection( );        
247                    Serv erConnecti on.Configu ration con fig = serv erConnect. GetServerC onfigurati on();        
248          
249                    Crea teAWorkflo w app = ne w CreateAW orkflow();        
250                    app. Run(config , true);        
251                }        
252                catch (F aultExcept ion<Micros oft.Xrm.Sd k.Organiza tionServic eFault> ex )        
253                {        
254                    Cons ole.WriteL ine("The a pplication  terminate d with an  error.");        
255                    Cons ole.WriteL ine("Times tamp: {0}" , ex.Detai l.Timestam p);        
256                    Cons ole.WriteL ine("Code:  {0}", ex. Detail.Err orCode);        
257                    Cons ole.WriteL ine("Messa ge: {0}",  ex.Detail. Message);        
258                    Cons ole.WriteL ine("Plugi n Trace: { 0}", ex.De tail.Trace Text);        
259                    Cons ole.WriteL ine("Inner  Fault: {0 }",        
260                         null == ex .Detail.In nerFault ?  "No Inner  Fault" :  "Has Inner  Fault");        
261                }        
262                catch (S ystem.Time outExcepti on ex)        
263                {        
264                    Cons ole.WriteL ine("The a pplication  terminate d with an  error.");        
265                    Cons ole.WriteL ine("Messa ge: {0}",  ex.Message );        
266                    Cons ole.WriteL ine("Stack  Trace: {0 }", ex.Sta ckTrace);        
267                    Cons ole.WriteL ine("Inner  Fault: {0 }",        
268                         null == ex .InnerExce ption.Mess age ? "No  Inner Faul t" : ex.In nerExcepti on.Message );        
269                }        
270                catch (S ystem.Exce ption ex)        
271                {        
272                    Cons ole.WriteL ine("The a pplication  terminate d with an  error.");        
273                    Cons ole.WriteL ine(ex.Mes sage);        
274          
275                    // D isplay the  details o f the inne r exceptio n.        
276                    if ( ex.InnerEx ception !=  null)        
277                    {        
278                         Console.Wr iteLine(ex .InnerExce ption.Mess age);        
279          
280                         FaultExcep tion<Micro soft.Xrm.S dk.Organiz ationServi ceFault> f e = ex.Inn erExceptio n        
281                             as Fau ltExceptio n<Microsof t.Xrm.Sdk. Organizati onServiceF ault>;        
282                         if (fe !=  null)        
283                         {        
284                             Consol e.WriteLin e("Timesta mp: {0}",  fe.Detail. Timestamp) ;        
285                             Consol e.WriteLin e("Code: { 0}", fe.De tail.Error Code);        
286                             Consol e.WriteLin e("Message : {0}", fe .Detail.Me ssage);        
287                             Consol e.WriteLin e("Plugin  Trace: {0} ", fe.Deta il.TraceTe xt);        
288                             Consol e.WriteLin e("Inner F ault: {0}" ,        
289                                 nu ll == fe.D etail.Inne rFault ? " No Inner F ault" : "H as Inner F ault");        
290                         }        
291                    }        
292                }        
293                // Addit ional exce ptions to  catch: Sec urityToken Validation Exception,  ExpiredSe curityToke nException ,        
294                // Secur ityAccessD eniedExcep tion, Mess ageSecurit yException , and Secu rityNegoti ationExcep tion.        
295          
296                finally        
297                {        
298                    Cons ole.WriteL ine("Press  <Enter> t o exit.");        
299                    Cons ole.ReadLi ne();        
300                }        
301           }        
302           #e ndregion M ain method        
303       }        
304   }        
305   //</snippe tCreateAWo rkflow>