Exemple #1
0
        void UdpClient_UDPReceivedEvent(object sender, ReceivedEventArgs args)
        {
            if (args.Content != null)
            {
                string result = Encoding.UTF8.GetString(args.Content);
                if (result != null && result.StartsWith(CommandConst.ROBOT_ONLINE))
                {
                    if (ResultDict.ContainsKey(args.Remote.ToString()))
                    {
                        return;
                    }

                    string txt = result.Replace(CommandConst.ROBOT_ONLINE, string.Empty).Trim();
                    ResultDict.TryAdd(args.Remote.ToString(), txt);

                    if (RobotResponseEvent != null)
                    {
                        ProgressEventArgs pea = new ProgressEventArgs();
                        pea.Remote       = args.Remote;
                        pea.ResponseText = txt;
                        RobotResponseEvent(this, pea);
                    }
                }
            }
        }
Exemple #2
0
        public string SaveResultDict()
        {
            var filename = DateTime.Now.ToString("yyyyMMddHHmmss") + "synonym.txt";
            var lines    = ResultDict.Select(p => $"{p.Value}=>{p.Key}").ToList();

            System.IO.File.WriteAllLines($@"{filename}", lines);

            return(filename);
        }