From: Vásáry Dániel Date: Sat, 18 Nov 2017 21:19:42 +0000 (+0000) Subject: git-tfs-id: [http://tfs.userrendszerhaz.hu:8080/tfs/DefaultCollection]$/MediaCube... X-Git-Url: http://git.useribm.hu/?a=commitdiff_plain;h=2305e7e4303807749fc6892d6a3a5887b96f8a74;p=mediacube.git git-tfs-id: [tfs.userrendszerhaz.hu:8080/tfs/DefaultCollection]$/MediaCube;C30746 --- diff --git a/client/IntegrationTests/lib/mysql.data.dll b/client/IntegrationTests/lib/mysql.data.dll new file mode 100644 index 00000000..216dbe38 Binary files /dev/null and b/client/IntegrationTests/lib/mysql.data.dll differ diff --git a/client/MXFFileParser/MXFFileParser.csproj.vspscc b/client/MXFFileParser/MXFFileParser.csproj.vspscc new file mode 100644 index 00000000..feffdeca --- /dev/null +++ b/client/MXFFileParser/MXFFileParser.csproj.vspscc @@ -0,0 +1,10 @@ +"" +{ +"FILE_VERSION" = "9237" +"ENLISTMENT_CHOICE" = "NEVER" +"PROJECT_FILE_RELATIVE_PATH" = "" +"NUMBER_OF_EXCLUDED_FILES" = "0" +"ORIGINAL_PROJECT_FILE_PATH" = "" +"NUMBER_OF_NESTED_PROJECTS" = "0" +"SOURCE_CONTROL_SETTINGS_PROVIDER" = "PROVIDER" +} diff --git a/client/Maestro/Configuration/configuration-editor.json b/client/Maestro/Configuration/configuration-editor.json index 5324669d..98f3a22b 100644 --- a/client/Maestro/Configuration/configuration-editor.json +++ b/client/Maestro/Configuration/configuration-editor.json @@ -1,6 +1,6 @@ { "title": "Szerkesztő", - "active": false, + "active": true, "startInTray": false, "enableCustomMetadataId": true, "player": { @@ -77,6 +77,7 @@ "outputFormat": "%ID%", "tag": "Betöltés", "nexioServer": true, + "nexioFileExistsMessage": "A feltöltéshez új 'placeholder' generálása szükséges az Octopus rendszerben, az anyagon belül az ALT+1 billenytűkombináció segítségével.", "killDateDays": 7, "disableFileVersioning": true, "agency": "MAESTRO-EDITOR", diff --git a/client/Maestro/Configuration/configuration-playout-ingest.json b/client/Maestro/Configuration/configuration-playout-ingest.json index aa818ef7..ddd13040 100644 --- a/client/Maestro/Configuration/configuration-playout-ingest.json +++ b/client/Maestro/Configuration/configuration-playout-ingest.json @@ -1,6 +1,6 @@ { "title": "Lebony betöltő", - "active": true, + "active": false, "startInTray": false, "enableCustomMetadataId": true, "player": { diff --git a/client/Maestro/MaestroForm.Designer.cs b/client/Maestro/MaestroForm.Designer.cs index 60924ec4..69730c92 100644 --- a/client/Maestro/MaestroForm.Designer.cs +++ b/client/Maestro/MaestroForm.Designer.cs @@ -194,7 +194,7 @@ namespace Maestro { this.dgSource.CellMouseDoubleClick += new System.Windows.Forms.DataGridViewCellMouseEventHandler(this.dataGridSource_CellMouseDoubleClick); this.dgSource.CellMouseEnter += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridSource_CellMouseEnter); this.dgSource.CellMouseLeave += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridSource_CellMouseLeave); - this.dgSource.CellPainting += new System.Windows.Forms.DataGridViewCellPaintingEventHandler(this.dataGridSource_CellPainting); + this.dgSource.CellPainting += new System.Windows.Forms.DataGridViewCellPaintingEventHandler(this.OnSourceCellPainting); this.dgSource.KeyDown += new System.Windows.Forms.KeyEventHandler(this.dataGridSource_KeyDown); // // treeFolders @@ -722,6 +722,7 @@ namespace Maestro { this.dgJobs.Size = new System.Drawing.Size(988, 90); this.dgJobs.TabIndex = 0; this.dgJobs.CellEnter += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridJobs_CellEnter); + this.dgJobs.CellPainting += new System.Windows.Forms.DataGridViewCellPaintingEventHandler(this.OnJobsCellPainting); this.dgJobs.MouseClick += new System.Windows.Forms.MouseEventHandler(this.dataGridJobs_MouseClick); // // columnLabel diff --git a/client/Maestro/MaestroForm.Source.cs b/client/Maestro/MaestroForm.Source.cs index 537b70b3..a13d6365 100644 --- a/client/Maestro/MaestroForm.Source.cs +++ b/client/Maestro/MaestroForm.Source.cs @@ -1,8 +1,10 @@ using DxPlay; using Maestro.Metadata; using Maestro.Sources; +using MaestroShared.Commons; using MaestroShared.Configuration; using MaestroShared.Metadata; +using MaestroShared.Resources; using System; using System.Collections.Generic; using System.Diagnostics; @@ -231,7 +233,7 @@ namespace Maestro { return new FileInfo(inputUri.LocalPath); } - private void dataGridSource_CellPainting(object sender, DataGridViewCellPaintingEventArgs e) { + private void OnSourceCellPainting(object sender, DataGridViewCellPaintingEventArgs e) { if (e.RowIndex < 0) return; ISourceItem item = dgSource.Rows[e.RowIndex].DataBoundItem as ISourceItem; @@ -239,7 +241,7 @@ namespace Maestro { return; DataGridViewRow row = dgSource.Rows[e.RowIndex]; if (item.IsHighlighted) { - row.DefaultCellStyle.BackColor = Color.DarkGreen; + row.DefaultCellStyle.BackColor = MaestroColors.Green200; row.DefaultCellStyle.ForeColor = Color.White; } else row.DefaultCellStyle = null; diff --git a/client/Maestro/MaestroForm.Target.cs b/client/Maestro/MaestroForm.Target.cs index 3765ab69..cad5a5e3 100644 --- a/client/Maestro/MaestroForm.Target.cs +++ b/client/Maestro/MaestroForm.Target.cs @@ -163,11 +163,9 @@ namespace Maestro { return; var controlls = panelActions.Controls; foreach (Control actual in controlls) { - CheckBox actualCheckbox = actual as CheckBox; - if (actualCheckbox != null && actualCheckbox.Text.Equals(reference)) { + if (actual is CheckBox actualCheckbox && actualCheckbox.Text.Equals(reference)) { if (check) actualCheckbox.Checked = check; - actualCheckbox.Enabled = !check; } } @@ -206,11 +204,12 @@ namespace Maestro { } private void OnExecuteClick(object sender, EventArgs e) { - foreach (var element in currentProcessors) - foreach (ITargetProcessor value in element.Value) { - jobs.Add(value); - jobsQueue.Add(value); + foreach (var element in currentProcessors) { + foreach (ITargetProcessor processor in element.Value) { + jobs.Add(processor); + jobsQueue.Enqueue(processor); } + } ClearSelectedProcessors(); if (processorWorker == null) diff --git a/client/Maestro/MaestroForm.cs b/client/Maestro/MaestroForm.cs index 3035bb2a..ff6c5b8b 100644 --- a/client/Maestro/MaestroForm.cs +++ b/client/Maestro/MaestroForm.cs @@ -15,6 +15,7 @@ using LinkDotNet.MessageHandling; using MaestroShared.Configuration; using MaestroShared.Targets; using MaestroShared.Commons; +using MaestroShared.Resources; namespace Maestro { @@ -25,7 +26,7 @@ namespace Maestro { private GroupBox[] groups; private Dictionary> currentProcessors = new Dictionary>(); private BindingList jobs = new BindingList(); - private BlockingCollection jobsQueue = new BlockingCollection(); + private ConcurrentQueue jobsQueue = new ConcurrentQueue(); private BackgroundWorker processorWorker; public IMessageBus MessageBus { get; set; } private IMessageBus errorMessageBus = new MessageBus(); @@ -105,9 +106,9 @@ namespace Maestro { private void InitializeJobs() { bindingSourceJobs.DataSource = jobs; - foreach (DataGridViewColumn column in dgJobs.Columns) { - column.HeaderCell.Style.Font = new Font(dgJobs.Font, FontStyle.Regular); - } + //foreach (DataGridViewColumn column in dgJobs.Columns) { + // column.HeaderCell.Style.Font = new Font(dgJobs.Font, FontStyle.Regular); + //} } private void MaestroForm_Resize(object sender, EventArgs e) { @@ -128,7 +129,9 @@ namespace Maestro { processorWorker.DoWork += (s, e) => { while (!e.Cancel) { ITargetProcessor job; - if (jobsQueue.TryTake(out job)) { + if (jobsQueue.TryDequeue(out job)) { + if (TargetProcessor.REVOKED.Equals(job.Status)) + continue; (this).SafeCall(() => { int position = jobs.IndexOf(job); if (position == -1) @@ -182,9 +185,8 @@ namespace Maestro { } private void MaestroForm_FormClosed(object sender, FormClosedEventArgs e) { - if (processorWorker != null) { + if (processorWorker != null) processorWorker.CancelAsync(); - } } private void dataGridJobs_CellEnter(object sender, DataGridViewCellEventArgs e) { @@ -200,74 +202,48 @@ namespace Maestro { InitializeComponents(); } - //private void textBox1_KeyUp(object sender, KeyEventArgs e) { - // if (e.KeyCode != Keys.Return) - // return; - // if (String.IsNullOrEmpty(txtSorceFilter.Text)) - // bindingSource.RemoveFilter(); - // else { - // bindingSource.Filter = txtSorceFilter.Text; - // } - //} - private void ActivateTab(int index) { tabSystem.SelectedIndex = index; } - //private void UpdateDataGridMessagesChanged() { - // dataGridMessages.DataSource = null; - // dataGridMessages.DataSource = systemMessageBindingSource; - //} - - //private void buttonDeleteFilter_Click(object sender, EventArgs e) { - // if (!String.IsNullOrEmpty(txtSorceFilter.Text)) { - // bindingSource.RemoveFilter(); - // txtSorceFilter.Text = string.Empty; - // } - //} - private void dataGridJobs_MouseClick(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Right && dgJobs.SelectedRows.Count == 1) { ContextMenu popupMenu = new ContextMenu(); MenuItem makeFileToProtected = new MenuItem(StringResources.ALLOMANY_VEDETTE_TETELE); makeFileToProtected.Click += MakeFileToProtected_click; - MenuItem deleteProcess = new MenuItem(StringResources.TORLES); - deleteProcess.Click += DeleteProcess_click; popupMenu.MenuItems.Add(makeFileToProtected); - popupMenu.MenuItems.Add(deleteProcess); popupMenu.Show(dgJobs, new Point(e.X, e.Y)); } } private void MakeFileToProtected_click(object sender, EventArgs e) { - ITargetProcessor current = bindingSourceJobs.Current as ITargetProcessor; - if (current == null) + ITargetProcessor processor = bindingSourceJobs.Current as ITargetProcessor; + if (processor == null) return; - if (File.Exists(current.KillDatePath)) { - File.Delete(current.KillDatePath); - current.KillDate = string.Empty; + if (File.Exists(processor.KillDatePath)) { + File.Delete(processor.KillDatePath); + processor.KillDate = string.Empty; } } - private void DeleteProcess_click(object sender, EventArgs e) { - ITargetProcessor current = bindingSourceJobs.Current as ITargetProcessor; - if (current == null) + private void OnJobsCellPainting(object sender, DataGridViewCellPaintingEventArgs e) { + if (e.RowIndex < 0) return; - //ha van státusza, már nem törölhető - if (current.Status != null) + ITargetProcessor item = dgJobs.Rows[e.RowIndex].DataBoundItem as ITargetProcessor; + if (item == null) return; - BackgroundWorker worker = new BackgroundWorker(); - worker.DoWork += (s, r) => { - ITargetProcessor outJob; - while (jobsQueue.TryTake(out outJob)) { - if (!outJob.Equals(current)) { - jobsQueue.TryAdd(outJob); - } - } - }; - var actualRow = dgJobs.SelectedRows[0]; - dgJobs.Rows.Remove(actualRow); + DataGridViewRow row = dgJobs.Rows[e.RowIndex]; + switch (item.Status) { + case TargetProcessor.ERROR: + row.DefaultCellStyle.BackColor = MaestroColors.Red200; + break; + case TargetProcessor.REVOKED: + row.DefaultCellStyle.BackColor = MaestroColors.Orange200; + break; + case TargetProcessor.READY: + row.DefaultCellStyle.BackColor = MaestroColors.BlueGray200; + break; + } } - } } diff --git a/client/Maestro/MaestroForm.resx b/client/Maestro/MaestroForm.resx index 71d12937..c8aa6e9d 100644 --- a/client/Maestro/MaestroForm.resx +++ b/client/Maestro/MaestroForm.resx @@ -128,7 +128,7 @@ AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj00LjAuMC4w LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAACZTeXN0 ZW0uV2luZG93cy5Gb3Jtcy5JbWFnZUxpc3RTdHJlYW1lcgEAAAAERGF0YQcCAgAAAAkDAAAADwMAAACc - BwAAAk1TRnQBSQFMAwEBAAEQAQABEAEAARABAAEQAQAE/wEJAQAI/wFCAU0BNgEEBgABNgEEAgABKAMA + BwAAAk1TRnQBSQFMAwEBAAEYAQABGAEAARABAAEQAQAE/wEJAQAI/wFCAU0BNgEEBgABNgEEAgABKAMA AUADAAEQAwABAQEAAQgGAAEEGAABgAIAAYADAAKAAQABgAMAAYABAAGAAQACgAIAA8ABAAHAAdwBwAEA AfABygGmAQABMwUAATMBAAEzAQABMwEAAjMCAAMWAQADHAEAAyIBAAMpAQADVQEAA00BAANCAQADOQEA AYABfAH/AQACUAH/AQABkwEAAdYBAAH/AewBzAEAAcYB1gHvAQAB1gLnAQABkAGpAa0CAAH/ATMDAAFm diff --git a/client/MaestroShared/Configuration/ConfigurationInfo.cs b/client/MaestroShared/Configuration/ConfigurationInfo.cs index 95b89b0a..f6d6135b 100644 --- a/client/MaestroShared/Configuration/ConfigurationInfo.cs +++ b/client/MaestroShared/Configuration/ConfigurationInfo.cs @@ -76,6 +76,7 @@ namespace MaestroShared.Configuration { public string SuccessEmailPattern { get; set; } public string Reference { get; set; } public bool NexioServer { get; set; } + public string NexioFileExistsMessage { get; set; } public string Agency { get; set; } } diff --git a/client/MaestroShared/MaestroShared.csproj b/client/MaestroShared/MaestroShared.csproj index 98b295a7..e7f1955c 100644 --- a/client/MaestroShared/MaestroShared.csproj +++ b/client/MaestroShared/MaestroShared.csproj @@ -89,6 +89,7 @@ + diff --git a/client/MaestroShared/MaestroShared.csproj.vspscc b/client/MaestroShared/MaestroShared.csproj.vspscc new file mode 100644 index 00000000..feffdeca --- /dev/null +++ b/client/MaestroShared/MaestroShared.csproj.vspscc @@ -0,0 +1,10 @@ +"" +{ +"FILE_VERSION" = "9237" +"ENLISTMENT_CHOICE" = "NEVER" +"PROJECT_FILE_RELATIVE_PATH" = "" +"NUMBER_OF_EXCLUDED_FILES" = "0" +"ORIGINAL_PROJECT_FILE_PATH" = "" +"NUMBER_OF_NESTED_PROJECTS" = "0" +"SOURCE_CONTROL_SETTINGS_PROVIDER" = "PROVIDER" +} diff --git a/client/MaestroShared/Resources/MaestroColors.cs b/client/MaestroShared/Resources/MaestroColors.cs new file mode 100644 index 00000000..32497ac4 --- /dev/null +++ b/client/MaestroShared/Resources/MaestroColors.cs @@ -0,0 +1,11 @@ +using System.Drawing; + +namespace MaestroShared.Resources { + public class MaestroColors { + public static readonly Color Green200 = Color.FromArgb(0xFF, 0xC5, 0xE1, 0xA5); + public static readonly Color Yellow200 = Color.FromArgb(0xFF, 0xE6, 0xEE, 0x9C); + public static readonly Color Orange200 = Color.FromArgb(0xFF, 0xFF, 0xCC, 0x80); + public static readonly Color Red200 = Color.FromArgb(0xFF, 0xEF, 0x9A, 0x9A); + public static readonly Color BlueGray200 = Color.FromArgb(0xFF, 0xB0, 0xBE, 0xC5); + } +} diff --git a/client/MaestroShared/Targets/FTPTargetProcessor.cs b/client/MaestroShared/Targets/FTPTargetProcessor.cs index 5a89cdd4..0d7cddd4 100644 --- a/client/MaestroShared/Targets/FTPTargetProcessor.cs +++ b/client/MaestroShared/Targets/FTPTargetProcessor.cs @@ -29,7 +29,7 @@ namespace MaestroShared.Targets { protected override void BeforeExecute() { base.BeforeExecute(); - targetFTP = CreateClient(parameters.TargetConfig.Remote); + targetFTP = CreateClient(Parameters.TargetConfig.Remote); } protected override void AfterExecute() { @@ -64,7 +64,7 @@ namespace MaestroShared.Targets { protected void reconnect() { TerminateClient(targetFTP); - targetFTP = CreateClient(parameters.TargetConfig.Remote); + targetFTP = CreateClient(Parameters.TargetConfig.Remote); EnsureDirectoryExistence(workingDir); } @@ -124,9 +124,9 @@ namespace MaestroShared.Targets { protected override string DetermineWorkingDirectory(Connection connection) { string result = null; - if (!String.IsNullOrEmpty(parameters.TargetConfig.SubFolderFormat)) { - string name = GetDynamicName(parameters.TargetConfig.SubFolderFormat); - if (parameters.TargetConfig.SubFolderFormat.Contains(PATTERN_TEXT)) { + if (!String.IsNullOrEmpty(Parameters.TargetConfig.SubFolderFormat)) { + string name = GetDynamicName(Parameters.TargetConfig.SubFolderFormat); + if (Parameters.TargetConfig.SubFolderFormat.Contains(PATTERN_TEXT)) { string pattern = name.Split(HYPHEN[0])[0] + HYPHEN; targetFTP.SetWorkingDirectory(connection.Address.LocalPath); FtpListItem item = targetFTP.GetListing()?.Where(i => i.Type.Equals(FtpFileSystemObjectType.Directory) && i.Name.StartsWith(pattern)).FirstOrDefault(); diff --git a/client/MaestroShared/Targets/FXPTargetProcessor.cs b/client/MaestroShared/Targets/FXPTargetProcessor.cs index 6ba5283d..0517ed54 100644 --- a/client/MaestroShared/Targets/FXPTargetProcessor.cs +++ b/client/MaestroShared/Targets/FXPTargetProcessor.cs @@ -33,7 +33,7 @@ namespace MaestroShared.Targets { string input = inputUri.AbsolutePath.Replace(LITERAL_SPACE, SPACE); long ilength = sourceFTP.GetFileSize(input); - if (parameters.TargetConfig.NexioServer) + if (Parameters.TargetConfig.NexioServer) ilength = ilength / 2; FtpReply replyPASV = targetFTP.Execute("PASV"); @@ -77,7 +77,7 @@ namespace MaestroShared.Targets { throw new Exception(replySTOR.ErrorMessage); - monitorFTP = CreateClient(parameters.TargetConfig.Remote); + monitorFTP = CreateClient(Parameters.TargetConfig.Remote); monitorFTP.SetWorkingDirectory(workingDir); FtpReply monitorReplyTYPE = monitorFTP.Execute("TYPE I"); if (!monitorReplyTYPE.Success) diff --git a/client/MaestroShared/Targets/ITargetProcessor.cs b/client/MaestroShared/Targets/ITargetProcessor.cs index 94157459..977f726d 100644 --- a/client/MaestroShared/Targets/ITargetProcessor.cs +++ b/client/MaestroShared/Targets/ITargetProcessor.cs @@ -5,6 +5,7 @@ using System.Windows.Forms; namespace MaestroShared.Targets { public interface ITargetProcessor : INotifyPropertyChanged { + TargetProcessorParameter Parameters { get; } DateTime Started { get; set; } DateTime Finished { get; set; } string Input { get; set; } diff --git a/client/MaestroShared/Targets/TargetProcessor.cs b/client/MaestroShared/Targets/TargetProcessor.cs index fc0b52a1..19dc09e6 100644 --- a/client/MaestroShared/Targets/TargetProcessor.cs +++ b/client/MaestroShared/Targets/TargetProcessor.cs @@ -7,6 +7,10 @@ using System.Windows.Forms; namespace MaestroShared.Targets { public abstract class TargetProcessor : MarshalByRefObject, ITargetProcessor { + public const string INPROGRESS = "Folyamatban"; + public const string ERROR = "Hiba"; + public const string READY = "Kész"; + public const string REVOKED = "Visszavonva"; private string status; private string message; private string id; @@ -25,6 +29,7 @@ namespace MaestroShared.Targets { public virtual void Initialize(Control parent, TargetProcessorParameter parameters) { this.parent = parent; + this.Parameters = parameters; } protected void NotifyPropertyChanged([CallerMemberName] String propertyName = "") { @@ -38,6 +43,8 @@ namespace MaestroShared.Targets { protected virtual void ExecuteCompleted() { } + public TargetProcessorParameter Parameters { get; internal set; } + public string Status { get { return status; diff --git a/client/MaestroShared/Targets/UNCTargetProcessor.cs b/client/MaestroShared/Targets/UNCTargetProcessor.cs index 2a842f66..33038f92 100644 --- a/client/MaestroShared/Targets/UNCTargetProcessor.cs +++ b/client/MaestroShared/Targets/UNCTargetProcessor.cs @@ -32,12 +32,9 @@ namespace MaestroShared.Targets { private const string COMMERCIAL = "COMMERCIAL"; private const string JUNCTION = "JUNCTION"; private const string XML_EXT = ".xml"; - private const string INPROGRESS = "Folyamatban"; - private const string ERROR = "Hiba"; private const string DOT = "."; private const string HYPHENSTAR = "-*"; private const string DATE_FORMAT_NODOTS = "yyyyMMdd"; - private const string READY = "Kész"; private const string HYPHEN_SPACES = " - "; private const string PATTERN_TARGETNAME = "%TARGETNAME%"; private const string PATTERN_ID = "%ID%"; @@ -53,13 +50,11 @@ namespace MaestroShared.Targets { protected const string SLASH = "/"; protected FileInfo inputFile; protected string workingDir; - protected TargetProcessorParameter parameters; public WorkflowAction workFlowAction { get; set; } public override void Initialize(Control parent, TargetProcessorParameter parameters) { base.Initialize(parent, parameters); - this.parameters = parameters; InputName = parameters.InputFileName; Input = Path.Combine(parameters.SourceConfig.Local.Address.LocalPath, parameters.InputFileName); inputFile = new FileInfo(Input); @@ -83,34 +78,29 @@ namespace MaestroShared.Targets { bool result = false; try { BeforeExecute(); - workingDir = DetermineWorkingDirectory(parameters.TargetConfig.Remote); + workingDir = DetermineWorkingDirectory(Parameters.TargetConfig.Remote); EnsureDirectoryExistence(workingDir); OutputName = CreateOutputFileName(); - OutputName = OutputName.ToUpper(); - Output = "/".Equals(workingDir) ? OutputName : Path.Combine(workingDir, OutputName); - Output = Output.Replace(@"\", "/"); + CreateOutput(workingDir); workFlowAction.source = Input; workFlowAction.destination = Output; Status = INPROGRESS; //DateTime started = DateTime.Now; string currentFile = GetOutputFilePath(workingDir, OutputName); - if (FileExists(currentFile) && parameters.TargetConfig.DisableFileVersioning) { - if (parameters.TargetConfig.NexioServer) { - MessageBox.Show(String.Format($"Az '{OutputName}' állomány már létezik. A feltöltéshez új Octopus azonosító generálása szükséges.")); - } else - DeleteFile(currentFile); + HandleFileExists(currentFile); + if (!REVOKED.Equals(Status)) { + UploadFile(); + //logger.Info("Spend (s):" + (DateTime.Now - started).TotalSeconds); + ExecuteCompleted(); } - UploadFile(); - //logger.Info("Spend (s):" + (DateTime.Now - started).TotalSeconds); - ExecuteCompleted(); } catch (Exception e) { Status = ERROR; Message = e.Message; workFlowAction.description = Message; logger.Error(e); - if (parameters.TargetConfig.SendEmailOnError && !String.IsNullOrEmpty(parameters.TargetConfig.ErrorEmailRecipient) && !String.IsNullOrEmpty(parameters.TargetConfig.ErrorEmailPattern)) - SendEmail(parameters.TargetConfig.ErrorEmailRecipient, parameters.TargetConfig.ErrorEmailPattern); + if (Parameters.TargetConfig.SendEmailOnError && !String.IsNullOrEmpty(Parameters.TargetConfig.ErrorEmailRecipient) && !String.IsNullOrEmpty(Parameters.TargetConfig.ErrorEmailPattern)) + SendEmail(Parameters.TargetConfig.ErrorEmailRecipient, Parameters.TargetConfig.ErrorEmailPattern); } finally { AfterExecute(); @@ -119,6 +109,30 @@ namespace MaestroShared.Targets { return result; } + private void CreateOutput(string workingDir) { + Output = "/".Equals(workingDir) ? OutputName : Path.Combine(workingDir, OutputName); + Output = Output.Replace(@"\", "/"); + } + + private void HandleFileExists(string currentFile) { + if (FileExists(currentFile) && Parameters.TargetConfig.DisableFileVersioning) { + if (Parameters.TargetConfig.NexioServer) { + Status = REVOKED; + ShowNexioFileExistsMessage(); + } else + DeleteFile(currentFile); + } + } + + private void ShowNexioFileExistsMessage() { + string message = null; + if (String.IsNullOrEmpty(Parameters.TargetConfig.NexioFileExistsMessage)) + message = "A feltöltéshez új Octopus azonosító generálása szükséges."; + else + message = Parameters.TargetConfig.NexioFileExistsMessage; + MessageBox.Show(String.Format($"Az '{OutputName}' állomány már létezik. {message}")); + } + protected virtual void DeleteFile(string currentFile) { File.Delete(currentFile); } @@ -136,22 +150,22 @@ namespace MaestroShared.Targets { base.ExecuteCompleted(); workFlowAction.description = SUCCESS; workFlowAction.successful = true; - if (parameters.TargetConfig.NexioServer) + if (Parameters.TargetConfig.NexioServer) UploadNexioMetadata(); else { - if (parameters.TargetConfig.KillDateDays > 0) + if (Parameters.TargetConfig.KillDateDays > 0) UploadKillDateFile(); } - if (parameters.TargetConfig.SaveArchiveMetadata && parameters.ArchiveMetadata != null) + if (Parameters.TargetConfig.SaveArchiveMetadata && Parameters.ArchiveMetadata != null) CreateArchiveMetadata(); - if (parameters.TargetConfig.SaveMorpheusMetadata && parameters.ArchiveMetadata != null && parameters.MovieSegments != null && parameters.MovieSegments.Count > 0) + if (Parameters.TargetConfig.SaveMorpheusMetadata && Parameters.ArchiveMetadata != null && Parameters.MovieSegments != null && Parameters.MovieSegments.Count > 0) UploadMorpheusMetadata(); - if (parameters.TargetConfig.SaveSegments && parameters.Segments != null) - parameters.TrafficApi.UpdateTrafficInformation(parameters.VariantID, true, (TrafficMetadataType)parameters.MetadataKind, parameters.Segments); + if (Parameters.TargetConfig.SaveSegments && Parameters.Segments != null) + Parameters.TrafficApi.UpdateTrafficInformation(Parameters.VariantID, true, (TrafficMetadataType)Parameters.MetadataKind, Parameters.Segments); - if (parameters.TargetConfig.SendEmailOnSuccess && !String.IsNullOrEmpty(parameters.TargetConfig.SuccessEmailRecipient) && !String.IsNullOrEmpty(parameters.TargetConfig.SuccessEmailPattern)) - SendEmail(parameters.TargetConfig.SuccessEmailRecipient, parameters.TargetConfig.SuccessEmailPattern); + 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; } @@ -159,24 +173,24 @@ namespace MaestroShared.Targets { private void UploadNexioMetadata() { String xml = null; string name = GetOutputName(); - string description = parameters.ArchiveMetadata?.mediaTitle; - if (parameters.TargetConfig.KillDateDays > 0) { + string description = Parameters.ArchiveMetadata?.mediaTitle; + if (Parameters.TargetConfig.KillDateDays > 0) { DateTime date = GetKillDate(); KillDate = date.ToString(DATE_FORMAT); - xml = NexioXML.ToXML(name, date, description, parameters.TargetConfig.Agency); + xml = NexioXML.ToXML(name, date, description, Parameters.TargetConfig.Agency); } else - xml = NexioXML.ToXML(name, null, description, parameters.TargetConfig.Agency); + xml = NexioXML.ToXML(name, null, description, Parameters.TargetConfig.Agency); byte[] content = Encoding.Unicode.GetBytes(xml); UploadContent(name + XML_EXT, content); } private void UploadMorpheusMetadata() { string name = GetOutputName(); - string title = parameters.ArchiveMetadata?.itemTitle; - if (!title.Equals(parameters.ArchiveMetadata?.mediaTitle)) - title += HYPHEN_SPACES + parameters.ArchiveMetadata?.mediaTitle; + string title = Parameters.ArchiveMetadata?.itemTitle; + if (!title.Equals(Parameters.ArchiveMetadata?.mediaTitle)) + title += HYPHEN_SPACES + Parameters.ArchiveMetadata?.mediaTitle; string type = null; - switch (parameters.MetadataKind) { + switch (Parameters.MetadataKind) { case MetadataType.TrafficMaterial: type = PROGRAMME; break; @@ -187,15 +201,15 @@ namespace MaestroShared.Targets { type = JUNCTION; break; } - byte[] content = MorpheusXML.ToXML(title, name, parameters.TargetConfig.DeviceIDMorpheus, type, parameters.MovieSegments); - EnsureDirectoryExistence(parameters.TargetConfig.PathMorpheusMetadata); + byte[] content = MorpheusXML.ToXML(title, name, Parameters.TargetConfig.DeviceIDMorpheus, type, Parameters.MovieSegments); + EnsureDirectoryExistence(Parameters.TargetConfig.PathMorpheusMetadata); UploadContent(name + XML_EXT, content); } private void SendEmail(string to, string messagePattern) { try { string message = messagePattern.Replace(PATTERN_TARGETNAME, OutputName); - parameters.MediaCubeApi.Notify(to, message); + Parameters.MediaCubeApi.Notify(to, message); } catch (Exception e) { MessageBox.Show(parent, e.Message); @@ -215,7 +229,7 @@ namespace MaestroShared.Targets { private void SendWorkFlowAction() { try { - parameters.MediaCubeApi.Create(workFlowAction); + Parameters.MediaCubeApi.Create(workFlowAction); } catch (Exception e) { MessageBox.Show(parent, e.Message); @@ -224,9 +238,9 @@ namespace MaestroShared.Targets { protected virtual string DetermineWorkingDirectory(Connection connection) { string result = null; - if (!String.IsNullOrEmpty(parameters.TargetConfig.SubFolderFormat)) { - string name = GetDynamicName(parameters.TargetConfig.SubFolderFormat); - if (parameters.TargetConfig.SubFolderFormat.Contains(PATTERN_TEXT)) { + if (!String.IsNullOrEmpty(Parameters.TargetConfig.SubFolderFormat)) { + string name = GetDynamicName(Parameters.TargetConfig.SubFolderFormat); + if (Parameters.TargetConfig.SubFolderFormat.Contains(PATTERN_TEXT)) { string pattern = name.Split(HYPHEN[0])[0] + HYPHENSTAR; string[] dirs = Directory.GetDirectories(connection.Address.LocalPath, pattern); if (dirs.Length > 0) @@ -240,12 +254,12 @@ namespace MaestroShared.Targets { private DateTime GetKillDate() { DateTime result = DateTime.Now; - result = result.AddDays(parameters.TargetConfig.KillDateDays); + result = result.AddDays(Parameters.TargetConfig.KillDateDays); return result; } private void UploadKillDateFile() { - Uri address = parameters.TargetConfig.Remote.Address; + Uri address = Parameters.TargetConfig.Remote.Address; string statusWorkDir = Path.Combine(workingDir, STATUS_FOLDER); EnsureDirectoryExistence(statusWorkDir); DateTime date = GetKillDate(); @@ -257,23 +271,23 @@ namespace MaestroShared.Targets { } private void CreateArchiveMetadata() { - Uri address = parameters.TargetConfig.Remote.Address; + Uri address = Parameters.TargetConfig.Remote.Address; string statusWorkDir = Path.Combine(workingDir, STATUS_FOLDER); EnsureDirectoryExistence(statusWorkDir); string fileName = String.Format(METADATA_FILE, OutputName); //logger.Debug("Creating METADATA file {0}", fileName); - byte[] content = Encoding.UTF8.GetBytes(parameters.ArchiveMetadata.ToString()); + byte[] content = Encoding.UTF8.GetBytes(Parameters.ArchiveMetadata.ToString()); string ouputPath = GetOutputFilePath(statusWorkDir, fileName); UploadContent(ouputPath, content); } private void CreateTrafficMetadata() { - Uri address = parameters.TargetConfig.Remote.Address; + Uri address = Parameters.TargetConfig.Remote.Address; string statusWorkDir = Path.Combine(workingDir, STATUS_FOLDER); EnsureDirectoryExistence(statusWorkDir); string fileName = String.Format(METADATA_FILE, OutputName); //logger.Debug("Creating METADATA file {0}", fileName); - byte[] content = Encoding.UTF8.GetBytes(parameters.ArchiveMetadata.ToString()); + byte[] content = Encoding.UTF8.GetBytes(Parameters.ArchiveMetadata.ToString()); string ouputPath = GetOutputFilePath(statusWorkDir, fileName); UploadContent(ouputPath, content); } @@ -330,8 +344,8 @@ namespace MaestroShared.Targets { .Replace(PATTERN_TIMESTAMP, DateTime.Now.ToString(DATETIME_FORMAT, CultureInfo.InvariantCulture)) .Replace(PATTERN_DATESTAMP, DateTime.Now.ToString(DATE_FORMAT_NODOTS, CultureInfo.InvariantCulture)); - if (!String.IsNullOrEmpty(parameters.MetadataText)) - result = result.Replace(PATTERN_TEXT, HYPHEN + RemoveDiacritics(parameters.MetadataText)); + if (!String.IsNullOrEmpty(Parameters.MetadataText)) + result = result.Replace(PATTERN_TEXT, HYPHEN + RemoveDiacritics(Parameters.MetadataText)); // replace hungarian and special characters result = Regex.Replace(result, NORMALIZE_TEXT_PATTERN, UNDERSCORE); @@ -341,11 +355,11 @@ namespace MaestroShared.Targets { } protected virtual string CreateOutputFileName() { - string nameWithoutExtension = GetDynamicName(parameters.TargetConfig.OutputFormat); + string nameWithoutExtension = GetDynamicName(Parameters.TargetConfig.OutputFormat); string extension = InputName.Contains(DOT) ? InputName.Substring(InputName.LastIndexOf(DOT)) : DEFAULT_EXTENSION; extension = extension.ToUpper(); string result = String.Format(FILENAME, nameWithoutExtension, extension); - if (!parameters.TargetConfig.DisableFileVersioning) { + if (!Parameters.TargetConfig.DisableFileVersioning) { int version = 1; while (FileExists(GetOutputFilePath(workingDir, result))) { string versioned = String.Format(VERSIONED_FILENAME, nameWithoutExtension, version, extension); @@ -354,7 +368,7 @@ namespace MaestroShared.Targets { version++; } } - return result; + return result.ToUpper(); } protected virtual void EnsureDirectoryExistence(string path) {