From 13f5ec6052f528d995df071eea5223b3e0031265 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Bellai=20=C3=81d=C3=A1m?= Date: Fri, 29 Sep 2017 11:50:24 +0000 Subject: [PATCH] git-tfs-id: [http://tfs.userrendszerhaz.hu:8080/tfs/DefaultCollection]$/MediaCube;C30485 --- client/IntegrationTests/MaestroIT.cs | 3 +- client/Maestro/ArchiveMetadata.Designer.cs | 1 + client/Maestro/ArchiveMetadata.cs | 12 +++- .../Configuration/ConfigurationInfo.cs | 1 + client/Maestro/MaestroForm.Metadata.cs | 60 ++--------------- client/Maestro/MaestroForm.Source.cs | 5 +- client/Maestro/MaestroForm.Target.cs | 67 +++++++++++++++++-- client/Maestro/Metadata/ArchiveMetadata.cs | 5 ++ .../Maestro/Resources/configuration-unc.json | 1 + client/Maestro/StringResources.Designer.cs | 9 +++ client/Maestro/StringResources.resx | 3 + client/Maestro/Targets/FTPTargetProcessor.cs | 53 ++++++++++++--- client/Maestro/Targets/FXPTargetProcessor.cs | 5 +- client/Maestro/Targets/TargetProcessor.cs | 7 +- client/OctopusClient/Resources.Designer.cs | 9 +++ client/OctopusClient/Resources.resx | 3 + .../TrafficIDSelector.Designer.cs | 10 +++ client/PlanAIRClient/TrafficIDSelector.cs | 22 +++--- 18 files changed, 186 insertions(+), 90 deletions(-) diff --git a/client/IntegrationTests/MaestroIT.cs b/client/IntegrationTests/MaestroIT.cs index e9ef00c2..2ab62d64 100644 --- a/client/IntegrationTests/MaestroIT.cs +++ b/client/IntegrationTests/MaestroIT.cs @@ -17,8 +17,7 @@ namespace IntegrationTests { }, OutputFormat = "{0}_{1}_{2}" }; - //todo utolsó paraméterként szegmens lista átadása - FTPTargetProcessor sut = new FTPTargetProcessor(null, null, configuration, @"c:\tmp\watch\tcdrone.MXF", "000000", null); + FTPTargetProcessor sut = new FTPTargetProcessor(null, null, configuration, @"c:\tmp\watch\tcdrone.MXF", "000000", null, null, null); sut.Execute(); } diff --git a/client/Maestro/ArchiveMetadata.Designer.cs b/client/Maestro/ArchiveMetadata.Designer.cs index 737d7eb2..777450f3 100644 --- a/client/Maestro/ArchiveMetadata.Designer.cs +++ b/client/Maestro/ArchiveMetadata.Designer.cs @@ -202,6 +202,7 @@ this.button_cancel.TabIndex = 0; this.button_cancel.Text = "Cancel"; this.button_cancel.UseVisualStyleBackColor = true; + this.button_cancel.Click += new System.EventHandler(this.button_cancel_Click); // // button_ok // diff --git a/client/Maestro/ArchiveMetadata.cs b/client/Maestro/ArchiveMetadata.cs index 0217f905..ea56eca2 100644 --- a/client/Maestro/ArchiveMetadata.cs +++ b/client/Maestro/ArchiveMetadata.cs @@ -25,7 +25,17 @@ namespace Maestro { } private void button_ok_Click(object sender, System.EventArgs e) { - //todo + model.StuffID = textBox_stuffID.Text; + model.StuffTitle = textBox_stuffTitle.Text; + model.StuffDescription = textBox_stuffDescription.Text; + model.MediaID = textBox_mediaID.Text; + model.MediaTitle = textBox_mediaTitle.Text; + model.MediaDescription = textBox_mediaDescription.Text; + Dispose(); + } + + private void button_cancel_Click(object sender, System.EventArgs e) { + Dispose(); } } } diff --git a/client/Maestro/Configuration/ConfigurationInfo.cs b/client/Maestro/Configuration/ConfigurationInfo.cs index 8d6d7abd..79e2103e 100644 --- a/client/Maestro/Configuration/ConfigurationInfo.cs +++ b/client/Maestro/Configuration/ConfigurationInfo.cs @@ -48,6 +48,7 @@ namespace Maestro.Configuration { public bool SaveSegments { get; set; } public bool CreateSubFolder { get; set; } public string Tag { get; set; } + public bool UseMetadata {get; set;} } public class Connection { diff --git a/client/Maestro/MaestroForm.Metadata.cs b/client/Maestro/MaestroForm.Metadata.cs index 5dc07076..a760f5a3 100644 --- a/client/Maestro/MaestroForm.Metadata.cs +++ b/client/Maestro/MaestroForm.Metadata.cs @@ -10,12 +10,13 @@ using System.Collections.Generic; using System.ComponentModel; using System.Text.RegularExpressions; using JobEngineClient; + namespace Maestro { public partial class MaestroForm { private MetadataInfo selectedMetadata; private List segments = new List(); private MediaCubeApi mediaCubeApi; - + private ArchiveMetadataModel model; public MetadataInfo SelectedMetadata { get { return selectedMetadata; @@ -74,64 +75,11 @@ namespace Maestro { } private void ModifyArchiveMetadataClick(object sender, EventArgs e) { - ArchiveMetadata form = null; - IDTypes idType = GetTypeOfSelectedMetadata(); - ArchiveMetadataModel model = new ArchiveMetadataModel(); - Cursor.Current = Cursors.WaitCursor; - if (idType == IDTypes.OctopusID) - FillTheModelFromOctopus(model); - else if (idType == IDTypes.TrafficID) - FillTheModelFromTraffic(model); - form = new ArchiveMetadata(model); + ArchiveMetadata form = new ArchiveMetadata(model); form.ShowDialog(); } - private void FillTheModelFromTraffic(ArchiveMetadataModel model) { - string id = selectedMetadata.ID; - TrafficAPI api = trafficIDSelector.trafficAPI; - List result = api.SearchArchiveMetadata(id); ; - ArchiveMatadataWrapper actualResult = result[0]; - model.StuffID = actualResult.ProgID; - model.StuffTitle = actualResult.ProgTitle; - model.StuffDescription = actualResult.ProgDescription; - model.MediaID = actualResult.EpisodeID; - model.MediaTitle = String.IsNullOrEmpty(actualResult.EpisodeTitle) ? actualResult.EpisodeTitle : actualResult.ProgTitle; - model.MediaDescription = actualResult.EpisodeDescription; - } - - private void FillTheModelFromOctopus(ArchiveMetadataModel model) { - string id = selectedMetadata.ID; - OctopusAPI api = octopusIDSelector.GetClient(); - IEnumerable storyEnum = api.GetStoriesById(id); - if (storyEnum != null) { - FillModelFromStories(model, storyEnum.ToList(), api); - } else { - //List mosObjectsEnum = api.GetMosObjectsByID(id).ToList(); - //MosObject mosObject = mosObjectsEnum[0]; - List stories = api.GetStoriesByPlaceHolderId(id).ToList(); - FillModelFromStories(model, stories, api); - //todo ha mosObject, mivel töltsem fel a model-t? - } - } - - private void FillModelFromStories(ArchiveMetadataModel model, List stories, OctopusAPI api) { - Story story = stories[0]; - if (story.StoryFolders != null) { - List storyFolders = api.GetStoryFoldersByStoryID(story.ID).ToList(); - StoryFolder folder = storyFolders[0]; - model.StuffID = folder.ID; - model.StuffTitle = folder.Name; - } else if (story.Rundowns != null) { - List rundowns = api.GetRundownsByStoryID(story.ID).ToList(); - Rundown rundown = rundowns[0]; - model.StuffID = rundown.ID; - model.StuffTitle = rundown.Name; - model.StuffDescription = rundown.Start; - } - model.MediaID = story.ID; - model.MediaTitle = story.Name; - model.MediaDescription = story.Script; - } + private IDTypes GetTypeOfSelectedMetadata() { IDTypes result = IDTypes.None; diff --git a/client/Maestro/MaestroForm.Source.cs b/client/Maestro/MaestroForm.Source.cs index d3488845..abd0eced 100644 --- a/client/Maestro/MaestroForm.Source.cs +++ b/client/Maestro/MaestroForm.Source.cs @@ -187,8 +187,9 @@ namespace Maestro { } private void SetSelectedSourceFileInfo(SourceInfo selectedSource) { - //todo ha nexio-s akkor null a fileinfo - if (selectedSources.Count == 1) { + if (Configuration.Source.GetType() == typeof(NEXIOSource)) + selectedSource.FileInfo = null; + else if (selectedSources.Count == 1) { Uri inputUri = new Uri(String.Format("{0}/{1}", Configuration.Source.Local.Address.LocalPath, selectedSources[0])); selectedSource.FileInfo = new System.IO.FileInfo(inputUri.LocalPath); } diff --git a/client/Maestro/MaestroForm.Target.cs b/client/Maestro/MaestroForm.Target.cs index a8e31f34..96ac62b0 100644 --- a/client/Maestro/MaestroForm.Target.cs +++ b/client/Maestro/MaestroForm.Target.cs @@ -8,6 +8,7 @@ using Maestro.Metadata; using System.Collections.Generic; using System.Text.RegularExpressions; using TrafficClient; +using OctopusClient; namespace Maestro { public partial class MaestroForm { @@ -42,18 +43,15 @@ namespace Maestro { foreach (String actual in selectedSources) { string typeName = string.Format("{0}.{1}", typeof(ITargetProcessor).Namespace, target.Processor); Type type = Type.GetType(typeName); - - //ISourceItem actualFile = new FileSourceItem() { FileInfo = new System.IO.FileInfo(actual), }; ISourceItem selectedFile = GetSourceItemFromBindingSource(actual);//bindingSource.Current as ISourceItem; string id = selectedMetadata.ID; - object[] parameters = new object[] { this, Configuration.Source, target, selectedFile.Name, id, segments, mediaCubeApi }; + object[] parameters = new object[] { this, Configuration.Source, target, selectedFile.Name, id, segments, mediaCubeApi, model }; ITargetProcessor processor = (ITargetProcessor)Activator.CreateInstance(type, parameters); processors.Add(processor); } currentProcessors.Add(checkBox, processors); } else currentProcessors.Remove(checkBox); - btnExecute.Enabled = currentProcessors.Count > 0; }; @@ -106,11 +104,68 @@ namespace Maestro { ChangeProcessButtonsState(false); } - ctxiModifyArchiveMetadata.Enabled = selectedMetadata != null; - if (Configuration.Player != null) ctxiDefineSegments.Enabled = SelectedSource?.FileInfo != null && Configuration.Player.SegmentEditor && MetadataType.Traffic.Equals(SelectedMetadata?.Kind); IsSelectedFileAnID(); + EnableArchiveMetadataButtonAndCreateMetadataModel(); + } + + private void EnableArchiveMetadataButtonAndCreateMetadataModel() { + ctxiModifyArchiveMetadata.Enabled = selectedMetadata != null; + if (ctxiModifyArchiveMetadata.Enabled) { + model = new ArchiveMetadataModel(); + Cursor.Current = Cursors.WaitCursor; + IDTypes idType = GetTypeOfSelectedMetadata(); + if (idType == IDTypes.OctopusID) + FillTheModelFromOctopus(model); + else if (idType == IDTypes.TrafficID) + FillTheModelFromTraffic(model); + } else + model = null; + } + + private void FillTheModelFromTraffic(ArchiveMetadataModel model) { + string id = selectedMetadata.ID; + TrafficAPI api = trafficIDSelector.trafficAPI; + List result = api.SearchArchiveMetadata(id); ; + ArchiveMatadataWrapper actualResult = result[0]; + model.StuffID = actualResult.ProgID; + model.StuffTitle = actualResult.ProgTitle; + model.StuffDescription = actualResult.ProgDescription; + model.MediaID = actualResult.EpisodeID; + model.MediaTitle = String.IsNullOrEmpty(actualResult.EpisodeTitle) ? actualResult.EpisodeTitle : actualResult.ProgTitle; + model.MediaDescription = actualResult.EpisodeDescription; + } + + private void FillTheModelFromOctopus(ArchiveMetadataModel model) { + string id = selectedMetadata.ID; + OctopusAPI api = octopusIDSelector.GetClient(); + IEnumerable storyEnum = api.GetStoriesById(id); + if (storyEnum != null) + FillModelFromStories(model, storyEnum.ToList(), api); + else { + List stories = api.GetStoriesByPlaceHolderId(id).ToList(); + FillModelFromStories(model, stories, api); + } + } + + private void FillModelFromStories(ArchiveMetadataModel model, List stories, OctopusAPI api) { + Story story = stories[0]; + if (story.StoryFolders != null) { + List storyFolders = api.GetStoryFoldersByStoryID(story.ID).ToList(); + StoryFolder folder = storyFolders[0]; + model.StuffID = folder.ID; + model.StuffTitle = folder.Name; + } else if (story.Rundowns != null) { + List rundowns = api.GetRundownsByStoryID(story.ID).ToList(); + Rundown rundown = rundowns[0]; + model.StuffID = rundown.ID; + model.StuffTitle = rundown.Name; + model.StuffDescription = rundown.Start; + } + model.MediaID = story.ID; + model.MediaTitle = story.Name; + model.MediaDescription = story.Script; } private void IsSelectedFileAnID() { diff --git a/client/Maestro/Metadata/ArchiveMetadata.cs b/client/Maestro/Metadata/ArchiveMetadata.cs index 92227c8e..676b4303 100644 --- a/client/Maestro/Metadata/ArchiveMetadata.cs +++ b/client/Maestro/Metadata/ArchiveMetadata.cs @@ -14,5 +14,10 @@ namespace Maestro.Metadata { public string MediaID { get; set; } public string MediaTitle { get; set; } public string MediaDescription { get; set; } + + public override string ToString() { + 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); + } } } diff --git a/client/Maestro/Resources/configuration-unc.json b/client/Maestro/Resources/configuration-unc.json index 127416c5..36d46875 100644 --- a/client/Maestro/Resources/configuration-unc.json +++ b/client/Maestro/Resources/configuration-unc.json @@ -67,6 +67,7 @@ "killDateDays": 1, "tag": "tag", "createSubFolder": true, + "useMetadata": true, "remote": { "address": "ftp://localhost:21/out", "userName": "dani", diff --git a/client/Maestro/StringResources.Designer.cs b/client/Maestro/StringResources.Designer.cs index d7519f7c..b889828e 100644 --- a/client/Maestro/StringResources.Designer.cs +++ b/client/Maestro/StringResources.Designer.cs @@ -87,6 +87,15 @@ namespace Maestro { } } + /// + /// Looks up a localized string similar to Archive. + /// + internal static string ARCHIVE { + get { + return ResourceManager.GetString("ARCHIVE", resourceCulture); + } + } + /// /// Looks up a localized string similar to Befejezés. /// diff --git a/client/Maestro/StringResources.resx b/client/Maestro/StringResources.resx index 8b6ca6cc..4aa791b6 100644 --- a/client/Maestro/StringResources.resx +++ b/client/Maestro/StringResources.resx @@ -123,6 +123,9 @@ Állapot + + Archive + Archív metaadatok módosítása diff --git a/client/Maestro/Targets/FTPTargetProcessor.cs b/client/Maestro/Targets/FTPTargetProcessor.cs index bebdde15..e3d59b0f 100644 --- a/client/Maestro/Targets/FTPTargetProcessor.cs +++ b/client/Maestro/Targets/FTPTargetProcessor.cs @@ -9,6 +9,7 @@ using System.Collections.Generic; using TrafficClient; using Model; using JobEngineClient; +using Maestro.Metadata; namespace Maestro.Targets { @@ -29,12 +30,13 @@ namespace Maestro.Targets { public WorkflowAction workFlowAction { get; set; } - public FTPTargetProcessor(Control parent, Source sourceConfig, Target targetConfig, string inputFileName, string id, List segments, MediaCubeApi mediaCubeApi) : base(parent, targetConfig, segments) { + public FTPTargetProcessor(Control parent, Source sourceConfig, Target targetConfig, string inputFileName, string id, List segments, MediaCubeApi mediaCubeApi, ArchiveMetadataModel model) + : base(parent, targetConfig, segments, model) { FtpTrace.LogFunctions = false; this.mediaCubeApi = mediaCubeApi; this.targetConfig = targetConfig; Uri inputUri = new Uri(String.Format("{0}/{1}", sourceConfig.Local.Address.LocalPath, inputFileName)); - inputFile = new FileInfo(inputUri.LocalPath); + inputFile = new FileInfo(inputUri.LocalPath); Input = inputFile.FullName; ID = id; workFlowAction = new WorkflowAction() { houseId = ID, tag = targetConfig.Tag, touched = DateTime.Now }; @@ -48,7 +50,7 @@ namespace Maestro.Targets { try { SetSubFolder(targetConfig.Remote); targetFTP = CreateClient(targetConfig.Remote); - EnsureDirectoryExistence(targetFTP); + EnsureDirectoryExistence(targetFTP, workingDir); Status = ProcessStatus.Progress; Output = CreateOutputFileName(); workFlowAction.destination = Path.Combine(workingDir, Output).Replace("\\", "/"); @@ -56,6 +58,8 @@ namespace Maestro.Targets { UploadFile(Output); if (targetConfig.KillDateDays > 0) UploadKillDateFile(targetConfig.Remote, Output); + if (targetConfig.UseMetadata) + UseMetadata(); ExecuteCompleted(); Status = ProcessStatus.Completed; Message = SUCCESS; @@ -77,11 +81,40 @@ namespace Maestro.Targets { return result; } + private void UseMetadata() { + if (model != null) { + string path = String.Format("{0}//.store", workingDir); + string fileName = "metadata.json"; + EnsureDirectoryExistence(targetFTP, path); + string finalFileName = GetVersionedFileName(fileName); + using (Stream ostream = targetFTP.OpenWrite(finalFileName)) { + string s = model.ToString(); + byte[] content = System.Text.Encoding.UTF8.GetBytes(s); + ostream.Write(content, 0, content.Length); + } + } + } + + private string GetVersionedFileName(string fileName) { + string result = fileName; + string nameWithoutExtension = String.Format(Path.GetFileNameWithoutExtension(fileName)); + string extension = Path.GetExtension(fileName); + int version = 0; + while (targetFTP.FileExists(result)) { + string versioned = String.Format(VERSIONED_FILENAME, nameWithoutExtension, version, extension); + logger.Debug(ALREADY_EXISTS, result, versioned); + result = versioned; + version++; + } + return result; + } + private void SendWorkFlowAction() { try { mediaCubeApi.Create(workFlowAction); - } catch (Exception e) { - MessageBox.Show(parent , e.Message); + } + catch (Exception e) { + MessageBox.Show(parent, e.Message); } } @@ -96,7 +129,7 @@ namespace Maestro.Targets { private void UploadKillDateFile(Connection connection, string output) { Uri address = connection.Address; string statusWorkDir = Path.Combine(address.PathAndQuery, STATUS_FOLDER).Replace("\\", "/"); - EnsureDirectoryExistence(targetFTP); + EnsureDirectoryExistence(targetFTP, workingDir); DateTime date = DateTime.Now; date = date.AddDays(targetConfig.KillDateDays); string fileName = String.Format(KILLDATE_FILE, output, date.ToString("yyyyMMdd")); @@ -142,10 +175,10 @@ namespace Maestro.Targets { } - private void EnsureDirectoryExistence(FtpClient client) { - if (!client.DirectoryExists(workingDir)) - client.CreateDirectory(workingDir, true); - client.SetWorkingDirectory(workingDir); + private void EnsureDirectoryExistence(FtpClient client, string path) { + if (!client.DirectoryExists(path)) + client.CreateDirectory(path, true); + client.SetWorkingDirectory(path); } protected FtpClient CreateClient(Connection connection) { diff --git a/client/Maestro/Targets/FXPTargetProcessor.cs b/client/Maestro/Targets/FXPTargetProcessor.cs index 5d405dca..abdb796b 100644 --- a/client/Maestro/Targets/FXPTargetProcessor.cs +++ b/client/Maestro/Targets/FXPTargetProcessor.cs @@ -9,6 +9,7 @@ using System.Windows.Forms; using System.Collections.Generic; using TrafficClient; using JobEngineClient; +using Maestro.Metadata; namespace Maestro.Targets { @@ -16,8 +17,8 @@ namespace Maestro.Targets { private Logger logger = LogManager.GetCurrentClassLogger(); private Source sourceConfig; - public FXPTargetProcessor(Control parent, Source sourceConfig, Target targetConfig, string inputFileName, string id, List segments, MediaCubeApi mediaCubeApi ) : - base(parent, sourceConfig, targetConfig, inputFileName, id, segments, mediaCubeApi) { + public FXPTargetProcessor(Control parent, Source sourceConfig, Target targetConfig, string inputFileName, string id, List segments, MediaCubeApi mediaCubeApi, ArchiveMetadataModel model) : + base(parent, sourceConfig, targetConfig, inputFileName, id, segments, mediaCubeApi, model) { this.sourceConfig = sourceConfig; } diff --git a/client/Maestro/Targets/TargetProcessor.cs b/client/Maestro/Targets/TargetProcessor.cs index 1488d3c1..18b935d0 100644 --- a/client/Maestro/Targets/TargetProcessor.cs +++ b/client/Maestro/Targets/TargetProcessor.cs @@ -7,7 +7,7 @@ using System.Windows.Forms; using System.Collections.Generic; using Maestro.Configuration; using TrafficClient; -using DxPlay; +using Maestro.Metadata; namespace Maestro.Targets { public abstract class TargetProcessor : ITargetProcessor { @@ -23,8 +23,11 @@ namespace Maestro.Targets { protected Target targetConfig; protected TrafficAPI client; protected List segments; - public TargetProcessor(Control parent, Target targetConfig, List segments) { + protected ArchiveMetadataModel model; + + public TargetProcessor(Control parent, Target targetConfig, List segments, ArchiveMetadataModel model) { this.parent = parent; + this.model = model; MaestroForm maestroForm = parent as MaestroForm; TrafficMetadata metadata = maestroForm.Configuration.Metadatas.Where(m => { return m is TrafficMetadata; }).FirstOrDefault() as TrafficMetadata; client = new TrafficAPI(metadata.Server.Address.OriginalString, metadata.Server.UserName, metadata.Server.Password, metadata.Server.Timeout); diff --git a/client/OctopusClient/Resources.Designer.cs b/client/OctopusClient/Resources.Designer.cs index 6cf734a1..abda2f3f 100644 --- a/client/OctopusClient/Resources.Designer.cs +++ b/client/OctopusClient/Resources.Designer.cs @@ -69,6 +69,15 @@ namespace OctopusClient { } } + /// + /// Looks up a localized string similar to Archive. + /// + internal static string ARCHIVE { + get { + return ResourceManager.GetString("ARCHIVE", resourceCulture); + } + } + /// /// Looks up a localized string similar to Global ID. /// diff --git a/client/OctopusClient/Resources.resx b/client/OctopusClient/Resources.resx index 7fde695d..3baa3ae9 100644 --- a/client/OctopusClient/Resources.resx +++ b/client/OctopusClient/Resources.resx @@ -120,6 +120,9 @@ Adástükör + + Archive + Global ID diff --git a/client/PlanAIRClient/TrafficIDSelector.Designer.cs b/client/PlanAIRClient/TrafficIDSelector.Designer.cs index 9b3c8441..fdbcc862 100644 --- a/client/PlanAIRClient/TrafficIDSelector.Designer.cs +++ b/client/PlanAIRClient/TrafficIDSelector.Designer.cs @@ -29,6 +29,7 @@ private void InitializeComponent() { this.components = new System.ComponentModel.Container(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle(); this.trafficAPIBindingSource = new System.Windows.Forms.BindingSource(this.components); this.backgroundWorker1 = new System.ComponentModel.BackgroundWorker(); this.backgroundWorker2 = new System.ComponentModel.BackgroundWorker(); @@ -72,12 +73,21 @@ this.dataGridView1.BackgroundColor = System.Drawing.Color.White; this.dataGridView1.BorderStyle = System.Windows.Forms.BorderStyle.None; this.dataGridView1.CellBorderStyle = System.Windows.Forms.DataGridViewCellBorderStyle.Raised; + dataGridViewCellStyle1.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft; + dataGridViewCellStyle1.BackColor = System.Drawing.SystemColors.Control; + dataGridViewCellStyle1.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238))); + dataGridViewCellStyle1.ForeColor = System.Drawing.SystemColors.WindowText; + dataGridViewCellStyle1.SelectionBackColor = System.Drawing.SystemColors.Highlight; + dataGridViewCellStyle1.SelectionForeColor = System.Drawing.SystemColors.HighlightText; + dataGridViewCellStyle1.WrapMode = System.Windows.Forms.DataGridViewTriState.False; + this.dataGridView1.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle1; this.dataGridView1.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; this.dataGridView1.Dock = System.Windows.Forms.DockStyle.Fill; this.dataGridView1.EditMode = System.Windows.Forms.DataGridViewEditMode.EditProgrammatically; this.dataGridView1.Location = new System.Drawing.Point(0, 0); this.dataGridView1.MultiSelect = false; this.dataGridView1.Name = "dataGridView1"; + this.dataGridView1.RowHeadersVisible = false; this.dataGridView1.Size = new System.Drawing.Size(263, 217); this.dataGridView1.TabIndex = 0; this.dataGridView1.CellContentClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView1_CellContentClick); diff --git a/client/PlanAIRClient/TrafficIDSelector.cs b/client/PlanAIRClient/TrafficIDSelector.cs index 724f73ab..9b8f48cf 100644 --- a/client/PlanAIRClient/TrafficIDSelector.cs +++ b/client/PlanAIRClient/TrafficIDSelector.cs @@ -2,6 +2,8 @@ using System; using System.Drawing; using System.ComponentModel; +using System.Linq; +using System.Collections.Generic; namespace TrafficClient { public delegate void OnSelectedIDChanged(string ID, int variantID); @@ -38,7 +40,8 @@ namespace TrafficClient { new DataGridViewTextBoxColumn() { AutoSizeMode = DataGridViewAutoSizeColumnMode.DisplayedCells, DataPropertyName = "MediaID", - HeaderText = Resources.TRAFFIC_ID + HeaderText = Resources.TRAFFIC_ID, + }, new DataGridViewTextBoxColumn() { AutoSizeMode = DataGridViewAutoSizeColumnMode.DisplayedCells, @@ -88,8 +91,12 @@ namespace TrafficClient { dataGridView1.DataSource = null; return; } - dataGridView1.DataSource = result; - //dataGridView1.Sort(dataGridView1.Columns[5], ListSortDirection.Ascending); + List list = new List(); + foreach (MamResultWrapper actual in result) { + list.Add(actual); + } + list.Sort((x, y) => DateTime.Compare(x.NextBroadcastDate.Value, y.NextBroadcastDate.Value)); + dataGridView1.DataSource = list; } private void textBox1_KeyDown(object sender, KeyEventArgs e) { @@ -126,16 +133,13 @@ namespace TrafficClient { return; //nincs multiselect DataGridViewCell checkBoxCell = gridView.SelectedCells[0]; + bool selected = checkBoxCell.Value.Equals(false); clearCheckBox?.Invoke(); ClearSelectionSource(); //checkBoxCell.Value = checkBoxCell.Value.Equals(true) ? true : false; MamResultWrapper res = dataGridView1.Rows[e.RowIndex].DataBoundItem as MamResultWrapper; - if (checkBoxCell.Value.Equals(false)) - res.Selected = true; - else - res.Selected = false; - if (checkBoxCell.Value.Equals(true)) { - + res.Selected = selected; + if (selected) { IDChangedEvent?.Invoke(res.MediaID, res.VariantID); } else IDChangedEvent?.Invoke(string.Empty, 0); -- 2.54.0