git-tfs-id: [http://tfs.userrendszerhaz.hu:8080/tfs/DefaultCollection]$/MediaCube...
authorVásáry Dániel <daniel.vasary@userrendszerhaz.hu>
Mon, 16 Oct 2017 16:05:40 +0000 (16:05 +0000)
committerVásáry Dániel <daniel.vasary@userrendszerhaz.hu>
Mon, 16 Oct 2017 16:05:40 +0000 (16:05 +0000)
13 files changed:
client/IntegrationTests/MaestroIT.cs
client/Maestro/Commons/NexioXML.cs [new file with mode: 0644]
client/Maestro/Configuration/ConfigurationInfo.cs
client/Maestro/Configuration/configuration-editor.json
client/Maestro/Configuration/configuration-nle.json
client/Maestro/Maestro.csproj
client/Maestro/MaestroForm.Designer.cs
client/Maestro/MaestroForm.Source.cs
client/Maestro/MaestroForm.Target.cs
client/Maestro/Sources/NexioRESTSource.cs
client/Maestro/Targets/FTPTargetProcessor.cs
client/Maestro/Targets/UNCTargetProcessor.cs
client/PlanAIRClient/TrafficIDSelector.cs

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