public void SendFiles()
 {
     try
     {
         fileChannelCreated = 1;
         //string destPath = "..\\..\\..\\Repository\\RepositoryStorage";
         //string srcPath1 = "..\\..\\..\\TestDriver\\TestDriver.dll";
         int        BlockSize = 1024;
         byte[]     block;
         HiResTimer hrt = new HiResTimer();
         block   = new byte[BlockSize];
         channel = CreateServiceChannel("http://localhost:8000/StreamService");
         hrt.Start();
         if (sel == 1)
         {
             UploadFile("TestDriver.dll");
             UploadFile("TestCode.dll");
         }
         else if (sel == 2)
         {
             UploadFile("TestDriver2.dll");
             UploadFile("TestCode2.dll");
         }
     }
     catch (Exception e)
     {
         Console.WriteLine("In Client 2" + e.Message);
     }
     //hrt = new HRTimer.HiResTimer();
 }
        void UploadFile(string filename)
        {
            //string srcPath = "..\\..\\..\\TestDriver2\\bin\\Debug\\";
            string     fqname = System.IO.Path.Combine(srcPath, filename);
            HiResTimer hrt    = new HiResTimer();

            try
            {
                hrt.Start();
                using (var inputStream = new FileStream(fqname, FileMode.Open))
                {
                    FileTransferMessage msg = new FileTransferMessage();
                    msg.filename       = filename;
                    msg.transferStream = inputStream;
                    channel.upLoadFile(msg);
                }
                hrt.Stop();
                Console.WriteLine("\n------------------------Requirement 2 and 6 -- Line 248 Client_1.xaml.cs---------------");
                Console.Write("\n  Uploaded file to Repository \"{0}\" in {1} microsec.", filename, hrt.ElapsedMicroseconds);
            }
            catch (Exception e)
            {
                Console.Write("\n  can't find \"{0}\"", fqname);
            }
        }
        public void SendMessage_Click(object sender, RoutedEventArgs e)
        {
            ListenButton.IsEnabled = false;
            //Send Files to Repository
            HiResTimer hrt = new HiResTimer();

            hrt.Start();
            SendFiles();
            hrt.Stop();
            Console.Write(
                "\n\n  Total elapsed time for uploading = {0} microsec.\n",
                hrt.ElapsedMicroseconds
                );
            Messages msg            = MakeMessage(endPoint, endPoint, requestFileName);
            string   remoteEndPoint = Comm <Client_1> .makeEndPoint("http://localhost", 8080);

            msg    = msg.copy();
            msg.to = remoteEndPoint;
            Console.WriteLine("\n------------------------Requirement 10 - Line 141 Client_1.xaml.cs---------------");
            Console.WriteLine("Sending message using WCF");
            comm.sndr.PostMessage(msg);
            displayMessage(msg);
            Thread.Sleep(2000);
            RequestMenu.IsEnabled = true;
        }
示例#4
0
        //Main activity of TestHarness

        public void processMessages()
        {
            AppDomain main = AppDomain.CurrentDomain;

            Console.Write("\n  Starting in AppDomain " + main.FriendlyName + "\n");
            HiResTimer  hrt1         = new HiResTimer();
            int         requestCount = 0;
            ThreadStart doTests      = () => {
                while (true)
                {
                    Messages testRequest = inQ_.deQ();
                    hrt1.Start();
                    if (++requestCount == 1)
                    {
                        Console.Write("\n\n  First Message body:{0}", testRequest.body);
                    }

                    if (testRequest.body == "quit")
                    {
                        inQ_.enQ(testRequest);
                        return;
                    }
                    ITestResults testResults = runTests(testRequest);
                    hrt1.Stop();
                    Console.WriteLine("\n------------------------Requirement 12 - Line 431 TestHarness.cs--------------------");
                    Console.WriteLine("Test Completed in " + hrt1.ElapsedMicroseconds);
                    Console.WriteLine("\n------------------------Requirement 6 and 10- Line 433 TestHarness.cs---------------");
                    Console.Write("\n  Sending Results to the client using WCF---  ");

                    lock (sync_)
                    {
                        comm.sndr.PostMessage(makeTestResultsMessage(testResults, testRequest));
                        //client_.sendResults(makeTestResultsMessage(testResults));
                    }
                }
            };

            Console.WriteLine("\n------------------------Requirement 4 - Line 401 TestHarness.cs---------------");
            Console.Write("\n  Creating AppDomain thread");
            Thread t = new Thread(doTests);

            threads_.Add(t);
            t.Start();
        }
        void download(string filename)
        {
            int BlockSize = 1024;

            byte[]     block      = new byte[BlockSize];
            string     SavePath   = "..\\..\\..\\Client_1\\Logs";
            int        totalBytes = 0;
            HiResTimer hrt        = new HiResTimer();

            try
            {
                hrt.Start();
                Stream strm      = channel.downLoadFile(filename);
                string rfilename = System.IO.Path.Combine(SavePath, filename);
                if (!Directory.Exists(SavePath))
                {
                    Directory.CreateDirectory(SavePath);
                }
                using (var outputStream = new FileStream(rfilename, FileMode.Create))
                {
                    while (true)
                    {
                        int bytesRead = strm.Read(block, 0, BlockSize);
                        totalBytes += bytesRead;
                        if (bytesRead > 0)
                        {
                            outputStream.Write(block, 0, bytesRead);
                        }
                        else
                        {
                            break;
                        }
                    }
                }
                hrt.Stop();
                ulong time = hrt.ElapsedMicroseconds;
                Console.Write("\n  Received file \"{0}\" of {1} bytes in {2} microsec.", filename, totalBytes, time);
            }
            catch (Exception ex)
            {
                Console.Write("\n  {0}", ex.Message);
            }
        }
示例#6
0
        public Stream downLoadFile(string filename)
        {
            HiResTimer hrt = new HiResTimer();

            hrt.Start();
            string     sfilename = Path.Combine(ToSendPath, filename);
            FileStream outStream = null;

            if (File.Exists(sfilename))
            {
                outStream = new FileStream(sfilename, FileMode.Open);
            }
            else
            {
                throw new Exception("open failed for \"" + filename + "\"");
            }
            hrt.Stop();
            Console.WriteLine("------------------------Requirement 6 -- Line 176 Repository.cs---------------");
            Console.Write("\n  Sent files \"{0}\" in {1} microsec.", filename, hrt.ElapsedMicroseconds);
            return(outStream);
        }
示例#7
0
        void download(string filename, string savePath)
        {
            //string savePath = "..\\..\\..\\Repository\\RepositoryStorage"
            int BlockSize = 1024;

            byte[]     block;
            HiResTimer hrt2 = new HiResTimer();

            block = new byte[BlockSize];
            int totalBytes = 0;

            hrt2.Start();
            Stream strm      = channel.downLoadFile(filename);
            string rfilename = Path.Combine(savePath, filename);

            if (!Directory.Exists(savePath))
            {
                Directory.CreateDirectory(savePath);
            }
            using (var outputStream = new FileStream(rfilename, FileMode.Create))
            {
                while (true)
                {
                    int bytesRead = strm.Read(block, 0, BlockSize);
                    totalBytes += bytesRead;
                    if (bytesRead > 0)
                    {
                        outputStream.Write(block, 0, bytesRead);
                    }
                    else
                    {
                        break;
                    }
                }
            }
            hrt2.Stop();
            ulong time = hrt2.ElapsedMicroseconds;

            Console.Write("\n  Received file \"{0}\" of {1} bytes in {2} microsec.", filename, totalBytes, time);
        }
示例#8
0
        public void upLoadFile(FileTransferMessage msg)
        {
            int totalBytes = 0;

            block = new byte[BlockSize];
            HiResTimer hrt1 = new HiResTimer();

            hrt1.Start();
            filename = msg.filename;
            string rfilename = Path.Combine(savePath, filename);

            if (!Directory.Exists(savePath))
            {
                Directory.CreateDirectory(savePath);
            }
            using (var outputStream = new FileStream(rfilename, FileMode.Create))
            {
                while (true)
                {
                    int bytesRead = msg.transferStream.Read(block, 0, BlockSize);
                    totalBytes += bytesRead;
                    if (bytesRead > 0)
                    {
                        outputStream.Write(block, 0, bytesRead);
                    }
                    else
                    {
                        break;
                    }
                }
            }
            hrt1.Stop();
            Console.Write(
                "\n  Received file \"{0}\" of {1} bytes in {2} microsec.",
                filename, totalBytes, hrt1.ElapsedMicroseconds
                );
        }