public NewTaskWindow(EditMode editMode, TaskScheduler taskScheduler)
        {
            InitializeComponent();
            this._App = ((ManagerConsole.MainWindow)Application.Current.MainWindow);
            this._EditMode = editMode;

            if (this._EditMode == EditMode.AddNew)
            {
                this._TaskScheduler = new TaskScheduler();
                this._TaskScheduler.IsEditorName = true;
                this.LoadParameterSetting();
            }
            else
            {
                this._EditorTaskScheduler = taskScheduler.Clone();
                this.SettingsUIBinding();
            }
            this._IsLoaded = true;
        }
 public void UpdateTaskScheduler(TaskScheduler taskScheduler)
 {
     foreach (TaskScheduler task in this._TaskSchedulers)
     {
         if (task.Id == taskScheduler.Id)
         {
             task.Update(taskScheduler);
             return;
         }
     }
 }
 public void LoadTaskSchedulers()
 {
     if (!this._IsGetTaskData)
     {
         ConsoleClient.Instance.GetTaskSchedulersData(delegate(List<CommonTaskScheduler> taskSchedulers)
         {
             foreach (CommonTaskScheduler commonTaskScheduler in taskSchedulers)
             {
                 TaskScheduler taskScheduler = new TaskScheduler(commonTaskScheduler);
                 this._TaskSchedulers.Add(taskScheduler);
             }
         });
     }
 }
 public void ChangeTaskStatus(TaskScheduler taskScheduler,bool isDisable)
 {
     taskScheduler.TaskStatus = isDisable? TaskStatus.Disable:TaskStatus.Ready;
 }
 public void AddTaskScheduler(TaskScheduler taskScheduler)
 {
     this._TaskSchedulers.Add(taskScheduler);
 }
        //Modify Completed Update
        internal void Update(TaskScheduler newTaskScheduler)
        {
            this.ExchangeCode = newTaskScheduler.ExchangeCode;
            this.Name = newTaskScheduler.Name;
            this.Description = newTaskScheduler.Description;
            this.TaskStatus = newTaskScheduler.TaskStatus;
            this.RecurDay = newTaskScheduler.RecurDay;
            this.Interval = newTaskScheduler.Interval;
            this.ActionType = newTaskScheduler.ActionType;
            this.TaskType = newTaskScheduler.TaskType;
            this.CreateDateTime = newTaskScheduler.CreateDateTime;
            this.RunTime = newTaskScheduler.RunTime;
            this.LastRunTime = newTaskScheduler.LastRunTime;

            this.ParameterSettings = newTaskScheduler.ParameterSettings;

            this.ParameterSettings.Clear();
            this.ExchangInstruments.Clear();

            foreach (ParameterSetting setting in newTaskScheduler.ParameterSettings)
            {
                this.ParameterSettings.Add(setting.Clone());
            }
            foreach (ExchangInstrument entity in newTaskScheduler.ExchangInstruments)
            {
                this.ExchangInstruments.Add(entity);
            }
        }
        internal TaskScheduler Clone()
        {
            TaskScheduler taskScheduler = new TaskScheduler();

            taskScheduler.Id = this.Id;
            taskScheduler.ExchangeCode = this.ExchangeCode;
            taskScheduler.Name = this.Name;
            taskScheduler.Description = this.Description;
            taskScheduler.TaskStatus = this.TaskStatus;
            taskScheduler.ActionType = this.ActionType;
            taskScheduler.RecurDay = this.RecurDay;
            taskScheduler.Interval = this.Interval;
            taskScheduler.TaskType = this.TaskType;
            taskScheduler.CreateDateTime = this.CreateDateTime;
            taskScheduler.RunTime = this.RunTime;
            taskScheduler.LastRunTime = this.LastRunTime;
            taskScheduler.WeekDays = this.WeekDays;
            taskScheduler.WeekDaySN = this.WeekDaySN;

            foreach (ParameterSetting setting in this.ParameterSettings)
            {
                taskScheduler.ParameterSettings.Add(setting.Clone());
            }

            foreach (ExchangInstrument entity in this.ExchangInstruments)
            {
                taskScheduler.ExchangInstruments.Add(entity);
            }

            return taskScheduler;
        }
 private void CreateTaskCompleted(EditMode editMode,TaskScheduler taskScheduler)
 {
     if (editMode == EditMode.AddNew)
     {
         this._TaskSchedulerModel.AddTaskScheduler(taskScheduler);
     }
     else
     {
         this._TaskSchedulerModel.UpdateTaskScheduler(taskScheduler);
     }
 }
 private void StartRunTaskScheduler(TaskScheduler taskScheduler)
 {
     CommonTaskScheduler commonTaskScheduler = taskScheduler.ToCommonTaskScheduler();
     ConsoleClient.Instance.StartRunTaskScheduler(commonTaskScheduler, this.StartRunTaskCallback);
 }
 private void ShowNewTaskWindow(EditMode ditorMode,TaskScheduler taskScheduler)
 {
     this._NewTaskWindow = new NewTaskWindow(ditorMode, taskScheduler);
     this._NewTaskWindow.OnConfirmDialogResult += new NewTaskWindow.ConfirmDialogResultHandle(this.CreateTaskCompleted);
     App.MainFrameWindow.MainFrame.Children.Add(this._NewTaskWindow);
     this._NewTaskWindow.IsModal = true;
     this._NewTaskWindow.Show();
 }
 private void EnableTaskScheduler(TaskScheduler taskScheduler)
 {
     this._TaskSchedulerModel.ChangeTaskStatus(taskScheduler,false);
     CommonTaskScheduler commonTaskScheduler = taskScheduler.ToCommonTaskScheduler();
     ConsoleClient.Instance.EnableTaskScheduler(commonTaskScheduler);
 }
 private void DisableTaskScheduler(TaskScheduler taskScheduler)
 {
     this._TaskSchedulerModel.ChangeTaskStatus(taskScheduler,true);
     CommonTaskScheduler commonTaskScheduler = taskScheduler.ToCommonTaskScheduler();
     ConsoleClient.Instance.DeleteTaskScheduler(commonTaskScheduler,this.DeleteTaskSchedulerCallback);
 }
 private void DeleteTaskScheduler(TaskScheduler taskScheduler)
 {
     CommonTaskScheduler commonTaskScheduler = taskScheduler.ToCommonTaskScheduler();
     ConsoleClient.Instance.DeleteTaskScheduler(commonTaskScheduler, this.DeleteTaskSchedulerCallback);
 }