Ejemplo n.º 1
0
        public void ThreadProc(InternalMessage imsg) //all file loading exceptions are handled here
        {
            FileClient    clnt        = new FileClient();;
            HiResTimer    hrt         = new HiResTimer();
            MessageClient msgSender   = new MessageClient();
            Message       msgToClient = new Message();

            Console.WriteLine("");
            Console.WriteLine("===============================================================");
            try
            {
                clnt.CreateFileChannel(imsg.connectMessage.fileConnectAddress);
                Console.WriteLine("\n Identifying Load request message...");
                if (imsg.fileMessage.loadType == "Download")
                {
                    foreach (string file in imsg.fileMessage.fileNames)
                    {
                        clnt.download(file, imsg.fileMessage.loadPath);
                    }
                    msgToClient = msgSender.SetupMessages(true, "Files successfully downloaded by Repository.", imsg.recipient);
                }
                else
                {
                    foreach (string file in imsg.fileMessage.fileNames)
                    {
                        clnt.upload(file, imsg.fileMessage.loadPath);
                    }
                    msgToClient = msgSender.SetupMessages(true, "Files successfully uploaded from Repository.", imsg.recipient);
                }
            }
            catch (Exception ex)
            {
                msgToClient = msgSender.SetupMessages(false, "\n[Error message]:" + ex.Message, imsg.recipient);
            }
            finally
            {
                Console.WriteLine("\nConnecting to message channel...");
                msgSender.CreateMessageChannel(imsg.connectMessage.MessageConnectAddress);
                Console.WriteLine("\nSending message about loading status back...");
                hrt.Start();
                msgSender.channel.PostMessage(msgToClient);
                hrt.Stop();
                Console.WriteLine("");
                Console.WriteLine("\nMessage sent back in {0} microsec.", hrt.ElapsedMicroseconds);
                Console.WriteLine("");
            }
        }
        private void btnSetHost_Click(object sender, RoutedEventArgs e)
        {
            Console.WriteLine("Constructing host to communicate with TH and repository...");
            msgReciever.CreateMessageServiceHost("http://localhost:8284/ICommService/BasicHttp");
            msgReciever.open();

            Console.WriteLine("Constructing host to download/upload files...");
            fileServer.CreateFileServiceHost("http://localhost:4244/ICommService/BasicHttp");
            fileServer.open();

            Console.WriteLine("Creating channel to send message to repository...");
            msgSenderwithRepo.CreateMessageChannel("http://localhost:8085/ICommService");

            Console.WriteLine("Creating channel to send message to TH...");
            msgSenderwithTH.CreateMessageChannel("http://localhost:8180/ICommService/BasicHttp");
            ((Button)sender).IsEnabled = false;
        }
Ejemplo n.º 3
0
        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);
        }