예제 #1
0
 private void button1_Click(object sender, RoutedEventArgs e)//send test request
 {
     button1.IsEnabled = false;
     cmd.command       = "Test";
     cmd.testAuthor    = author.Text.Replace(" ", "_");
     cmd.testName      = name.Text;
     cmd.dateTime      = DateTime.Now.ToString("MM_dd_yyyy_hh_mm_ss");
     //cmd.dateTime = "11_20_2016_09_00_00";
     cmd.xmlFile = System.IO.Path.GetFileName(xmlfile.Text);
     AddTestTime(xmlfile.Text, cmd);
     changeNameAndSendToRepo(xmlfile.Text, cmd);
     for (int i = 0; i < listBox.Items.Count; i++)
     {
         cmd.dllFiles.Add(System.IO.Path.GetFileName((string)listBox.Items.GetItemAt(i)));
         changeNameAndSendToRepo((string)listBox.Items.GetItemAt(i), cmd);
     }
     try
     {
         stringSender   sndr        = new stringSender("http://localhost:8080/THStrRcvr");
         CommandEncoder cmdEnocoder = new CommandEncoder(cmd);
         sndr.PostMessage(cmdEnocoder.encode());
         textBox7.Text += "\n the datetime for query is: " + cmd.dateTime;
         Thread th = new Thread(s => { IsFileExist((string)s); });
         th.Start("../../../log/" + cmd.testAuthor + "_" + cmd.dateTime + ".txt");
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.ToString());
     }
     button1.IsEnabled = true;
 }
예제 #2
0
        void caseRequestQuary(CommandData cmdData)//command from client to ask a query
        {
            IFileService fs     = null;
            string       CFRcvr = cmdData.url + "/CFRcvr";
            int          count  = 0;

            while (true)
            {
                try
                {
                    fs = TestHarness.fileSender.CreateChannel(CFRcvr);
                    break;
                }
                catch
                {
                    Console.Write("\n  connection to service failed {0} times - trying again", ++count);
                    Thread.Sleep(500);
                    continue;
                }
            }
            Console.Write("\n  Connected to {0}\n", CFRcvr);
            string relativeFilePath = "../../../repo/";
            string filepath         = Path.GetFullPath(relativeFilePath);
            string file             = filepath + cmdData.testAuthor + "_" + cmdData.dateTime + ".txt";

            try
            {
                Console.Write("\n  sending file {0}", file);
                timer.Start();
                if (!fileSender.SendFile(fs, file))
                {
                    timer.Stop();
                    Console.Write("\n  could not send file");
                    cmdData.command = "NoResult";
                    cmdData.from    = "Repository";
                    cmdData.to      = "Client";
                    string csl = cmdData.url + "/CStrRcvr";
                    try{
                        sndr = new stringSender(csl);
                        CommandEncoder cmdEnocoder = new CommandEncoder(cmdData);
                        sndr.PostMessage(cmdEnocoder.encode());
                    }
                    catch (Exception ex) {
                        Console.WriteLine(ex.ToString());
                    }
                }
                else
                {
                    timer.Stop();
                    Console.WriteLine("send file :{0} in {1} ", file, timer.ElapsedTimeSpan);
                }
            }
            catch {}
        }
예제 #3
0
 void sendRunTest(CommandData cmdData)//tell TH to run the test
 {
     cmdData.command = "RunTest";
     cmdData.from    = "Repo";
     cmdData.to      = "TH";
     try
     {
         stringSender   sndr        = new stringSender("http://localhost:8080/THStrRcvr");
         CommandEncoder cmdEnocoder = new CommandEncoder(cmdData);
         sndr.PostMessage(cmdEnocoder.encode());
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.ToString());
     }
 }
예제 #4
0
 void sendFileNotMatch(CommandData cmdData)//when we not find the match
 {
     cmdData.command = "FileNotMatch";
     cmdData.from    = "Repo";
     cmdData.to      = "TH";
     try
     {
         stringSender   sndr        = new stringSender("http://localhost:8080/THStrRcvr");
         CommandEncoder cmdEnocoder = new CommandEncoder(cmdData);
         sndr.PostMessage(cmdEnocoder.encode());
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.ToString());
     }
 }
예제 #5
0
        private void button5_Click(object sender, RoutedEventArgs e)//send the query request
        {
            cmd.command    = "Request Query";
            cmd.testAuthor = author.Text.Replace(" ", "_");
            cmd.dateTime   = datetime.Text;
            stringSender   sndr        = new stringSender("http://localhost:8081/RepoStrRcvr");
            CommandEncoder cmdEnocoder = new CommandEncoder(cmd);

            sndr.PostMessage(cmdEnocoder.encode());
            if (File.Exists("../../../log/" + cmd.testAuthor + "_" + cmd.dateTime + ".txt"))
            {
                try {
                    File.Delete("../../../log/" + cmd.testAuthor + "_" + cmd.dateTime + ".txt");
                }
                catch
                {
                }
            }
            Thread th = new Thread(s => { IsFileExist((string)s); });

            th.Start("../../../log/" + cmd.testAuthor + "_" + cmd.dateTime + ".txt");
            textBox7.Text += "----------------this is demo for requirement 9";
        }
예제 #6
0
        static void Main(string[] args)
        {
            Repository repo = new Repository();

            repo.startRepository();
            //------------------test sub------------------
#if (TEST_REPOSITORY)
            CommandData cmd = new CommandData();
            cmd.from       = "client";
            cmd.to         = "repo";
            cmd.testAuthor = "me";
            cmd.testName   = "test";
            cmd.command    = "Request Query";
            DateTime tm = new DateTime(2016, 11, 20, 09, 00, 00);
            cmd.dateTime = tm.ToString("MM_dd_yyyy_hh_mm_ss");
            cmd.url      = "http://localhost:8082/";
            cmd.dllFiles.Add("tc1.dll");
            cmd.dllFiles.Add("tc2.dll");
            cmd.dllFiles.Add("td1.dll");
            cmd.dllFiles.Add("td2.dll");
            cmd.xmlFile = "XMLFile1.xml";
            try
            {
                stringSender   sndr        = new stringSender("http://localhost:8081/RepoStrRcvr");
                CommandEncoder cmdEnocoder = new CommandEncoder(cmd);
                sndr.PostMessage(cmdEnocoder.encode());
                cmd.testAuthor = "me1";
                cmdEnocoder    = new CommandEncoder(cmd);
                sndr.PostMessage(cmdEnocoder.encode());
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
            }
#endif
        }