コード例 #1
0
ファイル: Scheduler.cs プロジェクト: ewin66/Monitor
        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);
        }
コード例 #2
0
ファイル: Task.cs プロジェクト: ewin66/Monitor
        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);
            }
        }