//如果审核不通过就执行这个函数
        public void NotPassStep(int id)
        {
            AuditProcess auditProcess = db.AuditProcesses.Find(id);
            // auditProcess.Result = 4;//直接返回结果就是不通过
            var item = (from p in db.AuditSteps where p.SId == auditProcess.SId select p).FirstOrDefault();

            if (item.NotApprovedToSId == -1)//如果不再需要执行下一步了,就直接返回审核失败
            {
                ReturnStatus(auditProcess.AId, 4);
            }
            else
            {
                int temp     = item.NotApprovedToSId;
                var laststep = (from p in db.AuditSteps where p.SId == temp select p).FirstOrDefault();//返回上一个节点

                AuditProcess lastauditProcess = new AuditProcess();

                lastauditProcess.AId          = auditProcess.AId;//还是这个AId
                lastauditProcess.SId          = laststep.SId;
                lastauditProcess.TId          = laststep.TId;
                lastauditProcess.BType        = auditProcess.BType;
                lastauditProcess.BNumber      = auditProcess.BNumber;
                lastauditProcess.TypeName     = auditProcess.TypeName;
                lastauditProcess.Info         = auditProcess.Info;
                lastauditProcess.CreateDate   = auditProcess.CreateDate;//还是记录auditProcess的申请时间;
                lastauditProcess.Result       = 0;
                lastauditProcess.Comment      = null;
                lastauditProcess.DeadlineDate = DateTime.Now.AddDays(item.Days); //记录一下该节点最晚的审核时间;
                lastauditProcess.AuditDate    = DateTime.Now;                    //AuditDate就记录为当前的时间;
                lastauditProcess.Approver     = laststep.Approver;

                db.AuditProcesses.Add(lastauditProcess);
                db.SaveChanges();
            }
        }
Esempio n. 2
0
        private void addCollectionChangeWorkUnit(AuditProcess auditProcess, ISessionImplementor session, string fromEntityName, RelationDescription relDesc, object value)
        {
            // relDesc.getToEntityName() doesn't always return the entity name of the value - in case
            // of subclasses, this will be root class, no the actual class. So it can't be used here.
            string toEntityName;
            object id;

            if (value is INHibernateProxy newValueAsProxy)
            {
                toEntityName = session.BestGuessEntityName(value);
                id           = newValueAsProxy.HibernateLazyInitializer.Identifier;
                // We've got to initialize the object from the proxy to later read its state.
                value = Toolz.GetTargetFromProxy(session, newValueAsProxy);
            }
            else
            {
                toEntityName = session.GuessEntityName(value);

                var idMapper = VerCfg.EntCfg[toEntityName].IdMapper;
                id = idMapper.MapToIdFromEntity(value);
            }

            var toPropertyNames = VerCfg.EntCfg.ToPropertyNames(fromEntityName, relDesc.FromPropertyName, toEntityName);
            var toPropertyName  = toPropertyNames.First();

            auditProcess.AddWorkUnit(new CollectionChangeWorkUnit(session, toEntityName, toPropertyName, VerCfg, id, value));
        }
        public ActionResult Submit(int id)
        {
            AuditApplication auditApplication = db.AuditApplications.Find(id);

            if (auditApplication == null)
            {
                return(HttpNotFound());
            }

            //标记该application的状态为等待审核
            auditApplication.State = 1;

            AuditTemplate template = db.AuditTemplates.Find(auditApplication.TId);
            //找到Template下的第一个Step节点
            AuditStep    step         = db.AuditSteps.Find(template.FirstStepSId);
            AuditProcess auditProcess = new AuditProcess();

            auditProcess.AId        = auditApplication.Id;
            auditProcess.SId        = step.SId;
            auditProcess.TId        = step.TId;
            auditProcess.CreateDate = DateTime.Now;
            auditProcess.Result     = 1;
            auditProcess.AuditDate  = DateTime.Now.AddDays(step.Days);//记录一下该节点最晚的审核时间;
            auditProcess.Approver   = step.Approver;
            db.AuditProcesses.Add(auditProcess);
            db.SaveChanges();

            return(RedirectToAction("Index"));
        }
        public ActionResult DeleteConfirmed(int id)
        {
            AuditProcess auditProcess = db.AuditProcesses.Find(id);

            db.AuditProcesses.Remove(auditProcess);
            //如果删除了一个process。如果是第一条或者最后一条,那么该员工应该是审核失效/过期;或者干脆不允许其删除

            //

            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
        public ActionResult Edit(int id, int?flag)
        {
            AuditProcess auditProcess = db.AuditProcesses.Find(id);

            auditProcess.AuditDate   = DateTime.Now;//实际的审核时间
            auditProcess.AuditPerson = this.UserName + "-" + this.Name;
            if (auditProcess == null)
            {
                return(HttpNotFound());
            }

            ////只要AuditProcess进入这一步。AuditApplication状态就改为在审核。
            //AuditApplication application = db.AuditApplications.Find(auditProcess.AId);//修改Application的状态
            //application.State = 1;
            ////调用一个函数;用来改变Staff的审核状态
            //ReturnStatus(application,1);

            ReturnStatus(auditProcess.AId, 1);

            /*超过审核时间,不再审核*/
            //if (auditProcess.AuditDate < DateTime.Now)
            if (auditProcess.AuditDate > auditProcess.DeadlineDate) //如果实际的审核时间大于截止日期
            {
                auditProcess.Result = 5;                            //过期,打回//
                //AuditApplication auditApplication = db.AuditApplications.Find(auditProcess.AId);//修改Application的状态
                //auditApplication.State = 5;//待审核 5(过期未处理)
                ReturnStatus(auditProcess.AId, 5);
            }
            else
            {
                if (flag == 1)
                {
                    // this.PassStep(id);
                    auditProcess.Result      = 3;//通过
                    auditProcess.Comment     = Request["Comment"];
                    auditProcess.AuditPerson = this.Name + "-" + this.UserName;
                    db.SaveChanges();
                    PassStep(id);
                }
                else if (flag == 0)               //审核不通过
                {
                    auditProcess.Result      = 4; //不通过
                    auditProcess.Comment     = Request["Comment"];
                    auditProcess.AuditPerson = this.Name + "-" + this.UserName;
                    db.SaveChanges();
                    // this.NotPassStep(id);
                    NotPassStep(id);
                }
            }
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Esempio n. 6
0
        private void generateBidirectionalCollectionChangeWorkUnits(AuditProcess auditProcess,
                                                                    IEntityPersister entityPersister,
                                                                    string entityName,
                                                                    IList <object> newState,
                                                                    IList <object> oldState,
                                                                    ISessionImplementor session)
        {
            // Checking if this is enabled in configuration ...
            if (!VerCfg.GlobalCfg.GenerateRevisionsForCollections)
            {
                return;
            }

            // Checks every property of the entity, if it is an "owned" to-one relation to another entity.
            // If the value of that property changed, and the relation is bi-directional, a new revision
            // for the related entity is generated.
            var propertyNames = entityPersister.PropertyNames;

            for (var i = 0; i < propertyNames.GetLength(0); i++)
            {
                var propertyName = propertyNames[i];
                var relDesc      = VerCfg.EntCfg.GetRelationDescription(entityName, propertyName);
                if (relDesc != null &&
                    relDesc.Bidirectional &&
                    relDesc.RelationType == RelationType.ToOne &&
                    relDesc.Insertable)
                {
                    // Checking for changes
                    var oldValue = oldState?[i];
                    var newValue = newState?[i];

                    if (!Toolz.EntitiesEqual(session, oldValue, newValue))
                    {
                        // We have to generate changes both in the old collection (size decreses) and new collection
                        // (size increases).
                        if (newValue != null)
                        {
                            addCollectionChangeWorkUnit(auditProcess, session, entityName, relDesc, newValue);
                        }
                        if (oldValue != null)
                        {
                            addCollectionChangeWorkUnit(auditProcess, session, entityName, relDesc, oldValue);
                        }
                    }
                }
            }
        }
        // POST: AuditProcess/Edit/5
        // 为了防止“过多发布”攻击,请启用要绑定到的特定属性,有关
        // 详细信息,请参阅 http://go.microsoft.com/fwlink/?LinkId=317598。
        //[HttpPost]
        //[ValidateAntiForgeryToken]
        //public ActionResult Edit(AuditProcess auditProcess)
        //{
        //    if (ModelState.IsValid)
        //    {


        //        db.Entry(auditProcess).State = EntityState.Modified;
        //        db.SaveChanges();
        //        return RedirectToAction("Index");
        //    }
        //    return View(auditProcess);
        //}

        // GET: AuditProcess/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            AuditProcess auditProcess = db.AuditProcesses.Find(id);

            if (auditProcess == null)
            {
                return(HttpNotFound());
            }
            string[] sArray = auditProcess.Info.Split(new char[] { ';' });
            ViewBag.sInfoArray             = sArray;
            auditProcess.ResultDescription = db.States.Find(auditProcess.Result).Description;
            return(View(auditProcess));
        }
Esempio n. 8
0
        //如果审核通过 执行这段代码
        public static void PassStep(int id, string userName)
        {
            UserModels       user         = (from u in sdb.Users where u.UserName == userName select u).FirstOrDefault();
            BonsaiiDbContext db           = new BonsaiiDbContext(user.ConnectionString);
            AuditProcess     auditProcess = db.AuditProcesses.Find(id);

            var item = (from p in db.AuditSteps where p.SId == auditProcess.SId select p).FirstOrDefault();

            //表明item是最后一个节点。返回一个结果:审核成功
            if (item.ApprovedToSId == -1)
            {
                //AuditApplication auditApplication = db.AuditApplications.Find(auditProcess.AId);
                //auditApplication.State = 3;//已审
                ReturnStatus(auditProcess.AId, 3, userName);
            }
            else//如果不是最后一个节点,那么寻找下一个节点,插入到AuditProcess表中
            {
                int temp     = item.ApprovedToSId;
                var nextstep = (from p in db.AuditSteps where p.SId == temp select p).FirstOrDefault();//下一个节点

                AuditProcess nextauditProcess = new AuditProcess();

                nextauditProcess.AId          = auditProcess.AId;//还是auditProcess的AId
                nextauditProcess.SId          = nextstep.SId;
                nextauditProcess.TId          = nextstep.TId;
                nextauditProcess.BType        = auditProcess.BType;
                nextauditProcess.BNumber      = auditProcess.BNumber;
                nextauditProcess.TypeName     = auditProcess.TypeName;
                nextauditProcess.Info         = auditProcess.Info;
                nextauditProcess.CreateDate   = auditProcess.CreateDate;         //还是记录auditProcess的申请时间;
                nextauditProcess.Result       = 0;                               //待审核
                nextauditProcess.Comment      = null;
                nextauditProcess.DeadlineDate = DateTime.Now.AddDays(item.Days); //记录一下该节点最晚的审核时间;
                nextauditProcess.AuditDate    = DateTime.Now;                    //实际的审核时间
                nextauditProcess.Approver     = nextstep.Approver;

                db.AuditProcesses.Add(nextauditProcess);
                db.SaveChanges();
                Audit(nextstep.Approver, user.CompanyId);
            }
            // db.SaveChanges();
        }
Esempio n. 9
0
        private void generateFakeBidirecationalRelationWorkUnits(AuditProcess auditProcess,
                                                                 IPersistentCollection newColl,
                                                                 object oldColl,
                                                                 string collectionEntityName,
                                                                 string referencingPropertyName,
                                                                 AbstractCollectionEvent evt,
                                                                 RelationDescription rd)
        {
            // First computing the relation changes
            var collectionChanges = VerCfg.EntCfg[collectionEntityName].PropertyMapper
                                    .MapCollectionChanges(evt.Session, referencingPropertyName, newColl, oldColl, evt.AffectedOwnerIdOrNull);

            // Getting the id mapper for the related entity, as the work units generated will corrspond to the related
            // entities.
            var relatedEntityName = rd.ToEntityName;
            var relatedIdMapper   = VerCfg.EntCfg[relatedEntityName].IdMapper;

            // For each collection change, generating the bidirectional work unit.
            foreach (var changeData in collectionChanges)
            {
                var relatedObj = changeData.GetChangedElement();
                var relatedId  = relatedIdMapper.MapToIdFromEntity(relatedObj);
                var revType    = (RevisionType)changeData.Data[VerCfg.AuditEntCfg.RevisionTypePropName];

                // This can be different from relatedEntityName, in case of inheritance (the real entity may be a subclass
                // of relatedEntityName).
                var realRelatedEntityName = evt.Session.BestGuessEntityName(relatedObj);

                // By default, the nested work unit is a collection change work unit.
                var nestedWorkUnit = new CollectionChangeWorkUnit(evt.Session, realRelatedEntityName, rd.MappedByPropertyName, VerCfg,
                                                                  relatedId, relatedObj);

                auditProcess.AddWorkUnit(new FakeBidirectionalRelationWorkUnit(evt.Session, realRelatedEntityName, VerCfg,
                                                                               relatedId, referencingPropertyName, evt.AffectedOwnerOrNull, rd, revType,
                                                                               changeData.GetChangedElementIndex(), nestedWorkUnit));
            }

            // We also have to generate a collection change work unit for the owning entity.
            auditProcess.AddWorkUnit(new CollectionChangeWorkUnit(evt.Session, collectionEntityName, referencingPropertyName, VerCfg,
                                                                  evt.AffectedOwnerIdOrNull, evt.AffectedOwnerOrNull));
        }
Esempio n. 10
0
        //如果审核不通过就执行这个函数
        public static void NotPassStep(int id, string userName)
        {
            UserModels       user         = (from u in sdb.Users where u.UserName == userName select u).FirstOrDefault();
            BonsaiiDbContext db           = new BonsaiiDbContext(user.ConnectionString);
            AuditProcess     auditProcess = db.AuditProcesses.Find(id);
            // auditProcess.Result = 4;//直接返回结果就是不通过
            var item = (from p in db.AuditSteps where p.SId == auditProcess.SId select p).FirstOrDefault();

            if (item.NotApprovedToSId == -1)//如果不再需要执行下一步了,就直接返回审核失败
            {
                ReturnStatus(auditProcess.AId, 4, userName);
            }
            else
            {
                int temp     = item.NotApprovedToSId;
                var laststep = (from p in db.AuditSteps where p.SId == temp select p).FirstOrDefault();//返回上一个节点

                AuditProcess lastauditProcess = new AuditProcess();

                lastauditProcess.AId          = auditProcess.AId;//还是这个AId
                lastauditProcess.SId          = laststep.SId;
                lastauditProcess.TId          = laststep.TId;
                lastauditProcess.BType        = auditProcess.BType;
                lastauditProcess.BNumber      = auditProcess.BNumber;
                lastauditProcess.TypeName     = auditProcess.TypeName;
                lastauditProcess.Info         = auditProcess.Info;
                lastauditProcess.CreateDate   = auditProcess.CreateDate;//还是记录auditProcess的申请时间;
                lastauditProcess.Result       = 0;
                lastauditProcess.Comment      = null;
                lastauditProcess.DeadlineDate = DateTime.Now.AddDays(item.Days); //记录一下该节点最晚的审核时间;
                lastauditProcess.AuditDate    = DateTime.Now;                    //AuditDate就记录为当前的时间;
                lastauditProcess.Approver     = laststep.Approver;

                db.AuditProcesses.Add(lastauditProcess);
                db.SaveChanges();
                Audit(laststep.Approver, user.CompanyId);
            }
        }
Esempio n. 11
0
        private void generateBidirectionalCollectionChangeWorkUnits(AuditProcess auditProcess,
                                                                    AbstractCollectionEvent evt,
                                                                    PersistentCollectionChangeWorkUnit workUnit,
                                                                    RelationDescription rd)
        {
            // Checking if this is enabled in configuration ...
            if (!VerCfg.GlobalCfg.GenerateRevisionsForCollections)
            {
                return;
            }

            // Checking if this is not a bidirectional relation - then, a revision needs also be generated for
            // the other side of the relation.
            // relDesc can be null if this is a collection of simple values (not a relation).
            if (rd != null && rd.Bidirectional)
            {
                var relatedEntityName = rd.ToEntityName;
                var relatedIdMapper   = VerCfg.EntCfg[relatedEntityName].IdMapper;

                foreach (var changeData in workUnit.CollectionChanges)
                {
                    var relatedObj = changeData.GetChangedElement();
                    var relatedId  = relatedIdMapper.MapToIdFromEntity(relatedObj);

                    var toPropertyNames = VerCfg.EntCfg.ToPropertyNames(evt.GetAffectedOwnerEntityName(), rd.FromPropertyName, relatedEntityName);
                    var toPropertyName  = toPropertyNames.First();

                    auditProcess.AddWorkUnit(new CollectionChangeWorkUnit(evt.Session,
                                                                          evt.Session.BestGuessEntityName(relatedObj),
                                                                          toPropertyName,
                                                                          VerCfg,
                                                                          relatedId,
                                                                          relatedObj));
                }
            }
        }
        /// <summary>
        /// 审批方法
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public ActionResult StepCheck(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            AuditProcess auditProcess = db.AuditProcesses.Find(id);

            ///根据逗号来分割字符串
            string[] sArray = auditProcess.Info.Split(new char[] { ';' });
            ///string转html有必要吗
            int       len     = sArray.Length;
            ArrayList newList = new ArrayList(sArray);

            newList.RemoveAt(len - 1);
            sArray                         = (string[])newList.ToArray(typeof(string));
            ViewBag.sInfoArray             = ConvertDataTableToHtml(sArray);
            auditProcess.ResultDescription = db.States.Find(auditProcess.Result).Description;
            /*之前的审核步骤*/
            var PList = (from p in db.AuditProcesses
                         where p.AId == auditProcess.AId && p.Id != auditProcess.Id
                         select p).ToList();

            ViewBag.PList = PList;

            //根据AuditApplication的Id寻找AuditProcess,然后寻找结果列表
            var resultList = (from p in db.AuditProcesses where p.AId == auditProcess.AId && p.Id != auditProcess.Id
                              orderby p.SId select p).ToList();

            ViewBag.resultlist = resultList;//存放结果列表
            foreach (var resultListItem in resultList)
            {
                resultListItem.ResultDescription = db.States.Find(resultListItem.Result).Description;
            }
            return(View(auditProcess));
        }
Esempio n. 13
0
        //private BonsaiiDbContext db = new BonsaiiDbContext();
        public byte AuditApplicationContract(Contract contract)//(string BillTypeNumber,int id)
        {
            /*访问单据性质,看是否是自动审核*/
            var item = (from p in db.BillProperties where p.Type == contract.BillTypeNumber select p).ToList().FirstOrDefault();

            if (item.IsAutoAudit == 1) //自动审核是1
            {                          //如果为0 代表不能自动审核 如果为1  代表可以自动审核
                return(3);             //代表自动审核
            }

            if (item.IsAutoAudit == 2)//手动审核是2
            {
                //手动审核,也写到db.AditApplications这个表中但是不走process?
                return(6);//手动审核
            }

            if (item.IsAutoAudit == 3)
            { //如果不自动审核,就要走人工审核流程。即,把信息写入db.AditApplications这个表中
                AuditApplication auditApplication = new AuditApplication();
                auditApplication.BType      = item.Type;
                auditApplication.TypeName   = item.TypeName;
                auditApplication.CreateDate = DateTime.Now;

                var template = (from p in db.AuditTemplates
                                where (
                                    (contract.BillTypeNumber == p.BType) && (DateTime.Now >= p.StartTime) && (DateTime.Now < p.ExpireTime)
                                    )
                                select p).ToList().FirstOrDefault();

                if (template != null)//如果没有用于审批的模板 那么这里没法运行
                {
                    var    tmpBillType    = (from p in db.BillProperties where p.Type == contract.BillTypeNumber select p.TypeFullName).ToList().Single();
                    Staff  staff          = db.Staffs.Where(c => c.StaffNumber.Equals(contract.SecondParty)).ToList().Single();
                    string departmentName = (from p in db.Departments where p.DepartmentId == contract.SecondParty select p.Name).SingleOrDefault();
                    auditApplication.BNumber     = contract.BillNumber;
                    auditApplication.TId         = template.Id;
                    auditApplication.Creator     = this.UserName;
                    auditApplication.CreatorName = this.Name;
                    auditApplication.State       = 0;//代表等待审核
                    auditApplication.Info        =
                        "单据名称:" + tmpBillType + ";" +
                        "工       号:" + contract.SecondParty + ";" +
                        "姓       名:" + contract.SecondParty + ";" +
                        "所在部门:" + departmentName + ";" +
                        "性       别:" + staff.Gender + ";" +
                        "职       位:" + staff.Position + ";" +
                        "用工性质:" + staff.WorkProperty + ";" +
                        "合同标题:" + contract.ContractObject + ";" +
                        "合同编号:" + contract.ContractNumber + ";" +
                        "签订时间:" + contract.SignDate + ";" +
                        "到期时间:" + contract.DueDate + ";" +
                        "合同金额:" + contract.Amount + ";" +
                        "备注:" + contract.Remark + ";" +

                        db.AuditApplications.Add(auditApplication);
                    db.SaveChanges();

                    AuditStep    step         = db.AuditSteps.Find(template.FirstStepSId);
                    AuditProcess auditProcess = new AuditProcess();
                    auditProcess.AId      = auditApplication.Id;
                    auditProcess.SId      = step.SId;
                    auditProcess.TId      = step.TId;
                    auditProcess.BType    = auditApplication.BType;
                    auditProcess.BNumber  = auditApplication.BNumber;
                    auditProcess.TypeName = auditApplication.TypeName;
                    auditProcess.Info     = auditApplication.Info;
                    //auditProcess.Info = auditApplication.Info + "提交人员:" + auditApplication.CreatorName + "-" + auditApplication.Creator + ";" +
                    //    "提交日期:" + auditApplication.CreateDate + ";";
                    auditProcess.AuditDate    = DateTime.Now;
                    auditProcess.CreateDate   = auditApplication.CreateDate;
                    auditProcess.Result       = 0;                               //待审
                    auditProcess.DeadlineDate = DateTime.Now.AddDays(step.Days); //记录一下该节点最晚的审核时间;
                    auditProcess.Approver     = step.Approver;
                    db.AuditProcesses.Add(auditProcess);

                    db.SaveChanges();
                    return(0);//待审
                }
                else
                {
                    return(7);//待审(未能进入审核流程)
                }
            }
            return(0);//待审
        }
Esempio n. 14
0
        public byte AuditApplicationStaffSkill(StaffSkill staffSkill)//(string BillTypeNumber,int id)
        {
            /*访问单据性质,看是否是自动审核*/
            var item = (from p in db.BillProperties where p.Type == staffSkill.BillTypeNumber select p).ToList().FirstOrDefault();

            if (item.IsAutoAudit == 1)
            {              //如果为0 代表不能自动审核 如果为1  代表可以自动审核
                return(3); //代表自动审核
            }

            if (item.IsAutoAudit == 2)
            {
                //手动审核,也写到db.AditApplications这个表中但是不走process?
                return(6);//手动审核
            }

            if (item.IsAutoAudit == 3)
            { //如果不自动审核,就要走人工审核流程。即,把信息写入db.AditApplications这个表中
                AuditApplication auditApplication = new AuditApplication();
                auditApplication.BType      = item.Type;
                auditApplication.TypeName   = item.TypeName;
                auditApplication.CreateDate = DateTime.Now;

                var template = (from p in db.AuditTemplates where (
                                    (staffSkill.BillTypeNumber == p.BType) && (DateTime.Now > p.StartTime) && (DateTime.Now < p.ExpireTime)
                                    )
                                select p).ToList().FirstOrDefault();
                if (template != null)
                {
                    // Staff staff = db.Staffs.Where(c => c.StaffNumber.Equals(staffSkill.StaffNumber)).ToList().Single();
                    Staff staff         = (from p in db.Staffs where p.StaffNumber == staffSkill.StaffNumber && p.AuditStatus == 3 && p.ArchiveTag == false select p).ToList().Single();
                    var   tmpDepartment = (from p in db.Departments where p.DepartmentId == staff.Department select p.Name).ToList().Single();
                    var   tmpBillType   = (from p in db.BillProperties where p.Type == staffSkill.BillTypeNumber select p.TypeFullName).ToList().Single();
                    auditApplication.Info =
                        "单据名称:" + tmpBillType + ";" +
                        "工       号:" + staffSkill.StaffNumber + ";" +
                        "员工名称:" + staff.Name + ";" +
                        "所在部门:" + tmpDepartment + ";" +
                        "性       别:" + staff.Gender + ";" +
                        "职       位:" + staff.Position + ";" +
                        "用工性质:" + staff.WorkProperty + ";";
                    //"单别:" + staffSkill.BillTypeNumber + ";" +
                    //"单号:" + staffSkill.BillNumber + ";" +
                    //"员工:" + staffSkill.StaffNumber + ";" +
                    //"技能编号:" + staffSkill.SkillNumber + ";" +
                    //"备注:" + staffSkill.SkillRemark + ";" +
                    //"单据类别编号:" + staffSkill.BillTypeNumber + ";" +
                    //"生效日期:" + staffSkill.ValidDate + ";" +
                    //"创建日期:" + staffSkill.RecordTime + ";" +
                    //"录入人员:" + staffSkill.RecordPerson + ";";

                    auditApplication.BNumber     = staffSkill.BillNumber;
                    auditApplication.TId         = template.Id;
                    auditApplication.Creator     = this.UserName;
                    auditApplication.CreatorName = this.Name;
                    auditApplication.State       = 0;//代表等待审核
                    db.AuditApplications.Add(auditApplication);
                    db.SaveChanges();

                    AuditStep step = db.AuditSteps.Find(template.FirstStepSId);
                    if (step == null)
                    {
                        return(7);
                    }
                    else
                    {
                        AuditProcess auditProcess = new AuditProcess();
                        auditProcess.AId      = auditApplication.Id;
                        auditProcess.SId      = step.SId;
                        auditProcess.TId      = step.TId;
                        auditProcess.BType    = auditApplication.BType;
                        auditProcess.BNumber  = auditApplication.BNumber;
                        auditProcess.TypeName = auditApplication.TypeName;
                        auditProcess.Info     = auditApplication.Info;
                        //auditProcess.Info = auditApplication.Info + "提交人员:" + auditApplication.CreatorName + "-" + auditApplication.Creator + ";" +
                        //   "提交日期:" + auditApplication.CreateDate + ";";
                        auditProcess.AuditDate    = DateTime.Now;
                        auditProcess.CreateDate   = auditApplication.CreateDate;
                        auditProcess.Result       = 0;                               //待审
                        auditProcess.DeadlineDate = DateTime.Now.AddDays(step.Days); //记录一下该节点最晚的审核时间;
                        auditProcess.Approver     = step.Approver;
                        db.AuditProcesses.Add(auditProcess);
                        db.SaveChanges();
                    }
                    db.SaveChanges();
                    return(0);//待审
                }
                else
                {
                    return(7);//待审(未能进入审核流程)
                }
            }
            return(0);//待审
        }
Esempio n. 15
0
        public async Task <IActionResult> Add(Input_APAdd model, [FromServices] ContextString dbContext)
        {
            QianMuResult _Result = new QianMuResult();

            Stream stream = HttpContext.Request.Body;

            byte[] buffer = new byte[HttpContext.Request.ContentLength.Value];
            stream.Read(buffer, 0, buffer.Length);
            string inputStr = Encoding.UTF8.GetString(buffer);

            model = (Input_APAdd)Newtonsoft.Json.JsonConvert.DeserializeObject(inputStr, model.GetType());



            if (String.IsNullOrEmpty(model.OperUser))
            {
                _Result.Code = "510";
                _Result.Msg  = "请输入审核人";
                _Result.Data = "";
                return(Json(_Result));
            }


            if (string.IsNullOrEmpty(model.MallCode))
            {
                //检测用户登录情况
                var uol = Method.GetLoginUserName(dbContext, this.HttpContext);
                if (string.IsNullOrEmpty(uol.UserName))
                {
                    _Result.Code = "401";
                    _Result.Msg  = "请登陆后再进行操作";
                    _Result.Data = "";
                    return(Json(_Result));
                }
                else
                {
                    model.MallCode = uol.MallCode;
                }
            }

            if (model.ModuleType == null)
            {
                _Result.Code = "510";
                _Result.Msg  = "请输入审核类型";
                _Result.Data = "";
                return(Json(_Result));
            }
            else
            {
                if (model.ModuleType < 1 || model.ModuleType > 2)
                {
                    _Result.Code = "510";
                    _Result.Msg  = "请输入有效的审核类型";
                    _Result.Data = "";
                    return(Json(_Result));
                }
            }
            var muser = await dbContext.Account.Where(i => i.Code == model.OperUser && i.Activity).FirstOrDefaultAsync();

            if (muser == null)
            {
                _Result.Code = "510";
                _Result.Msg  = "请输入有效的审核人";
                _Result.Data = "";
                return(Json(_Result));
            }

            int order = 1;


            var nowcount = await dbContext.AuditProcess.Where(i => i.MallCode == model.MallCode && i.ModuleType == model.ModuleType).CountAsync();

            if (nowcount >= 3)
            {
                _Result.Code = "510";
                _Result.Msg  = "最多只能有三个审核步骤";
                _Result.Data = "";
                return(Json(_Result));
            }

            if (nowcount <= 0)
            {
                order = 1;
            }
            else
            {
                //order = dbContext.AreaInfo.Max(m => m.Order) + 1;

                order = dbContext.AuditProcess.Where(i => i.MallCode == model.MallCode && i.ModuleType == model.ModuleType).Max(m => m.Order) + 1;
            }

            AuditProcess auditProcess = new AuditProcess
            {
                AddTime    = DateTime.Now,
                Code       = Guid.NewGuid().ToString(),
                UpdateTime = DateTime.Now,
                MallCode   = model.MallCode,
                ModuleType = (int)model.ModuleType,
                OperUser   = model.OperUser,
                Order      = order
            };


            dbContext.AuditProcess.Add(auditProcess);

            if (await dbContext.SaveChangesAsync() > 0)
            {
                _Result.Code = "200";
                _Result.Msg  = "添加成功";
                _Result.Data = "";
            }

            return(Json(_Result));
        }
Esempio n. 16
0
        public byte AuditApplication(StaffApplication staffApplication)//(string BillTypeNumber,int id)
        {
            /*访问单据性质,看是否是自动审核*/
            var item = (from p in db.BillProperties where p.Type == staffApplication.BillTypeNumber select p).ToList().FirstOrDefault();

            if (item.IsAutoAudit == 1) //自动审核是1
            {                          //如果为0 代表不能自动审核 如果为1  代表可以自动审核
                return(3);             //代表自动审核
            }

            if (item.IsAutoAudit == 2)//手动审核是2
            {
                //手动审核,也写到db.AditApplications这个表中但是不走process?
                return(6);//手动审核
            }

            if (item.IsAutoAudit == 3)
            { //如果不自动审核,就要走人工审核流程。即,把信息写入db.AditApplications这个表中
                AuditApplication auditApplication = new AuditApplication();
                auditApplication.BType      = item.Type;
                auditApplication.TypeName   = item.TypeName;
                auditApplication.CreateDate = DateTime.Now;

                var template = (from p in db.AuditTemplates
                                where (
                                    (staffApplication.BillTypeNumber == p.BType) && (DateTime.Now > p.StartTime) && (DateTime.Now < p.ExpireTime)
                                    )
                                select p).ToList().FirstOrDefault();

                if (template != null)//如果没有用于审批的模板 那么这里没法运行
                {
                    Staff    staff              = db.Staffs.Where(c => c.StaffNumber.Equals(staffApplication.StaffNumber)).ToList().Single();
                    string   departmentName     = (from p in db.Departments where p.DepartmentId == staff.Department select p.Name).SingleOrDefault();
                    DateTime entryDate_dateTime = (DateTime)staff.Entrydate;
                    DateTime leaveDate_dateTime = (DateTime)staffApplication.HopeLeaveDate;

                    auditApplication.BNumber = staffApplication.BillNumber;
                    auditApplication.TId     = template.Id;
                    auditApplication.Creator = this.UserName;
                    auditApplication.State   = 0;//代表等待审
                    auditApplication.Info    =
                        "单据名称:" + staffApplication.BillTypeName + ";" +
                        "工       号:" + staffApplication.StaffNumber + ";" +
                        "员工名称:" + staffApplication.StaffName + ";" +
                        "所在部门:" + departmentName + ";" +
                        "性       别:" + staff.Gender + ";" +
                        "职       位:" + staff.Position + ";" +
                        "用工性质:" + staff.WorkProperty + ";" +
                        "入职日期:" + entryDate_dateTime.Date.ToString("yyyy/MM/dd") + ";" +
                        "离职日期:" + leaveDate_dateTime.ToString("yyyy/MM/dd") + ";" +
                        "离职类型:" + staffApplication.LeaveType + ";" +
                        "离职原因:" + staffApplication.LeaveReason + ";" +
                        "备       注:" + staffApplication.Remark + ";" +
                        //"单别:" + staffApplication.BillTypeNumber + ";" +
                        //"单号:" + staffApplication.BillNumber + ";" +
                        //"员工工号:" + staffApplication.StaffNumber + ";" +
                        //"姓名:" + staffApplication.StaffName + ";" +
                        //"期望离职日期" + staffApplication.HopeLeaveDate + ";" +
                        //"离职类别" + staffApplication.LeaveType + ";" +
                        //"离职原因" + staffApplication.LeaveReason + ";" +
                        //"备注:" + staffApplication.Remark + ";" +
                        //"单据类别编号:" + staffApplication.BillTypeNumber + ";" +
                        //"创建日期:" + staffApplication.RecordTime + ";" +
                        //"录入人员:" + staffApplication.RecordPerson + ";";
                        db.AuditApplications.Add(auditApplication);
                    db.SaveChanges();

                    AuditStep step = db.AuditSteps.Find(template.FirstStepSId);
                    if (step == null)
                    {
                        return(7);
                    }
                    else
                    {
                        AuditProcess auditProcess = new AuditProcess();
                        auditProcess.AId      = auditApplication.Id;
                        auditProcess.SId      = step.SId;
                        auditProcess.TId      = step.TId;
                        auditProcess.BType    = auditApplication.BType;
                        auditProcess.BNumber  = auditApplication.BNumber;
                        auditProcess.TypeName = auditApplication.TypeName;
                        auditProcess.Info     = auditApplication.Info;
                        //auditProcess.Info = auditApplication.Info + "提交人员:" + auditApplication.CreatorName + "-" + auditApplication.Creator + ";" +
                        //    "提交日期:" + auditApplication.CreateDate + ";";
                        auditProcess.AuditDate    = DateTime.Now;
                        auditProcess.CreateDate   = auditApplication.CreateDate;
                        auditProcess.Result       = 0;                               //待审
                        auditProcess.DeadlineDate = DateTime.Now.AddDays(step.Days); //记录一下该节点最晚的审核时间;
                        auditProcess.Approver     = step.Approver;
                        db.AuditProcesses.Add(auditProcess);
                        db.SaveChanges();
                    }
                    db.SaveChanges();
                    return(0);//待审
                }
                else
                {
                    return(7);//待审(未能进入审核流程)
                }
            }
            return(0);//待审
        }
Esempio n. 17
0
        public byte AuditApplicationEvection(EvectionApplies evectionApplies)//(string BillTypeNumber,int id)
        {
            /*访问单据性质,看是否是自动审核*/
            var item = (from p in db.BillProperties where p.Type == evectionApplies.BillType select p).ToList().FirstOrDefault();

            if (item.IsAutoAudit == 1) //自动审核是1
            {                          //如果为0 代表不能自动审核 如果为1  代表可以自动审核
                return(3);             //代表自动审核
            }

            if (item.IsAutoAudit == 2)//手动审核是2
            {
                //手动审核,也写到db.AditApplications这个表中但是不走process?
                return(6);//手动审核
            }

            if (item.IsAutoAudit == 3)
            { //如果不自动审核,就要走人工审核流程。即,把信息写入db.AditApplications这个表中
                AuditApplication auditApplication = new AuditApplication();
                auditApplication.BType      = item.Type;
                auditApplication.TypeName   = item.TypeName;
                auditApplication.CreateDate = DateTime.Now;

                var template = (from p in db.AuditTemplates
                                where (
                                    (evectionApplies.BillType == p.BType) && (DateTime.Now > p.StartTime) && (DateTime.Now < p.ExpireTime)
                                    )
                                select p).ToList().FirstOrDefault();

                if (template != null)//如果没有用于审批的模板 那么这里没法运行
                {
                    Staff tmpStaff = db.Staffs.Where(p => p.StaffNumber.Equals(evectionApplies.StaffNumber)).ToList().First();
                    auditApplication.BNumber     = evectionApplies.BillNumber;
                    auditApplication.TId         = template.Id;
                    auditApplication.Creator     = this.UserName;
                    auditApplication.CreatorName = this.Name;
                    auditApplication.State       = 0;//代表等待审核
                    auditApplication.Info        =
                        "单据名称:" + db.BillProperties.Where(p => p.Type.Equals(evectionApplies.BillType)).ToList().First().TypeName + ";" +
                        "工      号:" + evectionApplies.StaffNumber + ";" +
                        "姓      名:" + tmpStaff.Name + ";" +
                        "所在部门:" + db.Departments.Where(p => p.DepartmentId.Equals(tmpStaff.Department)).ToList().First().Name + ";" +
                        "性       别:" + tmpStaff.Gender + ";" +
                        "职      位:" + tmpStaff.Position + ";" +
                        "用工性质:" + tmpStaff.WorkProperty + ";" +
                        "出差时间:" + evectionApplies.StartDateTime + ";" +
                        "结束时间:" + evectionApplies.EndDateTime + ";" +
                        "出差天数:" + evectionApplies.Days + ";" +
                        "出差事由:" + evectionApplies.Reason + ";" +
                        "出差地点:" + evectionApplies.Location + ";" +
                        "备注:" + evectionApplies.Remark + ";";
                    db.AuditApplications.Add(auditApplication);
                    db.SaveChanges();

                    AuditStep step = db.AuditSteps.Find(template.FirstStepSId);
                    if (step == null)
                    {
                        return(7);
                    }
                    else
                    {
                        AuditProcess auditProcess = new AuditProcess();
                        auditProcess.AId      = auditApplication.Id;
                        auditProcess.SId      = step.SId;
                        auditProcess.TId      = step.TId;
                        auditProcess.BType    = auditApplication.BType;
                        auditProcess.BNumber  = auditApplication.BNumber;
                        auditProcess.TypeName = auditApplication.TypeName;
                        auditProcess.Info     = auditApplication.Info + "提交人员:" + auditApplication.CreatorName + "-" + auditApplication.Creator + ";" +
                                                "提交日期:" + auditApplication.CreateDate + ";";
                        auditProcess.AuditDate    = DateTime.Now;
                        auditProcess.CreateDate   = auditApplication.CreateDate;
                        auditProcess.Result       = 0;                               //待审
                        auditProcess.DeadlineDate = DateTime.Now.AddDays(step.Days); //记录一下该节点最晚的审核时间;
                        auditProcess.Approver     = step.Approver;
                        db.AuditProcesses.Add(auditProcess);
                        db.SaveChanges();
                    }
                    db.SaveChanges();
                    return(0);//待审
                }
                else
                {
                    return(7);//待审(未能进入审核流程)
                }
            }
            return(0);//待审
        }
Esempio n. 18
0
        public byte AuditApplicationStaffSkill(TrainStart staffSkill)//(string BillTypeNumber,int id)
        {
            /*访问单据性质,看是否是自动审核*/
            var item = (from p in db.BillProperties where p.Type == staffSkill.BillTypeNumber select p).ToList().FirstOrDefault();

            if (item.IsAutoAudit == 1) //自动审核是1
            {                          //如果为0 代表不能自动审核 如果为1  代表可以自动审核
                return(3);             //代表自动审核
            }

            if (item.IsAutoAudit == 2)//手动审核是2
            {
                //手动审核,也写到db.AditApplications这个表中但是不走process?
                return(6);//手动审核
            }

            if (item.IsAutoAudit == 3)
            { //如果不自动审核,就要走人工审核流程。即,把信息写入db.AditApplications这个表中
                AuditApplication auditApplication = new AuditApplication();
                auditApplication.BType      = item.Type;
                auditApplication.TypeName   = item.TypeName;
                auditApplication.CreateDate = DateTime.Now;

                var template = (from p in db.AuditTemplates
                                where (
                                    (staffSkill.BillTypeNumber == p.BType) && (DateTime.Now > p.StartTime) && (DateTime.Now < p.ExpireTime)
                                    )
                                select p).ToList().FirstOrDefault();

                if (template != null)//如果没有用于审批的模板 那么这里没法运行
                {
                    auditApplication.BNumber     = staffSkill.BillNumber;
                    auditApplication.TId         = template.Id;
                    auditApplication.Creator     = this.UserName;
                    auditApplication.CreatorName = this.Name;
                    auditApplication.State       = 0;//代表等待审
                    auditApplication.Info        =
                        "单据名称:" + staffSkill.BillTypeNumber + ";" +
                        "培训类型:" + staffSkill.TrainType + ";" +
                        "培训主题:" + staffSkill.TrainTheme + ";" +
                        "培训讲师:" + staffSkill.TrainPerson + ";" +
                        "培训地址:" + staffSkill.TrainPlace + ";" +
                        "开始时间:" + staffSkill.StartDate + ";" +
                        "结束时间:" + staffSkill.EndDate + ";" +
                        "培训费用:" + staffSkill.TrainCost + "元" + ";" +
                        "联系电话:" + staffSkill.TellNumber + ";" +
                        "参加人员:" + staffSkill.JoinPerson + ";" +
                        "列席人员:" + staffSkill.TrainManage + ";" +
                        "培训内容:" + staffSkill.TrainContent + ";" +
                        db.AuditApplications.Add(auditApplication);
                    db.SaveChanges();

                    AuditStep step = db.AuditSteps.Find(template.FirstStepSId);
                    if (step == null)
                    {
                        return(7);
                    }
                    else
                    {
                        AuditProcess auditProcess = new AuditProcess();
                        auditProcess.AId      = auditApplication.Id;
                        auditProcess.SId      = step.SId;
                        auditProcess.TId      = step.TId;
                        auditProcess.BType    = auditApplication.BType;
                        auditProcess.BNumber  = auditApplication.BNumber;
                        auditProcess.TypeName = auditApplication.TypeName;
                        auditProcess.Info     = auditApplication.Info;
                        //auditProcess.Info = auditApplication.Info + "提交人员:" + auditApplication.CreatorName + "-" + auditApplication.Creator + ";" +
                        //    "提交日期:" + auditApplication.CreateDate + ";";
                        auditProcess.AuditDate    = DateTime.Now;
                        auditProcess.CreateDate   = auditApplication.CreateDate;
                        auditProcess.Result       = 0;                               //待审
                        auditProcess.DeadlineDate = DateTime.Now.AddDays(step.Days); //记录一下该节点最晚的审核时间;
                        auditProcess.Approver     = step.Approver;
                        db.AuditProcesses.Add(auditProcess);
                        db.SaveChanges();
                    }
                    db.SaveChanges();
                    return(0);//待审
                }
                else
                {
                    return(7);//待审(未能进入审核流程)
                }
            }
            return(0);//待审
        }