public bool Transfer(TransferResourceModel transferResource) { if (transferResource.Source == null) { TraceSource.TraceError("Source not valid for this? file"); return(false); } if (transferResource.Destination == null) { TraceSource.TraceError("Destination not valid for this? file"); return(false); } var source = TransferDownload(transferResource.Source); TraceSource.TraceInformation("Uploading file '{0}'", transferResource.Source.LocalPath); if (!TransferUpload(source, transferResource.Destination)) { TraceSource.TraceError("Error uploading file {0} to {1}", transferResource.Source.LocalPath, transferResource.Destination.LocalPath); return(false); } return(true); }
private Boolean GenerateTransferFileModel(ProductMediaModel productMediaModel, out TransferResourceModel transferResourceModel) { transferResourceModel = new TransferResourceModel(); if (productMediaModel == null) { TraceError("Unable to setup TranferResourceModel. ProductMediaModel is NUll or empty."); return(false); } var fileName = GenerateFileName(productMediaModel); if (fileName.IsNullOrWhiteSpace()) { TraceError("Unable to setup TranferResourceModel. Remote fileName cannot be setup."); return(false); } try { var source = new Uri( string.Format(@"file:///{0}?productId={1}&sequence={2}", Path.Combine(MediaLocationBasePath, productMediaModel.MediaPath), productMediaModel.ProductID, productMediaModel.Sequence), true); var destination = new Uri( string.Format(@"sftp://{0}@{1}/{2}?privateKeyFile={3}", ExportUser, ExportServer.Replace("sftp://", ""), fileName, ExportCertPath), true); transferResourceModel.Source = source; transferResourceModel.Destination = destination; } catch (Exception e) { TraceError("Error setting up TranferResourceModel for product # {1}. Error: {0}", e.Message, productMediaModel.ProductID); return(false); } return(true); }