Esempio n. 1
0
        /// <summary>
        /// 监听客户端执行结果。并下载到本地。
        /// </summary>
        public void ListenClient()
        {
            while (true)
            {
                if (Stop)
                {
                    break;
                }
                try
                {
                    client = lister.AcceptTcpClient();
                }
                catch (Exception ex)
                {
                    ShowInfo(ex.Message);
                    break;
                }
                //有数据,则读取
                if (client.Available > 0)
                {
                    BinaryReader br  = new BinaryReader(client.GetStream());
                    string       msg = br.ReadString();

                    TelMsg tMsg = TelMsg.ParseXml(msg);
                    ShowInfo("收到信息,来自 " + tMsg.From + "," + msg);
                    if (tMsg.MsgType == MsgType.Path)
                    {
                        string localPath = Path.Combine(resultDir, Path.GetFileName(tMsg.XmlContent));
                        Geo.Utils.NetUtil.FtpDownload(tMsg.XmlContent, localPath);
                        ShowInfo("已经下载到本地" + localPath + "耗时:" + Geo.Utils.DateTimeUtil.GetFloatString(watch.Elapsed));

                        completedThreadCount++;
                        //int runCount = ComputeNodes.Count<GofComputeNode>(m => m.Enabled);
                        if (completedThreadCount + failedThreadCount == _taskCount)
                        {
                            AfterCompleted();
                        }
                        else//继续执行。
                        {
                            GofComputeNode node = ComputeNodes.Find(m => tMsg.From.Contains(m.Ip));
                            if (node != null)
                            {
                                InvokeComputeNodeTask(node);
                            }
                        }
                    }
                }
            }
        }
Esempio n. 2
0
        public void ListenClient()
        {
            try
            {
                while (true)
                {
                    if (Stop)
                    {
                        break;
                    }
                    try
                    {
                        client = lister.AcceptTcpClient();
                    }
                    catch (Exception ex)
                    {
                        ShowInfo(ex.Message);
                        break;
                    }
                    TelCommand cmd = new TelCommand(client);
                    list.Add(cmd);

                    string info = "来自" + cmd.LocalEndPoint + ",命令:" + cmd.CmdStr + "\r\n";
                    ShowInfo(info);
                    ShowInfo("开始执行任务....");

                    currentTask = Task.ParseXml(TelMsg.ParseXml(cmd.CmdStr).XmlContent);

                    runner = new TaskRunner(Gnsser.Interoperation.Bernese.BerBpe.BerGpsDataPath);
                    runner.InfoProduced += runner_InfoProduced;
                    runner.TaskFinished += runner_TaskFinished;
                    runner.RunAsyn(currentTask);
                }
            }
            catch (Exception ex)
            {
                if (!this.IsDisposed)
                {
                    ShowInfo("运行错误:" + ex.Message);
                }
            }
        }
Esempio n. 3
0
        public void ListenClient()
        {
            //try
            //{
            while (true)
            {
                if (Stop)
                {
                    break;
                }
                try
                {
                    TcpClient = TcpListener.AcceptTcpClient();
                }
                catch (Exception ex)
                {
                    ShowInfo(ex.Message);
                    break;
                }
                TelCommand cmd = new TelCommand(TcpClient);
                list.Add(cmd);

                string info = "来自" + cmd.LocalEndPoint + ",命令:" + cmd.CmdStr + "\r\n";
                ShowInfo(info);
                ShowInfo("开始执行任务....");

                //解析并保存到当前目录
                CurrentTask = GofTask.ParseXml(TelMsg.ParseXml(cmd.CmdStr).XmlContent);
                var localGofPath = SaveGofToLocal(CurrentTask);

                //开始执行
                var pathes = new string[] { localGofPath };
                this.AppendPathToTextBox(pathes);
                this.AddTasksAndRun(pathes);
            }
            //}
            //catch (Exception ex)
            //{
            //    if (!this.IsDisposed)
            //        ShowInfo("运行错误:" + ex.Message);
            //}
        }