/// <summary>
 /// 增加危险观察登记信息
 /// </summary>
 /// <param name="hazardRegister">危险观察登记实体</param>
 public static void AddHazardRegister(Model.HSSE_Hazard_HazardRegister hazardRegister)
 {
     Model.SUBHSSEDB db = Funs.DB;
     Model.HSSE_Hazard_HazardRegister newHazardRegister = new Model.HSSE_Hazard_HazardRegister();
     newHazardRegister.HazardRegisterId      = hazardRegister.HazardRegisterId;
     newHazardRegister.HazardCode            = hazardRegister.HazardCode;
     newHazardRegister.RegisterDate          = DateTime.Now;
     newHazardRegister.RegisterDef           = hazardRegister.RegisterDef;
     newHazardRegister.RegisterTypesId       = hazardRegister.RegisterTypesId;
     newHazardRegister.CheckCycle            = hazardRegister.CheckCycle;
     newHazardRegister.Rectification         = hazardRegister.Rectification;
     newHazardRegister.Place                 = hazardRegister.Place;
     newHazardRegister.ResponsibleUnit       = hazardRegister.ResponsibleUnit;
     newHazardRegister.Observer              = hazardRegister.Observer;
     newHazardRegister.RectifiedDate         = hazardRegister.RectifiedDate;
     newHazardRegister.AttachUrl             = hazardRegister.AttachUrl;
     newHazardRegister.ProjectId             = hazardRegister.ProjectId;
     newHazardRegister.States                = hazardRegister.States;
     newHazardRegister.IsEffective           = hazardRegister.IsEffective;
     newHazardRegister.ResponsibleMan        = hazardRegister.ResponsibleMan;
     newHazardRegister.CheckManId            = hazardRegister.CheckManId;
     newHazardRegister.CheckTime             = hazardRegister.CheckTime;
     newHazardRegister.RectificationPeriod   = hazardRegister.RectificationPeriod;
     newHazardRegister.ImageUrl              = hazardRegister.ImageUrl;
     newHazardRegister.RectificationImageUrl = hazardRegister.RectificationImageUrl;
     newHazardRegister.RectificationTime     = hazardRegister.RectificationTime;
     newHazardRegister.ConfirmMan            = hazardRegister.ConfirmMan;
     newHazardRegister.ConfirmDate           = hazardRegister.ConfirmDate;
     newHazardRegister.HandleIdea            = hazardRegister.HandleIdea;
     newHazardRegister.CutPayment            = hazardRegister.CutPayment;
     newHazardRegister.ProblemTypes          = hazardRegister.ProblemTypes;
     newHazardRegister.DIC_ID                = hazardRegister.DIC_ID;
     db.HSSE_Hazard_HazardRegister.InsertOnSubmit(newHazardRegister);
     db.SubmitChanges();
 }
        /// <summary>
        /// 修改危险观察登记信息
        /// </summary>
        /// <param name="hazardRegister">危险观察登记实体</param>
        public static void UpdateHazardRegister(Model.HSSE_Hazard_HazardRegister hazardRegister)
        {
            Model.SUBHSSEDB db = Funs.DB;
            Model.HSSE_Hazard_HazardRegister newHazardRegister = db.HSSE_Hazard_HazardRegister.FirstOrDefault(e => e.HazardRegisterId == hazardRegister.HazardRegisterId);
            if (newHazardRegister != null)
            {
                newHazardRegister.HazardCode      = hazardRegister.HazardCode;
                newHazardRegister.RegisterDef     = hazardRegister.RegisterDef;
                newHazardRegister.Rectification   = hazardRegister.Rectification;
                newHazardRegister.Place           = hazardRegister.Place;
                newHazardRegister.ResponsibleUnit = hazardRegister.ResponsibleUnit;
                newHazardRegister.Observer        = hazardRegister.Observer;
                newHazardRegister.RectifiedDate   = hazardRegister.RectifiedDate;
                newHazardRegister.AttachUrl       = hazardRegister.AttachUrl;
                newHazardRegister.ProjectId       = hazardRegister.ProjectId;
                newHazardRegister.States          = hazardRegister.States;
                newHazardRegister.IsEffective     = hazardRegister.IsEffective;
                newHazardRegister.ResponsibleMan  = hazardRegister.ResponsibleMan;
                newHazardRegister.CheckManId      = hazardRegister.CheckManId;
                //newHazardRegister.CheckTime = hazardRegister.CheckTime;
                newHazardRegister.RectificationPeriod   = hazardRegister.RectificationPeriod;
                newHazardRegister.ImageUrl              = hazardRegister.ImageUrl;
                newHazardRegister.RectificationImageUrl = hazardRegister.RectificationImageUrl;
                newHazardRegister.RectificationTime     = hazardRegister.RectificationTime;
                newHazardRegister.ConfirmMan            = hazardRegister.ConfirmMan;
                newHazardRegister.ConfirmDate           = hazardRegister.ConfirmDate;
                newHazardRegister.HandleIdea            = hazardRegister.HandleIdea;
                newHazardRegister.CutPayment            = hazardRegister.CutPayment;
                newHazardRegister.ProblemTypes          = hazardRegister.ProblemTypes;
                newHazardRegister.DIC_ID = hazardRegister.DIC_ID;
                //把附件表的路径复制过来
                Model.AttachFile file = BLL.AttachFileService.GetAttachFile(hazardRegister.HazardRegisterId, Const.HSSE_HiddenRectificationListMenuId);
                if (file != null)
                {
                    newHazardRegister.ImageUrl = file.AttachUrl;
                }
                Model.AttachFile fileR = BLL.AttachFileService.GetAttachFile(hazardRegister.HazardRegisterId + "-R", Const.HSSE_HiddenRectificationListMenuId);
                if (fileR != null)
                {
                    newHazardRegister.RectificationImageUrl = fileR.AttachUrl;
                }

                db.SubmitChanges();
            }
        }
 /// <summary>
 /// 根据危险观察登记主键删除一个危险观察登记信息
 /// </summary>
 /// <param name="hazardRegisterId">危险观察登记主键</param>
 public static void DeleteHazardRegisterByHazardRegisterId(string hazardRegisterId)
 {
     Model.SUBHSSEDB db = Funs.DB;
     Model.HSSE_Hazard_HazardRegister hazardRegister = db.HSSE_Hazard_HazardRegister.FirstOrDefault(e => e.HazardRegisterId == hazardRegisterId);
     if (hazardRegister != null)
     {
         try
         {
             BLL.UploadFileService.DeleteFile(Funs.RootPath, hazardRegister.ImageUrl);              //删除整改前图片
             BLL.UploadFileService.DeleteFile(Funs.RootPath, hazardRegister.RectificationImageUrl); //删除整改后图片
         }
         catch (Exception)
         {
         }
         db.HSSE_Hazard_HazardRegister.DeleteOnSubmit(hazardRegister);
         db.SubmitChanges();
     }
 }
Beispiel #4
0
        /// <summary>
        /// 保存HazardRegister
        /// </summary>
        /// <param name="userInfo"></param>
        /// <returns></returns>
        public static void SaveHazardRegister(Model.HazardRegisterItem hazardRegister)
        {
            Model.HSSE_Hazard_HazardRegister newHazardRegister = new Model.HSSE_Hazard_HazardRegister
            {
                HazardRegisterId      = hazardRegister.HazardRegisterId,
                HazardCode            = hazardRegister.HazardCode,
                RegisterDef           = hazardRegister.RegisterDef,
                Rectification         = hazardRegister.Rectification,
                Place                 = hazardRegister.Place,
                ResponsibleUnit       = hazardRegister.ResponsibleUnit,
                ProjectId             = hazardRegister.ProjectId,
                States                = hazardRegister.States,
                IsEffective           = "1",
                ResponsibleMan        = hazardRegister.ResponsibleMan,
                CheckManId            = hazardRegister.CheckManId,
                CheckTime             = hazardRegister.CheckTime,
                RectificationPeriod   = hazardRegister.RectificationPeriod,
                ImageUrl              = hazardRegister.ImageUrl,
                RectificationImageUrl = hazardRegister.RectificationImageUrl,
                RectificationTime     = hazardRegister.RectificationTime,
                ConfirmMan            = hazardRegister.ConfirmMan,
                ConfirmDate           = hazardRegister.ConfirmDate,
                HandleIdea            = hazardRegister.HandleIdea,
                CutPayment            = hazardRegister.CutPayment,
                ProblemTypes          = hazardRegister.ProblemTypes,
                RegisterTypesId       = hazardRegister.RegisterTypesId,
                CheckCycle            = hazardRegister.CheckCycle,
                SafeSupervisionIsOK   = hazardRegister.SafeSupervisionIsOK,
                IsWx         = "Y",
                CCManIds     = hazardRegister.CCManIds,
                Requirements = hazardRegister.Requirements,
            };
            var isUpdate = Funs.DB.HSSE_Hazard_HazardRegister.FirstOrDefault(x => x.HazardRegisterId == newHazardRegister.HazardRegisterId);

            if (isUpdate == null)
            {
                newHazardRegister.RegisterDate = DateTime.Now;
                newHazardRegister.CheckTime    = DateTime.Now;
                if (string.IsNullOrEmpty(newHazardRegister.HazardRegisterId))
                {
                    newHazardRegister.HazardRegisterId = SQLHelper.GetNewID();
                }
                Funs.DB.HSSE_Hazard_HazardRegister.InsertOnSubmit(newHazardRegister);
            }
            else
            {
                if (newHazardRegister.States == "2")
                {
                    isUpdate.RectificationTime     = DateTime.Now;
                    isUpdate.Rectification         = newHazardRegister.Rectification;
                    isUpdate.RectificationImageUrl = newHazardRegister.RectificationImageUrl;
                }
                else
                {
                    isUpdate.ConfirmDate         = DateTime.Now;
                    isUpdate.ConfirmMan          = newHazardRegister.ConfirmMan;
                    isUpdate.HandleIdea          = newHazardRegister.HandleIdea;
                    isUpdate.SafeSupervisionIsOK = newHazardRegister.SafeSupervisionIsOK;
                }

                isUpdate.States = newHazardRegister.States;
            }
            Funs.SubmitChanges();

            if (hazardRegister.States == Const.State_1)
            {
                APICommonService.SendSubscribeMessage(hazardRegister.ResponsibleMan, "安全巡检问题待整改", hazardRegister.CheckManName, string.Format("{0:yyyy-MM-dd HH:mm:ss}", hazardRegister.CheckTime));
            }
            else if (hazardRegister.States == Const.State_2)
            {
                APICommonService.SendSubscribeMessage(hazardRegister.CheckManId, "安全巡检待复查验收", hazardRegister.ResponsibilityManName, string.Format("{0:yyyy-MM-dd HH:mm:ss}", hazardRegister.RectificationTime));
            }
        }