示例#1
0
        private void btnBatchFind_Click(object sender, EventArgs e)
        {
            DialogResult Ans = dlgOpen.ShowDialog();

            if (Ans == DialogResult.Cancel)
            {
                return;
            }
            dlgSaveBatch.FileName = "";
            Ans = dlgSaveBatch.ShowDialog();
            if (Ans == DialogResult.Cancel)
            {
                return;
            }
            ReportName = dlgSaveBatch.FileName;

            ColumnsData cd = new ColumnsData(CommonFunctions.SettingsPath +
                                             CommonFunctions.ColumnsDesrFile);

            cd.LoadData();

            IPBatchFinder Finder = new IPBatchFinder(dlgOpen.FileName,
                                                     ReportName, CSVLoader, cd);

            Finder.AllTorData    = settings.Settings.AllTorData;
            Finder.SxPath        = SxPath;
            Finder.StatusChange += new IPBatchFinder.OnStatusChange(Finder_StatusChange);
            Finder.Start();
        }
示例#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]);
            }
        }
示例#3
0
 public IPBatchFinder(string inputfile, string outputfile,
                      CSVWork csvloader, ColumnsData coldata)
 {
     InputFile  = inputfile;
     OutputFile = outputfile;
     AllTorData = false;
     SxPath     = string.Empty;
     CSVLoader  = csvloader;
     ColData    = coldata;
 }
示例#4
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));
        }
示例#5
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);
        }
示例#6
0
        private void frmColumnsDesr_Load(object sender, EventArgs e)
        {
            ttInfo.SetToolTip(btnAdd, "Добавить");
            ttInfo.SetToolTip(btnEdit, "Редактировать");
            ttInfo.SetToolTip(btnDel, "Удалить");

            colData = new ColumnsData(CommonFunctions.SettingsPath +
                                      CommonFunctions.ColumnsDesrFile);
            if (!colData.LoadData())
            {
                CommonFunctions.ErrMessage(colData.ErrorMessage);
                return;
            }

            gvColumns.DataSource = colData.dsColumns.Tables[colData.TableName].DefaultView;
        }
示例#7
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));
        }
示例#8
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);
            }
        }
示例#9
0
        private void btnFind_Click(object sender, EventArgs e)
        {
            if (!IPConverter.IsIP(ipAddr.Text))
            {
                lblMessage.ForeColor = Color.Red;
                lblMessage.Text      = "Введите правильный IP-адрес!";
                return; //что-то не ввели до конца
            }

            ColumnsData cd = new ColumnsData(CommonFunctions.SettingsPath +
                                             CommonFunctions.ColumnsDesrFile);

            cd.LoadData();

            CSVLoader.OutputGrid = grdAnswer;
            CSVLoader.ClearFind();
            int count = CSVLoader.Find(ipAddr.Text, cd);

            if (count == 0)
            {
                if (!string.IsNullOrEmpty(CSVLoader.ErrorMessage))
                {
                    lblMessage.ForeColor = Color.Red;
                    lblMessage.Text      = CSVLoader.ErrorMessage;
                }
                else
                {
                    lblMessage.ForeColor = Color.Red;
                    lblMessage.Text      = "IP " + ipAddr.Text + " не найден в базе данных TOR.";
                }
            }
            else
            {
                lblMessage.ForeColor = Color.Green;
                lblMessage.Text      = "IP " + ipAddr.Text + " найден в базе данных TOR. " +
                                       count.ToString() + " вхождений";
            }

            if (!string.IsNullOrEmpty(SxPath))
            {
                IPGeoinfo GeoInfo = new IPGeoinfo(SxPath);

                if (!GeoInfo.Open())
                {
                    lblMessage.ForeColor = Color.Red;
                    lblMessage.Text      = lblMessage.Text + "Ошибка SxGeo: " +
                                           GeoInfo.ErrorMessage;
                    return;
                }

                if (grdAnswer.Columns.Count < 2)
                {
                    grdAnswer.Columns.Add("Desr", "Параметр");
                    grdAnswer.Columns.Add("Value", "Значение");
                }

                GeoInfo.AddToDataGridView(ipAddr.Text, grdAnswer, cd);

                lblMessage.Text = lblMessage.Text + " Поиск по базе SxGeo выполнен.";
            }
        }