Exemplo n.º 1
0
 public string TransferMessage(string msg)
 {
     Console.WriteLine("TransferService Host recived message: {0}.", msg);
     Console.WriteLine("Send message to DecrytService...");
     using (var client = new DecryptServiceClient())
     {
         var str = client.ManageMessage(string.Format("\"{0}\" modified by TransferService", msg));
         return(str);
     }
 }
Exemplo n.º 2
0
        public Stream UploadFile(Stream stream)
        {
            var fileName = Path.Combine(_tempDir, Guid.NewGuid().ToString("D"));

            //Console.WriteLine("New filename: {0}", fileName);

            using (var output = new FileStream(fileName, FileMode.Create))
            {
                stream.CopyTo(output);
                Console.WriteLine("TransferService saves the file to {0}", fileName);
            }
            Stream returnStream;


            var baseAddress = new Uri(ConfigurationManager.AppSettings["DecryptUri"]);

            var myNetTcpBinding = new NetTcpBinding()
            {
                TransferMode           = TransferMode.Streamed,
                MaxReceivedMessageSize = 2147483647,
                Security = new NetTcpSecurity()
                {
                    Mode = SecurityMode.None
                },
                ReaderQuotas = new XmlDictionaryReaderQuotas()
                {
                    MaxBytesPerRead        = 2147483647,
                    MaxArrayLength         = 2147483647,
                    MaxStringContentLength = 2147483647,
                }
            };

            using (var client = new DecryptServiceClient(myNetTcpBinding, new EndpointAddress(baseAddress)))
            {
                returnStream = client.GetFileStream(fileName);
            }
            return(returnStream);
        }