Exemplo n.º 1
0
        /// <summary>
        /// 任务列表刷新
        /// </summary>
        private void CurrentTaskList_Refresh()
        {
            List <TaskData> taskDatas = PublicDataContorl.GetTaskData();

            if (taskDatas == null)
            {
                currentTaskList.Items.Clear();
                return;
            }

            currentTaskList.BeginUpdate();
            currentTaskList.Items.Clear();
            //foreach (var data in taskDatas)
            //{
            //    if(data != null)
            //    {
            //        ListViewItem item = new ListViewItem(data.NO + ""); // 任务信息
            //        //item.Text = data.NO + "" ;
            //        item.SubItems.Add(data.Msg); //站点信息
            //        item.SubItems.Add(data.SiteMsg); //站点信息
            //        currentTaskList.Items.Add(item);
            //    }

            //}
            for (int i = 0; i < taskDatas.Count; i++)
            {
                ListViewItem item = new ListViewItem(taskDatas[i].NO + ""); // 任务信息
                //item.Text = taskDatas[i].NO + "" ;
                item.SubItems.Add(taskDatas[i].Msg);                        //站点信息
                item.SubItems.Add(taskDatas[i].SiteMsg);                    //站点信息
                currentTaskList.Items.Add(item);
            }
            // 结束数据处理
            currentTaskList.EndUpdate();

            if (_currentTaskIndex != -1)
            {
                if (currentTaskList.Items.Count > _currentTaskIndex && _currentTaskText.Equals(currentTaskList.Items[_currentTaskIndex].Text))
                {
                    currentTaskList.FocusedItem = currentTaskList.Items[_currentTaskIndex];
                    currentTaskList.Items[_currentTaskIndex].BackColor = Color.LightGray;
                    return;
                }

                foreach (ListViewItem item in currentTaskList.Items)
                {
                    if (item.Text.Equals(_currentTaskText))
                    {
                        currentTaskList.FocusedItem           = item;
                        currentTaskList.FocusedItem.BackColor = Color.LightGray;
                        return;
                    }
                }
                _currentTaskIndex = -1;
                _currentTaskText  = "";
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// 停止选中的任务
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void taskStopBtn_Click(object sender, EventArgs e)
        {
            if (currentTaskList.FocusedItem == null)
            {
                MessageBox.Show("请选择任务");
                return;
            }

            PublicDataContorl.StopTask(int.Parse(currentTaskList.FocusedItem.Text));
        }
Exemplo n.º 3
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="no"></param>
 public void StopTask(int no)
 {
     lock (_ans)
     {
         F_ExcTask excTask = _taskList.Find(c => { return(c.NO == no); });
         if (excTask != null && _taskList.Contains(excTask))
         {
             LogFactory.LogAdd(LOGTYPE.FINISH, excTask.Id, excTask.GetTaskInfo(), "调度终止", excTask.GetTaskInfo());//任务完成日志
             PublicDataContorl.TaskIsSucc(excTask.NO);
             excTask.ISetTaskSuc();
             _taskList.Remove(excTask);
         }
     }
 }
Exemplo n.º 4
0
        /// <summary>
        /// 删除一个任务
        /// </summary>
        /// <param name="Id"></param>
        public void IDeletTask(string Id)
        {
            lock (_ans)
            {
                F_ExcTask exit = _taskList.Find(c => { return(c.Id == Id); });

                if (exit != null && _taskList.Contains(exit))
                {
                    LogFactory.LogAdd(LOGTYPE.FINISH, exit.Id, exit.GetTaskInfo(), "调度完成", exit.GetTaskInfo());//任务完成日志
                    PublicDataContorl.TaskIsSucc(exit.NO);
                    _taskList.Remove(exit);
                }
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// 开始一个新的操作任务
        /// </summary>
        /// <param name="task"></param>
        /// <returns></returns>
        public bool IStartTask(F_ExcTask task, String msg)
        {
            lock (_ans)
            {
                F_ExcTask exit = _taskList.Find(c => { return((c.Plc == task.Plc && task.Plc != null) || c.Id == task.Id); });

                if (exit == null)
                {
                    _taskList.Add(task);
                    PublicDataContorl.AddTaskData(new TaskData(task.NO, msg, task.StartSite + "," + task.EndSite));
                    return(true);
                }
            }

            return(false);
        }
Exemplo n.º 6
0
        /// <summary>
        /// 开始一个新的操作任务
        /// </summary>
        /// <param name="task"></param>
        /// <returns></returns>
        public bool IStartTask(F_ExcTask task, String msg)
        {
            lock (_ans)
            {
                F_ExcTask exit = _taskList.Find(c =>
                {
                    return //(c.Plc == task.Plc && task.Plc != null) ||
                    (c.Id == task.Id);
                });

                if (exit == null)
                {
                    _taskList.Add(task);
                    FLog.Log(task.Id + "加入任务列表");
                    PublicDataContorl.AddTaskData(new TaskData(task.NO, msg, task.StartSite + "," + task.EndSite));
                    return(true);
                }
                else if (task.EndSite != exit.EndSite)
                {
                    _taskList.Remove(exit);
                    FLog.Log(exit.Id + "移除任务列表");
                    PublicDataContorl.TaskIsSucc(exit.NO);
                    _taskList.Add(task);
                    FLog.Log(task.Id + "加入任务列表");
                    PublicDataContorl.AddTaskData(new TaskData(task.NO, msg, task.StartSite + "," + task.EndSite));
                    return(true);
                }
                else if (task.StartSite != exit.StartSite)
                {
                    _taskList.Remove(exit);
                    FLog.Log(exit.Id + "移除任务列表");
                    PublicDataContorl.TaskIsSucc(exit.NO);
                    _taskList.Add(task);
                    FLog.Log(task.Id + "加入任务列表");
                    PublicDataContorl.AddTaskData(new TaskData(task.NO, msg, task.StartSite + "," + task.EndSite));
                    return(true);
                }
                else
                {
                    return(true);
                }
            }
        }