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

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

623.2 Comparison summary

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

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

623.4 Active regular expressions

No regular expressions were active.

623.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 SetStateWo rkflow>        
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   using Micr osoft.Xrm. Sdk.Query;        
25          
26   // These n amespaces  are found  in the Mic rosoft.Crm .Sdk.Proxy .dll assem bly        
27   // located  in the SD K\bin fold er of the  SDK downlo ad.        
28   using Micr osoft.Crm. Sdk.Messag es;        
29          
30   namespace  Microsoft. Crm.Sdk.Sa mples        
31   {        
32       /// <s ummary>        
33       /// Th is sample  shows how  to change  the state  of a workf low.        
34       /// </ summary>        
35       /// <r emarks>        
36       /// At  run-time,  you will  be given t he option  to delete  all the        
37       /// da tabase rec ords creat ed by this  program.        
38       /// </ remarks>        
39       public  class Set StateWorkf low        
40       {        
41           #r egion Clas s Level Me mbers        
42          
43           pr ivate Guid  _workflow Id;        
44           pr ivate Orga nizationSe rviceProxy  _serviceP roxy;        
45                   
46           #e ndregion C lass Level  Members        
47          
48           #r egion How  To Sample  Code        
49           // / <summary >        
50           // / This met hod first  creates XA ML to defi ne the cus tom workfl ow. Afterw ards,         
51           // / it creat es the wor kflow reco rd with th is XAML an d then act ivates it.  Finally         
52           // / it check s if it is  activated  and, if s o, deactiv ates it.        
53           // / </summar y>        
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          
58           pu blic void  Run(Server Connection .Configura tion serve rConfig, b ool prompt forDelete)        
59           {        
60                try        
61                {        
62                    // C onnect to  the Organi zation ser vice.         
63                    // T he using s tatement a ssures tha t the serv ice proxy  will be pr operly dis posed.        
64                    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 ))        
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                         // Activat e the work flow.        
72                         Console.Wr iteLine("\ nActivatin g the work flow...");        
73                         //<snippet SetStateWo rkflow1>        
74                         var activa teRequest  = new SetS tateReques t        
75                         {        
76                             Entity Moniker =  new Entity Reference        
77                                 (W orkflow.En tityLogica lName, _wo rkflowId),        
78                             State  = new Opti onSetValue ((int)Work flowState. Activated) ,        
79                             Status  = new Opt ionSetValu e((int)wor kflow_stat uscode.Act ivated)        
80                         };        
81                         _servicePr oxy.Execut e(activate Request);        
82                         //</snippe tSetStateW orkflow1>        
83                                
84                         // Verify  that the w orkflow is  activated .        
85                         Workflow r etrievedWo rkflow =         
86                             (Workf low)_servi ceProxy.Re trieve("wo rkflow", _ workflowId , new Colu mnSet("sta tecode", " name"));        
87          
88                         Console.Wr iteLine("T he state o f workflow  {0} is: { 1}.", retr ievedWorkf low.Name,  retrievedW orkflow.St ateCode);        
89          
90                         // Deactiv ate the wo rkflow.        
91                         if (retrie vedWorkflo w.StateCod e == Workf lowState.A ctivated)        
92                         {        
93                             Consol e.WriteLin e("\nDeact ivating th e workflow ...");        
94                             //<sni ppetSetSta teWorkflow 2>        
95                             SetSta teRequest  deactivate Request =  new SetSta teRequest        
96                             {        
97                                 En tityMonike r =         
98                                      new Enti tyReferenc e(Workflow .EntityLog icalName,  _workflowI d),        
99                                 St ate = new  OptionSetV alue((int) WorkflowSt ate.Draft) ,        
100                                 St atus = new  OptionSet Value((int )workflow_ statuscode .Draft)        
101                             };        
102                             _servi ceProxy.Ex ecute(deac tivateRequ est);        
103                             //</sn ippetSetSt ateWorkflo w2>        
104                         }        
105          
106                         // Verify  that the w orkflow is  deactivat ed (in a d raft state ).        
107                         retrievedW orkflow =        
108                             (Workf low)_servi ceProxy.Re trieve("wo rkflow", _ workflowId , new Colu mnSet("sta tecode", " name"));        
109          
110                         Console.Wr iteLine("T he state o f workflow  {0} is: { 1}.", retr ievedWorkf low.Name,  retrievedW orkflow.St ateCode);        
111          
112                         DeleteRequ iredRecord s(promptfo rDelete);        
113                    }        
114                }        
115          
116                // Catch  any servi ce fault e xceptions  that Micro soft Dynam ics CRM th rows.        
117                catch (F aultExcept ion<Micros oft.Xrm.Sd k.Organiza tionServic eFault>)        
118                {        
119                    // Y ou can han dle an exc eption her e or pass  it back to  the calli ng method.        
120                    thro w;        
121                }        
122           }        
123          
124           #r egion Publ ic methods        
125          
126           // / <summary >        
127           // / Creates  any entity  records t hat this s ample requ ires.        
128           // / </summar y>        
129           pu blic void  CreateRequ iredRecord s()        
130           {        
131                #region  Create XAM L        
132          
133                // Defin e the work flow XAML.        
134                string x amlWF;        
135          
136                // This  xml define s a workfl ow that cr eates a ne w task whe n executed        
137                xamlWF =  @"<?xml v ersion=""1 .0"" encod ing=""utf- 16""?>        
138                             <Activ ity x:Clas s=""Create Task""         
139                                        xmlns= ""http://s chemas.mic rosoft.com /netfx/200 9/xaml/act ivities""         
140                                        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""         
141                                        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""         
142                                        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""         
143                                        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"        
144                                        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""         
145                                        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""                                             
146                                        xmlns: this=""clr -namespace :"" xmlns: x=""http:/ /schemas.m icrosoft.c om/winfx/2 006/xaml"" >        
147                                 <x :Members>        
148                                      <x:Prope rty Name=" "InputEnti ties"" Typ e=""InArgu ment(scg:I Dictionary (x:String,  mxs:Entit y))"" />        
149                                      <x:Prope rty Name=" "CreatedEn tities"" T ype=""InAr gument(scg :IDictiona ry(x:Strin g, mxs:Ent ity))"" />        
150                                 </ x:Members>        
151                                 <t his:Create Task.Input Entities>        
152                                      <InArgum ent x:Type Arguments= ""scg:IDic tionary(x: String, mx s:Entity)" " />        
153                                 </ this:Creat eTask.Inpu tEntities>        
154                                 <t his:Create Task.Creat edEntities >        
155                                    <InArgumen t x:TypeAr guments="" scg:IDicti onary(x:St ring, mxs: Entity)""  />        
156                                </t his:Create Task.Creat edEntities >        
157                                 <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>        
158                                 <m xswa:Workf low>        
159                                      <Sequenc e>        
160                                          <Ass ign x:Type Arguments= ""mxs:Enti ty"" To="" [CreatedEn tities(&qu ot;newTask &quot;)]""  Value=""[ New Entity (&quot;tas k&quot;)]" " />        
161                                          <mxs wa:SetEnti tyProperty  Attribute =""subject "" Entity= ""[Created Entities(& quot;newTa sk&quot;)] ""         
162                                               EntityName =""task""  TargetType =""{x:Null }""         
163                                                               Value =""[&quot; New Task&q uot;]"">        
164                                          </mx swa:SetEnt ityPropert y>        
165                                          <mxs wa:SetEnti tyProperty  Attribute =""regardi ngobjectid "" Entity= ""[Created Entities(& quot;newTa sk&quot;)] ""         
166                                               EntityName =""task""  TargetType =""{x:Null }""         
167                                                               Value =""[New En tityRefere nce(&quot; lead&quot; , New Guid (InputEnti ties(&quot ;primaryEn tity&quot; ).Id.ToStr ing()))]"" >        
168                                          </mx swa:SetEnt ityPropert y>        
169                                          <mxs wa:CreateE ntity Enti tyId=""{x: Null}"" En tity=""[Cr eatedEntit ies(&quot; newTask&qu ot;)]""         
170                                               EntityName =""task""  />        
171                                      </Sequen ce>        
172                                 </ mxswa:Work flow>        
173                             </Acti vity>";        
174          
175                #endregi on Create  XAML        
176          
177                #region  Create Wor kflow        
178          
179                // Creat e the work flow        
180                //<snipp etSetState Workflow3>        
181                Workflow  workflow  = new Work flow()        
182                {        
183                    Name  = "Create TaskXAML",        
184                    Type  = new Opt ionSetValu e((int)Wor kflowType. Definition ),        
185                    Cate gory = new  OptionSet Value((int )WorkflowC ategory.Wo rkflow),        
186                    Scop e = new Op tionSetVal ue((int)Wo rkflowScop e.User),        
187                    Lang uageCode =  1033,                  // U.S.  English        
188                    Trig gerOnCreat e = true,        
189                    OnDe mand = tru e,        
190                    Prim aryEntity  = Lead.Ent ityLogical Name,        
191                    Desc ription =        
192                         "Test work flow for t he SetStat eWorkflow  SDK sample ",        
193                    Xaml  = xamlWF        
194                };        
195                _workflo wId = _ser viceProxy. Create(wor kflow);        
196                //</snip petSetStat eWorkflow3 >        
197          
198                Console. WriteLine( "Created w orkflow {0 }.", workf low.Name);        
199          
200                #endregi on Create  Workflow        
201           }        
202          
203           // / <summary >        
204           // / Deletes  any entity  records t hat were c reated for  this samp le.        
205           // / <param n ame="promp t">Indicat es whether  to prompt  the user         
206           // / to delet e the reco rds create d in this  sample.</p aram>        
207           // / </summar y>        
208           pu blic void  DeleteRequ iredRecord s(bool pro mpt)        
209           {        
210                bool toB eDeleted =  true;        
211          
212                if (prom pt)        
213                {        
214                    // A sk the use r if the c reated ent ities shou ld be dele ted.        
215                    Cons ole.Write( "\nDo you  want these  entity re cords dele ted? (y/n)  [y]: ");        
216                    Stri ng answer  = Console. ReadLine() ;        
217                    if ( answer.Sta rtsWith("y ") ||        
218                         answer.Sta rtsWith("Y ") ||        
219                         answer ==  String.Emp ty)        
220                    {        
221                         toBeDelete d = true;        
222                    }        
223                    else        
224                    {        
225                         toBeDelete d = false;        
226                    }        
227                }        
228          
229                if (toBe Deleted)        
230                {        
231                    // D elete the  workflow.        
232                    _ser viceProxy. Delete(Wor kflow.Enti tyLogicalN ame, _work flowId);        
233                    Cons ole.WriteL ine("The w orkflow ha s been del eted.");        
234                }        
235           }        
236           #e ndregion P ublic Meth ods        
237          
238           #e ndregion H ow To Samp le Code        
239          
240           #r egion Main  method        
241          
242           // / <summary >        
243           // / Standard  Main() me thod used  by most SD K samples.        
244           // / </summar y>        
245           // / <param n ame="args" ></param>        
246           st atic publi c void Mai n(string[]  args)        
247           {        
248                try        
249                {        
250                    // O btain the  target org anization' s Web addr ess and cl ient logon          
251                    // c redentials  from the  user.        
252                    Serv erConnecti on serverC onnect = n ew ServerC onnection( );        
253                    Serv erConnecti on.Configu ration con fig = serv erConnect. GetServerC onfigurati on();        
254          
255                    SetS tateWorkfl ow app = n ew SetStat eWorkflow( );        
256                    app. Run(config , true);        
257                }        
258                catch (F aultExcept ion<Micros oft.Xrm.Sd k.Organiza tionServic eFault> ex )        
259                {        
260                    Cons ole.WriteL ine("The a pplication  terminate d with an  error.");        
261                    Cons ole.WriteL ine("Times tamp: {0}" , ex.Detai l.Timestam p);        
262                    Cons ole.WriteL ine("Code:  {0}", ex. Detail.Err orCode);        
263                    Cons ole.WriteL ine("Messa ge: {0}",  ex.Detail. Message);        
264                    Cons ole.WriteL ine("Plugi n Trace: { 0}", ex.De tail.Trace Text);        
265                    Cons ole.WriteL ine("Inner  Fault: {0 }",        
266                         null == ex .Detail.In nerFault ?  "No Inner  Fault" :  "Has Inner  Fault");        
267                }        
268                catch (S ystem.Time outExcepti on ex)        
269                {        
270                    Cons ole.WriteL ine("The a pplication  terminate d with an  error.");        
271                    Cons ole.WriteL ine("Messa ge: {0}",  ex.Message );        
272                    Cons ole.WriteL ine("Stack  Trace: {0 }", ex.Sta ckTrace);        
273                    Cons ole.WriteL ine("Inner  Fault: {0 }",        
274                         null == ex .InnerExce ption.Mess age ? "No  Inner Faul t" : ex.In nerExcepti on.Message );        
275                }        
276                catch (S ystem.Exce ption ex)        
277                {        
278                    Cons ole.WriteL ine("The a pplication  terminate d with an  error.");        
279                    Cons ole.WriteL ine(ex.Mes sage);        
280          
281                    // D isplay the  details o f the inne r exceptio n.        
282                    if ( ex.InnerEx ception !=  null)        
283                    {        
284                         Console.Wr iteLine(ex .InnerExce ption.Mess age);        
285          
286                         FaultExcep tion<Micro soft.Xrm.S dk.Organiz ationServi ceFault> f e = ex.Inn erExceptio n        
287                             as Fau ltExceptio n<Microsof t.Xrm.Sdk. Organizati onServiceF ault>;        
288                         if (fe !=  null)        
289                         {        
290                             Consol e.WriteLin e("Timesta mp: {0}",  fe.Detail. Timestamp) ;        
291                             Consol e.WriteLin e("Code: { 0}", fe.De tail.Error Code);        
292                             Consol e.WriteLin e("Message : {0}", fe .Detail.Me ssage);        
293                             Consol e.WriteLin e("Plugin  Trace: {0} ", fe.Deta il.TraceTe xt);        
294                             Consol e.WriteLin e("Inner F ault: {0}" ,        
295                                 nu ll == fe.D etail.Inne rFault ? " No Inner F ault" : "H as Inner F ault");        
296                         }        
297                    }        
298                }        
299                // Addit ional exce ptions to  catch: Sec urityToken Validation Exception,  ExpiredSe curityToke nException ,        
300                // Secur ityAccessD eniedExcep tion, Mess ageSecurit yException , and Secu rityNegoti ationExcep tion.        
301          
302                finally        
303                {        
304                    Cons ole.WriteL ine("Press  <Enter> t o exit.");        
305                    Cons ole.ReadLi ne();        
306                }        
307           }        
308          
309           #e ndregion M ain method        
310       }        
311   }        
312   //</snippe tSetStateW orkflow>