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.IP = textBox_ip.Text; mConfig.Port = (int)numericUpDown_port.Value; mConfig.RemoteSystemName = textBox_rsname.Text; mConfig.UserName = textBox_username.Text; mConfig.Password = mOldPassword.Equals("") ? CommonUtil.ToMD5Str(textBox_password.Text) : mOldPassword; mConfig.AutoLogin = checkBox_autologin.Checked; mConfig.Enabled = checkBox_enabled.Checked; return(true); } return(false); }
public bool RefreshRemoteSystem(IRemoteSystemConfig config, string username) { StringBuilder sb = new StringBuilder(config.SystemContext.RequestHeadInfo); sb.Append(config.Name + "<RemoteSystem>"); sb.Append("Refresh<Command>"); sb.Append(config.RemoteSystemName + "<MonitorSystem>"); sb.Append(username + "<UserName>"); //return WaitReliableSend(config.IP, config.Port, sb.ToString()); return(WaitSend(config.IP, config.Port, sb.ToString())); }
public void ShowAddDialog(IConfigManager <IRemoteSystemConfig> manager) { Text = "新增远程系统"; mIsOk = false; mManager = manager; mConfig = null; 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 IRemoteSystemConfig; if (config.Verify(ACOpts.Manager_Modify, false)) { if (InitDialog()) { ShowDialog(); } } }
public CRemoteSystem(IRemoteSystemManager manager, IRemoteSystemConfig config) : base(false) { mManager = manager; mConfig = config; if (mManager != null && mManager.SystemContext.RemoteManageClient != null) { mManager.SystemContext.RemoteManageClient.OnConnected -= new ClientConnectEvent(DoConnected); mManager.SystemContext.RemoteManageClient.OnDisconnected -= new ClientConnectEvent(DoDisconnected); mManager.SystemContext.RemoteManageClient.OnReceiveData -= new ClientReceiveEvent(DoReceiveData); mManager.SystemContext.RemoteManageClient.OnConnected += new ClientConnectEvent(DoConnected); mManager.SystemContext.RemoteManageClient.OnDisconnected += new ClientConnectEvent(DoDisconnected); mManager.SystemContext.RemoteManageClient.OnReceiveData += new ClientReceiveEvent(DoReceiveData); } }
public IRemoteSystem CreateRemoteSystem(IRemoteSystemConfig config) { if (config != null && config.Enabled) { lock (mRemoteSystems.SyncRoot) { IRemoteSystem rs = mRemoteSystems[config.Name] as IRemoteSystem; if (rs == null) { rs = new CRemoteSystem(this, config); rs.OnSystemStateChanged += new MonitorSystemStateChanged(DoSystemStateChanged); mRemoteSystems.Add(rs.Name, rs); rs.RefreshState(); } return(rs); } } else { return(null); } }
private void contextMenuStrip_func_Opening(object sender, CancelEventArgs e) { ToolStripMenuItem_init.Visible = false; ToolStripMenuItem_start.Visible = false; ToolStripMenuItem_add.Visible = false; ToolStripMenuItem_edit.Visible = false; ToolStripMenuItem_delete.Visible = false; ToolStripMenuItem_refresh.Visible = false; ToolStripMenuItem_refresh.Text = "Ë¢ÐÂ"; ToolStripMenuItem_1.Visible = false; ToolStripMenuItem_2.Visible = false; ToolStripMenuItem_3.Visible = false; if (mCurNode != null) { IConfigManager configManager = mCurNode.ExtConfigObj as IConfigManager; if (configManager != null) { ToolStripMenuItem_add.Visible = configManager.SystemContext.MonitorSystem.IsLogin; ToolStripMenuItem_refresh.Visible = true; ToolStripMenuItem_3.Visible = configManager.SystemContext.MonitorSystem.IsLogin; return; } IConfigType type = mCurNode.ExtConfigObj as IConfigType; if (type != null) { ToolStripMenuItem_add.Visible = type.SystemContext.MonitorSystem.IsLogin; ToolStripMenuItem_edit.Visible = type.SystemContext.MonitorSystem.IsLogin; ToolStripMenuItem_delete.Visible = type.SystemContext.MonitorSystem.IsLogin; ToolStripMenuItem_refresh.Visible = true; ToolStripMenuItem_3.Visible = type.SystemContext.MonitorSystem.IsLogin; return; } IRoleConfig roleConfig = mCurNode.ExtConfigObj as IRoleConfig; if (roleConfig != null) { ToolStripMenuItem_start.Visible = false; ToolStripMenuItem_edit.Visible = roleConfig.SystemContext.MonitorSystem.IsLogin; ToolStripMenuItem_delete.Visible = roleConfig.SystemContext.MonitorSystem.IsLogin; ToolStripMenuItem_refresh.Visible = false; ToolStripMenuItem_1.Visible = false; ToolStripMenuItem_3.Visible = false; return; } IUserConfig userConfig = mCurNode.ExtConfigObj as IUserConfig; if (userConfig != null) { ToolStripMenuItem_refresh.Text = "ÐÞ¸ÄÃÜÂë"; bool isLogin = userConfig.SystemContext.MonitorSystem.IsLogin; ToolStripMenuItem_start.Visible = false; ToolStripMenuItem_edit.Visible = isLogin; ToolStripMenuItem_delete.Visible = isLogin; ToolStripMenuItem_refresh.Visible = isLogin && userConfig.SystemContext.MonitorSystem.UserName.Equals(userConfig.Name); ToolStripMenuItem_1.Visible = false; ToolStripMenuItem_3.Visible = isLogin && userConfig.SystemContext.MonitorSystem.UserName.Equals(userConfig.Name); return; } IMonitorSystemContext sysContext = mCurNode.ExtConfigObj as IMonitorSystemContext; if (sysContext != null && sysContext.IsLocalSystem) { ToolStripMenuItem_start.Text = mCurNode.IsStart ? "×¢Ïú" : "µÇ¼"; ToolStripMenuItem_start.Visible = true; ToolStripMenuItem_edit.Visible = sysContext.MonitorSystem.IsLogin; ToolStripMenuItem_delete.Visible = false; ToolStripMenuItem_refresh.Visible = true; ToolStripMenuItem_1.Visible = true; ToolStripMenuItem_3.Visible = sysContext.MonitorSystem.IsLogin; return; } IRemoteSystemConfig rsConfig = mCurNode.ExtConfigObj as IRemoteSystemConfig; if (rsConfig != null) { ToolStripMenuItem_start.Text = mCurNode.IsStart ? "×¢Ïú" : "µÇ¼"; ToolStripMenuItem_start.Visible = rsConfig.Enabled && rsConfig.SystemContext.MonitorSystem.IsLogin; ToolStripMenuItem_edit.Visible = rsConfig.SystemContext.MonitorSystem.IsLogin; ToolStripMenuItem_delete.Visible = rsConfig.SystemContext.MonitorSystem.IsLogin; ToolStripMenuItem_refresh.Visible = true; ToolStripMenuItem_1.Visible = rsConfig.Enabled && rsConfig.SystemContext.MonitorSystem.IsLogin; ToolStripMenuItem_3.Visible = rsConfig.SystemContext.MonitorSystem.IsLogin; return; } IVideoSourceConfig vsconfig = mCurNode.ExtConfigObj as IVideoSourceConfig; if (vsconfig != null) { ToolStripMenuItem_init.Text = mCurNode.IsInit ? "¹Ø±Õ" : "´ò¿ª"; ToolStripMenuItem_start.Text = mCurNode.IsStart ? "Í£Ö¹" : "²¥·Å"; ToolStripMenuItem_init.Visible = vsconfig.Enabled; ToolStripMenuItem_start.Visible = mCurNode.IsInit; ToolStripMenuItem_edit.Visible = vsconfig.SystemContext.MonitorSystem.IsLogin; ToolStripMenuItem_delete.Visible = vsconfig.SystemContext.MonitorSystem.IsLogin; ToolStripMenuItem_1.Visible = vsconfig.Enabled && mCurNode.IsInit; ToolStripMenuItem_2.Visible = vsconfig.Enabled && vsconfig.SystemContext.MonitorSystem.IsLogin; return; } IConfig config = mCurNode.ExtConfigObj as IConfig; if (config != null) { ToolStripMenuItem_init.Text = mCurNode.IsInit ? "жÔØ" : "¼ÓÔØ"; ToolStripMenuItem_start.Text = mCurNode.IsStart ? "Í£Ö¹" : "Æô¶¯"; ToolStripMenuItem_init.Visible = config.Enabled; ToolStripMenuItem_start.Visible = mCurNode.IsInit; ToolStripMenuItem_edit.Visible = config.SystemContext.MonitorSystem.IsLogin; ToolStripMenuItem_delete.Visible = config.SystemContext.MonitorSystem.IsLogin; ToolStripMenuItem_1.Visible = config.Enabled && mCurNode.IsInit; ToolStripMenuItem_2.Visible = config.Enabled && config.SystemContext.MonitorSystem.IsLogin; return; } ToolStripMenuItem_refresh.Visible = 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); } } } }