From: Vásáry Dániel Date: Mon, 16 Oct 2017 16:05:40 +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=a142355900dc6f464bd91a87f6ed99fbf1af2a6c;p=mediacube.git git-tfs-id: [tfs.userrendszerhaz.hu:8080/tfs/DefaultCollection]$/MediaCube;C30629 --- diff --git a/client/IntegrationTests/MaestroIT.cs b/client/IntegrationTests/MaestroIT.cs index 4ccfe3d7..0017041e 100644 --- a/client/IntegrationTests/MaestroIT.cs +++ b/client/IntegrationTests/MaestroIT.cs @@ -3,10 +3,10 @@ using Maestro.Targets; using Maestro; using Microsoft.VisualStudio.TestTools.UnitTesting; using System; -using Commons; using Maestro.Commons; using System.Diagnostics; using SharpCifs.Smb; +using Commons; namespace IntegrationTests { [TestClass] @@ -63,5 +63,14 @@ namespace IntegrationTests { sut.Execute(); } + [TestMethod] + public void TestNexioXML() { + String xml = NexioXML.ToXML("aaaaa", DateTime.Now, "description", "agency"); + Debug.WriteLine(xml); + + string result = "valammi.mxf"; + result = result.Substring(0, result.LastIndexOf(".")); + Debug.WriteLine(result); + } } -} +} \ No newline at end of file diff --git a/client/Maestro/Commons/NexioXML.cs b/client/Maestro/Commons/NexioXML.cs new file mode 100644 index 00000000..bca4977f --- /dev/null +++ b/client/Maestro/Commons/NexioXML.cs @@ -0,0 +1,42 @@ +using System; +using System.IO; +using System.Text; +using System.Xml; + +/* + + + 02-02-2018 + TEST TEST + AGENT AGENT + +*/ +namespace Commons { + + public class NexioXML { + public static string ToXML(string fileName, DateTime? killDate, string description, string agency) { + if (String.IsNullOrEmpty(fileName)) + throw new NullReferenceException("Hiányzik a cél állomány neve."); + + string result = null; + XmlDocument doc = new XmlDocument(); + XmlElement rootElement = (XmlElement)doc.AppendChild(doc.CreateElement("ID")); + rootElement.SetAttribute("extendedId", fileName); + if (killDate != null) + rootElement.AppendChild(doc.CreateElement("KillDate")).InnerText = ((DateTime)killDate).ToString("MM-dd-yyyy"); + if (!String.IsNullOrEmpty(description)) + rootElement.AppendChild(doc.CreateElement("ExtendedDescription")).InnerText = description; + if (!String.IsNullOrEmpty(agency)) + rootElement.AppendChild(doc.CreateElement("ExtendedAgency")).InnerText = agency; + + XmlWriterSettings settings = new XmlWriterSettings(); + settings.Indent = true; + StringBuilder ms = new StringBuilder(); + XmlWriter writer = XmlWriter.Create(ms, settings); + doc.Save(writer); + result = ms.ToString(); + return result; + } + } + +} \ No newline at end of file diff --git a/client/Maestro/Configuration/ConfigurationInfo.cs b/client/Maestro/Configuration/ConfigurationInfo.cs index eab032f7..bc2dc1a8 100644 --- a/client/Maestro/Configuration/ConfigurationInfo.cs +++ b/client/Maestro/Configuration/ConfigurationInfo.cs @@ -56,6 +56,8 @@ namespace Maestro.Configuration { public string SuccessEmailRecipient { get; set; } public string SuccessEmailPattern { get; set; } public string Reference { get; set; } + public bool NexioServer { get; set; } + public string Agency { get; set; } } public class Connection { diff --git a/client/Maestro/Configuration/configuration-editor.json b/client/Maestro/Configuration/configuration-editor.json index d142ae26..4b210961 100644 --- a/client/Maestro/Configuration/configuration-editor.json +++ b/client/Maestro/Configuration/configuration-editor.json @@ -58,6 +58,8 @@ "processor": "FTPTargetProcessor", "outputFormat": "%ID%", "tag": "Betöltés", + "nexioServer": true, + "killDateDays": 7, "remote": { "address": "ftp://10.10.1.56:2098", "userName": "administaror", diff --git a/client/Maestro/Configuration/configuration-nle.json b/client/Maestro/Configuration/configuration-nle.json index 04a2d15c..a5d17193 100644 --- a/client/Maestro/Configuration/configuration-nle.json +++ b/client/Maestro/Configuration/configuration-nle.json @@ -58,10 +58,13 @@ "processor": "FTPTargetProcessor", "outputFormat": "%ID%", "tag": "Betöltés", + "nexioServer": true, + "agency": "NLE UPLOAD", + "killDateDays": 7, "remote": { "address": "ftp://10.10.1.56:2098", "userName": "administaror", - "password": "system", + "password": "system", "timeout": 1000 } }, diff --git a/client/Maestro/Maestro.csproj b/client/Maestro/Maestro.csproj index 829a37f0..5c057d7c 100644 --- a/client/Maestro/Maestro.csproj +++ b/client/Maestro/Maestro.csproj @@ -160,6 +160,7 @@ + @@ -171,6 +172,7 @@ ArchiveMetadataForm.cs + diff --git a/client/Maestro/MaestroForm.Designer.cs b/client/Maestro/MaestroForm.Designer.cs index 603ec587..3f96862b 100644 --- a/client/Maestro/MaestroForm.Designer.cs +++ b/client/Maestro/MaestroForm.Designer.cs @@ -91,6 +91,7 @@ namespace Maestro { this.messageDataGridViewTextBoxColumn = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.systemMessageBindingSource = new System.Windows.Forms.BindingSource(this.components); this.metadataInfoBindingSource = new System.Windows.Forms.BindingSource(this.components); + this.lbSourceTitle = new System.Windows.Forms.Label(); this.groupSource.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.dataGridSource)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.bindingSource)).BeginInit(); @@ -133,6 +134,7 @@ namespace Maestro { this.groupSource.Controls.Add(this.dataGridSource); this.groupSource.Controls.Add(this.tableLayoutPanel2); this.groupSource.Controls.Add(this.panel2); + this.groupSource.Controls.Add(this.lbSourceTitle); this.groupSource.Dock = System.Windows.Forms.DockStyle.Fill; this.groupSource.Location = new System.Drawing.Point(0, 0); this.groupSource.Name = "groupSource"; @@ -175,14 +177,14 @@ namespace Maestro { this.dataGridSource.DefaultCellStyle = dataGridViewCellStyle2; this.dataGridSource.Dock = System.Windows.Forms.DockStyle.Fill; this.dataGridSource.EditMode = System.Windows.Forms.DataGridViewEditMode.EditProgrammatically; - this.dataGridSource.Location = new System.Drawing.Point(10, 43); + this.dataGridSource.Location = new System.Drawing.Point(10, 56); this.dataGridSource.Name = "dataGridSource"; this.dataGridSource.RowHeadersVisible = false; dataGridViewCellStyle3.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238))); this.dataGridSource.RowsDefaultCellStyle = dataGridViewCellStyle3; this.dataGridSource.RowTemplate.DefaultCellStyle.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238))); this.dataGridSource.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect; - this.dataGridSource.Size = new System.Drawing.Size(394, 356); + this.dataGridSource.Size = new System.Drawing.Size(394, 343); this.dataGridSource.TabIndex = 0; this.dataGridSource.CellContentClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.sourceGridView_CellContentClick); this.dataGridSource.CellEnter += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridSource_CellEnter); @@ -255,7 +257,7 @@ namespace Maestro { this.panel2.Controls.Add(this.buttonDeleteFilter); this.panel2.Controls.Add(this.txtSorceFilter); this.panel2.Dock = System.Windows.Forms.DockStyle.Top; - this.panel2.Location = new System.Drawing.Point(10, 23); + this.panel2.Location = new System.Drawing.Point(10, 36); this.panel2.Name = "panel2"; this.panel2.Size = new System.Drawing.Size(394, 20); this.panel2.TabIndex = 14; @@ -830,6 +832,16 @@ namespace Maestro { // metadataInfoBindingSource // this.metadataInfoBindingSource.DataSource = typeof(Maestro.Metadata.MetadataInfo); + // + // lbSourceTitle + // + this.lbSourceTitle.Dock = System.Windows.Forms.DockStyle.Top; + this.lbSourceTitle.Location = new System.Drawing.Point(10, 23); + this.lbSourceTitle.Name = "lbSourceTitle"; + this.lbSourceTitle.Size = new System.Drawing.Size(394, 13); + this.lbSourceTitle.TabIndex = 15; + this.lbSourceTitle.Text = " sklj jgja gjfldjg fdljg fdkljg fldkjg jfdg sklj jgja gjfldjg fdljg fdkljg fldkjg" + + " jfdg sklj jgja gjfldjg fdljg fdkljg fldkjg jfdg"; // // MaestroForm // @@ -940,6 +952,7 @@ namespace Maestro { private System.Windows.Forms.DataGridViewTextBoxColumn columnInput; private System.Windows.Forms.DataGridViewTextBoxColumn columnOutput; private System.Windows.Forms.DataGridViewTextBoxColumn columnKillDate; + private System.Windows.Forms.Label lbSourceTitle; } } diff --git a/client/Maestro/MaestroForm.Source.cs b/client/Maestro/MaestroForm.Source.cs index 43cc83c0..2fd8d29d 100644 --- a/client/Maestro/MaestroForm.Source.cs +++ b/client/Maestro/MaestroForm.Source.cs @@ -18,7 +18,7 @@ namespace Maestro { private ISource source; private SourceInfo selectedSource; private string startingName; - private List selectedRows = new List(); + private List selectedSourceRows = new List(); public IDTypes IDType { get; set; } @@ -33,7 +33,13 @@ namespace Maestro { } private void InitializeSource() { - Uri address = Configuration?.Source?.Local?.Address; + Uri localAddress = Configuration?.Source?.Local?.Address; + Uri remoteAddress = Configuration?.Source?.Remote?.Address; + if (String.IsNullOrEmpty(remoteAddress?.ToString())) { + if (!String.IsNullOrEmpty(localAddress?.ToString())) + SetSourceTitle(localAddress?.ToString()); + } else + SetSourceTitle(remoteAddress?.ToString()); if (Configuration?.Source is UNCSource) { logger.Debug("UNC source initialization"); @@ -49,10 +55,23 @@ namespace Maestro { MessageBus.Subscribe(OnFileInvolved); MessageBus.Subscribe(OnFileInvolved); - source.Startup(address); + source.Startup(localAddress); bindingSource.DataSource = source; dataGridSource.Columns.AddRange(new DataGridViewCheckBoxColumn()); dataGridSource.Columns.AddRange(source.Columns); + + + } + + private void SetSourceTitle(String text) { + try { + lbSourceTitle.Text = text; + Size sz = new Size(lbSourceTitle.Width, Int32.MaxValue); + sz = TextRenderer.MeasureText(text, lbSourceTitle.Font, sz, TextFormatFlags.WordBreak); + lbSourceTitle.Height = sz.Height; + } + finally { + } } private void OnFileInvolved(FileActionMsg m) { @@ -128,10 +147,10 @@ namespace Maestro { else checkBoxCell.Value = (checkBoxCell.Value == null || checkBoxCell.Value.Equals(false)) ? true : false; if (checkBoxCell.Value.Equals(false)) - this.selectedRows.Remove(actualRow); + this.selectedSourceRows.Remove(actualRow); else { - if (!this.selectedRows.Contains(actualRow)) - this.selectedRows.Add(actualRow); + if (!this.selectedSourceRows.Contains(actualRow)) + this.selectedSourceRows.Add(actualRow); } SetTextSelectedSourceTextFromCheckBoxes(); SetMetadataButtonEnabled((bool)checkBoxCell.Value); @@ -153,18 +172,18 @@ namespace Maestro { private void SetMetadataButtonEnabled(bool checkBox) { SetStartingName(checkBox); - if (selectedRows == null || selectedRows.Count == 0) { + if (selectedSourceRows == null || selectedSourceRows.Count == 0) { buttonMetadata.Enabled = false; IsSelectedFileAnID(); return; } - if (selectedRows.Count == 1) { + if (selectedSourceRows.Count == 1) { buttonMetadata.Enabled = true; IsSelectedFileAnID(); return; } int index = dataGridSource.Columns.Cast().Where(x => x.HeaderText == StringResources.NEV).SingleOrDefault().Index; - foreach (DataGridViewRow actual in selectedRows) { + foreach (DataGridViewRow actual in selectedSourceRows) { string name = actual.Cells[index].Value as string; if (!name.StartsWith(String.Format("{0}-", startingName)) && !name.StartsWith(String.Format("{0}_", startingName)) && @@ -179,12 +198,12 @@ namespace Maestro { private void SetStartingName(bool checkBox) { if (!checkBox) - if (selectedRows == null || selectedRows.Count == 0) { + if (selectedSourceRows == null || selectedSourceRows.Count == 0) { startingName = null; return; } int index = dataGridSource.Columns.Cast().Where(x => x.HeaderText == StringResources.NEV).SingleOrDefault().Index; - string query = selectedRows[0].Cells[index].Value as string; + string query = selectedSourceRows[0].Cells[index].Value as string; int separatorPosition = query.IndexOf("-"); int separatorPosition2 = query.IndexOf("_"); int realseparatorPosition = 0; @@ -208,7 +227,7 @@ namespace Maestro { private void SetTextSelectedSourceTextFromCheckBoxes() { String selectedNames = ""; int index = dataGridSource.Columns.Cast().Where(x => x.HeaderText == StringResources.NEV).SingleOrDefault().Index; - foreach (DataGridViewRow actual in selectedRows) + foreach (DataGridViewRow actual in selectedSourceRows) selectedNames += actual.Cells[index].Value + " "; SelectedSource = new SourceInfo() { Name = selectedNames @@ -220,9 +239,9 @@ namespace Maestro { private void SetSelectedSourceFileInfo(SourceInfo selectedSource) { if (Configuration.Source.GetType() == typeof(NEXIOSource)) selectedSource.FileInfo = null; - else if (selectedRows.Count == 1) { + else if (selectedSourceRows.Count == 1) { int index = dataGridSource.Columns.Cast().Where(x => x.HeaderText == StringResources.NEV).SingleOrDefault().Index; - string name = selectedRows[0].Cells[index].Value as string; + string name = selectedSourceRows[0].Cells[index].Value as string; Uri inputUri = new Uri(String.Format("{0}/{1}", Configuration.Source.Local.Address.LocalPath, name)); selectedSource.FileInfo = new System.IO.FileInfo(inputUri.LocalPath); } @@ -251,10 +270,10 @@ namespace Maestro { public void SourceDeleted(String fileName) { int index = dataGridSource.Columns.Cast().Where(x => x.HeaderText == StringResources.NEV).SingleOrDefault().Index; - foreach (DataGridViewRow actual in selectedRows) { + foreach (DataGridViewRow actual in selectedSourceRows) { String actualName = actual.Cells[index].Value as string; if (fileName.Equals(actualName)) { - selectedRows.Remove(actual); + selectedSourceRows.Remove(actual); if (textSelectedSource.InvokeRequired) { SetTextCallback d = new SetTextCallback(SetTextSelectedSourceAndMetadataButtonEnabled); Invoke(d); @@ -267,7 +286,7 @@ namespace Maestro { private void SetTextSelectedSourceAndMetadataButtonEnabled() { SetTextSelectedSourceTextFromCheckBoxes(); - SetMetadataButtonEnabled(selectedRows.Count > 0); + SetMetadataButtonEnabled(selectedSourceRows.Count > 0); } private void dataGridSource_KeyDown(object sender, KeyEventArgs e) { diff --git a/client/Maestro/MaestroForm.Target.cs b/client/Maestro/MaestroForm.Target.cs index 02cf026f..7bc2ac77 100644 --- a/client/Maestro/MaestroForm.Target.cs +++ b/client/Maestro/MaestroForm.Target.cs @@ -71,12 +71,12 @@ namespace Maestro { return; if (checkBox.Checked) { List processors = new List(); - foreach (DataGridViewRow actualRow in selectedRows) { - - string fileName = actualRow.Cells[1].Value as string; + foreach (DataGridViewRow actualRow in selectedSourceRows) { + ISourceItem sourceItem = actualRow.DataBoundItem as ISourceItem; + if (sourceItem == null) + continue; string typeName = string.Format("{0}.{1}", typeof(ITargetProcessor).Namespace, target.Processor); Type type = Type.GetType(typeName); - ISourceItem selectedFile = GetSourceItemFromBindingSource(fileName); string id = selectedMetadata == null ? textSelectedMetadata.Text : selectedMetadata.ID; if (segments == null) { if (target.SaveSegments) { @@ -90,7 +90,7 @@ namespace Maestro { ArchiveMetadata = ArchiveMetadata.DeepClone(archiveMetadatamodel), Client = trafficIDSelector.trafficAPI, ID = id, - InputFileName = selectedFile.Name, + InputFileName = sourceItem.Name, MediaCubeApi = mediaCubeApi, Segments = new List(segments), SourceConfig = Configuration.Source, @@ -150,16 +150,15 @@ namespace Maestro { } private void ApplyMetaDataButtonLogic() { - if (selectedRows.Count <= 0) { + if (selectedSourceRows.Count <= 0) { buttonMetadata.Enabled = false; return; } - if (selectedRows.Count == 1) + if (selectedSourceRows.Count == 1) buttonMetadata.Enabled = true; else { - String calculatedHouseID = selectedRows[0].Cells[1].Value as String; - foreach (DataGridViewRow actual in selectedRows) { - string actualName = actual.Cells[2].Value as string; + foreach (DataGridViewRow actualRow in selectedSourceRows) { + string actualName = (actualRow as ISourceItem).Name; if (!actualName.StartsWith(startingName)) buttonMetadata.Enabled = false; } @@ -267,18 +266,19 @@ namespace Maestro { } private void IsSelectedFileAnID() { + IDType = IDTypes.None; if (String.IsNullOrEmpty(startingName)) return; - string pattern = "[A-Z]{1}[0-9]{6}[A-Z]{1}"; - Match match = Regex.Match(startingName, pattern); + Match match = Regex.Match(startingName, "[A-Z]{1}[0-9]{6}[A-Z]{1}"); if (match.Success) { IDType = IDTypes.TrafficID; return; - } else { - pattern = "[0-9]"; - match = Regex.Match(startingName, pattern); - IDType = match.Success ? IDTypes.OctopusID : IDTypes.None; } + + match = Regex.Match(startingName, "[0-9]"); + if (match.Success) + IDType = IDTypes.OctopusID; + buttonMetadata.Enabled = IDType != IDTypes.None; } diff --git a/client/Maestro/Sources/NexioRESTSource.cs b/client/Maestro/Sources/NexioRESTSource.cs index 3e98734d..70527951 100644 --- a/client/Maestro/Sources/NexioRESTSource.cs +++ b/client/Maestro/Sources/NexioRESTSource.cs @@ -13,6 +13,7 @@ using System.Drawing; using NLog; using JobEngineClient; using System.Collections.Generic; +using System.Collections.Concurrent; namespace Maestro.Sources { class NexioRESTSource : BindingList, ISource { @@ -24,7 +25,7 @@ namespace Maestro.Sources { private const string DURATION = "duration"; private const string MODIFIED = "modifiedtimestamp"; private List acceptableAgencies = new List(); - private List cache = new List(); + //private ConcurrentBag cache = new ConcurrentBag(); private IMessageBus messageBus; private Control parent; private NexioAPI dataClient; @@ -64,11 +65,13 @@ namespace Maestro.Sources { public string Filter { get => filter; set { - if (cache.Count == 0) - cache.AddRange(this); filter = value; - Clear(); - cache.Where(i => i.Name.ToLower().Contains(filter.ToLower())).ToList().ForEach(i => Add(i)); + if (String.IsNullOrEmpty(value)) { + RemoveFilter(); + } else { + Clear(); + //cache.Where(i => i.Name.ToLower().Contains(filter.ToLower())).ToList().ForEach(i => Add(i)); + } } } @@ -99,8 +102,6 @@ namespace Maestro.Sources { } private void CreateWatch(string path) { - logger.Info("info"); - logger.Error("error"); dataClient = new NexioAPI(path) { ErrorReporter = errorReporter }; dataClient.Open(OnResponse); } @@ -149,7 +150,8 @@ namespace Maestro.Sources { item.ID = token[ID].ToString(); item.Name = token[LONGNAMEID].ToString() + ".mxf"; //item.Created = DateTime.Parse(token[RECORDDATE].ToString()); - item.Agency = token[EXTAGENCY].ToString(); + + item.Agency = token[EXTAGENCY]?.ToString(); if (token[MODIFIED] != null && String.IsNullOrEmpty(token[MODIFIED].ToString())) item.Modified = DateTime.Parse(token[MODIFIED].ToString()); if (DateTime.MinValue.Equals(item.Modified)) @@ -168,45 +170,43 @@ namespace Maestro.Sources { string id = token[ID].ToString(); var item = Items.Where(x => x.ID == id).SingleOrDefault(); if (item == null) { - var newItem = CreateItem(token, true); - item = newItem; - } - SetItem(ref item, token); - if (!item.CanHandle(acceptableAgencies)) { - if (Contains(item)) { - parent.SafeCall(() => { - Remove(item); - cache.Remove(item); + item = CreateItem(token, true); + if (!item.CanHandle(acceptableAgencies)) + return; + parent.SafeCall(() => { + Add(item); + messageBus.Send(new ModifyFileActionMsg() { + FileName = item.Name, + Source = parent }); - } - return; - } - parent.SafeCall(() => { - messageBus.Send(new ModifyFileActionMsg() { - FileName = item.Name, - Source = parent }); - }); - if (!Contains(item)) + } else { parent.SafeCall(() => { - Add(item); - cache.Add(item); + SetItem(ref item, token); + if (item.CanHandle(acceptableAgencies)) + return; + Remove(item); + messageBus.Send(new RemoveFileActionMsg() { + FileName = item.Name, + Source = parent + }); }); + } Debug.WriteLine(string.Format("Changed {0}", item.Name)); } private void OnCreated(JToken token) { var item = CreateItem(token, true); - if (item.CanHandle(acceptableAgencies)) { - parent.SafeCall(() => { - Insert(0, item); - messageBus.Send(new CreateFileActionMsg() { - FileName = item.Name, - Source = parent - }); + if (!item.CanHandle(acceptableAgencies)) + return; + parent.SafeCall(() => { + Insert(0, item); + messageBus.Send(new CreateFileActionMsg() { + FileName = item.Name, + Source = parent }); - Debug.WriteLine(string.Format("Created {0}", item.Name)); - } + }); + Debug.WriteLine(string.Format("Created {0}", item.Name)); } private void OnDeleted(JToken d) { @@ -229,7 +229,9 @@ namespace Maestro.Sources { public void RemoveFilter() { Clear(); - cache.ForEach(i => Add(i)); + //cache.ToList().ForEach(i => Add(i)); } + + } } diff --git a/client/Maestro/Targets/FTPTargetProcessor.cs b/client/Maestro/Targets/FTPTargetProcessor.cs index a7c0cc25..52358d25 100644 --- a/client/Maestro/Targets/FTPTargetProcessor.cs +++ b/client/Maestro/Targets/FTPTargetProcessor.cs @@ -34,13 +34,37 @@ namespace Maestro.Targets { TerminateClient(targetFTP); } - protected override void UploadFile() { using (FileStream istream = File.OpenRead(Input)) { using (Stream ostream = targetFTP.OpenWrite(Output)) { - CopyStream(istream, inputFile.Length, ostream); + try { + CopyStream(istream, inputFile.Length, ostream); + } + catch (Exception e) { + logger.Error(e.Message); + } + finally { + ostream.Close(); + } + } + } + if (parameters.TargetConfig.NexioServer) + Thread.Sleep(500); + } + + protected override void UploadContent(string outputPath, byte[] content) { + using (Stream ostream = targetFTP.OpenWrite(outputPath)) { + try { + ostream.Write(content, 0, content.Length); } + catch (Exception e) { + logger.Error(e.Message); + } finally{ + ostream.Close(); + } } + if (parameters.TargetConfig.NexioServer) + Thread.Sleep(500); } protected override bool FileExists(string path) { @@ -76,7 +100,6 @@ namespace Maestro.Targets { protected void TerminateClient(FtpClient ftpClient) { if (ftpClient != null) { - Thread.Sleep(500); ftpClient.Disconnect(); ftpClient.Dispose(); } diff --git a/client/Maestro/Targets/UNCTargetProcessor.cs b/client/Maestro/Targets/UNCTargetProcessor.cs index abb26a26..7f386e79 100644 --- a/client/Maestro/Targets/UNCTargetProcessor.cs +++ b/client/Maestro/Targets/UNCTargetProcessor.cs @@ -7,6 +7,7 @@ using TrafficClient; using Model; using System.Text; using Maestro.Commons; +using Commons; namespace Maestro.Targets { @@ -74,14 +75,29 @@ namespace Maestro.Targets { return result; } + + private string GetOutputName() { + if (String.IsNullOrEmpty(OutputName)) + return null; + string result = OutputName; + if (result.Contains(".")) + result = result.Substring(0, result.LastIndexOf(".")); + return result; + } + protected override void ExecuteCompleted() { base.ExecuteCompleted(); Status = "Kész"; Message = SUCCESS; workFlowAction.description = SUCCESS; workFlowAction.successful = true; - if (parameters.TargetConfig.KillDateDays > 0) - UploadKillDateFile(); + if (parameters.TargetConfig.NexioServer) + UploadNexioMetadata(); + else { + if (parameters.TargetConfig.KillDateDays > 0) + UploadKillDateFile(); + } + if (parameters.TargetConfig.CreateMetadata && parameters.ArchiveMetadata != null) CreateMetadata(); if (parameters.TargetConfig.SaveSegments && parameters.Segments != null) { @@ -93,6 +109,20 @@ namespace Maestro.Targets { SendEmail(parameters.TargetConfig.SuccessEmailRecipient, parameters.TargetConfig.SuccessEmailPattern); } + private void UploadNexioMetadata() { + String xml = null; + string name = GetOutputName(); + string description = parameters.ArchiveMetadata?.mediaTitle == null ? parameters.ArchiveMetadata?.itemTitle : parameters.ArchiveMetadata?.mediaTitle; + if (parameters.TargetConfig.KillDateDays > 0) { + KillDate = GetKillDate(); + xml = NexioXML.ToXML(name, KillDate, description, parameters.TargetConfig.Agency); + } + else + xml = NexioXML.ToXML(name, null, description, parameters.TargetConfig.Agency); + byte[] content = Encoding.Unicode.GetBytes(xml); + UploadContent(name + ".xml", content); + } + private void SendEmail(string to, string messagePattern) { try { string message = messagePattern.Replace("%TARGETNAME%", Output); @@ -129,7 +159,7 @@ namespace Maestro.Targets { } } - private String DetermineWorkingDirectory(Connection connection) { + protected String DetermineWorkingDirectory(Connection connection) { string result = null; if (parameters.TargetConfig.CreateSubFolder) result = Path.Combine(connection.Address.LocalPath, ID); @@ -138,12 +168,17 @@ namespace Maestro.Targets { return result; } + private DateTime GetKillDate() { + DateTime result = DateTime.Now; + result = result.AddDays(parameters.TargetConfig.KillDateDays); + return result; + } + private void UploadKillDateFile() { Uri address = parameters.TargetConfig.Remote.Address; string statusWorkDir = Path.Combine(workingDir, STATUS_FOLDER); EnsureDirectoryExistence(statusWorkDir); - DateTime date = DateTime.Now; - date = date.AddDays(parameters.TargetConfig.KillDateDays); + DateTime date = GetKillDate(); string fileName = String.Format(KILLDATE_FILE, OutputName, date.ToString("yyyyMMdd")); logger.Debug("Creating KILLDATE status file {0}", fileName); KillDatePath = Path.Combine(statusWorkDir, fileName); diff --git a/client/PlanAIRClient/TrafficIDSelector.cs b/client/PlanAIRClient/TrafficIDSelector.cs index 9f199936..9cdfb8cc 100644 --- a/client/PlanAIRClient/TrafficIDSelector.cs +++ b/client/PlanAIRClient/TrafficIDSelector.cs @@ -18,14 +18,7 @@ namespace TrafficClient { public TrafficIDSelector() { InitializeComponent(); InitializeTexts(); - //test(); panel1.Dock = DockStyle.Fill; - - } - - private void test() { - TableLayoutRowStyleCollection coll = tableLayoutPanelSearch.RowStyles; - coll[1].SizeType = SizeType.Percent; } private void InitializeTexts() {