예제 #1
0
        ///<summary>
        ///添加:
        ///</summary>
        /// <param name="model">要添加的model</param>
        /// <returns>受影响的行数</returns>
        public Result <int> AddTzConDrawing(Epm_TzConDrawing model, List <Base_Files> baseEntity)
        {
            Result <int> result = new Result <int>();

            try
            {
                int  rows     = 0;
                bool isAdd    = false;
                var  reveiews = DataOperateBusiness <Epm_TzConDrawing> .Get().GetList(t => t.ProjectId == model.ProjectId).FirstOrDefault();

                var ApprovalInfo = DataOperateBusiness <Epm_TzProjectApprovalInfo> .Get().GetList(t => t.ProjectId == model.ProjectId).FirstOrDefault();

                if (reveiews == null)
                {
                    isAdd    = true;
                    reveiews = new Epm_TzConDrawing();
                    //当前创建人
                    SetCreateUser(reveiews);
                }
                reveiews.ProjectId     = model.ProjectId;           //项目id
                reveiews.ProjectCode   = model.ProjectCode;         //项目编码
                reveiews.ProjectName   = model.ProjectName;         //项目名称
                reveiews.ApprovalNo    = model.ApprovalNo;          //批复号
                reveiews.Nature        = model.Nature;              //项目性质
                reveiews.NatureName    = model.NatureName;          //项目性质名称
                reveiews.ApplyTime     = model.ApplyTime;           //项目提出日期
                reveiews.StationId     = model.StationId;           //站库id
                reveiews.StationCodeXt = model.StationCodeXt;       //站库协同编码
                reveiews.StationName   = model.StationName;         //站库名称
                reveiews.CompanyId     = model.CompanyId;           //地市公司id
                reveiews.CompanyCodeXt = model.CompanyCodeXt;       //地市公司协同编码
                reveiews.CompanyName   = model.CompanyName;         //地市公司名称
                reveiews.ReviewTime    = model.ReviewTime;          //评审日期
                reveiews.Moderator     = model.Moderator;           //主持人
                reveiews.ReviewAddress = model.ReviewAddress;       //评审地点
                reveiews.ReviewExperts = model.ReviewExperts;       //评审专家
                reveiews.Participants  = model.Participants;        //参会人员
                reveiews.Conclusion    = model.Conclusion;          //评审结论

                reveiews.State            = model.State;            //状态
                reveiews.Remark           = model.Remark;           //备注
                reveiews.DrawingId        = model.DrawingId;        //图纸id
                reveiews.ProjectDrawingID = model.ProjectDrawingID; //施工项目id

                //当前操作人
                SetCurrentUser(reveiews);
                //上传附件
                AddFilesBytzTable(reveiews, model.TzAttachs);
                #region  施工图纸会审流程申请     暂时注释  勿删!!!
                var XtWorkFlow = System.Configuration.ConfigurationManager.AppSettings.Get("XtWorkFlow");
                if (model.State == (int)PreProjectState.WaitApproval && XtWorkFlow == "1")
                {
                    TzConDrawingWorkFlowView view = new TzConDrawingWorkFlowView();

                    view.CompanyName     = model.CompanyName;
                    view.Conclusion      = model.CompanyName;
                    view.Moderator       = model.Moderator;
                    view.NatureName      = model.NatureName;
                    view.Participants    = model.Participants;
                    view.PredictMoney    = "";
                    view.ProjectCode     = model.ProjectCode;
                    view.ProjectName     = model.ProjectName;
                    view.ProvinceName    = model.CompanyName;
                    view.ReviewAddress   = model.ReviewAddress;
                    view.ReviewExperts   = model.ReviewExperts;
                    view.ReviewTime      = model.ReviewTime.ToString();
                    view.StationName     = model.StationName;
                    view.StationTypeName = model.Nature;
                    view.LandCosts       = ApprovalInfo.LandCosts.ToString();
                    view.OtherExpenses   = ApprovalInfo.OtherExpenses.ToString();
                    view.EngineeringCost = ApprovalInfo.EngineeringCost.ToString();
                    var baseUser = DataOperateBasic <Base_User> .Get().GetModel(reveiews.CreateUserId);

                    if (baseUser == null)
                    {
                        throw new Exception("未找到申请人相关信息!");
                    }

                    view.hr_sqr = baseUser.ObjeId;
                    //上传附件
                    if (model.TzAttachs != null && model.TzAttachs.Any())
                    {
                        //string baseFaleUrl = System.Configuration.ConfigurationManager.AppSettings.Get("XtDownloadUrl");
                        //foreach (var item in model.TzAttachs)
                        //{
                        //    //string fileUrl = string.Format("{0}?fileId={1}&type={2}", baseFaleUrl, item.Id, item.TypeNo);
                        //    //view.Temp_TzAttachs = fileUrl + '|' + view.Temp_TzAttachs;
                        //    string fileUrl = XtWorkFlowService.GetXtAttachPaht(item.FilePath);
                        //    view.Temp_TzAttachs = fileUrl + '|' + view.Temp_TzAttachs;
                        //}
                        //if (view.Temp_TzAttachs != null)
                        //{
                        //    view.Temp_TzAttachs = view.Temp_TzAttachs.Substring(0, view.Temp_TzAttachs.Length - 1);
                        //}
                        view.Temp_TzAttachs = XtWorkFlowSubmitService.CreateXtAttachPath(model.TzAttachs);
                    }

                    reveiews.WorkFlowId = XtWorkFlowService.CreateConDrawingWorkFlow(view);
                }
                #endregion
                if (isAdd)
                {
                    rows = DataOperateBusiness <Epm_TzConDrawing> .Get().Add(reveiews);
                }
                else
                {
                    rows = DataOperateBusiness <Epm_TzConDrawing> .Get().Update(reveiews);
                }


                if (baseEntity.Count != 0 && model.State == (int)PreProjectApprovalState.ApprovalSuccess) //如果附件选择了图纸类型&&状态是通过了审核,往图纸管理同步一条数据
                {
                    baseEntity = baseEntity.Where(p => p.ImageType == "SGTZSHTZ").ToList();               //筛选附件是图纸类型(SGTZSHTZ)
                    drawingToDraw(reveiews, baseEntity);                                                  //整理图纸管理数据
                }



                result.Data = rows;
                result.Flag = EResultFlag.Success;
                // WriteLog(AdminModule.TzConDrawing.GetText(), SystemRight.Add.GetText(), "新增: " + model.Id);
            }
            catch (Exception ex)
            {
                result.Data      = -1;
                result.Flag      = EResultFlag.Failure;
                result.Exception = new ExceptionEx(ex, "AddTzConDrawing");
            }
            return(result);
        }
예제 #2
0
        ///<summary>
        ///修改:
        ///</summary>
        /// <param name="model">要修改的model</param>
        /// <returns>受影响的行数</returns>
        public Result <int> UpdateTzConDrawing(Epm_TzConDrawing model, List <Base_Files> baseEntity)
        {
            Result <int> result = new Result <int>();

            try
            {
                var drawing = DataOperateBusiness <Epm_TzConDrawing> .Get().Single(p => p.Id == model.Id);

                model.ProjectId     = drawing.ProjectId;     //项目ID
                model.ProjectCode   = drawing.ProjectCode;   //项目编码
                model.ProjectName   = drawing.ProjectName;   //项目名称
                model.ApprovalNo    = drawing.ApprovalNo;    //项目批复号
                model.Nature        = drawing.Nature;        //项目性质
                model.NatureName    = drawing.NatureName;    //项目性质名称
                model.ApplyTime     = drawing.ApplyTime;     //项目提出时间
                model.StationId     = drawing.StationId;     //站库id
                model.StationCodeXt = drawing.StationCodeXt; //站库协同编码
                model.StationName   = drawing.StationName;   //站库名称
                model.CompanyId     = drawing.CompanyId;     //地市公司ID
                model.CompanyCodeXt = drawing.CompanyCodeXt; //地市公司编码
                model.CompanyName   = drawing.CompanyName;   //地市公司名称

                SetCurrentUser(model);
                //上传图纸
                AddFilesBytzTable(model, model.TzAttachs);
                #region  施工图纸会审流程申请     暂时注释  勿删!!!
                var XtWorkFlow = System.Configuration.ConfigurationManager.AppSettings.Get("XtWorkFlow");
                if (model.State == (int)PreProjectState.WaitApproval && XtWorkFlow == "1")
                {
                    TzConDrawingWorkFlowView view = new TzConDrawingWorkFlowView();
                    var baseUser = DataOperateBasic <Base_User> .Get().GetModel(model.CreateUserId);

                    if (baseUser == null)
                    {
                        throw new Exception("未找到申请人相关信息!");
                    }
                    else
                    {
                        view.hr_sqr = baseUser.ObjeId;
                    }
                    view.CompanyName     = model.CompanyName;
                    view.Conclusion      = model.CompanyName;
                    view.Moderator       = model.Moderator;
                    view.NatureName      = model.NatureName;
                    view.Participants    = model.Participants;
                    view.PredictMoney    = "";
                    view.ProjectCode     = model.ProjectCode;
                    view.ProjectName     = model.ProjectName;
                    view.ProvinceName    = model.CompanyName;
                    view.ReviewAddress   = model.ReviewAddress;
                    view.ReviewExperts   = model.ReviewExperts;
                    view.ReviewTime      = model.ReviewTime.ToString();
                    view.StationName     = model.StationName;
                    view.StationTypeName = model.Nature;

                    //上传附件
                    if (model.TzAttachs != null && model.TzAttachs.Any())
                    {
                        //string baseFaleUrl = System.Configuration.ConfigurationManager.AppSettings.Get("XtDownloadUrl");
                        //foreach (var item in model.TzAttachs)
                        //{
                        //    //string fileUrl = string.Format("{0}?fileId={1}&type={2}", baseFaleUrl, item.Id, item.TypeNo);
                        //    //view.Temp_TzAttachs = fileUrl + '|' + view.Temp_TzAttachs;
                        //    string fileUrl = XtWorkFlowService.GetXtAttachPaht(item.FilePath);
                        //    view.Temp_TzAttachs = fileUrl + '|' + view.Temp_TzAttachs;
                        //}
                        //if (view.Temp_TzAttachs != null)
                        //{
                        //    view.Temp_TzAttachs = view.Temp_TzAttachs.Substring(0, view.Temp_TzAttachs.Length - 1);
                        //}
                        view.Temp_TzAttachs = XtWorkFlowSubmitService.CreateXtAttachPath(model.TzAttachs);
                    }

                    model.WorkFlowId = XtWorkFlowService.CreateConDrawingWorkFlow(view);
                }
                #endregion

                var rows = DataOperateBusiness <Epm_TzConDrawing> .Get().Update(model);

                //AddFilesBytzTable(reveiews, model.TzAttachs);

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

                if (baseEntity.Count != 0 && model.State == (int)PreProjectApprovalState.ApprovalSuccess)//如果附件选择了图纸类型&&状态是通过了审核,往图纸管理同步一条数据
                {
                    baseEntity = baseEntity.Where(p => p.ImageType == "SGTZSHTZ").ToList();
                    drawingToDraw(model, baseEntity);
                }

                result.Data = rows;
                result.Flag = EResultFlag.Success;
                // WriteLog(AdminModule.TzConDrawing.GetText(), SystemRight.Modify.GetText(), "修改: " + model.Id);
            }
            catch (Exception ex)
            {
                result.Data      = -1;
                result.Flag      = EResultFlag.Failure;
                result.Exception = new ExceptionEx(ex, "UpdateTzConDrawing");
            }
            return(result);
        }