コード例 #1
0
        public Result <CompletionAcceptanceView> GetCompletionAcceptanceModelNew(long id)
        {
            Result <CompletionAcceptanceView> result = new Result <CompletionAcceptanceView>();

            try
            {
                var model = DataOperateBusiness <Epm_CompletionAcceptance> .Get().GetModel(id);

                if (model == null)
                {
                    throw new Exception("该完工验收详情信息不存在或已被删除!");
                }

                CompletionAcceptanceView view = new CompletionAcceptanceView();

                view.CompletionAcceptance      = model;
                view.CompletionRectifyCompanys = DataOperateBusiness <Epm_CompletionRectifyCompany> .Get()
                                                 .GetList(p => p.AcceptanceId == id).ToList();

                string tableName = model.GetType().Name;

                view.BaseFiles = DataOperateBasic <Base_Files> .Get().GetList(p => p.TableName == tableName && p.TableId == id).ToList();

                result.Data = view;
                result.Flag = EResultFlag.Success;
            }
            catch (Exception ex)
            {
                result.Data      = null;
                result.Flag      = EResultFlag.Failure;
                result.Exception = new ExceptionEx(ex, "GetCompletionAcceptanceModelNew");
            }
            return(result);
        }
コード例 #2
0
        public ActionResult Edit(Epm_CompletionAcceptance model)
        {
            ResultView <int>         view     = new ResultView <int>();
            CompletionAcceptanceView complete = new CompletionAcceptanceView();

            complete.CompletionAcceptance = model;
            //表单校验
            if (string.IsNullOrEmpty(model.ProjectName))
            {
                view.Flag    = false;
                view.Message = "项目名称不能为空";
                return(Json(view));
            }
            if (string.IsNullOrEmpty(model.Title))
            {
                view.Flag    = false;
                view.Message = "验收标题不能为空";
                return(Json(view));
            }
            if (string.IsNullOrEmpty(model.Content))
            {
                view.Flag    = false;
                view.Message = "验收内容不能为空";
                return(Json(view));
            }
            //List<Epm_CompletionRectifyCompany> completionRectifyCompanys = new List<Epm_CompletionRectifyCompany>();
            string dataVisaCompany = Request.Form["Unit"];

            if (!string.IsNullOrEmpty(dataVisaCompany))
            {
                complete.CompletionRectifyCompanys = JsonConvert.DeserializeObject <List <Epm_CompletionRectifyCompany> >(dataVisaCompany);
            }

            //List<Base_Files> baseFiles = new List<Base_Files>();
            string fileDataJson = Request.Form["fileDataJsonFile"];                                //获取上传图片json字符串

            complete.BaseFiles = JsonConvert.DeserializeObject <List <Base_Files> >(fileDataJson); //将文件信息json字符

            Result <int> result = new Result <int>();

            using (ClientSiteClientProxy proxy = new ClientSiteClientProxy(ProxyEx(Request)))
            {
                result = proxy.UpdateCompletionAcceptanceNew(complete);

                var      project = proxy.GetProject(model.ProjectId.Value).Data;
                DateTime time    = DateTime.Now;
                //foreach (var item in complete.BaseFiles)
                //{
                //    if (string.IsNullOrEmpty(item.ImageType))
                //    {
                //        if (item.TableColumn == "YSD" || item.TableColumn == "JGT")
                //        {
                //            Bp_SendDate send = new Bp_SendDate();
                //            send.IsSend = false;
                //            if (item.TableColumn == "YSD")
                //            {
                //                send.Key = "2003020004";
                //            }
                //            if (item.TableColumn == "JGT")
                //            {
                //                send.Key = "2003020002";
                //            }

                //            send.Value = "{\"FDFS_NAME\":\"" + item.Url + "\",\"FDFS_GROUP\":\"" + item.Group + "\",\"NAME\":\"" + item.Name + "\",\"WJLX\":\"" + ListExtensionMethod.GetFileType(item.Name) + "\",\"SIZE\":\"" + ListExtensionMethod.GetByteLength(item.Size) + "\",\"USER\":\"" + CurrentUser.UserCode + "\"}";
                //            send.Type = "12";
                //            send.Project = "BIM";
                //            send.KeyValue = project.ObjeId;
                //            send.UserName = CurrentUser.UserCode;
                //            send.CreateTime = time;
                //            send.OperateTime = time;
                //            send.OperateUserId = CurrentUser.UserId;
                //            send.OperateUserName = CurrentUser.UserName;
                //            send.CreateUserId = CurrentUser.UserId;
                //            send.CreateUserName = CurrentUser.UserName;
                //            proxy.AddSendDate(send);
                //        }
                //    }
                //}
            }
            return(Json(result.ToResultView()));
        }
コード例 #3
0
        ///<summary>
        ///修改完工验收
        ///</summary>
        /// <param name="view">完工验收</param>
        /// <returns>受影响的行数</returns>
        public Result <int> UpdateCompletionAcceptanceNew(CompletionAcceptanceView view)
        {
            Result <int> result = new Result <int>();

            try
            {
                var completionAcceptance      = view.CompletionAcceptance;
                var completionRectifyCompanys = view.CompletionRectifyCompanys;
                var baseFiles = view.BaseFiles;
                if (completionAcceptance == null)
                {
                    throw new Exception("请选择要修改的内容!");
                }

                var oldModel = DataOperateBusiness <Epm_CompletionAcceptance> .Get().GetModel(completionAcceptance.Id);

                if (oldModel == null)
                {
                    throw new Exception("要修改的信息不存在!");
                }
                //if (oldModel.State != (int)PreCompletionScceptanceState.WaitApproval)
                //{
                //    throw new Exception("只有未提交审核的信息才可以进行修改!");
                //}

                oldModel.Title            = completionAcceptance.Title;
                oldModel.RecTime          = completionAcceptance.RecTime;
                oldModel.Content          = completionAcceptance.Content;
                oldModel.Num              = completionAcceptance.Num;
                oldModel.RecTime          = completionAcceptance.RecTime;
                oldModel.RecCompanyId     = completionAcceptance.RecCompanyId;
                oldModel.RecCompanyName   = completionAcceptance.RecCompanyName;
                oldModel.RecUserId        = completionAcceptance.RecUserId;
                oldModel.RecUserName      = completionAcceptance.RecUserName;
                oldModel.RectifContent    = completionAcceptance.RectifContent;
                oldModel.AcceptanceResult = completionAcceptance.AcceptanceResult;
                oldModel.State            = completionAcceptance.State;

                var oldCompanyList = DataOperateBusiness <Epm_CompletionRectifyCompany> .Get().GetList(p => p.AcceptanceId == oldModel.Id);

                var rows = DataOperateBusiness <Epm_CompletionAcceptance> .Get().Update(oldModel);

                if (oldCompanyList.Any())
                {
                    DataOperateBusiness <Epm_CompletionRectifyCompany> .Get().DeleteRange(oldCompanyList);
                }
                if (completionRectifyCompanys != null && completionRectifyCompanys.Any())
                {
                    completionRectifyCompanys.ForEach(p =>
                    {
                        SetCreateUser(p);
                        SetCurrentUser(p);
                        p.AcceptanceId = oldModel.Id;
                    });
                    DataOperateBusiness <Epm_CompletionRectifyCompany> .Get().AddRange(completionRectifyCompanys);
                }

                if (baseFiles != null)
                {
                    //删除之前的附件
                    DeleteFilesByTable(oldModel.GetType().Name, new List <long>()
                    {
                        oldModel.Id
                    });
                    //新增附件
                    AddFilesByTable(oldModel, baseFiles);
                }

                //处理待办
                //var temp = DataOperateBusiness<Epm_Approver>.Get().GetList(t => t.BusinessId == oldModel.Id && t.IsApprover == false).FirstOrDefault();
                //if (temp != null)
                //{
                //    ComplateApprover(temp.Id);
                //}

                //生成代办消息
                //if ((PreCompletionScceptanceState)oldModel.State == PreCompletionScceptanceState.WaitApproval)
                //{
                //    #region 生成待办
                //    var project = DataOperateBusiness<Epm_Project>.Get().GetModel(oldModel.ProjectId.Value);
                //    List<Epm_Approver> list = new List<Epm_Approver>();
                //    Epm_Approver app = new Epm_Approver();
                //    app.Title = CurrentUserName + "提交了" + project.Name + "完工验收申请,待审核";
                //    app.Content = CurrentUserName + "提交了" + project.Name + "完工验收申请,待审核";
                //    app.SendUserId = CurrentUserID.ToLongReq();
                //    app.SendUserName = CurrentUserName;
                //    app.SendTime = DateTime.Now;
                //    app.LinkURL = string.Empty;
                //    app.BusinessTypeNo = BusinessType.Completed.ToString();
                //    app.Action = SystemRight.Add.ToString();
                //    app.BusinessTypeName = BusinessType.Completed.GetText();
                //    app.BusinessState = (int)(PreCompletionScceptanceState.WaitApproval);
                //    app.BusinessId = oldModel.Id;
                //    app.ApproverId = project.PMId;
                //    app.ApproverName = project.PMName;
                //    app.ProjectId = oldModel.ProjectId;
                //    app.ProjectName = project.Name;
                //    list.Add(app);
                //    AddApproverBatch(list);
                //    WriteLog(BusinessType.Completed.GetText(), SystemRight.Add.GetText(), "提交完工验收生成待办: " + oldModel.Id);
                //    #endregion

                //    #region 消息
                //    var waitSend = GetWaitSendMessageList(oldModel.ProjectId.Value);
                //    foreach (var send in waitSend)
                //    {
                //        Epm_Massage modelMsg = new Epm_Massage();
                //        modelMsg.ReadTime = null;
                //        modelMsg.RecId = send.Key;
                //        modelMsg.RecName = send.Value;
                //        modelMsg.RecTime = DateTime.Now;
                //        modelMsg.SendId = CurrentUserID.ToLongReq();
                //        modelMsg.SendName = CurrentUserName;
                //        modelMsg.SendTime = DateTime.Now;
                //        modelMsg.Title = CurrentUserName + "提交了" + project.Name + "完工验收申请,待审核";
                //        modelMsg.Content = CurrentUserName + "提交了" + project.Name + "完工验收申请,待审核";
                //        modelMsg.Type = 2;
                //        modelMsg.IsRead = false;
                //        modelMsg.BussinessId = oldModel.Id;
                //        modelMsg.BussinesType = BusinessType.Completed.ToString();
                //        modelMsg.ProjectId = oldModel.ProjectId.Value;
                //        modelMsg.ProjectName = oldModel.ProjectName;
                //        modelMsg = base.SetCurrentUser(modelMsg);
                //        modelMsg = base.SetCreateUser(modelMsg);
                //        DataOperateBusiness<Epm_Massage>.Get().Add(modelMsg);
                //    }
                //    #endregion

                //    #region 发送短信
                //    //Dictionary<string, string> parameters = new Dictionary<string, string>();
                //    //parameters.Add("UserName", CurrentUserName);
                //    //WriteSMS(project.PMId.Value, 0, MessageStep.ComplationAdd, parameters);
                //    #endregion
                //}

                result.Data = rows;
                result.Flag = EResultFlag.Success;
                WriteLog(BusinessType.Completed.GetText(), SystemRight.Modify.GetText(), "修改: " + oldModel.Id);
            }
            catch (Exception ex)
            {
                result.Data      = -1;
                result.Flag      = EResultFlag.Failure;
                result.Exception = new ExceptionEx(ex, "UpdateCompletionAcceptance");
            }
            return(result);
        }
コード例 #4
0
        /// <summary>
        /// 新增完工验收
        /// </summary>
        /// <param name="view"></param>
        /// <returns></returns>
        public Result <int> AddCompletionAcceptanceNew(CompletionAcceptanceView view)
        {
            Result <int> result = new Result <int>();

            try
            {
                var completionAcceptance      = view.CompletionAcceptance;
                var completionRectifyCompanys = view.CompletionRectifyCompanys;
                completionAcceptance = base.SetCurrentUser(completionAcceptance);
                completionAcceptance.CrtCompanyId   = CurrentCompanyID.ToLongReq();
                completionAcceptance.CrtCompanyName = CurrentCompanyName;
                completionAcceptance.RecUserId      = CurrentUser.Id;
                completionAcceptance.RecUserName    = CurrentUserName;

                var rows = DataOperateBusiness <Epm_CompletionAcceptance> .Get().Add(completionAcceptance);

                if (completionRectifyCompanys != null && completionRectifyCompanys.Any())
                {
                    completionRectifyCompanys.ForEach(p =>
                    {
                        SetCreateUser(p);
                        SetCurrentUser(p);
                        p.AcceptanceId = completionAcceptance.Id;
                    });
                    DataOperateBusiness <Epm_CompletionRectifyCompany> .Get().AddRange(completionRectifyCompanys);
                }

                if (view.BaseFiles != null)
                {
                    AddFilesByTable(completionAcceptance, view.BaseFiles);
                }

                //生成代办消息
                if ((PreCompletionScceptanceState)completionAcceptance.State == PreCompletionScceptanceState.WaitApproval)
                {
                    #region 生成待办
                    var project = DataOperateBusiness <Epm_Project> .Get().GetModel(completionAcceptance.ProjectId.Value);

                    List <Epm_Approver> list = new List <Epm_Approver>();
                    Epm_Approver        app  = new Epm_Approver();
                    app.Title            = CurrentUserName + "提交了" + project.Name + "完工验收申请,待审核";
                    app.Content          = CurrentUserName + "提交了" + project.Name + "完工验收申请,待审核";
                    app.SendUserId       = CurrentUserID.ToLongReq();
                    app.SendUserName     = CurrentUserName;
                    app.SendTime         = DateTime.Now;
                    app.LinkURL          = string.Empty;
                    app.BusinessTypeNo   = BusinessType.Completed.ToString();
                    app.Action           = SystemRight.Add.ToString();
                    app.BusinessTypeName = BusinessType.Completed.GetText();
                    app.BusinessState    = (int)(PreCompletionScceptanceState.WaitApproval);
                    app.BusinessId       = completionAcceptance.Id;
                    app.ApproverId       = project.PMId;
                    app.ApproverName     = project.PMName;
                    app.ProjectId        = completionAcceptance.ProjectId;
                    app.ProjectName      = project.Name;
                    list.Add(app);
                    AddApproverBatch(list);
                    WriteLog(BusinessType.Completed.GetText(), SystemRight.Add.GetText(), "提交完工验收生成待办: " + completionAcceptance.Id);
                    #endregion

                    #region 消息
                    var waitSend = GetWaitSendMessageList(completionAcceptance.ProjectId.Value);
                    foreach (var send in waitSend)
                    {
                        Epm_Massage modelMsg = new Epm_Massage();
                        modelMsg.ReadTime     = null;
                        modelMsg.RecId        = send.Key;
                        modelMsg.RecName      = send.Value;
                        modelMsg.RecTime      = DateTime.Now;
                        modelMsg.SendId       = CurrentUserID.ToLongReq();
                        modelMsg.SendName     = CurrentUserName;
                        modelMsg.SendTime     = DateTime.Now;
                        modelMsg.Title        = CurrentUserName + "提交了" + project.Name + "完工验收申请,待审核";
                        modelMsg.Content      = CurrentUserName + "提交了" + project.Name + "完工验收申请,待审核";
                        modelMsg.Type         = 2;
                        modelMsg.IsRead       = false;
                        modelMsg.BussinessId  = completionAcceptance.Id;
                        modelMsg.BussinesType = BusinessType.Completed.ToString();
                        modelMsg.ProjectId    = completionAcceptance.ProjectId.Value;
                        modelMsg.ProjectName  = completionAcceptance.ProjectName;
                        modelMsg = base.SetCurrentUser(modelMsg);
                        modelMsg = base.SetCreateUser(modelMsg);
                        DataOperateBusiness <Epm_Massage> .Get().Add(modelMsg);
                    }
                    #endregion

                    #region 发送短信
                    //Dictionary<string, string> parameters = new Dictionary<string, string>();
                    //parameters.Add("UserName", CurrentUserName);
                    //WriteSMS(project.PMId.Value, 0, MessageStep.ComplationAdd, parameters);
                    #endregion
                }

                result.Data = rows;
                result.Flag = EResultFlag.Success;
                WriteLog(BusinessType.Completed.GetText(), SystemRight.Add.GetText(), "新增: " + completionAcceptance.Id);
            }
            catch (Exception ex)
            {
                result.Data      = -1;
                result.Flag      = EResultFlag.Failure;
                result.Exception = new ExceptionEx(ex, "AddCompletionAcceptanceNew");
            }
            return(result);
        }