Exemple #1
0
        public void Run(Models.ServerModel server, Models.SchtaskModel schtask)
        {
            var    isLocal = Commons.NetHelper.IsLocalIPAddress(server.IP);
            string cmd;

            if (isLocal)
            {
                cmd = string.Format("schtasks /run /tn {0}", schtask.TaskName);
            }
            else
            {
                cmd = string.Format("schtasks /run /s {0} /u {1} /p {2} /tn {3}", server.IP, server.UserName, server.Password, schtask.TaskName);
            }

            var result = CmdHelper.ExecuteCmd(cmd).ToLower();

            if (result.Contains("成功") || result.Contains("success"))
            {
                schtask.TaskStatus = Models.SchtaskStatus.Executed;
            }
            else
            {
                schtask.TaskStatus = Models.SchtaskStatus.Failed;
            }
        }
Exemple #2
0
        public void CreateTask(Models.ServerModel server, Models.SchtaskModel schtask)
        {
            string time    = DateTime.Now.AddMinutes(-10).ToString("HH:mm");
            var    isLocal = Commons.NetHelper.IsLocalIPAddress(server.IP);

            string cmd;

            if (isLocal)
            {
                cmd = string.Format("schtasks /create /tn {0} /tr {1} /sc once /st {2}", schtask.TaskName, schtask.TaskPath, time);
            }
            else
            {
                cmd = string.Format("schtasks /create /s {0} /u {1} /p {2} /tn {3} /tr {4} /sc once /st {5}", server.IP, server.UserName, server.Password, schtask.TaskName, schtask.TaskPath, time);
            }
            var result = CmdHelper.ExecuteCmd(cmd);

            if (result.Contains("成功") || result.ToLower().Contains("success"))
            {
                schtask.TaskStatus = Models.SchtaskStatus.Exist;
            }
            else
            {
                schtask.TaskStatus = Models.SchtaskStatus.Failed;
            }
        }
Exemple #3
0
        public void Query(Models.ServerModel server, Models.SchtaskModel schtask)
        {
            var    isLocal = Commons.NetHelper.IsLocalIPAddress(server.IP);
            string cmd;

            //string chcp437 = "chcp 437";
            //CmdHelper.ExecuteCmd(chcp437);
            if (isLocal)
            {
                cmd = string.Format("schtasks /query /tn {0}", schtask.TaskName);
            }
            else
            {
                cmd = string.Format("schtasks /query /s {0} /u {1} /p {2} /tn {3}", server.IP, server.UserName, server.Password, schtask.TaskName);
            }

            var result = CmdHelper.ExecuteCmd(cmd).ToLower();

            if (result.Contains("任务名") || result.Contains("folder"))
            {
                schtask.TaskStatus = Models.SchtaskStatus.Exist;
            }
            else
            {
                schtask.TaskStatus = Models.SchtaskStatus.NotExist;
            }
        }
Exemple #4
0
 private void btn_save_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         ServerModel            = new Models.ServerModel();
         ServerModel.IP         = txt_ip.Text;
         ServerModel.Mac        = txt_mac.Text;
         ServerModel.Mode       = (Models.ServerMode)Enum.Parse(typeof(Models.ServerMode), txt_mode.SelectedValue.ToString());
         ServerModel.Password   = txt_password.Text;
         ServerModel.ServerName = txt_servername.Text;
         ServerModel.State      = Models.ServerState.Off;
         ServerModel.UserName   = txt_username.Text;
         this.Close();
     }
     catch (Exception)
     {
     }
 }