/// <summary>
        ///
        /// </summary>
        /// <param name="definitionPath"></param>
        /// <param name="mapPath"></param>
        /// <param name="connectionString"></param>
        /// <param name="instanceId"></param>
        public static void Update(String definitionPath, String mapPath, String connectionString, Guid instanceId)
        {
            // Store
            SqlWorkflowInstanceStore instanceStore = new SqlWorkflowInstanceStore
            {
                ConnectionString = connectionString
            };

            // Instance to update
            WorkflowApplicationInstance wfInstance = WorkflowApplication.GetInstance(instanceId, instanceStore);

            // Load update map
            DynamicUpdateMap       updateMap;
            DataContractSerializer s = new DataContractSerializer(typeof(DynamicUpdateMap));

            using (FileStream fs = File.Open(mapPath, FileMode.Open))
            {
                updateMap = s.ReadObject(fs) as DynamicUpdateMap;
            }
            // if (updateMap == null) return; // Throw

            WorkflowApplication wfApp =
                new WorkflowApplication(LoadActivityBuilder(definitionPath).Implementation);

            IList <ActivityBlockingUpdate> act;

            if (wfInstance.CanApplyUpdate(updateMap, out act))
            {
                wfApp.Load(wfInstance, updateMap);
                wfApp.Unload();
            }
        }
 public void Unload()
 {
     if (wfApp != null)
     {
         wfApp.Unload();
     }
 }
      private void cmdUpdateInstance_Click(object sender, RoutedEventArgs e)
      {
          SqlWorkflowInstanceStore instanceStore = new SqlWorkflowInstanceStore();

          instanceStore.ConnectionString =
              @"Data Source=(LocalDB)\v11.0;Initial Catalog=WFPersist;Integrated Security=True";

          WorkflowApplicationInstance wfInstance =
              WorkflowApplication.GetInstance(new Guid(txtUpdateInstance.Text), instanceStore);

          DataContractSerializer s = new DataContractSerializer(typeof(DynamicUpdateMap));

          using (FileStream fs = File.Open(txtUpdateMapFile.Text, FileMode.Open))
          {
              updateMap = s.ReadObject(fs) as DynamicUpdateMap;
          }

          var wfApp =
              new WorkflowApplication(new MovieRentalProcess(),
                                      new WorkflowIdentity
            {
                Name    = "v2MovieRentalProcess",
                Version = new System.Version(2, 0, 0, 0)
            });

          IList <ActivityBlockingUpdate> act;

          if (wfInstance.CanApplyUpdate(updateMap, out act))
          {
              wfApp.Load(wfInstance, updateMap);
              wfApp.Unload();
          }
      }
 public void Unload()
 {
     if (_workflowApplication != null)
     {
         _workflowApplication.Unload();
     }
 }
Esempio n. 5
0
 public virtual void Unload()
 {
     if (app != null)
     {
         app.Unload();
         //app.Unload();
         this.barrier.WaitOne();
     }
 }
Esempio n. 6
0
        private static void UpgradeExistingWorkflow(Guid id, DynamicUpdateMap map)
        {
            SqlWorkflowInstanceStore    store    = new SqlWorkflowInstanceStore(ConfigurationManager.ConnectionStrings["db"].ConnectionString);
            WorkflowApplicationInstance instance = WorkflowApplication.GetInstance(id, store);
            WorkflowApplication         app      = new WorkflowApplication(GetUpdatedWorkflow());

            app.Load(instance, map);
            app.Unload();
        }
Esempio n. 7
0
        private static Guid CreateAndUnloadInitialWorkflow()
        {
            SqlWorkflowInstanceStore store = new SqlWorkflowInstanceStore(ConfigurationManager.ConnectionStrings["db"].ConnectionString);
            WorkflowApplication      app   = new WorkflowApplication(GetOriginalWorkflow());

            app.InstanceStore = store;
            app.Unload();

            return(app.Id);
        }
Esempio n. 8
0
 public void Dispose()
 {
     if (wfApp?.InstanceStore != null)
     {
         wfApp?.Unload();
     }
     else
     {
         wfApp?.Cancel();
     }
 }
 private void UnloadApplication(WorkflowApplication application)
 {
     try
     {
         // attempt to unload will fail if the workflow is idle within a NoPersistZone
         application.Unload(TimeSpan.FromSeconds(5));
     }
     catch (TimeoutException e)
     {
         Debug.Write(e.Message);
     }
 }
Esempio n. 10
0
 public void Stop()
 {
     if (m_app != null)
     {
         try
         {
             m_app.Unload();
             m_app.Terminate("执行已取消", new TimeSpan(0, 0, 0, 30));
         }
         catch (Exception)
         {
             MessageBox.Show(App.Current.MainWindow, "停止调试发生异常!", ResxIF.GetString("PronptText"), MessageBoxButton.OK, MessageBoxImage.Warning);
         }
     }
 }
Esempio n. 11
0
        static void Main(string[] args)
        {
            WorkflowApplication wfApp = CreateWorkflowApplication();
            var workflowInstanceId    = wfApp.Id;

            wfApp.Run();
            string bookmarkName = workflowInstanceId.ToString();

            wfApp.Unload();
            _unloadedEvent.WaitOne();
            /* create */
            wfApp = CreateWorkflowApplication();
            wfApp.Load(workflowInstanceId);
            var result = wfApp.ResumeBookmark(bookmarkName, null); // <- this hits the BookmarkActivity while **IT SHOULD'NT**
        }
Esempio n. 12
0
    private void GetReimbursementVoid(Guid id)
    {
        // Initialize Windows Workflow Foundation
        WorkflowApplication _wfApp = new WorkflowApplication(new ReimbursementRequest());

        SqlWorkflowInstanceStore store = new SqlWorkflowInstanceStore(ConfigurationManager.ConnectionStrings["workflows"].ConnectionString);

        _wfApp.InstanceStore   = store;
        _wfApp.PersistableIdle = delegate(WorkflowApplicationIdleEventArgs ex)
        {
            return(PersistableIdleAction.Persist);
        };
        _wfApp.Run();
        _wfApp.Unload();
        Session["wfid"] = _wfApp.Id;
    }
Esempio n. 13
0
        public string ExecuteWF(User user, bool reject = false)
        {
            string retMsg = "SuccessWF";

            if (user == null || user.WorkflowInstId == Guid.Empty)
            {
                Dictionary <string, object> dic = new Dictionary <string, object>();
                dic.Add("model", user);
                instance = new WorkflowApplication(new AdminRights(), dic);

                this.InitWorkflowApplication();
                instance.Run();
            }
            else
            {
                AdminRights rights = new AdminRights();
                instance = new WorkflowApplication(rights);
                this.InitWorkflowApplication();
                instance.Load(user.WorkflowInstId);
                string approver = "SuperAdmin";
                if (reject)
                {
                    //更新状态
                    WFinstanceDAL wfDal = new WFinstanceDAL();
                    wfDal.Add(user.WorkflowInstId.ToString(), approver, "驳回");

                    WFCurrentNodeInfoDAL infoDal = new WFCurrentNodeInfoDAL();
                    infoDal.UpdateExitTime(user.WorkflowInstId.ToString(), DateTime.Now);

                    instance.Cancel();
                    retMsg = "驳回成功";
                }
                if (instance.GetBookmarks().Count > 0)
                {
                    Dictionary <string, object> dic = new Dictionary <string, object>();
                    dic.Add("model", user);
                    dic.Add("curApproveUser", approver);
                    instance.ResumeBookmark("BookmarkTest", dic);
                }
            }

            user.WorkflowInstId = instance.Id;
            //等待工作线程结束
            idleEvent.WaitOne();
            instance.Unload();
            return(retMsg);
        }
Esempio n. 14
0
        static void Main(string[] args)
        {
            SqlWorkflowInstanceStore store = new SqlWorkflowInstanceStore(connectionString);

            WorkflowApplication.CreateDefaultInstanceOwner(store, null, WorkflowIdentityFilter.Any);

            IDictionary <WorkflowIdentity, DynamicUpdateInfo> updateMaps = LoadMaps();

            foreach (Guid id in GetIds())
            {
                // Get a proxy to the instance.
                WorkflowApplicationInstance instance =
                    WorkflowApplication.GetInstance(id, store);

                Console.WriteLine("Inspecting: {0}", instance.DefinitionIdentity);

                // Only update v1 workflows.
                if (instance.DefinitionIdentity != null &&
                    instance.DefinitionIdentity.Version.Equals(new Version(1, 0, 0, 0)))
                {
                    DynamicUpdateInfo info = updateMaps[instance.DefinitionIdentity];

                    // Associate the persisted WorkflowApplicationInstance with
                    // a WorkflowApplication that is configured with the updated
                    // definition and updated WorkflowIdentity.
                    Activity            wf    = WorkflowVersionMap.GetWorkflowDefinition(info.newIdentity);
                    WorkflowApplication wfApp =
                        new WorkflowApplication(wf, info.newIdentity);

                    // Apply the Dynamic Update.
                    wfApp.Load(instance, info.updateMap);

                    // Persist the updated instance.
                    wfApp.Unload();

                    Console.WriteLine("Updated to: {0}", info.newIdentity);
                }
                else
                {
                    // Not updating this instance, so unload it.
                    instance.Abandon();
                }
            }
        }
Esempio n. 15
0
        // single interaction with the user. The user enters a string in the console and that
        // string is used to resume the ReadLine activity bookmark
        static void Interact(WorkflowApplication application, AutoResetEvent resetEvent)
        {
            Console.WriteLine("Workflow is ready for input");
            Console.WriteLine("Special commands: 'unload', 'exit'");

            bool done = false;

            while (!done)
            {
                Console.Write("> ");
                string s = Console.ReadLine();
                if (s.Equals("unload"))
                {
                    try
                    {
                        // attempt to unload will fail if the workflow is idle within a NoPersistZone
                        application.Unload(TimeSpan.FromSeconds(5));
                        done = true;
                    }
                    catch (TimeoutException e)
                    {
                        Console.WriteLine(e.Message);
                    }
                }
                else if (s.Equals("exit"))
                {
                    application.ResumeBookmark("inputBookmark", s);
                    done = true;
                }
                else
                {
                    application.ResumeBookmark("inputBookmark", s);
                }
            }
            resetEvent.WaitOne();
        }
 private void cmdUnload_Click(object sender, RoutedEventArgs e)
 {
     _wfApp.Unload();
 }
Esempio n. 17
0
        /// <summary>
        ///     Starts processing the given activity via the WorkflowApplication.
        /// </summary>
        /// <param name="command">The command to be ran.</param>
        /// <param name="firstParameter">The first parameter to include (if any).</param>
        /// <param name="secondParameter">The second parameter to include (if any).</param>
        /// <param name="thirdParameter">The third parameter to include (if any).</param>
        private void StartWorkflowScience(string command, string firstParameter, string secondParameter, string thirdParameter /* future use */)
        {
            // Now stage the WorkflowApplication, using the SQL instance, wrapped in using to dispose all of the things when done.
            using (AutoResetEvent syncEvent = new AutoResetEvent(false))
            {
                // NOTE: If the string doesn't - explicitly - match, the .ctor() of the
                // SwedishCodeActivity will throw, since the string is the key. Also,
                // no boxing/unboxing required for Dictionary<T,T>; which saves overhead.
                Dictionary <string, SwedishCodeActivity <object> > newDictionary = new Dictionary <string, SwedishCodeActivity <object> >
                {
                    // See the 'Activities' folder for examples of Activities that you can use here.
                    { "CheckFreeDiskSpaceActivity", new CheckFreeDiskSpaceActivity() },
                    { "CopyFilesActivity", new CopyFilesActivity() },
                    { "CopyNIsAndDLLsActivity", new CopyImagesAndLibrariesActivity() },
                    { "DateTimeActivity", new UtcDateTimeActivity() },
                    { "DumpProcessThreadsActivity", new DumpProcessThreadsActivity() },
                    { "FileExistsActivity", new CheckIfFileExistsActivity() },
                    { "ForceBlueScreenActivity", new ForceBlueScreenActivity() },
                    { "GetLoggedOnUsersActivity", new GetCurrentLoggedOnUsersActivity() },
                    { "GetOsFileVersionActivity", new GetOsFileVersionActivity() },
                    { "GetProcessIdActivity", new GetProcessIdsActivity() },
                    { "GetSystemUptimeActivity", new GetSystemUptimeActivity() },
                    { "GetTimeSkewActivity", new GetSystemTimeSkewActivity() },
                    { "InstallSysInternalsActivity", new InstallSysInternalsActivity() },
                    { "ModifyConfigurationFileActivity", new EditConfigurationFileActivity() },
                    { "PingActivity", new PingResponseActivity() },
                    { "PortConnectivityActivity", new PortConnectivityActivity() },
                    { "ReadFileContentsActivity", new ReadFileContentsActivity() },
                    { "RenameMachineActivity", new RenameMachineActivity() },
                    { "RestartServiceActivity", new RestartServiceActivity() },
                    { "SetSymbolsEnvironmentPath", new SetSymbolServerEnvironmentPathActivity() },
                    { "StartSecureDeleteActivity", new StartSecureDeleteActivity() },
                    { "WindowsUpdateActivity", new WindowsUpdateActivity() },
                    { "WebStringActivity", new WebStringActivity() }
                };

                SwedishCodeActivity <object> newSwedishCodeActivity = (SwedishCodeActivity <object>)newDictionary[command];
                if (!string.IsNullOrWhiteSpace(firstParameter))
                {
                    newSwedishCodeActivity.FirstInArgument = firstParameter;
                }

                if (!string.IsNullOrWhiteSpace(secondParameter))
                {
                    newSwedishCodeActivity.SecondInArgument = secondParameter;
                }

                if (!string.IsNullOrWhiteSpace(thirdParameter))
                {
                    newSwedishCodeActivity.ThirdInArgument = thirdParameter;
                }

                SqlWorkflowInstanceStore newSqlWorkflowInstanceStore = new SqlWorkflowInstanceStore("Server=192.168.0.252,1433\\SQL2008EXPRESS;Initial Catalog=WorkflowInstanceStore;Integrated Security=SSPI")
                {
                    HostLockRenewalPeriod            = TimeSpan.FromSeconds(1),
                    InstanceCompletionAction         = InstanceCompletionAction.DeleteNothing,
                    InstanceLockedExceptionAction    = InstanceLockedExceptionAction.AggressiveRetry,
                    RunnableInstancesDetectionPeriod = TimeSpan.FromSeconds(1) // Minimum allowed value.
                };

                InstanceHandle             workflowInstanceStoreHandle = newSqlWorkflowInstanceStore.CreateInstanceHandle();
                CreateWorkflowOwnerCommand createWorkflowOwnerCommand  = new CreateWorkflowOwnerCommand();
                InstanceView newInstanceView = newSqlWorkflowInstanceStore.Execute(workflowInstanceStoreHandle, createWorkflowOwnerCommand, TimeSpan.FromSeconds(30));
                newSqlWorkflowInstanceStore.DefaultInstanceOwner = newInstanceView.InstanceOwner;

                WorkflowApplication newWorkflowApplication = new WorkflowApplication(newSwedishCodeActivity, new WorkflowIdentity
                {
                    // The Dictionary will throw for non-found key before we ever get here, so no need to validate input.
                    Name    = command,
                    Version = new Version(0, 1, 0, 0)
                })
                {
                    InstanceStore          = newSqlWorkflowInstanceStore,
                    SynchronizationContext = SynchronizationContext.Current
                };

                newWorkflowApplication.Persist();
                ResultObject = new object();
                newWorkflowApplication.Completed += delegate(WorkflowApplicationCompletedEventArgs e)
                {
                    if (e.CompletionState == ActivityInstanceState.Faulted)
                    {
                        EventLog.WriteEntry("Felsökning.Tomte.AdminService", $"Workflow {e.InstanceId} has faulted.\nException: {e.TerminationException.GetType().FullName}\nMessage:{e.TerminationException.Message}");
                        syncEvent.Set();
                    }
                    else if (e.CompletionState == ActivityInstanceState.Canceled)
                    {
                        EventLog.WriteEntry("Felsökning.Tomte.AdminService", $"Workflow {e.InstanceId} has been canceled.");
                        syncEvent.Set();
                    }
                    else
                    {
                        // Since the result can be *anything*, let's not treat it like a string.
                        EventLog.WriteEntry("Felsökning.Tomte.AdminService", $"Workflow {e.InstanceId} completed. Result: {e.Outputs["Result"]}");
                        ResultObject = e.Outputs["Result"];
                        syncEvent.Set();
                    }
                };

                newWorkflowApplication.Aborted = delegate(WorkflowApplicationAbortedEventArgs e)
                {
                    // The workflow aborted, so let's find out why.
                    EventLog.WriteEntry("Felsökning.Tomte.AdminService", $"Workflow {e.InstanceId} has been aborted.\nException: {e.Reason.GetType().FullName}\nMessage:{e.Reason.Message}");
                    syncEvent.Set();
                };

                newWorkflowApplication.Idle = delegate(WorkflowApplicationIdleEventArgs e)
                {
                    // TODO: [FUTURE] Need to handle future persistence maintenance.
                    EventLog.WriteEntry("Felsökning.Tomte.AdminService", $"Workflow {e.InstanceId} has entered the Idle state.");
                    syncEvent.Set();
                };

                newWorkflowApplication.PersistableIdle = delegate(WorkflowApplicationIdleEventArgs e)
                {
                    EventLog.WriteEntry("Felsökning.Tomte.AdminService", $"Workflow {e.InstanceId} has entered PersistableIdle.");
                    syncEvent.Set();

                    // Runtime will persist.
                    return(PersistableIdleAction.Persist);
                };

                newWorkflowApplication.Unloaded = delegate(WorkflowApplicationEventArgs e)
                {
                    EventLog.WriteEntry("Felsökning.Tomte.AdminService", $"Workflow {e.InstanceId} has been unloaded.");
                    syncEvent.Set();
                };

                newWorkflowApplication.OnUnhandledException = delegate(WorkflowApplicationUnhandledExceptionEventArgs e)
                {
                    // Log the unhandled exception.
                    EventLog.WriteEntry("Felsökning.Tomte.AdminService",
                                        !string.IsNullOrWhiteSpace(e.UnhandledException.InnerException?.Message)
                            ? $"Workflow {e.InstanceId} has reached an AggregateException in OnUnhandledException.\nException Source: {e.ExceptionSource.DisplayName}\nException Instance ID: {e.ExceptionSourceInstanceId}\nException: {e.UnhandledException.InnerException.GetType().FullName}\nMessage: {e.UnhandledException.InnerException.Message}\nFirstArgument: {firstParameter}\nSecondArgument: {secondParameter}"
                            : $"Workflow {e.InstanceId} has reached OnUnhandledException.\nException Source: {e.ExceptionSource.DisplayName}\nException Instance ID: {e.ExceptionSourceInstanceId}\nException: {e.UnhandledException.GetType().FullName}\nMessage: {e.UnhandledException.Message}\nFirstArgument: {firstParameter}\nSecondArgument: {secondParameter}");

                    syncEvent.Set();

                    // Instruct the runtime to terminate the workflow.
                    // The other viable choices here are 'Abort' or 'Cancel'
                    return(UnhandledExceptionAction.Terminate);
                };

                newWorkflowApplication.Run();

                // Because a new thread is spawned, we need to wait for it to complete before we can move on.
                syncEvent.WaitOne();

                // Instance MUST be unloaded to update the SQL record. One would think this would happen on the overridden delegate methods (e.g.: Completed,OnUnhandledException, etc.)
                // but testing has proven this to not be the case.
                newWorkflowApplication.Unload(TimeSpan.FromSeconds(30));

                // Now, we dump the instance owner.
                DeleteWorkflowOwnerCommand newDeleteWorkflowOwnerCommand = new DeleteWorkflowOwnerCommand();
                newSqlWorkflowInstanceStore.Execute(
                    workflowInstanceStoreHandle,
                    newDeleteWorkflowOwnerCommand,
                    TimeSpan.FromSeconds(30));
            }

            GC.Collect();
        }
Esempio n. 18
0
        /// <summary>
        /// Invoked when a web request arrives.
        /// </summary>
        public void ProcessRequest(HttpContext context)
        {
            try
            {
                // bind ourselves to the context
                Context = context;

                // request was for a resource
                if (Request[ResourceQueryKey] != null)
                {
                    // handle it and return, no need to deal with workflow
                    ProcessResourceRequest(Request[ResourceQueryKey]);
                    return;
                }

                // obtain our activity instance
                Activity = CreateActivity();

                // configure application
                WorkflowApplication = Request[InstanceIdQueryKey] == null ? new WorkflowApplication(Activity, GetArguments()) : new WorkflowApplication(Activity);
                WorkflowApplication.Extensions.Add <ITwilioContext>(() => this);
                WorkflowApplication.SynchronizationContext = new SynchronizedSynchronizationContext();
                WorkflowApplication.InstanceStore          = CreateInstanceStore();
                WorkflowApplication.Aborted              = OnAborted;
                WorkflowApplication.Completed            = OnCompleted;
                WorkflowApplication.Idle                 = OnIdle;
                WorkflowApplication.OnUnhandledException = OnUnhandledException;
                WorkflowApplication.PersistableIdle      = OnPersistableIdle;
                WorkflowApplication.Unloaded             = OnUnloaded;

                // attempt to resolve current instance id and reload workflow state
                if (Request[InstanceIdQueryKey] != null)
                {
                    WorkflowApplication.Load(Guid.Parse(Request[InstanceIdQueryKey]), Timeout);
                }

                // postback to resume a bookmark
                if (Request[BookmarkQueryKey] != null)
                {
                    WorkflowApplication.ResumeBookmark(Request[BookmarkQueryKey], GetPostData(), Timeout);
                }
                else
                {
                    // begin running the workflow from the start
                    WorkflowApplication.Run(Timeout);
                }

                // throw exception
                if (UnhandledExceptionInfo != null)
                {
                    UnhandledExceptionInfo.Throw();
                }

                // strip off temporary attributes
                foreach (var element in TwilioResponse.DescendantsAndSelf())
                {
                    foreach (var attribute in element.Attributes())
                    {
                        if (attribute.Name.Namespace == tmpNs)
                        {
                            attribute.Remove();
                        }
                    }
                }

                // write finished twilio output
                Response.ContentType = "text/xml";
                using (var wrt = XmlWriter.Create(Response.Output))
                    TwilioResponse.WriteTo(wrt);

                // if we've reached the end, no need to force unload
                WorkflowApplication = null;
            }
            finally
            {
                // clean up application if possible
                if (WorkflowApplication != null)
                {
                    try
                    {
                        WorkflowApplication.Unload(Timeout);
                        WorkflowApplication = null;
                    }
                    catch
                    {
                        // ignore
                    }
                }
            }
        }
    //end

    protected void btnEdit_ServerClick(object sender, EventArgs e)
    {
        if (this.DropDown_sp.SelectedValue.Length == 0)
        {
            MessageBox.Show(this, "请您选择审核结果");
        }
        else
        {
            Model.SelectRecord selectRecords = new Model.SelectRecord("view_DocumentInfo", "", "*", "where id='" + id + "'");
            DataTable          dt            = BLL.SelectRecord.SelectRecordData(selectRecords).Tables[0];
            //ziyunhx add 2013-8-5 workflow Persistence
            if (dt == null)
            {
                return;
            }
            Model.SelectRecord selectRecord = new Model.SelectRecord("WorkFlow", "", "*", "where id='" + dt.Rows[0]["WorkFlowID"].ToString() + "'");
            DataTable          table        = BLL.SelectRecord.SelectRecordData(selectRecord).Tables[0];

            string content = File.ReadAllText(System.Web.HttpContext.Current.Request.MapPath("../") + table.Rows[0]["URL"].ToString());

            instance = engineManager.createInstance(content, null, null);
            if (instanceStore == null)
            {
                instanceStore = new SqlWorkflowInstanceStore(SqlHelper.strconn);
                view          = instanceStore.Execute(instanceStore.CreateInstanceHandle(), new CreateWorkflowOwnerCommand(), TimeSpan.FromSeconds(30));
                instanceStore.DefaultInstanceOwner = view.InstanceOwner;
            }
            instance.InstanceStore = instanceStore;
            Guid guid = new Guid(dt.Rows[0]["FlowInstranceID"].ToString());
            instance.Load(guid);
            //end


            if (this.DropDown_sp.SelectedValue == "true")
            {
                string[] s = dt.Rows[0]["OID"].ToString().Split(new char[] { ',' });
                if (s[s.Length - 1] == "1")
                {
                    Model.SelectRecord selectExecut = new Model.SelectRecord("WorkFlowExecution", "", "*", "where DID='" + id + "' and step ='" + dt.Rows[0]["WStep"].ToString() + "' and UID='" + this.Session["admin"].ToString() + "'");
                    DataTable          executdt     = BLL.SelectRecord.SelectRecordData(selectExecut).Tables[0];
                    if (executdt.Rows.Count > 0)
                    {
                        MessageBox.ShowAndRedirect(this, "该公文您已审核,请等待其他人审核!", "/document/DocumentList.aspx");
                    }
                    else
                    {
                        Model.SelectRecord selectExecutCount = new Model.SelectRecord("WorkFlowExecution", "", "distinct UID", "where DID='" + id + "' and step ='" + dt.Rows[0]["WStep"].ToString() + "'");
                        DataTable          dtcount           = BLL.SelectRecord.SelectRecordData(selectExecutCount).Tables[0];

                        string where = "where IsState=2 AND (1=2 ";

                        string[] str = dt.Rows[0]["OID"].ToString().Split(new char[] { ',' });
                        for (int j = 1; j < str.Length - 1; j++)
                        {
                            where += "OR OID like '%" + str[j].ToString() + "%' ";
                        }
                        where += ") order by id desc";

                        Model.SelectRecord selectUserCount = new Model.SelectRecord("Users", "", "ID", where);
                        DataTable          usercount       = BLL.SelectRecord.SelectRecordData(selectUserCount).Tables[0];

                        if (dtcount.Rows.Count + 1 == usercount.Rows.Count)
                        {
                            if (instance.GetBookmarks().Count(p => p.BookmarkName == dt.Rows[0]["value"].ToString()) == 1)
                            {
                                instance.ResumeBookmark(dt.Rows[0]["value"].ToString(), this.DropDown_sp.SelectedValue.ToString());
                            }
                        }
                    }
                }
                else
                {
                    //一旦审批未通过,删除该公文当前流转步骤信息
                    BLL.GeneralMethods.GeneralDelDB("WorkFlowExecution", "where DID ='" + id + "' and step='" + dt.Rows[0]["WStep"].ToString() + "'");
                    if (instance.GetBookmarks().Count(p => p.BookmarkName == dt.Rows[0]["value"].ToString()) == 1)
                    {
                        instance.ResumeBookmark(dt.Rows[0]["value"].ToString(), this.DropDown_sp.SelectedValue.ToString());
                    }
                }

                Model.WorkFlowExecution workexe = new Model.WorkFlowExecution
                {
                    DID    = dt.Rows[0]["ID"].ToString(),
                    UID    = this.Session["admin"].ToString(),
                    step   = dt.Rows[0]["WStep"].ToString(),
                    Remark = this.txtSP.Value.Trim(),
                    Result = "1",
                };

                BLL.WorkFlowExecution.Add(workexe);
            }
            else
            {
                Model.WorkFlowExecution workexe = new Model.WorkFlowExecution
                {
                    DID    = dt.Rows[0]["ID"].ToString(),
                    UID    = this.Session["admin"].ToString(),
                    step   = dt.Rows[0]["WStep"].ToString(),
                    Remark = this.txtSP.Value.Trim(),
                    Result = "2",
                };

                BLL.WorkFlowExecution.Add(workexe);

                if (instance.GetBookmarks().Count(p => p.BookmarkName == dt.Rows[0]["value"].ToString()) == 1)
                {
                    instance.ResumeBookmark(dt.Rows[0]["value"].ToString(), this.DropDown_sp.SelectedValue.ToString());
                }
            }
            UserOperatingManager.InputUserOperating(this.Session["admin"].ToString(), "公文管理", "公文审核" + dt.Rows[0]["Name"].ToString() + "的信息成功");
            MessageBox.ShowAndRedirect(this, "审核公文成功!", "/document/DocumentList.aspx");

            instance.Unload();
        }
    }