public bool ConfigScheduler(string name, ISchedulerConfig config) { IScheduler scheduler = GetScheduler(name); if (scheduler != null) { scheduler.Config = config; return(true); } return(false); }
public IScheduler CreateScheduler(ISchedulerConfig config, ISchedulerType type) { if (config == null || !config.Enabled) { return(null); } lock (mSchedulers.SyncRoot) { CScheduler scheduler = mSchedulers[config.Name] as CScheduler; if (scheduler == null) { if (type == null) { type = mSystemContext.SchedulerTypeManager.GetConfig(config.Type); } if (type != null && type.Enabled && !type.SchedulerClass.Equals("")) { if (!type.FileName.Equals("")) { scheduler = CommonUtil.CreateInstance(SystemContext, type.FileName, type.SchedulerClass) as CScheduler; } else { scheduler = CommonUtil.CreateInstance(type.SchedulerClass) as CScheduler; } } if (scheduler != null) { if (scheduler.Init(this, config, type)) { scheduler.OnSchedulerStateChanged += new SchedulerStateChanged(DoSchedulerStateChanged); scheduler.OnSchedulerEvent += new SchedulerEvent(DoSchedulerEvent); mSchedulers.Add(scheduler.Name, scheduler); scheduler.RefreshState(); } else { return(null); } } } else { scheduler.Config = config; } return(scheduler); } }
public IScheduler CreateScheduler(ISchedulerConfig config) { if (config != null) { ISchedulerType type = mSystemContext.SchedulerTypeManager.GetConfig(config.Type); return(CreateScheduler(config, type)); } else { return(null); } }
public IScheduler CreateInstance(ISchedulerConfig config, object owner) { if (config != null) { ISchedulerType type = mSystemContext.SchedulerTypeManager.GetConfig(config.Type); return(CreateInstance(config, type, owner)); } else { return(null); } }
public IScheduler CreateScheduler(string name) { ISchedulerConfig config = mSystemContext.SchedulerConfigManager.GetConfig(name) as ISchedulerConfig; if (config != null) { return(CreateScheduler(config)); } else { return(null); } }
public IScheduler CreateInstance(string name, object owner) { ISchedulerConfig config = mSystemContext.SchedulerConfigManager.GetConfig(name) as ISchedulerConfig; if (config != null) { return(CreateInstance(config, owner)); } else { return(null); } }
public bool Init(ISchedulerManager manager, ISchedulerConfig config, ISchedulerType type) { mConfig = config; mManager = manager; mType = type; if (!IsInit && Verify(ACOpts.Exec_Init)) { if (mManager.SystemContext.MonitorSystem.IsLocal) { if (InitScheduler()) { State = SchedulerState.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); sb.Append(Name + "<Scheduler>"); 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); }
public void ShowAddDialog(ISchedulerType type) { Text = "新增调度模块"; mIsOk = false; mManager = type.SystemContext.SchedulerConfigManager; mType = type; mConfig = null; if (type.Verify(ACOpts.Manager_Add, false)) { InitTypeList(mManager.SystemContext); if (InitDialog()) { ShowDialog(); } } }
public override void ShowEditDialog(IConfig config) { Text = "编辑调度模块 - [" + config.Name + "]"; mIsOk = false; mManager = null; mType = null; mConfig = config as ISchedulerConfig; if (config.Verify(ACOpts.Manager_Modify, false)) { InitTypeList(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.Type = CtrlUtil.GetComboBoxText(comboBox_type); mConfig.AutoRun = checkBox_autorun.Checked; mConfig.Enabled = checkBox_enabled.Checked; mConfig.SetValue("StartTime", comboBox_startTime.Text); mConfig.SetValue("StopTime", comboBox_stopTime.Text); mConfig.SetValue("Delay", comboBox_delayTime.Text); mConfig.SetValue("Period", comboBox_period.Text); mConfig.Cycle = (int)numericUpDown_cycleNumber.Value; mConfig.PerCycle = 1; mConfig.OnTimeStart = checkBox_onTimeStart.Checked; ITimeSegment ts = null; mConfig.ClearTimeSegment(); foreach (DataGridViewRow row in dataGridView_timeSegment.Rows) { if (row.Cells[0].Value != null || row.Cells[1].Value != null) { ts = mConfig.AppendTimeSegment(); ts.SetValue("StartTime", row.Cells[0].Value != null ? row.Cells[0].Value.ToString() : ""); ts.SetValue("StopTime", row.Cells[1].Value != null ? row.Cells[1].Value.ToString() : ""); ts.Enabled = Convert.ToBoolean(row.Cells[2].Value); } } return(true); } return(false); }
public IScheduler CreateInstance(ISchedulerConfig config, ISchedulerType type, object owner) { if (config == null || !config.Enabled) { return(null); } if (type == null) { type = mSystemContext.SchedulerTypeManager.GetConfig(config.Type); } CScheduler scheduler = null; if (type != null && type.Enabled && !type.SchedulerClass.Equals("")) { if (!type.FileName.Equals("")) { scheduler = CommonUtil.CreateInstance(SystemContext, type.FileName, type.SchedulerClass) as CScheduler; } else { scheduler = CommonUtil.CreateInstance(type.SchedulerClass) as CScheduler; } } if (scheduler != null) { scheduler.Owner = owner; if (scheduler.Init(this, config, type)) { return(scheduler); } } return(null); }
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 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); } } } }
public CScheduler(ISchedulerManager manager, ISchedulerConfig config, ISchedulerType type) { Init(manager, config, type); }