public ITaskObserver BeginTask(ITaskType taskType, string taskDescription = null, bool exposed = true, bool indeterminate = true) { if (taskType == null) { throw new ArgumentNullException(nameof(taskType)); } ITaskObserver observer = new TaskObserver(taskType, taskDescription, exposed); OnTaskCreated(observer); observer.Status = TaskObserveStatus.Running; observer.StartTime = DateTime.Now; if (indeterminate) { observer.Progress = TaskObserver.TaskIndeterminate; } lock (_runningObservers) { _runningObservers.Add(observer); } return(observer); }
public Task(IRequirement parent, ITaskType type) { Parent = parent; Type = type; Siblings = new List <ITask>(); Attachments = new List <IAttachment>(); }
public IEnumerable <ITaskObserver> GetTasks(ITaskType taskType) { lock (_runningObservers) { return(_runningObservers.Where(observer => observer.Type == taskType && observer.Exposed)); } }
public TaskObserver(ITaskType type, string description = null, bool exposed = true) { if (type == null) { throw new ArgumentNullException(nameof(type)); } Type = type; Description = description; Exposed = exposed; }
public ITask CreateTask(ITaskConfig config, ITaskType type) { if (config == null || !config.Enabled) { return(null); } lock (mTasks.SyncRoot) { CTask task = mTasks[config.Name] as CTask; if (task == null) { if (type == null) { type = mSystemContext.TaskTypeManager.GetConfig(config.Type); } if (type != null && type.Enabled && !type.TaskClass.Equals("")) { if (!type.FileName.Equals("")) { task = CommonUtil.CreateInstance(SystemContext, type.FileName, type.TaskClass) as CTask; } else { task = CommonUtil.CreateInstance(type.TaskClass) as CTask; } } if (task != null) { if (task.Init(this, config, type)) { task.OnTaskStateChanged += new TaskStateChanged(DoTaskStateChanged); //task.OnBeforeTask += new TaskEvent(DoBeforeTask); //task.OnAfterTask += new TaskEvent(DoAfterTask); mTasks.Add(task.Name, task); task.RefreshState(); } else { return(null); } } } else { task.Config = config; } return(task); } }
public ITask CreateTask(ITaskConfig config) { if (config != null) { ITaskType type = mSystemContext.TaskTypeManager.GetConfig(config.Type); return(CreateTask(config, type)); } else { return(null); } }
public void ShowAddDialog(ITaskType type) { Text = "新增任务模块"; mIsOk = false; mManager = type.SystemContext.TaskConfigManager; mType = type; mConfig = null; InitTypeList(mManager.SystemContext); InitSchedulerList(mManager.SystemContext); InitActionList(mManager.SystemContext); if (InitDialog()) { ShowDialog(); } }
public void ShowAddDialog(IConfigManager <ITaskType> manager) { Text = "新增任务类型"; mIsOk = false; mConfig = null; mManager = manager; if (mManager.SystemContext.MonitorSystem.Verify(manager.TypeName, "计划任务", (ushort)ACOpts.Manager_Add, false)) { if (InitDialog()) { ShowDialog(); } } }
public override void ShowEditDialog(IConfig config) { Text = "编辑任务类型 - [" + config.Name + "]"; mIsOk = false; mManager = null; mConfig = config as ITaskType; if (config.Verify(ACOpts.Manager_Modify, false)) { if (InitDialog()) { ShowDialog(); } } }
public override void ShowEditDialog(IConfig config) { Text = "编辑任务模块 - [" + config.Name + "]"; mIsOk = false; mManager = null; mType = null; mConfig = config as ITaskConfig; if (config.Verify(ACOpts.Manager_Modify, false)) { InitTypeList(config.SystemContext); InitSchedulerList(config.SystemContext); InitActionList(config.SystemContext); if (InitDialog()) { ShowDialog(); } } }
protected bool SetConfig() { if (mConfig == null && mManager != null) { mConfig = mManager.CreateConfigInstance(); } if (mConfig != null) { (mConfig as CConfig).Name = textBox_name.Text; mConfig.SetValue("Name", textBox_name.Text); mConfig.Desc = textBox_desc.Text; mConfig.ConfigClass = textBox_configClass.Text; mConfig.ConfigFormClass = textBox_formClass.Text; mConfig.TaskClass = textBox_createClass.Text; mConfig.FileName = textBox_fileName.Text; mConfig.Enabled = checkBox_enabled.Checked; return(true); } return(false); }
public CTask(ITaskManager manager, ITaskConfig config, ITaskType type) { Init(manager, config, type); }
public bool Init(ITaskManager manager, ITaskConfig config, ITaskType type) { mConfig = config; mManager = manager; mType = type; if (!IsInit && Verify(ACOpts.Exec_Init)) { if (mManager.SystemContext.MonitorSystem.IsLocal) { if (InitTask()) { State = TaskState.Init; Config = mConfig; if (!IsActive && mConfig.AutoRun) { this.Start(); } return(true); } } else if (mManager.SystemContext.RemoteManageClient != null) { SystemContext.RemoteManageClient.OnConnected -= new ClientConnectEvent(DoConnected); SystemContext.RemoteManageClient.OnDisconnected -= new ClientConnectEvent(DoDisconnected); SystemContext.RemoteManageClient.OnReceiveData -= new ClientReceiveEvent(DoReceiveData); SystemContext.RemoteManageClient.OnConnected += new ClientConnectEvent(DoConnected); SystemContext.RemoteManageClient.OnDisconnected += new ClientConnectEvent(DoDisconnected); SystemContext.RemoteManageClient.OnReceiveData += new ClientReceiveEvent(DoReceiveData); IRemoteSystem rs = mManager.SystemContext.MonitorSystem as IRemoteSystem; if (rs != null) { StringBuilder sb = new StringBuilder(mManager.SystemContext.RequestHeadInfo); ISchedulerConfig sc = mManager.SystemContext.SchedulerConfigManager.GetConfig(mConfig.Scheduler); if (sc != null) { ISchedulerType st = mManager.SystemContext.SchedulerTypeManager.GetConfig(sc.Type); if (st != null) { sb.Append(sc.Name + "<Scheduler>"); sb.Append("InitConfig<Command>"); sb.Append(st.ToXml() + "<Type>"); sb.Append(sc.ToXml() + "<Config><CommandSegment>"); } } IActionConfig ac; IActionParam[] apList = mConfig.GetActionList(); if (apList != null) { foreach (IActionParam pc in apList) { ac = mManager.SystemContext.ActionConfigManager.GetConfig(pc.Name); if (ac != null) { IActionType at = mManager.SystemContext.ActionTypeManager.GetConfig(ac.Type); if (at != null) { sb.Append(ac.Name + "<Action>"); sb.Append("Init;Start<Command>"); sb.Append(at.ToXml() + "<Type>"); sb.Append(ac.ToXml() + "<Config><CommandSegment>"); } } } } sb.Append(Name + "<Task>"); sb.Append("Init<Command>"); sb.Append(mType.ToXml() + "<Type>"); sb.Append(mConfig.ToXml() + "<Config>"); return(mManager.SystemContext.RemoteManageClient.WaitReliableSend(rs.Config.IP, rs.Config.Port, sb.ToString())); } } return(false); } else { return(true); } }
public I CreateConfigInstance(string type, string name) { if (!type.Equals("")) { if (TypeName.Equals("Actions")) { IActionType actionType = SystemContext.ActionTypeManager.GetConfig(type); if (actionType != null) { return(CreateConfigInstance(actionType, name)); } } else if (TypeName.Equals("Schedulers")) { ISchedulerType schedulerType = SystemContext.SchedulerTypeManager.GetConfig(type); if (schedulerType != null) { return(CreateConfigInstance(schedulerType, name)); } } else if (TypeName.Equals("Tasks")) { ITaskType taskType = SystemContext.TaskTypeManager.GetConfig(type); if (taskType != null) { return(CreateConfigInstance(taskType, name)); } } else if (TypeName.Equals("Monitors")) { IMonitorType monitorType = SystemContext.MonitorTypeManager.GetConfig(type); if (monitorType != null) { return(CreateConfigInstance(monitorType, name)); } } else if (TypeName.Equals("VideoSources")) { IVideoSourceType vsType = SystemContext.VideoSourceTypeManager.GetConfig(type); if (vsType != null) { return(CreateConfigInstance(vsType, name)); } } } IConfig config = CreateConfigInstance(); if (config != null) { if (name != null) { ((CConfig)config).Name = name; } ITypeConfig tc = config as ITypeConfig; if (tc != null) { tc.Type = type; } } return((I)config); }
public static void AddRemoteConfig(IMonitorSystemContext context, string name, string data, bool saveConfig) { IConfig config = null; if (data.StartsWith("<Monitor>")) { config = context.MonitorConfigManager.GetConfig(name); if (config == null) { IMonitorConfig monitorConfig = context.MonitorConfigManager.BuildConfigFromXml(data) as IMonitorConfig; if (monitorConfig != null) { context.MonitorConfigManager.Append(monitorConfig, saveConfig); } } } else if (data.StartsWith("<MonitorType>")) { config = context.MonitorTypeManager.GetConfig(name); if (config == null) { IMonitorType monitorType = context.MonitorTypeManager.BuildConfigFromXml(data) as IMonitorType; if (monitorType != null) { context.MonitorTypeManager.Append(monitorType, saveConfig); } } } else if (data.StartsWith("<VideoSource>")) { config = context.VideoSourceConfigManager.GetConfig(name); if (config == null) { IVideoSourceConfig vsConfig = context.VideoSourceConfigManager.BuildConfigFromXml(data) as IVideoSourceConfig; if (vsConfig != null) { context.VideoSourceConfigManager.Append(vsConfig, saveConfig); } } } else if (data.StartsWith("<VideoSourceType>")) { config = context.VideoSourceTypeManager.GetConfig(name); if (config == null) { IVideoSourceType vsType = context.VideoSourceTypeManager.BuildConfigFromXml(data) as IVideoSourceType; if (vsType != null) { context.VideoSourceTypeManager.Append(vsType, saveConfig); } } } else if (data.StartsWith("<Action>")) { config = context.ActionConfigManager.GetConfig(name); if (config == null) { IActionConfig actionConfig = context.ActionConfigManager.BuildConfigFromXml(data) as IActionConfig; if (actionConfig != null) { context.ActionConfigManager.Append(actionConfig, saveConfig); } } } else if (data.StartsWith("<ActionType>")) { config = context.ActionTypeManager.GetConfig(name); if (config == null) { IActionType actionType = context.ActionTypeManager.BuildConfigFromXml(data) as IActionType; if (actionType != null) { context.ActionTypeManager.Append(actionType, saveConfig); } } } else if (data.StartsWith("<Scheduler>")) { config = context.SchedulerConfigManager.GetConfig(name); if (config == null) { ISchedulerConfig schedulerConfig = context.SchedulerConfigManager.BuildConfigFromXml(data) as ISchedulerConfig; if (schedulerConfig != null) { context.SchedulerConfigManager.Append(schedulerConfig, saveConfig); } } } else if (data.StartsWith("<SchedulerType>")) { config = context.SchedulerTypeManager.GetConfig(name); if (config == null) { ISchedulerType schedulerType = context.SchedulerTypeManager.BuildConfigFromXml(data) as ISchedulerType; if (schedulerType != null) { context.SchedulerTypeManager.Append(schedulerType, saveConfig); } } } else if (data.StartsWith("<Task>")) { config = context.TaskConfigManager.GetConfig(name); if (config == null) { ITaskConfig taskConfig = context.TaskConfigManager.BuildConfigFromXml(data) as ITaskConfig; if (taskConfig != null) { context.TaskConfigManager.Append(taskConfig, saveConfig); } } } else if (data.StartsWith("<TaskType>")) { config = context.TaskTypeManager.GetConfig(name); if (config == null) { ITaskType taskType = context.TaskTypeManager.BuildConfigFromXml(data) as ITaskType; if (taskType != null) { context.TaskTypeManager.Append(taskType, saveConfig); } } } else if (data.StartsWith("<RemoteSystem>")) { config = context.RemoteSystemConfigManager.GetConfig(name); if (config == null) { IRemoteSystemConfig rsConfig = context.RemoteSystemConfigManager.BuildConfigFromXml(data) as IRemoteSystemConfig; if (rsConfig != null) { context.RemoteSystemConfigManager.Append(rsConfig, saveConfig); } } } else if (data.StartsWith("<Role>")) { config = context.RoleConfigManager.GetConfig(name); if (config == null) { IRoleConfig roleConfig = context.RoleConfigManager.BuildConfigFromXml(data) as IRoleConfig; if (roleConfig != null) { context.RoleConfigManager.Append(roleConfig, saveConfig); } } } else if (data.StartsWith("<User>")) { config = context.UserConfigManager.GetConfig(name); if (config == null) { IUserConfig userConfig = context.UserConfigManager.BuildConfigFromXml(data) as IUserConfig; if (userConfig != null) { context.UserConfigManager.Append(userConfig, saveConfig); } } } }