Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Collections;
- using System.IO;
- using System.Linq;
- using System.Net;
- using System.Text;
- using System.Text.RegularExpressions;
- using System.Threading;
- using System.Threading.Tasks;
- //using Lexicons;
- namespace ConsoleApplication2
- {
- public class Program
- {
- //private static List<KeyValuePair<string, string>> firstNames = new List<KeyValuePair<string, string>>();
- static void Main(string[] args)
- {
- //Consider making this configurable
- const string sourceFile = "testSolar.txt";
- //const string pattern = "http://10.123.9.66:80";
- //var FirstSeparatorLastNameExact = new[] { "nosyn_name_last_exact:(qxq" };
- //var SecondSeparatorLastNameExact = new[] { "qxq)" };
- string[] FirstSeparator = new string[] { "nosyn_name_last_exact:(qxq" };
- string[] SecondSeparator = new string[] { "qxq)" };
- string[] FirstSeperatorFirstName = new string[] { "nosyn_name_first_exact:(qxq" };
- string[] secondSeperatorFirstName = new string[] { "qxq)" };
- string[] nameLastBFirst = new string[] {"nosyn_name_last_b_exact:(qxq" };
- string[] nameLastBSecond = new string[] {"qxq)"};
- Regex re = new Regex("^(http|https)://");
- HttpWebResponse response;
- // var webClient = new WebClient();
- var times = new Dictionary<string, TimeSpan>();
- var stopwatch = new System.Diagnostics.Stopwatch();
- //Add header so if headers are tracked, it will show it is your application rather than something ambiguous
- //webClient.Headers.Add(HttpRequestHeader.UserAgent, "Response-Tester-Client");
- var urlList = new List<string>();
- var listNames = new List<string>();
- //var firstname = new List<string>();
- var firstNames = new Dictionary<string, string>();
- List<KeyValuePair<string, string>> list = new List<KeyValuePair<string, string>>();
- //var firstNames = new Func<string, string>();
- //Loop through the lines in the file to get the urls
- try
- {
- stopwatch.Start();
- using (var reader = new StreamReader(sourceFile))
- {
- while (!reader.EndOfStream)
- {
- //var urNewList = new List<string>();
- var line = reader.ReadLine();
- var columns = line.Split('t');
- if (columns[2] == "R")
- {
- var url = columns[4] + "?" + columns[5];
- urlList.Add(url);
- //Thread.Sleep(250);
- }
- var temp = line.Split(FirstSeparator, StringSplitOptions.RemoveEmptyEntries)[1];
- var result2 = temp.Split(SecondSeparator, StringSplitOptions.RemoveEmptyEntries)[0];
- //Console.WriteLine(result2);
- listNames.Add(result2);
- foreach (KeyValuePair<string, string> pair in firstNames)
- {
- var split = line.Split(FirstSeperatorFirstName, StringSplitOptions.RemoveEmptyEntries);
- if (split.Length > 1)
- {
- var hallo = (split[1].Split(')')[0]);
- Console.WriteLine(pair.Key + "....." + pair.Value + "<br />");
- }
- }
- }
- }
- }
- catch (Exception e)
- {
- Console.WriteLine("An error occured while attempting to access the source file at {0}", sourceFile);
- }
- finally
- {
- //Stop, record and reset the stopwatch
- stopwatch.Stop();
- times.Add("FileReadTime", stopwatch.Elapsed);
- stopwatch.Reset();
- }
- //Try to connect to each url
- var counter = 1;
- foreach (var url in urlList)
- {
- try
- {
- stopwatch.Start();
- using (WebClient webClient = new WebClient())
- {
- webClient.Headers.Add(HttpRequestHeader.UserAgent, "Response-Tester-Client");
- // HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
- HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
- request.Method = "POST";
- //webClient.Dispose();
- }
- }
- catch (Exception e)
- {
- Console.WriteLine("An error occured while attempting to connect to {0}", url);
- }
- finally
- {
- stopwatch.Stop();
- //We use the counter for a friendlier url as the current ones are unwieldly
- times.Add("Url " + counter, stopwatch.Elapsed);
- counter++;
- stopwatch.Reset();
- }
- }
- //Release the resources for the WebClient
- //webClient.Dispose();
- //Write the response times
- Console.WriteLine("Url " + "ttttLast Name" + "ttt first Name");
- int index = -1;
- foreach (var key in times.Keys)
- {
- if (key.Contains("Url"))
- {
- index++;
- var temp = firstNames.ContainsKey(listNames[index]) ? "tt" + listNames[index] + "tt" + firstNames[listNames[index]] : "tt" + listNames[index];
- Console.WriteLine("{0}: {1} {2}", key, times[key].TotalSeconds, temp);
- }
- else
- {
- Console.WriteLine("{0}: {1}", key, times[key].TotalSeconds);
- }
- }
- Console.ReadKey();
- }
- }
- }
- foreach (KeyValuePair<string, string> pair in firstNames)
- {
- var split = line.Split(FirstSeperatorFirstName, StringSplitOptions.RemoveEmptyEntries);
- if (split.Length > 1)
- {
- var hallo = (split[1].Split(')')[0]);
- Console.WriteLine(pair.Key + "....." + pair.Value + "<br />");
- }
- }
- 2014-08-25 14:20:45,930 DEV hmb0uqzc10s0ounwdhpwmflp 1 R O http://10.123.9.66:80/solr_3.6/combi_live/select/ qt=standard_a2aperson&q=(((((nosyn_name_last_b_exact:(qxqkruijsqxq))))))&fq=(nosyn_name_first_exact:(qxqw*qxq))&fq=(nosyn_name_last_exact:(qxqtreurenqxq))&spellcheck.q=(qxqw*qxq qxqtreurenqxq kruijs)&spellcheck=true&spellcheck.count=-3&start=0&sort=date_main asc, score desc&omitHeader=true
- 2014-08-25 14:20:45,478 DEV z5gyjtcexs41vra4yegqejcf 0 R . http://10.123.9.66:80/solr_3.6/combi_live/select/ qt=standard_a2aperson&q=(((((nosyn_name_last_b_exact:(qxqkuilenburgqxq))))))&fq=(nosyn_name_last_exact:(qxqbroekqxq))&spellcheck.q=(qxqbroekqxq kuilenburg)&fq=(fk_collectiontype:6)&spellcheck=true&spellcheck.count=-3&start=10&sort=date_main asc, score desc&omitHeader=true
- 2014-08-25 14:20:43,949 DEV belkbyavlahok0jrvoutn2xd 21 R O http://10.123.9.66:80/solr_3.6/wiewaswie_live/select/ qt=standard_a2aperson&q=*:*&fq=(nosyn_name_last_exact:(qxqroelofqxq))&fq=(nosyn_name_patronym_exact:(qxqharmsqxq))&spellcheck.q=(qxqroelofqxq qxqharmsqxq)&fq={!tag%3Dalldoctypes}doc_type:1&fq=date_main:[0 TO 18133112]&facet.query={!ex%3Dalldoctypes}doc_type:3 AND (b_public:1)&facet.query={!ex%3Dalldoctypes}doc_type:2 AND (b_public:1)&spellcheck=true&spellcheck.count=-3&start=0&sort=name_last asc, score desc&omitHeader=true
- 2014-08-25 14:20:43,949 DEV belkbyavlahok0jrvoutn2xd 21 R O http://10.123.9.66:80/solr_3.6/wiewaswie_live/select/ qt=standard_a2aperson&q=*:*&fq=(nosyn_name_last_exact:(qxqroelofqxq))&fq=(nosyn_name_patronym_exact:(qxqharmsqxq))&spellcheck.q=(qxqroelofqxq qxqharmsqxq)&fq={!tag%3Dalldoctypes}doc_type:1&fq=date_main:[0 TO 18133112]&facet.query={!ex%3Dalldoctypes}doc_type:3 AND (b_public:1)&facet.query={!ex%3Dalldoctypes}doc_type:2 AND (b_public:1)&spellcheck=true&spellcheck.count=-3&start=0&sort=name_last asc, score desc&omitHeader=true
- var temp = firstNames.ContainsKey(listNames[index]) ? "tt" + listNames[index] + "tt" + firstNames[listNames[index]] : "tt" + listNames[index];
- foreach (KeyValuePair<string, string> pair in firstNames)
- {
- var split = line.Split(FirstSeperatorFirstName, StringSplitOptions.RemoveEmptyEntries);
- if (split.Length > 1)
- {
- var hallo = (split[1].Split(')')[0]);
- Console.WriteLine(pair.Key + "....." + pair.Value + "<br />");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement