示例#1
0
        //public override
        //Send Message to client
        public override void CycleResponse()
        {
            if (stack.CurrentDirect == FlowDirect.WaitingOutput)
            {
                BaseDCTAction action = stack.GetNextAction();
                // Added by Icyer 2006/12/14
                if (action == null)
                {
                    return;
                }
                // Added end

                try
                {
                    stack.SendMessage(client, action.Do(client), "");

                    //stack.CurrentDirect = action.FlowDirect;
                }
                catch (Exception ex)
                {
                    UserControl.Messages msg = new UserControl.Messages();
                    msg.Add(new UserControl.Message(ex));
                    stack.SendMessage(client, msg, "");
                }
            }
        }
示例#2
0
        //public override
        //Send Message to client
        public override void CycleResponse()
        {
            if (stack.CurrentDirect == FlowDirect.WaitingOutput)
            {
                BaseDCTAction action = stack.GetNextAction();
                if (action == null)
                {
                    this.Login();
                    return;
                }

                try
                {
                    stack.SendMessage(client, action.Do(client), "");

                    //stack.CurrentDirect = action.FlowDirect;
                }
                catch (Exception ex)
                {
                    UserControl.FileLog.FileLogOut("DCTControlPanel.log", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + ex.StackTrace);
                    UserControl.Messages msg = new UserControl.Messages();
                    msg.Add(new UserControl.Message(ex));
                    stack.SendMessage(client, msg, "");
                }
            }
        }
示例#3
0
        //logon mes
        protected override void Login()
        {
            BaseDCTAction action = stack.GetNextAction();

            if (stack.CurrentDirect == FlowDirect.WaitingOutput)
            {
                if (action == null)
                {
                    action = new ActionUser();
                    stack.Add(action);
                }


                try
                {
                    stack.SendMessage(client, action.Do(client), "");

                    //stack.CurrentDirect = action.FlowDirect;
                }
                catch (Exception ex)
                {
                    UserControl.Messages msg = new UserControl.Messages();
                    msg.Add(new UserControl.Message(ex));
                    stack.SendMessage(client, msg, "");
                }
            }
        }
示例#4
0
        private void InitMsg()
        {
            if (AgentInfo.Module != null && AgentInfo.Module != string.Empty)
            {
                UserControl.Messages msgs = new UserControl.Messages();

                msgs.Add(new UserControl.Message(UserControl.MessageType.Success, string.Format("MES {0} Agent 启动", AgentInfo.Module)));
                msgs.Add(new UserControl.Message(UserControl.MessageType.Success, string.Format("MES {0} Agent 监控目录为 {1}", AgentInfo.Module, AgentInfo.DirectoryPath)));
                msgs.Add(new UserControl.Message(" "));

                ApplicationRun.GetInfoForm().Add(msgs);
            }
        }
示例#5
0
        // Added end

        //Recieve Data from client
        public override void CycleRequest()
        {
            if (this.IsRootDriver == true || stack.CurrentDirect == FlowDirect.WaitingInput)
            {
                string strRec = null;

                int clientId = 0;
                strRec = (client as DSC19Client).RecieveData(ref clientId);

                BaseDCTAction action = null;
                if (strRec != null && strRec != string.Empty)
                {
                    if (this.IsRootDriver == false)             // 如果不是种子Driver,则执行Action操作
                    {
                        if (strRec.IndexOf("ALL RIGHTS") < 0 && strRec != String.Empty && strRec.IndexOf("DCS-19 SELF-RESET") < 0)
                        {
                            try
                            {
                                DealSuperCommand(strRec);

                                action = stack.GetNextAction();
                                stack.SendMessage(client, action.Do(client), "");
                                //stack.CurrentDirect = action.FlowDirect;
                            }
                            catch (Exception ex)
                            {
                                UserControl.Messages msg = new UserControl.Messages();
                                msg.Add(new UserControl.Message(ex));
                                stack.SendMessage(client, msg, "");
                                if (action != null)
                                {
                                    //stack.CurrentDirect = action.FlowDirect;
                                }
                            }
                        }
                    }
                    else                // 如果是种子Driver,则将数据发送到真实的Driver上
                    {
                        DSC19DCTDriver driver = this.GetDriver(clientId);
                        this.AsyncTransferData(driver, strRec);

                        // 继续向下读
                        if (strRec != null && strRec != string.Empty)
                        {
                            CycleRequest();
                        }
                    }
                }
            }
        }
示例#6
0
        //Send Message to client
        public virtual void CycleResponse()
        {
            if (stack.CurrentDirect == FlowDirect.WaitingOutput)
            {
                BaseDCTAction action = stack.GetNextAction();

                try
                {
                    stack.SendMessage(client, action.Do(client), string.Empty);
                }
                catch (Exception ex)
                {
                    UserControl.Messages msg = new UserControl.Messages();
                    msg.Add(new UserControl.Message(ex));
                    stack.SendMessage(client, msg, string.Empty);
                }
            }
        }
示例#7
0
        //Recieve Data from client
        public override void CycleRequest()
        {
            if (stack.CurrentDirect == FlowDirect.WaitingInput)
            {
                string strRec = null;

                strRec = (client as DCN500Client).RecieveData();

                //strRec = (client as DCN500Client).RecievedData;

                BaseDCTAction action = null;
                if (strRec != null)
                {
                    //strRec = strRec.Replace(System.Text.Encoding.ASCII.GetString(fixedMsg),"").Trim();
                    //strRec = strRec.Replace(System.Text.Encoding.ASCII.GetString(fixedMsg2),"").Trim();
                    //strRec = strRec.Replace(System.Text.Encoding.ASCII.GetString(fixedMsg3),"").Trim();
                    if (                   //strRec.IndexOf(System.Text.Encoding.ASCII.GetString(fixedMsg)) < 0 &&
                        strRec != String.Empty)
                    {
                        try
                        {
                            DealSuperCommand(strRec);

                            action = stack.GetNextAction();

                            stack.SendMessage(client, action.Do(client), "");
                        }
                        catch (Exception ex)
                        {
                            UserControl.Messages msg = new UserControl.Messages();
                            msg.Add(new UserControl.Message(ex));
                            stack.SendMessage(client, msg, "");
                            if (action != null)
                            {
                                lock (stack)
                                {
                                    //stack.CurrentDirect = action.FlowDirect;
                                }
                            }
                        }
                    }
                }
            }
        }
示例#8
0
        //public override
        //Send Message to client
        public override void CycleResponse()
        {
            if (stack.CurrentDirect == FlowDirect.WaitingOutput)
            {
                BaseDCTAction action = stack.GetNextAction();

                try
                {
                    stack.SendMessage(client, action.Do(client), "");

                    lock (stack)
                    {
                        //stack.CurrentDirect = action.FlowDirect;
                    }
                }
                catch (Exception ex)
                {
                    UserControl.Messages msg = new UserControl.Messages();
                    msg.Add(new UserControl.Message(ex));
                    stack.SendMessage(client, msg, "");
                }
            }
        }
示例#9
0
        //logon mes
        protected override void Login()
        {
            BaseDCTAction action = stack.GetNextAction();

            //			if(action == null)
            //			{
            //			action = new ActionUser();
            //			stack.Add(action);
            //			}

            if (stack.CurrentDirect == FlowDirect.WaitingOutput && action == null)
            {
                action = new ActionUser();
                if (bIsInitLoginMessage == true)
                {
                    action.OutMesssage  = new UserControl.Message(UserControl.MessageType.Normal, "$DCT_LOGIN");
                    bIsInitLoginMessage = false;
                }
                stack.Add(action);


                try
                {
                    stack.SendMessage(client, action.Do(client), "");

                    //stack.CurrentDirect = action.FlowDirect;
                }
                catch (Exception ex)
                {
                    UserControl.FileLog.FileLogOut("DCTControlPanel.log", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + ex.StackTrace);
                    UserControl.Messages msg = new UserControl.Messages();
                    msg.Add(new UserControl.Message(ex));
                    stack.SendMessage(client, msg, "");
                }
            }
        }
示例#10
0
        private void AgentRun()
        {
            CollectExcute collect = new CollectExcute(_domainDataProvider);

            try
            {
                if (AgentInfo.RunStatus == "TRUE")
                {
                    string[] fileList = this.GetFiles(AgentInfo.DirectoryPath);
                    if (fileList != null && fileList.Length > 0)
                    {
                        foreach (string filePath in fileList)
                        {
                            UserControl.Messages collectMessage = collect.Excute(AgentInfo.Module, filePath, AgentInfo.FileEncoding);
                            ApplicationRun.GetInfoForm().Add(collectMessage);                                   //采集信息显示

                            DealFile(filePath);                                                                 //文件处理
                        }
                    }
                }
            }
            catch
            {}
        }
示例#11
0
        //Recieve Data from client
        public override void CycleRequest()
        {
            if (stack.CurrentDirect == FlowDirect.WaitingInput)
            {
                string strRec = null;

                strRec = (client as GW28Client).RecieveData();

                BaseDCTAction action = null;
                if (strRec != null)
                {
                    if (strRec.IndexOf("ALL RIGHTS") < 0 && strRec != String.Empty)
                    {
                        try
                        {
                            if (IsInputedLoginCmd == false && strRec == "10")
                            {
                                return;
                            }
                            string receivedData = strRec;
                            if (receivedData == EXIT)
                            {
                                IsInputedLoginCmd = false;
                            }
                            else if (receivedData == LOGIN && IsInputedLoginCmd == true)                // 输入LOGIN,要先退出
                            {
                                receivedData      = EXIT;
                                IsInputedLoginCmd = false;
                            }
                            if (receivedData == EXIT || IsInputedLoginCmd == false)
                            {
                                stack = new BaseActionStack();
                                //stack.CurrentDirect = FlowDirect.WaitingOutPut;
                            }

                            DealSuperCommand(receivedData);

                            if (!client.Authorized)
                            {
                                Login();
                            }

                            bool bIsLoginCmd = false;
                            if (IsInputedLoginCmd == false && !client.Authorized)       // 如果还没有输入登录命令,而且客户端没有登录
                            {
                                bIsLoginCmd       = true;
                                IsInputedLoginCmd = true;
                            }
                            if (client.Authorized || bIsLoginCmd == false)      // 如果是登录命令,则不用再次执行Action,以免将命令当做用户名
                            {
                                // 获取现在的Action
                                action = stack.GetNextAction();

                                /* joe 20070903 GW28 输入和输出在一个界面,不需要输出原始输入
                                 * // 输出原始输入
                                 * UserControl.Messages inputMsg = new UserControl.Messages();
                                 * string strInput = receivedData;
                                 * if (action is Action.ActionPassword)
                                 * {
                                 *  strInput = new string('*', receivedData.Length);
                                 * }
                                 * inputMsg.Add(new UserControl.Message(strInput));
                                 * stack.SendMessage(client, inputMsg);
                                 */

                                // 执行Action
                                if (stack.CancelActionOutput == false)
                                {
                                    stack.SendMessage(client, action.Do(client), "");
                                }
                                else
                                {
                                    action.Do(client);
                                    stack.CancelActionOutput = false;
                                }
                                //stack.CurrentDirect = action.FlowDirect;
                            }

                            /*
                             * SuperCommand(strRec);
                             *
                             * action = stack.GetNextAction();
                             * stack.SendMessage(client,action.Do(client));
                             * stack.CurrentDirect = action.FlowDirect;
                             */
                        }
                        catch (Exception ex)
                        {
                            UserControl.FileLog.FileLogOut("DCTControlPanel.log", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + ex.StackTrace);
                            UserControl.Messages msg = new UserControl.Messages();
                            msg.Add(new UserControl.Message(ex));
                            stack.SendMessage(client, msg, "");
                            if (action != null)
                            {
                                //stack.CurrentDirect = action.FlowDirect;
                            }
                        }
                    }
                }
            }
        }
示例#12
0
        public void RequestInputFromRoot(string receivedData)
        {
            BaseDCTAction action = null;

            if (receivedData != null)
            {
                ((DSC19Client)client).RecieveDataFromRoot(receivedData);
                if (receivedData.IndexOf("ALL RIGHTS") < 0 && receivedData != String.Empty)
                {
                    client.RecievedData = receivedData;
                    try
                    {
                        if (receivedData.IndexOf("DCS-19 SELF-RESET OK") >= 0)  // 终端启动
                        {
                            receivedData = "LOGIN";
                            UserControl.Messages loginMsg = new UserControl.Messages();
                            loginMsg.Add(new UserControl.Message("$DCT_LOGIN"));
                            stack.SendMessage(client, loginMsg, "");

                            /*
                             * if (timer == null)
                             * {
                             *  timer = new System.Threading.Timer(new System.Threading.TimerCallback(this.ResponseTimerCallback), this, 0, System.Threading.Timeout.Infinite);
                             * }
                             */
                            if (threadResponse == null)
                            {
                                System.Threading.ThreadStart threadStart = new System.Threading.ThreadStart(this.ResponseTimerCallback);
                                threadResponse = new System.Threading.Thread(threadStart);
                                threadResponse.Start();
                            }
                            return;
                        }
                        bInRequestExecute = true;
                        if (receivedData == EXIT)
                        {
                            IsInputedLoginCmd = false;
                        }
                        else if (receivedData == LOGIN && IsInputedLoginCmd == true)            // 输入LOGIN,要先退出
                        {
                            receivedData      = EXIT;
                            IsInputedLoginCmd = false;
                        }
                        if (receivedData == EXIT)
                        {
                            this.RaiseAfterLogout();

                            /*
                             * if (timer != null)
                             * {
                             *  timer = null;
                             *  System.Threading.Thread.Sleep(20);
                             *  System.Windows.Forms.Application.DoEvents();
                             * }
                             */
                            if (threadResponse != null)
                            {
                                threadResponse.Abort();
                                System.Threading.Thread.Sleep(20);
                                System.Windows.Forms.Application.DoEvents();
                                threadResponse = null;
                            }
                            stack = new BaseActionStack();
                        }

                        DealSuperCommand(receivedData);

                        if (!client.Authorized)
                        {
                            Login();
                        }

                        bool bIsLoginCmd = false;
                        if (IsInputedLoginCmd == false && !client.Authorized)   // 如果还没有输入登录命令,而且客户端没有登录
                        {
                            bIsLoginCmd       = true;
                            IsInputedLoginCmd = true;
                        }
                        if (client.Authorized || bIsLoginCmd == false)  // 如果是登录命令,则不用再次执行Action,以免将命令当做用户名
                        {
                            // 获取现在的Action
                            action = stack.GetNextAction();

                            // 输出原始输入
                            UserControl.Messages inputMsg = new UserControl.Messages();
                            string strInput = receivedData;
                            if (action is Action.ActionPassword)
                            {
                                strInput = new string('*', receivedData.Length);
                            }
                            inputMsg.Add(new UserControl.Message(strInput));
                            stack.SendMessage(client, inputMsg, "");

                            // 执行Action
                            if (stack.CancelActionOutput == false)
                            {
                                stack.SendMessage(client, action.Do(client), "");
                            }
                            else
                            {
                                action.Do(client);
                                stack.CancelActionOutput = false;
                            }
                            //stack.CurrentDirect = action.FlowDirect;
                        }

                        /*
                         * if (timer == null)
                         * {
                         *  timer = new System.Threading.Timer(new System.Threading.TimerCallback(this.ResponseTimerCallback), this, 0, System.Threading.Timeout.Infinite);
                         * }
                         */
                        if (threadResponse == null)
                        {
                            System.Threading.ThreadStart threadStart = new System.Threading.ThreadStart(this.ResponseTimerCallback);
                            threadResponse = new System.Threading.Thread(threadStart);
                            threadResponse.Start();
                        }
                    }
                    catch (Exception ex)
                    {
                        UserControl.Messages msg = new UserControl.Messages();
                        msg.Add(new UserControl.Message(ex));
                        stack.SendMessage(client, msg, "");
                        // Added by Icyer 2006/12/14
                        if (action != null && action.NeedCancel == true)
                        {
                            action.NeedCancel = false;
                            //this.Cancel();
                            UserControl.Messages msgTmp = new UserControl.Messages();
                            msgTmp.Add(new UserControl.Message(UserControl.MessageType.Normal, "$DCT_Please_Input_SN_OR_Directive"));
                            stack.SendMessage(client, msgTmp, "");
                        }
                        // Added end
                        if (action != null)
                        {
                            //stack.CurrentDirect = action.FlowDirect;
                        }
                    }
                    bInRequestExecute = false;
                }
            }
        }