Ejemplo n.º 1
0
        /// <summary>
        /// Метод заполнения свойства IPArray стандартными ip адресами ЦВЗ
        /// </summary>
        public void CreateStandartListIP()
        {
            IPArray = new ObservableCollection <IP>();
            string armIP = Lan_Ip.Remove(Lan_Ip.Length - 4);

            IPArray.Add(new IP()
            {
                IPAddress = $"{this.WanIP}", Type = IPType.Маршрутизатор
            });
            IPArray.Add(new IP()
            {
                IPAddress = $"{armIP}.101"
            });
            IPArray.Add(new IP()
            {
                IPAddress = $"{armIP}.102"
            });
            IPArray.Add(new IP()
            {
                IPAddress = $"{armIP}.103"
            });
            IPArray.Add(new IP()
            {
                IPAddress = $"{armIP}.240"
            });
            IPArray.Add(new IP()
            {
                IPAddress = $"{armIP}.241"
            });
            IPArray.Add(new IP()
            {
                IPAddress = $"{armIP}.250"
            });
            IPArray.Add(new IP()
            {
                IPAddress = $"{armIP}.251"
            });
            IPArray.Add(new IP()
            {
                IPAddress = $"{armIP}.254"
            });
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Заполнение IP листа IPArray
        /// </summary>
        public void PopulateIPList()
        {
            IPAddress address;

            if (string.IsNullOrEmpty(this.SubnetMask))
            {
                this.SubnetMask = "255.255.255.0";
            }
            int num = this.CalculateHostCount(this.SubnetMask, 254);

            try
            {
                string[] curSubnetTemp = Lan_Ip.Split('.');
                curSubnetTemp[3] = "0";
                string curSubnet = "";
                bool   firstNumb = true;
                foreach (var str in curSubnetTemp)
                {
                    if (firstNumb)
                    {
                        curSubnet += str;
                        firstNumb  = false;
                    }
                    else
                    {
                        curSubnet += "." + str;
                    }
                }
                address = IPAddress.Parse(curSubnet);
                //address = IPAddress.Parse(NetMikrotik);
            }
            catch
            {
                this.DetectSubnetIP();
                return;
            }

            IPArray = new ObservableCollection <IP>();

            //if (this.Providers != null)
            //{
            //    for (int j = 0; j < this.Providers.Count; j++)
            //    {
            //        try
            //        {
            //            if ((this.Providers[j].ProvName == null) || !this.Providers[j].ProvName.Contains("Wi-Fi"))
            //            {
            //                if ((j > 0))
            //                {
            //                    break;
            //                }
            //                if (!string.IsNullOrEmpty(this.Providers[j].ExtGW))
            //                {
            //                    IP ip = new IP
            //                    {
            //                        Owner = this,
            //                        IPAddress = this.Providers[j].ExtGW,
            //                        Region = this.Region,
            //                        Description = "Шлюз провайдера"
            //                    };
            //                    if (j > 0)
            //                    {
            //                        ip.Description = ip.Description + " #" + j.ToString();
            //                    }
            //                    ip.Type = IPType.Маршрутизатор;
            //                    this.IPArray.Add(ip);
            //                }
            //                if (!string.IsNullOrEmpty(this.Providers[j].ExtIP))
            //                {
            //                    IP ip2 = new IP
            //                    {
            //                        Owner = this,
            //                        IPAddress = this.Providers[j].ExtIP,
            //                        Region = this.Region,
            //                        Description = "Внешний адрес"
            //                    };
            //                    if (j > 0)
            //                    {
            //                        ip2.Description = ip2.Description + " #" + j.ToString();
            //                    }
            //                    ip2.Type = IPType.Маршрутизатор;
            //                    this.IPArray.Add(ip2);
            //                }
            //            }
            //        }
            //        catch
            //        {
            //        }
            //    }
            //}
            string[] strArray = new string[0xfe]; //0xfe - число 254
                                                  //string[] strArray2 = new string[0x7f];  //0x7f - число 127
                                                  //try
                                                  //{
                                                  //    strArray = System.IO.File.ReadAllLines(AppDomain.CurrentDomain.BaseDirectory + @"SupportTools\im.dat");
                                                  //}
                                                  //catch
                                                  //{
                                                  //    for (int k = 0; k < strArray.Length; k++)
                                                  //    {
                                                  //        strArray[k] = "unknown";
                                                  //    }
                                                  //}
                                                  //try
                                                  //{
                                                  //    strArray2 = System.IO.File.ReadAllLines(AppDomain.CurrentDomain.BaseDirectory + @"support\top.dat");
                                                  //}
                                                  //catch
                                                  //{
                                                  //    for (int m = 0; m < strArray2.Length; m++)
                                                  //    {
                                                  //        strArray2[m] = "unknown";
                                                  //    }
                                                  //}
            int[] source = new int[] { 12, 13, 14 };
            for (int i = 1; i <= num; i++)        // цикл с проходом по общему количеству хостов
            {
                IP ip3 = new IP();
                try
                {
                    ip3.Owner  = this;
                    ip3.Region = this.Region;

                    //if (this.SubnetMask.EndsWith(".128"))
                    //{
                    //    ip3.Description = strArray2[i - 1];
                    //    ip3.Type = GetIMIPType(ip3.Description);
                    //}
                    //else
                    //{
                    //    if ((this.SubnetMask.EndsWith(".253") || this.SubnetMask.EndsWith(".254")) || this.SubnetMask.EndsWith(".255"))
                    //    {
                    //        ip3.Address = this.ExpandIpRange(address, i - 1).ToString();
                    //        if (ip3.Address.StartsWith("10.91"))
                    //        {
                    //            ip3.Description = "УТ";
                    //            ip3.Type = IPType.УТ;
                    //        }
                    //        else
                    //        {
                    //            ip3.Description = "АРМ";
                    //            ip3.Type = IPType.АРМ;
                    //        }
                    //        this.IPArray.Add(ip3);
                    //        return;
                    //    }
                    switch (i)
                    {
                    case 0xfe:
                        ip3.Description = "Маршрутизатор";
                        ip3.Type        = IPType.Маршрутизатор;
                        if (!string.IsNullOrWhiteSpace(this.Router))
                        {
                            ip3.Tooltip = this.Router;
                        }
                        break;

                    case 101:
                        ip3.Description = "АРМ УТТ";
                        ip3.Type        = IPType.АРМ;
                        break;

                    case 102:
                        ip3.Description = "АРМ ПТТ";
                        ip3.Type        = IPType.АРМ;
                        break;

                    case 103:
                        ip3.Description = "АРМ 3";
                        ip3.Type        = IPType.АРМ;
                        break;

                    case 0xfa:
                        ip3.Description = "Принтер";
                        ip3.Type        = IPType.Принтер;
                        break;

                    case 0xfb:
                        ip3.Description = "Камера IP";
                        ip3.Type        = IPType.КамераIP;
                        break;

                    case 0xf0:
                        ip3.Description = "Телефон IP";
                        ip3.Type        = IPType.ТелефонIP;
                        break;

                    case 0xf1:
                        ip3.Description = "Телефон Сервисный";
                        ip3.Type        = IPType.ТелефонСервисный;
                        break;

                    default:
                        ip3.Description = "Прочее";
                        ip3.Type        = IPType.Прочее;
                        break;
                    }

                    //}
                }
                catch
                {
                }
                ip3.IPAddress = this.ExpandIpRange(address, i).ToString();
                if ((ip3.Type == IPType.Маршрутизатор) && string.IsNullOrWhiteSpace(this.Gateway))
                {
                    this.Gateway = ip3.IPAddress;
                }
                this.IPArray.Add(ip3);
            }
        }