Example #1
0
        private void ForeachRun()
        {
            //1.取数据
            Tdms_WinserviceCollection daWinServiceColl = new Tdms_WinserviceCollection();

            daWinServiceColl.ListByNextTime();
            Log.Info("待监控SQL[" + daWinServiceColl.Count + "]条");
            if (daWinServiceColl.Count <= 0)
            {
                Log.Info("没有需要监控的数据,进入休眠30秒");
                Thread.Sleep(millisecondsTimeout: 30000);
                return;
            }
            //2.监控
            foreach (Tdms_Winservice item in daWinServiceColl)
            {
                Tdms_Info daInfo = new Tdms_Info(item.DataRow);
                Log.Info("[" + daInfo.Title + "]开始监控");
                //调用执行方法
                Run(daInfo, item);
                //修改
                if (!item.Update())
                {
                    Log.Error("修改失败");
                }
                string endInfo = string.Format("[{0}]监控结束(监控到[{1}]行数据)", daInfo.Title, item.RunResult);
                Log.Info(endInfo);

                NoticeFacade notiFace = new NoticeFacade();
                notiFace.IsEixt(item, daInfo);
            }
            Log.Info("监控完成");
        }
Example #2
0
 public ActionResult Execute(int Id)
 {
     try
     {
         Tdms_Info daInfo = new Tdms_Info();
         if (!daInfo.SelectByPK(Id))
         {
             return(FailResult("该记录不存在"));
         }
         string SqlContext = daInfo.SqlContext;
         if (string.IsNullOrEmpty(SqlContext))
         {
             return(FailResult("sql语句为空,无法执行"));
         }
         MSQL sqlFacade = new MSQL();
         int  count;
         if (!sqlFacade.ExecuteSQL(SqlContext, out count))
         {
             return(FailResult(sqlFacade.PromptInfo.MessageStack));
         }
         if (count > 0 || count == 0)
         {
             return(FailResult("监控到" + count + "条非法数据!"));
         }
         return(SuccessResult());
     }
     catch (Exception ex)
     {
         return(FailResult("执行SQL出现异常:" + ex.Message));
     }
 }
Example #3
0
        public void SendType(Tdms_Admin taAdmin, Tdms_Info daInfo, Tdms_Winservice item)
        {
            Vnet_Reginfo daVinfo = new Vnet_Reginfo();

            if (!daVinfo.SelectByPK(taAdmin.NodeId))
            {
                return;
            }
            //TODO:接入消息中心,此方法屏蔽掉,直接新建一个类似的方法
            //装饰者
            NotifyAdmin notify = new NotifyAdmin();

            //装饰EMail发送功能
            notify           = EMailNotify.New(notify);
            notify.Address   = taAdmin.Email;
            notify.RunResult = item.RunResult;
            notify.Content   = string.Format("[{0}]{2}监控到{1}条非法数据。", daInfo.Title, item.RunResult, DateTime.Now.ToString("MM月dd日"));

            if ((taAdmin.SendType & SqlSendType.短信) == SqlSendType.短信)
            {
                if ((taAdmin.IsSend == SqlIsSend.发送) ||
                    (DateTime.Now.Hour >= 8))
                {
                    //装饰短信发送功能
                    notify         = SMSNotify.New(notify);
                    notify.Address = daVinfo.Mobileno;
                }
            }
            notify.Send();
        }
Example #4
0
 public void IsEixt(Tdms_Winservice item, Tdms_Info daInfo)
 {
     if (item.RunResult > 0)
     {
         IsSend(item, daInfo);
     }
 }
Example #5
0
        /// <summary>
        /// 验证数据
        /// </summary>
        /// <returns></returns>
        private bool SaveVerify()
        {
            Tdms_Info daIndo = new Tdms_Info();

            if (!daIndo.SelectByPK(this.DAL.Id))
            {
                Alert("此条SQL语句不存在!");
                return(false);
            }
            return(true);
        }
Example #6
0
        public ActionResult Delete(int Id)
        {
            Tdms_Info daInfo = new Tdms_Info();

            if (!daInfo.SelectByPK(Id))
            {
                return(FailResult("此记录已不存在"));
            }

            ViewBag.Id = Id;
            return(View());
        }
Example #7
0
        public ActionResult Delete()
        {
            int       channelId = Request.Form["channelId"].Safe().ToInt32();
            Tdms_Info daInfo    = new Tdms_Info();

            if (daInfo.SelectByChannelId(channelId))
            {
                return(FailResult("该栏目下有监控数据无法删除!"));
            }
            Channel dachannel = new Channel(channelId);

            if (!dachannel.Delete())
            {
                return(FailResult("删除失败!原因:" + dachannel.PromptInfo.MessageStack));
            }
            return(SuccessResult());
        }
Example #8
0
        public bool IsSend(Tdms_Winservice item, Tdms_Info daInfo)
        {
            //Tdms_Admin daAdmin = new Tdms_Admin();
            //if (!daAdmin.SelectByInfoId(item.Id))
            //{
            //    Log.Error("[" + daInfo.Title + "]没有管理员!");
            //    return false;
            //}
            Tdms_AdminCollection daAdminColl = new Tdms_AdminCollection();

            daAdminColl.ListByInfoId(item.Id);
            foreach (Tdms_Admin taAdmin in daAdminColl)
            {
                SendType(taAdmin, daInfo, item);
            }
            return(true);
        }
Example #9
0
 public bool Run(Tdms_Info daInfo, Tdms_Winservice item)
 {
     try
     {
         MSQL sql = new MSQL();
         int  count;
         if (!sql.ExecuteSQL(daInfo.SqlContext, out count))
         {
             Log.Error("SQL语句有误");
             Failure(item);
             return(false);
         }
         Success(item, count);
         return(true);
     }
     catch (Exception ex)
     {
         Log.Error(ex.Message);
         Failure(item);
         return(false);
     }
 }
Example #10
0
        public ActionResult Delete()
        {
            int        id      = Request.Form["Id"].Safe().ToInt32();
            Tdms_Admin daAdmin = new Tdms_Admin();

            if (daAdmin.SelectByInfoId(id))
            {
                return(FailResult("该记录已有管理员监控无法删除!"));
            }
            Tdms_Info daInfo = new Tdms_Info();

            if (!daInfo.SelectByPK(id))
            {
                return(FailResult("此记录已不存在"));
            }

            if (!daInfo.Delete(id))
            {
                return(FailResult("删除失败!原因:" + daInfo.PromptInfo.MessageStack));
            }

            return(SuccessResult());
        }