static void _runtime_ProcessStatusChanged(object sender, ProcessStatusChangedEventArgs e)
        {
            if (e.NewStatus != ProcessStatus.Idled && e.NewStatus != ProcessStatus.Finalized)
            {
                return;
            }

            if (string.IsNullOrEmpty(e.SchemeCode))
            {
                return;
            }

            WorkflowActions.DeleteEmptyPreHistory(e.ProcessId);
            _runtime.PreExecuteFromCurrentActivity(e.ProcessId);

            //Inbox
            using (var session = Workflow.WorkflowInit.Provider.Store.OpenSession())
            {
                var inboxDocs = session.Query <WorkflowInbox>().Where(c => c.ProcessId == e.ProcessId).ToList();
                foreach (var d in inboxDocs)
                {
                    session.Delete(d);
                }
                session.SaveChanges();
            }

            if (e.NewStatus != ProcessStatus.Finalized)
            {
                var d = new Action <ProcessStatusChangedEventArgs>(PreExecuteAndFillInbox);
                d.BeginInvoke(e, FillInboxCallback, null);
            }

            //Change state name
            var nextState = WorkflowInit.Runtime.GetLocalizedStateName(e.ProcessId, e.ProcessInstance.CurrentState);

            using (var session = Workflow.WorkflowInit.Provider.Store.OpenSession())
            {
                var document = session.Load <Document>(e.ProcessId);
                if (document != null)
                {
                    document.StateName = nextState;
                    session.SaveChanges();
                }
            }
        }
예제 #2
0
        static void _runtime_ProcessStatusChanged(object sender, ProcessStatusChangedEventArgs e)
        {
            if (e.NewStatus != ProcessStatus.Idled && e.NewStatus != ProcessStatus.Finalized)
            {
                return;
            }

            if (string.IsNullOrEmpty(e.SchemeCode))
            {
                return;
            }

            WorkflowActions.DeleteEmptyPreHistory(e.ProcessId);
            _runtime.PreExecuteFromCurrentActivity(e.ProcessId);

            //Inbox
            using (var context = new DataModelDataContext())
            {
                context.DropWorkflowInbox(e.ProcessId);
                context.SubmitChanges();
            }

            if (e.NewStatus != ProcessStatus.Finalized)
            {
                var d = new Action <ProcessStatusChangedEventArgs>(PreExecuteAndFillInbox);
                d.BeginInvoke(e, FillInboxCallback, null);
            }

            //Change state name
            var nextState = WorkflowInit.Runtime.GetLocalizedStateName(e.ProcessId, e.ProcessInstance.CurrentState);

            using (var context = new DataModelDataContext())
            {
                var document = DocumentHelper.Get(e.ProcessId, context);
                if (document == null)
                {
                    return;
                }

                document.StateName = nextState;
                context.SubmitChanges();
            }
        }
예제 #3
0
        static void _runtime_ProcessStatusChanged(object sender, ProcessStatusChangedEventArgs e)
        {
            if (e.NewStatus != ProcessStatus.Idled && e.NewStatus != ProcessStatus.Finalized)
            {
                return;
            }

            if (string.IsNullOrEmpty(e.SchemeCode))
            {
                return;
            }

            WorkflowActions.DeleteEmptyPreHistory(e.ProcessId);
            _runtime.PreExecuteFromCurrentActivity(e.ProcessId);

            //Inbox
            var dbcoll = Provider.Store.GetCollection <WorkflowInbox>("WorkflowInbox");

            dbcoll.DeleteMany(c => c.ProcessId == e.ProcessId);

            if (e.NewStatus != ProcessStatus.Finalized)
            {
                var d = new Action <ProcessStatusChangedEventArgs>(PreExecuteAndFillInbox);
                d.BeginInvoke(e, FillInboxCallback, null);
            }

            //Change state name
            var docdbcoll = Provider.Store.GetCollection <Document>("Document");
            var document  = docdbcoll.Find(x => x.Id == e.ProcessId).FirstOrDefault();

            if (document != null)
            {
                var nextState = Runtime.GetLocalizedStateName(e.ProcessId, e.ProcessInstance.CurrentState);
                document.StateName = nextState;
                docdbcoll.ReplaceOne(x => x.Id == document.Id, document, new UpdateOptions {
                    IsUpsert = true
                });
            }
        }
예제 #4
0
        static void _runtime_ProcessStatusChanged(object sender, ProcessStatusChangedEventArgs e)
        {
            if (e.NewStatus != ProcessStatus.Idled && e.NewStatus != ProcessStatus.Finalized)
            {
                return;
            }

            if (string.IsNullOrEmpty(e.SchemeCode))
            {
                return;
            }

            WorkflowActions.DeleteEmptyPreHistory(e.ProcessId);
            _runtime.PreExecuteFromCurrentActivity(e.ProcessId);

            //Inbox
            var dbcoll = Provider.Store.GetCollection <WorkflowInbox>("WorkflowInbox");

            dbcoll.Remove(Query <WorkflowInbox> .Where(c => c.ProcessId == e.ProcessId));

            if (e.NewStatus != ProcessStatus.Finalized)
            {
                var d = new Action <ProcessStatusChangedEventArgs>(PreExecuteAndFillInbox);
                d.BeginInvoke(e, FillInboxCallback, null);
            }

            //Change state name
            var docdbcoll = Workflow.WorkflowInit.Provider.Store.GetCollection <Document>("Document");
            var document  = docdbcoll.FindOneById(e.ProcessId);

            if (document != null)
            {
                var nextState = WorkflowInit.Runtime.GetLocalizedStateName(e.ProcessId, e.ProcessInstance.CurrentState);
                document.StateName = nextState;
                docdbcoll.Save(document);
            }
        }