Exemple #1
0
        public IList <CV_PM_ALT_BASE_QuaryParam> getAllAltBase()
        {
            IList <CV_PM_ALT_BASE>            list      = new List <CV_PM_ALT_BASE>();
            IList <CV_PM_ALT_BASE_QuaryParam> listQuary = new List <CV_PM_ALT_BASE_QuaryParam>();

            try
            {
                list = cv_PM_ALT_BASEBO.GetEntities();
                if (list == null || list.Count == 0)
                {
                    return(listQuary);
                }

                for (int i = 0; i < list.Count; i++)
                {
                    CV_PM_ALT_BASE_QuaryParam Entity = new CV_PM_ALT_BASE_QuaryParam();
                    Entity.AlertID         = list[i].AlertID;
                    Entity.AlertName       = list[i].AlertName;
                    Entity.AlertAlias      = list[i].AlertAlias;
                    Entity.AlertDesc       = list[i].AlertDesc;
                    Entity.AlertContent    = list[i].AlertContent;
                    Entity.Category        = list[i].Category;
                    Entity.AlertType       = list[i].AlertType;
                    Entity.Format          = list[i].Format;
                    Entity.AlertObject     = list[i].AlertObject;
                    Entity.PreProcedure    = list[i].PreProcedure;
                    Entity.PostProcedure   = list[i].PostProcedure;
                    Entity.AlertInterval   = list[i].AlertInterval;
                    Entity.AlertTimePoints = list[i].AlertTimePoints;
                    Entity.LastAlertedTime = list[i].LastAlertedTime;
                    Entity.IsActive        = list[i].IsActive;
                    Entity.CIsActive       = list[i].CIsActive;
                    Entity.RowDeleted      = list[i].RowDeleted;
                    Entity.CreatedBy       = list[i].CreatedBy;
                    Entity.CreatedOn       = list[i].CreatedOn;
                    Entity.ModifiedBy      = list[i].ModifiedBy;
                    Entity.ModifiedOn      = list[i].ModifiedOn;
                    Entity.SqlScript       = list[i].SqlScript;
                    Entity.URL             = list[i].URL;

                    if (list[i].AlertType.ToString() == "1")
                    {
                        Entity.alertTypeName = "邮件";
                    }
                    else if (list[i].AlertType.ToString() == "2")
                    {
                        Entity.alertTypeName = "微信";
                    }
                    listQuary.Add(Entity);
                }
                if (listQuary.Count > 0)
                {
                    listQuary = listQuary.OrderByDescending(c => c.ModifiedOn).ToList();
                }
                return(listQuary);
            }
            catch (Exception e)
            {
                throw e;
            }
        }
Exemple #2
0
        public string InsertBase(PM_ALT_BASE entity)
        {
            if (entity == null)
            {
                return("预警内容为空");
            }
            if (entity.AlertInterval.HasValue)
            {
                if (entity.AlertInterval < 10)
                {
                    return("执行间隔不能低于10秒");
                }
            }
            if (!string.IsNullOrEmpty(entity.AlertTimePoints))
            {
                foreach (string fixedTimer in entity.AlertTimePoints.Split(','))
                {
                    if (string.IsNullOrEmpty(fixedTimer.Trim()))
                    {
                        continue;
                    }

                    string   strTime  = string.Format("2000-01-01 {0}:00", fixedTimer.Trim());
                    DateTime dateTime = new DateTime();
                    bool     result   = DateTime.TryParse(strTime, out dateTime);
                    if (!result)
                    {
                        return("执行时间点格式错误");
                    }
                }
            }
            PM_ALT_BASE exist = pm_ALT_BASEBO.GetEntity(entity.AlertName);

            if (exist == null || exist.AlertID == null)
            {
                //nothing
            }
            else
            {
                return("预警名称已存在");
            }

            IList <CV_PM_ALT_BASE_QuaryParam> list      = new List <CV_PM_ALT_BASE_QuaryParam>();
            CV_PM_ALT_BASE_QuaryParam         cvAltBace = new CV_PM_ALT_BASE_QuaryParam();

            entity.AlertID    = Guid.NewGuid();
            entity.CreatedOn  = SSGlobalConfig.Now;
            entity.ModifiedOn = entity.CreatedOn;
            entity.RowDeleted = false;

            try
            {
                PM_ALT_BASE altBase = new PM_ALT_BASE();
                altBase = pm_ALT_BASEBO.Insert(entity);

                cvAltBace.AlertAlias      = altBase.AlertAlias;
                cvAltBace.AlertContent    = altBase.AlertContent;
                cvAltBace.AlertDesc       = altBase.AlertDesc;
                cvAltBace.AlertID         = altBase.AlertID;
                cvAltBace.AlertInterval   = altBase.AlertInterval;
                cvAltBace.AlertName       = altBase.AlertName;
                cvAltBace.AlertObject     = altBase.AlertObject;
                cvAltBace.AlertTimePoints = altBase.AlertTimePoints;
                cvAltBace.AlertType       = altBase.AlertType;
                cvAltBace.Category        = altBase.Category;
                cvAltBace.CreatedBy       = altBase.CreatedBy;
                cvAltBace.CreatedOn       = altBase.CreatedOn;
                cvAltBace.Format          = altBase.Format;
                cvAltBace.IsActive        = altBase.IsActive;
                cvAltBace.LastAlertedTime = altBase.LastAlertedTime;
                cvAltBace.ModifiedBy      = altBase.ModifiedBy;
                cvAltBace.ModifiedOn      = altBase.ModifiedOn;
                cvAltBace.PostProcedure   = altBase.PostProcedure;
                cvAltBace.PreProcedure    = altBase.PreProcedure;
                cvAltBace.RowDeleted      = altBase.RowDeleted;
                cvAltBace.URL             = altBase.URL;

                if (altBase.AlertType.ToString() == "1")
                {
                    cvAltBace.alertTypeName = "邮件";
                }
                else if (altBase.AlertType.ToString() == "2")
                {
                    cvAltBace.alertTypeName = "微信";
                }
                list.Add(cvAltBace);

                return("OK");
            }
            catch (Exception ex)
            {
                return("新增异常:" + ex.Message);
            }
        }