Example #1
0
        public static void Insert(F_INST_FLOW entity)
        {
            using (MainDataContext dbContext = new MainDataContext())
            {
                //dbContext.Database.Connection.Open();

                //var list = from a in dbContext.F_INST_FLOW select a.ID;

                //long total = list.LongCount();

                //if (total == 0)
                //{
                //    entity.ID = 1;
                //}
                //else
                //{
                //    entity.ID = dbContext.F_INST_FLOW.Max(a => a.ID) + 1;
                //    entity.FlowNo = dbContext.F_INST_FLOW.Where(t => t.FlowID == entity.FlowID).Max(a => a.FlowNo) + 1;
                //}


                dbContext.F_INST_FLOW.InsertOnSubmit(entity);

                dbContext.SubmitChanges();
            }
        }
Example #2
0
        /// <summary>
        /// 否决
        /// </summary>
        public void Reject()
        {
            F_INST_FLOW inst = DAL.WorkFlow.FlowInstance.Get(m_FlowInstanceId);

            inst.EndDate = DateTime.Now;

            inst.State = FlowInstanceState.Reject;

            DAL.WorkFlow.FlowInstance.Save(inst);

            //更新其他对象
            ApproveEventArgs e = new ApproveEventArgs();

            e.FlowId     = this.FlowDefine.ID;
            e.FlowName   = this.FlowDefine.Name;
            e.FlowInstId = this.ID;
            e.AppValue   = WorkItemAppValue.Reject;
            e.Url        = this.FlowDefine.Url;
            e.BeginDate  = this.m_BeginDate;
            e.IsInner    = this.FlowDefine.IsInner;
            e.FlowNo     = this.FlowNo;
            e.ApplyerId  = this.m_ApplerId;

            ApproveReject(this, e);//调用相关方法
        }
Example #3
0
        public bool DeleteFlowStance(int flowId, int flowNo)
        {
            try
            {
                F_INST_FLOW flowInst = DAL.WorkFlow.FlowInstance.Get(flowId, flowNo);

                if (flowInst == null)
                {
                    return(false);
                }

                if (flowInst.State == FlowInstanceState.Recall ||
                    flowInst.State == FlowInstanceState.InActive ||
                    flowInst.State == FlowInstanceState.Reject)
                {
                    DAL.WorkFlow.FlowInstance.Delete(flowInst.ID);
                }
                else
                {
                    return(false);;
                }
            }
            catch (Exception ex)
            {
                Log4Net.LogError("Workflow_Engine", string.Format("FlowId:{0},FlowId:{1},Message:{2}", flowId, flowNo, ex.ToString()));

                return(false);
            }

            return(true);
        }
Example #4
0
        /// <summary>
        /// 更新状态
        /// </summary>
        /// <param name="state"></param>
        private void UpdateState(string state)
        {
            F_INST_FLOW inst = DAL.WorkFlow.FlowInstance.Get(this.m_FlowInstanceId);

            inst.State = state;

            DAL.WorkFlow.FlowInstance.Save(inst);
        }
Example #5
0
        /// <summary>
        /// 更新摘要
        /// </summary>
        /// <param name="digest"></param>
        public void UpdateDigest(string digest)
        {
            //更新状态
            F_INST_FLOW inst = DAL.WorkFlow.FlowInstance.Get(m_FlowInstanceId);

            inst.Digest = digest;

            DAL.WorkFlow.FlowInstance.Save(inst);
        }
Example #6
0
        /// <summary>
        /// 激活
        /// </summary>
        /// <returns></returns>
        public void Active()
        {
            //更新状态
            F_INST_FLOW inst = DAL.WorkFlow.FlowInstance.Get(m_FlowInstanceId);

            //inst.BeginDate = DateTime.Now;
            inst.State = FlowInstanceState.Active;

            DAL.WorkFlow.FlowInstance.Save(inst);
        }
Example #7
0
        public override IList <int> GetApprover(int flowId, int flowNo)
        {
            List <int> listWorkerId = new List <int>();

            F_PARTICIPANT_RELATION relation = DAL.WorkFlow.Participant.GetMDRelation(this.ModelID);

            if (relation.Relation.ToUpper() == "APPLYER")
            {
                F_INST_FLOW flowInst = DAL.WorkFlow.FlowInstance.Get(flowId, flowNo);

                listWorkerId.Add(flowInst.ApplyerID);
            }

            return(listWorkerId);
        }
Example #8
0
        public FlowInstance(int id)
        {
            m_FlowInstanceId = id;

            F_INST_FLOW instFlow = DAL.WorkFlow.FlowInstance.Get(m_FlowInstanceId);

            m_FlowDefine = new FlowDefine(instFlow.FlowID);

            m_FlowNo = instFlow.FlowNo;

            m_Status = instFlow.State;

            m_FormDigest = instFlow.Digest;

            m_ApplerId = instFlow.ApplyerID;

            m_BeginDate = instFlow.BeginDate;
        }
Example #9
0
        public override IList <int> GetApprover(int flowId, int flowNo)
        {
            F_PARTICIPANT_LEVEL model = DAL.WorkFlow.Participant.GetMDLevel(this.ModelID);

            F_INST_FLOW flowInst = DAL.WorkFlow.FlowInstance.Get(flowId, flowNo);

            //得到申请人默认职位层级
            C_Worker_Level applyer = iworker.GetDefaultLevel(flowInst.ApplyerID);

            //计算目标层级
            int level = 0;

            if (model.IsAbsolute == "N")
            {
                level = model.Level + applyer.Level;
            }
            else
            {
                level = model.Level;
            }

            //得到对应层级签核人
            List <int> listWorkerId = new List <int>();

            if (applyer.Level >= level)
            {
                listWorkerId.Add(flowInst.ApplyerID);
            }
            else if (applyer.ID != applyer.ParentID)
            {
                List <int> listDepart = new List <int>();

                iorg.GetUnitList(listDepart, applyer.DepartID);

                int approver = GetAbsoluteLevelParentId(applyer.ParentID, listDepart, level);

                if (approver != -1)
                {
                    listWorkerId.Add(approver);
                }
            }

            return(listWorkerId);
        }
Example #10
0
        public FlowInstance(int flowId, int flowNo)
        {
            F_INST_FLOW instFlow = DAL.WorkFlow.FlowInstance.Get(flowId, flowNo);

            if (instFlow != null)
            {
                m_FlowInstanceId = instFlow.ID;

                m_FlowDefine = new FlowDefine(instFlow.FlowID);

                m_FlowNo = instFlow.FlowNo;

                m_Status = instFlow.State;

                m_FormDigest = instFlow.Digest;

                m_ApplerId = instFlow.ApplyerID;
            }
        }
Example #11
0
        public static bool Save(F_INST_FLOW entity)
        {
            using (MainDataContext dbContext = new MainDataContext())
            {
                var model = dbContext.F_INST_FLOW.FirstOrDefault(t => t.ID == entity.ID);

                model.ApplyerID = entity.ApplyerID;
                model.BeginDate = entity.BeginDate;
                model.EndDate   = entity.EndDate;
                model.FillerID  = entity.FillerID;
                model.FlowID    = entity.FlowID;
                model.FlowNo    = entity.FlowNo;
                model.State     = entity.State;
                model.Digest    = entity.Digest;

                dbContext.SubmitChanges();
            }

            return(true);
        }
Example #12
0
        /// <summary>
        /// 创建流程实例
        /// </summary>
        /// <param name="flow"></param>
        /// <returns></returns>
        public void Create(int flowId, int flowNo, int applyerId, string digest)
        {
            m_FlowDefine = new FlowDefine(flowId);

            F_INST_FLOW inst = new F_INST_FLOW();

            //IPrimaryKeyCreater prikey = ctx["PrimaryKeyCreater"] as IPrimaryKeyCreater;

            m_FlowInstanceId = PrimaryKeyCreater.getIntPrimaryKey("F_INST_FLOW");

            inst.ID        = m_FlowInstanceId;
            inst.ApplyerID = applyerId;
            inst.BeginDate = DateTime.Now;
            inst.EndDate   = null;
            inst.FlowID    = flowId;
            inst.State     = FlowInstanceState.InActive;
            inst.FlowNo    = flowNo;
            inst.Digest    = digest;

            DAL.WorkFlow.FlowInstance.Insert(inst);
        }
Example #13
0
        public static bool Exists(int flowId, int flowNo)
        {
            F_INST_FLOW instFlow = DAL.WorkFlow.FlowInstance.Get(flowId, flowNo);

            return(instFlow == null ? false : true);
        }