internal void LoadList(ArchorDevList archors)
        {
            this.archors = archors;
            resultList   = new CommandResultManager();
            if (archors.ArchorList != null)
            {
                foreach (var item in archors.ArchorList)
                {
                    var group = resultList.Add(item);
                    //group.Archor.Ip = item.ArchorIp;
                    group.Archor.Area = item.InstallArea;
                }
            }

            UDPArchorList list = new UDPArchorList();

            foreach (var item in resultList.Groups)
            {
                list.Add(item.Archor);
                item.Archor.Num = list.Count;
            }

            archorList = list;
            if (ArchorListChanged != null)
            {
                ArchorListChanged(list, null);
            }
        }
        public void ScanArchors(ScanArg arg, UDPArchorList list)
        {
            if (arg == null)
            {
                return;
            }
            this.arg = arg;
            var ips = arg.ipsText.Split(';');

            archorPort = arg.port.ToInt();
            if (resultList == null)
            {
                resultList = new CommandResultManager();
            }
            StartTime();

            List <string> localIps = GetLocalIps(ips);

            if (arg.OneIPS)
            {
                List <string> allIps = new List <string>();
                foreach (var ip in localIps)
                {
                    var ipList = IpHelper.GetIPS(ip);
                    allIps.AddRange(ipList);
                }
                ScanArchors(arg.cmds, allIps.ToArray());
            }
            else if (arg.ScanList)
            {
                List <string> allIps = new List <string>();
                if (list != null)
                {
                    foreach (var archor in list)
                    {
                        allIps.Add(archor.GetIp());
                    }
                }
                else if (archors != null)
                {
                    foreach (var archor in archors.ArchorList)
                    {
                        allIps.Add(archor.ArchorIp);
                    }
                }
                else if (archorList != null)
                {
                    foreach (var archor in archorList)
                    {
                        allIps.Add(archor.GetClientIP());
                    }
                }
                ScanArchors(arg.cmds, allIps.ToArray());
            }
            else
            {
                ScanArchors(arg.cmds, localIps.ToArray());
            }
        }
Exemple #3
0
        internal void LoadArchorList(string path)
        {
            archorList = XmlSerializeHelper.LoadFromFile <UDPArchorList>(path);

            resultList = new CommandResultManager();
            foreach (var item in archorList)
            {
                var group = resultList.Add(item);
            }

            OnArchorListChanged(archorList, null);
        }
Exemple #4
0
        public void SearchArchor(string ipsText, string port)
        {
            resultList = new CommandResultManager();
            archorPort = port.ToInt();
            var ips = ipsText.Split(';');

            foreach (var ip in ips)
            {
                var localIp = IpHelper.GetLocalIp(ip);
                if (localIp != null)
                {
                    AddLog("存在IP段:" + ip);

                    var        udp        = GetLightUDP(localIp);
                    int        sleepTime  = 200;
                    IPEndPoint ipEndPoint = new IPEndPoint(IPAddress.Parse(ip), archorPort);
                    udp.SendHex(UDPCommands.GetServerIp, ipEndPoint);
                    Thread.Sleep(sleepTime);
                    udp.SendHex(UDPCommands.GetId, ipEndPoint);
                    Thread.Sleep(sleepTime);
                    udp.SendHex(UDPCommands.GetIp, ipEndPoint);
                    Thread.Sleep(sleepTime);
                    udp.SendHex(UDPCommands.GetPort, ipEndPoint);
                    Thread.Sleep(sleepTime);
                    udp.SendHex(UDPCommands.GetArchorType, ipEndPoint);
                    Thread.Sleep(sleepTime);
                    udp.SendHex(UDPCommands.GetDHCP, ipEndPoint);
                    Thread.Sleep(sleepTime);
                    udp.SendHex(UDPCommands.GetMask, ipEndPoint);
                    Thread.Sleep(sleepTime);
                    udp.SendHex(UDPCommands.GetGateway, ipEndPoint);
                    Thread.Sleep(sleepTime);
                    udp.SendHex(UDPCommands.GetSoftVersion, ipEndPoint);
                    Thread.Sleep(sleepTime);
                    udp.SendHex(UDPCommands.GetHardVersion, ipEndPoint);
                    Thread.Sleep(sleepTime);
                    udp.SendHex(UDPCommands.GetPower, ipEndPoint);
                    Thread.Sleep(sleepTime);

                    Thread.Sleep(1000);
                }
                else
                {
                    AddLog("不存在IP段:" + ip);
                    //MessageBox.Show("当前电脑不存在IP段:" + ips);
                }
            }
        }
        private void Udp_DGramRecieved1(object sender, BUDPGram dgram)
        {
            if (resultList == null)
            {
                resultList = new CommandResultManager();
            }
            var group = resultList.Add(dgram.iep, dgram.data);

            group.Archor.Value = ByteHelper.byteToHexStr(dgram.data);

            valueList.Add(dgram.iep, dgram.data);
            AddLog(string.Format("收到 :: {0}", group.ToString()));


            archorList = OnDataReceive(group);
        }
 internal void ClearBuffer()
 {
     resultList = new CommandResultManager();
 }