Example #1
0
        static void Main(string[] args)
        {
            IFileReaderServiceCallback callback = new FileReaderServiceCallback();
            InstanceContext            context  = new InstanceContext(callback);

            string request  = string.Empty;
            string response = string.Empty;

            FileReaderService.FileReaderService sc = new FileReaderService.FileReaderService();


            #region ParallelTasks
            Parallel.Invoke(
                () =>
            {
                using (FileReaderServiceProxy.FileReaderServiceProxy proxy = new FileReaderServiceProxy.FileReaderServiceProxy(context))
                {
                    ConsoleLogger logger = new ConsoleLogger();

                    try
                    {
                        logger.print_To_Client_FileReaderService();

                        logger.print_File_Info();

                        logger.print_Session_Info();
                    }

                    catch (FaultException <ApplicationException> e)
                    {
                        Console.WriteLine("FaultException<>: " + e.Detail.GetType().Name + " - " + e.Detail.Message);
                    }
                    catch (FaultException e)
                    {
                        Console.WriteLine("FaultException: " + e.GetType().Name + " - " + e.Message);
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine("EXCEPTION: " + e.GetType().Name + " - " + e.Message);
                    }
                }
            }

                );
            #endregion

            Console.WriteLine("Press any key to exit");
            Console.ReadKey();
        }
Example #2
0
        private void OnGetContentsClick(object sender, EventArgs e)
        {
            IFileReaderServiceCallback callback = new FileReaderServiceCallback();
            InstanceContext            context  = new InstanceContext(callback);

            FileReaderServiceProxy.FileReaderServiceProxy proxy = new FileReaderServiceProxy.FileReaderServiceProxy(context);
            string filePath = FilePath.Text;

            string message = proxy.Echo(filePath);

            FileAttributes.Text = proxy.GetFileAttributes(filePath);


            MessageBoxResult result = MessageBox.Show(proxy.PerCall_FileReader() + "\nSession ID :" + proxy.InnerChannel.SessionId);
        }
Example #3
0
        public void Run()
        {
            // Picks up configuration from the configuration file.
            //  FileReaderServiceClient wcfClient
            //    = new FileReaderServiceClient(new InstanceContext(this), "FileReaderService.FileReaderService");

            IFileReaderServiceCallback callback = new FileReaderServiceCallback();
            InstanceContext            context  = new InstanceContext(callback);

            FileReaderServiceProxy.FileReaderServiceProxy proxy = new FileReaderServiceProxy.FileReaderServiceProxy(context);

            try
            {
                Console.ForegroundColor = ConsoleColor.White;
                Console.WriteLine("Enter a filepath and press ENTER: ");
                Console.Write(">>> ");
                Console.ForegroundColor = ConsoleColor.Green;
                string filePath = Console.ReadLine();
                Console.ForegroundColor = ConsoleColor.White;
                Console.WriteLine("Called service with: \r\n\t" + filePath);

                proxy.Echo(filePath);

                //    wcfClient.Hello(greeting);
                Console.WriteLine("Execution passes service call and moves to the WaitHandle.");
                this.waitHandle.WaitOne();
                Console.ForegroundColor = ConsoleColor.Blue;
                Console.WriteLine("Set was called.");
                Console.Write("Press ");
                Console.ForegroundColor = ConsoleColor.Red;
                Console.Write("ENTER");
                Console.ForegroundColor = ConsoleColor.Blue;
                Console.Write(" to exit...");
                Console.ReadLine();
            }
            catch (TimeoutException timeProblem)
            {
                Console.WriteLine("The service operation timed out. " + timeProblem.Message);
                Console.ReadLine();
            }
            catch (CommunicationException commProblem)
            {
                Console.WriteLine("There was a communication problem. " + commProblem.Message);
                Console.ReadLine();
            }
        }