Example #1
0
        public void WorkflowContinue(Mercury.Server.Application application, Int64 workQueueItemId, String assemblyUrl, String workflowClassName, Guid workflowInstanceId, Server.Workflows.UserInteractions.Response.ResponseBase userInteractionResponse)
        {
            workflowResponse.WorkQueueItemId = workQueueItemId;


            #region Load Workflow Assembly

            assemblyReferencePath = assemblyUrl.Substring(0, assemblyUrl.LastIndexOf('\\') + 1);

            assemblyReferenceName = assemblyUrl.Replace(assemblyReferencePath, "");


            AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(CurrentDomain_AssemblyResolve);

            System.Reflection.Assembly workflowAssembly = System.Reflection.Assembly.LoadFrom(assemblyUrl);

            Type workflowClass = workflowAssembly.GetType(workflowClassName);

            if (workflowClass == null)
            {
                throw new ApplicationException("Unable to find Class [" + workflowClassName + "] in referenced Assembly [" + assemblyUrl + "].");
            }

            #endregion


            // SET RESPONSE VALUE

            UserInteractionResponse = userInteractionResponse;


            // CREATE WORKFLOW INSTANCE

            workflowInstance = new System.Activities.WorkflowApplication((System.Activities.Activity)Activator.CreateInstance(workflowAssembly.GetType(workflowClassName)));


            // LINK EVENT HANDLERS

            workflowInstance.Completed = WorkflowCompleted;

            workflowInstance.Aborted = WorkflowAborted;

            // workflowInstance.Idle = WorkflowIdle; // DO NOTHING, REMOVED, FALL THROUGH TO PERSISTABLE IDLE TO UNLOAD

            workflowInstance.PersistableIdle = WorkflowPersistableIdle;

            workflowInstance.Unloaded = WorkflowUnloaded;

            workflowInstance.OnUnhandledException = WorkflowOnUnhandledException;


            // LINK PERSISTANCE INSTANCE STORE AND LOAD FROM STORE

            workflowInstance.InstanceStore = instanceStore;

            workflowInstance.Load(workflowInstanceId);


            // RESUME FROM BOOKMARK

            workflowInstance.ResumeBookmark(workflowInstanceId.ToString(), this);


            return;
        }
Example #2
0
        public void createApp()
        {
            //var xh = new XamlHelper(workflow.xaml);
            //extraextension.updateProfile(xh.Variables.ToArray(), xh.ArgumentNames.ToArray());
            var CustomTrackingParticipant = new WorkflowTrackingParticipant();

            CustomTrackingParticipant.OnVisualTracking += Participant_OnVisualTracking;

            if (string.IsNullOrEmpty(InstanceId))
            {
                // Remove unknown Parameters, if we don't the workflow will fail
                foreach (var param in Parameters.ToList())
                {
                    var allowed = Workflow.Parameters.Where(x => x.name == param.Key).FirstOrDefault();
                    if (allowed == null || allowed.direction == workflowparameterdirection.@out)
                    {
                        Parameters.Remove(param.Key);
                    }
                }
                // Ensure Type
                foreach (var wfparam in Workflow.Parameters)
                {
                    if (Parameters.ContainsKey(wfparam.name) && wfparam.type == "System.Int32")
                    {
                        if (Parameters[wfparam.name] != null)
                        {
                            Parameters[wfparam.name] = int.Parse(Parameters[wfparam.name].ToString());
                        }
                    }
                    else if (Parameters.ContainsKey(wfparam.name) && wfparam.type == "System.Boolean")
                    {
                        if (Parameters[wfparam.name] != null)
                        {
                            Parameters[wfparam.name] = bool.Parse(Parameters[wfparam.name].ToString());
                        }
                    }
                }
                wfApp = new System.Activities.WorkflowApplication(Workflow.Activity, Parameters);
                wfApp.Extensions.Add(CustomTrackingParticipant);
                if (Workflow.Serializable)
                {
                    //if (Config.local.localstate)
                    //{
                    //    if (!System.IO.Directory.Exists(System.IO.Directory.GetCurrentDirectory() + "\\state")) System.IO.Directory.CreateDirectory(System.IO.Directory.GetCurrentDirectory() + "\\state");
                    //    wfApp.InstanceStore = new Store.XMLFileInstanceStore(System.IO.Directory.GetCurrentDirectory() + "\\state");
                    //}
                    //else
                    //{
                    //    wfApp.InstanceStore = new Store.OpenFlowInstanceStore();
                    //}
                    wfApp.InstanceStore = new Store.OpenFlowInstanceStore();
                }
                addwfApphandlers(wfApp);
            }
            else
            {
                wfApp = new System.Activities.WorkflowApplication(Workflow.Activity);
                wfApp.Extensions.Add(CustomTrackingParticipant);
                addwfApphandlers(wfApp);
                if (Workflow.Serializable || !Workflow.Serializable)
                {
                    //if (Config.local.localstate)
                    //{
                    //    if (!System.IO.Directory.Exists(System.IO.Directory.GetCurrentDirectory() + "\\state")) System.IO.Directory.CreateDirectory(System.IO.Directory.GetCurrentDirectory() + "\\state");
                    //    wfApp.InstanceStore = new Store.XMLFileInstanceStore(System.IO.Directory.GetCurrentDirectory() + "\\state");
                    //}
                    //else
                    //{
                    //    wfApp.InstanceStore = new Store.OpenFlowInstanceStore();
                    //}
                    wfApp.InstanceStore = new Store.OpenFlowInstanceStore();
                }
                wfApp.Load(new Guid(InstanceId));
            }
            state = "loaded";
        }
Example #3
0
 public void createApp()
 {
     if (string.IsNullOrEmpty(InstanceId))
     {
         // Remove unknown Parameters, if we don't the workflow will fail
         foreach (var param in Parameters.ToList())
         {
             var allowed = Workflow.Parameters.Where(x => x.name == param.Key).FirstOrDefault();
             if (allowed == null || allowed.direction == workflowparameterdirection.@out)
             {
                 Parameters.Remove(param.Key);
             }
         }
         // Ensure Type
         foreach (var wfparam in Workflow.Parameters)
         {
             if (Parameters.ContainsKey(wfparam.name) && wfparam.type == "System.Int32")
             {
                 if (Parameters[wfparam.name] != null)
                 {
                     Parameters[wfparam.name] = int.Parse(Parameters[wfparam.name].ToString());
                 }
             }
             else if (Parameters.ContainsKey(wfparam.name) && wfparam.type == "System.Boolean")
             {
                 if (Parameters[wfparam.name] != null)
                 {
                     Parameters[wfparam.name] = bool.Parse(Parameters[wfparam.name].ToString());
                 }
             }
         }
         wfApp = new System.Activities.WorkflowApplication(Workflow.Activity, Parameters);
         if (Workflow.Serializable)
         {
             //if (Config.local.localstate)
             //{
             //    if (!System.IO.Directory.Exists(System.IO.Directory.GetCurrentDirectory() + "\\state")) System.IO.Directory.CreateDirectory(System.IO.Directory.GetCurrentDirectory() + "\\state");
             //    wfApp.InstanceStore = new Store.XMLFileInstanceStore(System.IO.Directory.GetCurrentDirectory() + "\\state");
             //}
             //else
             //{
             //    wfApp.InstanceStore = new Store.OpenFlowInstanceStore();
             //}
             wfApp.InstanceStore = new Store.OpenFlowInstanceStore();
         }
         addwfApphandlers(wfApp);
     }
     else
     {
         wfApp = new System.Activities.WorkflowApplication(Workflow.Activity);
         addwfApphandlers(wfApp);
         if (Workflow.Serializable)
         {
             //if (Config.local.localstate)
             //{
             //    if (!System.IO.Directory.Exists(System.IO.Directory.GetCurrentDirectory() + "\\state")) System.IO.Directory.CreateDirectory(System.IO.Directory.GetCurrentDirectory() + "\\state");
             //    wfApp.InstanceStore = new Store.XMLFileInstanceStore(System.IO.Directory.GetCurrentDirectory() + "\\state");
             //}
             //else
             //{
             //    wfApp.InstanceStore = new Store.OpenFlowInstanceStore();
             //}
             wfApp.InstanceStore = new Store.OpenFlowInstanceStore();
         }
         wfApp.Load(new Guid(InstanceId));
     }
     state = "loaded";
 }