Пример #1
0
 private List <JackTime2Run.JackJob> GetAllTask()
 {
     JackTime2Run.NamePipeSrvClient client = new JackTime2Run.NamePipeSrvClient();
     try
     {
         JackTime2Run.JackJob[] tasks = client.GetAllJobs();
         if (tasks == null)
         {
             MessageBox.Show("拉取当前任务计划失败,服务异常,请查看日志[" + AppDomain.CurrentDomain.BaseDirectory + "log\\SrvManage" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".log]", "服务异常", MessageBoxButtons.OK, MessageBoxIcon.Warning);
             checkBox1.Checked = false;
             return(new List <JackTime2Run.JackJob>());
         }
         return(tasks.ToList());
     }
     catch (Exception ex)
     {
         if (ex is System.ServiceModel.EndpointNotFoundException)
         {
             MessageBox.Show("拉取当前任务计划失败,请检查是否安装并启动了服务JackTime2Run!", "连接失败", MessageBoxButtons.OK, MessageBoxIcon.Warning);
         }
         else
         {
             MessageBox.Show(ex.ToString());
         }
         checkBox1.Checked = false;
         return(new List <JackTime2Run.JackJob>());
     }
 }
Пример #2
0
        /// <summary>获取完整的任务列表
        /// </summary>
        /// <returns></returns>
        private List <JackTime2Run.JackJob> GetAllTask()
        {
            try
            {
                if (cycle_client.State == System.ServiceModel.CommunicationState.Faulted)
                {
                    cycle_client = new JackTime2Run.NamePipeSrvClient();
                }

                if (cycle_client.State != System.ServiceModel.CommunicationState.Opened)
                {
                    cycle_client.Open();
                }
                JackTime2Run.JackJob[] tasks = cycle_client.GetAllJobs();
                //client.Close();
                //成功返回结果,图标变正常
                if (currentIcon == "disabled")
                {
                    JackTime2Run.Icon = normal;
                    currentIcon       = "normal";
                }
                if (tasks == null)
                {
                    MessageBox.Show("拉取当前任务计划失败,服务异常,请查看日志[" + AppDomain.CurrentDomain.BaseDirectory + "log\\SrvManage" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".log]", "服务异常", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    checkBox1.Checked = false;
                    return(new List <JackTime2Run.JackJob>());
                }
                return(tasks.ToList());
            }
            catch (Exception ex)
            {
                if (ex is System.ServiceModel.EndpointNotFoundException)
                {
                    MessageBox.Show("拉取当前任务计划失败,请检查是否安装并启动了服务JackTime2Run!", "连接失败", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
                else
                {
                    MessageBox.Show(ex.ToString());
                }

                this.BeginInvoke((Action)(() =>
                {
                    //出现异常,图标变灰色
                    if (currentIcon == "normal")
                    {
                        JackTime2Run.Icon = disabled;
                        currentIcon = "disabled";
                    }
                    checkBox1.Checked = false;
                }));
                return(new List <JackTime2Run.JackJob>());
            }
        }