git-tfs-id: [http://tfs.userrendszerhaz.hu:8080/tfs/DefaultCollection]$/MediaCube...
authorVásáry Dániel <daniel.vasary@userrendszerhaz.hu>
Wed, 4 Oct 2017 21:34:10 +0000 (21:34 +0000)
committerVásáry Dániel <daniel.vasary@userrendszerhaz.hu>
Wed, 4 Oct 2017 21:34:10 +0000 (21:34 +0000)
20 files changed:
client/Maestro/ArchiveMetadata.cs
client/Maestro/Commons/Win32File.cs [new file with mode: 0644]
client/Maestro/Configuration/ConfigurationInfo.cs
client/Maestro/Maestro.csproj
client/Maestro/MaestroForm.Designer.cs
client/Maestro/MaestroForm.Metadata.cs
client/Maestro/MaestroForm.Target.cs
client/Maestro/MaestroForm.cs
client/Maestro/MaestroForm.resx
client/Maestro/Metadata/ArchiveMetadata.cs
client/Maestro/Resources/configuration-nexio.json
client/Maestro/Resources/configuration-unc.json
client/Maestro/StringResources.Designer.cs
client/Maestro/StringResources.resx
client/Maestro/Targets/FTPTargetProcessor.cs
client/Maestro/Targets/FXPTargetProcessor.cs
client/Maestro/Targets/ITargetProcessor.cs
client/Maestro/Targets/ProcessStatus.cs [deleted file]
client/Maestro/Targets/TargetProcessor.cs
client/Maestro/Targets/UNCTargetProcessor.cs [new file with mode: 0644]

index 694209b90a966483de9af4e2a2a575839113e84f..c21aab2beedb9fcd45eb041228d43665458b8889 100644 (file)
@@ -16,21 +16,21 @@ namespace Maestro {
         }\r
 \r
         private void FillTheTextBoxes() {\r
-            textBox_stuffID.Text = model.StuffID;\r
-            textBox_stuffTitle.Text = model.StuffTitle;\r
-            textBox_stuffDescription.Text = model.StuffDescription;\r
-            textBox_mediaID.Text = model.MediaID;\r
-            textBox_mediaTitle.Text = model.MediaTitle;\r
-            textBox_mediaDescription.Text = model.MediaDescription;\r
+            textBox_stuffID.Text = model.itemHouseId;\r
+            textBox_stuffTitle.Text = model.itemTitle;\r
+            textBox_stuffDescription.Text = model.itemDescription;\r
+            textBox_mediaID.Text = model.mediaHouseId;\r
+            textBox_mediaTitle.Text = model.mediaTitle;\r
+            textBox_mediaDescription.Text = model.mediaDescription;\r
         }\r
 \r
         private void button_Ok_Click_1(object sender, System.EventArgs e) {\r
-            model.StuffID = textBox_stuffID.Text;\r
-            model.StuffTitle = textBox_stuffTitle.Text;\r
-            model.StuffDescription = textBox_stuffDescription.Text;\r
-            model.MediaID = textBox_mediaID.Text;\r
-            model.MediaTitle = textBox_mediaTitle.Text;\r
-            model.MediaDescription = textBox_mediaDescription.Text;\r
+            model.itemHouseId = textBox_stuffID.Text;\r
+            model.itemTitle = textBox_stuffTitle.Text;\r
+            model.itemDescription = textBox_stuffDescription.Text;\r
+            model.mediaHouseId = textBox_mediaID.Text;\r
+            model.mediaTitle = textBox_mediaTitle.Text;\r
+            model.mediaDescription = textBox_mediaDescription.Text;\r
             Dispose();\r
         }\r
 \r
diff --git a/client/Maestro/Commons/Win32File.cs b/client/Maestro/Commons/Win32File.cs
new file mode 100644 (file)
index 0000000..dd846a5
--- /dev/null
@@ -0,0 +1,55 @@
+using System;\r
+using System.Runtime.InteropServices;\r
+\r
+namespace Maestro.Commons {\r
+    public enum CopyProgressResult : uint {\r
+        PROGRESS_CONTINUE = 0,\r
+        PROGRESS_CANCEL = 1,\r
+        PROGRESS_STOP = 2,\r
+        PROGRESS_QUIET = 3\r
+    }\r
+\r
+    public enum CopyProgressCallbackReason : uint {\r
+        CALLBACK_CHUNK_FINISHED = 0x00000000,\r
+        CALLBACK_STREAM_SWITCH = 0x00000001\r
+    }\r
+\r
+    [Flags]\r
+    public enum CopyFileFlags : uint {\r
+        COPY_FILE_FAIL_IF_EXISTS = 0x00000001,\r
+        COPY_FILE_RESTARTABLE = 0x00000002,\r
+        COPY_FILE_OPEN_SOURCE_FOR_WRITE = 0x00000004,\r
+        COPY_FILE_ALLOW_DECRYPTED_DESTINATION = 0x00000008\r
+    }\r
+\r
+        public delegate CopyProgressResult CopyProgressRoutine(\r
+        long TotalFileSize,\r
+        long TotalBytesTransferred,\r
+        long StreamSize,\r
+        long StreamBytesTransferred,\r
+        uint dwStreamNumber,\r
+        CopyProgressCallbackReason dwCallbackReason,\r
+        IntPtr hSourceFile,\r
+        IntPtr hDestinationFile,\r
+        IntPtr lpData);\r
+\r
+    public class Win32File {\r
+\r
+        [DllImport("kernel32.dll", SetLastError = true, CharSet = CharSet.Auto)]\r
+        [return: MarshalAs(UnmanagedType.Bool)]\r
+        static public extern bool CopyFileEx(string lpExistingFileName, string lpNewFileName,\r
+               CopyProgressRoutine lpProgressRoutine, IntPtr lpData, ref Int32 pbCancel,\r
+               CopyFileFlags dwCopyFlags);\r
+\r
+\r
+        int pbCancel;\r
+\r
+        private void XCopy(string oldFile, string newFile) {\r
+            CopyFileEx(oldFile, newFile, new CopyProgressRoutine(this.CopyProgressHandler), IntPtr.Zero, ref pbCancel, CopyFileFlags.COPY_FILE_RESTARTABLE);\r
+        }\r
+\r
+        private CopyProgressResult CopyProgressHandler(long total, long transferred, long streamSize, long StreamByteTrans, uint dwStreamNumber, CopyProgressCallbackReason reason, IntPtr hSourceFile, IntPtr hDestinationFile, IntPtr lpData) {\r
+            return CopyProgressResult.PROGRESS_CONTINUE;\r
+        }\r
+    }\r
+}\r
index 79e2103e2d10b8e5d5fa363028b9ca1c5696c88e..0b484174e6a2ef6e8a3bf41891d02772001f7097 100644 (file)
@@ -25,9 +25,9 @@ namespace Maestro.Configuration {
         public bool StartInTray { get; set; }\r
         public bool Active { get; set; }\r
         public string Title { get; set; }\r
-        public bool IsAdmin { get; set; }\r
         public Player Player { get; set; }\r
         public Source Source { get; set; }\r
+        public bool EnableCustomMetadataId { get; set; }\r
         public MetadataProvider[] Metadatas { get; set; }\r
         public Target[] Targets { get; set; }\r
     }\r
index 300d80afd351267f0df3d7e854bcc532b174a267..e536122bfc71c8baec1e25630441be944430563f 100644 (file)
     </Compile>\r
     <Compile Include="Commons\DataGridViewProgressColumn.cs" />\r
     <Compile Include="Commons\ObjectExtensions.cs" />\r
+    <Compile Include="Commons\Win32File.cs" />\r
     <Compile Include="Configuration\ConfigurationInfo.cs" />\r
     <Compile Include="Configuration\KeysJsonConverter.cs" />\r
     <Compile Include="Configuration\KnownTypesBinder.cs" />\r
     <Compile Include="Program.cs" />\r
     <Compile Include="Properties\AssemblyInfo.cs" />\r
     <Compile Include="Sources\Messages\FileActionMsg.cs" />\r
+    <Compile Include="Targets\UNCTargetProcessor.cs" />\r
     <Compile Include="Targets\FXPTargetProcessor.cs" />\r
     <Compile Include="Targets\FTPTargetProcessor.cs" />\r
     <Compile Include="Targets\SegmentConverter.cs" />\r
     <Compile Include="Targets\TargetProcessor.cs" />\r
     <Compile Include="Targets\ITargetProcessor.cs" />\r
-    <Compile Include="Targets\ProcessStatus.cs" />\r
     <EmbeddedResource Include="ArchiveMetadata.resx">\r
       <DependentUpon>ArchiveMetadata.cs</DependentUpon>\r
     </EmbeddedResource>\r
index c3e885882d1a3497fd09c7e418103b686ae92310..cba2bd62404f9b25aaf0a82252130dc68196668a 100644 (file)
@@ -66,15 +66,15 @@ namespace Maestro {
             this.splitContainer2 = new System.Windows.Forms.SplitContainer();\r
             this.groupActions = new System.Windows.Forms.GroupBox();\r
             this.dataGridJobs = new System.Windows.Forms.DataGridView();\r
+            this.bindingSourceJobs = new System.Windows.Forms.BindingSource(this.components);\r
+            this.metadataInfoBindingSource = new System.Windows.Forms.BindingSource(this.components);\r
             this.columnID = new System.Windows.Forms.DataGridViewTextBoxColumn();\r
+            this.columnStatus = new System.Windows.Forms.DataGridViewTextBoxColumn();\r
+            this.columnProgress = new Maestro.Commons.DataGridViewProgressColumn();\r
             this.columnStarted = new System.Windows.Forms.DataGridViewTextBoxColumn();\r
             this.columnFinished = new System.Windows.Forms.DataGridViewTextBoxColumn();\r
             this.columnInput = new System.Windows.Forms.DataGridViewTextBoxColumn();\r
             this.columnOutput = new System.Windows.Forms.DataGridViewTextBoxColumn();\r
-            this.columnProgress = new Maestro.Commons.DataGridViewProgressColumn();\r
-            this.columnStatus = new System.Windows.Forms.DataGridViewTextBoxColumn();\r
-            this.bindingSourceJobs = new System.Windows.Forms.BindingSource(this.components);\r
-            this.metadataInfoBindingSource = new System.Windows.Forms.BindingSource(this.components);\r
             this.groupSource.SuspendLayout();\r
             ((System.ComponentModel.ISupportInitialize)(this.dataGridSource)).BeginInit();\r
             ((System.ComponentModel.ISupportInitialize)(this.bindingSource)).BeginInit();\r
@@ -545,12 +545,12 @@ namespace Maestro {
             this.dataGridJobs.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;\r
             this.dataGridJobs.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {\r
             this.columnID,\r
+            this.columnStatus,\r
+            this.columnProgress,\r
             this.columnStarted,\r
             this.columnFinished,\r
             this.columnInput,\r
-            this.columnOutput,\r
-            this.columnProgress,\r
-            this.columnStatus});\r
+            this.columnOutput});\r
             this.dataGridJobs.DataSource = this.bindingSourceJobs;\r
             dataGridViewCellStyle8.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft;\r
             dataGridViewCellStyle8.BackColor = System.Drawing.SystemColors.Window;\r
@@ -581,6 +581,10 @@ namespace Maestro {
             this.dataGridJobs.TabIndex = 0;\r
             this.dataGridJobs.CellEnter += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridJobs_CellEnter);\r
             // \r
+            // metadataInfoBindingSource\r
+            // \r
+            this.metadataInfoBindingSource.DataSource = typeof(Maestro.Metadata.MetadataInfo);\r
+            // \r
             // columnID\r
             // \r
             this.columnID.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.DisplayedCells;\r
@@ -592,6 +596,31 @@ namespace Maestro {
             this.columnID.Name = "columnID";\r
             this.columnID.Width = 44;\r
             // \r
+            // columnStatus\r
+            // \r
+            this.columnStatus.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.DisplayedCells;\r
+            this.columnStatus.DataPropertyName = "Status";\r
+            dataGridViewCellStyle6.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238)));\r
+            this.columnStatus.DefaultCellStyle = dataGridViewCellStyle6;\r
+            this.columnStatus.Frozen = true;\r
+            this.columnStatus.HeaderText = "Status";\r
+            this.columnStatus.Name = "columnStatus";\r
+            this.columnStatus.Width = 66;\r
+            // \r
+            // columnProgress\r
+            // \r
+            this.columnProgress.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.None;\r
+            this.columnProgress.DataPropertyName = "Progress";\r
+            dataGridViewCellStyle7.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter;\r
+            dataGridViewCellStyle7.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238)));\r
+            dataGridViewCellStyle7.NullValue = null;\r
+            this.columnProgress.DefaultCellStyle = dataGridViewCellStyle7;\r
+            this.columnProgress.HeaderText = "Progress";\r
+            this.columnProgress.Name = "columnProgress";\r
+            this.columnProgress.Resizable = System.Windows.Forms.DataGridViewTriState.True;\r
+            this.columnProgress.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic;\r
+            this.columnProgress.Width = 200;\r
+            // \r
             // columnStarted\r
             // \r
             this.columnStarted.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.DisplayedCells;\r
@@ -624,34 +653,6 @@ namespace Maestro {
             this.columnOutput.Name = "columnOutput";\r
             this.columnOutput.Width = 68;\r
             // \r
-            // columnProgress\r
-            // \r
-            this.columnProgress.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.None;\r
-            this.columnProgress.DataPropertyName = "Progress";\r
-            dataGridViewCellStyle6.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter;\r
-            dataGridViewCellStyle6.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238)));\r
-            dataGridViewCellStyle6.NullValue = null;\r
-            this.columnProgress.DefaultCellStyle = dataGridViewCellStyle6;\r
-            this.columnProgress.HeaderText = "Progress";\r
-            this.columnProgress.Name = "columnProgress";\r
-            this.columnProgress.Resizable = System.Windows.Forms.DataGridViewTriState.True;\r
-            this.columnProgress.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic;\r
-            this.columnProgress.Width = 200;\r
-            // \r
-            // columnStatus\r
-            // \r
-            this.columnStatus.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.DisplayedCells;\r
-            this.columnStatus.DataPropertyName = "Status";\r
-            dataGridViewCellStyle7.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238)));\r
-            this.columnStatus.DefaultCellStyle = dataGridViewCellStyle7;\r
-            this.columnStatus.HeaderText = "Status";\r
-            this.columnStatus.Name = "columnStatus";\r
-            this.columnStatus.Width = 66;\r
-            // \r
-            // metadataInfoBindingSource\r
-            // \r
-            this.metadataInfoBindingSource.DataSource = typeof(Maestro.Metadata.MetadataInfo);\r
-            // \r
             // MaestroForm\r
             // \r
             this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);\r
@@ -734,15 +735,15 @@ namespace Maestro {
         private System.Windows.Forms.Label label1;\r
         private System.Windows.Forms.TableLayoutPanel tableLayoutPanel1;\r
         private TrafficClient.TrafficIDSelector trafficIDSelector;\r
+        private System.Windows.Forms.Button buttonMetadata;\r
+        private System.Windows.Forms.TextBox txtSorceFilter;\r
         private System.Windows.Forms.DataGridViewTextBoxColumn columnID;\r
+        private System.Windows.Forms.DataGridViewTextBoxColumn columnStatus;\r
+        private Commons.DataGridViewProgressColumn columnProgress;\r
         private System.Windows.Forms.DataGridViewTextBoxColumn columnStarted;\r
         private System.Windows.Forms.DataGridViewTextBoxColumn columnFinished;\r
         private System.Windows.Forms.DataGridViewTextBoxColumn columnInput;\r
         private System.Windows.Forms.DataGridViewTextBoxColumn columnOutput;\r
-        private Commons.DataGridViewProgressColumn columnProgress;\r
-        private System.Windows.Forms.DataGridViewTextBoxColumn columnStatus;\r
-        private System.Windows.Forms.Button buttonMetadata;\r
-        private System.Windows.Forms.TextBox txtSorceFilter;\r
     }\r
 }\r
 \r
index b42fc3e30ee824f10ddc774e783770e757a09b43..88cba312e348b195ab5b53ee55234f634204bf5c 100644 (file)
@@ -31,6 +31,7 @@ namespace Maestro {
             InitializeOctopusSelector();\r
             InitializeTrafficSelector();\r
             InitializeMediaCubeApi();\r
+            textSelectedMetadata.ReadOnly = !Configuration.EnableCustomMetadataId;\r
         }\r
 \r
         private void InitializeTrafficSelector() {\r
index cfb0243ea69be5c96f017c0f5153b9f4ad87fe90..17a16d91bcb507f22fd6c1a72540efd47f760d79 100644 (file)
@@ -23,8 +23,6 @@ namespace Maestro {
                 CreateTarget(target);\r
             }\r
 \r
-            textSelectedSource.ReadOnly = !Configuration.IsAdmin;\r
-            textSelectedMetadata.ReadOnly = !Configuration.IsAdmin;\r
             ApplyProcessorButtonsLogic();\r
             segmentConverter = new SegmentConverter();\r
         }\r
@@ -45,7 +43,7 @@ namespace Maestro {
                         string typeName = string.Format("{0}.{1}", typeof(ITargetProcessor).Namespace, target.Processor);\r
                         Type type = Type.GetType(typeName);\r
                         ISourceItem selectedFile = GetSourceItemFromBindingSource(fileName);//bindingSource.Current as ISourceItem;\r
-                        string id = selectedMetadata.ID;\r
+                        string id = selectedMetadata == null ? textSelectedMetadata.Text : selectedMetadata.ID;\r
                         object[] parameters = new object[] { this, Configuration.Source, target, selectedFile.Name, id, segments, mediaCubeApi, model };\r
                         ITargetProcessor processor = (ITargetProcessor)Activator.CreateInstance(type, parameters);\r
                         processors.Add(processor);\r
@@ -141,12 +139,12 @@ namespace Maestro {
             TrafficAPI api = trafficIDSelector.trafficAPI;\r
             List<ArchiveMatadataWrapper> result = api.SearchArchiveMetadata(id); ;\r
             ArchiveMatadataWrapper actualResult = result[0];\r
-            model.StuffID = actualResult.ProgID;\r
-            model.StuffTitle = actualResult.ProgTitle;\r
-            model.StuffDescription = actualResult.ProgDescription;\r
-            model.MediaID = actualResult.EpisodeID;\r
-            model.MediaTitle = !String.IsNullOrEmpty(actualResult.EpisodeTitle) ? actualResult.EpisodeTitle : actualResult.ProgTitle;\r
-            model.MediaDescription = actualResult.EpisodeDescription;\r
+            model.itemHouseId = actualResult.ProgID;\r
+            model.itemTitle = actualResult.ProgTitle;\r
+            model.itemDescription = actualResult.ProgDescription;\r
+            model.mediaHouseId = actualResult.EpisodeID;\r
+            model.mediaTitle = !String.IsNullOrEmpty(actualResult.EpisodeTitle) ? actualResult.EpisodeTitle : actualResult.ProgTitle;\r
+            model.mediaDescription = actualResult.EpisodeDescription;\r
         }\r
 \r
         private void FillTheModelFromOctopus(ArchiveMetadataModel model) {\r
@@ -172,21 +170,21 @@ namespace Maestro {
                     return;\r
                 List<StoryFolder> storyFolders = storyFoldersEnum.ToList();\r
                 StoryFolder folder = storyFolders[0];\r
-                model.StuffID = folder.ID;\r
-                model.StuffTitle = folder.Name;\r
+                model.itemHouseId = folder.ID;\r
+                model.itemTitle = folder.Name;\r
             } else if (story.Rundowns != null) {\r
                 IEnumerable<Rundown> rundownsEnum = api.GetRundownsByStoryID(story.ID);\r
                 if (rundownsEnum == null)\r
                     return;\r
                 List<Rundown> rundowns = rundownsEnum.ToList();\r
                 Rundown rundown = rundowns[0];\r
-                model.StuffID = rundown.ID;\r
-                model.StuffTitle = rundown.Name;\r
-                model.StuffDescription = rundown.Start;\r
+                model.itemHouseId = rundown.ID;\r
+                model.itemTitle = rundown.Name;\r
+                model.itemDescription = rundown.Start;\r
             }\r
-            model.MediaID = story.ID;\r
-            model.MediaTitle = story.Name;\r
-            model.MediaDescription = story.Script;\r
+            model.mediaHouseId = story.ID;\r
+            model.mediaTitle = story.Name;\r
+            model.mediaDescription = story.Script;\r
         }\r
 \r
         private void IsSelectedFileAnID() {\r
index 8ccfa29f105989e637428636db1f537d24c4fd5d..a3c13d1c760effb828d0b72dc0fa972ca5f9110c 100644 (file)
@@ -58,8 +58,8 @@ namespace Maestro {
             groupActions.Text = StringResources.AKCIOK;\r
             columnStarted.HeaderText = StringResources.KEZDES;\r
             columnFinished.HeaderText = StringResources.BEFEJEZES;\r
-            columnInput.HeaderText = StringResources.BEMENET;\r
-            columnOutput.HeaderText = StringResources.KIMENET;\r
+            columnInput.HeaderText = StringResources.FORRAS;\r
+            columnOutput.HeaderText = StringResources.CEL;\r
             columnProgress.HeaderText = StringResources.ALLAPOT;\r
             columnStatus.HeaderText = StringResources.STATUSZ;\r
             ctxiDefineSegments.Text = StringResources.SZEGMENS_LETREHOZASA;\r
index 93ab1e2ff970dbd754b397b942fd67fc0069a98a..6323a0bb14c360013f02d55850f8f5d460da23ab 100644 (file)
   <metadata name="columnID.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">\r
     <value>True</value>\r
   </metadata>\r
-  <metadata name="columnStarted.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">\r
+  <metadata name="columnStatus.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">\r
     <value>True</value>\r
   </metadata>\r
-  <metadata name="columnFinished.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">\r
+  <metadata name="columnProgress.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">\r
     <value>True</value>\r
   </metadata>\r
-  <metadata name="columnInput.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">\r
+  <metadata name="columnStarted.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">\r
     <value>True</value>\r
   </metadata>\r
-  <metadata name="columnOutput.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">\r
+  <metadata name="columnFinished.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">\r
     <value>True</value>\r
   </metadata>\r
-  <metadata name="columnProgress.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">\r
+  <metadata name="columnInput.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">\r
     <value>True</value>\r
   </metadata>\r
-  <metadata name="columnStatus.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">\r
+  <metadata name="columnOutput.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">\r
     <value>True</value>\r
   </metadata>\r
   <metadata name="bindingSourceJobs.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">\r
index ee33487b8d0c4aab256df08bdf1afcbddb2b65db..dd8dbaeb7eec33d3ab4eb13d03d3304eeff94a7a 100644 (file)
@@ -4,12 +4,12 @@ namespace Maestro.Metadata {
     public class ArchiveMetadataModel {\r
 \r
         //todo rename a Stuffra??\r
-        public string StuffID { get; set; }\r
-        public string StuffTitle { get; set; }\r
-        public string StuffDescription { get; set; }\r
-        public string MediaID { get; set; }\r
-        public string MediaTitle { get; set; }\r
-        public string MediaDescription { get; set; }\r
+        public string itemHouseId { get; set; }\r
+        public string itemTitle { get; set; }\r
+        public string itemDescription { get; set; }\r
+        public string mediaHouseId { get; set; }\r
+        public string mediaTitle { get; set; }\r
+        public string mediaDescription { get; set; }\r
 \r
         public override string ToString() {\r
             return JsonConvert.SerializeObject(this);\r
index fc4a75a759955da65432e50312487926641187b6..e31b2a031b3edc86effaf0697b94b4fa1e14c162 100644 (file)
@@ -51,7 +51,7 @@
     {\r
       "label": "Archive",\r
       "processor": "FTPTargetProcessor",\r
-      "outputFormat": "{0}-{1}-{2}",\r
+      "outputFormat": "%ID%-%SOURCENAME%",\r
       "killDateDays": 1,\r
       "remote": {\r
         "address": "ftp://localhost:21/out",\r
@@ -62,7 +62,7 @@
     {\r
       "label": "Ready",\r
       "processor": "FXPTargetProcessor",\r
-      "outputFormat": "{0}-{1}-{2}",\r
+      "outputFormat": "%ID%-%SOURCENAME%",\r
       "remote": {\r
         "address": "ftp://localhost:22/out",\r
         "userName": "dani",\r
index 48fa46938ff71b48c3f224a594e29ffa6b5de822..4bf60fc13614e37768f583c3646c1c6ab2f33824 100644 (file)
@@ -3,6 +3,7 @@
   "active": true,\r
   "startInTray": false,\r
   "enableNameOverride": false,\r
+  "enableCustomMetadataId": true,\r
   "player": {\r
     "enabled": true,\r
     "autoStart": false,\r
   "targets": [\r
     {\r
       "label": "Archiválandó",\r
-      "processor": "FTPTargetProcessor",\r
-      "outputFormat": "{0}-{1}",\r
+      "processor": "UNCTargetProcessor",\r
+      "outputFormat": "%ID%-%SOURCENAME%",\r
       "tag": "Archiválásra kijelöl",\r
       "useMetadata": true,\r
       "remote": {\r
-        "address": "ftp://10.10.1.100:21/ARCHIVE",\r
+        "address": "file://10.10.1.100/BRAAVOS/ARCHIVE",\r
         "userName": "mediacube",\r
         "password": "Broadca5T"\r
       }\r
     {\r
       "label": "Adáskész",\r
       "processor": "FTPTargetProcessor",\r
-      "outputFormat": "{0}-{1}",\r
-           "saveSegments": true,\r
-           "killDateDays": 1,\r
-           "tag": "Adáskész",\r
-           "createSubFolder": true,\r
-           "useMetadata": true,\r
+      "outputFormat": "%ID%-%SOURCENAME%",\r
+      "saveSegments": true,\r
+      "killDateDays": 1,\r
+      "tag": "Adáskész",\r
+      "createSubFolder": true,\r
+      "useMetadata": true,\r
       "remote": {\r
         "address": "ftp://10.10.1.100:21/READY",\r
-        "userName": "dani",\r
-        "password": "dani"\r
+        "userName": "mediacube",\r
+        "password": "Broadca5T"\r
       }\r
     }\r
   ]\r
index b889828ee7e9eb4ceae71df1dfdec46de70f77a7..6855d6b360a876f184553eaf35751fa1b1ddf16d 100644 (file)
@@ -106,11 +106,11 @@ namespace Maestro {
         }\r
         \r
         /// <summary>\r
-        ///   Looks up a localized string similar to Bemenet.\r
+        ///   Looks up a localized string similar to Cél.\r
         /// </summary>\r
-        internal static string BEMENET {\r
+        internal static string CEL {\r
             get {\r
-                return ResourceManager.GetString("BEMENET", resourceCulture);\r
+                return ResourceManager.GetString("CEL", resourceCulture);\r
             }\r
         }\r
         \r
@@ -133,29 +133,29 @@ namespace Maestro {
         }\r
         \r
         /// <summary>\r
-        ///   Looks up a localized string similar to Forrás fájl.\r
+        ///   Looks up a localized string similar to Forrás.\r
         /// </summary>\r
-        internal static string FORRAS_FAJL {\r
+        internal static string FORRAS {\r
             get {\r
-                return ResourceManager.GetString("FORRAS_FAJL", resourceCulture);\r
+                return ResourceManager.GetString("FORRAS", resourceCulture);\r
             }\r
         }\r
         \r
         /// <summary>\r
-        ///   Looks up a localized string similar to Kezdés.\r
+        ///   Looks up a localized string similar to Forrás fájl.\r
         /// </summary>\r
-        internal static string KEZDES {\r
+        internal static string FORRAS_FAJL {\r
             get {\r
-                return ResourceManager.GetString("KEZDES", resourceCulture);\r
+                return ResourceManager.GetString("FORRAS_FAJL", resourceCulture);\r
             }\r
         }\r
         \r
         /// <summary>\r
-        ///   Looks up a localized string similar to Kimenet.\r
+        ///   Looks up a localized string similar to Kezdés.\r
         /// </summary>\r
-        internal static string KIMENET {\r
+        internal static string KEZDES {\r
             get {\r
-                return ResourceManager.GetString("KIMENET", resourceCulture);\r
+                return ResourceManager.GetString("KEZDES", resourceCulture);\r
             }\r
         }\r
         \r
index 4aa791b6062100d2390da353982ae987e0bbec75..cbbbbab7953aa93046b9a1dd8e33062a7275d517 100644 (file)
   <data name="BEFEJEZES" xml:space="preserve">\r
     <value>Befejezés</value>\r
   </data>\r
-  <data name="BEMENET" xml:space="preserve">\r
-    <value>Bemenet</value>\r
+  <data name="CEL" xml:space="preserve">\r
+    <value>Cél</value>\r
   </data>\r
   <data name="CEL_AKCIO" xml:space="preserve">\r
     <value>Cél akció</value>\r
   <data name="FELVETEL_DATUMA" xml:space="preserve">\r
     <value>Felvétel dátuma</value>\r
   </data>\r
+  <data name="FORRAS" xml:space="preserve">\r
+    <value>Forrás</value>\r
+  </data>\r
   <data name="FORRAS_FAJL" xml:space="preserve">\r
     <value>Forrás fájl</value>\r
   </data>\r
   <data name="KEZDES" xml:space="preserve">\r
     <value>Kezdés</value>\r
   </data>\r
-  <data name="KIMENET" xml:space="preserve">\r
-    <value>Kimenet</value>\r
-  </data>\r
   <data name="KIVALASZTOTT_FORRAS" xml:space="preserve">\r
     <value>Kiválasztott forrás</value>\r
   </data>\r
index 4c39ade19997b16fa8b3241c4958c9f71cb6eb73..5265c543de12a63efdcd102e8360f1ee9ad8e1c9 100644 (file)
@@ -10,33 +10,16 @@ using TrafficClient;
 using Model;\r
 using JobEngineClient;\r
 using Maestro.Metadata;\r
-using System.Text;\r
 \r
 namespace Maestro.Targets {\r
 \r
-    public class FTPTargetProcessor : TargetProcessor {\r
+    public class FTPTargetProcessor : UNCTargetProcessor {\r
         private readonly Logger logger = LogManager.GetCurrentClassLogger();\r
-        private const string SUCCESS = "Successfully completed.";\r
-        private const string PROCESSING = "Processing {0}";\r
-        private const string PROCESSING_COMPLETED = "Finished processing {0}";\r
-        private const string FILENAME = "{0}{1}";\r
-        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 METADATA_FILE = "{0}.json";\r
         protected FtpClient targetFTP;\r
-        protected FileInfo inputFile;\r
-        private string workingDir;\r
-        private MediaCubeApi mediaCubeApi;\r
 \r
-        public WorkflowAction workFlowAction { get; set; }\r
-\r
-        public FTPTargetProcessor(Control parent, Source sourceConfig, Target targetConfig, string inputFileName, string id, List<Segment> segments, MediaCubeApi mediaCubeApi, ArchiveMetadataModel model)\r
-            : base(parent, targetConfig, segments, model) {\r
+        public FTPTargetProcessor(Control parent, Source sourceConfig, Target targetConfig, string inputFileName, string id, List<Segment> segments, MediaCubeApi mediaCubeApi, ArchiveMetadataModel archiveMetadata)\r
+            : base(parent, sourceConfig, targetConfig, inputFileName, id, segments, mediaCubeApi, archiveMetadata) {\r
             FtpTrace.LogFunctions = false;\r
-            this.mediaCubeApi = mediaCubeApi;\r
-            this.targetConfig = targetConfig;\r
             Uri inputUri = new Uri(String.Format("{0}/{1}", sourceConfig.Local.Address.LocalPath, inputFileName));\r
             inputFile = new FileInfo(inputUri.LocalPath);\r
             Input = inputFile.FullName;\r
@@ -44,147 +27,33 @@ namespace Maestro.Targets {
             workFlowAction = new WorkflowAction() { houseId = ID, tag = targetConfig.Tag, touched = DateTime.Now };\r
         }\r
 \r
-        public override bool Execute() {\r
-            logger.Info(PROCESSING, inputFile.Name);\r
-            Started = DateTime.Now;\r
-            workFlowAction.started = Started;\r
-            bool result = false;\r
-            try {\r
-                targetFTP = CreateClient(targetConfig.Remote);\r
-                workingDir = DetermineWorkingDirectory(targetConfig.Remote);\r
-                EnsureDirectoryExistence(targetFTP, workingDir);\r
-                Status = ProcessStatus.Progress;\r
-                Output = CreateOutputFileName();\r
-                workFlowAction.source = Input;\r
-                workFlowAction.destination = Path.Combine(workingDir, Output).Replace("\\", "/");\r
-                UploadFile(Output);\r
-                ExecuteCompleted();\r
-                Status = ProcessStatus.Completed;\r
-                Message = SUCCESS;\r
-                workFlowAction.successful = true;\r
-            }\r
-            catch (Exception e) {\r
-                Status = ProcessStatus.Error;\r
-                Message = e.Message;\r
-                workFlowAction.description = Message;\r
-                logger.Error(e);\r
-            }\r
-            finally {\r
-                TerminateClient(targetFTP);\r
-                Finished = DateTime.Now;\r
-                workFlowAction.finished = Finished;\r
-                SendWorkFlowAction();\r
-            }\r
-            logger.Info(PROCESSING_COMPLETED, inputFile.Name);\r
-            return result;\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
-            string result = fileName;\r
-            string nameWithoutExtension = String.Format(Path.GetFileNameWithoutExtension(fileName));\r
-            string extension = Path.GetExtension(fileName);\r
-            int version = 0;\r
-            while (targetFTP.FileExists(result)) {\r
-                string versioned = String.Format(VERSIONED_FILENAME, nameWithoutExtension, version, extension);\r
-                logger.Debug(ALREADY_EXISTS, result, versioned);\r
-                result = versioned;\r
-                version++;\r
-            }\r
-            return result;\r
-        }\r
-\r
-        private void SendWorkFlowAction() {\r
-            try {\r
-                mediaCubeApi.Create(workFlowAction);\r
-            }\r
-            catch (Exception e) {\r
-                MessageBox.Show(parent, e.Message);\r
-            }\r
-        }\r
-\r
-        private String DetermineWorkingDirectory(Connection connection) {\r
-            string result = null;\r
-            Uri address = connection.Address;\r
-            if (targetConfig.CreateSubFolder)\r
-                result = Path.Combine(address.PathAndQuery, ID).Replace("\\", "/");\r
-            else\r
-                result = address.PathAndQuery;\r
-            return result;\r
+        protected override void BeforeExecute() {\r
+            base.BeforeExecute();\r
+            targetFTP = CreateClient(targetConfig.Remote);\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, statusWorkDir);\r
-            DateTime date = DateTime.Now;\r
-            date = date.AddDays(targetConfig.KillDateDays);\r
-            string fileName = String.Format(KILLDATE_FILE, output, date.ToString("yyyyMMdd"));\r
-            logger.Debug("Creating KILLDATE status file {0}", fileName);\r
-            //fileName = Path.Combine(statusWorkDir, fileName).Replace("\\", "/");\r
-            byte[] bytes = new byte[1];\r
-            bytes[0] = 0;\r
-            using (Stream ostream = targetFTP.OpenWrite(fileName)) {\r
-                ostream.Write(bytes, 0, 0);\r
-            }\r
+        protected override void AfterExecute() {\r
+            base.AfterExecute();\r
+            TerminateClient(targetFTP);\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
-            while ((read = istream.Read(buffer, 0, buffer.Length)) > 0) {\r
-                ostream.Write(buffer, 0, read);\r
-                overall += read;\r
-                Progress = (int)((double)overall / ilength * 100);\r
-            }\r
-        }\r
 \r
-        protected virtual void UploadFile(string outputFileName) {\r
-            using (FileStream istream = File.OpenRead(inputFile.FullName)) {\r
-                using (Stream ostream = targetFTP.OpenWrite(outputFileName)) {\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
                 }\r
             }\r
         }\r
 \r
-        protected virtual string CreateOutputFileName() {\r
-            string nameWithoutExtension = targetConfig.OutputFormat.Replace("%ID%", ID).Replace("%SOURCENAME%", Path.GetFileNameWithoutExtension(inputFile.Name));\r
-            string result = String.Format(FILENAME, nameWithoutExtension, inputFile.Extension);\r
-            int version = 1;\r
-            if (targetFTP != null)\r
-                while (targetFTP.FileExists(result)) {\r
-                    string versioned = String.Format(VERSIONED_FILENAME, nameWithoutExtension, version, inputFile.Extension);\r
-                    logger.Debug(ALREADY_EXISTS, result, versioned);\r
-                    result = versioned;\r
-                    version++;\r
-                }\r
-            return result;\r
+        protected override bool FileExists(string path) {\r
+            return targetFTP.FileExists(path);\r
         }\r
 \r
-\r
-        private void EnsureDirectoryExistence(FtpClient client, string path) {\r
-            if (!client.DirectoryExists(path))\r
-                client.CreateDirectory(path, true);\r
-            client.SetWorkingDirectory(path);\r
+        protected override void EnsureDirectoryExistence(string path) {\r
+            if (!targetFTP.DirectoryExists(path))\r
+                targetFTP.CreateDirectory(path, true);\r
+            targetFTP.SetWorkingDirectory(path);\r
         }\r
 \r
         protected FtpClient CreateClient(Connection connection) {\r
index abdb796b395eebdb399b0bbaf681cd82a0b2fe74..51d47dd112b406256a67cfaa6ed54befa4636b55 100644 (file)
@@ -22,7 +22,7 @@ namespace Maestro.Targets {
             this.sourceConfig = sourceConfig;\r
         }\r
 \r
-        protected override void UploadFile(string outputFileName) {\r
+        protected override void UploadFile() {\r
             FtpClient sourceFTP = null;\r
             FtpClient monitorFTP = null;\r
 \r
@@ -46,7 +46,7 @@ namespace Maestro.Targets {
                 if (!replyTYPE.Success)\r
                     throw new Exception(replyTYPE.ErrorMessage);\r
 \r
-                FtpReply replySTOR = targetFTP.Execute("STOR " + outputFileName);\r
+                FtpReply replySTOR = targetFTP.Execute("STOR " + OutputName);\r
                 if (!replySTOR.Success)\r
                     throw new Exception(replySTOR.ErrorMessage);\r
 \r
@@ -62,7 +62,7 @@ namespace Maestro.Targets {
 \r
                 long overall = 0;\r
                 while (overall != ilength) {\r
-                    overall = monitorFTP.GetFileSize(outputFileName);\r
+                    overall = monitorFTP.GetFileSize(OutputName);\r
                     Progress = (int)((double)overall / ilength * 100);\r
                     Thread.Sleep(100);\r
                 }\r
index 0f8424deaf67670dec947043e13cf839f37c9dc6..7da7a2d0557364f3db5e135b6dd550ba7f8472a6 100644 (file)
@@ -12,7 +12,7 @@ namespace Maestro.Targets {
 \r
         string Output { get; set; }\r
 \r
-        ProcessStatus Status { get; set; }\r
+        string Status { get; set; }\r
 \r
         string Message { get; set; }\r
 \r
diff --git a/client/Maestro/Targets/ProcessStatus.cs b/client/Maestro/Targets/ProcessStatus.cs
deleted file mode 100644 (file)
index d403aa1..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-namespace Maestro.Targets {\r
-    public enum ProcessStatus {\r
-        Idle, Progress, Completed, Error\r
-    }\r
-}\r
index febbaa4f8c5aa645541d229230a7f52d851d0a5f..a6fe6e5c6e0f5e22d07df02a6adb5174c0bbb474 100644 (file)
@@ -1,37 +1,25 @@
 using Maestro.Commons;\r
 using System;\r
-using System.Linq;\r
 using System.ComponentModel;\r
 using System.Runtime.CompilerServices;\r
 using System.Windows.Forms;\r
-using System.Collections.Generic;\r
-using Maestro.Configuration;\r
-using TrafficClient;\r
-using Maestro.Metadata;\r
 \r
 namespace Maestro.Targets {\r
     public abstract class TargetProcessor : ITargetProcessor {\r
-        private ProcessStatus status;\r
+        private string status;\r
         private string message;\r
         private string id;\r
         private DateTime started;\r
         private DateTime finished;\r
         private string input;\r
         private string output;\r
+        private string inputName;\r
+        private string outputName;\r
         private int progress;\r
         protected Control parent;\r
-        protected Target targetConfig;\r
-        protected TrafficAPI client;\r
-        protected List<Segment> segments;\r
-        protected ArchiveMetadataModel metadataModel;\r
 \r
-        public TargetProcessor(Control parent, Target targetConfig, List<Segment> segments, ArchiveMetadataModel model) {\r
+        public TargetProcessor(Control parent) {\r
             this.parent = parent;\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
-            this.segments = segments;\r
         }\r
 \r
         public event PropertyChangedEventHandler PropertyChanged;\r
@@ -45,20 +33,9 @@ namespace Maestro.Targets {
         public abstract bool Execute();\r
 \r
         protected virtual void ExecuteCompleted() {\r
-            if (targetConfig.SaveSegments)\r
-                SaveSegments();\r
         }\r
 \r
-        private void SaveSegments() {\r
-            MaestroForm maestroForm = parent as MaestroForm;\r
-            client.DeleteSegments(maestroForm.SelectedMetadata.VariantID);\r
-            if (segments != null)\r
-                foreach (Segment actual in segments) {\r
-                    Segment segment = client.AddSegmentToCopia(maestroForm.SelectedMetadata.VariantID, actual.Comment, actual.TCIn, actual.TCOut, actual.Optional);\r
-                }\r
-        }\r
-\r
-        public ProcessStatus Status {\r
+        public string Status {\r
             get {\r
                 return status;\r
             }\r
@@ -118,6 +95,30 @@ namespace Maestro.Targets {
             }\r
         }\r
 \r
+        public string InputName {\r
+            get {\r
+                return inputName;\r
+            }\r
+            set {\r
+                if (inputName != value) {\r
+                    inputName = value;\r
+                    NotifyPropertyChanged();\r
+                }\r
+            }\r
+        }\r
+\r
+        public string OutputName {\r
+            get {\r
+                return outputName;\r
+            }\r
+            set {\r
+                if (outputName != value) {\r
+                    outputName = value;\r
+                    NotifyPropertyChanged();\r
+                }\r
+            }\r
+        }\r
+\r
         public string Message {\r
             get {\r
                 return message;\r
diff --git a/client/Maestro/Targets/UNCTargetProcessor.cs b/client/Maestro/Targets/UNCTargetProcessor.cs
new file mode 100644 (file)
index 0000000..e8ed691
--- /dev/null
@@ -0,0 +1,200 @@
+using Maestro.Configuration;\r
+using NLog;\r
+using System;\r
+using System.Linq;\r
+using System.IO;\r
+using System.Windows.Forms;\r
+using System.Collections.Generic;\r
+using TrafficClient;\r
+using Model;\r
+using JobEngineClient;\r
+using Maestro.Metadata;\r
+using System.Text;\r
+using Maestro.Commons;\r
+\r
+namespace Maestro.Targets {\r
+\r
+    public class UNCTargetProcessor : TargetProcessor {\r
+        private readonly Logger logger = LogManager.GetCurrentClassLogger();\r
+        private const string SUCCESS = "Successfully completed.";\r
+        private const string PROCESSING = "Processing {0}";\r
+        private const string PROCESSING_COMPLETED = "Finished processing {0}";\r
+        private const string FILENAME = "{0}{1}";\r
+        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 METADATA_FILE = "{0}.json";\r
+        private MediaCubeApi mediaCubeApi;\r
+        protected Target targetConfig;\r
+        protected FileInfo inputFile;\r
+        protected string workingDir;\r
+        protected List<Segment> segments;\r
+        protected ArchiveMetadataModel archiveMetadata;\r
+        public WorkflowAction workFlowAction { get; set; }\r
+\r
+        public UNCTargetProcessor(Control parent, Source sourceConfig, Target targetConfig, string inputFileName, string id, List<Segment> segments, MediaCubeApi mediaCubeApi, ArchiveMetadataModel archiveMetadata)\r
+            : base(parent) {\r
+            this.mediaCubeApi = mediaCubeApi;\r
+            this.targetConfig = targetConfig;\r
+            this.archiveMetadata = archiveMetadata;\r
+            this.segments = segments;\r
+            InputName = inputFileName;\r
+            Input = Path.Combine(sourceConfig.Local.Address.LocalPath, inputFileName);\r
+            inputFile = new FileInfo(Input);\r
+            ID = id;\r
+            workFlowAction = new WorkflowAction() { houseId = ID, tag = targetConfig.Tag, touched = DateTime.Now };\r
+        }\r
+\r
+        protected virtual void BeforeExecute() {\r
+            Started = DateTime.Now;\r
+            workFlowAction.started = Started;\r
+        }\r
+\r
+        public override bool Execute() {\r
+            logger.Info(PROCESSING, inputFile.Name);\r
+            bool result = false;\r
+            try {\r
+                BeforeExecute();\r
+                workingDir = DetermineWorkingDirectory(targetConfig.Remote);\r
+                EnsureDirectoryExistence(workingDir);\r
+                OutputName = CreateOutputFileName();\r
+                Output = Path.Combine(workingDir, OutputName);\r
+                workFlowAction.source = Input;\r
+                workFlowAction.destination = Output;\r
+                Status = "Folyamatban";\r
+                UploadFile();\r
+                ExecuteCompleted();\r
+            }\r
+            catch (Exception e) {\r
+                Status = "Hiba";\r
+                Message = e.Message;\r
+                workFlowAction.description = Message;\r
+                logger.Error(e);\r
+            }\r
+            finally {\r
+                AfterExecute();\r
+            }\r
+            logger.Info(PROCESSING_COMPLETED, inputFile.Name);\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 (targetConfig.KillDateDays > 0)\r
+                UploadKillDateFile();\r
+            if (targetConfig.UseMetadata && archiveMetadata != null)\r
+                CreateMetadata();\r
+            if (targetConfig.SaveSegments && segments != null && segments.Count > 0) \r
+                SaveSegments();\r
+        }\r
+\r
+        private void SaveSegments() {\r
+            MaestroForm maestroForm = parent as MaestroForm;\r
+            TrafficMetadata metadata = maestroForm.Configuration.Metadatas.Where(m => { return m is TrafficMetadata; }).FirstOrDefault() as TrafficMetadata;\r
+            TrafficAPI client = new TrafficAPI(metadata.Server.Address.OriginalString, metadata.Server.UserName, metadata.Server.Password, metadata.Server.Timeout);\r
+            client.DeleteSegments(maestroForm.SelectedMetadata.VariantID);\r
+            foreach (Segment actual in segments) {\r
+                Segment segment = client.AddSegmentToCopia(maestroForm.SelectedMetadata.VariantID, actual.Comment, actual.TCIn, actual.TCOut, actual.Optional);\r
+            }\r
+        }\r
+\r
+        protected virtual void AfterExecute() {\r
+            Finished = DateTime.Now;\r
+            workFlowAction.finished = Finished;\r
+            SendWorkFlowAction();\r
+        }\r
+\r
+        protected virtual bool FileExists(string path) {\r
+            return File.Exists(path);\r
+        }\r
+\r
+        private void SendWorkFlowAction() {\r
+            try {\r
+                mediaCubeApi.Create(workFlowAction);\r
+            }\r
+            catch (Exception e) {\r
+                MessageBox.Show(parent, e.Message);\r
+            }\r
+        }\r
+\r
+        private String DetermineWorkingDirectory(Connection connection) {\r
+            string result = null;\r
+            if (targetConfig.CreateSubFolder)\r
+                result = Path.Combine(connection.Address.LocalPath, ID);\r
+            else\r
+                result = connection.Address.LocalPath;\r
+            return result;\r
+        }\r
+\r
+        private void UploadKillDateFile() {\r
+            Uri address = targetConfig.Remote.Address;\r
+            string statusWorkDir = Path.Combine(address.LocalPath, STATUS_FOLDER);\r
+            EnsureDirectoryExistence(statusWorkDir);\r
+            DateTime date = DateTime.Now;\r
+            date = date.AddDays(targetConfig.KillDateDays);\r
+            string fileName = String.Format(KILLDATE_FILE, OutputName, date.ToString("yyyyMMdd"));\r
+            logger.Debug("Creating KILLDATE status file {0}", fileName);\r
+            UploadContent(Path.Combine(statusWorkDir, fileName), null);\r
+        }\r
+\r
+        private void CreateMetadata() {\r
+            Uri address = targetConfig.Remote.Address;\r
+            string statusWorkDir = Path.Combine(address.LocalPath, STATUS_FOLDER);\r
+            EnsureDirectoryExistence(statusWorkDir);\r
+            string fileName = String.Format(METADATA_FILE, OutputName);\r
+            logger.Debug("Creating METADATA file {0}", fileName);\r
+            byte[] content = Encoding.UTF8.GetBytes(archiveMetadata.ToString());\r
+            UploadContent(Path.Combine(statusWorkDir, fileName), content);\r
+        }\r
+\r
+\r
+        protected void CopyStream(Stream istream, long ilength, Stream ostream) {\r
+            byte[] buffer = new byte[32768];\r
+            int read, overall = 0;\r
+            while ((read = istream.Read(buffer, 0, buffer.Length)) > 0) {\r
+                ostream.Write(buffer, 0, read);\r
+                overall += read;\r
+                Progress = (int)((double)overall / ilength * 100);\r
+            }\r
+        }\r
+\r
+        protected virtual void UploadContent(string outputPath, byte[] content) {\r
+            File.WriteAllBytes(outputPath, content);\r
+        }\r
+\r
+        private CopyProgressResult CopyProgressHandler(long total, long transferred, long streamSize, long StreamByteTrans, uint dwStreamNumber, CopyProgressCallbackReason reason, IntPtr hSourceFile, IntPtr hDestinationFile, IntPtr lpData) {\r
+            Progress = (int)((double)total / transferred * 100);\r
+            return CopyProgressResult.PROGRESS_CONTINUE;\r
+        }\r
+\r
+        protected virtual void UploadFile() {\r
+            int pbCancel = 0;\r
+            Win32File.CopyFileEx(Input, Output, new CopyProgressRoutine(this.CopyProgressHandler), IntPtr.Zero, ref pbCancel, CopyFileFlags.COPY_FILE_RESTARTABLE);\r
+        }\r
+\r
+        protected virtual string CreateOutputFileName() {\r
+            string nameWithoutExtension = targetConfig.OutputFormat.Replace("%ID%", ID).Replace("%SOURCENAME%", Path.GetFileNameWithoutExtension(inputFile.Name));\r
+            string result = String.Format(FILENAME, nameWithoutExtension, inputFile.Extension);\r
+            int version = 1;\r
+            while (FileExists(Path.Combine(workingDir, result))) {\r
+                string versioned = String.Format(VERSIONED_FILENAME, nameWithoutExtension, version, inputFile.Extension);\r
+                logger.Debug(ALREADY_EXISTS, result, versioned);\r
+                result = versioned;\r
+                version++;\r
+            }\r
+            return result;\r
+        }\r
+\r
+        protected virtual void EnsureDirectoryExistence(string path) {\r
+            if (!Directory.Exists(path))\r
+                Directory.CreateDirectory(path);\r
+        }\r
+\r
+\r
+    }\r
+}\r