620. Araxis Merge File Comparison Report

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

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

620.2 Comparison summary

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

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

620.4 Active regular expressions

No regular expressions were active.

620.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 CreateReal TimeWorkfl ow>        
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 cr eate a rea l-time wor kflow in M icrosoft D ynamics CR M.        
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 ateRealTim eWorkflow        
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,server Config.Cre dentials,  serverConf ig.DeviceC redentials ))        
64                    {        
65                         // This st atement is  required  to enable  early-boun d type sup port.        
66                         _servicePr oxy.Enable ProxyTypes ();        
67                            
68                         CreateRequ iredRecord s();        
69          
70                         #region De fine the w orkflow in  XAML        
71          
72                         // Define  the workfl ow using X AML. This  is typical ly done in  the Visua l Studio        
73                         // workflo w designer .        
74                         string xam lWF = @"<? xml versio n=""1.0""  encoding=" "utf-16""? >        
75                             <Activ ity x:Clas s=""Sample WF""         
76                                        xmlns= ""http://s chemas.mic rosoft.com /netfx/200 9/xaml/act ivities""         
77                                        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""         
78                                        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""         
79                                        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""         
80                                        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"        
81                                        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""         
82                                        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""                                             
83                                        xmlns: this=""clr -namespace :"" xmlns: x=""http:/ /schemas.m icrosoft.c om/winfx/2 006/xaml"" >        
84                                 <x :Members>        
85                                      <x:Prope rty Name=" "InputEnti ties"" Typ e=""InArgu ment(scg:I Dictionary (x:String,  mxs:Entit y))"" />        
86                                      <x:Prope rty Name=" "CreatedEn tities"" T ype=""InAr gument(scg :IDictiona ry(x:Strin g, mxs:Ent ity))"" />        
87                                 </ x:Members>        
88                                 <t his:Sample WF.InputEn tities>        
89                                      <InArgum ent x:Type Arguments= ""scg:IDic tionary(x: String, mx s:Entity)" " />        
90                                 </ this:Sampl eWF.InputE ntities>        
91                                 <t his:Sample WF.Created Entities>        
92                                    <InArgumen t x:TypeAr guments="" scg:IDicti onary(x:St ring, mxs: Entity)""  />        
93                                </t his:Sample WF.Created Entities>        
94                                 <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>        
95                                 <m xswa:Workf low>        
96                                      <Sequenc e>        
97                                          <Seq uence.Vari ables>        
98                                               <Variable  x:TypeArgu ments=""x: Int32"" De fault=""[4 0]"" Name= ""probabil ity_value" " />        
99                                               <Variable  x:TypeArgu ments=""mx s:Entity""  Default=" "[CreatedE ntities(&q uot;primar yEntity#Te mp&quot;)] "" Name="" CreatedEnt ity"" />        
100                                          </Se quence.Var iables>        
101                                          <Ass ign x:Type Arguments= ""mxs:Enti ty"" To="" [CreatedEn tity]"" Va lue=""[New  Entity(&q uot;opport unity&quot ;)]"" />        
102                                          <Ass ign x:Type Arguments= ""s:Guid""  To=""[Cre atedEntity .Id]"" Val ue=""[Inpu tEntities( &quot;prim aryEntity& quot;).Id] "" />        
103                                          <mxs wa:SetEnti tyProperty  Attribute =""closepr obability" " Entity=" "[CreatedE ntity]""         
104                                               EntityName =""opportu nity"" Tar getType="" [Type.GetT ype(&quot; probabilit y_value&qu ot;)]""         
105                                                               Value =""[probab ility_valu e]"">        
106                                          </mx swa:SetEnt ityPropert y>        
107                                          <mxs wa:UpdateE ntity Enti ty=""[Crea tedEntity] "" EntityN ame=""oppo rtunity""  />        
108                                          <Ass ign x:Type Arguments= ""mxs:Enti ty"" To="" [InputEnti ties(&quot ;primaryEn tity&quot; )]"" Value =""[Create dEntity]""  />        
109                                          <Per sist />        
110                                      </Sequen ce>        
111                                 </ mxswa:Work flow>        
112                             </Acti vity>";        
113          
114                         #endregion  Define th e workflow  in XAML        
115          
116                         #region Cr eate the w orkflow        
117          
118                         //<snippet CreateReal TimeWorkfl ow1>        
119                         // Create  a real-tim e workflow        
120                         // The wor kflow shou ld execute  after a n ew opportu nity is cr eated        
121                         // and run  in the co ntext of t he logged  on user.        
122                         Workflow w orkflow =  new Workfl ow()        
123                         {        
124                             // The se propert ies map to  the New P rocess for m settings  in the we b applicat ion.        
125                             Name =  "Set clos eprobabili ty on oppo rtunity cr eate (real -time)",        
126                             Type =  new Optio nSetValue( (int)Workf lowType.De finition),                
127                             Catego ry = new O ptionSetVa lue((int)W orkflowCat egory.Work flow),        
128                             Primar yEntity =  Opportunit y.EntityLo gicalName,        
129                             Mode =  new Optio nSetValue( (int)Workf lowMode.Re altime),        
130          
131                             // Add itional se ttings fro m the seco nd New Pro cess form.        
132                             Descri ption = @" When an op portunity  is created , this wor kflow" +        
133                                 "  sets the c loseprobab ility fiel d of the o pportunity  record to  40%.",        
134                             OnDema nd = false ,        
135                             Subpro cess = fal se,        
136                             Scope  = new Opti onSetValue ((int)Work flowScope. User),        
137                             RunAs  = new Opti onSetValue ((int)work flow_runas .CallingUs er),        
138                             SyncWo rkflowLogO nFailure =  true,        
139                             Trigge rOnCreate  = true,        
140                             Create Stage = ne w OptionSe tValue((in t)workflow _stage.Pos toperation ),        
141                             Xaml =  xamlWF,        
142          
143                             // Oth er propert ies not in  the web f orms.        
144                             Langua geCode = 1 033,  // U .S. Englis h        
145                         };        
146                         _workflowI d = _servi ceProxy.Cr eate(workf low);        
147                         //</snippe tCreateRea lTimeWorkf low1>        
148          
149                         Console.Wr iteLine("C reated Wor kflow: " +  workflow. Name);        
150          
151                         #endregion  Create th e workflow        
152          
153                         #region Ac tivate the  workflow        
154          
155                         // Activat e the work flow. Init ially, the  workflow  is created  in        
156                         // a Draft  state and  must be a ctivated b efore it c an run.        
157                         var activa teRequest  = new SetS tateReques t        
158                         {        
159                             Entity Moniker =  new Entity Reference        
160                                 (W orkflow.En tityLogica lName, _wo rkflowId),        
161                             State  = new Opti onSetValue ((int)Work flowState. Activated) ,        
162                             Status  = new Opt ionSetValu e((int)wor kflow_stat uscode.Act ivated)        
163                         };        
164                         _servicePr oxy.Execut e(activate Request);        
165                         Console.Wr iteLine("A ctivated W orkflow: "  + workflo w.Name);        
166          
167                         #endregion  Activate  the workfl ow        
168          
169                         DeleteRequ iredRecord s(promptfo rDelete);        
170                    }        
171                }        
172          
173                // Catch  any servi ce fault e xceptions  that Micro soft Dynam ics CRM th rows.        
174                catch (F aultExcept ion<Micros oft.Xrm.Sd k.Organiza tionServic eFault>)        
175                {        
176                    // Y ou can han dle an exc eption her e or pass  it back to  the calli ng method.        
177                    thro w;        
178                }        
179           }        
180          
181           #r egion Clas s methods        
182          
183           // / <summary >        
184           // / Creates  any entity  records t hat this s ample requ ires.        
185           // / </summar y>        
186           pu blic void  CreateRequ iredRecord s()        
187           {        
188                // No ne w entity r ecords nee ded for th is sample.        
189           }        
190          
191           // / <summary >        
192           // / Deletes  any entity  records t hat were c reated for  this samp le.        
193           // / <param n ame="promp t">Indicat es whether  to prompt  the user         
194           // / to delet e the reco rds create d in this  sample.</p aram>        
195           // / </summar y>        
196           pu blic void  DeleteRequ iredRecord s(bool pro mpt)        
197           {        
198                bool toB eDeleted =  true;        
199          
200                if (prom pt)        
201                {        
202                    // A sk the use r if the c reated ent ities shou ld be dele ted.        
203                    Cons ole.Write( "\nDo you  want these  entity re cords dele ted? (y/n)  [y]: ");        
204                    Stri ng answer  = Console. ReadLine() ;        
205                    if ( answer.Sta rtsWith("y ") ||        
206                         answer.Sta rtsWith("Y ") ||        
207                         answer ==  String.Emp ty)        
208                    {        
209                         toBeDelete d = true;        
210                    }        
211                    else        
212                    {        
213                         toBeDelete d = false;        
214                    }        
215                }        
216          
217                if (toBe Deleted)        
218                {        
219          
220                    // D eactivate  then delet e the work flow.        
221                    SetS tateReques t deactiva teRequest  = new SetS tateReques t        
222                    {        
223                         EntityMoni ker = new  EntityRefe rence(Work flow.Entit yLogicalNa me, _workf lowId),        
224                         State = ne w OptionSe tValue((in t)Workflow State.Draf t),        
225                         Status = n ew OptionS etValue((i nt)workflo w_statusco de.Draft)        
226                    };        
227                    _ser viceProxy. Execute(de activateRe quest);        
228                    _ser viceProxy. Delete(Wor kflow.Enti tyLogicalN ame, _work flowId);        
229                    Cons ole.WriteL ine("Workf low has be en deactiv ated and d eleted.");        
230                }        
231           }        
232          
233           #e ndregion C lass metho ds        
234          
235           #r egion Main  method        
236          
237           // / <summary >        
238           // / Standard  Main() me thod used  by most SD K samples.        
239           // / </summar y>        
240           // / <param n ame="args" ></param>        
241           st atic publi c void Mai n(string[]  args)        
242           {        
243                try        
244                {        
245                    // O btain the  target org anization' s web addr ess and cl ient logon          
246                    // c redentials  from the  user.        
247                    Serv erConnecti on serverC onnect = n ew ServerC onnection( );        
248                    Serv erConnecti on.Configu ration con fig = serv erConnect. GetServerC onfigurati on();        
249          
250                    Crea teRealTime Workflow a pp = new C reateRealT imeWorkflo w();        
251                    app. Run(config , true);        
252                }        
253                catch (F aultExcept ion<Micros oft.Xrm.Sd k.Organiza tionServic eFault> ex )        
254                {        
255                    Cons ole.WriteL ine("The a pplication  terminate d with an  error.");        
256                    Cons ole.WriteL ine("Times tamp: {0}" , ex.Detai l.Timestam p);        
257                    Cons ole.WriteL ine("Code:  {0}", ex. Detail.Err orCode);        
258                    Cons ole.WriteL ine("Messa ge: {0}",  ex.Detail. Message);        
259                    Cons ole.WriteL ine("Plugi n Trace: { 0}", ex.De tail.Trace Text);        
260                    Cons ole.WriteL ine("Inner  Fault: {0 }",        
261                         null == ex .Detail.In nerFault ?  "No Inner  Fault" :  "Has Inner  Fault");        
262                }        
263                catch (S ystem.Time outExcepti on ex)        
264                {        
265                    Cons ole.WriteL ine("The a pplication  terminate d with an  error.");        
266                    Cons ole.WriteL ine("Messa ge: {0}",  ex.Message );        
267                    Cons ole.WriteL ine("Stack  Trace: {0 }", ex.Sta ckTrace);        
268                    Cons ole.WriteL ine("Inner  Fault: {0 }",        
269                         null == ex .InnerExce ption.Mess age ? "No  Inner Faul t" : ex.In nerExcepti on.Message );        
270                }        
271                catch (S ystem.Exce ption ex)        
272                {        
273                    Cons ole.WriteL ine("The a pplication  terminate d with an  error.");        
274                    Cons ole.WriteL ine(ex.Mes sage);        
275          
276                    // D isplay the  details o f the inne r exceptio n.        
277                    if ( ex.InnerEx ception !=  null)        
278                    {        
279                         Console.Wr iteLine(ex .InnerExce ption.Mess age);        
280          
281                         FaultExcep tion<Micro soft.Xrm.S dk.Organiz ationServi ceFault> f e = ex.Inn erExceptio n        
282                             as Fau ltExceptio n<Microsof t.Xrm.Sdk. Organizati onServiceF ault>;        
283                         if (fe !=  null)        
284                         {        
285                             Consol e.WriteLin e("Timesta mp: {0}",  fe.Detail. Timestamp) ;        
286                             Consol e.WriteLin e("Code: { 0}", fe.De tail.Error Code);        
287                             Consol e.WriteLin e("Message : {0}", fe .Detail.Me ssage);        
288                             Consol e.WriteLin e("Plugin  Trace: {0} ", fe.Deta il.TraceTe xt);        
289                             Consol e.WriteLin e("Inner F ault: {0}" ,        
290                                 nu ll == fe.D etail.Inne rFault ? " No Inner F ault" : "H as Inner F ault");        
291                         }        
292                    }        
293                }        
294                // Addit ional exce ptions to  catch: Sec urityToken Validation Exception,  ExpiredSe curityToke nException ,        
295                // Secur ityAccessD eniedExcep tion, Mess ageSecurit yException , and Secu rityNegoti ationExcep tion.        
296          
297                finally        
298                {        
299                    Cons ole.WriteL ine("Press  <Enter> t o exit.");        
300                    Cons ole.ReadLi ne();        
301                }        
302           }        
303           #e ndregion M ain method        
304       }        
305   }        
306   //</snippe tCreateRea lTimeWorkf low>