Exemplo n.º 1
0
        private void newSessionBtn_Click(object sender, EventArgs e)
        {
            SessionList.ClearSelected();
            newSessionBtn.Checked = true;
            sessionFile.Text      = "";

            SessionCotroller.newPath();
        }
Exemplo n.º 2
0
        private void sessionCheck_Click(object sender, EventArgs e)
        {
            OpenFileDialog ofd = new OpenFileDialog();

            if (ofd.ShowDialog() == DialogResult.OK)
            {
                SessionCotroller.Path = ofd.FileName;
                SessionCotroller.ReadToLast();
                sessionLabel.Text = SessionCotroller.Session + " " + SessionCotroller.LastRecord;
            }
        }
Exemplo n.º 3
0
        public MainForm()
        {
            InitializeComponent();

            Logger.ShowLog    += ConsoleWriteLine;
            Output.ShowResult += PrintResult;

            LoadFilters();
            timeOutInput.Value = 3;
            AvrgTime           = 0;
            domainPingBox.Text = "ya.ru";
            providerName       = ProviderNameBox.Text;
            canceled           = false;

            SessionCotroller.Session = DateTime.Now.ToString("yyyyMMddHHmmss");
            SessionCotroller.newPath();
        }
Exemplo n.º 4
0
        private void buttonStart_Click(object sender, EventArgs e)
        {
            if (!newSessionBtn.Checked)
            {
                filePath           = SessionCotroller.Session.FilePath;
                filePathLabel.Text = filePath;
            }
            else
            {
                SessionCotroller.CreateNew();
            }

            if (filePath == "" || filePath == null)
            {
                richTextBox.AppendText(new string('-', 50));
                richTextBox.AppendText("\nФайл не выбран\n");
                richTextBox.AppendText(new string('-', 50));
            }
            else
            {
                buttonStart.Enabled = false;
                buttonStop.Enabled  = true;
                progressBar.Value   = progressBar.Minimum;
                resultBox.Clear();
                canceled = false;

                Output.Write("File: " + filePath);

                ThreadPool.QueueUserWorkItem(_ =>
                {
                    DoTraceRoute();
                    Requester.LoadDomains();
                    Requester.LoadStubs();

                    ThreadPool.QueueUserWorkItem(__ =>
                    {
                        Work();
                    });
                });
            }
        }
Exemplo n.º 5
0
        public MainForm()
        {
            InitializeComponent();

            Logger.ShowLog    += ConsoleWriteLine;
            Output.ShowResult += PrintResult;

            SessionCotroller.Initialize();

            SessionCotroller.CreateNew();
            newSessionBtn.Checked = true;

            LoadSession();
            SessionList.ClearSelected();
            newSessionBtn.Checked = true;
            sessionFile.Text      = "";

            LoadFilters();
            timeOutInput.Value = 3;
            domainPingBox.Text = "ya.ru";
            providerName       = ProviderNameBox.Text;
            canceled           = false;
        }
Exemplo n.º 6
0
        void Work()
        {
            Stopwatch sw_total = new Stopwatch();

            sw_total.Start();


            //	Parallel.For(0, reader.records.Count, i =>
            //	{
            //		if (!canceled)
            //		{
            //			reader.records[i].Status = Requester.Send(reader.records[i].GetURL(), timeOut);
            //
            //			Logger.Log(string.Format("HOST {0} is {1}", reader.records[i].GetURL(), reader.records[i].Status));
            //			Logger.Log(string.Format("[{0} of {1}] at [{2}] s", completed, reader.records.Count, sw_total.ElapsedMilliseconds / 1000));
            //
            //			completed++;
            //			ProgressBarChanged(reader.records.Count);
            //		}
            //
            //	});


            int completed = 0;
            int counter   = 0;

            try
            {
                Logger.Log("\n******Begin Reading********\n");
                totalLines = File.ReadAllLines(filePath).Length;

                Logger.Log(string.Format("File: " + filePath));
                Logger.Log(string.Format("Total Lines: " + totalLines));
                //	SessionCotroller.Write(filePath));
                //	SessionCotroller.Write("Total Lines: " + totalLines);
                //	SessionCotroller.Write(new string('-',50));


                ProgressBarMax(totalLines);
                Record record;

                Output.Write(string.Format("MachineName: {0} ProviderName: {1} Total {2} URL's\n",
                                           Environment.MachineName, providerName, totalLines));
                Output.Write(new string('=', 100));

                using (StreamReader sr = new StreamReader(filePath, System.Text.Encoding.Default))
                {
                    string   line;
                    string[] temp;



                    for (completed = SessionCotroller.LastRecord; completed < totalLines; completed++)
                    {
                        line = sr.ReadLine();

                        if (canceled)
                        {
                            break;
                        }

                        //if (completed > SessionCotroller.LastRecord)
                        //{
                        temp = line.Split('\t');

                        record = new Record(long.Parse(temp[0]), temp[1], temp[2], temp[3], temp[4]);

                        //records.Add(new Record(temp[0], temp[1], temp[2]));
                        //records.Add(new Record(long.Parse(temp[0]), temp[1], temp[2], temp[3], temp[4]));
                        Logger.Log(string.Format("#{0} URL: {1} DOMAIN: {2} IP: {3}", temp[0], temp[4], temp[3], temp[2]));
                        record.Status = Requester.Send(record.GetURL(), timeOut);

                        Logger.Log(string.Format("HOST {0} is {1}", record.GetURL(), record.Status));



                        if (record.Status == Status.Available)
                        {
                            Output.Write(record.ToString());
                            counter++;
                        }

                        completed++;
                        SessionCotroller.Write(completed.ToString(), filePath);
                        Logger.Log(string.Format("[{0} of {1}] at [{2}] s", completed, totalLines, sw_total.Elapsed.Seconds));
                        ProgressBarChanged(completed);
                        double calc = sw_total.Elapsed.TotalSeconds / completed * totalLines;
                        UpdateTimer(calc - sw_total.Elapsed.TotalSeconds);
                    }

                    //}

                    Output.Write((string.Format("[{0} of {1}] Avaible", counter, totalLines)));
                    Output.Write(new string('=', 100));

                    if (completed == totalLines)
                    {
                        SessionCotroller.Write(new string('-', 100), filePath, true);
                    }
                }
            }
            catch (Exception ex)
            {
                Logger.Log(ex.Message);
            }
            //-------------вывод результата таймера----------------------------------------------------------------------//
            sw_total.Stop();
            Logger.Log(string.Format("Checked [{0}] URL's at [{1}] ms", completed, sw_total.ElapsedMilliseconds));



            //sw_total.Stop();

            Console.WriteLine("Total Time: [{0} s]", sw_total.ElapsedMilliseconds / 1000);
            Logger.Log(string.Format("Total Time: [{0} s]", sw_total.ElapsedMilliseconds / 1000));

            //foreach (var item in reader.records)
            //{
            //	Logger.Log(item.ToString());
            //}


            //	Output.InTXT(reader.records, providerName);
            //	PrintResult(reader.records);

            //Logger.WriteLogs();
        }
Exemplo n.º 7
0
 private void LoadSession()
 {
     SessionCotroller.Scan();
     SessionList.DataSource = SessionCotroller.List;
 }