///<summary>
        ///添加:
        ///</summary>
        /// <param name="model">要添加的model</param>
        /// <returns>受影响的行数</returns>
        public Result <int> AddMeetingFileReport(Epm_MeetingFileReport model)
        {
            Result <int> result = new Result <int>();

            try
            {
                int  rows    = 0;
                bool isAdd   = false;
                var  meeting = DataOperateBusiness <Epm_MeetingFileReport> .Get().GetList(t => t.ProjectId == model.ProjectId && t.State != (int)PreProjectState.ApprovalFailure && t.State != (int)PreProjectState.Discarded).FirstOrDefault();

                if (meeting == null)
                {
                    isAdd   = true;
                    meeting = new Epm_MeetingFileReport();
                    SetCreateUser(meeting);
                }
                meeting.ProjectId = model.ProjectId;
                meeting.State     = model.State;
                SetCurrentUser(meeting);

                //上传附件
                AddFilesBytzTable(meeting, model.TzAttachs);

                var projectInfo = DataOperateBusiness <Epm_TzProjectProposal> .Get().GetModel(model.ProjectId);

                //特许经营项目性质的项目审批到项目批复完成就结束了,不生成工程模块的内容,不用写到机器人表里
                if (projectInfo.Nature != "XMXZTXJY")
                {
                    #region   会材料上报流程申请
                    var XtWorkFlow = System.Configuration.ConfigurationManager.AppSettings.Get("XtWorkFlow");
                    if (model.State == (int)PreProjectState.WaitApproval && XtWorkFlow == "1")
                    {
                        TzMeetingFileReportWorkFlowView view = new TzMeetingFileReportWorkFlowView();
                        var project = DataOperateBusiness <Epm_TzProjectProposal> .Get().GetModel(model.ProjectId);

                        view.ProjectName   = project.ProjectName;
                        view.StationName   = project.StationName;
                        view.NatureName    = project.NatureName;
                        view.Position      = project.Position;
                        view.ApplyTime     = string.Format("{0:yyyy-MM-dd}", project.ApplyTime);
                        view.CompanyName   = project.CompanyName;
                        view.PredictMoney  = project.PredictMoney.ToString();
                        view.OilSalesTotal = project.OilSalesTotal.ToString();
                        view.CNGY          = model.CNG.ToString();
                        view.LNGQ          = model.LNG.ToString();
                        var baseUser = DataOperateBasic <Base_User> .Get().GetModel(meeting.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;

                            //}

                            //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);
                        }

                        meeting.WorkFlowId = XtWorkFlowService.CreateMeetingFileReportWorkFlow(view);
                    }
                    #endregion
                }

                if (isAdd)
                {
                    rows = DataOperateBusiness <Epm_MeetingFileReport> .Get().Add(meeting);
                }
                else
                {
                    rows = DataOperateBusiness <Epm_MeetingFileReport> .Get().Update(meeting);
                }


                result.Data = rows;
                result.Flag = EResultFlag.Success;
                //WriteLog(AdminModule.MeetingFileReport.GetText(), SystemRight.Add.GetText(), "新增: " + model.Id);
            }
            catch (Exception ex)
            {
                result.Data      = -1;
                result.Flag      = EResultFlag.Failure;
                result.Exception = new ExceptionEx(ex, "AddMeetingFileReport");
            }
            return(result);
        }
        ///<summary>
        ///修改:
        ///</summary>
        /// <param name="model">要修改的model</param>
        /// <returns>受影响的行数</returns>
        public Result <int> UpdateMeetingFileReport(Epm_MeetingFileReport model)
        {
            Result <int> result = new Result <int>();

            try
            {
                #region   会材料上报流程申请     暂时注释  勿删!!!
                var XtWorkFlow = System.Configuration.ConfigurationManager.AppSettings.Get("XtWorkFlow");
                if (model.State == (int)PreProjectState.WaitApproval && XtWorkFlow == "1")
                {
                    TzMeetingFileReportWorkFlowView view = new TzMeetingFileReportWorkFlowView();
                    var project = DataOperateBusiness <Epm_TzProjectProposal> .Get().GetModel(model.ProjectId);

                    view.ProjectName   = project.ProjectName;
                    view.StationName   = project.StationName;
                    view.NatureName    = project.NatureName;
                    view.Position      = project.Position;
                    view.ApplyTime     = project.ApplyTime.ToString();
                    view.CompanyName   = project.CompanyName;
                    view.PredictMoney  = project.ProjectCode;
                    view.OilSalesTotal = project.OilSalesTotal.ToString();
                    view.CNGY          = model.CNG.ToString();
                    view.LNGQ          = model.LNG.ToString();
                    var baseUser = DataOperateBasic <Base_User> .Get().GetModel(model.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);
                    }

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

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

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