Ejemplo n.º 1
0
        public string GetDescriptions(ColumnsData CD)
        {
            Dictionary <string, Type> tmpDct = db.GetAllAnswerTypes(InfoType);

            string[] buf = new string[tmpDct.Keys.Count + 1];
            int      i   = 0;

            foreach (string Key in tmpDct.Keys)
            {
                buf[i] = CD.GetDesription(Key);
                i++;
            }
            buf[i] = CD.GetDesription("status");

            return(string.Join(";", buf));
        }
Ejemplo n.º 2
0
        public void AddToDataGridView(string IP, DataGridView Grid, ColumnsData CD)
        {
            Dictionary <string, object> Info = GetIPInfo(IP);

            foreach (string Key in Info.Keys)
            {
                Grid.Rows.Add(CD.GetDesription(Key), Info[Key]);
            }
        }
Ejemplo n.º 3
0
        public string GetDescriptions(ColumnsData CD)
        {
            string[] buf = new string[dsTorData.Tables[TableName].Columns.Count];
            int      i   = 0;

            foreach (DataColumn col in dsTorData.Tables[TableName].Columns)
            {
                buf[i] = CD.GetDesription(col.ColumnName);
                i++;
            }

            return(string.Join(";", buf));
        }
Ejemplo n.º 4
0
        public int Find(string IP, ColumnsData cd)
        {
            CSVErrorEventArgs e = new CSVErrorEventArgs();

            DataRow[] selected = null;
            if (DataFormat == FormatType.IPList)
            {
                IPField = "IP";
            }
            try
            {
                selected = dsTorData.Tables[TableName].
                           Select("[" + IPField + "]='" + IP + "'");
            }
            catch (Exception ex)
            {
                ErrorMessage   = ex.Message;
                e.ErrorMessage = ex.Message;
                if (CSVError != null)
                {
                    CSVError(e);
                }
                return(0);
            }

            if (selected == null)
            {
                return(0);
            }
            if (selected.Length == 0)
            {
                return(0);
            }

            OutputGrid.Columns.Clear();

            OutputGrid.Columns.Add("Desr", "Параметр");
            OutputGrid.Columns.Add("Value", "Значение");

            foreach (DataRow row in selected)
            {
                foreach (DataColumn col in dsTorData.Tables[TableName].Columns)
                {
                    string Desr  = cd.GetDesription(col.ColumnName);
                    string Value = row[col].ToString();
                    OutputGrid.Rows.Add(Desr, Value);
                }
            }
            return(selected.Length);
        }
Ejemplo n.º 5
0
        private void frmViewAll_Load(object sender, EventArgs e)
        {
            ColumnsData cd = new ColumnsData(CommonFunctions.SettingsPath +
                                             CommonFunctions.ColumnsDesrFile);

            cd.LoadData();
            if (LoadedData.dsTorData.Tables[LoadedData.TableName] != null)
            {
                gridData.DataSource = LoadedData.dsTorData.Tables[LoadedData.TableName]
                                      .DefaultView;

                for (int i = 0; i < gridData.Columns.Count; i++)
                {
                    gridData.Columns[i].HeaderText =
                        cd.GetDesription(gridData.Columns[i].Name);
                }
                bRenaming = true;
                gridData_CurrentCellChanged(null, null);
            }
        }
Ejemplo n.º 6
0
        private void GetData()
        {
            IPGeoinfo GeoInfo = null;

            SendStatus(BatchFinderStatus.Working, "Получаю список IP...");
            string[] IPs = GetAllIPs();
            if (IPs == null)
            {
                SendStatus(BatchFinderStatus.Error, ErrorMessage);
                return;
            }

            SendStatus(BatchFinderStatus.Working, "Подготавливаю данные...");
            if (!string.IsNullOrEmpty(SxPath)) //открываем базу SxGeo
            {
                GeoInfo = new IPGeoinfo(SxPath);
                if (!GeoInfo.Open())
                {
                    ErrorMessage = GeoInfo.ErrorMessage;
                    SendStatus(BatchFinderStatus.Error, ErrorMessage);
                    return;
                }
            }

            //объект для отчета
            PrintReport Log = new PrintReport(OutputFile);

            //добавляем строку с полями
            string stFields = "";

            if (GeoInfo != null)
            {
                stFields = GeoInfo.GetDescriptions(ColData);
            }

            if (AllTorData)
            {
                stFields = stFields + ";" + ColData.GetDesription("In_Tor") +
                           ";" + CSVLoader.GetDescriptions(ColData);
            }
            else
            {
                stFields = stFields + ";" + ColData.GetDesription("In_Tor");
            }
            Log.ReportAdd(stFields);

            //начинаем обработку IP
            int Count    = IPs.Length;
            int Current  = 0;
            int ErrCount = 0;

            if (GeoInfo != null)
            {
                GeoInfo.PrepareBatch();
            }

            //обрабатываем IP
            foreach (string IP in IPs)
            {
                //прибавили счетчик, послали статус, подготовили буфер
                Current++;
                SendStatus(BatchFinderStatus.Working, "IP " + Current.ToString() + "/" +
                           Count.ToString());
                string buf    = string.Empty;
                string sxinfo = string.Empty;

                //информация SxGeo
                if (GeoInfo != null)
                {
                    sxinfo = GeoInfo.GetDataString(IP);
                }

                //информация Tor
                List <string> listTor = CSVLoader.FindList(IP);

                if (listTor == null) //ошибка
                {
                    SendStatus(BatchFinderStatus.Error, CSVLoader.ErrorMessage);
                    ErrCount++;
                    buf = sxinfo + ";" + CSVLoader.ErrorMessage;
                    Log.ReportAdd(buf);
                }
                else
                {
                    if (listTor.Count == 0) //не нашли
                    {
                        buf = sxinfo + ";Not found in TOR";
                        Log.ReportAdd(buf);
                    }
                    else
                    {
                        string found = ";Found (" + listTor.Count.ToString() + ")";

                        if (!AllTorData) //полная информация не нужна
                        {
                            buf = sxinfo + found;
                            Log.ReportAdd(buf);
                        }
                        else //нужна полная информация по tor-ноде(ам)
                        {
                            int torI = 0;
                            foreach (string node in listTor)
                            {
                                torI++;
                                buf = sxinfo + found + " #" + torI + ";"
                                      + node;
                                Log.ReportAdd(buf);
                            }
                        }
                    }
                }
                //конец обработки IP
            }
            //конец цикла обработки всех IP
            //сохраняем отчет
            if (!Log.ReportSave(OutputFile))
            {
                ErrorMessage = Log.ErrorMessage;
                SendStatus(BatchFinderStatus.Error, "Ошибка сохранения отчета: " +
                           ErrorMessage);
                return;
            }

            if (ErrCount != 0)
            {
                ErrorMessage = "При обработке адресов произошли ошибки.";
                SendStatus(BatchFinderStatus.Error, ErrorMessage);
            }
            else
            {
                SendStatus(BatchFinderStatus.Complete, "Отчет успешно сохранен.");
            }
        }