Exemplo n.º 1
0
        private void UploadLatestPOFile(TransferServiceClient TransferServiceClient, string AuthToken, string Culture, ProjectImportExportInfo ProjectExportInfo)
        {
            var SourceDirectory  = new DirectoryInfo(CommandUtils.CombinePaths(RootWorkingDirectory, ProjectExportInfo.DestinationPath));
            var CultureDirectory = (ProjectExportInfo.bUseCultureDirectory) ? new DirectoryInfo(Path.Combine(SourceDirectory.FullName, Culture)) : SourceDirectory;

            var FileToUpload = new FileInfo(Path.Combine(CultureDirectory.FullName, ProjectExportInfo.PortableObjectName));
            var XLocFilename = GetXLocFilename(ProjectExportInfo.PortableObjectName);

            using (var FileStream = FileToUpload.OpenRead())
            {
                // We need to leave the language ID field blank for the native culture to avoid XLoc trying to process it as translated source, rather than raw source text
                var EpicCultureToXLocLanguageId = GetEpicCultureToXLocLanguageId();
                var LanguageId = (Culture == ProjectExportInfo.NativeCulture) ? "" : EpicCultureToXLocLanguageId[Culture];

                var FileUploadMetaData = new XLoc.Contracts.GameFileUploadInfo();
                FileUploadMetaData.CaseSensitive         = false;
                FileUploadMetaData.FileName              = XLocFilename;
                FileUploadMetaData.HistoricalTranslation = false;
                FileUploadMetaData.LanguageId            = LanguageId;
                FileUploadMetaData.LocalizationId        = Config.LocalizationId;
                FileUploadMetaData.PlatformId            = "!";

                Console.WriteLine("Uploading: '{0}' as '{1}' ({2})", FileToUpload.FullName, XLocFilename, Culture);

                try
                {
                    TransferServiceClient.UploadGameFile(Config.APIKey, AuthToken, FileUploadMetaData, FileToUpload.Length, FileStream);
                    Console.WriteLine("[SUCCESS] Uploading: '{0}' ({1})", FileToUpload.FullName, Culture);
                }
                catch (Exception Ex)
                {
                    Console.WriteLine("[FAILED] Uploading: '{0}' ({1}) - {2}", FileToUpload.FullName, Culture, Ex);
                }
            }
        }
Exemplo n.º 2
0
 private async Task <bool> SendMessageToServer(string[] message)
 {
     //отправляем сообщение на сервер
     return(await Task.Run(() =>
     {
         bool IsTransfer = false;
         //String host = System.Net.Dns.GetHostName();
         //System.Net.IPAddress ip = System.Net.Dns.GetHostByName(host).AddressList[0];
         List <TransferMessage> transferMessages = new List <TransferMessage>();
         foreach (var item in message)
         {
             transferMessages.Add(new TransferMessage()
             {
                 Message = item
                           //ip = ip.ToString()
             });
         }
         try
         {
             var client = new TransferServiceClient("NetTcpBinding_ITransferService");
             client.SaveData(transferMessages.ToArray());
             client.Close();
             IsTransfer = true;
         }
         catch
         { IsTransfer = false; }
         return IsTransfer;
     }));
 }
 public void AuthenticateTest()
 {
     using (TransferServiceClient objClientProxy = new TransferServiceClient(this.GetWcfTransferServiceBinding(), this.GetWcfTransferServiceEndpoint()))
     {
         bool bRet = objClientProxy.Authenticate(Constants.Sender, Constants.SecurityCode);
         Assert.IsTrue(bRet, "Wrong credentials to access wcf service.");
     }
 }
Exemplo n.º 4
0
 void SyncFunction(string pathClient, TransferServiceClient service, Client client)
 {
     while (true)
     {
         DirectoryInfo clientInfo = new DirectoryInfo(pathClient);
         Synchronizer.SyncFolders(clientInfo, service.GetRootRepository(client));
     }
 }
Exemplo n.º 5
0
 private void TransferFundsFromCustomer(Guid OrderNumber, int pCustomerAccountNumber, double pTotal)
 {
     using (TransferServiceClient lClient = new TransferServiceClient()){
         lClient.Transfer(OrderNumber, pTotal,
                          pCustomerAccountNumber, RetrieveVideoStoreAccountNumber(),
                          "net.msmq://localhost/private/BankNotificationService");
     }
 }
Exemplo n.º 6
0
 public AddDicomFileViewModel(LaboratoryDomainContext laboratoryDomainContext, IServiceLocator serviceLocator)
 {
     _laboratoryDomainContext = laboratoryDomainContext;
     _transferServiceClient = new TransferServiceClient();
     _serviceLocator = serviceLocator;
     Patients = new BindableCollection<IdentifikacneUdaje>();
     Studies = new BindableCollection<Vysetrenie>();
     Modalities = new BindableCollection<ModalityDto>();
 }
Exemplo n.º 7
0
 public void HandleMessage(Message pMsg)
 {
     if (pMsg.GetType() == typeof(SubmitOrderCommand))
     {
         SubmitOrderCommand lCmd = pMsg as SubmitOrderCommand;
         Order lOrder = lCmd.Order;
         TransferServiceClient lClient = new TransferServiceClient();
         lClient.Transfer(lOrder.Total, lOrder.Customer.BankAccountNumber, GetStoreAcctNumber(), "orderPurchase");
     }
 }
Exemplo n.º 8
0
    private void Download()
    {
        String fileName = TextBox_FileName.Text;

        if (String.IsNullOrWhiteSpace(fileName))
        {
            return;
        }

        // 如果文件在服务器上,可以直接使用下面的方法,进行文件下载
        // 直接向 HTTP 流输出响应,而不在内存中缓存它
        // Response.TransmitFile("file");
        try
        {
            TransferServiceClient proxy = new TransferServiceClient("basicHttpUpload");
            DownloadRequest requestInfo =
                new DownloadRequest
                {
                    FilePath = Path.Combine(Server.MapPath("~/TempFiles"), fileName)
                };

            Response.Clear();
            Response.ClearHeaders();
            Response.ContentType = "application/octet-stream";

            Response.AddHeader("Content-Disposition", "attachment; filename=" + FileNameHelper.GetDownloadFileName(fileName));

            try
            {
                UploadAndDownloadFile fileInfo = proxy.DownloadFile(requestInfo);
                fileInfo.FileByteStream.CopyTo(Response.OutputStream, 1024 * 100);
                proxy.Close();
            }
            catch (TimeoutException)
            {
                proxy.Abort();
            }
            catch (CommunicationException)
            {
                proxy.Abort();
            }

            Response.End();
        }
        catch (Exception ex)
        {
            Response.Write("Error : " + ex.Message);
        }
        finally
        {
            Response.End();
            Response.Close();
        }
    }
Exemplo n.º 9
0
    protected void LinkButton1_Click(object sender, EventArgs e)
    {
        try
        {
            FileTransferServiceReference.ITransferService clientDownload = new TransferServiceClient();
            FileTransferServiceReference.DownloadRequest  requestData    = new DownloadRequest();

            FileTransferServiceReference.RemoteFileInfo fileInfo = new RemoteFileInfo();
            requestData.FileName = "codebase.zip";

            fileInfo = clientDownload.DownloadFile(requestData);

            Response.BufferOutput = false;   // to prevent buffering
            byte[] buffer    = new byte[6500];
            int    bytesRead = 0;

            HttpContext.Current.Response.Clear();
            HttpContext.Current.Response.ClearHeaders();
            HttpContext.Current.Response.ContentType = "application/octet-stream";
            HttpContext.Current.Response.AddHeader("Content-Disposition", "attachment; filename=" + requestData.FileName);

            bytesRead = fileInfo.FileByteStream.Read(buffer, 0, buffer.Length);

            while (bytesRead > 0)
            {
                // Verify that the client is connected.
                if (Response.IsClientConnected)
                {
                    Response.OutputStream.Write(buffer, 0, bytesRead);
                    // Flush the data to the HTML output.
                    Response.Flush();

                    buffer    = new byte[6500];
                    bytesRead = fileInfo.FileByteStream.Read(buffer, 0, buffer.Length);
                }
                else
                {
                    bytesRead = -1;
                }
            }
        }
        catch (Exception ex)
        {
            // Trap the error, if any.
            System.Web.HttpContext.Current.Response.Write("Error : " + ex.Message);
        }
        finally
        {
            Response.Flush();
            Response.Close();
            Response.End();
            System.Web.HttpContext.Current.Response.Close();
        }
    }
Exemplo n.º 10
0
        public void HandleMessage(Message pMsg)
        {
            if (pMsg.GetType() == typeof(SubmitOrderCommand))
            {
                SubmitOrderCommand lCmd = pMsg as SubmitOrderCommand;
                Order lOrder = lCmd.Order;

                // how transfer is invoked, service reference
                TransferServiceClient lClient = new TransferServiceClient();
                lClient.Transfer((decimal)lOrder.Total, lOrder.Customer.BankAccountNumber, GetStoreAcctNumber(), lOrder.ExternalOrderId, getWCFQueueName());
            }
        }
Exemplo n.º 11
0
        private void Login()
        {
            try
            {
                service = new TransferServiceClient();
                service.ClientCredentials.ServiceCertificate.Authentication.CertificateValidationMode = X509CertificateValidationMode.None;
                service.ClientCredentials.UserName.UserName = login;
                service.ClientCredentials.UserName.Password = password;

                client = service.GetClient(login);

                DirectoryInfo rootDir = service.GetRootRepository(client);


                clientRoot = CheckForFirsSing(rootDir);

                _controller.CurrentDirectory = clientRoot;

                OpenDirectory("");


                if (sync != null)
                {
                    try
                    {
                        sync.Abort();
                    }
                    catch { }
                }

                string path = @"D:\Cursova\DropBox\" + client.login;

                sync = new Thread(() => SyncFunction(path, service, client));
                sync.IsBackground = true;
                sync.Start();
            }
            catch
            {
                MessageBox.Show("uncorrect data please try again");
                if (!isExit)
                {
                    AuthenticationApplication app = new AuthenticationApplication(this);
                    app.ShowDialog();
                    Login();
                }
                else
                {
                    Application.Exit();
                }
            }
        }
        public void GetFileSizeTest()
        {
            int iTimeout = 0;

            while (!_IsUploadComplete && iTimeout < 10000)
            {
                System.Threading.Thread.Sleep(500);
                iTimeout += 500;
            }

            Assert.IsNotNull(_RemoteUri, "You need to run this test in sequence with upload test.");

            using (TransferServiceClient objClientProxy = new TransferServiceClient(this.GetWcfTransferServiceBinding(), this.GetWcfTransferServiceEndpoint()))
            {
                long lSize = objClientProxy.GetFileSize(_RemoteUri);
                Assert.AreEqual <long>(_FileInfo.Length, lSize);
            }
        }
Exemplo n.º 13
0
        static void Main(string[] args)
        {
            TransferServiceClient proxy = new TransferServiceClient();

            Stream stream   = new MemoryStream();
            string filename = string.Empty;

            var result = proxy.DownloadFile(ref filename, out stream);

            using (Stream file = File.Create(filename))
            {
                stream.CopyTo(file);
            }

            stream.Dispose();

            Console.ReadLine();
        }
 public void UploadTest()
 {
     Assert.IsTrue(_FileInfo.Exists, String.Format("Test file \"{0}\" does not exist.", _FileInfo.FullName));
     //Open local input stream (We can call dispose/using because of WCFTransferServiceFix)
     using (FileStream objFileStream = _FileInfo.OpenRead())
         //Start service client
         using (TransferServiceClient objClientProxy = new TransferServiceClient(this.GetWcfTransferServiceBinding(), this.GetWcfTransferServiceEndpoint()))
         {
             Guid gFileGuid = Guid.NewGuid();
             _RemoteUri = new Uri(Constants.DevWebSite + gFileGuid.ToString("N") + ".dat");
             objClientProxy.Upload(
                 this.GetMimeType(_FileInfo.Name),
                 Constants.Sender,
                 gFileGuid,
                 _FileInfo.Name,
                 String.Empty,
                 _FileInfo.Length,
                 Constants.SecurityCode,
                 objFileStream);
         }
     Assert.IsTrue(true); //If we have reached here, we should be OK. We could consider tracking the uploaded file in the storage directory
     _IsUploadComplete = true;
 }
Exemplo n.º 15
0
 private void TransferFundsFromCustomer(int pCustomerAccountNumber, double pTotal, Guid pOrderNumber)
 {
     TransferServiceClient lClient = new TransferServiceClient();
     lClient.Transfer(pTotal, pCustomerAccountNumber, RetrieveVideoStoreAccountNumber(), pOrderNumber, "net.msmq://localhost/private/NotificationMessageQueueTransacted");
 }
Exemplo n.º 16
0
 private void Upload()
 {
     if (FileUpload_Main.HasFile)
     {
         TransferServiceClient clientUpload = new TransferServiceClient("basicHttpUpload");
         UploadAndDownloadFile uploadRequestInfo = new UploadAndDownloadFile
         {
             FilePath = Path.Combine(Server.MapPath("~/TempFiles"), FileUpload_Main.FileName),
             Length = FileUpload_Main.PostedFile.InputStream.Length,
             FileByteStream = FileUpload_Main.PostedFile.InputStream
         };
         clientUpload.UploadFile(uploadRequestInfo);
     }
 }
Exemplo n.º 17
0
        static void Main()
        {
            // Create a new TransferGuard Service Client.
            var client = new TransferServiceClient();

            // Add the client certificate (where the subject is equal to SiteId) from the current user's personal certificate store.  The client certificate must be manually imported into the certificate store.
            if (client.ClientCredentials != null)
                client.ClientCredentials.ClientCertificate.SetCertificate(StoreLocation.CurrentUser, StoreName.My, X509FindType.FindBySubjectName, SiteId);

            // Get the current version of the TransferGuard Service
            var version = client.GetVersion();
            Console.WriteLine("Using TransferGuard Service Version: {0}\n", version);

            // Create an order.
            Console.WriteLine("Preparing to place order...\n");
            var orderRequest = new OrderRequest
                                   {
                                       HL7Message = @"<ORM_O01><MSH><MSH.1>|</MSH.1><MSH.2>^~\&amp;</MSH.2><MSH.3><HD.1>SENDING_APPLICATION</HD.1></MSH.3><MSH.4><HD.1>SENDING_FACILITY</HD.1></MSH.4><MSH.5><HD.1>PAML</HD.1></MSH.5><MSH.6><HD.1>PAML</HD.1></MSH.6><MSH.7><TS.1>20121204105753.865-0800</TS.1></MSH.7><MSH.9><MSG.1>ORM</MSG.1><MSG.2>O01</MSG.2><MSG.3>ORM_O01</MSG.3></MSH.9><MSH.10>1</MSH.10><MSH.11><PT.1>T</PT.1></MSH.11><MSH.12><VID.1>2.5.1</VID.1></MSH.12></MSH></ORM_O01>",
                                       SiteID = SiteId
                                   };

            // Place an order.
            var orderResponse = client.PlaceOrder(orderRequest);

            // Get the order message ID for tracking purposes.
            Console.WriteLine("Order successfully placed. You can use Message ID {0} to track the message.\n", orderResponse.MessageID);

            // Check if there are any results waiting.
            Console.WriteLine("Checking for pending results...\n");
            var resultRequest = new ResultRequest
                                    {
                                        SiteID = SiteId
                                    };

            var resultCount = client.GetPendingResultCount(resultRequest);
            Console.WriteLine("There are {0} result(s) waiting to be retieved.\n", resultCount);

            // If there are pending results, retrieve them
            if (resultCount > 0)
            {
                // Retrieve results.
                Console.WriteLine("Retrieving results...\n");
                var results = client.GetResults(resultRequest);

                var xmlResults = new XmlDocument();
                var ns = new XmlNamespaceManager(xmlResults.NameTable);
                ns.AddNamespace("v2xml", "urn:hl7-org:v2xml");

                int index = 0;
                foreach (Result result in results.Results)
                {
                    xmlResults.LoadXml(result.HL7Message);
                    XmlNode node = xmlResults.SelectSingleNode("//v2xml:ORU_R01/v2xml:MSH/v2xml:MSH.8", ns);
                    Console.WriteLine("Result Message {0}   ID: {1}", index, node.InnerXml);
                    index++;
                }
            }

            Console.WriteLine("\nPress enter to continue...");
            Console.ReadLine();
        }
        public void DownloadTest()
        {
            int iTimeout = 0;

            while (!_IsUploadComplete && iTimeout < 10000)
            {
                System.Threading.Thread.Sleep(500);
                iTimeout += 500;
            }

            Assert.IsNotNull(_RemoteUri, "You need to run this test in sequence with upload test.");

            string   sLocalFile       = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), _FileInfo.Name);
            FileInfo objLocalFileInfo = new FileInfo(sLocalFile);

            if (objLocalFileInfo.Exists)
            {
                objLocalFileInfo.Attributes &= ~FileAttributes.ReadOnly;
                objLocalFileInfo.Delete();
            }

            TransferServiceClient objClientProxy = null;
            Stream objRemoteStream = null;
            Stream objLocalStream  = null;

            try
            {
                //We cannot use the using pattern here because it is incompatible with out ref parameters
                objClientProxy = new TransferServiceClient(this.GetWcfTransferServiceBinding(), this.GetWcfTransferServiceEndpoint());
                string sEmail;
                Guid   gFileGuid;
                string sFileName;
                string sHashCode;
                long   lLength;
                string sSecurityCode;

                objClientProxy.Download(
                    _RemoteUri,
                    out sEmail, //returns null
                    out gFileGuid,
                    out sFileName,
                    out sHashCode,
                    out lLength,
                    out sSecurityCode, //returns null
                    out objRemoteStream);

                Assert.IsNull(sEmail);
                Assert.IsNull(sSecurityCode);

                objLocalStream = objLocalFileInfo.Create();
                byte[] arrBuffer = new byte[4096];
                int    iBytesRead;
                do
                {
                    iBytesRead = objRemoteStream.Read(arrBuffer, 0, arrBuffer.Length);
                    objLocalStream.Write(arrBuffer, 0, iBytesRead);
                } while (iBytesRead > 0);

                Assert.IsTrue(objLocalFileInfo.Exists);
                Assert.AreEqual <long>(_FileInfo.Length, objLocalFileInfo.Length);
            }
            finally
            {
                if (objClientProxy != null)
                {
                    objClientProxy.Dispose(); //<-- We can call dispose because of WCFTransferServiceFix
                    objClientProxy = null;
                }
                if (objRemoteStream != null)
                {
                    objRemoteStream.Close();
                    objRemoteStream = null;
                }
                if (objLocalStream != null)
                {
                    objLocalStream.Close();
                    objLocalStream = null;
                }
            }
        }
Exemplo n.º 19
0
        private void TransferFundsFromCustomer(int pCustomerAccountNumber, double pTotal, Guid pOrderNumber)
        {
            TransferServiceClient lClient = new TransferServiceClient();

            lClient.Transfer(pTotal, pCustomerAccountNumber, RetrieveVideoStoreAccountNumber(), pOrderNumber, "net.msmq://localhost/private/NotificationMessageQueueTransacted");
        }
Exemplo n.º 20
0
 public ReciverClient()
 {
     inst = new InstanceContext(this);
     transferServiceClient = new TransferService.TransferServiceClient(inst);
 }
	private void UploadLatestPOFile(TransferServiceClient TransferServiceClient, string AuthToken, string Culture, ProjectImportExportInfo ProjectExportInfo)
	{
		var SourceDirectory = new DirectoryInfo(CommandUtils.CombinePaths(RootWorkingDirectory, ProjectExportInfo.DestinationPath));
		var CultureDirectory = (ProjectExportInfo.bUseCultureDirectory) ? new DirectoryInfo(Path.Combine(SourceDirectory.FullName, Culture)) : SourceDirectory;

		var FileToUpload = new FileInfo(Path.Combine(CultureDirectory.FullName, ProjectExportInfo.PortableObjectName));
		var XLocFilename = GetXLocFilename(ProjectExportInfo.PortableObjectName);

		using (var FileStream = FileToUpload.OpenRead())
		{
			// We need to leave the language ID field blank for the native culture to avoid XLoc trying to process it as translated source, rather than raw source text
			var EpicCultureToXLocLanguageId = GetEpicCultureToXLocLanguageId();
			var LanguageId = (Culture == ProjectExportInfo.NativeCulture) ? "" : EpicCultureToXLocLanguageId[Culture];

			var FileUploadMetaData = new XLoc.Contracts.GameFileUploadInfo();
			FileUploadMetaData.CaseSensitive = false;
			FileUploadMetaData.FileName = XLocFilename;
			FileUploadMetaData.HistoricalTranslation = false;
			FileUploadMetaData.LanguageId = LanguageId;
			FileUploadMetaData.LocalizationId = Config.LocalizationId;
			FileUploadMetaData.PlatformId = "!";

			Console.WriteLine("Uploading: '{0}' as '{1}' ({2})", FileToUpload.FullName, XLocFilename, Culture);

			try
			{
				TransferServiceClient.UploadGameFile(Config.APIKey, AuthToken, FileUploadMetaData, FileToUpload.Length, FileStream);
				Console.WriteLine("[SUCCESS] Uploading: '{0}' ({1})", FileToUpload.FullName, Culture);
			}
			catch (Exception Ex)
			{
				Console.WriteLine("[FAILED] Uploading: '{0}' ({1}) - {2}", FileToUpload.FullName, Culture, Ex);
			}
		}
	}