Пример #1
0
        public bool SaveWorkFlowLog(D_Report_Model model, D_WorkFlowLog_Model logModel)
        {
            NHibernate.ITransaction tran = NhSession.BeginTransaction();
            try
            {
                logModel.ReportGuid = model;

                NhSession.SaveOrUpdate(model.ReportD2);
                NhSession.SaveOrUpdate(model);
                if (model.ReportD8DataModels.Count > 0)
                {
                    foreach (var item in model.ReportD8DataModels)
                    {
                        NhSession.SaveOrUpdate(item);
                    }
                }
                if (model.WorkFlow_Models.Count > 0)
                {
                    foreach (var item in model.WorkFlow_Models)
                    {
                        NhSession.SaveOrUpdate(item);
                    }
                }
                if (model.WorkFlowLog_Models.Count > 0)
                {
                    foreach (var item in model.WorkFlowLog_Models)
                    {
                        NhSession.SaveOrUpdate(item);
                    }
                }

                NhSession.SaveOrUpdate(model);

                tran.Commit();
                return(true);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                if (!tran.WasCommitted && !tran.WasRolledBack)
                {
                    tran.Rollback();
                }
            }
        }
Пример #2
0
        public ActionResult CancelApprove(Report_WorkFlow_Log_Model model)
        {
            bool success = false;

            try
            {
                string type = Request.Form["type"] == null ? string.Empty : Request.Form["type"].ToString();
                Model.D_Report_Model dataModel = NhSession.Get <Model.D_Report_Model>(model.ReportGuid);
                if (dataModel != null)
                {
                    if (dataModel.ReportCancelStatus == 0)
                    {
                        return(Json(new { success = success, message = "请先提交本8D Report" }, JsonRequestBehavior.AllowGet));
                    }

                    if (!string.IsNullOrEmpty(type))
                    {
                        Model.D_WorkFlowLog_Model logModel = new D_WorkFlowLog_Model();
                        switch (type)
                        {
                        case "0":
                            if (dataModel.ReportStatus == (int)ReportStatusEnum.TeamLeader)
                            {
                                dataModel.ReportStatus    = (int)ReportStatusEnum.New;
                                dataModel.CurrentStepUser = string.Empty;
                                dataModel.PreStepUser     = string.Empty;
                                dataModel.PreStepType     = string.Empty;

                                logModel.OperateType = "Cancel";
                            }
                            break;

                        case "1":
                            if (dataModel.ReportCancelStatus == (int)ReportCancelStatusEnum.TeamLeader)
                            {
                                dataModel.ReportCancelStatus = (int)ReportCancelStatusEnum.QE;
                                dataModel.CurrentStepUser    = dataModel.ResponsibleQE;
                            }
                            else if (dataModel.ReportCancelStatus == (int)ReportCancelStatusEnum.QE)
                            {
                                dataModel.ReportCancelStatus = (int)ReportCancelStatusEnum.Sponsor;
                                dataModel.CurrentStepUser    = dataModel.Sponaor;
                            }
                            else if (dataModel.ReportCancelStatus == (int)ReportCancelStatusEnum.Sponsor)
                            {
                                dataModel.ReportCancelStatus = (int)ReportCancelStatusEnum.Completed;
                                dataModel.CurrentStepUser    = string.Empty;
                            }
                            dataModel.PreStepUser = string.Empty;
                            dataModel.PreStepType = string.Empty;

                            logModel.OperateType = "Approve";
                            break;

                        case "2":
                            dataModel.ReportCancelStatus = (int)ReportCancelStatusEnum.TeamLeader;
                            if (model.ReportCancelStatus == (int)ReportCancelStatusEnum.QE)
                            {
                                dataModel.PreStepType = ((int)ReportCancelStatusEnum.QE).ToString();

                                dataModel.PreStepUser     = dataModel.ResponsibleQE;
                                dataModel.CurrentStepUser = dataModel.Team_Leader;
                            }
                            if (model.ReportCancelStatus == (int)ReportCancelStatusEnum.Sponsor)
                            {
                                dataModel.PreStepType = ((int)ReportCancelStatusEnum.Sponsor).ToString();

                                dataModel.PreStepUser     = dataModel.Sponaor;
                                dataModel.CurrentStepUser = dataModel.Team_Leader;
                            }

                            logModel.OperateType = "Review";
                            break;

                        case "3":
                            if (dataModel.PreStepType == ((int)ReportCancelStatusEnum.QE).ToString())
                            {
                                dataModel.ReportCancelStatus = (int)ReportCancelStatusEnum.QE;
                                dataModel.CurrentStepUser    = dataModel.PreStepUser;
                                dataModel.PreStepUser        = string.Empty;
                                dataModel.PreStepType        = string.Empty;

                                logModel.OperateType = "Submit Review To QE";
                            }
                            if (dataModel.PreStepType == ((int)ReportCancelStatusEnum.Sponsor).ToString())
                            {
                                dataModel.ReportCancelStatus = (int)ReportCancelStatusEnum.Sponsor;
                                dataModel.CurrentStepUser    = dataModel.PreStepUser;
                                dataModel.PreStepUser        = string.Empty;
                                dataModel.PreStepType        = string.Empty;

                                logModel.OperateType = "Submit Review To Sponsor";
                            }
                            break;

                        //case "4":
                        //    dataModel.ReportCancelStatus = (int)ReportStatusEnum.Sponsor;
                        //    logModel.OperateType = "Submit Review To Sponsor";
                        //    break;
                        case "5":
                            dataModel.ReportCancelStatus = (int)ReportCancelStatusEnum.TeamLeader;
                            dataModel.CurrentStepUser    = dataModel.Team_Leader;
                            dataModel.PreStepType        = "";
                            dataModel.PreStepUser        = "";
                            logModel.OperateType         = "Reject";
                            break;

                        default:
                            break;
                        }

                        logModel.ReportGuid     = dataModel;
                        logModel.Status         = ((ReportCancelStatusEnum)dataModel.ReportCancelStatus).ToString();
                        logModel.CreateUser     = UserView.UserLoginName;
                        logModel.CreateUserName = UserView.UserName;
                        logModel.Comments       = model.Comment;
                        logModel.CreateDateTime = DateTime.Now;

                        dataModel.WorkFlowLog_Models.Add(logModel);

                        success = new DAL.D_Report_DAL().SaveWorkFlowLog(dataModel, logModel);
                    }
                }

                return(Json(new { success = success, message = "成功" }, JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                return(Json(new { success = success, message = ex.Message }));
            }
        }
Пример #3
0
        public ActionResult Approve(Report_WorkFlow_Log_Model model)
        {
            bool success = false;

            try
            {
                string type = Request.Form["type"] == null ? string.Empty : Request.Form["type"].ToString();
                Model.D_Report_Model dataModel = NhSession.Get <Model.D_Report_Model>(model.ReportGuid);
                if (dataModel != null)
                {
                    if (dataModel.ReportStatus == 0)
                    {
                        return(Json(new { success = success, message = "请先提交本8D Report" }, JsonRequestBehavior.AllowGet));
                    }

                    if (!string.IsNullOrEmpty(type))
                    {
                        Model.D_WorkFlowLog_Model logModel = new D_WorkFlowLog_Model();
                        switch (type)
                        {
                        case "0":
                            if (dataModel.ReportStatus == (int)ReportStatusEnum.TeamLeader)
                            {
                                dataModel.ReportStatus    = (int)ReportStatusEnum.New;
                                dataModel.CurrentStepUser = string.Empty;
                                dataModel.PreStepUser     = string.Empty;
                                dataModel.PreStepType     = string.Empty;

                                logModel.OperateType = "Cancel";
                            }
                            break;

                        case "1":
                            if (dataModel.ReportStatus == (int)ReportStatusEnum.TeamLeader)
                            {
                                dataModel.ReportStatus    = (int)ReportStatusEnum.Sponsor;
                                dataModel.CurrentStepUser = dataModel.Sponaor;
                            }
                            else if (dataModel.ReportStatus == (int)ReportStatusEnum.Sponsor)
                            {
                                dataModel.ReportStatus = (int)ReportStatusEnum.Approve;

                                List <Models.D_User> list = Newtonsoft.Json.JsonConvert.DeserializeObject <List <Models.D_User> >(dataModel.WorkFlow_Models[0].Additional_Approver);

                                dataModel.CurrentStepUser = Newtonsoft.Json.JsonConvert.SerializeObject(list[0]);
                            }
                            else if (dataModel.ReportStatus == (int)ReportStatusEnum.Approve)
                            {
                                Models.D_User        user = Newtonsoft.Json.JsonConvert.DeserializeObject <Models.D_User>(dataModel.CurrentStepUser);
                                List <Models.D_User> list = Newtonsoft.Json.JsonConvert.DeserializeObject <List <Models.D_User> >(dataModel.WorkFlow_Models[0].Additional_Approver);

                                if (user.Serial != list.Count - 1)
                                {
                                    dataModel.CurrentStepUser = Newtonsoft.Json.JsonConvert.SerializeObject(list[user.Serial + 1]);
                                    dataModel.ReportStatus    = (int)ReportStatusEnum.Completed;
                                }
                                else
                                {
                                    dataModel.CurrentStepUser = string.Empty;
                                }
                            }
                            dataModel.PreStepUser = string.Empty;
                            dataModel.PreStepType = string.Empty;

                            logModel.OperateType = "Approve";
                            break;

                        case "2":
                            dataModel.ReportStatus = (int)ReportStatusEnum.TeamLeader;
                            if (model.ReportStatus == (int)ReportStatusEnum.Sponsor)
                            {
                                dataModel.PreStepType = ((int)ReportStatusEnum.Sponsor).ToString();

                                dataModel.PreStepUser     = dataModel.Sponaor;
                                dataModel.CurrentStepUser = dataModel.Team_Leader;

                                //Models.D_User preStepUser = new Models.D_User();
                                //preStepUser.UserGuid = UserView.UserGuid;
                                //preStepUser.UserLoginName = UserView.UserLoginName;
                                //preStepUser.UserName = UserView.UserName;
                                //dataModel.PreStepUser = Newtonsoft.Json.JsonConvert.SerializeObject(preStepUser);
                            }
                            if (model.ReportStatus == (int)ReportStatusEnum.Approve)
                            {
                                dataModel.PreStepType = ((int)ReportStatusEnum.Approve).ToString();

                                dataModel.PreStepUser     = dataModel.CurrentStepUser;
                                dataModel.CurrentStepUser = dataModel.Team_Leader;

                                //Models.D_User preStepUser = new Models.D_User();
                                //preStepUser.UserGuid = UserView.UserGuid;
                                //preStepUser.UserLoginName = UserView.UserLoginName;
                                //preStepUser.UserName = UserView.UserName;
                                //dataModel.PreStepUser = Newtonsoft.Json.JsonConvert.SerializeObject(preStepUser);
                            }


                            logModel.OperateType = "Review";
                            break;

                        case "3":
                            if (dataModel.PreStepType == ((int)ReportStatusEnum.Sponsor).ToString())
                            {
                                dataModel.ReportStatus    = (int)ReportStatusEnum.Sponsor;
                                dataModel.CurrentStepUser = dataModel.PreStepUser;
                                dataModel.PreStepUser     = string.Empty;
                                dataModel.PreStepType     = string.Empty;

                                logModel.OperateType = "Submit Review To Sponsor";
                            }
                            if (dataModel.PreStepType == ((int)ReportStatusEnum.Approve).ToString())
                            {
                                dataModel.ReportStatus    = (int)ReportStatusEnum.Approve;
                                dataModel.CurrentStepUser = dataModel.PreStepUser;
                                dataModel.PreStepUser     = string.Empty;
                                dataModel.PreStepType     = string.Empty;

                                logModel.OperateType = "Submit Review To AA";
                            }
                            break;

                        //case "4":
                        //    dataModel.ReportStatus = (int)ReportStatusEnum.Approve;
                        //    logModel.OperateType = "Submit Review To AA";
                        //    break;
                        case "5":
                            dataModel.ReportStatus    = (int)ReportStatusEnum.TeamLeader;
                            dataModel.CurrentStepUser = dataModel.Team_Leader;
                            dataModel.PreStepType     = "";
                            dataModel.PreStepUser     = "";
                            logModel.OperateType      = "Reject";
                            break;

                        default:
                            break;
                        }

                        logModel.ReportGuid     = dataModel;
                        logModel.Status         = ((ReportStatusEnum)dataModel.ReportStatus).ToString();
                        logModel.CreateUser     = UserView.UserLoginName;
                        logModel.CreateUserName = UserView.UserName;
                        logModel.Comments       = model.Comment;
                        logModel.CreateDateTime = DateTime.Now;

                        dataModel.WorkFlowLog_Models.Add(logModel);

                        success = new DAL.D_Report_DAL().SaveWorkFlowLog(dataModel, logModel);
                    }
                }

                return(Json(new { success = success, message = "成功" }, JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                return(Json(new { success = success, message = ex.Message }));
            }
        }