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 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(IConfigManager <ISchedulerType> 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 ISchedulerType; if (config.Verify(ACOpts.Manager_Modify, false)) { if (InitDialog()) { ShowDialog(); } } }
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(); } } }
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); }
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.SchedulerClass = textBox_createClass.Text; mConfig.FileName = textBox_fileName.Text; mConfig.Enabled = checkBox_enabled.Checked; return(true); } return(false); }
/// <summary> /// 开始启动任务注册 /// </summary> public static void StartTask() { try { Assembly asm = Assembly.GetExecutingAssembly(); Type[] types = asm.GetTypes(); types.Where(p => p.GetInterfaces().Select(p1 => p1 == typeof(ISchedulerType)).Count() > 0).ToList().ForEach(p => { //以”TriggerRunner“结尾的触发器类名 if (p.Name.EndsWith("TriggerRunner")) { //设置或者注册任务的触发 ISchedulerType sc = (ISchedulerType)ObjectUtils.InstantiateType(p); sc.Run(); Console.WriteLine(p.Name + "定时任务已启动"); } }); } catch (Exception ex) { Console.WriteLine("StartTask:启动失败", ex.Message); } }
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); } } } }
public CScheduler(ISchedulerManager manager, ISchedulerConfig config, ISchedulerType type) { Init(manager, config, type); }