From 22cf9c9b7aa1f6b486e7bbe00f04445f7d5cbbcc Mon Sep 17 00:00:00 2001 From: =?utf8?q?V=C3=A1s=C3=A1ry=20D=C3=A1niel?= Date: Tue, 7 Aug 2018 22:51:50 +0000 Subject: [PATCH] git-tfs-id: [http://tfs.userrendszerhaz.hu:8080/tfs/DefaultCollection]$/MediaCube;C31231 --- ....json => -configuration-nexio-ingest.json} | 0 ...-studio.json => configuration-studio.json} | 2 +- client/Maestro/Maestro.csproj | 8 +-- .../Targets/FTPTargetProcessor.cs | 2 +- .../Targets/FXPTargetProcessor.cs | 59 +++++++++++-------- 5 files changed, 40 insertions(+), 31 deletions(-) rename client/Maestro/Configuration/{configuration-nexio-ingest.json => -configuration-nexio-ingest.json} (100%) rename client/Maestro/Configuration/{-configuration-studio.json => configuration-studio.json} (94%) diff --git a/client/Maestro/Configuration/configuration-nexio-ingest.json b/client/Maestro/Configuration/-configuration-nexio-ingest.json similarity index 100% rename from client/Maestro/Configuration/configuration-nexio-ingest.json rename to client/Maestro/Configuration/-configuration-nexio-ingest.json diff --git a/client/Maestro/Configuration/-configuration-studio.json b/client/Maestro/Configuration/configuration-studio.json similarity index 94% rename from client/Maestro/Configuration/-configuration-studio.json rename to client/Maestro/Configuration/configuration-studio.json index 3c358144..74e6e227 100644 --- a/client/Maestro/Configuration/-configuration-studio.json +++ b/client/Maestro/Configuration/configuration-studio.json @@ -67,7 +67,7 @@ "tag": "Archiválás", "saveArchiveMetadata": true, "remote": { - "address": "ftp://10.10.1.100:21/ARCHIVE", + "address": "ftp://10.10.1.100:21/ARCHIVE/ONE", "userName": "mediacube", "password": "Dn8t4gfHcK98o8hyPgLDhr5SgSji4JCxsfpMJsODikUp3nXgrM0UNCi45lLAK8ZOnmEneO44P9qpJ4QDqhctN6MxZodjJgdZTyoZKmSa+ECzEzLr/wPYNgxVaXrVotEy", "timeout": 1000 diff --git a/client/Maestro/Maestro.csproj b/client/Maestro/Maestro.csproj index 8a3fe707..67b86884 100644 --- a/client/Maestro/Maestro.csproj +++ b/client/Maestro/Maestro.csproj @@ -281,13 +281,13 @@ Always - + Always Always - + Always @@ -296,7 +296,7 @@ Always - + Always @@ -335,7 +335,7 @@ Always - + Always diff --git a/client/MaestroShared/Targets/FTPTargetProcessor.cs b/client/MaestroShared/Targets/FTPTargetProcessor.cs index 4cf88f19..c0d6b3e6 100644 --- a/client/MaestroShared/Targets/FTPTargetProcessor.cs +++ b/client/MaestroShared/Targets/FTPTargetProcessor.cs @@ -69,7 +69,7 @@ namespace MaestroShared.Targets { long sourceSize = inputFile.Length; long uploadedSize = targetFTP.GetFileSize(OutputName); if (sourceSize != uploadedSize) - throw new Exception(UPLOAD_ERROR); + throw new Exception(COPY_SIZE_ERROR); } } diff --git a/client/MaestroShared/Targets/FXPTargetProcessor.cs b/client/MaestroShared/Targets/FXPTargetProcessor.cs index 6e235a0e..2514ab07 100644 --- a/client/MaestroShared/Targets/FXPTargetProcessor.cs +++ b/client/MaestroShared/Targets/FXPTargetProcessor.cs @@ -3,7 +3,6 @@ using MaestroShared.Configuration; using MaestroShared.Target; using NLog; using System; -using System.Diagnostics; using System.IO; using System.Text.RegularExpressions; using System.Threading; @@ -16,6 +15,10 @@ namespace MaestroShared.Targets { private const string SPACE = " "; private Logger logger = LogManager.GetCurrentClassLogger(); private Source sourceConfig; + private FtpClient sourceFTP = null; + private FtpClient monitorFTP = null; + private long sourceFileLength = 0; + private long uploadedFileLength = 0; Uri inputUri; public override void Initialize(Control parent, TargetProcessorParameter parameters) { @@ -42,16 +45,17 @@ namespace MaestroShared.Targets { } protected override void UploadFile() { - FtpClient sourceFTP = null; - FtpClient monitorFTP = null; - try { sourceFTP = CreateClient(sourceConfig.Remote); + logger.Info("1 " + IsNexioServer(sourceFTP)); + string input = Uri.UnescapeDataString(inputUri.AbsolutePath); - long ilength = sourceFTP.GetFileSize(input); + sourceFileLength = sourceFTP.GetFileSize(input); if (Parameters.TargetConfig.NexioServer) - ilength = ilength / 2; + sourceFileLength = sourceFileLength / 2; + + logger.Info("2 " + IsNexioServer(sourceFTP)); FtpReply replyPASV = targetFTP.Execute("PASV"); if (!replyPASV.Success) @@ -65,11 +69,15 @@ namespace MaestroShared.Targets { if (!replyPORT.Success) throw new Exception(replyPORT.ErrorMessage); + logger.Info("3 " + IsNexioServer(sourceFTP)); + FtpReply sourceReplyTYPE = sourceFTP.Execute("TYPE I"); if (!sourceReplyTYPE.Success) throw new Exception(sourceReplyTYPE.ErrorMessage); + logger.Info("4 " + IsNexioServer(sourceFTP)); + if (input.LastIndexOf("/") == 0) input = input.Replace("/", ""); FtpReply replyRETR = sourceFTP.Execute("RETR " + input); @@ -83,6 +91,8 @@ namespace MaestroShared.Targets { throw new Exception(replyRETR.ErrorMessage); } + logger.Info("5 " + IsNexioServer(sourceFTP)); + FtpReply targetReplyTYPE = targetFTP.Execute("TYPE I"); if (!targetReplyTYPE.Success) throw new Exception(targetReplyTYPE.ErrorMessage); @@ -101,10 +111,9 @@ namespace MaestroShared.Targets { throw new Exception(targetReplyTYPE.ErrorMessage); //if (!FileExists(OutputName)) // throw new Exception("A cél állomány nem jött létre."); - long overall = 0; long lastSize = 0; - while (overall != ilength) { - overall = monitorFTP.GetFileSize(OutputName); + while (uploadedFileLength != sourceFileLength) { + uploadedFileLength = monitorFTP.GetFileSize(OutputName); /* FtpReply statRETR = sourceFTP.Execute("STAT"); if (!statRETR.Success) @@ -112,37 +121,37 @@ namespace MaestroShared.Targets { else Debug.WriteLine($"Overall {overall}, last {lastSize} site {statRETR.Message}"); */ - if (overall == lastSize && overall > 0) { + if (uploadedFileLength == lastSize && uploadedFileLength > 0) { Progress = 100; break; } else { - int currentProgress = (int)((double)overall / ilength * 100); + int currentProgress = (int)((double)uploadedFileLength / sourceFileLength * 100); Progress = currentProgress > 100 ? 100 : currentProgress; - lastSize = overall; + lastSize = uploadedFileLength; } Thread.Sleep(1000); } - - /* Ezen még agyalni kell - if (!Parameters.TargetConfig.NexioServer) { - //-1 -et ad??? - long uploadedSize = targetFTP.GetFileSize(OutputName); - if (ilength != uploadedSize) - throw new Exception(UPLOAD_SIZE_ERROR); - } - */ } catch (Exception e) { throw e; } - finally { - TerminateClient(monitorFTP); - TerminateClient(sourceFTP); - } //logger.Debug("Done"); } + protected override void ValidateTransfer() { + if (!IsNexioServer(sourceFTP) && !IsNexioServer(monitorFTP)) { + if (sourceFileLength != uploadedFileLength) + throw new Exception(COPY_SIZE_ERROR); + } + } + + protected override void AfterExecute() { + base.AfterExecute(); + TerminateClient(monitorFTP); + TerminateClient(sourceFTP); + } + } } -- 2.54.0