Ejemplo n.º 1
0
        static void CallApm(object n)
        {
            Message msg = (Message)n;

            Console.Write("\nThreadname is:" + Thread.CurrentThread.ManagedThreadId + "-----Req 4\n");
            msg.showMsg();

            // stwr.WriteLine(msg.body);
            // stwr.Close();
            XmlCreator.TestRequest tr = msg.body.FromXml <XmlCreator.TestRequest>();

            if (tr != null)
            {
                foreach (XmlCreator.TestElement t in tr.tests)
                {
                    AppDomainManager1 apm             = new AppDomainManager1();
                    string            x               = apm.LoadTests(t, tr.author);
                    string            testreqfilename = msg.author + DateTime.Now.Month + DateTime.Now.Day + DateTime.Now.Year + ".log";
                    StreamWriter      stwr            = new StreamWriter("../../../ServerMemory/" + testreqfilename);
                    stwr.WriteLine(x);
                    msg.body = x;
                    stwr.Close();
                    string remoteEndPoint = null;
                    if (msg.author == "Client2")
                    {
                        remoteEndPoint = Comm <Server> .makeEndPoint("http://localhost", 8085);
                    }
                    else if (msg.author == "Client1")
                    {
                        remoteEndPoint = Comm <Server> .makeEndPoint("http://localhost", 8081);
                    }
                    Sender s = new Sender();
                    s.CreateSendChannel(msg.from);
                    msg.from = msg.to;
                    msg.to   = remoteEndPoint;
                    Console.Write("\n\nSending test results to Client ---req 8\n\n");
                    s.PostMessage(msg);
                    Console.Write("\n\nSending log file to repository----Req 8\n\n");
                    upload("../../../ServerMemory/" + testreqfilename);
                }
            }
        }
Ejemplo n.º 2
0
        public static string makeTestRequest(string DriverName, List <string> testcode, string author)
        {
            TestElement te1 = new TestElement("test1");

            te1.addDriver(DriverName);
            foreach (string x in testcode)
            {
                te1.addCode(x.ToString());
                Console.Write(x);
            }
            //te1.addCode("t1.dll");
            //te1.addCode("t2.dll");
            //TestElement te2 = new TestElement("test2");
            //te2.addDriver("td2.dll");
            //te2.addCode("tc3.dll");
            //te2.addCode("tc4.dll");
            TestRequest tr = new TestRequest();

            tr.author = author;
            tr.tests.Add(te1);
            // tr.tests.Add(te2);
            return(tr.ToXml());
        }
Ejemplo n.º 3
0
        void rcvThreadProc()
        {
            ThreadPool.SetMaxThreads(4, 4);
            int  x1 = 0, y1 = 0;
            int  num = 8;
            bool y   = true;

            while (y == true)
            {
                //ThreadPool.GetAvailableThreads(out x1, out y1);
                Console.Write(x1.ToString(), y1);
                Message msg = comm.rcvr.GetMessage();
                XmlCreator.TestRequest tr = msg.body.FromXml <XmlCreator.TestRequest>();

                {
                    foreach (XmlCreator.TestElement t in tr.tests)
                    {
                        if (t.testDriver != null)
                        {
                            this.download(t.testDriver.ToString());
                            foreach (string x in t.testCodes)
                            {
                                this.download(x);
                            }
                        }
                    }
                }
                if (msg == null)
                {
                    y = false;
                    break;
                }
                msg.time = DateTime.Now;
                // while (msg != null)
                // {
                Console.Write("\n  {0} received message:", comm.name);

                // msg.showMsg();

                if (msg.body == "quit")
                {
                    break;
                }
                else
                {
                    ThreadStart rts = () =>
                    {
                        CallApm(msg);
                    };
                    Thread th = new Thread(rts);
                    x1++;
                    th.Start();
                    if (x1 == num)
                    {
                        y = false;
                    }
                    t_.Add(th);
                }
                foreach (Thread t in t_)
                {
                    t.Join();
                }
            }
        }