示例#1
0
        public static ProcessSession CreateNew(ProcessRunner r, TaskPersisterSession ps)
        {
            var s = new ProcessSession
            {
                _runner           = r,
                _persisterSession = ps
            };

            if (s._persisterSession == null)
            {
                throw new Exception("Task persister session not present");
            }
            return(s);
        }
示例#2
0
        protected void RunProcessTransaction(TaskPersistenceMode persMode, Action <ProcessSession> act)
        {
            if (ProcessSession.Current != null)
            {
                act(ProcessSession.Current);
                return;
            }

            IEnumerable <ProcessMessage> outgoing = null;

            InSystemTransaction(() =>
            {
                InDbTransaction(dbs =>
                {
                    using (var pess = TaskPersister.OpenSession(dbs))
                    {
                        pess.PersistenceMode = persMode;
                        Services.TaskPersisterSession.Current = pess;
                        using (var ps = ProcessSession.CreateNew(this, pess))
                        {
                            ProcessSession.Current = ps;
                            act(ps);
                            ps.PumpMessages();
                            outgoing = ps.GetOutgoingAsyncMessages();
                        }
                        pess.SaveChanges();
                        Services.TaskPersisterSession.Current = null;
                    }
                });
            });
            if (outgoing != null)
            {
                foreach (var pm in outgoing)
                {
                    SendLocalAsyncMessage(pm);
                }
            }
        }