public void SendLogToRepo(string threadName, string tempLogPath, MessageClient msgSenderRepo, MessageServer msgReciever) { int trycount = 0; HiResTimer hrt = new HiResTimer(); while (trycount <= 5) { trycount++; Console.WriteLine("\n({0})Sending logs to repository...", threadName); Message msgToRepo = msgSenderRepo.SetupUploadMessageToRepo(threadName, tempLogPath, "http://localhost:4140/ICommService/BasicHttp", "http://localhost:8180/ICommService/BasicHttp"); msgSenderRepo.channel.PostMessage(msgToRepo); Console.WriteLine("\n({0})Waiting for message from repository...", threadName); hrt.Start(); Message msgFromRepo = msgReciever.TryGetMessage("Repository", threadName); hrt.Stop(); Console.WriteLine(""); Console.WriteLine("\n({0})Recieved message from repository in {0} microsec.", threadName, hrt.ElapsedMicroseconds); Console.WriteLine(""); TestLoadStatus loadStat = msgReciever.Parse(msgFromRepo); Console.WriteLine(loadStat.loadMessage); if (loadStat.status) { break; } if (trycount <= 5) { Thread.Sleep(500); continue; } throw new Exception("Failed sending logs to repository"); } }
public void THMsgProc() { while (true) { HiResTimer hrt = new HiResTimer(); Message msg = msgReciever.TryGetTHMessage(); Console.WriteLine("\n<--------------------------------------------------------->"); Console.WriteLine("\nMessage recieved from test harness."); if (msg.recipient == "AboutLog") { Console.WriteLine("\nDemonstrating test logs and results:"); TestResults tr = msgReciever.ParseResultMsg(msg); Console.WriteLine(tr.log); Console.WriteLine("\nDemonstrating querying results from repository:"); Console.WriteLine("\nSending message to repository..."); clientUtil.SetupQueryMessageToRepo(msgToRepoQuery, tr, "http://localhost:4244/ICommService/BasicHttp", "http://localhost:8284/ICommService/BasicHttp", "Upload"); msgSenderwithRepo.channel.PostMessage(msgToRepoQuery); Console.WriteLine("\nWaiting for message from repository..."); hrt.Start(); Message repoReply = msgReciever.TryGetRepoMessage("Query"); hrt.Stop(); Console.WriteLine(""); Console.WriteLine("\nRecieved message in {0} microsec.", hrt.ElapsedMicroseconds); Console.WriteLine(""); TestLoadStatus loadStatus = msgReciever.ParseLoadMsg(repoReply); Console.WriteLine(loadStatus.loadMessage); using (FileStream fs = new FileStream(System.IO.Path.Combine(System.IO.Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "..\\..\\..\\TestResults", tr.LogName + "Summary.txt"), FileMode.Open)) using (StreamReader sr = new StreamReader(fs)) { Dispatcher.Invoke( new Action <string>(ShowStringResult), System.Windows.Threading.DispatcherPriority.Background, new string[] { sr.ReadToEnd() }); } } else { Console.WriteLine("\nDemonstrating dll load status in test harness:"); Dispatcher.Invoke( new Action <string>(ShowLoadMsg), System.Windows.Threading.DispatcherPriority.Background, new string[] { msgReciever.ParseLoadMsg(msg).loadMessage }); } } }
public void THMsgProc() { while (true) { HiResTimer hrt = new HiResTimer(); Message msg = msgReciever.TryGetTHMessage(); Console.WriteLine("\n<--------------------------------------------------------->"); Console.WriteLine("\nMessage recieved from test harness."); if (msg.recipient == "AboutLog") { Console.WriteLine("\nDemonstrating test logs and results:"); TestResults tr = msgReciever.ParseResultMsg(msg); Console.WriteLine(tr.log); Console.WriteLine("\nDemonstrating querying results from repository:"); Console.WriteLine("\nSending message to repository..."); SetupQueryMessageToRepo(tr, "http://localhost:4048/ICommService/BasicHttp", "http://localhost:8088/ICommService/BasicHttp", "Upload"); msgSenderwithRepo.channel.PostMessage(msgToRepoQuery); Console.WriteLine("\nWaiting for message from repository..."); hrt.Start(); Message repoReply = msgReciever.TryGetRepoMessage("Query"); hrt.Stop(); Console.WriteLine(""); Console.WriteLine("\nRecieved message in {0} microsec.", hrt.ElapsedMicroseconds); Console.WriteLine(""); TestLoadStatus loadStatus = msgReciever.ParseLoadMsg(repoReply); Console.WriteLine(loadStatus.loadMessage); if (loadStatus.status) { using (FileStream fs = new FileStream(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "..\\..\\..\\TestResults", tr.LogName + "Summary.txt"), FileMode.Open)) using (StreamReader sr = new StreamReader(fs)) { Console.WriteLine(sr.ReadToEnd()); } } } else { Console.WriteLine("\nDemonstrating dll load status in test harness:"); Console.WriteLine(msgReciever.ParseLoadMsg(msg).loadMessage); } } }
static void Main(string[] args) { object locker = new object(); lock (locker) { Client client = new Client(); client.ClientSetup(client); Thread childTH = new Thread(new ThreadStart(client.THMsgProc)); childTH.Start(); try { client.GetRequestFiles(); foreach (info_In_One_Request_Folder info in client.folderInfoList) { HiResTimer hrt = new HiResTimer(); client.SetupLoadMessageToRepo(info, "http://localhost:4048/ICommService/BasicHttp", "http://localhost:8088/ICommService/BasicHttp", "Download"); client.msgSenderwithRepo.channel.PostMessage(client.msgToRepoLoad); Console.WriteLine("\nWaiting for message from repository"); hrt.Start(); Message msgFromRepo = client.msgReciever.TryGetRepoMessage("Load"); hrt.Stop(); TestLoadStatus loadStatus = client.msgReciever.ParseLoadMsg(msgFromRepo); Console.WriteLine(""); Console.WriteLine("\nRecieved message from repository in {0} microsec", hrt.ElapsedMicroseconds); Console.WriteLine(""); Console.WriteLine(loadStatus.loadMessage); if (loadStatus.status) { Console.WriteLine("\nSending message to TH"); client.SetupMessageToTH(info, "http://localhost:4048/ICommService/BasicHttp", "http://localhost:8088/ICommService/BasicHttp"); client.msgSenderwithTH.channel.PostMessage(client.msgToTH); } } childTH.Join(); Console.ReadKey(); } catch (Exception ex) { Console.Write("\n\n {0}", ex.Message); } Console.Write("\n\n"); } }
public List <TestInfo> Phase1(string threadName, ref string tempPath, Message msg, MessageClient msgSenderRepo, MessageClient msgSenderCL, MessageServer msgReciever) { HiResTimer hrt = new HiResTimer(); Console.WriteLine("\n({0})Parsing test request...", threadName); Parser parser = new Parser(); List <TestInfo> requestInfo = parser.doParse(msg); Console.WriteLine("\n({0})The result of parsing:", threadName); parser.showParsed(); Console.WriteLine("\n({0})Creating Temporary directory...", threadName); tempPath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "..\\..\\..\\temp" + requestInfo[0].requestName); Directory.CreateDirectory(tempPath); Console.WriteLine("\n({0})Creating channel to send message to repository...", threadName); msgSenderRepo.CreateMessageChannel("http://localhost:8085/ICommService"); Message msgToRepo = msgSenderRepo.SetupDownLoadMessageToRepo(threadName, requestInfo, tempPath, "http://localhost:4140/ICommService/BasicHttp", "http://localhost:8180/ICommService/BasicHttp"); Console.WriteLine("\n({0})Sending message to repository...", threadName); msgSenderRepo.channel.PostMessage(msgToRepo); Console.WriteLine("\n({0})Waiting for message from repository...", threadName); hrt.Start(); Message reply = msgReciever.TryGetMessage("Repository", threadName); hrt.Stop(); TestLoadStatus stat = msgReciever.Parse(reply); Console.WriteLine(""); Console.WriteLine("\n({0})Recieved message from repository in {2} microsec:\n{1}", threadName, stat.loadMessage, hrt.ElapsedMicroseconds); Console.WriteLine(""); Console.WriteLine("\n({0})Creating channel to send message to client...", threadName); msgSenderCL.CreateMessageChannel(parser.ParseConnect(msg)); Message loadMsgToCL = msgSenderCL.SetupLoadMessageToClient(stat); Console.WriteLine("\n({0})Sending load message to client...", threadName); msgSenderCL.channel.PostMessage(loadMsgToCL); Console.WriteLine("\n<---------------------------------------------------------------------->"); return(requestInfo); }
private void RepoMsgProc() { Console.WriteLine("\nWaiting for message from repository"); Message msgFromRepo = msgReciever.TryGetRepoMessage("Load"); TestLoadStatus loadStatus = msgReciever.ParseLoadMsg(msgFromRepo); Console.WriteLine(""); Console.WriteLine("\nRecieved message from repository."); Console.WriteLine(""); Console.WriteLine(loadStatus.loadMessage); if (loadStatus.status) { Console.WriteLine("\nSending message to TH"); clientUtil.SetupMessageToTH(msgToTH, "http://localhost:4244/ICommService/BasicHttp", "http://localhost:8284/ICommService/BasicHttp"); msgSenderwithTH.channel.PostMessage(msgToTH); } }