From c3f3f0921f6893c7c24dea90e79b29498eb606a7 Mon Sep 17 00:00:00 2001 From: =?utf8?q?V=C3=A1s=C3=A1ry=20D=C3=A1niel?= Date: Thu, 23 Nov 2017 21:57:43 +0000 Subject: [PATCH] git-tfs-id: [http://tfs.userrendszerhaz.hu:8080/tfs/DefaultCollection]$/MediaCube;C30763 --- .../Configuration/configuration-nle.json | 8 +- .../Targets/FTPTargetProcessor.cs | 10 +-- .../Targets/UNCTargetProcessor.cs | 74 +++++++++---------- client/OctopusClient/OctopusIDSelector.cs | 19 +++-- 4 files changed, 49 insertions(+), 62 deletions(-) diff --git a/client/Maestro/Configuration/configuration-nle.json b/client/Maestro/Configuration/configuration-nle.json index c9fd6245..96cda96c 100644 --- a/client/Maestro/Configuration/configuration-nle.json +++ b/client/Maestro/Configuration/configuration-nle.json @@ -26,20 +26,20 @@ }, "projectSettings": { "templateRoot": { - "address": "ftp://10.10.1.100/.MAESTRO", + "address": "file://10.10.1.100/BRAAVOS/.MAESTRO", "userName": "mediacube", "password": "Dn8t4gfHcK98o8hyPgLDhr5SgSji4JCxsfpMJsODikUp3nXgrM0UNCi45lLAK8ZOnmEneO44P9qpJ4QDqhctN6MxZodjJgdZTyoZKmSa+ECzEzLr/wPYNgxVaXrVotEy", "timeout": 1000 }, "projectRoot": { - "address": "ftp://10.10.1.100/OCTOPUS", + "address": "file://10.10.1.100/BRAAVOS/OCTOPUS", "userName": "mediacube", "password": "Dn8t4gfHcK98o8hyPgLDhr5SgSji4JCxsfpMJsODikUp3nXgrM0UNCi45lLAK8ZOnmEneO44P9qpJ4QDqhctN6MxZodjJgdZTyoZKmSa+ECzEzLr/wPYNgxVaXrVotEy", "timeout": 1000 }, "templateName": "ALAPTIMELINE.ezp", - "projectName": "PROJECT/%ID%-%TEXT%.ezp", - "projectFormat": "%IDROOT%-%TEXT%", + "projectName": "%ID%-%TEXT%", + "projectFormat": "%IDROOT%-%TEXT%/PROJECT", "disableProject": false, "disableSourceOpen": false } diff --git a/client/MaestroShared/Targets/FTPTargetProcessor.cs b/client/MaestroShared/Targets/FTPTargetProcessor.cs index d0fc6eb0..ee19782a 100644 --- a/client/MaestroShared/Targets/FTPTargetProcessor.cs +++ b/client/MaestroShared/Targets/FTPTargetProcessor.cs @@ -25,9 +25,7 @@ namespace MaestroShared.Targets { string address = parameters?.SourceConfig?.Remote?.Address.ToString(); if (address == null) throw new Exception("Missing 'source.remote' parameter."); - if (!SLASH.Equals(address[address.Length - 1])) - address = address + SLASH; - Uri inputUri = new Uri(new Uri(address.ToString()), parameters.InputFileName); + Uri inputUri = new Uri(Path.Combine(address, parameters.InputFileName)); Input = inputUri.ToString(); } } @@ -67,12 +65,6 @@ namespace MaestroShared.Targets { } } - protected void reconnect() { - TerminateClient(targetFTP); - targetFTP = CreateClient(Parameters.TargetConfig.Remote); - EnsureDirectoryExistence(workingDir); - } - protected override void UploadContent(string outputPath, byte[] content) { using (Stream ostream = targetFTP.OpenWrite(outputPath, FtpDataType.Binary, false)) { try { diff --git a/client/MaestroShared/Targets/UNCTargetProcessor.cs b/client/MaestroShared/Targets/UNCTargetProcessor.cs index ad0af0e2..db0e27fc 100644 --- a/client/MaestroShared/Targets/UNCTargetProcessor.cs +++ b/client/MaestroShared/Targets/UNCTargetProcessor.cs @@ -33,17 +33,8 @@ namespace MaestroShared.Targets { private const string HYPHENSTAR = "-*"; private const string DATE_FORMAT_NODOTS = "yyyyMMdd"; private const string HYPHEN_SPACES = " - "; - private const string PATTERN_TARGETNAME = "%TARGETNAME%"; - private const string PATTERN_ID = "%ID%"; - private const string PATTERN_IDROOT = "%IDROOT%"; - private const string PATTERN_SOURCENAME = "%SOURCENAME%"; - private const string PATTERN_TIMESTAMP = "%TIMESTAMP%"; - private const string PATTERN_DATESTAMP = "%DATESTAMP%"; - private const string DATETIME_FORMAT = "yyyyMMddhhmmss"; - protected const string UNDERSCORE = "_"; protected const string HYPHEN = "-"; - protected const string PATTERN_TEXT = "%TEXT%"; protected const string SLASH = "/"; protected const string BACKSLASH = @"\"; private const string STAR = "*"; @@ -86,12 +77,13 @@ namespace MaestroShared.Targets { Status = INPROGRESS; //DateTime started = DateTime.Now; string currentFile = GetOutputFilePath(workingDir, OutputName); - HandleFileExists(currentFile); - if (!REVOKED.Equals(Status)) { + if (DeleteExisting(currentFile)) { UploadFile(); //logger.Info("Spend (s):" + (DateTime.Now - started).TotalSeconds); ExecuteCompleted(); } + Status = READY; + Message = SUCCESS; } catch (Exception e) { Status = ERROR; @@ -112,14 +104,21 @@ namespace MaestroShared.Targets { Output = SLASH.Equals(workingDir) ? OutputName : Path.Combine(workingDir, OutputName); } - private void HandleFileExists(string currentFile) { + private bool DeleteExisting(string currentFile) { + bool result = true; if (FileExists(currentFile) && (Parameters.TargetConfig.DisableFileVersioning || Parameters.TargetConfig.DisableOverride)) { if (Parameters.TargetConfig.NexioServer) { Status = REVOKED; ShowNexioFileExistsMessage(); - } else - DeleteFile(currentFile); + result = false; + } else { + if (Parameters.TargetConfig.DisableOverride) + result = false; + else + DeleteFile(currentFile); + } } + return result; } private void ShowNexioFileExistsMessage() { @@ -163,8 +162,6 @@ namespace MaestroShared.Targets { UpdateTrafficInformation(); if (Parameters.TargetConfig.SendEmailOnSuccess && !String.IsNullOrEmpty(Parameters.TargetConfig.SuccessEmailRecipient) && !String.IsNullOrEmpty(Parameters.TargetConfig.SuccessEmailPattern)) SendEmail(Parameters.TargetConfig.SuccessEmailRecipient, Parameters.TargetConfig.SuccessEmailPattern); - Status = READY; - Message = SUCCESS; } private void UpdateTrafficInformation() { @@ -215,7 +212,7 @@ namespace MaestroShared.Targets { private void SendEmail(string to, string messagePattern) { try { - string message = GetDynamicText(PATTERN_TARGETNAME); + string message = GetDynamicText(messagePattern); Parameters.MediaCubeApi.Notify(to, message); } catch (Exception e) { @@ -260,28 +257,27 @@ namespace MaestroShared.Targets { if (String.IsNullOrEmpty(Parameters.TargetConfig.SubFolderFormat)) return result; string subFolderName = Slash(GetDynamicText(Parameters.TargetConfig.SubFolderFormat)); - string pattern = subFolderName; - string searchPath = result; - if (pattern.Contains(SLASH)) { - string[] segments = pattern.Split(SLASH[0]); - pattern = segments[segments.Length - 1]; - searchPath = Slash(Path.Combine(result, subFolderName.Substring(0, subFolderName.Length - pattern.Length - 1))); + string[] segments = subFolderName.Split(SLASH[0]); + string[] formats = Parameters.TargetConfig.SubFolderFormat.Replace(BACKSLASH, SLASH).Split(SLASH[0]); + for (int i = 0; i < segments.Length; i++) { + string segment = segments[i]; + int p = segment.IndexOf(HYPHEN); + int o = segment.IndexOf(UNDERSCORE); + if (formats[i].Contains("%") && (p > -1 || o > -1)) { + string pattern = null; + if (p < o && p > -1) + pattern = segment.Substring(0, p); + else + pattern = segment.Substring(0, o); + pattern += STAR; + string searchResult = SearchDirectory(result, pattern); + if (searchResult == null) + result = Slash(Path.Combine(result, segment)); + else + result = Slash(Path.Combine(result, searchResult)); + } else + result = Slash(Path.Combine(result, segment)); } - int p = pattern.IndexOf(HYPHEN); - int o = pattern.IndexOf(UNDERSCORE); - if (p > -1 || o > -1) { - if (p < o && p > -1) - pattern = pattern.Substring(0, p); - else - pattern = pattern.Substring(0, o); - pattern += STAR; - string searchResult = SearchDirectory(searchPath, pattern); - if (searchResult == null) - result = Slash(Path.Combine(result, subFolderName)); - else - result = Slash(Path.Combine(result, searchResult)); - } else - result = Slash(Path.Combine(connection.Address.LocalPath, subFolderName)); return result; } @@ -387,7 +383,7 @@ namespace MaestroShared.Targets { version++; } } - return result.ToUpper().Replace(BACKSLASH, SLASH); + return result.ToUpper(); } protected virtual void EnsureDirectoryExistence(string path) { diff --git a/client/OctopusClient/OctopusIDSelector.cs b/client/OctopusClient/OctopusIDSelector.cs index ac785efe..a2371363 100644 --- a/client/OctopusClient/OctopusIDSelector.cs +++ b/client/OctopusClient/OctopusIDSelector.cs @@ -10,6 +10,7 @@ using MaestroShared.Configuration; using System.IO; using MaestroShared.Targets; using MaestroShared.Target; +using System.Diagnostics; namespace OctopusClient { public delegate void OnSelectedIDChanged(string id, string name, string text); @@ -410,13 +411,7 @@ namespace OctopusClient { MessageBox.Show("A 'projectSetings' beállítás hiányos a konfigurációs állományban.", null, MessageBoxButtons.OK, MessageBoxIcon.Error); return; } - //string source = Path.Combine(projectConfiguration.TemplateRoot.Address.LocalPath, projectConfiguration.TemplateName); - //if (!File.Exists(source)) { - // MessageBox.Show($"Az '{source}' állomány nem létezik.", null, MessageBoxButtons.OK, MessageBoxIcon.Error); - // return; - //} Story story = node.Tag as Story; - TargetProcessorParameter processorParameter = new TargetProcessorParameter() { SourceConfig = new Source() { Local = projectConfiguration.TemplateRoot, @@ -435,12 +430,16 @@ namespace OctopusClient { UserName = parameters.UserName, }; - ITargetProcessor result = new FXPTargetProcessor(); - result.Initialize(null, processorParameter); - result.Execute(); + ITargetProcessor processor = new UNCTargetProcessor(); + processor.Initialize(null, processorParameter); + processor.Execute(); - //Patter + if (!TargetProcessor.READY.Equals(processor.Status)) { + MessageBox.Show(processor.Message, null, MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + Process.Start(processor.Output); } -- 2.54.0