git-tfs-id: [http://tfs.userrendszerhaz.hu:8080/tfs/DefaultCollection]$/MediaCube...
authorVásáry Dániel <daniel.vasary@userrendszerhaz.hu>
Tue, 3 Oct 2017 11:22:22 +0000 (11:22 +0000)
committerVásáry Dániel <daniel.vasary@userrendszerhaz.hu>
Tue, 3 Oct 2017 11:22:22 +0000 (11:22 +0000)
client/Maestro/ArchiveMetadata.Designer.cs
client/Maestro/MaestroForm.Target.cs
client/Maestro/Targets/FTPTargetProcessor.cs
client/Maestro/Targets/TargetProcessor.cs

index d8a9a7f3370ccbd84601d1bf19c1e2d9935a6ee4..01206e4392cb762303f9c2fc221757f13ed0e073 100644 (file)
@@ -47,7 +47,7 @@
             // label_stuffID\r
             // \r
             this.label_stuffID.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));\r
-            this.label_stuffID.Location = new System.Drawing.Point(3, 7);\r
+            this.label_stuffID.Location = new System.Drawing.Point(8, 12);\r
             this.label_stuffID.Name = "label_stuffID";\r
             this.label_stuffID.Size = new System.Drawing.Size(87, 13);\r
             this.label_stuffID.TabIndex = 0;\r
@@ -56,7 +56,7 @@
             // label_stuffDescription\r
             // \r
             this.label_stuffDescription.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));\r
-            this.label_stuffDescription.Location = new System.Drawing.Point(3, 87);\r
+            this.label_stuffDescription.Location = new System.Drawing.Point(8, 92);\r
             this.label_stuffDescription.Name = "label_stuffDescription";\r
             this.label_stuffDescription.Size = new System.Drawing.Size(66, 13);\r
             this.label_stuffDescription.TabIndex = 2;\r
@@ -65,7 +65,7 @@
             // label_mediaID\r
             // \r
             this.label_mediaID.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));\r
-            this.label_mediaID.Location = new System.Drawing.Point(3, 161);\r
+            this.label_mediaID.Location = new System.Drawing.Point(8, 166);\r
             this.label_mediaID.Name = "label_mediaID";\r
             this.label_mediaID.Size = new System.Drawing.Size(86, 13);\r
             this.label_mediaID.TabIndex = 3;\r
@@ -74,7 +74,7 @@
             // label_mediaTitle\r
             // \r
             this.label_mediaTitle.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));\r
-            this.label_mediaTitle.Location = new System.Drawing.Point(3, 201);\r
+            this.label_mediaTitle.Location = new System.Drawing.Point(8, 206);\r
             this.label_mediaTitle.Name = "label_mediaTitle";\r
             this.label_mediaTitle.Size = new System.Drawing.Size(57, 13);\r
             this.label_mediaTitle.TabIndex = 4;\r
@@ -84,7 +84,7 @@
             // \r
             this.label_mediaDescription.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));\r
             this.label_mediaDescription.AutoSize = true;\r
-            this.label_mediaDescription.Location = new System.Drawing.Point(3, 241);\r
+            this.label_mediaDescription.Location = new System.Drawing.Point(8, 246);\r
             this.label_mediaDescription.Name = "label_mediaDescription";\r
             this.label_mediaDescription.Size = new System.Drawing.Size(65, 13);\r
             this.label_mediaDescription.TabIndex = 5;\r
             // textBox_stuffID\r
             // \r
             this.textBox_stuffID.Dock = System.Windows.Forms.DockStyle.Fill;\r
-            this.textBox_stuffID.Location = new System.Drawing.Point(3, 23);\r
+            this.textBox_stuffID.Location = new System.Drawing.Point(8, 28);\r
             this.textBox_stuffID.Name = "textBox_stuffID";\r
-            this.textBox_stuffID.Size = new System.Drawing.Size(295, 20);\r
+            this.textBox_stuffID.Size = new System.Drawing.Size(549, 20);\r
             this.textBox_stuffID.TabIndex = 6;\r
             // \r
             // textBox_stuffTitle\r
             // \r
             this.textBox_stuffTitle.Dock = System.Windows.Forms.DockStyle.Fill;\r
-            this.textBox_stuffTitle.Location = new System.Drawing.Point(3, 63);\r
+            this.textBox_stuffTitle.Location = new System.Drawing.Point(8, 68);\r
             this.textBox_stuffTitle.Name = "textBox_stuffTitle";\r
-            this.textBox_stuffTitle.Size = new System.Drawing.Size(295, 20);\r
+            this.textBox_stuffTitle.Size = new System.Drawing.Size(549, 20);\r
             this.textBox_stuffTitle.TabIndex = 7;\r
             // \r
             // textBox_stuffDescription\r
             // \r
             this.textBox_stuffDescription.Dock = System.Windows.Forms.DockStyle.Fill;\r
-            this.textBox_stuffDescription.Location = new System.Drawing.Point(3, 103);\r
+            this.textBox_stuffDescription.Location = new System.Drawing.Point(8, 108);\r
             this.textBox_stuffDescription.Multiline = true;\r
             this.textBox_stuffDescription.Name = "textBox_stuffDescription";\r
             this.textBox_stuffDescription.ScrollBars = System.Windows.Forms.ScrollBars.Both;\r
-            this.textBox_stuffDescription.Size = new System.Drawing.Size(295, 48);\r
+            this.textBox_stuffDescription.Size = new System.Drawing.Size(549, 48);\r
             this.textBox_stuffDescription.TabIndex = 8;\r
             // \r
             // textBox_mediaID\r
             // \r
             this.textBox_mediaID.Dock = System.Windows.Forms.DockStyle.Fill;\r
-            this.textBox_mediaID.Location = new System.Drawing.Point(3, 177);\r
+            this.textBox_mediaID.Location = new System.Drawing.Point(8, 182);\r
             this.textBox_mediaID.Name = "textBox_mediaID";\r
-            this.textBox_mediaID.Size = new System.Drawing.Size(295, 20);\r
+            this.textBox_mediaID.Size = new System.Drawing.Size(549, 20);\r
             this.textBox_mediaID.TabIndex = 9;\r
             // \r
             // textBox_mediaTitle\r
             // \r
             this.textBox_mediaTitle.Dock = System.Windows.Forms.DockStyle.Fill;\r
-            this.textBox_mediaTitle.Location = new System.Drawing.Point(3, 217);\r
+            this.textBox_mediaTitle.Location = new System.Drawing.Point(8, 222);\r
             this.textBox_mediaTitle.Name = "textBox_mediaTitle";\r
-            this.textBox_mediaTitle.Size = new System.Drawing.Size(295, 20);\r
+            this.textBox_mediaTitle.Size = new System.Drawing.Size(549, 20);\r
             this.textBox_mediaTitle.TabIndex = 10;\r
             // \r
             // textBox_mediaDescription\r
             // \r
             this.textBox_mediaDescription.Dock = System.Windows.Forms.DockStyle.Fill;\r
-            this.textBox_mediaDescription.Location = new System.Drawing.Point(3, 257);\r
+            this.textBox_mediaDescription.Location = new System.Drawing.Point(8, 262);\r
             this.textBox_mediaDescription.Multiline = true;\r
             this.textBox_mediaDescription.Name = "textBox_mediaDescription";\r
             this.textBox_mediaDescription.ScrollBars = System.Windows.Forms.ScrollBars.Both;\r
-            this.textBox_mediaDescription.Size = new System.Drawing.Size(295, 153);\r
+            this.textBox_mediaDescription.Size = new System.Drawing.Size(549, 87);\r
             this.textBox_mediaDescription.TabIndex = 11;\r
             // \r
             // label_stuffTitle\r
             // \r
             this.label_stuffTitle.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));\r
-            this.label_stuffTitle.Location = new System.Drawing.Point(3, 47);\r
+            this.label_stuffTitle.Location = new System.Drawing.Point(8, 52);\r
             this.label_stuffTitle.Name = "label_stuffTitle";\r
             this.label_stuffTitle.Size = new System.Drawing.Size(58, 13);\r
             this.label_stuffTitle.TabIndex = 1;\r
             this.groupBox1.Controls.Add(this.button_Ok);\r
             this.groupBox1.Controls.Add(this.buttonCancel);\r
             this.groupBox1.Dock = System.Windows.Forms.DockStyle.Bottom;\r
-            this.groupBox1.Location = new System.Drawing.Point(0, 413);\r
+            this.groupBox1.Location = new System.Drawing.Point(0, 357);\r
             this.groupBox1.Name = "groupBox1";\r
-            this.groupBox1.Size = new System.Drawing.Size(301, 48);\r
+            this.groupBox1.Size = new System.Drawing.Size(565, 48);\r
             this.groupBox1.TabIndex = 1;\r
             this.groupBox1.TabStop = false;\r
             // \r
             // button_Ok\r
             // \r
             this.button_Ok.Anchor = System.Windows.Forms.AnchorStyles.Right;\r
-            this.button_Ok.Location = new System.Drawing.Point(224, 19);\r
+            this.button_Ok.Location = new System.Drawing.Point(488, 19);\r
             this.button_Ok.Name = "button_Ok";\r
             this.button_Ok.Size = new System.Drawing.Size(75, 23);\r
             this.button_Ok.TabIndex = 1;\r
             // buttonCancel\r
             // \r
             this.buttonCancel.Anchor = System.Windows.Forms.AnchorStyles.Right;\r
-            this.buttonCancel.Location = new System.Drawing.Point(145, 19);\r
+            this.buttonCancel.Location = new System.Drawing.Point(409, 19);\r
             this.buttonCancel.Name = "buttonCancel";\r
             this.buttonCancel.Size = new System.Drawing.Size(75, 23);\r
             this.buttonCancel.TabIndex = 0;\r
             this.tableLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill;\r
             this.tableLayoutPanel1.Location = new System.Drawing.Point(0, 0);\r
             this.tableLayoutPanel1.Name = "tableLayoutPanel1";\r
+            this.tableLayoutPanel1.Padding = new System.Windows.Forms.Padding(5);\r
             this.tableLayoutPanel1.RowCount = 12;\r
             this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));\r
             this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));\r
             this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));\r
             this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));\r
             this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 54F));\r
-            this.tableLayoutPanel1.Size = new System.Drawing.Size(301, 413);\r
+            this.tableLayoutPanel1.Size = new System.Drawing.Size(565, 357);\r
             this.tableLayoutPanel1.TabIndex = 3;\r
             // \r
             // ArchiveMetadata\r
             // \r
             this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);\r
             this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;\r
-            this.ClientSize = new System.Drawing.Size(301, 461);\r
+            this.ClientSize = new System.Drawing.Size(565, 405);\r
             this.Controls.Add(this.tableLayoutPanel1);\r
             this.Controls.Add(this.groupBox1);\r
             this.Icon = global::Maestro.Properties.Resources.AppIcon;\r
index 5af541b8e28a64f813d2eb3e89e0d97b0521b4f7..fb4c29646202f40be4764b990bd9f4af7d5d2752 100644 (file)
@@ -98,7 +98,7 @@ namespace Maestro {
 \r
         private void ApplyProcessorButtonsLogic() {\r
             ClearSelectedProcessors();\r
-            if (!String.IsNullOrEmpty(textSelectedMetadata.Text) && !String.IsNullOrEmpty(textSelectedMetadata.Text)) {\r
+            if (!String.IsNullOrEmpty(textSelectedSource.Text) && !String.IsNullOrEmpty(textSelectedMetadata.Text)) {\r
                 ChangeProcessButtonsState(true);\r
             } else {\r
                 ChangeProcessButtonsState(false);\r
index e3d59b0f5df10172d6a33693d020d561fca32e4c..636bfd1eb74eb851c2be697f9c15136ccf5b0bf4 100644 (file)
@@ -10,6 +10,7 @@ using TrafficClient;
 using Model;\r
 using JobEngineClient;\r
 using Maestro.Metadata;\r
+using System.Text;\r
 \r
 namespace Maestro.Targets {\r
 \r
@@ -22,7 +23,8 @@ namespace Maestro.Targets {
         private const string VERSIONED_FILENAME = "{0}-{1}{2}";\r
         private const string ALREADY_EXISTS = "File {0} already exists, trying {1}";\r
         private const string STATUS_FOLDER = ".STATUS";\r
-        private const string KILLDATE_FILE = "{0}.{1}.KILLDATE";\r
+        private const string KILLDATE_FILE = "{0}.{1}.killdate";\r
+        private const string METADATA_FILE = "{0}.json";\r
         protected FtpClient targetFTP;\r
         protected FileInfo inputFile;\r
         private string workingDir;\r
@@ -48,18 +50,14 @@ namespace Maestro.Targets {
             workFlowAction.started = Started;\r
             bool result = false;\r
             try {\r
-                SetSubFolder(targetConfig.Remote);\r
                 targetFTP = CreateClient(targetConfig.Remote);\r
+                workingDir = DetermineWorkingDirectory(targetConfig.Remote);\r
                 EnsureDirectoryExistence(targetFTP, workingDir);\r
                 Status = ProcessStatus.Progress;\r
                 Output = CreateOutputFileName();\r
-                workFlowAction.destination = Path.Combine(workingDir, Output).Replace("\\", "/");\r
                 workFlowAction.source = Input;\r
+                workFlowAction.destination = Path.Combine(workingDir, Output).Replace("\\", "/");\r
                 UploadFile(Output);\r
-                if (targetConfig.KillDateDays > 0)\r
-                    UploadKillDateFile(targetConfig.Remote, Output);\r
-                if (targetConfig.UseMetadata)\r
-                    UseMetadata();\r
                 ExecuteCompleted();\r
                 Status = ProcessStatus.Completed;\r
                 Message = SUCCESS;\r
@@ -81,18 +79,12 @@ namespace Maestro.Targets {
             return result;\r
         }\r
 \r
-        private void UseMetadata() {\r
-            if (model != null) {\r
-                string path = String.Format("{0}//.store", workingDir);\r
-                string fileName = "metadata.json";\r
-                EnsureDirectoryExistence(targetFTP, path);\r
-                string finalFileName = GetVersionedFileName(fileName);\r
-                using (Stream ostream = targetFTP.OpenWrite(finalFileName)) {\r
-                    string s = model.ToString();\r
-                    byte[] content = System.Text.Encoding.UTF8.GetBytes(s);\r
-                    ostream.Write(content, 0, content.Length);\r
-                }\r
-            }\r
+        protected override void ExecuteCompleted() {\r
+            base.ExecuteCompleted();\r
+            if (targetConfig.KillDateDays > 0)\r
+                UploadKillDateFile(targetConfig.Remote, Output);\r
+            if (targetConfig.UseMetadata && metadataModel != null)\r
+                CreateMetadata(targetConfig.Remote, Output);\r
         }\r
 \r
         private string GetVersionedFileName(string fileName) {\r
@@ -118,18 +110,20 @@ namespace Maestro.Targets {
             }\r
         }\r
 \r
-        private void SetSubFolder(Connection connection) {\r
+        private String DetermineWorkingDirectory(Connection connection) {\r
+            string result = null;\r
             Uri address = connection.Address;\r
             if (targetConfig.CreateSubFolder)\r
-                workingDir = Path.Combine(address.PathAndQuery, ID).Replace("\\", "/");\r
+                result = Path.Combine(address.PathAndQuery, ID).Replace("\\", "/");\r
             else\r
-                workingDir = address.PathAndQuery;\r
+                result = address.PathAndQuery;\r
+            return result;\r
         }\r
 \r
         private void UploadKillDateFile(Connection connection, string output) {\r
             Uri address = connection.Address;\r
             string statusWorkDir = Path.Combine(address.PathAndQuery, STATUS_FOLDER).Replace("\\", "/");\r
-            EnsureDirectoryExistence(targetFTP, workingDir);\r
+            EnsureDirectoryExistence(targetFTP, statusWorkDir);\r
             DateTime date = DateTime.Now;\r
             date = date.AddDays(targetConfig.KillDateDays);\r
             string fileName = String.Format(KILLDATE_FILE, output, date.ToString("yyyyMMdd"));\r
@@ -142,6 +136,18 @@ namespace Maestro.Targets {
             }\r
         }\r
 \r
+        private void CreateMetadata(Connection connection, string output) {\r
+            Uri address = connection.Address;\r
+            string statusWorkDir = Path.Combine(address.PathAndQuery, STATUS_FOLDER).Replace("\\", "/");\r
+            EnsureDirectoryExistence(targetFTP, statusWorkDir);\r
+            string fileName = String.Format(METADATA_FILE, output);\r
+            logger.Debug("Creating METADATA file {0}", fileName);\r
+            byte[] content = Encoding.UTF8.GetBytes(metadataModel.ToString());\r
+            using (Stream ostream = targetFTP.OpenWrite(fileName)) {\r
+                ostream.Write(content, 0, content.Length);\r
+            }\r
+        }\r
+\r
         private void CopyStream(Stream istream, long ilength, Stream ostream) {\r
             byte[] buffer = new byte[32768];\r
             int read, overall = 0;\r
index 18b935d0e827ceaff90c7d7d7d431697eee5b61c..febbaa4f8c5aa645541d229230a7f52d851d0a5f 100644 (file)
@@ -23,11 +23,11 @@ namespace Maestro.Targets {
         protected Target targetConfig;\r
         protected TrafficAPI client;\r
         protected List<Segment> segments;\r
-        protected ArchiveMetadataModel model;\r
+        protected ArchiveMetadataModel metadataModel;\r
 \r
         public TargetProcessor(Control parent, Target targetConfig, List<Segment> segments, ArchiveMetadataModel model) {\r
             this.parent = parent;\r
-            this.model = model;\r
+            this.metadataModel = model;\r
             MaestroForm maestroForm = parent as MaestroForm;\r
             TrafficMetadata metadata = maestroForm.Configuration.Metadatas.Where(m => { return m is TrafficMetadata; }).FirstOrDefault() as TrafficMetadata;\r
             client = new TrafficAPI(metadata.Server.Address.OriginalString, metadata.Server.UserName, metadata.Server.Password, metadata.Server.Timeout);\r
@@ -44,7 +44,7 @@ namespace Maestro.Targets {
 \r
         public abstract bool Execute();\r
 \r
-        protected void ExecuteCompleted() {\r
+        protected virtual void ExecuteCompleted() {\r
             if (targetConfig.SaveSegments)\r
                 SaveSegments();\r
         }\r