コード例 #1
0
ファイル: Program.cs プロジェクト: caoyue/WorkflowDemo
        static void Main(string[] args)
        {
            var host = new WorkflowServiceHost(
                new Leaveflow.LeaveWorkflow(),
                new Uri("http://localhost:8080/LWS"));
            host.AddDefaultEndpoints();

            host.Description.Behaviors.Add(
                new ServiceMetadataBehavior() { HttpGetEnabled = true });

            host.Description.Behaviors.Add(
                new WorkflowIdleBehavior() {
                    TimeToPersist = new TimeSpan(0, 0, 0),
                    TimeToUnload = new TimeSpan(0, 0, 0)
                });

            host.AddServiceEndpoint(
                "IMetadataExchange",
                MetadataExchangeBindings.CreateMexHttpBinding(),
                "mex");

            var store = new SqlWorkflowInstanceStore(
                "server=(local)\\sqlexpress;database=wftest;uid=sa;pwd=123456;");

            host.DurableInstancingOptions.InstanceStore = store;
            host.UnknownMessageReceived += (o, e) => {
                Console.WriteLine("\n" + e.Message + "\n");
            };
            host.Open();
            Console.WriteLine("> Server is ready.");
            Console.Read();
        }
 public SaveWorkflowAsyncResult(InstancePersistenceContext context, InstancePersistenceCommand command, SqlWorkflowInstanceStore store, SqlWorkflowInstanceStoreLock storeLock, Transaction currentTransaction, TimeSpan timeout, AsyncCallback callback, object state) : base(context, command, store, storeLock, currentTransaction, timeout, callback, state)
 {
     if (((SaveWorkflowCommand) command).InstanceKeyMetadataChanges.Count > 0)
     {
         throw FxTrace.Exception.AsError(new InstancePersistenceCommandException(System.Activities.DurableInstancing.SR.InstanceKeyMetadataChangesNotSupported));
     }
 }
 public TryLoadRunnableWorkflowAsyncResult(InstancePersistenceContext context, InstancePersistenceCommand command, SqlWorkflowInstanceStore store, SqlWorkflowInstanceStoreLock storeLock, Transaction currentTransaction, TimeSpan timeout, AsyncCallback callback, object state) : base(context, command, store, storeLock, currentTransaction, timeout, callback, state)
 {
     if (base.Store.WorkflowHostType == Guid.Empty)
     {
         throw FxTrace.Exception.AsError(new InstancePersistenceCommandException(command.Name, System.Activities.DurableInstancing.SR.TryLoadRequiresWorkflowType, null));
     }
 }
コード例 #4
0
ファイル: Program.cs プロジェクト: cpm2710/cellbank
        static void Main(string[] args)
        {
            var connStr = @"Data Source=.\sqlexpress;Initial Catalog=WorkflowInstanceStore;Integrated Security=True;Pooling=False";
            SqlWorkflowInstanceStore instanceStore = new SqlWorkflowInstanceStore(connStr);

            Workflow1 w = new Workflow1();

            //instanceStore.
            //IDictionary<string, object> xx=WorkflowInvoker.Invoke(new Workflow1());
            //ICollection<string> keys=xx.Keys;

            WorkflowApplication a = new WorkflowApplication(w);
            a.InstanceStore = instanceStore;
            a.GetBookmarks();
            //a.ResumeBookmark("Final State", new object());

            a.Run();
            //a.ResumeBookmark(

            //a.Persist();
            //a.Unload();
            //Guid id = a.Id;
            //WorkflowApplication b = new WorkflowApplication(w);
            //b.InstanceStore = instanceStore;
            //b.Load(id);
            //WorkflowApplication a=new WorkflowApplication(
        }
コード例 #5
0
 public static void RunCheckCheck(Guid id, ReviewCheckCheck Form)
 {
     SqlWorkflowInstanceStore instanceStore = new SqlWorkflowInstanceStore(@"server=.\SQLEXPRESS;database=aspnetdb;uid=sa;pwd=123456");
     WorkflowApplication application2 = new WorkflowApplication(new DocumentPublish());
     application2.InstanceStore = instanceStore;
     application2.Completed = (workflowApplicationCompletedEventArgs) =>
     {
         Console.WriteLine("\nWorkflowApplication has Completed in the {0} state.", workflowApplicationCompletedEventArgs.CompletionState);
         instanceUnloaded.Set();
     };
     application2.PersistableIdle = (e) =>
     {
         instanceUnloaded.Set();
         return PersistableIdleAction.Unload;
     };
     application2.Unloaded = (workflowApplicationEventArgs) =>
     {
         Console.WriteLine("WorkflowApplication has Unloaded\n");
         instanceUnloaded.Set();
     };
     application2.Load(id);
     application2.ResumeBookmark("WaitCheckingChecking", Form);
     instanceUnloaded.WaitOne();
     Console.ReadLine();
 }
コード例 #6
0
ファイル: Program.cs プロジェクト: weibin268/Zhuang.BPM
        static void Main(string[] args)
        {
            WorkflowApplication wfApplication = new WorkflowApplication(new Activity1());

            SqlWorkflowInstanceStore instanceStore = new SqlWorkflowInstanceStore(ConfigurationManager.ConnectionStrings["ZhuangBPM"].ToString());
            wfApplication.InstanceStore = instanceStore;


            InstanceView view = instanceStore.Execute(instanceStore.CreateInstanceHandle(), new CreateWorkflowOwnerCommand(), TimeSpan.FromSeconds(30));
            instanceStore.DefaultInstanceOwner = view.InstanceOwner;
 


            wfApplication.PersistableIdle = (e) => {
                System.Console.WriteLine("persistableIdle:{0}", e.InstanceId); 

                return PersistableIdleAction.Unload;
            };

            wfApplication.Run();



            Console.ReadKey();
        }
コード例 #7
0
ファイル: WorkflowService.cs プロジェクト: NickAndersonX/xodb
        public WorkflowService(
            IUsersService users

          )
        {
            _users = users;
            T = NullLocalizer.Instance;
            Logger = NullLogger.Instance;
            SqlWorkflowInstanceStore store = new SqlWorkflowInstanceStore(_users.ApplicationConnectionString);
            _wfApp = new WorkflowApplication(new XODB.Workflow.AssignResponsibility());
            _wfApp.InstanceStore = store;
            
            XName wfHostTypeName = XName.Get("XODB", _users.ApplicationID.ToString());
            Dictionary<XName, object> wfScope = new Dictionary<XName, object> { { workflowHostTypePropertyName, wfHostTypeName } };
            _wfApp.AddInitialInstanceValues(wfScope);
            
            _wfApp.Extensions.Add(new ResponsibilityExtension());
            List<XName> variantProperties = new List<XName>() 
            { 
                ResponsibilityExtension.xNS.GetName("CompanyID"), 
                ResponsibilityExtension.xNS.GetName("ContactID") 
            };
            store.Promote("Responsibility", variantProperties, null);

            InstanceHandle handle = store.CreateInstanceHandle(null);
            var cmd = new CreateWorkflowOwnerCommand
            {
                InstanceOwnerMetadata =
                    {
                        {workflowHostTypePropertyName, new InstanceValue(wfHostTypeName)}
                    }
            };
            InstanceOwner owner = store.Execute(handle, cmd, TimeSpan.MaxValue).InstanceOwner;
            store.DefaultInstanceOwner = owner;
            
            handle.Free();
   
            _wfApp.PersistableIdle = delegate(WorkflowApplicationIdleEventArgs e)
            {
                return PersistableIdleAction.Persist;
            };

            _wfApp.Completed = delegate(WorkflowApplicationCompletedEventArgs e)
            {
                if (System.Diagnostics.Debugger.IsAttached)
                {
                    foreach (var item in e.Outputs)
                    {
                        System.Diagnostics.Debug.WriteLine("Variable:{0} has value: {1}", item.Key, item.Value);
                    }
                }
            };

            var trackingParticipant = new TrackingHelper.DebugTrackingParticipant
            {
                TrackingProfile = TrackingHelper.SimpleProfile
            };
            _wfApp.Extensions.Add(trackingParticipant);
        }
 public LoadRetryAsyncResult(SqlWorkflowInstanceStore store, System.Runtime.DurableInstancing.InstancePersistenceContext context, System.Runtime.DurableInstancing.InstancePersistenceCommand command, TimeSpan timeout, AsyncCallback callback, object state) : base(callback, state)
 {
     this.InstanceStore = store;
     this.InstancePersistenceContext = context;
     this.InstancePersistenceCommand = command;
     this.commandTimeout = new TimeoutHelper(timeout);
     this.InstanceStore.BeginTryCommandInternal(this.InstancePersistenceContext, this.InstancePersistenceCommand, this.commandTimeout.RemainingTime(), onTryCommandCallback, this);
 }
コード例 #9
0
 public LoadRetryAsyncResult(SqlWorkflowInstanceStore store, System.Runtime.DurableInstancing.InstancePersistenceContext context, System.Runtime.DurableInstancing.InstancePersistenceCommand command, TimeSpan timeout, AsyncCallback callback, object state) : base(callback, state)
 {
     this.InstanceStore = store;
     this.InstancePersistenceContext = context;
     this.InstancePersistenceCommand = command;
     this.commandTimeout             = new TimeoutHelper(timeout);
     this.InstanceStore.BeginTryCommandInternal(this.InstancePersistenceContext, this.InstancePersistenceCommand, this.commandTimeout.RemainingTime(), onTryCommandCallback, this);
 }
コード例 #10
0
    //end
    protected void btnEdit_ServerClick(object sender, EventArgs e)
    {
        if (((this.txtName.Value.Length == 0) || (this.uploadurl.Value.Length == 0)) || (this.selWorkFlow.SelectedValue.Length == 0))
        {
            MessageBox.Show(this, "请您填写完整的信息");
        }
        else
        {
            Model.SelectRecord selectRecord = new Model.SelectRecord("WorkFlow", "", "*", "where id='" + this.selWorkFlow.SelectedValue + "'");
            DataTable table = BLL.SelectRecord.SelectRecordData(selectRecord).Tables[0];
            string content = File.ReadAllText(System.Web.HttpContext.Current.Request.MapPath("../") + table.Rows[0]["URL"].ToString());

            //ziyunhx add 2013-8-5 workflow Persistence
            //old code
            //WorkFlowTracking.instance = engineManager.createInstance(content, null, null);
            //WorkFlowTracking.instance.Run();
            //new code
            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;
            instance.Run();
            //end

            Model.Document documents = new Model.Document
            {
                ID = id.Trim(),
                Name = this.txtName.Value.Trim(),
                URL = this.uploadurl.Value.Trim(),
                Remark = this.txtReMark.Value.Trim(),
                WID = this.selWorkFlow.SelectedValue,
                WStep = "0",
                Result = "0",
                UID = this.Session["admin"].ToString(),
                //ziyunhx add 2013-8-5 workflow Persistence
                //old code
                //FlowInstranceID = WorkFlowTracking.instance.Id,
                //new code
                FlowInstranceID = instance.Id,
                //end
            };

            if (BLL.Document.DocumentUpdate(documents) == 1)
            {
                UserOperatingManager.InputUserOperating(this.Session["admin"].ToString(), "工作流管理", "编辑工作流" + documents.Name + "的信息成功");
                MessageBox.ShowAndRedirect(this, "编辑公文成功!", "/document/DocumentList.aspx");
            }
            else
            {
                UserOperatingManager.InputUserOperating(this.Session["admin"].ToString(), "工作流管理", "编辑工作流" + documents.Name + "的信息失败");
                MessageBox.Show(this, "编辑工作流失败");
            }
        }
    }
 protected SqlWorkflowInstanceStoreAsyncResult(System.Runtime.DurableInstancing.InstancePersistenceContext context, System.Runtime.DurableInstancing.InstancePersistenceCommand command, SqlWorkflowInstanceStore store, SqlWorkflowInstanceStoreLock storeLock, Transaction currentTransaction, TimeSpan timeout, AsyncCallback callback, object state) : base(callback, state)
 {
     this.DependentTransaction = (currentTransaction != null) ? currentTransaction.DependentClone(DependentCloneOption.BlockCommitUntilComplete) : null;
     this.InstancePersistenceContext = context;
     this.InstancePersistenceCommand = command;
     this.Store = store;
     this.StoreLock = storeLock;
     this.TimeoutHelper = new System.Runtime.TimeoutHelper(timeout);
     base.OnCompleting = (Action<AsyncResult, Exception>) Delegate.Combine(base.OnCompleting, finallyCallback);
 }
コード例 #12
0
 public PersistenceTask(SqlWorkflowInstanceStore store, SqlWorkflowInstanceStoreLock storeLock, InstancePersistenceCommand instancePersistenceCommand, TimeSpan taskInterval, bool automaticallyResetTimer)
 {
     this.automaticallyResetTimer    = automaticallyResetTimer;
     this.commandCompletedCallback   = Fx.ThunkCallback(new AsyncCallback(this.CommandCompletedCallback));
     this.instancePersistenceCommand = instancePersistenceCommand;
     this.Store                = store;
     this.StoreLock            = storeLock;
     this.SurrogateLockOwnerId = this.StoreLock.SurrogateLockOwnerId;
     this.taskInterval         = taskInterval;
     this.thisLock             = new object();
 }
コード例 #13
0
 public PersistenceTask(SqlWorkflowInstanceStore store, SqlWorkflowInstanceStoreLock storeLock, InstancePersistenceCommand instancePersistenceCommand, TimeSpan taskInterval, bool automaticallyResetTimer)
 {
     this.automaticallyResetTimer = automaticallyResetTimer;
     this.commandCompletedCallback = Fx.ThunkCallback(new AsyncCallback(this.CommandCompletedCallback));
     this.instancePersistenceCommand = instancePersistenceCommand;
     this.Store = store;
     this.StoreLock = storeLock;
     this.SurrogateLockOwnerId = this.StoreLock.SurrogateLockOwnerId;
     this.taskInterval = taskInterval;
     this.thisLock = new object();
 }
コード例 #14
0
        /// <summary>
        /// Initializes a new instance of the <see cref="StateTrackerPersistence"/> class.
        /// </summary>
        /// <param name="tracker">
        /// The tracker. 
        /// </param>
        /// <param name="instanceStore">
        /// The instance Store. 
        /// </param>
        public StateTrackerPersistence(StateTracker tracker, SqlWorkflowInstanceStore instanceStore)
            : this(tracker)
        {
            Contract.Requires(instanceStore != null);
            if (instanceStore == null)
            {
                throw new ArgumentNullException("instanceStore");
            }

            Promote(instanceStore);
        }
コード例 #15
0
        public void AttachNullWorkflowApplicationShouldThrow()
        {
            using (var testdb = new SqlWorkflowInstanceStoreTest())
            {
                // Arrange
                var store = new SqlWorkflowInstanceStore(testdb.ConnectionString);

                // Act / Assert
                AssertHelper.Throws<ArgumentNullException>(
                    () => StateMachineStateTracker.Attach((WorkflowApplication)null, store));
            }
        }
 public SqlWorkflowInstanceStoreBehavior(string connectionString)
 {
     System.Activities.DurableInstancing.SqlWorkflowInstanceStore store = new System.Activities.DurableInstancing.SqlWorkflowInstanceStore(connectionString) {
         InstanceEncodingOption = System.Activities.DurableInstancing.InstanceEncodingOption.GZip,
         InstanceCompletionAction = System.Activities.DurableInstancing.InstanceCompletionAction.DeleteAll,
         InstanceLockedExceptionAction = System.Activities.DurableInstancing.InstanceLockedExceptionAction.NoRetry,
         HostLockRenewalPeriod = defaultHostRenewalPeriod,
         RunnableInstancesDetectionPeriod = defaultRunnableInstancesDetectionPeriod,
         EnqueueRunCommands = true
     };
     this.SqlWorkflowInstanceStore = store;
 }
 public SqlWorkflowInstanceStoreBehavior(string connectionString)
 {
     System.Activities.DurableInstancing.SqlWorkflowInstanceStore store = new System.Activities.DurableInstancing.SqlWorkflowInstanceStore(connectionString)
     {
         InstanceEncodingOption           = System.Activities.DurableInstancing.InstanceEncodingOption.GZip,
         InstanceCompletionAction         = System.Activities.DurableInstancing.InstanceCompletionAction.DeleteAll,
         InstanceLockedExceptionAction    = System.Activities.DurableInstancing.InstanceLockedExceptionAction.NoRetry,
         HostLockRenewalPeriod            = defaultHostRenewalPeriod,
         RunnableInstancesDetectionPeriod = defaultRunnableInstancesDetectionPeriod,
         EnqueueRunCommands = true
     };
     this.SqlWorkflowInstanceStore = store;
 }
 public DetectActivatableWorkflowsAsyncResult
     (
     InstancePersistenceContext context,
     InstancePersistenceCommand command,
     SqlWorkflowInstanceStore store,
     SqlWorkflowInstanceStoreLock storeLock,
     Transaction currentTransaction,
     TimeSpan timeout,
     AsyncCallback callback,
     object state
     ) :
     base(context, command, store, storeLock, currentTransaction, timeout, callback, state)
 {
 }
コード例 #19
0
        private static void RunInstance(Guid guid, string bookmark, Activity activity, object args)
        {
            SqlWorkflowInstanceStore instanceStore = new SqlWorkflowInstanceStore(ConnectString);
            WorkflowApplication application = new WorkflowApplication(activity);
            application.InstanceStore = instanceStore;

            application.PersistableIdle = (e) =>
            {
                return PersistableIdleAction.Unload;
            };

            application.Load(guid);
            application.ResumeBookmark(bookmark, args);
        }
 protected SqlWorkflowInstanceStoreAsyncResult
     (
     InstancePersistenceContext context,
     InstancePersistenceCommand command,
     SqlWorkflowInstanceStore store,
     SqlWorkflowInstanceStoreLock storeLock,
     Transaction currentTransaction,
     TimeSpan timeout,
     AsyncCallback callback,
     object state
     ) 
     : this(context, command, store, storeLock, currentTransaction, timeout, store.MaxConnectionRetries, callback, state)
 {
 }
コード例 #21
0
 protected SqlWorkflowInstanceStoreAsyncResult
 (
     InstancePersistenceContext context,
     InstancePersistenceCommand command,
     SqlWorkflowInstanceStore store,
     SqlWorkflowInstanceStoreLock storeLock,
     Transaction currentTransaction,
     TimeSpan timeout,
     AsyncCallback callback,
     object state
 )
     : this(context, command, store, storeLock, currentTransaction, timeout, store.MaxConnectionRetries, callback, state)
 {
 }
コード例 #22
0
 public ExtendLockAsyncResult
     (
     InstancePersistenceContext context,
     InstancePersistenceCommand command,
     SqlWorkflowInstanceStore store,
     SqlWorkflowInstanceStoreLock storeLock,
     Transaction currentTransaction,
     TimeSpan timeout, 
     AsyncCallback callback, 
     object state
     ) :
     base(context, command, store, storeLock, currentTransaction, timeout, int.MaxValue, callback, state)
 {
 }
コード例 #23
0
 public LoadWorkflowByKeyAsyncResult
 (
     InstancePersistenceContext context,
     InstancePersistenceCommand command,
     SqlWorkflowInstanceStore store,
     SqlWorkflowInstanceStoreLock storeLock,
     Transaction currentTransaction,
     TimeSpan timeout,
     AsyncCallback callback,
     object state
 ) :
     base(context, command, store, storeLock, currentTransaction, timeout, callback, state)
 {
 }
コード例 #24
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;
    }
 public TestDatabaseVersionAndRunAsyncResult(
     InstancePersistenceContext context,
     InstancePersistenceCommand command,
     SqlWorkflowInstanceStore store,
     SqlWorkflowInstanceStoreLock storeLock,
     Transaction currentTransaction,
     TimeSpan timeout,
     Version targetVersion,
     AsyncCallback callback,
     object state) :
     base(context, command, store, storeLock, currentTransaction, timeout, callback, state)
 {
     this.currentTransaction = currentTransaction;
     this.targetVersion      = targetVersion;
 }
コード例 #26
0
 public TestDatabaseVersionAndRunAsyncResult(
     InstancePersistenceContext context,
     InstancePersistenceCommand command,
     SqlWorkflowInstanceStore store,
     SqlWorkflowInstanceStoreLock storeLock,
     Transaction currentTransaction,
     TimeSpan timeout,
     Version targetVersion,
     AsyncCallback callback,
     object state) :
     base(context, command, store, storeLock, currentTransaction, timeout, callback, state)
 {
     this.currentTransaction = currentTransaction;
     this.targetVersion = targetVersion;
 }
コード例 #27
0
        private static Guid CreateAndRun(IDictionary<string, object> data, Activity activity)
        {
            SqlWorkflowInstanceStore instanceStore = new SqlWorkflowInstanceStore(ConnectString);
            WorkflowApplication application = new WorkflowApplication(activity, data);
            application.InstanceStore = instanceStore;

            application.PersistableIdle = (e) =>
            {
                return PersistableIdleAction.Unload;
            };

            application.Persist();
            Guid id = application.Id;

            application.Run();
            return id;
        }
コード例 #28
0
 public LoadWorkflowAsyncResult
 (
     InstancePersistenceContext context,
     InstancePersistenceCommand command,
     SqlWorkflowInstanceStore store,
     SqlWorkflowInstanceStoreLock storeLock,
     Transaction currentTransaction,
     TimeSpan timeout,
     AsyncCallback callback,
     object state
 ) :
     base(context, command, store, storeLock, currentTransaction, timeout, callback, state)
 {
     this.associatedInstanceKeys = new Dictionary <Guid, IDictionary <XName, InstanceValue> >();
     this.completedInstanceKeys  = new Dictionary <Guid, IDictionary <XName, InstanceValue> >();
     this.objectSerializer       = ObjectSerializerFactory.GetDefaultObjectSerializer();
 }
コード例 #29
0
 public LoadWorkflowAsyncResult
     (
     InstancePersistenceContext context, 
     InstancePersistenceCommand command, 
     SqlWorkflowInstanceStore store,
     SqlWorkflowInstanceStoreLock storeLock,
     Transaction currentTransaction,
     TimeSpan timeout, 
     AsyncCallback callback, 
     object state
     ) :
     base(context, command, store, storeLock, currentTransaction, timeout, callback, state)
 {
     this.associatedInstanceKeys = new Dictionary<Guid, IDictionary<XName, InstanceValue>>();
     this.completedInstanceKeys = new Dictionary<Guid, IDictionary<XName, InstanceValue>>();
     this.objectSerializer = ObjectSerializerFactory.GetDefaultObjectSerializer();
 }
コード例 #30
0
        public void AttachShouldAttachToApplication()
        {
            var activity = new StateMachineExample();
            Debug.Assert(TestInstanceStore != null, "TestInstanceStore != null");
            var sqlStore = new SqlWorkflowInstanceStore(TestInstanceStore.ConnectionString);

            // Setup the host
            var host = CreateHost(activity, sqlStore);

            // Setup the tracker
            Debug.Assert(host != null, "host != null");

            var tracker = StateTracker.Attach(host.TestWorkflowApplication, sqlStore);

            try
            {
                // Using Microsoft.Activities.Extensions run the workflow until a bookmark named "T1"
                var result = host.TestWorkflowApplication.RunEpisode("T1", TimeSpan.FromSeconds(60));

                Assert.IsInstanceOfType(result, typeof(WorkflowIdleEpisodeResult));
                Assert.IsTrue(host.WaitForUnloadedEvent(Constants.Timeout), "Host did not unload");

                Debug.Assert(result != null, "result != null");
                var instance = StateTracker.LoadInstance(result.InstanceId, TestInstanceStore.ConnectionString);

                Assert.IsNotNull(instance, "Failed to load instance");
                Assert.IsNotNull(tracker);
                Assert.AreEqual(
                    tracker.CurrentState,
                    instance.CurrentState,
                    "State read from database does not match current state from tracker");
            }
            finally
            {
                if (tracker != null)
                {
                    tracker.Trace();
                }

                if (host.Tracking != null)
                {
                    host.Tracking.Trace();
                }
            }
        }
 public TryLoadRunnableWorkflowAsyncResult
 (
     InstancePersistenceContext context,
     InstancePersistenceCommand command,
     SqlWorkflowInstanceStore store,
     SqlWorkflowInstanceStoreLock storeLock,
     Transaction currentTransaction,
     TimeSpan timeout,
     AsyncCallback callback,
     object state
 ) :
     base(context, command, store, storeLock, currentTransaction, timeout, callback, state)
 {
     if (base.Store.WorkflowHostType == Guid.Empty)
     {
         throw FxTrace.Exception.AsError(new InstancePersistenceCommandException(command.Name, SR.TryLoadRequiresWorkflowType, null));
     }
 }
コード例 #32
0
 public SaveWorkflowAsyncResult
 (
     InstancePersistenceContext context,
     InstancePersistenceCommand command,
     SqlWorkflowInstanceStore store,
     SqlWorkflowInstanceStoreLock storeLock,
     Transaction currentTransaction,
     TimeSpan timeout,
     AsyncCallback callback,
     object state
 ) :
     base(context, command, store, storeLock, currentTransaction, timeout, callback, state)
 {
     if (((SaveWorkflowCommand)command).InstanceKeyMetadataChanges.Count > 0)
     {
         throw FxTrace.Exception.AsError(new InstancePersistenceCommandException(SR.InstanceKeyMetadataChangesNotSupported));
     }
 }
コード例 #33
0
ファイル: Program.cs プロジェクト: object/CloudWorkflows
        static InstanceStore CreateInstanceStore()
        {
            string connectionString = ConfigurationManager.ConnectionStrings["InstanceStore"].ConnectionString;
            var instanceStore = new SqlWorkflowInstanceStore(connectionString);
            var instanceHandle = instanceStore.CreateInstanceHandle();
            var ownerCommand = new CreateWorkflowOwnerCommand();
            XNamespace hostNamespace = XNamespace.Get("urn:schemas-microsoft-com:System.Activities/4.0/properties");
            XName hostKey = hostNamespace.GetName("WorkflowHostType");
            var hostValue = new InstanceValue(XNamespace.Get("http://tempuri.org").GetName("SampleInstance"));
            ownerCommand.InstanceOwnerMetadata.Add(hostKey, hostValue);
            instanceStore.DefaultInstanceOwner = instanceStore.Execute(
                               instanceHandle,
                               ownerCommand,
                               TimeSpan.FromSeconds(30)).InstanceOwner;
            instanceHandle.Free();

            return instanceStore;
        }
コード例 #34
0
        public static Guid CreateAndRun(requestinfo requsetForm)
        {
            //工作流服务实例的状态信息持久保存到数据库中
            //SqlWorkflowInstanceStore instanceStore = new SqlWorkflowInstanceStore("server=.;database=aspnetdb;uid=sa;pwd=0000");
            SqlWorkflowInstanceStore instanceStore = new SqlWorkflowInstanceStore(@"Data Source=.\SQLEXPRESS;Initial Catalog=aspnetdb;Integrated Security=True");//在宿主程序中首先我们创建SqlWorkflowInstanceStore的实例
            InstanceView view = instanceStore.Execute(instanceStore.CreateInstanceHandle(), new CreateWorkflowOwnerCommand(), TimeSpan.FromSeconds(30));

            instanceStore.DefaultInstanceOwner = view.InstanceOwner;//对SqlWorkflowInstanceStore实例的各种配置

            IDictionary<string, object> input = new Dictionary<string, object>
            {
                { "Request" , requsetForm }
            };

            WorkflowApplication application = new WorkflowApplication(new DocumentPublish(), input);

            application.InstanceStore = instanceStore;//并将application的InstanceStore属性设置为该实例来指定使用的持久化存储
            application.PersistableIdle = (e) =>//获取工作流实例处于空闲状态并且可被保留时调用
            {
                instanceUnloaded.Set();
                return PersistableIdleAction.Unload;//保持并且卸载工作流
            };
            application.Unloaded = (e) =>//获取或设置卸载当前工作流时调用
            {
                instanceUnloaded.Set();//将事件设置为主终止状态允许其他的线程继续。
            };
            application.OnUnhandledException = (ex) =>//异常
            {
                Console.Write("Exception");
                return UnhandledExceptionAction.Terminate;
            };

            Guid id = application.Id;
            //application.Persist();
            application.Run();
            instanceUnloaded.WaitOne();//阻止当前线程,直到收到信号
            return id;
        }
コード例 #35
0
 // ExtendLockAsyncResult and RecoverInstanceLocksAsyncResult directly call this ctor
 protected SqlWorkflowInstanceStoreAsyncResult
 (
     InstancePersistenceContext context,
     InstancePersistenceCommand command,
     SqlWorkflowInstanceStore store,
     SqlWorkflowInstanceStoreLock storeLock,
     Transaction currentTransaction,
     TimeSpan timeout,
     int maximumRetries,
     AsyncCallback callback,
     object state
 ) :
     base(callback, state)
 {
     this.DependentTransaction       = (currentTransaction != null) ? currentTransaction.DependentClone(DependentCloneOption.BlockCommitUntilComplete) : null;
     this.InstancePersistenceContext = context;
     this.InstancePersistenceCommand = command;
     this.Store          = store;
     this.StoreLock      = storeLock;
     this.TimeoutHelper  = new TimeoutHelper(timeout);
     this.OnCompleting  += SqlWorkflowInstanceStoreAsyncResult.finallyCallback;
     this.maximumRetries = maximumRetries;
 }
 // ExtendLockAsyncResult and RecoverInstanceLocksAsyncResult directly call this ctor
 protected SqlWorkflowInstanceStoreAsyncResult
     (
     InstancePersistenceContext context,
     InstancePersistenceCommand command,
     SqlWorkflowInstanceStore store,
     SqlWorkflowInstanceStoreLock storeLock,
     Transaction currentTransaction,
     TimeSpan timeout,
     int maximumRetries,
     AsyncCallback callback,
     object state
     ) :
     base(callback, state)
 {
     this.DependentTransaction = (currentTransaction != null) ? currentTransaction.DependentClone(DependentCloneOption.BlockCommitUntilComplete) : null;
     this.InstancePersistenceContext = context;
     this.InstancePersistenceCommand = command;
     this.Store = store;
     this.StoreLock = storeLock;
     this.TimeoutHelper = new TimeoutHelper(timeout);
     this.OnCompleting += SqlWorkflowInstanceStoreAsyncResult.finallyCallback;
     this.maximumRetries = maximumRetries;
 }
コード例 #37
0
        /// <summary>
        /// 创建并启动一个工作流,在申请时候触发
        /// </summary>
        /// <param name="meeting">申请时所填表单的数据</param>
        /// <returns>返回一个Guid</returns>
        public static Guid CreateAndRun(Model.Meeting meeting, Dictionary<int, int> d_EquipmentCount,Dictionary<string,string> MeetingUserNameAndEmail,Model.MeetingRoom MeetingRoomIDAndName)
        {
            SqlWorkflowInstanceStore instanceStore = new SqlWorkflowInstanceStore(connectionString);
            InstanceView view = instanceStore.Execute(instanceStore.CreateInstanceHandle(), new CreateWorkflowOwnerCommand(),TimeSpan.FromDays(30));

            instanceStore.DefaultInstanceOwner = view.InstanceOwner;

            IDictionary<string, object> input = new Dictionary<string, object>();
            input.Add("Request",meeting);
            input.Add("EquipmentCount",d_EquipmentCount);
            input.Add("MeetingUserEmailFrom", MeetingUserNameAndEmail);
            input.Add("MeetingRoomIDAndName", MeetingRoomIDAndName);
            WorkflowApplication application = new WorkflowApplication(new MeetingApply(),input);

            application.InstanceStore = instanceStore;
            application.PersistableIdle = (e) =>
            {
                instanceUnloaded.Set();
                return PersistableIdleAction.Unload;
            };

            application.Unloaded = (e) =>
            {
                instanceUnloaded.Set();
            };

            application.OnUnhandledException = (ex) =>
            {
                return UnhandledExceptionAction.Terminate;
            };

            Guid id = application.Id;
            application.Persist();
            application.Run();
            instanceUnloaded.WaitOne();
            return id;
        }
コード例 #38
0
 public static void RunArrangeDrawOutFrom(ArrangeDrawOutFrom form)
 {
     SqlWorkflowInstanceStore instanceStore = new SqlWorkflowInstanceStore(@"server=.\SQLEXPRESS;database=aspnetdb;uid=sa;pwd=123456");
     WorkflowApplication application1 = new WorkflowApplication(new UseCarApply());
     application1.InstanceStore = instanceStore;
     application1.Completed = (workflowApplicationCompletedEventArgs) =>
     {
         Console.WriteLine("\nWorkflowApplication has Completed in the {0} state.", workflowApplicationCompletedEventArgs.CompletionState);
     };
     application1.PersistableIdle = (e) =>
     {
         instanceUnloaded.Set();
         return PersistableIdleAction.Unload;
     };
     application1.Unloaded = (workflowApplicationEventArgs) =>
     {
         Console.WriteLine("WorkflowApplication has Unloaded\n");
         instanceUnloaded.Set();
     };
     application1.Load(form.WFID);
     application1.ResumeBookmark("WaitArrangeDrawOut", form);
     instanceUnloaded.WaitOne();
     Console.ReadLine();
 }
コード例 #39
0
ファイル: LockRecoveryTask.cs プロジェクト: dox0/DotNet471RS3
 public LockRecoveryTask(SqlWorkflowInstanceStore store, SqlWorkflowInstanceStoreLock storeLock, TimeSpan taskInterval, TimeSpan taskTimeout)
     : base(store, storeLock, new RecoverInstanceLocksCommand(), taskInterval, taskTimeout, true)
 {
 }
 protected SqlWorkflowInstanceStoreAsyncResult(System.Runtime.DurableInstancing.InstancePersistenceContext context, System.Runtime.DurableInstancing.InstancePersistenceCommand command, SqlWorkflowInstanceStore store, SqlWorkflowInstanceStoreLock storeLock, Transaction currentTransaction, TimeSpan timeout, AsyncCallback callback, object state) : base(callback, state)
 {
     this.DependentTransaction       = (currentTransaction != null) ? currentTransaction.DependentClone(DependentCloneOption.BlockCommitUntilComplete) : null;
     this.InstancePersistenceContext = context;
     this.InstancePersistenceCommand = command;
     this.Store         = store;
     this.StoreLock     = storeLock;
     this.TimeoutHelper = new System.Runtime.TimeoutHelper(timeout);
     base.OnCompleting  = (Action <AsyncResult, Exception>)Delegate.Combine(base.OnCompleting, finallyCallback);
 }
コード例 #41
0
 public SqlWorkflowInstanceStoreLock(SqlWorkflowInstanceStore sqlWorkflowInstanceStore)
 {
     this.sqlWorkflowInstanceStore = sqlWorkflowInstanceStore;
     this.thisLock             = new object();
     this.SurrogateLockOwnerId = -1;
 }
コード例 #42
0
        private void WorkflowHostForm_Load(object sender, EventArgs e)
        {
            // Initialize the store and configure it so that it can be used for
            // multiple WorkflowApplication instances.
            store = new SqlWorkflowInstanceStore(connectionString);
            WorkflowApplication.CreateDefaultInstanceOwner(store, null, WorkflowIdentityFilter.Any);

            // Set default ComboBox selections.
            NumberRange.SelectedIndex = 0;
            WorkflowType.SelectedIndex = 0;

            ListPersistedWorkflows();
        }
コード例 #43
0
ファイル: LockRenewalTask.cs プロジェクト: dox0/DotNet471RS3
 public LockRenewalTask(SqlWorkflowInstanceStore store, SqlWorkflowInstanceStoreLock storeLock, TimeSpan taskInterval, TimeSpan taskTimeout)
     : base(store, storeLock, new ExtendLockCommand(), taskInterval, taskTimeout, true)
 {
 }
 public DetectActivatableWorkflowsTask(SqlWorkflowInstanceStore store, SqlWorkflowInstanceStoreLock storeLock, TimeSpan taskInterval) : base(store, storeLock, new DetectActivatableWorkflowsCommand(), taskInterval, false)
 {
 }
コード例 #45
0
 public InstanceLockTracking(SqlWorkflowInstanceStore store)
 {
     this.InstanceId = Guid.Empty;
     this.store = store;
     this.synchLock = new object();
 }
コード例 #46
0
 public DetectRunnableInstancesTask(SqlWorkflowInstanceStore store, SqlWorkflowInstanceStoreLock storeLock, TimeSpan taskInterval)
     : base(store, storeLock, new DetectRunnableInstancesCommand(), taskInterval, SqlWorkflowInstanceStoreConstants.DefaultTaskTimeout, false)
 {
 }