From e753f6c804a268752405aee40e46d4498ca4a037 Mon Sep 17 00:00:00 2001 From: =?utf8?q?V=C3=A1s=C3=A1ry=20D=C3=A1niel?= Date: Thu, 16 Nov 2017 23:00:20 +0000 Subject: [PATCH] git-tfs-id: [http://tfs.userrendszerhaz.hu:8080/tfs/DefaultCollection]$/MediaCube;C30737 --- client/DxPlay/DxPlayer.cs | 1 + client/DxPlay/MediaDescription.cs | 1 + client/DxPlay/MediaDetector.cs | 1 + client/DxPlay/MediaDetectorLight.cs | 5 +- client/DxPlay/PlayerForm.Designer.cs | 7 +- client/DxPlay/PlayerForm.cs | 10 +- client/IntegrationTests/TimecodeTests.cs | 1 + client/Maestro/ArchiveMetadataForm.cs | 1 + client/Maestro/MaestroForm.Designer.cs | 188 ++++----- client/Maestro/Metadata/ArchiveMetadata.cs | 47 --- client/Maestro/Metadata/MetaDataInfo.cs | 4 +- client/Maestro/Sources/FileSystemSource.cs | 2 +- client/Maestro/Sources/NexioRESTSource.cs | 2 +- client/Maestro/Targets/FTPTargetProcessor.cs | 151 -------- client/Maestro/Targets/FXPTargetProcessor.cs | 115 ------ client/Maestro/Targets/ITargetProcessor.cs | 31 -- client/Maestro/Targets/TargetProcessor.cs | 196 ---------- client/Maestro/Targets/UNCTargetProcessor.cs | 357 ------------------ .../Commons/MorpheusXML.cs | 5 +- .../Commons/NexioXML.cs | 2 +- .../Commons/ObjectExtensions.cs | 2 +- .../Commons/Win32File.cs | 2 +- .../Metadata}/SegmentConverter.cs | 7 +- 23 files changed, 118 insertions(+), 1020 deletions(-) delete mode 100644 client/Maestro/Metadata/ArchiveMetadata.cs delete mode 100644 client/Maestro/Targets/FTPTargetProcessor.cs delete mode 100644 client/Maestro/Targets/FXPTargetProcessor.cs delete mode 100644 client/Maestro/Targets/ITargetProcessor.cs delete mode 100644 client/Maestro/Targets/TargetProcessor.cs delete mode 100644 client/Maestro/Targets/UNCTargetProcessor.cs rename client/{Maestro => MaestroShared}/Commons/MorpheusXML.cs (97%) rename client/{Maestro => MaestroShared}/Commons/NexioXML.cs (95%) rename client/{Maestro => MaestroShared}/Commons/ObjectExtensions.cs (88%) rename client/{Maestro => MaestroShared}/Commons/Win32File.cs (95%) rename client/{Maestro/Targets => MaestroShared/Metadata}/SegmentConverter.cs (86%) diff --git a/client/DxPlay/DxPlayer.cs b/client/DxPlay/DxPlayer.cs index 7a8fcbaf..50b5c352 100644 --- a/client/DxPlay/DxPlayer.cs +++ b/client/DxPlay/DxPlayer.cs @@ -13,6 +13,7 @@ using System.Drawing.Imaging; using System.Drawing.Drawing2D; using System.Collections.Generic; using Myriadbits.MXF; +using MaestroShared.Metadata; namespace DxPlay { diff --git a/client/DxPlay/MediaDescription.cs b/client/DxPlay/MediaDescription.cs index c83c295b..c6233696 100644 --- a/client/DxPlay/MediaDescription.cs +++ b/client/DxPlay/MediaDescription.cs @@ -1,3 +1,4 @@ +using MaestroShared.Metadata; using System; using System.ComponentModel; using System.Drawing; diff --git a/client/DxPlay/MediaDetector.cs b/client/DxPlay/MediaDetector.cs index d5837a3d..58c7326d 100644 --- a/client/DxPlay/MediaDetector.cs +++ b/client/DxPlay/MediaDetector.cs @@ -11,6 +11,7 @@ using MediaInfoLib; using System.Diagnostics; using System.Globalization; using NLog; +using MaestroShared.Metadata; namespace DxPlay { /// diff --git a/client/DxPlay/MediaDetectorLight.cs b/client/DxPlay/MediaDetectorLight.cs index 5b220a16..517492f1 100644 --- a/client/DxPlay/MediaDetectorLight.cs +++ b/client/DxPlay/MediaDetectorLight.cs @@ -4,13 +4,10 @@ using System.Drawing.Imaging; using System.Runtime.InteropServices; using System.Text; using System.Windows.Forms; - using DirectShowLib; using DirectShowLib.DES; -using MediaInfoLib; -using System.Diagnostics; -using System.Globalization; using NLog; +using MaestroShared.Metadata; namespace DxPlay { /// diff --git a/client/DxPlay/PlayerForm.Designer.cs b/client/DxPlay/PlayerForm.Designer.cs index 4f651645..13915987 100644 --- a/client/DxPlay/PlayerForm.Designer.cs +++ b/client/DxPlay/PlayerForm.Designer.cs @@ -253,6 +253,7 @@ namespace DxPlay { this.btnPlay.AutoSize = true; this.btnPlay.BackColor = System.Drawing.Color.White; this.btnPlay.FlatAppearance.BorderSize = 0; + this.btnPlay.FlatStyle = System.Windows.Forms.FlatStyle.Flat; this.btnPlay.Image = global::DxPlay.Properties.Resources.ic_play_arrow_black_24dp_2x; this.btnPlay.Location = new System.Drawing.Point(3, 3); this.btnPlay.Name = "btnPlay"; @@ -267,7 +268,7 @@ namespace DxPlay { this.btnStop.AutoSize = true; this.btnStop.BackColor = System.Drawing.Color.White; this.btnStop.FlatAppearance.BorderSize = 0; - this.btnStop.FlatStyle = System.Windows.Forms.FlatStyle.Popup; + this.btnStop.FlatStyle = System.Windows.Forms.FlatStyle.Flat; this.btnStop.Image = global::DxPlay.Properties.Resources.ic_stop_black_24dp_2x; this.btnStop.Location = new System.Drawing.Point(63, 3); this.btnStop.Name = "btnStop"; @@ -282,7 +283,7 @@ namespace DxPlay { this.btnPause.AutoSize = true; this.btnPause.BackColor = System.Drawing.Color.White; this.btnPause.FlatAppearance.BorderSize = 0; - this.btnPause.FlatStyle = System.Windows.Forms.FlatStyle.Popup; + this.btnPause.FlatStyle = System.Windows.Forms.FlatStyle.Flat; this.btnPause.Image = global::DxPlay.Properties.Resources.ic_pause_black_24dp_2x; this.btnPause.Location = new System.Drawing.Point(123, 3); this.btnPause.Name = "btnPause"; @@ -392,7 +393,7 @@ namespace DxPlay { this.MinimumSize = new System.Drawing.Size(640, 480); this.Name = "PlayerForm"; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; - this.Text = "MediaCUBE Video Player"; + this.Text = "MediaCube Player"; this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.PlayerForm_FormClosing); this.FormClosed += new System.Windows.Forms.FormClosedEventHandler(this.PlayerForm_FormClosed); this.Load += new System.EventHandler(this.PlayerForm_Load); diff --git a/client/DxPlay/PlayerForm.cs b/client/DxPlay/PlayerForm.cs index 4bea8a2b..c5f403db 100644 --- a/client/DxPlay/PlayerForm.cs +++ b/client/DxPlay/PlayerForm.cs @@ -1,20 +1,12 @@ -/**************************************************************************** -While the underlying libraries are covered by LGPL, this sample is released -as public domain. It is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -or FITNESS FOR A PARTICULAR PURPOSE. -*****************************************************************************/ - using System; using System.Windows.Forms; -using System.Runtime.InteropServices; using System.Diagnostics; using static DxPlay.DxPlayer; using JR.Utils.GUI.Forms; using System.IO; using System.Linq; using System.ComponentModel; -using System.Collections.Generic; +using MaestroShared.Metadata; namespace DxPlay { diff --git a/client/IntegrationTests/TimecodeTests.cs b/client/IntegrationTests/TimecodeTests.cs index 4720f407..60a3d4ab 100644 --- a/client/IntegrationTests/TimecodeTests.cs +++ b/client/IntegrationTests/TimecodeTests.cs @@ -1,4 +1,5 @@ using DxPlay; +using MaestroShared.Metadata; using Microsoft.VisualStudio.TestTools.UnitTesting; using MongoDB.Bson; using MongoDB.Driver; diff --git a/client/Maestro/ArchiveMetadataForm.cs b/client/Maestro/ArchiveMetadataForm.cs index d4c29590..ce594fc7 100644 --- a/client/Maestro/ArchiveMetadataForm.cs +++ b/client/Maestro/ArchiveMetadataForm.cs @@ -1,5 +1,6 @@ using System.Windows.Forms; using Maestro.Metadata; +using MaestroShared.Metadata; namespace Maestro { public partial class ArchiveMetadataForm : Form { diff --git a/client/Maestro/MaestroForm.Designer.cs b/client/Maestro/MaestroForm.Designer.cs index a52eb53b..f4474813 100644 --- a/client/Maestro/MaestroForm.Designer.cs +++ b/client/Maestro/MaestroForm.Designer.cs @@ -26,21 +26,21 @@ namespace Maestro { /// private void InitializeComponent() { this.components = new System.ComponentModel.Container(); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle29 = new System.Windows.Forms.DataGridViewCellStyle(); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle30 = new System.Windows.Forms.DataGridViewCellStyle(); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle31 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle15 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle16 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle17 = new System.Windows.Forms.DataGridViewCellStyle(); System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(MaestroForm)); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle32 = new System.Windows.Forms.DataGridViewCellStyle(); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle35 = new System.Windows.Forms.DataGridViewCellStyle(); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle36 = new System.Windows.Forms.DataGridViewCellStyle(); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle37 = new System.Windows.Forms.DataGridViewCellStyle(); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle33 = new System.Windows.Forms.DataGridViewCellStyle(); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle34 = new System.Windows.Forms.DataGridViewCellStyle(); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle38 = new System.Windows.Forms.DataGridViewCellStyle(); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle40 = new System.Windows.Forms.DataGridViewCellStyle(); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle41 = new System.Windows.Forms.DataGridViewCellStyle(); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle42 = new System.Windows.Forms.DataGridViewCellStyle(); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle39 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle18 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle21 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle22 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle23 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle19 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle20 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle24 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle26 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle27 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle28 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle25 = new System.Windows.Forms.DataGridViewCellStyle(); this.groupSource = new System.Windows.Forms.GroupBox(); this.dgSource = new System.Windows.Forms.DataGridView(); this.bindingSource = new System.Windows.Forms.BindingSource(this.components); @@ -158,32 +158,32 @@ namespace Maestro { this.dgSource.BackgroundColor = System.Drawing.Color.White; this.dgSource.BorderStyle = System.Windows.Forms.BorderStyle.None; this.dgSource.CellBorderStyle = System.Windows.Forms.DataGridViewCellBorderStyle.Raised; - dataGridViewCellStyle29.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft; - dataGridViewCellStyle29.BackColor = System.Drawing.SystemColors.Control; - dataGridViewCellStyle29.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238))); - dataGridViewCellStyle29.ForeColor = System.Drawing.SystemColors.WindowText; - dataGridViewCellStyle29.SelectionBackColor = System.Drawing.SystemColors.Highlight; - dataGridViewCellStyle29.SelectionForeColor = System.Drawing.SystemColors.HighlightText; - dataGridViewCellStyle29.WrapMode = System.Windows.Forms.DataGridViewTriState.True; - this.dgSource.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle29; + dataGridViewCellStyle15.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft; + dataGridViewCellStyle15.BackColor = System.Drawing.SystemColors.Control; + dataGridViewCellStyle15.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238))); + dataGridViewCellStyle15.ForeColor = System.Drawing.SystemColors.WindowText; + dataGridViewCellStyle15.SelectionBackColor = System.Drawing.SystemColors.Highlight; + dataGridViewCellStyle15.SelectionForeColor = System.Drawing.SystemColors.HighlightText; + dataGridViewCellStyle15.WrapMode = System.Windows.Forms.DataGridViewTriState.True; + this.dgSource.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle15; this.dgSource.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; this.dgSource.DataSource = this.bindingSource; - dataGridViewCellStyle30.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft; - dataGridViewCellStyle30.BackColor = System.Drawing.SystemColors.Window; - dataGridViewCellStyle30.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238))); - dataGridViewCellStyle30.ForeColor = System.Drawing.SystemColors.ControlText; - dataGridViewCellStyle30.SelectionBackColor = System.Drawing.Color.Gainsboro; - dataGridViewCellStyle30.SelectionForeColor = System.Drawing.Color.Black; - dataGridViewCellStyle30.WrapMode = System.Windows.Forms.DataGridViewTriState.False; - this.dgSource.DefaultCellStyle = dataGridViewCellStyle30; + dataGridViewCellStyle16.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft; + dataGridViewCellStyle16.BackColor = System.Drawing.SystemColors.Window; + dataGridViewCellStyle16.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238))); + dataGridViewCellStyle16.ForeColor = System.Drawing.SystemColors.ControlText; + dataGridViewCellStyle16.SelectionBackColor = System.Drawing.Color.Gainsboro; + dataGridViewCellStyle16.SelectionForeColor = System.Drawing.Color.Black; + dataGridViewCellStyle16.WrapMode = System.Windows.Forms.DataGridViewTriState.False; + this.dgSource.DefaultCellStyle = dataGridViewCellStyle16; this.dgSource.Dock = System.Windows.Forms.DockStyle.Fill; this.dgSource.EditMode = System.Windows.Forms.DataGridViewEditMode.EditProgrammatically; this.dgSource.EnableHeadersVisualStyles = false; this.dgSource.Location = new System.Drawing.Point(10, 47); this.dgSource.Name = "dgSource"; this.dgSource.RowHeadersVisible = false; - dataGridViewCellStyle31.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238))); - this.dgSource.RowsDefaultCellStyle = dataGridViewCellStyle31; + dataGridViewCellStyle17.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238))); + this.dgSource.RowsDefaultCellStyle = dataGridViewCellStyle17; this.dgSource.RowTemplate.DefaultCellStyle.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238))); this.dgSource.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect; this.dgSource.Size = new System.Drawing.Size(330, 352); @@ -418,7 +418,7 @@ namespace Maestro { this.tpTraffic.Location = new System.Drawing.Point(4, 24); this.tpTraffic.Name = "tpTraffic"; this.tpTraffic.Padding = new System.Windows.Forms.Padding(3); - this.tpTraffic.Size = new System.Drawing.Size(278, 348); + this.tpTraffic.Size = new System.Drawing.Size(322, 348); this.tpTraffic.TabIndex = 1; this.tpTraffic.Text = "Traffic"; this.tpTraffic.UseVisualStyleBackColor = true; @@ -433,7 +433,7 @@ namespace Maestro { this.trafficIDSelector.Margin = new System.Windows.Forms.Padding(4); this.trafficIDSelector.Name = "trafficIDSelector"; this.trafficIDSelector.Padding = new System.Windows.Forms.Padding(6); - this.trafficIDSelector.Size = new System.Drawing.Size(272, 342); + this.trafficIDSelector.Size = new System.Drawing.Size(316, 342); this.trafficIDSelector.TabIndex = 0; // // tableLayoutPanel1 @@ -637,14 +637,14 @@ namespace Maestro { this.dgJobs.AutoSizeRowsMode = System.Windows.Forms.DataGridViewAutoSizeRowsMode.DisplayedCells; this.dgJobs.BackgroundColor = System.Drawing.Color.White; this.dgJobs.BorderStyle = System.Windows.Forms.BorderStyle.None; - dataGridViewCellStyle32.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft; - dataGridViewCellStyle32.BackColor = System.Drawing.SystemColors.Control; - dataGridViewCellStyle32.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238))); - dataGridViewCellStyle32.ForeColor = System.Drawing.SystemColors.WindowText; - dataGridViewCellStyle32.SelectionBackColor = System.Drawing.SystemColors.Highlight; - dataGridViewCellStyle32.SelectionForeColor = System.Drawing.SystemColors.HighlightText; - dataGridViewCellStyle32.WrapMode = System.Windows.Forms.DataGridViewTriState.True; - this.dgJobs.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle32; + dataGridViewCellStyle18.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft; + dataGridViewCellStyle18.BackColor = System.Drawing.SystemColors.Control; + dataGridViewCellStyle18.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238))); + dataGridViewCellStyle18.ForeColor = System.Drawing.SystemColors.WindowText; + dataGridViewCellStyle18.SelectionBackColor = System.Drawing.SystemColors.Highlight; + dataGridViewCellStyle18.SelectionForeColor = System.Drawing.SystemColors.HighlightText; + dataGridViewCellStyle18.WrapMode = System.Windows.Forms.DataGridViewTriState.True; + this.dgJobs.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle18; this.dgJobs.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; this.dgJobs.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { this.columnLabel, @@ -657,32 +657,32 @@ namespace Maestro { this.columnOutput, this.columnKillDate}); this.dgJobs.DataSource = this.bindingSourceJobs; - dataGridViewCellStyle35.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft; - dataGridViewCellStyle35.BackColor = System.Drawing.SystemColors.Window; - dataGridViewCellStyle35.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238))); - dataGridViewCellStyle35.ForeColor = System.Drawing.SystemColors.ControlText; - dataGridViewCellStyle35.NullValue = null; - dataGridViewCellStyle35.SelectionBackColor = System.Drawing.Color.Gainsboro; - dataGridViewCellStyle35.SelectionForeColor = System.Drawing.Color.Black; - dataGridViewCellStyle35.WrapMode = System.Windows.Forms.DataGridViewTriState.False; - this.dgJobs.DefaultCellStyle = dataGridViewCellStyle35; + dataGridViewCellStyle21.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft; + dataGridViewCellStyle21.BackColor = System.Drawing.SystemColors.Window; + dataGridViewCellStyle21.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238))); + dataGridViewCellStyle21.ForeColor = System.Drawing.SystemColors.ControlText; + dataGridViewCellStyle21.NullValue = null; + dataGridViewCellStyle21.SelectionBackColor = System.Drawing.Color.Gainsboro; + dataGridViewCellStyle21.SelectionForeColor = System.Drawing.Color.Black; + dataGridViewCellStyle21.WrapMode = System.Windows.Forms.DataGridViewTriState.False; + this.dgJobs.DefaultCellStyle = dataGridViewCellStyle21; this.dgJobs.Dock = System.Windows.Forms.DockStyle.Fill; this.dgJobs.EditMode = System.Windows.Forms.DataGridViewEditMode.EditProgrammatically; this.dgJobs.EnableHeadersVisualStyles = false; this.dgJobs.GridColor = System.Drawing.Color.White; this.dgJobs.Location = new System.Drawing.Point(3, 3); this.dgJobs.Name = "dgJobs"; - dataGridViewCellStyle36.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft; - dataGridViewCellStyle36.BackColor = System.Drawing.SystemColors.Control; - dataGridViewCellStyle36.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238))); - dataGridViewCellStyle36.ForeColor = System.Drawing.SystemColors.WindowText; - dataGridViewCellStyle36.SelectionBackColor = System.Drawing.SystemColors.Highlight; - dataGridViewCellStyle36.SelectionForeColor = System.Drawing.SystemColors.HighlightText; - dataGridViewCellStyle36.WrapMode = System.Windows.Forms.DataGridViewTriState.True; - this.dgJobs.RowHeadersDefaultCellStyle = dataGridViewCellStyle36; + dataGridViewCellStyle22.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft; + dataGridViewCellStyle22.BackColor = System.Drawing.SystemColors.Control; + dataGridViewCellStyle22.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238))); + dataGridViewCellStyle22.ForeColor = System.Drawing.SystemColors.WindowText; + dataGridViewCellStyle22.SelectionBackColor = System.Drawing.SystemColors.Highlight; + dataGridViewCellStyle22.SelectionForeColor = System.Drawing.SystemColors.HighlightText; + dataGridViewCellStyle22.WrapMode = System.Windows.Forms.DataGridViewTriState.True; + this.dgJobs.RowHeadersDefaultCellStyle = dataGridViewCellStyle22; this.dgJobs.RowHeadersVisible = false; - dataGridViewCellStyle37.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238))); - this.dgJobs.RowsDefaultCellStyle = dataGridViewCellStyle37; + dataGridViewCellStyle23.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238))); + this.dgJobs.RowsDefaultCellStyle = dataGridViewCellStyle23; this.dgJobs.RowTemplate.DefaultCellStyle.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238))); this.dgJobs.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect; this.dgJobs.Size = new System.Drawing.Size(988, 92); @@ -702,8 +702,8 @@ namespace Maestro { // this.columnID.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.DisplayedCells; this.columnID.DataPropertyName = "ID"; - dataGridViewCellStyle33.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238))); - this.columnID.DefaultCellStyle = dataGridViewCellStyle33; + dataGridViewCellStyle19.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238))); + this.columnID.DefaultCellStyle = dataGridViewCellStyle19; this.columnID.HeaderText = "ID"; this.columnID.Name = "columnID"; this.columnID.Width = 44; @@ -720,8 +720,8 @@ namespace Maestro { // this.columnStatus.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.DisplayedCells; this.columnStatus.DataPropertyName = "Status"; - dataGridViewCellStyle34.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238))); - this.columnStatus.DefaultCellStyle = dataGridViewCellStyle34; + dataGridViewCellStyle20.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238))); + this.columnStatus.DefaultCellStyle = dataGridViewCellStyle20; this.columnStatus.HeaderText = "Status"; this.columnStatus.Name = "columnStatus"; this.columnStatus.Width = 66; @@ -785,27 +785,27 @@ namespace Maestro { this.dgMessages.AutoSizeRowsMode = System.Windows.Forms.DataGridViewAutoSizeRowsMode.DisplayedCells; this.dgMessages.BackgroundColor = System.Drawing.Color.White; this.dgMessages.BorderStyle = System.Windows.Forms.BorderStyle.None; - dataGridViewCellStyle38.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft; - dataGridViewCellStyle38.BackColor = System.Drawing.SystemColors.Control; - dataGridViewCellStyle38.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238))); - dataGridViewCellStyle38.ForeColor = System.Drawing.SystemColors.WindowText; - dataGridViewCellStyle38.SelectionBackColor = System.Drawing.SystemColors.Highlight; - dataGridViewCellStyle38.SelectionForeColor = System.Drawing.SystemColors.HighlightText; - dataGridViewCellStyle38.WrapMode = System.Windows.Forms.DataGridViewTriState.True; - this.dgMessages.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle38; + dataGridViewCellStyle24.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft; + dataGridViewCellStyle24.BackColor = System.Drawing.SystemColors.Control; + dataGridViewCellStyle24.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238))); + dataGridViewCellStyle24.ForeColor = System.Drawing.SystemColors.WindowText; + dataGridViewCellStyle24.SelectionBackColor = System.Drawing.SystemColors.Highlight; + dataGridViewCellStyle24.SelectionForeColor = System.Drawing.SystemColors.HighlightText; + dataGridViewCellStyle24.WrapMode = System.Windows.Forms.DataGridViewTriState.True; + this.dgMessages.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle24; this.dgMessages.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; this.dgMessages.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { this.dataGridViewTextBoxColumn1, this.dataGridViewTextBoxColumn2}); - dataGridViewCellStyle40.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft; - dataGridViewCellStyle40.BackColor = System.Drawing.SystemColors.Window; - dataGridViewCellStyle40.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238))); - dataGridViewCellStyle40.ForeColor = System.Drawing.Color.Red; - dataGridViewCellStyle40.NullValue = null; - dataGridViewCellStyle40.SelectionBackColor = System.Drawing.Color.Gainsboro; - dataGridViewCellStyle40.SelectionForeColor = System.Drawing.Color.Red; - dataGridViewCellStyle40.WrapMode = System.Windows.Forms.DataGridViewTriState.False; - this.dgMessages.DefaultCellStyle = dataGridViewCellStyle40; + dataGridViewCellStyle26.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft; + dataGridViewCellStyle26.BackColor = System.Drawing.SystemColors.Window; + dataGridViewCellStyle26.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238))); + dataGridViewCellStyle26.ForeColor = System.Drawing.Color.Red; + dataGridViewCellStyle26.NullValue = null; + dataGridViewCellStyle26.SelectionBackColor = System.Drawing.Color.Gainsboro; + dataGridViewCellStyle26.SelectionForeColor = System.Drawing.Color.Red; + dataGridViewCellStyle26.WrapMode = System.Windows.Forms.DataGridViewTriState.False; + this.dgMessages.DefaultCellStyle = dataGridViewCellStyle26; this.dgMessages.Dock = System.Windows.Forms.DockStyle.Fill; this.dgMessages.EditMode = System.Windows.Forms.DataGridViewEditMode.EditProgrammatically; this.dgMessages.EnableHeadersVisualStyles = false; @@ -813,17 +813,17 @@ namespace Maestro { this.dgMessages.Location = new System.Drawing.Point(3, 3); this.dgMessages.Name = "dgMessages"; this.dgMessages.ReadOnly = true; - dataGridViewCellStyle41.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft; - dataGridViewCellStyle41.BackColor = System.Drawing.SystemColors.Control; - dataGridViewCellStyle41.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238))); - dataGridViewCellStyle41.ForeColor = System.Drawing.SystemColors.WindowText; - dataGridViewCellStyle41.SelectionBackColor = System.Drawing.SystemColors.Highlight; - dataGridViewCellStyle41.SelectionForeColor = System.Drawing.SystemColors.HighlightText; - dataGridViewCellStyle41.WrapMode = System.Windows.Forms.DataGridViewTriState.True; - this.dgMessages.RowHeadersDefaultCellStyle = dataGridViewCellStyle41; + dataGridViewCellStyle27.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft; + dataGridViewCellStyle27.BackColor = System.Drawing.SystemColors.Control; + dataGridViewCellStyle27.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238))); + dataGridViewCellStyle27.ForeColor = System.Drawing.SystemColors.WindowText; + dataGridViewCellStyle27.SelectionBackColor = System.Drawing.SystemColors.Highlight; + dataGridViewCellStyle27.SelectionForeColor = System.Drawing.SystemColors.HighlightText; + dataGridViewCellStyle27.WrapMode = System.Windows.Forms.DataGridViewTriState.True; + this.dgMessages.RowHeadersDefaultCellStyle = dataGridViewCellStyle27; this.dgMessages.RowHeadersVisible = false; - dataGridViewCellStyle42.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238))); - this.dgMessages.RowsDefaultCellStyle = dataGridViewCellStyle42; + dataGridViewCellStyle28.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238))); + this.dgMessages.RowsDefaultCellStyle = dataGridViewCellStyle28; this.dgMessages.RowTemplate.DefaultCellStyle.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238))); this.dgMessages.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect; this.dgMessages.Size = new System.Drawing.Size(988, 92); @@ -842,8 +842,8 @@ namespace Maestro { // this.dataGridViewTextBoxColumn2.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill; this.dataGridViewTextBoxColumn2.DataPropertyName = "Message"; - dataGridViewCellStyle39.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238))); - this.dataGridViewTextBoxColumn2.DefaultCellStyle = dataGridViewCellStyle39; + dataGridViewCellStyle25.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238))); + this.dataGridViewTextBoxColumn2.DefaultCellStyle = dataGridViewCellStyle25; this.dataGridViewTextBoxColumn2.HeaderText = "Üzenet"; this.dataGridViewTextBoxColumn2.Name = "dataGridViewTextBoxColumn2"; this.dataGridViewTextBoxColumn2.ReadOnly = true; diff --git a/client/Maestro/Metadata/ArchiveMetadata.cs b/client/Maestro/Metadata/ArchiveMetadata.cs deleted file mode 100644 index b245a294..00000000 --- a/client/Maestro/Metadata/ArchiveMetadata.cs +++ /dev/null @@ -1,47 +0,0 @@ -using System; -using Newtonsoft.Json; -using System.Runtime.Serialization.Formatters.Binary; -using System.IO; - -namespace Maestro.Metadata { - - [Serializable()] - public class ArchiveMetadata { - - //todo rename a Stuffra?? - public string itemHouseId { get; set; } - public string itemTitle { get; set; } - public string itemDescription { get; set; } - public string mediaHouseId { get; set; } - public string mediaTitle { get; set; } - public string mediaDescription { get; set; } - - public override string ToString() { - return JsonConvert.SerializeObject(this); - //return String.Format("{{\n \"Anyag azonosító\": \"{0}\",\n, \"Anyag cím\": \"{1}\",\n \"Anyag leírása\": \"{2}\",\n \"Média azonosító\": \"{3}\",\n \"Média cím\": \"{4}\",\n \"Média leírás\": \"{5}\" \n}}", - // StuffID, StuffTitle, StuffDescription, MediaID, MediaTitle, MediaDescription); - } - - [JsonIgnore] - public bool IsFilled { - get { - return - !String.IsNullOrEmpty(itemHouseId) && - !String.IsNullOrEmpty(itemTitle) && - !String.IsNullOrEmpty(mediaHouseId) && - !String.IsNullOrEmpty(mediaTitle); - } - } - - public static ArchiveMetadata DeepClone(ArchiveMetadata obj) { - if (obj == null) - return null; - using (var ms = new MemoryStream()) { - var formatter = new BinaryFormatter(); - formatter.Serialize(ms, obj); - ms.Position = 0; - return (ArchiveMetadata)formatter.Deserialize(ms); - } - } - } -} diff --git a/client/Maestro/Metadata/MetaDataInfo.cs b/client/Maestro/Metadata/MetaDataInfo.cs index 04608efb..4afb7061 100644 --- a/client/Maestro/Metadata/MetaDataInfo.cs +++ b/client/Maestro/Metadata/MetaDataInfo.cs @@ -1,4 +1,6 @@ -namespace Maestro.Metadata { +using MaestroShared.Metadata; + +namespace Maestro.Metadata { public class MetadataInfo { public string ID { get; set; } public string MetadataText { get; set; } diff --git a/client/Maestro/Sources/FileSystemSource.cs b/client/Maestro/Sources/FileSystemSource.cs index f64147a1..525e39d9 100644 --- a/client/Maestro/Sources/FileSystemSource.cs +++ b/client/Maestro/Sources/FileSystemSource.cs @@ -6,9 +6,9 @@ using System.IO; using System.Windows.Forms; using LinkDotNet.MessageHandling.Contracts; using Maestro.Sources.Messages; -using Maestro.Commons; using System.Drawing; using NLog; +using MaestroShared.Commons; namespace Maestro.Sources { public delegate void ClearAndInitialize(); diff --git a/client/Maestro/Sources/NexioRESTSource.cs b/client/Maestro/Sources/NexioRESTSource.cs index 77f84ebf..5fc1e3df 100644 --- a/client/Maestro/Sources/NexioRESTSource.cs +++ b/client/Maestro/Sources/NexioRESTSource.cs @@ -4,7 +4,6 @@ using System.Diagnostics; using System.Windows.Forms; using LinkDotNet.MessageHandling.Contracts; using Maestro.Sources.Messages; -using Maestro.Commons; using NexioClient; using Newtonsoft.Json.Linq; using WebSocketSharp; @@ -12,6 +11,7 @@ using System; using System.Drawing; using NLog; using System.Collections.Generic; +using MaestroShared.Commons; namespace Maestro.Sources { class NexioRESTSource : BindingList, ISource { diff --git a/client/Maestro/Targets/FTPTargetProcessor.cs b/client/Maestro/Targets/FTPTargetProcessor.cs deleted file mode 100644 index 0263220c..00000000 --- a/client/Maestro/Targets/FTPTargetProcessor.cs +++ /dev/null @@ -1,151 +0,0 @@ -using FluentFTP; -using MaestroShared.Configuration; -using NLog; -using System; -using System.IO; -using System.Linq; -using System.Net; -using System.Windows.Forms; - -namespace Maestro.Targets { - - public class FTPTargetProcessor : UNCTargetProcessor { - private const string PATTERN_CONCAT = "{0}{1}"; - private const string _226 = "226"; - private const string UPLOAD_ERROR = "Feltöltési hiba."; - private readonly Logger logger = LogManager.GetCurrentClassLogger(); - protected FtpClient targetFTP; - - public FTPTargetProcessor(Control parent, TargetProcessorParameter parameters) - : base(parent, parameters) { - FtpTrace.LogFunctions = false; - if (!(parameters.SourceConfig is UNCSource)) { - inputFile = null; - Uri inputUri = new Uri(String.Format(PATTERN_CONCAT, parameters.SourceConfig.Remote.Address, parameters.InputFileName)); - Input = inputUri.ToString(); - } - } - - protected override void BeforeExecute() { - base.BeforeExecute(); - targetFTP = CreateClient(parameters.TargetConfig.Remote); - } - - protected override void AfterExecute() { - base.AfterExecute(); - TerminateClient(targetFTP); - } - - protected override void DeleteFile(string currentFile) { - targetFTP.DeleteFile(currentFile); - } - - protected override void UploadFile() { - using (FileStream istream = File.OpenRead(Input)) { - using (Stream ostream = targetFTP.OpenWrite(OutputName)) { - try { - CopyStream(istream, inputFile.Length, ostream); - } - catch (Exception e) { - logger.Error(e.Message); - throw e; - } - finally { - ostream.Close(); - } - } - } - FtpReply reply = targetFTP.GetReply(); - if (!reply.Success || !_226.Equals(reply.Code)) { - throw new Exception(UPLOAD_ERROR); - } - } - - protected void reconnect() { - TerminateClient(targetFTP); - targetFTP = CreateClient(parameters.TargetConfig.Remote); - EnsureDirectoryExistence(workingDir); - } - - protected override void UploadContent(string outputPath, byte[] content) { - using (Stream ostream = targetFTP.OpenWrite(outputPath, FtpDataType.Binary, false)) { - try { - ostream.Write(content, 0, content.Length); - } - catch (Exception e) { - logger.Error(e.Message); - throw e; - } - finally { - ostream.Close(); - } - } - FtpReply reply = targetFTP.GetReply(); - if (!reply.Success || !_226.Equals(reply.Code)) { - throw new Exception(UPLOAD_ERROR); - } - } - - protected override bool FileExists(string path) { - long x = -1; - try { - x = targetFTP.GetFileSize(path); - } - catch (Exception e) { - logger.Warn(e.Message); - } - return x > -1; - } - - protected override string GetOutputFilePath(string path, string fileName) { - return fileName; - } - - protected override void EnsureDirectoryExistence(string path) { - if (!targetFTP.DirectoryExists(path)) - targetFTP.CreateDirectory(path, true); - targetFTP.SetWorkingDirectory(path); - } - - protected FtpClient CreateClient(Connection connection) { - Uri address = connection.Address; - FtpClient result = new FtpClient() { - Host = address.Host, - Port = address.Port, - InternetProtocolVersions = FtpIpVersion.IPv4, - UploadDataType = FtpDataType.Binary, - DownloadDataType = FtpDataType.Binary, - Credentials = new NetworkCredential(connection.UserName, connection.Password) - }; - result.Connect(); - return result; - } - - protected override string DetermineWorkingDirectory(Connection connection) { - string result = null; - if (!String.IsNullOrEmpty(parameters.TargetConfig.SubFolderFormat)) { - string name = GetDynamicName(parameters.TargetConfig.SubFolderFormat); - //TODO ellenőrizni, hogy mi van placeholder esetén - if (parameters.TargetConfig.SubFolderFormat.Contains(PATTERN_TEXT)) { - string pattern = name.Split(HYPHEN[0])[0] + HYPHEN; - targetFTP.SetWorkingDirectory(connection.Address.LocalPath); - FtpListItem item = targetFTP.GetListing()?.Where(i => i.Type.Equals(FtpFileSystemObjectType.Directory) && i.Name.StartsWith(pattern)).FirstOrDefault(); - if (item != null) - name = item.Name; - targetFTP.SetWorkingDirectory(SLASH); - } - result = Path.Combine(connection.Address.LocalPath, name); - } else - result = connection.Address.LocalPath; - return result; - } - - protected void TerminateClient(FtpClient ftpClient) { - if (ftpClient != null) { - ftpClient.Disconnect(); - ftpClient.Dispose(); - } - } - - } -} diff --git a/client/Maestro/Targets/FXPTargetProcessor.cs b/client/Maestro/Targets/FXPTargetProcessor.cs deleted file mode 100644 index 48fa3894..00000000 --- a/client/Maestro/Targets/FXPTargetProcessor.cs +++ /dev/null @@ -1,115 +0,0 @@ -using FluentFTP; -using MaestroShared.Configuration; -using NLog; -using System; -using System.IO; -using System.Text.RegularExpressions; -using System.Threading; -using System.Windows.Forms; - -namespace Maestro.Targets { - - public class FXPTargetProcessor : FTPTargetProcessor { - private const string LITERAL_SPACE = "%20"; - private const string SPACE = " "; - private Logger logger = LogManager.GetCurrentClassLogger(); - private Source sourceConfig; - Uri inputUri; - - public FXPTargetProcessor(Control parent,TargetProcessorParameter parameters) : - base(parent, parameters) { - sourceConfig = parameters.SourceConfig; - //inputUri = new Uri(String.Format("{0}/{1}", parameters.SourceConfig.Remote.Address, parameters.InputFileName)); - inputUri = new Uri(Path.Combine(parameters.SourceConfig.Remote.Address.ToString(), parameters.InputFileName)); - Input = inputUri.ToString(); - } - - protected override void UploadFile() { - FtpClient sourceFTP = null; - FtpClient monitorFTP = null; - - try { - sourceFTP = CreateClient(sourceConfig.Remote); - - string input = inputUri.AbsolutePath.Replace(LITERAL_SPACE, SPACE); - long ilength = sourceFTP.GetFileSize(input); - if (parameters.TargetConfig.NexioServer) - ilength = ilength / 2; - - FtpReply replyPASV = targetFTP.Execute("PASV"); - if (!replyPASV.Success) - throw new Exception(replyPASV.ErrorMessage); - - Regex regex = new Regex(Regex.Escape("(") + "(.*)" + Regex.Escape(")")); - var v = regex.Match(replyPASV.Message); - string port = v.Groups[1].ToString(); - - FtpReply replyPORT = sourceFTP.Execute("PORT " + port); - if (!replyPORT.Success) - throw new Exception(replyPORT.ErrorMessage); - - - FtpReply sourceReplyTYPE = sourceFTP.Execute("TYPE I"); - if (!sourceReplyTYPE.Success) - throw new Exception(sourceReplyTYPE.ErrorMessage); - - if (input.LastIndexOf("/") == 0) - input = input.Replace("/", ""); - FtpReply replyRETR = sourceFTP.Execute("RETR " + input); - - if (!replyRETR.Success) { - input = inputUri.Segments[inputUri.Segments.Length - 1]; - input = input.Replace("%20", " "); - replyRETR = sourceFTP.Execute("RETR " + input); - - if (!replyRETR.Success) - throw new Exception(replyRETR.ErrorMessage); - } - - FtpReply targetReplyTYPE = targetFTP.Execute("TYPE I"); - if (!targetReplyTYPE.Success) - throw new Exception(targetReplyTYPE.ErrorMessage); - - string currentWorkingDir = targetFTP.GetWorkingDirectory(); - logger.Debug("Current target working directory is {0}", currentWorkingDir); - FtpReply replySTOR = targetFTP.Execute("STOR " + OutputName); - if (!replySTOR.Success) - throw new Exception(replySTOR.ErrorMessage); - - - monitorFTP = CreateClient(parameters.TargetConfig.Remote); - monitorFTP.SetWorkingDirectory(workingDir); - FtpReply monitorReplyTYPE = monitorFTP.Execute("TYPE I"); - if (!monitorReplyTYPE.Success) - throw new Exception(targetReplyTYPE.ErrorMessage); - if (!monitorFTP.FileExists(OutputName)) - throw new Exception("A cél állomány nem jött létre."); - long overall = 0; - long lastSize = 0; - while (overall != ilength) { - overall = monitorFTP.GetFileSize(OutputName); - if (overall == lastSize) { - Progress = 100; - break; - } else { - int currentProgress = (int)((double)overall / ilength * 100); - Progress = currentProgress > 100 ? 100 : currentProgress; - lastSize = overall; - } - Thread.Sleep(1000); - } - - } - catch (Exception e) { - throw e; - } - finally { - TerminateClient(monitorFTP); - TerminateClient(sourceFTP); - } - - //logger.Debug("Done"); - } - - } -} diff --git a/client/Maestro/Targets/ITargetProcessor.cs b/client/Maestro/Targets/ITargetProcessor.cs deleted file mode 100644 index 7a65be1a..00000000 --- a/client/Maestro/Targets/ITargetProcessor.cs +++ /dev/null @@ -1,31 +0,0 @@ -using System; -using System.ComponentModel; - -namespace Maestro.Targets { - internal interface ITargetProcessor : INotifyPropertyChanged { - - DateTime Started { get; set; } - - DateTime Finished { get; set; } - - string Input { get; set; } - - string Output { get; set; } - - string Status { get; set; } - - string Message { get; set; } - - string ID { get; set; } - - int Progress { get; set; } - - string KillDate { get; set; } - - string Label { get; set; } - - string KillDatePath { get; set; } - - bool Execute(); - } -} \ No newline at end of file diff --git a/client/Maestro/Targets/TargetProcessor.cs b/client/Maestro/Targets/TargetProcessor.cs deleted file mode 100644 index 7e98f7bd..00000000 --- a/client/Maestro/Targets/TargetProcessor.cs +++ /dev/null @@ -1,196 +0,0 @@ -using Maestro.Commons; -using System; -using System.ComponentModel; -using System.Runtime.CompilerServices; -using System.Windows.Forms; - -namespace Maestro.Targets { - public abstract class TargetProcessor : ITargetProcessor { - private string status; - private string message; - private string id; - private DateTime started; - private DateTime finished; - private string input; - private string output; - private string inputName; - private string outputName; - private int progress; - private string killDate; - private string label; - private string killDatePath; - protected Control parent; - - public TargetProcessor(Control parent) { - this.parent = parent; - } - - public event PropertyChangedEventHandler PropertyChanged; - - protected void NotifyPropertyChanged([CallerMemberName] String propertyName = "") { - parent?.SafeCall(() => { - PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); - }); - } - - public abstract bool Execute(); - - protected virtual void ExecuteCompleted() { - } - - public string Status { - get { - return status; - } - set { - if (status != value) { - status = value; - NotifyPropertyChanged(); - } - } - } - - public DateTime Started { - get { - return started; - } - set { - if (started != value) { - started = value; - NotifyPropertyChanged(); - } - } - } - - public DateTime Finished { - get { - return finished; - } - set { - if (finished != value) { - finished = value; - NotifyPropertyChanged(); - } - } - } - - public string Input { - get { - return input; - } - set { - if (input != value) { - input = value; - NotifyPropertyChanged(); - } - } - } - - public string Output { - get { - return output; - } - set { - if (output != value) { - output = value; - NotifyPropertyChanged(); - } - } - } - - public string InputName { - get { - return inputName; - } - set { - if (inputName != value) { - inputName = value; - NotifyPropertyChanged(); - } - } - } - - public string OutputName { - get { - return outputName; - } - set { - if (outputName != value) { - outputName = value; - NotifyPropertyChanged(); - } - } - } - - public string Message { - get { - return message; - } - set { - if (message != value) { - message = value; - NotifyPropertyChanged(); - } - } - } - - public string ID { - get { - return id; - } - set { - if (id != value) { - id = value; - NotifyPropertyChanged(); - } - } - } - - public int Progress { - get { - return progress; - } - set { - if (progress != value) { - progress = value; - NotifyPropertyChanged(); - } - } - } - - public string KillDate { - get { - return killDate; - } - set { - if (killDate != value) { - killDate = value; - NotifyPropertyChanged(); - } - } - } - - - public string Label { - get { return label; } - set { - //label != value biztos jó stringeknél? - if (label != value) { - label = value; - NotifyPropertyChanged(); - } - } - } - - public string KillDatePath { - get { return killDatePath; } - set { - //label != value biztos jó stringeknél? - if (killDatePath != value) { - killDatePath = value; - NotifyPropertyChanged(); - } - } - } - } -} \ No newline at end of file diff --git a/client/Maestro/Targets/UNCTargetProcessor.cs b/client/Maestro/Targets/UNCTargetProcessor.cs deleted file mode 100644 index 6ee00b07..00000000 --- a/client/Maestro/Targets/UNCTargetProcessor.cs +++ /dev/null @@ -1,357 +0,0 @@ -using NLog; -using System; -using System.IO; -using System.Windows.Forms; -using TrafficClient; -using Model; -using System.Text; -using Maestro.Commons; -using Commons; -using Maestro.Metadata; -using System.Globalization; -using System.Text.RegularExpressions; -using MaestroShared.Configuration; - -namespace Maestro.Targets { - - public class UNCTargetProcessor : TargetProcessor { - private readonly Logger logger = LogManager.GetCurrentClassLogger(); - private const string SUCCESS = "Successfully completed."; - private const string PROCESSING = "Processing {0}"; - private const string PROCESSING_COMPLETED = "Finished processing {0}"; - private const string FILENAME = "{0}{1}"; - private const string VERSIONED_FILENAME = "{0}-{1}{2}"; - private const string ALREADY_EXISTS = "File {0} already exists, trying {1}"; - private const string STATUS_FOLDER = ".STATUS"; - private const string KILLDATE_FILE = "{0}.{1}.killdate"; - private const string METADATA_FILE = "{0}.json"; - private const string DEFAULT_EXTENSION = ".MXF"; - private const string NORMALIZE_TEXT_PATTERN = "[^0-9A-Za-z-._]"; - protected const string UNDERSCORE = "_"; - protected const string HYPHEN = "-"; - private const string DATE_FORMAT = "yyyy.MM.dd"; - private const string PROGRAMME = "PROGRAMME"; - private const string COMMERCIAL = "COMMERCIAL"; - private const string JUNCTION = "JUNCTION"; - private const string XML_EXT = ".xml"; - private const string PATTERN_TARGETNAME = "%TARGETNAME%"; - protected const string PATTERN_TEXT = "%TEXT%"; - protected const string SLASH = "/"; - private const string INPROGRESS = "Folyamatban"; - private const string ERROR = "Hiba"; - private const string DOT = "."; - private const string HYPHENSTAR = "-*"; - private const string DATE_FORMAT_NODOTS = "yyyyMMdd"; - private const string READY = "Kész"; - private const string HYPHEN_SPACES = " - "; - private const string PATTERN_ID = "%ID%"; - private const string PATTERN_IDROOT = "%IDROOT%"; - private const string PATTERN_SOURCENAME = "%SOURCENAME%"; - private const string PATTERN_TIMESTAMP = "%TIMESTAMP%"; - private const string DATETIME_FORMAT = "yyyyMMddhhmmss"; - protected FileInfo inputFile; - protected string workingDir; - protected TargetProcessorParameter parameters; - - public WorkflowAction workFlowAction { get; set; } - - public UNCTargetProcessor(Control parent, TargetProcessorParameter parameters) - : base(parent) { - this.parameters = parameters; - InputName = parameters.InputFileName; - Input = Path.Combine(parameters.SourceConfig.Local.Address.LocalPath, parameters.InputFileName); - inputFile = new FileInfo(Input); - ID = parameters.ID; - workFlowAction = new WorkflowAction() { - houseId = ID, - tag = parameters.TargetConfig.Tag, - touched = DateTime.Now, - userName = TrayApplicationContext.UserName - }; - Label = parameters.TargetConfig.Label; - } - - protected virtual void BeforeExecute() { - Started = DateTime.Now; - workFlowAction.started = Started; - } - - public override bool Execute() { - logger.Info(PROCESSING, InputName); - bool result = false; - try { - BeforeExecute(); - workingDir = DetermineWorkingDirectory(parameters.TargetConfig.Remote); - EnsureDirectoryExistence(workingDir); - OutputName = CreateOutputFileName(); - OutputName = OutputName.ToUpper(); - Output = "/".Equals(workingDir) ? OutputName : Path.Combine(workingDir, OutputName); - Output = Output.Replace(@"\", "/"); - workFlowAction.source = Input; - workFlowAction.destination = Output; - Status = INPROGRESS; - //DateTime started = DateTime.Now; - string currentFile = GetOutputFilePath(workingDir, OutputName); - if (FileExists(currentFile) && parameters.TargetConfig.DisableFileVersioning) - DeleteFile(currentFile); - UploadFile(); - //logger.Info("Spend (s):" + (DateTime.Now - started).TotalSeconds); - ExecuteCompleted(); - } - catch (Exception e) { - Status = ERROR; - Message = e.Message; - workFlowAction.description = Message; - logger.Error(e); - if (parameters.TargetConfig.SendEmailOnError && !String.IsNullOrEmpty(parameters.TargetConfig.ErrorEmailRecipient) && !String.IsNullOrEmpty(parameters.TargetConfig.ErrorEmailPattern)) - SendEmail(parameters.TargetConfig.ErrorEmailRecipient, parameters.TargetConfig.ErrorEmailPattern); - } - finally { - AfterExecute(); - } - logger.Info(PROCESSING_COMPLETED, InputName); - return result; - } - - protected virtual void DeleteFile(string currentFile) { - File.Delete(currentFile); - } - - private string GetOutputName() { - if (String.IsNullOrEmpty(OutputName)) - return null; - string result = OutputName; - if (result.Contains(DOT)) - result = result.Substring(0, result.LastIndexOf(DOT)); - return result; - } - - protected override void ExecuteCompleted() { - base.ExecuteCompleted(); - workFlowAction.description = SUCCESS; - workFlowAction.successful = true; - if (parameters.TargetConfig.NexioServer) - UploadNexioMetadata(); - else { - if (parameters.TargetConfig.KillDateDays > 0) - UploadKillDateFile(); - } - - if (parameters.TargetConfig.SaveArchiveMetadata && parameters.ArchiveMetadata != null) - CreateArchiveMetadata(); - if (parameters.TargetConfig.SaveMorpheusMetadata && parameters.ArchiveMetadata != null && parameters.MovieSegments != null && parameters.MovieSegments.Count > 0) - UploadMorpheusMetadata(); - if (parameters.TargetConfig.SaveSegments && parameters.Segments != null) - parameters.TrafficApi.UpdateTrafficInformation(parameters.VariantID, true, (TrafficMetadataType)parameters.MetadataKind, parameters.Segments); - - if (parameters.TargetConfig.SendEmailOnSuccess && !String.IsNullOrEmpty(parameters.TargetConfig.SuccessEmailRecipient) && !String.IsNullOrEmpty(parameters.TargetConfig.SuccessEmailPattern)) - SendEmail(parameters.TargetConfig.SuccessEmailRecipient, parameters.TargetConfig.SuccessEmailPattern); - Status = READY; - Message = SUCCESS; - } - - private void UploadNexioMetadata() { - String xml = null; - string name = GetOutputName(); - string description = parameters.ArchiveMetadata?.mediaTitle; - if (parameters.TargetConfig.KillDateDays > 0) { - DateTime date = GetKillDate(); - KillDate = date.ToString(DATE_FORMAT); - xml = NexioXML.ToXML(name, date, description, parameters.TargetConfig.Agency); - } else - xml = NexioXML.ToXML(name, null, description, parameters.TargetConfig.Agency); - byte[] content = Encoding.Unicode.GetBytes(xml); - UploadContent(name + XML_EXT, content); - } - - private void UploadMorpheusMetadata() { - string name = GetOutputName(); - string title = parameters.ArchiveMetadata?.itemTitle; - if (!title.Equals(parameters.ArchiveMetadata?.mediaTitle)) - title += HYPHEN_SPACES + parameters.ArchiveMetadata?.mediaTitle; - string type = null; - switch (parameters.MetadataKind) { - case MetadataType.TrafficMaterial: - type = PROGRAMME; - break; - case MetadataType.TrafficPromo: - type = COMMERCIAL; - break; - case MetadataType.TrafficAD: - type = JUNCTION; - break; - } - byte[] content = MorpheusXML.ToXML(title, name, parameters.TargetConfig.DeviceIDMorpheus, type, parameters.MovieSegments); - EnsureDirectoryExistence(parameters.TargetConfig.PathMorpheusMetadata); - UploadContent(name + XML_EXT, content); - } - - private void SendEmail(string to, string messagePattern) { - try { - string message = messagePattern.Replace(PATTERN_TARGETNAME, OutputName); - parameters.MediaCubeApi.Notify(to, message); - } - catch (Exception e) { - MessageBox.Show(parent, e.Message); - } - } - - protected virtual void AfterExecute() { - Finished = DateTime.Now; - workFlowAction.finished = Finished; - SendWorkFlowAction(); - Progress = 0; - } - - protected virtual bool FileExists(string path) { - return File.Exists(path); - } - - private void SendWorkFlowAction() { - try { - parameters.MediaCubeApi.Create(workFlowAction); - } - catch (Exception e) { - MessageBox.Show(parent, e.Message); - } - } - - protected virtual string DetermineWorkingDirectory(Connection connection) { - string result = null; - if (!String.IsNullOrEmpty(parameters.TargetConfig.SubFolderFormat)) { - string name = GetDynamicName(parameters.TargetConfig.SubFolderFormat); - if (parameters.TargetConfig.SubFolderFormat.Contains(PATTERN_TEXT)) { - string pattern = name.Split(HYPHEN[0])[0] + HYPHENSTAR; - string[] dirs = Directory.GetDirectories(connection.Address.LocalPath, pattern); - if (dirs.Length > 0) - name = dirs[0]; - } - result = Path.Combine(connection.Address.LocalPath, name); - } else - result = connection.Address.LocalPath; - return result; - } - - private DateTime GetKillDate() { - DateTime result = DateTime.Now; - result = result.AddDays(parameters.TargetConfig.KillDateDays); - return result; - } - - private void UploadKillDateFile() { - Uri address = parameters.TargetConfig.Remote.Address; - string statusWorkDir = Path.Combine(workingDir, STATUS_FOLDER); - EnsureDirectoryExistence(statusWorkDir); - DateTime date = GetKillDate(); - string fileName = String.Format(KILLDATE_FILE, OutputName, date.ToString(DATE_FORMAT_NODOTS)); - //logger.Debug("Creating KILLDATE status file {0}", fileName); - KillDatePath = GetOutputFilePath(statusWorkDir, fileName); - UploadContent(KillDatePath, new byte[] { }); - KillDate = date.ToString(DATE_FORMAT); - } - - private void CreateArchiveMetadata() { - Uri address = parameters.TargetConfig.Remote.Address; - string statusWorkDir = Path.Combine(workingDir, STATUS_FOLDER); - EnsureDirectoryExistence(statusWorkDir); - string fileName = String.Format(METADATA_FILE, OutputName); - //logger.Debug("Creating METADATA file {0}", fileName); - byte[] content = Encoding.UTF8.GetBytes(parameters.ArchiveMetadata.ToString()); - string ouputPath = GetOutputFilePath(statusWorkDir, fileName); - UploadContent(ouputPath, content); - } - - private void CreateTrafficMetadata() { - Uri address = parameters.TargetConfig.Remote.Address; - string statusWorkDir = Path.Combine(workingDir, STATUS_FOLDER); - EnsureDirectoryExistence(statusWorkDir); - string fileName = String.Format(METADATA_FILE, OutputName); - //logger.Debug("Creating METADATA file {0}", fileName); - byte[] content = Encoding.UTF8.GetBytes(parameters.ArchiveMetadata.ToString()); - string ouputPath = GetOutputFilePath(statusWorkDir, fileName); - UploadContent(ouputPath, content); - } - - protected void CopyStream(Stream istream, long ilength, Stream ostream) { - byte[] buffer = new byte[32768]; - int read, overall = 0; - while ((read = istream.Read(buffer, 0, buffer.Length)) > 0) { - ostream.Write(buffer, 0, read); - ostream.Flush(); - overall += read; - Progress = (int)((double)overall / ilength * 100); - } - } - - protected virtual void UploadContent(string outputPath, byte[] content) { - File.WriteAllBytes(outputPath, content); - } - - private CopyProgressResult CopyProgressHandler(long total, long transferred, long streamSize, long StreamByteTrans, uint dwStreamNumber, CopyProgressCallbackReason reason, IntPtr hSourceFile, IntPtr hDestinationFile, IntPtr lpData) { - if (transferred > 0) - Progress = (int)((double)transferred * 100 / total); - return CopyProgressResult.PROGRESS_CONTINUE; - } - - protected virtual void UploadFile() { - int pbCancel = 0; - Win32File.CopyFileEx(Input, Output, new CopyProgressRoutine(this.CopyProgressHandler), IntPtr.Zero, ref pbCancel, CopyFileFlags.COPY_FILE_RESTARTABLE); - } - - protected virtual string GetOutputFilePath(string path, string fileName) { - return "/".Equals(workingDir) ? fileName : Path.Combine(path, fileName); - } - - public static String RemoveDiacritics(String s) { - String normalizedString = s.Normalize(NormalizationForm.FormD); - StringBuilder stringBuilder = new StringBuilder(); - - for (int i = 0; i < normalizedString.Length; i++) { - Char c = normalizedString[i]; - if (CharUnicodeInfo.GetUnicodeCategory(c) != UnicodeCategory.NonSpacingMark) - stringBuilder.Append(c); - } - - return stringBuilder.ToString(); - } - - protected string GetDynamicName(string text) { - string idRoot = ID.Contains(UNDERSCORE) ? ID.Split(UNDERSCORE[0])[0] : ID; - string result = text - .Replace(PATTERN_ID, ID) - .Replace(PATTERN_IDROOT, idRoot) - .Replace(PATTERN_TEXT, HYPHEN + RemoveDiacritics(parameters.MetadataText)) - .Replace(PATTERN_SOURCENAME, Path.GetFileNameWithoutExtension(InputName)) - .Replace(PATTERN_TIMESTAMP, DateTime.Now.ToString(DATETIME_FORMAT, CultureInfo.InvariantCulture)); - // replace hungarian and special characters - result = Regex.Replace(result, NORMALIZE_TEXT_PATTERN, UNDERSCORE); - if (result.Length > 100) - result = result.Substring(0, 100); - return result; - } - - protected virtual string CreateOutputFileName() { - string nameWithoutExtension = GetDynamicName(parameters.TargetConfig.OutputFormat); - string extension = InputName.Contains(DOT) ? InputName.Substring(InputName.LastIndexOf(DOT)) : DEFAULT_EXTENSION; - extension = extension.ToUpper(); - string result = String.Format(FILENAME, nameWithoutExtension, extension); - if (!parameters.TargetConfig.DisableFileVersioning) { - int version = 1; - while (FileExists(GetOutputFilePath(workingDir, result))) { - string versioned = String.Format(VERSIONED_FILENAME, nameWithoutExtension, version, extension); - logger.Debug(ALREADY_EXISTS, result, versioned); - result = versioned; - version++; - } - } - return result; - } - - protected virtual void EnsureDirectoryExistence(string path) { - if (!Directory.Exists(path)) - Directory.CreateDirectory(path); - } - - - } -} diff --git a/client/Maestro/Commons/MorpheusXML.cs b/client/MaestroShared/Commons/MorpheusXML.cs similarity index 97% rename from client/Maestro/Commons/MorpheusXML.cs rename to client/MaestroShared/Commons/MorpheusXML.cs index 828911af..bfb789fd 100644 --- a/client/Maestro/Commons/MorpheusXML.cs +++ b/client/MaestroShared/Commons/MorpheusXML.cs @@ -1,5 +1,4 @@ -using DxPlay; -using Maestro.Metadata; +using MaestroShared.Metadata; using System; using System.Collections.Generic; using System.Globalization; @@ -25,7 +24,7 @@ using System.Xml; */ -namespace Commons { +namespace MaestroShared.Commons { public class MorpheusXML { diff --git a/client/Maestro/Commons/NexioXML.cs b/client/MaestroShared/Commons/NexioXML.cs similarity index 95% rename from client/Maestro/Commons/NexioXML.cs rename to client/MaestroShared/Commons/NexioXML.cs index 05fb32a2..dc37821c 100644 --- a/client/Maestro/Commons/NexioXML.cs +++ b/client/MaestroShared/Commons/NexioXML.cs @@ -10,7 +10,7 @@ using System.Xml; AGENT AGENT */ -namespace Commons { +namespace MaestroShared.Commons { public class NexioXML { public static string ToXML(string fileName, DateTime? killDate, string description, string agency) { diff --git a/client/Maestro/Commons/ObjectExtensions.cs b/client/MaestroShared/Commons/ObjectExtensions.cs similarity index 88% rename from client/Maestro/Commons/ObjectExtensions.cs rename to client/MaestroShared/Commons/ObjectExtensions.cs index be3cb5a2..7be04103 100644 --- a/client/Maestro/Commons/ObjectExtensions.cs +++ b/client/MaestroShared/Commons/ObjectExtensions.cs @@ -1,7 +1,7 @@ using System; using System.Windows.Forms; -namespace Maestro.Commons { +namespace MaestroShared.Commons { public static class ObjectExtensions { public static void SafeCall(this Control ctrl, Action x, bool force = false) { diff --git a/client/Maestro/Commons/Win32File.cs b/client/MaestroShared/Commons/Win32File.cs similarity index 95% rename from client/Maestro/Commons/Win32File.cs rename to client/MaestroShared/Commons/Win32File.cs index dd846a50..03328281 100644 --- a/client/Maestro/Commons/Win32File.cs +++ b/client/MaestroShared/Commons/Win32File.cs @@ -1,7 +1,7 @@ using System; using System.Runtime.InteropServices; -namespace Maestro.Commons { +namespace MaestroShared.Commons { public enum CopyProgressResult : uint { PROGRESS_CONTINUE = 0, PROGRESS_CANCEL = 1, diff --git a/client/Maestro/Targets/SegmentConverter.cs b/client/MaestroShared/Metadata/SegmentConverter.cs similarity index 86% rename from client/Maestro/Targets/SegmentConverter.cs rename to client/MaestroShared/Metadata/SegmentConverter.cs index 31bbd358..1f631ac2 100644 --- a/client/Maestro/Targets/SegmentConverter.cs +++ b/client/MaestroShared/Metadata/SegmentConverter.cs @@ -1,8 +1,7 @@ -using DxPlay; -using TrafficClient; +using TrafficClient; -namespace Maestro.Targets { - class SegmentConverter { +namespace MaestroShared.Metadata { + public class SegmentConverter { public MovieSegment ConvertToMovieSegment(Segment source) { Timecode tcIn = new Timecode(); -- 2.54.0