public static tb_node_model GetOneNode(DbConn PubConn,int id)
 {
     tb_node_dal dal = new tb_node_dal();
     DataRow dr = dal.GetOneNode(PubConn, id);
     tb_node_model model = CreateModelForNode(dr);
     return model;
 }
 public static List<tb_node_model> GetNodeList(DbConn PubConn, string keyword, int pagesize, int pageindex, out int count)
 {
     DataSet ds = new tb_node_dal().GetList(PubConn, keyword, pagesize, pageindex, out count);
     List<tb_node_model> Model = new List<tb_node_model>();
     foreach (DataRow dr in ds.Tables[0].Rows)
     {
         tb_node_model m = CreateModelForNode(dr);
         Model.Add(m);
     }
     return Model;
 }
 public static int GetAvailableNode()
 {
     lock (k)
     {
         using (DbConn PubConn = DbConfig.CreateConn(Config.TaskConnectString))
         {
             PubConn.Open();
             int id = new tb_node_dal().GetAvailableNode(PubConn);
             return id;
         }
     }
 }
 public ActionResult Update(int id)
 {
     return this.Visit(Core.EnumUserRole.Admin, () =>
     {
         tb_node_dal dal = new tb_node_dal();
         using (DbConn PubConn = DbConfig.CreateConn(Config.TaskConnectString))
         {
             PubConn.Open();
             tb_node_model model = dal.GetOneNode(PubConn, id);
             return View(model);
         }
     });
 }
 public override void Run()
 {
     List<tb_node_model> models = new List<tb_node_model>();
     SqlHelper.ExcuteSql(Config.TaskConnectString, (c) => {
         Domain.Dal.tb_node_dal dal = new tb_node_dal();
         models = dal.GetAllStopNodesWithNeedCheckState(c);
     });
     foreach (var m in models)
     {
         LogHelper.AddError(new tb_error_model() { errorcreatetime=DateTime.Now, errortype=(int)XXF.BaseService.TaskManager.SystemRuntime.EnumTaskLogType.SystemError,
             msg=string.Format("当前节点:{0}【{1}】运行已经停止,请及时检查!",m.nodename,m.id),
             nodeid=m.id, taskid=0 });
     }
 }
 public ActionResult Update(tb_node_model model)
 {
     return this.Visit(Core.EnumUserRole.Admin, () =>
     {
         tb_node_dal Dal = new tb_node_dal();
         model.nodecreatetime = DateTime.Now;
         model.nodelastupdatetime = DateTime.Now;
         using (DbConn PubConn = DbConfig.CreateConn(Config.TaskConnectString))
         {
             PubConn.Open();
             Dal.Update(PubConn, model);
         }
         return RedirectToAction("index");
     });
 }
 public ActionResult Update(int id)
 {
     return this.Visit(Core.EnumUserRole.Admin, () =>
     {
         using (DbConn PubConn = DbConfig.CreateConn(Config.TaskConnectString))
         {
             PubConn.Open();
             tb_command_dal dal = new tb_command_dal();
             tb_command_model_Ex model = dal.GetOneCommand(PubConn, id);
             List<tb_node_model> Node = new tb_node_dal().GetListAll(PubConn);
             ViewBag.Node = Node;
             return View(model);
         }
     });
 }
 public ActionResult Add()
 {
     return this.Visit(Core.EnumUserRole.Admin, () =>
     {
         using (DbConn PubConn = DbConfig.CreateConn(Config.TaskConnectString))
         {
             PubConn.Open();
             List<tb_task_model> Task = new tb_task_dal().GetListAll(PubConn);
             List<tb_node_model> Node = new tb_node_dal().GetListAll(PubConn);
             ViewBag.Node = Node;
             ViewBag.Task = Task;
             return View();
         }
     });
 }
 protected override void Run()
 {
     SqlHelper.ExcuteSql(GlobalConfig.TaskDataBaseConnectString, (c) =>
     {
         var sqldatetime = c.GetServerDate();
         tb_node_dal nodedal = new tb_node_dal();
         nodedal.AddOrUpdate(c, new Domain.Model.tb_node_model()
         {
             nodecreatetime = sqldatetime, 
             nodeip=System.Net.Dns.GetHostName(),
             nodelastupdatetime = sqldatetime, 
             nodename="新增节点", 
             id=GlobalConfig.NodeID});
     });
     
 }
        //
        // GET: /Node/

        public ActionResult Index(string keyword, string CStime, string CEtime, int pagesize = 10, int pageindex = 1)
        {
            return this.Visit(Core.EnumUserRole.Admin, () =>
            {
                ViewBag.sqldatetimenow = DateTime.Now;
                tb_node_dal dal = new tb_node_dal();
                Webdiyer.WebControls.Mvc.PagedList<tb_node_model> pageList = null;
                int count = 0;
                using (DbConn PubConn = DbConfig.CreateConn(Config.TaskConnectString))
                {
                    PubConn.Open();
                    List<tb_node_model> List = dal.GetList(PubConn, keyword, CStime, CEtime, pagesize, pageindex, out count);
                    pageList = new PagedList<tb_node_model>(List, pageindex, pagesize, count);
                    ViewBag.sqldatetimenow = PubConn.GetServerDate();
                }
                return View(pageList);
            });
        }
 public ActionResult Log(string keyword, string CStime, string CEtime, int id = -1, int logtype = -1, int taskid = -1, int nodeid = -1, int pagesize = 10, int pageindex = 1)
 {
     return this.Visit(Core.EnumUserRole.None, () =>
     {
         ViewBag.keyword = keyword; ViewBag.CStime = CStime; ViewBag.CEtime = CEtime; ViewBag.id = id; ViewBag.logtype = logtype; ViewBag.taskid = taskid;
         ViewBag.nodeid = nodeid; ViewBag.pagesize = pagesize; ViewBag.pageindex = pageindex;
         int count = 0;
         using (DbConn PubConn = DbConfig.CreateConn(Config.TaskConnectString))
         {
             PubConn.Open();
             tb_log_dal dal = new tb_log_dal();
             List<tb_loginfo_model> model = dal.GetList(PubConn, keyword, id, CStime, CEtime, logtype, taskid, nodeid, pagesize, pageindex, out count);
             PagedList<tb_loginfo_model> pageList = new PagedList<tb_loginfo_model>(model, pageindex, pagesize, count);
             List<tb_task_model> Task = new tb_task_dal().GetListAll(PubConn);
             List<tb_node_model> Node = new tb_node_dal().GetListAll(PubConn);
             ViewBag.Node = Node;
             ViewBag.Task = Task;
             return View(pageList);
         }
     });
 }
        //
        // GET: /Command/

        public ActionResult Index(int taskid = -1, int commandstate = -1, int nodeid = -1, int pagesize = 10, int pageindex = 1)
        {
            return this.Visit(Core.EnumUserRole.Admin, () =>
            {
                ViewBag.taskid = taskid; ViewBag.commandstate = commandstate; ViewBag.nodeid = nodeid; ViewBag.pagesize = pagesize; ViewBag.pageindex = pageindex;
                tb_command_dal dal = new tb_command_dal();
                PagedList<tb_command_model_Ex> pageList = null;
                int count = 0;
                using (DbConn PubConn = DbConfig.CreateConn(Config.TaskConnectString))
                {
                    PubConn.Open();
                    List<tb_command_model_Ex> List = dal.GetList(PubConn, commandstate, taskid, nodeid, pagesize, pageindex, out count);
                    List<tb_task_model> Task = new tb_task_dal().GetListAll(PubConn);
                    List<tb_node_model> Node = new tb_node_dal().GetListAll(PubConn);
                    ViewBag.Node = Node;
                    ViewBag.Task = Task;
                    pageList = new PagedList<tb_command_model_Ex>(List, pageindex, pagesize, count);
                }
                return View(pageList);
            });
        }
 public JsonResult Delete(int id)
 {
     return this.Visit(Core.EnumUserRole.Admin, () =>
     {
         try
         {
             tb_node_dal dal = new tb_node_dal();
             using (DbConn PubConn = DbConfig.CreateConn(Config.TaskConnectString))
             {
                 PubConn.Open();
                 bool state = dal.DeleteOneNode(PubConn, id);
                 return Json(new { code = 1, state = state });
             }
         }
         catch (Exception ex)
         {
             return Json(new { code = -1, msg = ex.Message });
         }
     });
 }