Example #1
0
        public List <ResolvedNetObj> GetResolvedNetObj(List <string> CurrentNetObj)
        {
            if (progressBar2.InvokeRequired)
            {
                progressBar2.BeginInvoke(new MethodInvoker(() => progressBar2.Maximum = CurrentNetObj.Count));
            }
            else
            {
                progressBar2.Maximum = CurrentNetObj.Count;
            }

            if (progressBar2.InvokeRequired)
            {
                progressBar2.BeginInvoke(new MethodInvoker(() => progressBar2.Value = 0));
            }
            else
            {
                progressBar2.Value = 0;
            }

            List <ResolvedNetObj> CurrentResolvedNetObjs = new List <ResolvedNetObj>();

            foreach (string OneNetObj in CurrentNetObj)
            {
                string         s      = OneNetObj.Replace("Not ", "").Trim();
                ResolvedNetObj TmpRNO = new ResolvedNetObj(s, OneNetObj.Contains("Not "));

                CurrentResolvedNetObjs.Add(TmpRNO);

                if (progressBar2.InvokeRequired)
                {
                    progressBar2.BeginInvoke(new MethodInvoker(() => progressBar2.Value++));
                }
                else
                {
                    progressBar2.Value++;
                }

                System.Windows.Forms.Application.DoEvents();
            }
            return(CurrentResolvedNetObjs);
        }
Example #2
0
        public void AddWStoWB(ResolvedNetObj SingleNetObj, Workbook WB)
        {
            Worksheet tmpWS = (Worksheet)WB.Worksheets.Add();

            tmpWS.Name = SingleNetObj.NetObjName.Replace("?", "").Replace("!", "").Replace(";", "").Trim();
            //tmpWS.Tab.Color = System.Drawing.ColorTranslator.ToOle(System.Drawing.Color.Red);

            tmpWS.Cells[1, 1].Value = "Имя";
            tmpWS.Cells[1, 2].Value = "IP";
            tmpWS.Cells[1, 3].Value = "Маска";

            for (int j = 0; j < SingleNetObj.ResolvedObj.Count; j++)
            {
                tmpWS.Cells[j + 2, 1].Value = SingleNetObj.ResolvedObj[j][0];
                tmpWS.Cells[j + 2, 2].Value = SingleNetObj.ResolvedObj[j][1];
                tmpWS.Cells[j + 2, 3].Value = SingleNetObj.ResolvedObj[j][2];
            }

            tmpWS.Columns.AutoFit();
        }
Example #3
0
        public void AddAllNodeList(Workbook WB)
        {
            List <NetInfo> AllNets = GetNets();

            Worksheet tmpWS = (Worksheet)WB.Sheets.Add(Missing.Value, Missing.Value, Missing.Value, Missing.Value);

            tmpWS.Activate();
            tmpWS.Name = "AllNode";

            tmpWS.Cells[2, 1].Value = "Динамический объект";
            tmpWS.Cells[2, 2].Value = "FQDN (если применимо)";
            tmpWS.Cells[2, 3].Value = "IP/MASK";
            tmpWS.Cells[2, 4].Value = "Включенные объекты (для групп)";
            tmpWS.Cells[2, 5].Value = "Система (сервис)";
            tmpWS.Cells[2, 6].Value = "Сегмент сети";
            tmpWS.Cells[2, 7].Value = "Категория обрабатываемой информации";
            tmpWS.Cells[2, 8].Value = "Примечание";

            int i = 3;

            if (progressBar2.InvokeRequired)
            {
                progressBar2.BeginInvoke(new MethodInvoker(() => progressBar2.Maximum = NetworkObj.Count * 2));
            }
            else
            {
                progressBar2.Maximum = NetworkObj.Count * 2;
            }

            if (progressBar2.InvokeRequired)
            {
                progressBar2.BeginInvoke(new MethodInvoker(() => progressBar2.Value = 0));
            }
            else
            {
                progressBar2.Value = 0;
            }

            List <ResolvedNetObj> AllNodesToNodeList = new List <ResolvedNetObj>();

            foreach (List <IEnumerable <string> > OneNetObj in NetworkObj)
            {
                ResolvedNetObj tmp = new ResolvedNetObj(OneNetObj[0].ToList()[0].Trim().ToLower());
                AllNodesToNodeList.Add(tmp);

                if (progressBar2.InvokeRequired)
                {
                    progressBar2.BeginInvoke(new MethodInvoker(() => progressBar2.Value++));
                }
                else
                {
                    progressBar2.Value++;
                }
                System.Windows.Forms.Application.DoEvents();
            }

            foreach (ResolvedNetObj oneNetObj in AllNodesToNodeList)
            {
                if (i == 237)
                {
                    continue;
                }

                tmpWS.Cells[i, 1].Value = oneNetObj.NetObjName;
                if (oneNetObj.ResolvedObj.Count > 1)
                {
                    string Entre4Cell = "";
                    foreach (List <string> OneResNetObj in oneNetObj.ResolvedObj)
                    {
                        Entre4Cell += OneResNetObj[0] + Environment.NewLine;
                    }
                    tmpWS.Cells[i, 4].Value = Entre4Cell.Trim();
                }
                else
                {
                    tmpWS.Cells[i, 3].Value = oneNetObj.ResolvedObj[0][1] + oneNetObj.ResolvedObj[0][2];
                    List <NetInfo> InfoAboutNetFromIPDB = AllNets.Where(n => n.Net.Replace("/32", "") == oneNetObj.ResolvedObj[0][1] + oneNetObj.ResolvedObj[0][2]).ToList();
                    if (InfoAboutNetFromIPDB.Count == 0 && oneNetObj.ResolvedObj[0][2] == "")
                    {
                        InfoAboutNetFromIPDB = AllNets.Where(n => IP2Int(oneNetObj.ResolvedObj[0][1]) >= n.StartIP && IP2Int(oneNetObj.ResolvedObj[0][1]) <= n.EndIP).ToList();
                    }
                    if (InfoAboutNetFromIPDB.Count > 0)
                    {
                        tmpWS.Cells[i, 6].Value = InfoAboutNetFromIPDB[0].Descr.Replace("/", "").Replace("\\", "").Trim().ToString(new CultureInfo("en-US"));
                    }
                }

                if (progressBar2.InvokeRequired)
                {
                    progressBar2.BeginInvoke(new MethodInvoker(() => progressBar2.Value++));
                }
                else
                {
                    progressBar2.Value++;
                }
                System.Windows.Forms.Application.DoEvents();

                i++;
            }

            Microsoft.Office.Interop.Excel.Range c1 = tmpWS.Cells[2, 1];
            Microsoft.Office.Interop.Excel.Range c2 = tmpWS.Cells[2, 8];
            Range oRange = (Microsoft.Office.Interop.Excel.Range)tmpWS.get_Range(c1, c2);

            oRange.Interior.Color = System.Drawing.ColorTranslator.ToOle(System.Drawing.Color.Gray);
            oRange.Font.Bold      = true;

            c1     = tmpWS.Cells[1, 1];
            c2     = tmpWS.Cells[i, 8];
            oRange = (Microsoft.Office.Interop.Excel.Range)tmpWS.get_Range(c1, c2);
            oRange.Columns.AutoFit();
            oRange.Rows.AutoFit();

            tmpWS.Cells[1, 1].Font.Size = 18;
            tmpWS.Cells[1, 1].Font.Bold = true;
            tmpWS.Cells[1, 1].Value     = "Описание объектов";

            tmpWS.Application.ActiveWindow.SplitRow    = 2;
            tmpWS.Application.ActiveWindow.FreezePanes = true;
        }