public ActionResult Add(HttpPostedFileBase filedll) { if (filedll == null) { ModelState.AddModelError("Error", "请选择上传文件"); return(View()); } Stream dll = filedll.InputStream; byte[] dllbyte = new byte[dll.Length]; dll.Read(dllbyte, 0, Convert.ToInt32(dll.Length)); try { tb_cluster_collect_version_dal dal = new tb_cluster_collect_version_dal(); using (DbConn PubConn = DbConfig.CreateConn(Config.PlatformManageConnectString)) { PubConn.Open(); tb_cluster_collect_version_model model = new tb_cluster_collect_version_model() { versionnum = dal.GetMaxVersion(PubConn), versioncreatetime = DateTime.Now, zipfile = dllbyte, zipfilename = filedll.FileName }; dal.Add(PubConn, model); return(RedirectToAction("index")); } } catch (Exception ex) { ModelState.AddModelError("Error", ex.Message); return(View()); } }
public JsonResult EnableID(int id) { try { tb_cluster_collect_version_dal dal = new tb_cluster_collect_version_dal(); using (DbConn PubConn = DbConfig.CreateConn(Config.PlatformManageConnectString)) { PubConn.Open(); dal.ChangePerformVersion(PubConn, id); return(Json(new { code = 1, msg = "Success" })); } } catch (Exception ex) { return(Json(new { code = -1, msg = ex.Message })); } }
/// <summary> /// 任务的开启 /// </summary> /// <param name="taskid"></param> /// <returns></returns> public bool Start() { lock (_locktag) { if (TaskRunTimeInfo != null) { throw new Exception("采集任务已启动,启动失败"); } TaskRunTimeInfo = new TaskRuntimeInfo(); SqlHelper.ExcuteSql(CoreGlobalConfig.PlatformManageConnectString, (c) => { tb_cluster_collect_version_dal versiondal = new tb_cluster_collect_version_dal(); TaskRunTimeInfo.TaskVersionModel = versiondal.GetCurrentVersion(c); }); string filelocalcachepath = AppDomain.CurrentDomain.BaseDirectory.TrimEnd('\\') + "\\" + GlobalConfig.TaskDllCompressFileCacheDir + @"\" + TaskRunTimeInfo.TaskVersionModel.versionnum + @"\" + TaskRunTimeInfo.TaskVersionModel.zipfilename; string fileinstallpath = AppDomain.CurrentDomain.BaseDirectory.TrimEnd('\\') + "\\" + GlobalConfig.TaskDllDir + @"\"; string fileinstallmainclassdllpath = fileinstallpath + @"\" + "Dyd.BaseService.Monitor.Collect.exe"; XXF.Common.IOHelper.CreateDirectory(filelocalcachepath); XXF.Common.IOHelper.CreateDirectory(fileinstallpath); System.IO.File.WriteAllBytes(filelocalcachepath, TaskRunTimeInfo.TaskVersionModel.zipfile); CompressHelper.UnCompress(filelocalcachepath, fileinstallpath); try { var dlltask = new AppDomainLoader <BaseCollectMonitorDll>().Load(fileinstallmainclassdllpath, "Dyd.BaseService.Monitor.Collect.CollectMonitorDll", out TaskRunTimeInfo.Domain); dlltask.PlatformManageConnectString = CoreGlobalConfig.PlatformManageConnectString; dlltask.ServerIP = GlobalConfig.ServerIP; dlltask.TryStart(); LogHelper.Log("采集任务启动成功"); return(true); } catch (Exception exp) { DisposeTask(); throw exp; } } }
// // GET: /Manage/ClusterCollectVersion/ public ActionResult Index(int pagesize = 10, int pageindex = 1) { ViewBag.pagesize = pagesize; ViewBag.pageindex = pageindex; tb_cluster_collect_version_dal dal = new tb_cluster_collect_version_dal(); PagedList <tb_cluster_collect_version_model> pageList = null; int count = 0; using (DbConn PubConn = DbConfig.CreateConn(Config.PlatformManageConnectString)) { PubConn.Open(); List <tb_cluster_collect_version_model> List = dal.GetList(PubConn, pagesize, pageindex, out count); pageList = new PagedList <tb_cluster_collect_version_model>(List, pageindex, pagesize, count); ViewBag.MaxVersion = dal.GetMaxVersionNumber(PubConn); } if (Request.IsAjaxRequest()) { return(PartialView("List", pageList)); } return(View(pageList)); }
protected override void Run() { int maxversion = -1; DateTime sqltime = DateTime.Now; SqlHelper.ExcuteSql(CoreGlobalConfig.PlatformManageConnectString, (c) => { tb_cluster_collect_version_dal versiondal = new tb_cluster_collect_version_dal(); maxversion = versiondal.GetMaxVersionNumber(c); sqltime = c.GetServerDate(); }); if (maxversion > GlobalConfig.VersionNum) { GlobalConfig.LoadConfig(); if (GlobalConfig.TaskProvider.IsStart()) { GlobalConfig.TaskProvider.Stop(); } GlobalConfig.TaskProvider.Start(); GlobalConfig.VersionNum = maxversion; GlobalConfig.ClusterLastUpdateTime = sqltime; Core.LogHelper.Log(string.Format("服务器ip【{0}】采集任务dll新版本【" + maxversion + "】更新完毕", GlobalConfig.ServerIP)); } }
private void button1_Click(object sender, EventArgs e) { var d = DateTime.Parse("05 19 2015 7:55AM"); var o = 12; //List<CollectConfig> cc = new List<CollectConfig>(); //cc.Add(new CollectConfig(){ CollectName= "cpu", CategoryName = "Processor", CounterName= "% Processor Time",InstanceName= "_Total", // CollectType= CollectType.System, // EqualWarningValue=new EqualWarningValue(){ IsWarning=false, Value=""}, // LessThanWarningValue=new ContrastWarningValue(){ IsWarning=true, Value=0.2}, // MoreThanWarningValue=new ContrastWarningValue(){ IsWarning=true, Value=0.8}}); //cc.Add(new CollectConfig(){CollectName="内存",CategoryName= "Memory", CounterName="Available MBytes",InstanceName= "", // CollectType= CollectType.System, // EqualWarningValue=new EqualWarningValue(){ IsWarning=false, Value=""}, // LessThanWarningValue=new ContrastWarningValue(){ IsWarning=true, Value=0.2}, // MoreThanWarningValue=new ContrastWarningValue(){ IsWarning=true, Value=0.8}}); //cc.Add(new CollectConfig() //{ // CollectName = "网络发送/s", // CategoryName = "Network Interface", // CounterName = "Bytes Sent/sec", // InstanceName = "本地连接* 14", // CollectType = CollectType.System, // EqualWarningValue = new EqualWarningValue() { IsWarning = false, Value = "" }, // LessThanWarningValue = new ContrastWarningValue() { IsWarning = true, Value = 0.2 }, // MoreThanWarningValue = new ContrastWarningValue() { IsWarning = true, Value = 0.8 } //}); //cc.Add(new CollectConfig() //{ // CollectName = "网络下载/s", // CategoryName = "Network Interface", // CounterName = "Bytes Received/sec", // InstanceName = "本地连接* 14", // CollectType = CollectType.System, // EqualWarningValue = new EqualWarningValue() { IsWarning = false, Value = "" }, // LessThanWarningValue = new ContrastWarningValue() { IsWarning = true, Value = 0.2 }, // MoreThanWarningValue = new ContrastWarningValue() { IsWarning = true, Value = 0.8 } //}); //cc.Add(new CollectConfig() //{ // CollectName = "物理磁盘读字节/s", // CategoryName = "PhysicalDisk", // CounterName = "Disk Read Bytes/sec", // InstanceName = "_Total", // CollectType = CollectType.System, // EqualWarningValue = new EqualWarningValue() { IsWarning = false, Value = "" }, // LessThanWarningValue = new ContrastWarningValue() { IsWarning = true, Value = 0.2 }, // MoreThanWarningValue = new ContrastWarningValue() { IsWarning = true, Value = 0.8 } //}); //cc.Add(new CollectConfig() //{ // CollectName = "物理磁盘写字节/s", // CategoryName = "PhysicalDisk", // CounterName = "Disk Write Bytes/sec", // InstanceName = "_Total", // CollectType = CollectType.System, // EqualWarningValue = new EqualWarningValue() { IsWarning = false, Value = "" }, // LessThanWarningValue = new ContrastWarningValue() { IsWarning = true, Value = 0.2 }, // MoreThanWarningValue = new ContrastWarningValue() { IsWarning = true, Value = 0.8 } //}); //cc.Add(new CollectConfig() //{ // CollectName = "IIS请求/s", // CategoryName = "Web Service", // CounterName = "Current Connections", // InstanceName = "_Total", // CollectType = CollectType.System, // EqualWarningValue = new EqualWarningValue() { IsWarning = false, Value = "0" }, // LessThanWarningValue = new ContrastWarningValue() { IsWarning = true, Value = 0 }, // MoreThanWarningValue = new ContrastWarningValue() { IsWarning = true, Value = 100 } //}); //var str = new XXF.Serialization.JsonHelper().Serializer(cc); SqlHelper.ExcuteSql("server=192.168.17.201;Initial Catalog=dyd_bs_monitor_platform_manage;User ID=sa;Password=Xx~!@#;", (c) => { tb_cluster_collect_version_dal versiondal = new tb_cluster_collect_version_dal(); versiondal.Edit(c, new tb_cluster_collect_version_model() { id = 2, versionnum = 9, versioncreatetime = DateTime.Now, zipfile = System.IO.File.ReadAllBytes(@"E:\collect.rar"), zipfilename = "collect.rar" }); }); string text = @"aaaa"; DateTime dt1 = DateTime.Now; string hash = ELFHash(text) + ""; var mseconds = (DateTime.Now - dt1).TotalMilliseconds; DateTime dt2 = DateTime.Now; string hash2 = text.GetHashCode() + ""; var mseconds2 = (DateTime.Now - dt2).TotalMilliseconds; var a = 1; }