示例#1
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);
        }
示例#2
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();
            }
        }