Пример #1
0
        public bool Stop()
        {
            if (IsActive && Verify(ACOpts.Exec_Stop))
            {
                if (mManager.SystemContext.MonitorSystem.IsLocal)
                {
                    if (StopTask())
                    {
                        State = TaskState.Stop;
                        return(true);
                    }
                }
                else if (mManager.SystemContext.RemoteManageClient != null)
                {
                    IRemoteSystem rs = mManager.SystemContext.MonitorSystem as IRemoteSystem;
                    if (rs != null)
                    {
                        StringBuilder sb = new StringBuilder(mManager.SystemContext.RequestHeadInfo);
                        sb.Append(Name + "<Task>");
                        sb.Append("Stop<Command>");

                        return(mManager.SystemContext.RemoteManageClient.WaitReliableSend(rs.Config.IP, rs.Config.Port, sb.ToString()));
                    }
                }
            }
            return(false);
        }
Пример #2
0
        public bool Cleanup()
        {
            if (IsInit && Verify(ACOpts.Exec_Cleanup))
            {
                Stop();

                if (mManager.SystemContext.MonitorSystem.IsLocal)
                {
                    if (CleanupAction())
                    {
                        State = ActionState.None;
                        return(true);
                    }
                }
                else if (mManager.SystemContext.RemoteManageClient != null)
                {
                    IRemoteSystem rs = mManager.SystemContext.MonitorSystem as IRemoteSystem;
                    if (rs != null)
                    {
                        StringBuilder sb = new StringBuilder(mManager.SystemContext.RequestHeadInfo);
                        sb.Append(string.Format("{0}<Action>", Name));
                        sb.Append("Cleanup<Command>");

                        return(mManager.SystemContext.RemoteManageClient.WaitReliableSend(rs.Config.IP, rs.Config.Port, sb.ToString()));
                    }

                    SystemContext.RemoteManageClient.OnConnected    -= new ClientConnectEvent(DoConnected);
                    SystemContext.RemoteManageClient.OnDisconnected -= new ClientConnectEvent(DoDisconnected);
                    SystemContext.RemoteManageClient.OnReceiveData  -= new ClientReceiveEvent(DoReceiveData);
                }
            }
            return(false);
        }
Пример #3
0
        public bool Start()
        {
            if (IsInit && Verify(ACOpts.Exec_Start))
            {
                if (!IsActive)
                {
                    if (mManager.SystemContext.MonitorSystem.IsLocal)
                    {
                        if (StartAction())
                        {
                            State = ActionState.Run;
                            return(true);
                        }
                    }
                    else if (mManager.SystemContext.RemoteManageClient != null)
                    {
                        IRemoteSystem rs = mManager.SystemContext.MonitorSystem as IRemoteSystem;
                        if (rs != null)
                        {
                            StringBuilder sb = new StringBuilder(mManager.SystemContext.RequestHeadInfo);
                            sb.Append(string.Format("{0}<Action>", Name));
                            sb.Append("Start<Command>");

                            return(mManager.SystemContext.RemoteManageClient.WaitReliableSend(rs.Config.IP, rs.Config.Port, sb.ToString()));
                        }
                    }
                    return(false);
                }
                else
                {
                    return(true);
                }
            }
            return(false);
        }
Пример #4
0
        public void LoginRemoteSystem(string name)
        {
            IRemoteSystem rs = GetRemoteSystem(name);

            if (rs != null)
            {
                rs.Login(rs.Config.UserName, rs.Config.Password, false);
            }
        }
Пример #5
0
        public void LogoutRemoteSystem(string name)
        {
            IRemoteSystem rs = GetRemoteSystem(name);

            if (rs != null)
            {
                rs.Logout();
            }
        }
Пример #6
0
 private bool CheckOrigin(IMonitorSystemContext context, IProcessor processor)
 {
     if (context == SystemContext)
     {
         IRemoteSystem rs = context.MonitorSystem as IRemoteSystem;
         if (rs != null && processor.Host.Equals(rs.Config.IP) && processor.Port == rs.Config.Port)
         {
             return(true);
         }
     }
     return(false);
 }
Пример #7
0
 private bool CheckOrigin(IMonitorSystemContext context, IProcessor processor)
 {
     if (context == SystemContext)
     {
         IRemoteSystem rs = context.MonitorSystem as IRemoteSystem;
         //if ((context.IsLocalSystem && NetUtil.IPEquals(processor.Host, mConfig.Host) && processor.Port == mConfig.Port) || (rs != null && NetUtil.IPEquals(processor.Host, rs.Config.IP) && processor.Port == rs.Config.Port))
         if ((context.IsLocalSystem && processor.Host.Equals(mConfig.Host) && processor.Port == mConfig.Port) || (rs != null && processor.Host.Equals(rs.Config.IP) && processor.Port == rs.Config.Port))
         {
             return(true);
         }
     }
     return(false);
 }
Пример #8
0
        public static bool CheckSystemLogin(IMonitorSystem system)
        {
            IRemoteSystem rs = system as IRemoteSystem;

            if (rs != null)
            {
                return(CheckRemoteSystemLogin(rs));
            }
            else
            {
                return(CheckLocalSystemLogin());
            }
        }
Пример #9
0
 public IRemoteSystem[] GetRemoteSystems()
 {
     lock (mRemoteSystems.SyncRoot)
     {
         if (mRemoteSystems.Count > 0)
         {
             IRemoteSystem[] rss = new IRemoteSystem[mRemoteSystems.Count];
             mRemoteSystems.Values.CopyTo(rss, 0);
             return(rss);
         }
         return(null);
     }
 }
Пример #10
0
        public bool FreeRemoteSystem(string name)
        {
            lock (mRemoteSystems.SyncRoot)
            {
                IRemoteSystem rs = mRemoteSystems[name] as IRemoteSystem;
                if (rs != null)
                {
                    mRemoteSystems.Remove(name);

                    rs.Dispose();
                }
            }
            return(true);
        }
Пример #11
0
        public bool Init(IActionManager manager, IActionConfig config, IActionType type)
        {
            mConfig  = config;
            mManager = manager;
            mType    = type;

            if (!IsInit && Verify(ACOpts.Exec_Init))
            {
                if (mManager.SystemContext.MonitorSystem.IsLocal)
                {
                    if (InitAction())
                    {
                        State = ActionState.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(string.Format("{0}<Action>", Name));
                        sb.Append("Init<Command>");
                        sb.Append(string.Format("{0}<Type>", mType.ToXml()));
                        sb.Append(string.Format("{0}<Config>", mConfig.ToXml()));

                        return(mManager.SystemContext.RemoteManageClient.WaitReliableSend(rs.Config.IP, rs.Config.Port, sb.ToString()));
                    }
                }
            }
            return(false);
        }
Пример #12
0
        public bool CloseVideoSource(IVideoSourceConfig config)
        {
            if (config != null)
            {
                StringBuilder sb = new StringBuilder(config.SystemContext.RequestHeadInfo);
                sb.Append(config.Name + "<VideoSource>");
                sb.Append("Close<Command>");

                IRemoteSystem rs = config.SystemContext.MonitorSystem as IRemoteSystem;
                if (rs != null)
                {
                    return(WaitReliableSend(rs.Config.IP, rs.Config.Port, sb.ToString()));
                }
            }
            return(false);
        }
Пример #13
0
        public static bool CheckRemoteSystemLogin(IRemoteSystem rs)
        {
            if (rs == null)
            {
                return(false);
            }

            if (!rs.Config.UserName.Equals("") && !rs.Config.Password.Equals("") && !rs.Config.Password.Equals(CommonUtil.ToMD5Str("")))
            {
                rs.Login(rs.Config.UserName, rs.Config.Password, true);
                return(true);
            }
            else
            {
                return(ShowLoginDialog(rs));
            }
        }
Пример #14
0
 public void InitRemoteSystems()
 {
     IRemoteSystemConfig[] rsList = mSystemContext.RemoteSystemConfigManager.GetConfigs();
     if (rsList != null)
     {
         foreach (IRemoteSystemConfig config in rsList)
         {
             if (config != null)
             {
                 IRemoteSystem rs = CreateRemoteSystem(config);
                 if (rs != null && config.AutoLogin && !config.UserName.Equals("") && !config.Password.Equals("") && !config.Password.Equals(CommonUtil.ToMD5Str("")))
                 {
                     rs.Login(config.UserName, config.Password, true);
                 }
             }
         }
     }
 }
Пример #15
0
        public bool ShowDialog(IMonitorSystem system)
        {
            IRemoteSystem rs = system as IRemoteSystem;

            if (rs != null)
            {
                Text = "远程系统登录 ";
            }
            else
            {
                Text = "本地系统登录 ";
            }

            textBox_username.Text = rs != null ? rs.Config.UserName : "";
            textBox_password.Text = "";

            return(ShowDialog() == DialogResult.OK);
        }
Пример #16
0
        public bool SyncMonitorState(IMonitorConfig config)
        {
            StringBuilder sb = new StringBuilder(config.SystemContext.RequestHeadInfo);

            sb.Append(config.Name + "<Monitor>");
            sb.Append("QueryState<Command>");

            IRemoteSystem rs = config.SystemContext.MonitorSystem as IRemoteSystem;

            if (rs != null)
            {
                return(Send(rs.Config.IP, rs.Config.Port, sb.ToString()));
            }
            else
            {
                return(Send(config.Host, config.Port, sb.ToString()));
            }
        }
Пример #17
0
        public bool CleanupMonitor(IMonitorConfig config)
        {
            StringBuilder sb = new StringBuilder(config.SystemContext.RequestHeadInfo);

            sb.Append(config.Name + "<Monitor>");
            sb.Append("Cleanup<Command>");

            IRemoteSystem rs = config.SystemContext.MonitorSystem as IRemoteSystem;

            if (rs != null)
            {
                return(WaitReliableSend(rs.Config.IP, rs.Config.Port, sb.ToString()));
            }
            else
            {
                return(WaitReliableSend(config.Host, config.Port, sb.ToString()));
            }
        }
Пример #18
0
        public bool DeleteRemoteConfig(IConfig config)
        {
            StringBuilder sb = new StringBuilder(config.SystemContext.RequestHeadInfo);

            sb.Append(config.Name + "<RemoteConfig>");
            sb.Append("Delete<Command>");
            sb.Append("<" + config.TypeName + ">");

            IRemoteSystem rs = config.SystemContext.MonitorSystem as IRemoteSystem;

            if (rs != null)
            {
                return(WaitReliableSend(rs.Config.IP, rs.Config.Port, sb.ToString()));
            }
            else
            {
                return(false);
            }
        }
Пример #19
0
 public static IMonitorSystemContext GetSystemContext(string name)
 {
     if (mLocalSystem.Name.Equals(name))
     {
         return(mLocalSystem.SystemContext);
     }
     else
     {
         IRemoteSystem rs = mLocalSystem.SystemContext.RemoteSystemManager.GetRemoteSystem(name);
         if (rs != null)
         {
             return(rs.SystemContext);
         }
         else
         {
             return(null);
         }
     }
 }
Пример #20
0
        public bool PreviewMonitorAlarmImage(IMonitorConfig config, string id, IntPtr hWnd)
        {
            StringBuilder sb = new StringBuilder(config.SystemContext.RequestHeadInfo);

            sb.Append(config.Name + "<Monitor>");
            sb.Append("GetMonitorAlarmImage<Command>");
            sb.Append(id + "<ID>");

            IRemoteSystem rs = config.SystemContext.MonitorSystem as IRemoteSystem;

            if (rs != null)
            {
                return(Send(rs.Config.IP, rs.Config.Port, sb.ToString()));
            }
            else
            {
                return(Send(config.Host, config.Port, sb.ToString()));
            }
        }
Пример #21
0
        public bool StopAlarmRecord(IMonitorConfig config, string alarmID)
        {
            StringBuilder sb = new StringBuilder(config.SystemContext.RequestHeadInfo);

            sb.Append(config.Name + "<Monitor>");
            sb.Append("StopSaveAlarmRecord<Command>");
            sb.Append(alarmID + "<AlarmID>");

            IRemoteSystem rs = config.SystemContext.MonitorSystem as IRemoteSystem;

            if (rs != null)
            {
                return(Send(rs.Config.IP, rs.Config.Port, sb.ToString()));
            }
            else
            {
                return(Send(config.Host, config.Port, sb.ToString()));
            }
        }
Пример #22
0
        public bool GetNextVisionAlarmRecord(IMonitorConfig config, string id, int hPlay)
        {
            StringBuilder sb = new StringBuilder(config.SystemContext.RequestHeadInfo);

            sb.Append(config.Name + "<Monitor>");
            sb.Append("GetNextVisionAlarmRecord<Command>");
            sb.Append(id + "<ID>");
            sb.Append(hPlay + "<PlayID>");

            IRemoteSystem rs = config.SystemContext.MonitorSystem as IRemoteSystem;

            if (rs != null)
            {
                return(Send(rs.Config.IP, rs.Config.Port, sb.ToString()));
            }
            else
            {
                return(Send(config.Host, config.Port, sb.ToString()));
            }
        }
Пример #23
0
        public bool CleanupVideoSource(IMonitorConfig config)
        {
            IVisionMonitorConfig vmConfig = config as IVisionMonitorConfig;

            if (vmConfig != null)
            {
                StringBuilder sb = new StringBuilder(config.SystemContext.RequestHeadInfo);
                sb.Append(vmConfig.VisionParamConfig.VSName + "<VideoSource>");
                sb.Append("Cleanup<Command>");

                IRemoteSystem rs = config.SystemContext.MonitorSystem as IRemoteSystem;
                if (rs != null)
                {
                    return(WaitReliableSend(rs.Config.IP, rs.Config.Port, sb.ToString()));
                }
                else
                {
                    return(WaitReliableSend(config.Host, config.Port, sb.ToString()));
                }
            }
            return(false);
        }
Пример #24
0
 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);
     }
 }
Пример #25
0
        public bool OpenVideoSource(IVideoSourceConfig config)
        {
            if (config != null)
            {
                IVideoSourceType vsType = config.SystemContext.GetVideoSourceType(config.Type);

                if (vsType != null)
                {
                    StringBuilder sb = new StringBuilder(config.SystemContext.RequestHeadInfo);
                    sb.Append(config.Name + "<VideoSource>");
                    sb.Append("Open<Command>");
                    sb.Append(vsType.ToXml() + "<Type>");
                    sb.Append(config.ToXml() + "<Config>");

                    IRemoteSystem rs = config.SystemContext.MonitorSystem as IRemoteSystem;
                    if (rs != null)
                    {
                        return(WaitReliableSend(rs.Config.IP, rs.Config.Port, sb.ToString()));
                    }
                }
            }
            return(false);
        }
Пример #26
0
        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);
            }
        }
Пример #27
0
        public bool InitMonitor(IMonitorConfig config)
        {
            IVisionMonitorConfig vmConfig = config as IVisionMonitorConfig;

            if (vmConfig != null)
            {
                IVideoSourceConfig vsConfig = config.SystemContext.GetVideoSourceConfig(vmConfig.Watcher.ActiveVisionParamConfig.VSName);
                if (vsConfig != null)
                {
                    IVideoSourceType vsType = config.SystemContext.GetVideoSourceType(vsConfig.Type);

                    StringBuilder sb = new StringBuilder(config.SystemContext.RequestHeadInfo);
                    sb.Append(vsConfig.Name + "<VideoSource>");
                    sb.Append("Open;Play;InitKernel<Command>");
                    sb.Append(vsType.ToXml() + "<Type>");
                    sb.Append(vsConfig.ToXml() + "<Config><CommandSegment>");

                    IActionConfig  ac;
                    IActionParam[] apList;
                    if (!config.Watcher.ActiveActionParamConfig.LocalAlarmAction)
                    {
                        apList = config.Watcher.ActiveActionParamConfig.GetAlarmActionList();
                        if (apList != null)
                        {
                            foreach (IActionParam pc in apList)
                            {
                                ac = config.SystemContext.ActionConfigManager.GetConfig(pc.Name);
                                if (ac != null)
                                {
                                    IActionType at = config.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>");
                                    }
                                }
                            }
                        }
                    }
                    if (!config.Watcher.ActiveActionParamConfig.LocalTransactAction)
                    {
                        apList = config.Watcher.ActiveActionParamConfig.GetTransactActionList();
                        if (apList != null)
                        {
                            foreach (IActionParam pc in apList)
                            {
                                ac = config.SystemContext.ActionConfigManager.GetConfig(pc.Name);
                                if (ac != null)
                                {
                                    IActionType at = config.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>");
                                    }
                                }
                            }
                        }
                    }

                    IMonitorType vuType = config.SystemContext.GetMonitorType(config.Type);

                    sb.Append(config.Name + "<Monitor>");
                    sb.Append("Init<Command>");
                    sb.Append(vuType.ToXml() + "<Type>");
                    sb.Append(config.ToXml() + "<Config>");

                    IRemoteSystem rs = config.SystemContext.MonitorSystem as IRemoteSystem;
                    if (rs != null)
                    {
                        return(WaitReliableSend(rs.Config.IP, rs.Config.Port, sb.ToString()));
                    }
                    else
                    {
                        return(WaitReliableSend(config.Host, config.Port, sb.ToString()));
                    }
                }
            }
            else
            {
                IMonitorType vuType = config.SystemContext.GetMonitorType(config.Type);

                StringBuilder sb = new StringBuilder(config.SystemContext.RequestHeadInfo);
                sb.Append(config.Name + "<Monitor>");
                sb.Append("Init<Command>");
                sb.Append(vuType.ToXml() + "<Type>");
                sb.Append(config.ToXml() + "<Config>");

                IRemoteSystem rs = config.SystemContext.MonitorSystem as IRemoteSystem;
                if (rs != null)
                {
                    return(WaitReliableSend(rs.Config.IP, rs.Config.Port, sb.ToString()));
                }
                else
                {
                    return(WaitReliableSend(config.Host, config.Port, sb.ToString()));
                }
            }
            return(false);
        }
Пример #28
0
 public AD7UnixAsyncCommand(IRemoteSystem remoteSystem, IDebugUnixShellCommandCallback callback)
 {
     _remoteSystem = remoteSystem;
     _callback     = callback;
 }