예제 #1
0
        public object BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext)
        {
            var stream = controllerContext.RequestContext.HttpContext.Request.InputStream;

            stream.Seek(0, SeekOrigin.Begin);
            string json = new StreamReader(stream).ReadToEnd();

            return(SerializerHelper.DeserializeObjectByJsonConvert <UpdateFilter>(json));
        }
예제 #2
0
 public static List <NavigationViewModel> GetNavigations()
 {
     using (FileStream fs = File.Open(mNavigationConfig, FileMode.Open, FileAccess.Read, FileShare.Read))
     {
         byte[] buffer = new byte[fs.Length];
         fs.Read(buffer, 0, buffer.Length);
         string config = Encoding.Default.GetString(buffer);
         return(SerializerHelper.DeserializeObjectByJsonConvert <List <NavigationViewModel> >(config));
     }
 }
예제 #3
0
        public override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            DatabaseConfigViewModel databaseConfig = filterContext.ActionParameters.Keys.Contains(Constant.DATABASE_CONFIG) ? filterContext.ActionParameters[Constant.DATABASE_CONFIG] as DatabaseConfigViewModel : null;

            if (databaseConfig == null)
            {
                databaseConfig = SerializerHelper.DeserializeObjectByJsonConvert <DatabaseConfigViewModel>(filterContext.HttpContext.Request.Headers[Constant.DATABASE_CONFIG]);
            }
            if (databaseConfig != null)
            {
                DBConnect dbConnect = new DBConnect()
                {
                    Address = databaseConfig.Address, Port = databaseConfig.Port, Userename = databaseConfig.Username, Password = Base64.Decrypt(databaseConfig.Password)
                };
                ServiceFactory.Register(databaseConfig.Type, dbConnect);
                this.mIsInject = true;
            }
        }
예제 #4
0
        public void Execute(SQLAdmin.TimerContract.Schedule schedule)
        {
            Monitor monitor = SerializerHelper.DeserializeObjectByJsonConvert <Monitor>(schedule.Context);
            SQLServerReportService reportService = new SQLServerReportService(monitor.DBConnect);
            CPUViewModel           cpu           = reportService.GetCPUInfos().FirstOrDefault();
            int used = cpu.DBProess + cpu.OtherProcess;

            if (used > monitor.Threshold)
            {
                Email email = new Email()
                {
                    To = new List <string>()
                    {
                        monitor.ToEmail
                    },
                    Subject = "CPU 警报",
                    Body    = $"Server:{monitor.DBConnect.Address},当前CPU使用率为:{used}%"
                };
                EmailHelper.SendEmail(email);
            }
        }