From 25b87a648b70923e2dba36c5201ae0c3aa433ff5 Mon Sep 17 00:00:00 2001 From: =?utf8?q?V=C3=A1s=C3=A1ry=20D=C3=A1niel?= Date: Wed, 12 Dec 2018 14:59:09 +0000 Subject: [PATCH] =?utf8?q?Feature=20#116=20Multiszegmens=20adatok=20ment?= =?utf8?q?=C3=A9si=20logik=C3=A1ja=20Feature=20#115=20Multiszegmens=20Traf?= =?utf8?q?fic=20list=C3=A1z=C3=A1s?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit git-tfs-id: [http://tfs.userrendszerhaz.hu:8080/tfs/DefaultCollection]$/MediaCube;C31367 --- client/AudioRecorder/MetadataSelectorForm.cs | 5 +- client/DxPlay/DxPlay.csproj | 1 + client/DxPlay/Integration/Traffic.cs | 4 +- client/DxPlay/PlayerForm.cs | 4 +- client/MXFFileParser/MXFFileParser.csproj | 1 + .../Maestro/Configuration/configuration.json | 2 +- client/Maestro/MaestroForm.Metadata.cs | 66 ++--- client/Maestro/MaestroForm.Target.cs | 5 +- client/Maestro/Metadata/MetaDataInfo.cs | 2 + .../Configuration/ConfigurationInfo.cs | 4 + .../MaestroShared/Interfaces/ITrafficAPI.cs | 20 ++ client/MaestroShared/MaestroShared.csproj | 2 + client/MaestroShared/Metadata/Traffic.cs | 43 +++ .../Targets/TargetProcessorParameter.cs | 7 +- .../Targets/UNCTargetProcessor.cs | 53 ++-- client/MetadataSelector/MetadataIDSelector.cs | 8 +- .../MetadataSelector/MetadataSelector.csproj | 1 + .../NativeOctopusClient.csproj | 1 + client/OctopusClient/OctopusClient.csproj | 1 + .../PasswordEncrypter.csproj | 1 + client/PasswordEncrypter/Program.cs | 8 + .../{ => Model}/PlanAirADResult.cs | 2 +- .../Model/PlanAirMaterialResult.cs | 30 ++ .../PlanAirMaterialSegmentResult.cs | 2 +- .../{ => Model}/PlanAirPromoResult.cs | 2 +- client/PlanAIRClient/PlanAirDataReader.cs | 68 ++++- .../Properties/Settings.Designer.cs | 13 +- .../Properties/Settings.settings | 13 +- client/PlanAIRClient/Resources.Designer.cs | 9 + client/PlanAIRClient/Resources.resx | 3 + client/PlanAIRClient/TrafficAPI.cs | 64 ++++- client/PlanAIRClient/TrafficClasses.cs | 4 - client/PlanAIRClient/TrafficClasses.dbml | 34 --- .../PlanAIRClient/TrafficClasses.dbml.layout | 4 - .../PlanAIRClient/TrafficClasses.designer.cs | 60 ---- client/PlanAIRClient/TrafficClient.csproj | 26 +- client/PlanAIRClient/TrafficIDSelector.cs | 113 ++++---- .../PlanAIRClient/TrafficIDSelectorColumns.cs | 68 ++++- .../TrafficLookupResultSelector.cs | 3 +- ...cConfiguration.cs => TrafficParameters.cs} | 0 client/PlanAIRClient/Workers/ADWorker.cs | 7 +- .../Workers/MultiSegmentMaterialWorker.cs | 30 +- client/PlanAIRClient/Workers/PromoWorker.cs | 7 +- .../Workers/SingleSegmentMaterialWorker.cs | 100 +++++-- client/PlanAIRClient/Workers/TrafficWorker.cs | 6 +- .../clIFsp_EC_MAMBradocastResult.cs | 259 ------------------ server/-dependencies/pom.xml | 3 + .../mediacube/executors/tests/Support.java | 20 ++ .../user/jobengine/server/IT/Support.java | 1 + 49 files changed, 578 insertions(+), 612 deletions(-) create mode 100644 client/MaestroShared/Interfaces/ITrafficAPI.cs create mode 100644 client/MaestroShared/Metadata/Traffic.cs rename client/PlanAIRClient/{ => Model}/PlanAirADResult.cs (96%) create mode 100644 client/PlanAIRClient/Model/PlanAirMaterialResult.cs rename client/PlanAIRClient/{ => Model}/PlanAirMaterialSegmentResult.cs (96%) rename client/PlanAIRClient/{ => Model}/PlanAirPromoResult.cs (96%) delete mode 100644 client/PlanAIRClient/TrafficClasses.cs delete mode 100644 client/PlanAIRClient/TrafficClasses.dbml delete mode 100644 client/PlanAIRClient/TrafficClasses.dbml.layout delete mode 100644 client/PlanAIRClient/TrafficClasses.designer.cs rename client/PlanAIRClient/{TrafficConfiguration.cs => TrafficParameters.cs} (100%) delete mode 100644 client/PlanAIRClient/clIFsp_EC_MAMBradocastResult.cs diff --git a/client/AudioRecorder/MetadataSelectorForm.cs b/client/AudioRecorder/MetadataSelectorForm.cs index cedd49b5..85acb573 100644 --- a/client/AudioRecorder/MetadataSelectorForm.cs +++ b/client/AudioRecorder/MetadataSelectorForm.cs @@ -1,6 +1,7 @@ using AudioRecorder.Properties; using MaestroShared.Metadata; using System; +using System.Collections.Generic; using System.Windows.Forms; namespace AudioRecorder { @@ -8,7 +9,7 @@ namespace AudioRecorder { private Metadata selectedMetadata; public enum TargetType { - Free, Octopus, TrafficPromo, TrafficAD, TrafficMaterial + Free, Octopus, TrafficPromo, TrafficAD, TrafficMaterial } public class Metadata { @@ -82,7 +83,7 @@ namespace AudioRecorder { }; } - private void TrafficIDChangedEvent(string id, int variantID, string text) { + private void TrafficIDChangedEvent(string id, int variantID, string text, List selected) { if (id == null) SelectedMetadata = null; else { diff --git a/client/DxPlay/DxPlay.csproj b/client/DxPlay/DxPlay.csproj index 57e4c91f..38fc792d 100644 --- a/client/DxPlay/DxPlay.csproj +++ b/client/DxPlay/DxPlay.csproj @@ -118,6 +118,7 @@ prompt MinimumRecommendedRules.ruleset false + true LocalIntranet diff --git a/client/DxPlay/Integration/Traffic.cs b/client/DxPlay/Integration/Traffic.cs index 90432cac..372715f5 100644 --- a/client/DxPlay/Integration/Traffic.cs +++ b/client/DxPlay/Integration/Traffic.cs @@ -55,11 +55,13 @@ namespace DxPlay.Integration { public void SaveSegments(TargetUpdateTrafficMessage message) { //logger.Info("Now update!!!!!!!!!"); - selector.trafficAPI.SaveSegments(message.VariantID, message.MetadataType, message.Segments); + //TODO a listabol kijelolt szegmenseket is at kell adni + selector.trafficAPI.SaveSegments(message.VariantID, message.MetadataType, message.Segments, null); //message.Ready, } public void Approve(TargetUpdateTrafficMessage message) { + //TODO ifCompleted selector.trafficAPI.Approve(message.VariantID, message.Ready, message.MetadataType); } } diff --git a/client/DxPlay/PlayerForm.cs b/client/DxPlay/PlayerForm.cs index 21e290e6..9d989e0b 100644 --- a/client/DxPlay/PlayerForm.cs +++ b/client/DxPlay/PlayerForm.cs @@ -1,8 +1,10 @@ using DxPlay.Model; using DxPlay.Properties; using MaestroShared.Commons; +using MaestroShared.Metadata; using NLog; using System; +using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Runtime.InteropServices; @@ -81,7 +83,7 @@ namespace DxPlay { } - private void OnSelectedIDChanged(string ID, int variantID, string text) { + private void OnSelectedIDChanged(string ID, int variantID, string text, List selected) { //logger.Info("Selected ID: " + ID); try { model.ID = ID; diff --git a/client/MXFFileParser/MXFFileParser.csproj b/client/MXFFileParser/MXFFileParser.csproj index 2c96ba3e..77dcf2c1 100644 --- a/client/MXFFileParser/MXFFileParser.csproj +++ b/client/MXFFileParser/MXFFileParser.csproj @@ -58,6 +58,7 @@ prompt MinimumRecommendedRules.ruleset false + true diff --git a/client/Maestro/Configuration/configuration.json b/client/Maestro/Configuration/configuration.json index 9688cf26..3932bcbd 100644 --- a/client/Maestro/Configuration/configuration.json +++ b/client/Maestro/Configuration/configuration.json @@ -41,7 +41,7 @@ "password": "7RKZYBzumKjL40SJwuwiFCvX57xuCN8zay6OttUm2wbrgImyYZBHyZTUUYrXX31Ge2Uwew07HYsqh2uzdJeDBDwcVntxaHg3nIpv9Dyq/odVoiC4tUF/K+lgvKWANcrZ", "timeout": 1000 }, - "version": 2 + "version": 1 }, { "$type": "MediaCubeMetadata", diff --git a/client/Maestro/MaestroForm.Metadata.cs b/client/Maestro/MaestroForm.Metadata.cs index 51bee826..13f3cec2 100644 --- a/client/Maestro/MaestroForm.Metadata.cs +++ b/client/Maestro/MaestroForm.Metadata.cs @@ -1,9 +1,9 @@ -using Maestro.Metadata; +using Interfaces; +using Maestro.Metadata; using MaestroShared.Commons; using MaestroShared.Configuration; using MaestroShared.Metadata; using MaestroShared.Model; -using MaestroShared.Targets; using MediaCubeClient; using OctopusClient; using System; @@ -53,20 +53,6 @@ namespace Maestro { textSelectedMetadata.ReadOnly = !Configuration.EnableCustomMetadataId; UpdateDefineSegmentEnabled(); UpdateEditArchiveMetadataEnabled(); - - MessageBus.Subscribe(m => OnTargetUpdateTrafficMessage(m)); - } - - private void OnTargetUpdateTrafficMessage(TargetUpdateTrafficMessage message) { - if (message.Ready == false) { - //Target futas elejen elmentjuk a szegmenseket - logger.Info("Saving segments for {0}", message.VariantID); - trafficIDSelector.trafficAPI.SaveSegments(message.VariantID, message.MetadataType, message.Segments); - } else { - //Target futas vegen OK - logger.Info("Approving {0}", message.VariantID); - trafficIDSelector.trafficAPI.Approve(message.VariantID, true, message.MetadataType); - } } private void InitializeTrafficSelector() { @@ -135,12 +121,12 @@ namespace Maestro { private void OnDefineSegments(object sender, EventArgs e) { if (SelectedSource?.FileInfo == null) return; - DefineSegments(SelectedSource.FileInfo); + DefineSegments(SelectedSource.FileInfo, false); } - private void DefineSegments(FileInfo fileInfo) { + private void DefineSegments(FileInfo fileInfo, bool redefine) { Cursor = Cursors.WaitCursor; - if (movieSegments == null || movieSegments.Count == 0) + if (!redefine && (movieSegments == null || movieSegments.Count == 0)) movieSegments = QuerySegments(); if (movieSegments == null) movieSegments = new BindingList(); @@ -162,7 +148,17 @@ namespace Maestro { private BindingList QuerySegments() { BindingList result = null; - List storedSegments = GetSegments(); + List storedSegments = null; + TrafficMetadata metadata = MetadataProvider.Get(Configuration.Metadatas); + if (true.Equals(metadata?.MultiSegmentEnabled)) { + storedSegments = new List(); + foreach (TrafficItem item in SelectedMetadata.Selected) { + if (item.MovieSegment != null) + storedSegments.Add(item.MovieSegment); + } + } else + storedSegments = GetSegments(); + if (storedSegments != null && storedSegments.Count > 0) result = new BindingList(storedSegments); return result; @@ -272,7 +268,7 @@ namespace Maestro { string id = textSelectedMetadata.Text; if (String.IsNullOrEmpty(id)) return null; - TrafficAPI api = trafficIDSelector.trafficAPI; + ITrafficAPI api = trafficIDSelector.trafficAPI; List trafficResult = null; switch (metadataType) { case MetadataType.TrafficMaterial: @@ -350,23 +346,6 @@ namespace Maestro { } } - //switch (SelectedMetadata?.Kind) { - // case MetadataType.OctopusStory: - // case MetadataType.OctopusPlaceHolder: - // ArchiveMetadata = GetArchiveMetadata(); - // break; - // case MetadataType.TrafficAD: - // case MetadataType.TrafficMaterial: - // case MetadataType.TrafficPromo: - // ArchiveMetadata = GetArchiveMetadata(); - // movieSegments = null; - // movieSegments = QuerySegments(); - // break; - // default: - // movieSegments = null; - // ArchiveMetadata = null; - // break; - //} movieSegments = null; ArchiveMetadata = null; @@ -392,7 +371,7 @@ namespace Maestro { }; } - private void OnTrafficIDSelected(string id, int variantID, string text) { + private void OnTrafficIDSelected(string id, int variantID, string text, List selected) { btnRedefineSegments.Visible = false; if (id == null) { ArchiveMetadata = null; @@ -405,7 +384,8 @@ namespace Maestro { Kind = metadataType, ID = id, MetadataText = text, - VariantID = variantID + VariantID = variantID, + Selected = selected }; CheckIfRedefineSegments(); @@ -452,11 +432,7 @@ namespace Maestro { return; } - DefineSegments(new FileInfo(SelectedMetadata.RedefineSegmentsFile)); - /* - trafficIDSelector.trafficAPI.SaveSegments(SelectedMetadata.VariantID, SelectedMetadata.Kind, movieSegments.ToList()); - trafficIDSelector.trafficAPI.Approve(SelectedMetadata.VariantID, true, SelectedMetadata.Kind); - */ + DefineSegments(new FileInfo(SelectedMetadata.RedefineSegmentsFile), true); } private static string GetMetadataTypeTooltip(MetadataType? metadataType) { diff --git a/client/Maestro/MaestroForm.Target.cs b/client/Maestro/MaestroForm.Target.cs index 4d7645c2..0a54f414 100644 --- a/client/Maestro/MaestroForm.Target.cs +++ b/client/Maestro/MaestroForm.Target.cs @@ -179,12 +179,14 @@ namespace Maestro { TargetProcessorParameter result = new TargetProcessorParameter(); result.SourcePathOverride = (source == null || source.Path.Equals(Configuration.Source.Local.Address.LocalPath)) ? null : source.Path; result.MediaCubeApi = mediaCubeApi; + result.TrafficApi = trafficIDSelector.trafficAPI; + result.TrafficMetadata = MetadataProvider.Get(Configuration.Metadatas); result.SourceConfig = Configuration.Source; result.TargetConfig = target; result.ID = textSelectedMetadata.Text; result.MetadataText = SelectedMetadata?.MetadataText; result.InputFileName = sourceItem.Name; - result.MovieSegments = movieSegments == null ? null : movieSegments.ToList(); + result.MovieSegments = movieSegments?.ToList(); result.ArchiveMetadata = ArchiveMetadata.DeepClone(ArchiveMetadata); result.VariantID = selectedMetadata == null ? 0 : selectedMetadata.VariantID; result.MetadataKind = selectedMetadata == null ? MetadataType.None : selectedMetadata.Kind; @@ -194,6 +196,7 @@ namespace Maestro { result.Frames = sourceItem.Frames; result.TargetOrder = Configuration.Targets.ToList().IndexOf(target); result.ArchiveMetadata.userName = result.UserName; + result.SelectedSegments = SelectedMetadata?.Selected; if (SelectedMetadata.Kind == MetadataType.MediaCube && result.ArchiveMetadata != null) { result.ArchiveMetadata.itemHouseId = PatternNameMaker.Get(result.ArchiveMetadata.itemHouseId, result.ID, result.InputFileName, null, null, result.MetadataText); result.ArchiveMetadata.itemTitle = PatternNameMaker.Get(result.ArchiveMetadata.itemTitle, result.ID, result.InputFileName, null, null, result.MetadataText); diff --git a/client/Maestro/Metadata/MetaDataInfo.cs b/client/Maestro/Metadata/MetaDataInfo.cs index efb2bc89..4d1e4e85 100644 --- a/client/Maestro/Metadata/MetaDataInfo.cs +++ b/client/Maestro/Metadata/MetaDataInfo.cs @@ -1,5 +1,6 @@ using MaestroShared.Metadata; using MaestroShared.Model; +using System.Collections.Generic; namespace Maestro.Metadata { public class MetadataInfo { @@ -10,5 +11,6 @@ namespace Maestro.Metadata { public string RedefineSegmentsFile { get; set; } public bool RedefineWithRestore { get; set; } public Media RedefineMedia { get; set; } + public List Selected { get; set; } } } diff --git a/client/MaestroShared/Configuration/ConfigurationInfo.cs b/client/MaestroShared/Configuration/ConfigurationInfo.cs index 1a31301a..5c8cc2a8 100644 --- a/client/MaestroShared/Configuration/ConfigurationInfo.cs +++ b/client/MaestroShared/Configuration/ConfigurationInfo.cs @@ -191,6 +191,10 @@ namespace MaestroShared.Configuration { public ProjectSettings ProjectSettings { get; set; } public string FunctionName { get; set; } public int Version { get; set; } + public bool MultiSegmentEnabled { + get => Version == 1; + } + } public class MediaCubeMetadata : MetadataProvider { diff --git a/client/MaestroShared/Interfaces/ITrafficAPI.cs b/client/MaestroShared/Interfaces/ITrafficAPI.cs new file mode 100644 index 00000000..7b9fd286 --- /dev/null +++ b/client/MaestroShared/Interfaces/ITrafficAPI.cs @@ -0,0 +1,20 @@ +using MaestroShared.Metadata; +using System; +using System.Collections.Generic; + +namespace Interfaces { + public interface ITrafficAPI { + void Approve(int itemID, bool ready, MetadataType kind, bool ifCompleted = false); + TrafficVersion CreateMaterialVersion(string episodeID, bool recut); + List GetADArchiveMetadata(string strParam); + List GetADs(string search, bool problematic, DateTime? from = null, DateTime? to = null); + List GetADSegments(string strParam); + List GetMaterialMetadata(string strParam); + List GetMaterials(string strParam, bool problematic, DateTime? from = null, DateTime? to = null); + List GetMaterialSegments(int itemID); + List GetPromoArchiveMetadata(string strParam); + List GetPromos(string search, bool problematic, DateTime? from = null, DateTime? to = null); + List GetPromoSegments(string strParam); + string SaveSegments(int itemID, MetadataType kind, List segments, List selectedSegments); + } +} \ No newline at end of file diff --git a/client/MaestroShared/MaestroShared.csproj b/client/MaestroShared/MaestroShared.csproj index 221991be..68a8ab0e 100644 --- a/client/MaestroShared/MaestroShared.csproj +++ b/client/MaestroShared/MaestroShared.csproj @@ -115,9 +115,11 @@ + + diff --git a/client/MaestroShared/Metadata/Traffic.cs b/client/MaestroShared/Metadata/Traffic.cs new file mode 100644 index 00000000..66b69514 --- /dev/null +++ b/client/MaestroShared/Metadata/Traffic.cs @@ -0,0 +1,43 @@ +using System; + +namespace MaestroShared.Metadata { + public class TrafficItem { + public bool Selected { get; set; } + public string MediaID { get; set; } + public bool OK { get; set; } + public string Title { get; set; } + public DateTime? NextBroadcastDate { get; set; } + public DateTime? FirstBroadcastDate { get; set; } + public int? SegmentCount { get; set; } + public int? SegmentNr { get; set; } + public long? SegmentId { get; set; } + public MovieSegment MovieSegment { get; set; } + public short EpisodeNumber { get; set; } + public string EpisodeTitle { get; set; } + public int VariantID { get; set; } + public string EpisodeID { get; set; } + public string Segment { + get { + if (SegmentCount != null && SegmentNr != null) + return string.Format($"{SegmentCount} / {SegmentNr}"); + else + return ""; + } + } + } + + public class TrafficVersion { + public string MediaID { get; set; } + public int VariantID { get; set; } + } + + public class TrafficItemMetadata { + public string ProgTitle { get; set; } + public string ProgDescription { get; set; } + public string ProgID { get; set; } + public string EpisodeTitle { get; set; } + public string EpisodeDescription { get; set; } + public string EpisodeID { get; set; } + public bool OK { get; set; } + } +} diff --git a/client/MaestroShared/Targets/TargetProcessorParameter.cs b/client/MaestroShared/Targets/TargetProcessorParameter.cs index 9771fb53..932d3e05 100644 --- a/client/MaestroShared/Targets/TargetProcessorParameter.cs +++ b/client/MaestroShared/Targets/TargetProcessorParameter.cs @@ -1,4 +1,5 @@ -using LinkDotNet.MessageHandling.Contracts; +using Interfaces; +using LinkDotNet.MessageHandling.Contracts; using MaestroShared.Configuration; using MaestroShared.Interfaces; using MaestroShared.Metadata; @@ -14,7 +15,9 @@ namespace MaestroShared.Target { public string ID { get; set; } public string MetadataText { get; set; } public List MovieSegments { get; set; } + public List SelectedSegments { get; set; } public IMediaCubeApi MediaCubeApi { get; set; } + public ITrafficAPI TrafficApi { get; set; } public ArchiveMetadata ArchiveMetadata { get; set; } public int VariantID { get; set; } public MetadataType MetadataKind { get; set; } @@ -23,6 +26,6 @@ namespace MaestroShared.Target { public DateTime CreateDate { get; set; } public long Frames { get; set; } public int TargetOrder { get; set; } - + public TrafficMetadata TrafficMetadata { get; set; } } } diff --git a/client/MaestroShared/Targets/UNCTargetProcessor.cs b/client/MaestroShared/Targets/UNCTargetProcessor.cs index a17b4093..3b13eb76 100644 --- a/client/MaestroShared/Targets/UNCTargetProcessor.cs +++ b/client/MaestroShared/Targets/UNCTargetProcessor.cs @@ -70,11 +70,13 @@ namespace MaestroShared.Targets { protected virtual void BeforeExecute() { Started = DateTime.Now; workFlowAction.started = Started; - } - - protected virtual void BeforeUpload() { - if (Parameters.TargetConfig.SaveSegments && Parameters.MovieSegments != null) - TrafficSaveSegments(); + if (Parameters.TargetConfig.SaveSegments && Parameters.MovieSegments != null) { + string fileName = Parameters?.TrafficApi?.SaveSegments(Parameters.VariantID, Parameters.MetadataKind, Parameters.MovieSegments, Parameters.SelectedSegments); + if (true.Equals(Parameters?.TrafficMetadata?.MultiSegmentEnabled)) { + //a Traffic adja a nevet + OutputName = fileName; + } + } } public override bool Execute() { @@ -84,7 +86,10 @@ namespace MaestroShared.Targets { BeforeExecute(); workingDir = DetermineWorkingDirectory(Parameters.TargetConfig.Remote); EnsureDirectoryExistence(workingDir); - OutputName = CreateOutputFileName(); + + //multiszegmens mukodes eseten a filenevet a traffic generalja + if (!true.Equals(Parameters?.TrafficMetadata?.MultiSegmentEnabled)) + OutputName = CreateOutputFileName(); CreateOutput(workingDir); workFlowAction.source = Input; workFlowAction.destination = Output; @@ -93,7 +98,6 @@ namespace MaestroShared.Targets { string currentFile = GetOutputFilePath(workingDir, OutputName); //csak akkor csinalunk barmit is, ha a feluliras logika engedi if (DeleteExisting(currentFile)) { - BeforeUpload(); UploadFile(); ValidateTransfer(); //logger.Info("Spend (s):" + (DateTime.Now - started).TotalSeconds); @@ -201,38 +205,19 @@ namespace MaestroShared.Targets { CreateArchiveMetadata(); if (Parameters.TargetConfig.SaveMorpheusMetadata && Parameters.ArchiveMetadata != null && Parameters.MovieSegments != null && Parameters.MovieSegments.Count > 0) UploadMorpheusMetadata(); - if (Parameters.TargetConfig.SaveSegments && Parameters.MovieSegments != null) - TrafficApprove(); + + if (Parameters.TargetConfig.SaveSegments && Parameters.MovieSegments != null) { + bool ifCompleted = true.Equals(Parameters?.TrafficMetadata?.MultiSegmentEnabled); + Parameters?.TrafficApi?.Approve(Parameters.VariantID, true, Parameters.MetadataKind, ifCompleted); + } if (Parameters.TargetConfig.SendEmailOnSuccess && !String.IsNullOrEmpty(Parameters.TargetConfig.SuccessEmailRecipient) && !String.IsNullOrEmpty(Parameters.TargetConfig.SuccessEmailPattern)) SendEmail(Parameters.TargetConfig.SuccessEmailRecipient, Parameters.TargetConfig.SuccessEmailPattern); logger.Trace(Strings.EXIT); } - private void TrafficApprove() { - logger.Trace(Strings.ENTRY); - TargetUpdateTrafficMessage message = new TargetUpdateTrafficMessage { - VariantID = Parameters.VariantID, - Ready = true, - MetadataType = Parameters.MetadataKind - }; - Parameters.MessageBus.Send(message); - logger.Trace(Strings.EXIT); - } - - private void TrafficSaveSegments() { - logger.Trace(Strings.ENTRY); - TargetUpdateTrafficMessage message = new TargetUpdateTrafficMessage { - VariantID = Parameters.VariantID, - MetadataType = Parameters.MetadataKind, - Segments = Parameters.MovieSegments - }; - Parameters.MessageBus.Send(message); - logger.Trace(Strings.EXIT); - } - private void UploadNexioMetadata() { logger.Trace(Strings.ENTRY); - String xml = null; + string xml = null; string name = GetOutputName(); string description = Parameters.ArchiveMetadata?.mediaTitle; if (Parameters.TargetConfig.KillDateDays > 0) { @@ -440,11 +425,11 @@ namespace MaestroShared.Targets { string nameWithoutExtension = GetDynamicText(Parameters.TargetConfig.OutputFormat); string extension = Path.GetExtension(InputName); extension = extension.ToUpper(); - string result = String.Format(FILENAME, nameWithoutExtension, extension); + 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); + string versioned = string.Format(VERSIONED_FILENAME, nameWithoutExtension, version, extension); logger.Debug(ALREADY_EXISTS, result, versioned); result = versioned; version++; diff --git a/client/MetadataSelector/MetadataIDSelector.cs b/client/MetadataSelector/MetadataIDSelector.cs index a37ae9c0..ec0048d9 100644 --- a/client/MetadataSelector/MetadataIDSelector.cs +++ b/client/MetadataSelector/MetadataIDSelector.cs @@ -7,6 +7,7 @@ using MediaCubeClient; using NativeOctopusClient; using OctopusClient; using System; +using System.Collections.Generic; using System.Security.Principal; using System.Text.RegularExpressions; using System.Windows.Forms; @@ -29,7 +30,8 @@ namespace MaestroShared.Controls { public TrafficIDSelector TrafficIDSelector { get => trafficIDSelector; } public UISettings Settings { get; set; } - public MetadataProvider[] Providers { get => providers; + public MetadataProvider[] Providers { + get => providers; set { providers = value; if (providers == null) @@ -139,7 +141,7 @@ namespace MaestroShared.Controls { textSelectedMetadata.Text = name; } - private void TrafficIDChangedEvent(string id, int variantID, string text) { + private void TrafficIDChangedEvent(string id, int variantID, string text, List selected) { octopusIDSelector.ClearSelection(); nativeOctopusIDSelector.ClearSelection(); ClearFreeMetadata(); @@ -158,7 +160,7 @@ namespace MaestroShared.Controls { config = MetadataProvider.Get(Providers); if (config == null) return; - tabMetadata.SelectedTab = tpTraffic; + tabMetadata.SelectedTab = tpTraffic; trafficIDSelector.LookupByMaterialID(id); break; case MetadataType.TrafficPromo: diff --git a/client/MetadataSelector/MetadataSelector.csproj b/client/MetadataSelector/MetadataSelector.csproj index 64e0ca12..bf5a5ed3 100644 --- a/client/MetadataSelector/MetadataSelector.csproj +++ b/client/MetadataSelector/MetadataSelector.csproj @@ -50,6 +50,7 @@ x64 prompt MinimumRecommendedRules.ruleset + true diff --git a/client/NativeOctopusClient/NativeOctopusClient.csproj b/client/NativeOctopusClient/NativeOctopusClient.csproj index a0874dc3..79828f4f 100644 --- a/client/NativeOctopusClient/NativeOctopusClient.csproj +++ b/client/NativeOctopusClient/NativeOctopusClient.csproj @@ -50,6 +50,7 @@ x64 prompt MinimumRecommendedRules.ruleset + true diff --git a/client/OctopusClient/OctopusClient.csproj b/client/OctopusClient/OctopusClient.csproj index 0e1dba67..ff5561b1 100644 --- a/client/OctopusClient/OctopusClient.csproj +++ b/client/OctopusClient/OctopusClient.csproj @@ -71,6 +71,7 @@ x64 prompt MinimumRecommendedRules.ruleset + true diff --git a/client/PasswordEncrypter/PasswordEncrypter.csproj b/client/PasswordEncrypter/PasswordEncrypter.csproj index 7a1d3936..14645450 100644 --- a/client/PasswordEncrypter/PasswordEncrypter.csproj +++ b/client/PasswordEncrypter/PasswordEncrypter.csproj @@ -54,6 +54,7 @@ prompt MinimumRecommendedRules.ruleset true + true maestro.ico diff --git a/client/PasswordEncrypter/Program.cs b/client/PasswordEncrypter/Program.cs index e05ef495..e5fd801b 100644 --- a/client/PasswordEncrypter/Program.cs +++ b/client/PasswordEncrypter/Program.cs @@ -6,6 +6,14 @@ namespace PasswordEncrypter { [STAThread] static void Main(string[] args) { + /* + string s = "7RKZYBzumKjL40SJwuwiFCvX57xuCN8zay6OttUm2wbrgImyYZBHyZTUUYrXX31Ge2Uwew07HYsqh2uzdJeDBDwcVntxaHg3nIpv9Dyq/odVoiC4tUF/K+lgvKWANcrZ"; + string original = StringCipher.Decrypt(s); + Console.WriteLine("Restored password:"); + Console.WriteLine(original); + Console.ReadLine(); + */ + Console.WriteLine("Password:"); string password = Console.ReadLine(); diff --git a/client/PlanAIRClient/PlanAirADResult.cs b/client/PlanAIRClient/Model/PlanAirADResult.cs similarity index 96% rename from client/PlanAIRClient/PlanAirADResult.cs rename to client/PlanAIRClient/Model/PlanAirADResult.cs index 5d34b50e..5636e440 100644 --- a/client/PlanAIRClient/PlanAirADResult.cs +++ b/client/PlanAIRClient/Model/PlanAirADResult.cs @@ -1,4 +1,4 @@ -namespace TrafficClient { +namespace TrafficClient.Model { public partial class PlanAirADResult { private int _t_SpotID; diff --git a/client/PlanAIRClient/Model/PlanAirMaterialResult.cs b/client/PlanAIRClient/Model/PlanAirMaterialResult.cs new file mode 100644 index 00000000..11581b99 --- /dev/null +++ b/client/PlanAIRClient/Model/PlanAirMaterialResult.cs @@ -0,0 +1,30 @@ +namespace TrafficClient.Model { + public partial class PlanAirMaterialResult { + public int v_ProgrammeID; + public bool v_Live; + public string v_EpisodeID; + public int? v_VariantID; + public string v_MediaID; + public int? v_VariantTypeID; + public string v_ProgTitle; + public string v_EpTitle; + public short? v_Episode; + public string v_VariantType; + public string v_VariantKeywords; + public string v_VariantLengthTC; + public int? v_VariantLengthFrame; + public int? v_VariantNrSegments; + public System.DateTime? v_FirstBroadcastDate; + public System.DateTime? v_NextBroadcastDate; + public bool? v_OkForAir; + public bool? v_ForTransm; + public int? v_SegNr; + public int? v_SegID; + public int? v_SegTcIn; + public int? v_SegTcOut; + public int? v_SegDuration; + public string v_SegTitle; + public string v_SegKeyWords; + public bool? v_SegDropable; + } +} diff --git a/client/PlanAIRClient/PlanAirMaterialSegmentResult.cs b/client/PlanAIRClient/Model/PlanAirMaterialSegmentResult.cs similarity index 96% rename from client/PlanAIRClient/PlanAirMaterialSegmentResult.cs rename to client/PlanAIRClient/Model/PlanAirMaterialSegmentResult.cs index 9fb85701..99615b9e 100644 --- a/client/PlanAIRClient/PlanAirMaterialSegmentResult.cs +++ b/client/PlanAIRClient/Model/PlanAirMaterialSegmentResult.cs @@ -1,4 +1,4 @@ -namespace TrafficClient { +namespace TrafficClient.Model { public partial class PlanAirMaterialSegmentResult { private int _v_SegID; diff --git a/client/PlanAIRClient/PlanAirPromoResult.cs b/client/PlanAIRClient/Model/PlanAirPromoResult.cs similarity index 96% rename from client/PlanAIRClient/PlanAirPromoResult.cs rename to client/PlanAIRClient/Model/PlanAirPromoResult.cs index 4171aaa6..0837b53a 100644 --- a/client/PlanAIRClient/PlanAirPromoResult.cs +++ b/client/PlanAIRClient/Model/PlanAirPromoResult.cs @@ -1,4 +1,4 @@ -namespace TrafficClient { +namespace TrafficClient.Model { public partial class PlanAirPromoResult { private int _t_SpotID; diff --git a/client/PlanAIRClient/PlanAirDataReader.cs b/client/PlanAIRClient/PlanAirDataReader.cs index d28422c7..1fc68f17 100644 --- a/client/PlanAIRClient/PlanAirDataReader.cs +++ b/client/PlanAIRClient/PlanAirDataReader.cs @@ -1,8 +1,11 @@ -using System; +using NLog; +using System; using System.Data.SqlClient; +using TrafficClient.Model; namespace TrafficClient { public class PlanAirDataReader { + private static readonly Logger logger = LogManager.GetCurrentClassLogger(); private string ReadString(SqlDataReader reader, ref int f) { string result = null; @@ -39,8 +42,10 @@ namespace TrafficClient { return result; } - public clIFsp_EC_MAMBradocastResult ToclIFsp_MAMBroadcastResult(SqlDataReader reader) { - clIFsp_EC_MAMBradocastResult item = new clIFsp_EC_MAMBradocastResult(); + public PlanAirMaterialResult ToSingleMaterialResult(SqlDataReader reader) { + //for (int i = 0; i < reader.FieldCount; i++) + // logger.Debug($"{i} : {reader.GetName(i)} {reader.GetDataTypeName(i)} {reader.GetFieldType(i)}"); + PlanAirMaterialResult item = new PlanAirMaterialResult(); int f = 0; item.v_ProgrammeID = (int)ReadInt(reader, ref f); item.v_Live = (bool)ReadBool(reader, ref f); @@ -63,8 +68,59 @@ namespace TrafficClient { item.v_ForTransm = ReadBool(reader, ref f); return item; } + /* +USE [PA_Echo] +GO - public PlanAirPromoResult ToclIFsp_MAMPromotionalResult(SqlDataReader reader) { +DECLARE @return_value int + +EXEC @return_value = [dbo].[clIFsp_EC_MAM] + @Operation = 6002, + @@@Options = 0, + @@ItemID = NULL, + @@DateParam1 = N'2018-12-06', + @@DateParam2 = N'2018-12-06' + +SELECT 'Return Value' = @return_value + +GO + + */ + public PlanAirMaterialResult ToMultiMaterialResult(SqlDataReader reader) { + //for (int i = 0; i < reader.FieldCount; i++) + // logger.Debug($"{i} : {reader.GetName(i)} {reader.GetDataTypeName(i)} {reader.GetFieldType(i)}"); + PlanAirMaterialResult item = new PlanAirMaterialResult(); + int f = 0; + item.v_ProgrammeID = (int)ReadInt(reader, ref f); + item.v_Live = (bool)ReadBool(reader, ref f); + item.v_EpisodeID = ReadString(reader, ref f); + item.v_VariantID = ReadInt(reader, ref f); + item.v_MediaID = ReadString(reader, ref f); + item.v_VariantTypeID = ReadInt(reader, ref f); + item.v_ProgTitle = ReadString(reader, ref f); + item.v_EpTitle = ReadString(reader, ref f); + item.v_Episode = ReadShort(reader, ref f); + item.v_VariantType = ReadString(reader, ref f); + item.v_VariantKeywords = ReadString(reader, ref f); + item.v_OkForAir = ReadBool(reader, ref f); + item.v_ForTransm = ReadBool(reader, ref f); + item.v_VariantLengthTC = ReadString(reader, ref f); + item.v_VariantLengthFrame = ReadInt(reader, ref f); + item.v_VariantNrSegments = ReadInt(reader, ref f); + item.v_SegNr = ReadInt(reader, ref f); + item.v_SegID = ReadInt(reader, ref f); + item.v_SegTcIn = ReadInt(reader, ref f); + item.v_SegTcOut = ReadInt(reader, ref f); + item.v_SegDuration = ReadInt(reader, ref f); + item.v_SegTitle = ReadString(reader, ref f); + item.v_SegKeyWords = ReadString(reader, ref f); + item.v_SegDropable = ReadBool(reader, ref f); + item.v_FirstBroadcastDate = ReadDateTime(reader, ref f); + item.v_NextBroadcastDate = ReadDateTime(reader, ref f); + return item; + } + + public PlanAirPromoResult ToPromoResult(SqlDataReader reader) { PlanAirPromoResult item = new PlanAirPromoResult(); int f = 0; item.t_SpotID = (int)ReadInt(reader, ref f); @@ -89,7 +145,7 @@ namespace TrafficClient { return item; } - public PlanAirADResult ToclIFsp_MAMAdvertisementResult(SqlDataReader reader) { + public PlanAirADResult ToADResult(SqlDataReader reader) { PlanAirADResult item = new PlanAirADResult(); int f = 0; item.t_SpotID = (int)ReadInt(reader, ref f); @@ -108,7 +164,7 @@ namespace TrafficClient { return item; } - public PlanAirMaterialSegmentResult ToclIFsp_SegmentResult(SqlDataReader reader) { + public PlanAirMaterialSegmentResult ToMaterialSegmentResult(SqlDataReader reader) { PlanAirMaterialSegmentResult item = new PlanAirMaterialSegmentResult(); int f = 0; item.v_SegID = (int)ReadInt(reader, ref f); diff --git a/client/PlanAIRClient/Properties/Settings.Designer.cs b/client/PlanAIRClient/Properties/Settings.Designer.cs index 72a5fcf1..f75ca3e9 100644 --- a/client/PlanAIRClient/Properties/Settings.Designer.cs +++ b/client/PlanAIRClient/Properties/Settings.Designer.cs @@ -12,7 +12,7 @@ namespace TrafficClient.Properties { [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "15.1.0.0")] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "15.8.0.0")] internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); @@ -22,16 +22,5 @@ namespace TrafficClient.Properties { return defaultInstance; } } - - [global::System.Configuration.ApplicationScopedSettingAttribute()] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Configuration.SpecialSettingAttribute(global::System.Configuration.SpecialSetting.ConnectionString)] - [global::System.Configuration.DefaultSettingValueAttribute("Data Source=folkloredb.hu\\sql08,33860;Initial Catalog=CLArchiveTF_0;Persist Secur" + - "ity Info=True;User ID=MAM;Password=Echotv.hu")] - public string CLArchiveTF_0ConnectionString { - get { - return ((string)(this["CLArchiveTF_0ConnectionString"])); - } - } } } diff --git a/client/PlanAIRClient/Properties/Settings.settings b/client/PlanAIRClient/Properties/Settings.settings index 63504285..2bd17f05 100644 --- a/client/PlanAIRClient/Properties/Settings.settings +++ b/client/PlanAIRClient/Properties/Settings.settings @@ -1,14 +1,5 @@  - + - - - <?xml version="1.0" encoding="utf-16"?> -<SerializableConnectionString xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> - <ConnectionString>Data Source=folkloredb.hu\sql08,33860;Initial Catalog=CLArchiveTF_0;Persist Security Info=True;User ID=MAM;Password=Echotv.hu</ConnectionString> - <ProviderName>System.Data.SqlClient</ProviderName> -</SerializableConnectionString> - Data Source=folkloredb.hu\sql08,33860;Initial Catalog=CLArchiveTF_0;Persist Security Info=True;User ID=MAM;Password=Echotv.hu - - + \ No newline at end of file diff --git a/client/PlanAIRClient/Resources.Designer.cs b/client/PlanAIRClient/Resources.Designer.cs index 4c678946..bcbde51c 100644 --- a/client/PlanAIRClient/Resources.Designer.cs +++ b/client/PlanAIRClient/Resources.Designer.cs @@ -178,6 +178,15 @@ namespace TrafficClient { } } + /// + /// Looks up a localized string similar to Szegmens. + /// + internal static string SEGMENT { + get { + return ResourceManager.GetString("SEGMENT", resourceCulture); + } + } + /// /// Looks up a localized string similar to Szegmensek. /// diff --git a/client/PlanAIRClient/Resources.resx b/client/PlanAIRClient/Resources.resx index eb3cd1ca..1e9af041 100644 --- a/client/PlanAIRClient/Resources.resx +++ b/client/PlanAIRClient/Resources.resx @@ -169,4 +169,7 @@ Az azonosító jelenleg nem található a rendszerben. Kérem próbálja újra. + + Szegmens + \ No newline at end of file diff --git a/client/PlanAIRClient/TrafficAPI.cs b/client/PlanAIRClient/TrafficAPI.cs index 4ddd6b86..d0d3b74b 100644 --- a/client/PlanAIRClient/TrafficAPI.cs +++ b/client/PlanAIRClient/TrafficAPI.cs @@ -1,4 +1,5 @@ -using LinkDotNet.MessageHandling.Contracts; +using Interfaces; +using LinkDotNet.MessageHandling.Contracts; using MaestroShared.Metadata; using NLog; using System; @@ -7,9 +8,8 @@ using System.Data.SqlClient; using TrafficClient.Workers; namespace TrafficClient { - public class TrafficAPI { + public class TrafficAPI : ITrafficAPI { private static readonly Logger logger = LogManager.GetCurrentClassLogger(); - private TrafficContext context = new TrafficContext(); private string connectionString; private PlanAirDataReader cliFSPReader; private SqlConnection connection; @@ -17,6 +17,28 @@ namespace TrafficClient { private PromoWorker promoWorker; private ADWorker adWorker; + public TrafficParameters Parameters { get; } + + public TrafficAPI(TrafficParameters parameters) { + Parameters = parameters; + var timeout = parameters?.Configuration?.Server?.Timeout; + timeout = timeout < 1000 ? 1000 : timeout; + var connString = parameters?.Configuration?.Server.Address; + var user = parameters?.Configuration?.Server.UserName; + var password = parameters?.Configuration?.Server.Password; + var functionName = parameters?.Configuration?.FunctionName; + var messageBus = parameters?.MessageBus; + connectionString = string.Format("{0};User ID={1};Password={2};Connection Timeout={3}", connString, user, password, timeout / 1000); + connection = new SqlConnection(connectionString); + cliFSPReader = new PlanAirDataReader(); + if (true.Equals(parameters?.Configuration?.MultiSegmentEnabled)) + materialWorker = new MultiSegmentMaterialWorker(connection, cliFSPReader, functionName, messageBus); + else + materialWorker = new SingleSegmentMaterialWorker(connection, cliFSPReader, functionName, messageBus); + promoWorker = new PromoWorker(connection, cliFSPReader, functionName, messageBus); + adWorker = new ADWorker(connection, cliFSPReader, functionName, messageBus); + } + public TrafficAPI(string connString, string user, string password, int timeout, string functionName, IMessageBus messageBus) { var correctedTimeout = timeout < 1000 ? 1000 : timeout; connectionString = String.Format("{0};User ID={1};Password={2};Connection Timeout={3}", connString, user, password, correctedTimeout / 1000); @@ -35,10 +57,10 @@ namespace TrafficClient { return materialWorker.GetMaterialArchiveMetadata(strParam); } - public void Approve(int itemID, bool ready, MetadataType kind) { + public void Approve(int itemID, bool ready, MetadataType kind, bool ifCompleted) { switch (kind) { case MetadataType.TrafficMaterial: { - materialWorker.SetMaterialOK(itemID, ready); + materialWorker.SetMaterialOK(itemID, ready, ifCompleted); break; } case MetadataType.TrafficAD: { @@ -52,14 +74,33 @@ namespace TrafficClient { } } - public void SaveSegments(int itemID, MetadataType kind, List segments) { + public string SaveSegments(int itemID, MetadataType kind, List segments, List selectedSegments) { + string result = null; switch (kind) { case MetadataType.TrafficMaterial: { - //egyebkent nem fogadja el a szegmnesadatokat? - materialWorker.SetMaterialOK(itemID, false); - materialWorker.DeleteMaterialSegments(itemID); - foreach (MovieSegment actualSegment in segments) - materialWorker.AddMaterialSegment(itemID, actualSegment); + if (true.Equals(Parameters?.Configuration?.MultiSegmentEnabled)) { + materialWorker.SetMaterialOK(itemID, false); + int delSegCount = selectedSegments.Count - segments.Count; + while (delSegCount > 0) { + var segNr = (int)selectedSegments[selectedSegments.Count - 1].SegmentNr; + materialWorker.DeleteMaterialSegment(itemID, segNr); + selectedSegments.RemoveAt(selectedSegments.Count - 1); + delSegCount--; + } + + for (int i = 0; i < segments.Count; i++) { + MovieSegment actualSegment = segments[i]; + var segNr = (int)selectedSegments[i].SegmentNr; + result = materialWorker.AddMaterialSegment(itemID, actualSegment, result, segNr); + } + + } else { + //egyebkent nem fogadja el a szegmnesadatokat? + materialWorker.SetMaterialOK(itemID, false); + materialWorker.DeleteMaterialSegments(itemID); + foreach (MovieSegment actualSegment in segments) + materialWorker.AddMaterialSegment(itemID, actualSegment); + } break; } case MetadataType.TrafficAD: { @@ -73,6 +114,7 @@ namespace TrafficClient { break; } } + return result; } public List GetPromos(string search, bool problematic, DateTime? from = null, DateTime? to = null) { diff --git a/client/PlanAIRClient/TrafficClasses.cs b/client/PlanAIRClient/TrafficClasses.cs deleted file mode 100644 index f2771aee..00000000 --- a/client/PlanAIRClient/TrafficClasses.cs +++ /dev/null @@ -1,4 +0,0 @@ -namespace TrafficClient { - partial class TrafficContext { - } -} \ No newline at end of file diff --git a/client/PlanAIRClient/TrafficClasses.dbml b/client/PlanAIRClient/TrafficClasses.dbml deleted file mode 100644 index 55f03f0c..00000000 --- a/client/PlanAIRClient/TrafficClasses.dbml +++ /dev/null @@ -1,34 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/client/PlanAIRClient/TrafficClasses.dbml.layout b/client/PlanAIRClient/TrafficClasses.dbml.layout deleted file mode 100644 index 61038ffc..00000000 --- a/client/PlanAIRClient/TrafficClasses.dbml.layout +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/client/PlanAIRClient/TrafficClasses.designer.cs b/client/PlanAIRClient/TrafficClasses.designer.cs deleted file mode 100644 index 555d8e07..00000000 --- a/client/PlanAIRClient/TrafficClasses.designer.cs +++ /dev/null @@ -1,60 +0,0 @@ -#pragma warning disable 1591 -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:4.0.30319.42000 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace TrafficClient { - using System.Data.Linq; - using System.Data.Linq.Mapping; - using System.Reflection; - - - [global::System.Data.Linq.Mapping.DatabaseAttribute(Name = "CLArchiveTF_0")] - public partial class TrafficContext : System.Data.Linq.DataContext { - - private static System.Data.Linq.Mapping.MappingSource mappingSource = new AttributeMappingSource(); - - #region Extensibility Method Definitions - partial void OnCreated(); - #endregion - - public TrafficContext() : - base(global::TrafficClient.Properties.Settings.Default.CLArchiveTF_0ConnectionString, mappingSource) { - OnCreated(); - } - - public TrafficContext(string connection) : - base(connection, mappingSource) { - OnCreated(); - } - - public TrafficContext(System.Data.IDbConnection connection) : - base(connection, mappingSource) { - OnCreated(); - } - - public TrafficContext(string connection, System.Data.Linq.Mapping.MappingSource mappingSource) : - base(connection, mappingSource) { - OnCreated(); - } - - public TrafficContext(System.Data.IDbConnection connection, System.Data.Linq.Mapping.MappingSource mappingSource) : - base(connection, mappingSource) { - OnCreated(); - } - - [global::System.Data.Linq.Mapping.FunctionAttribute(Name = "dbo.clIFsp_EC_MAM")] - public ISingleResult clIFsp_EC_MAM([global::System.Data.Linq.Mapping.ParameterAttribute(Name = "Operation", DbType = "Int")] System.Nullable operation, [global::System.Data.Linq.Mapping.ParameterAttribute(Name = "@@Options", DbType = "Int")] System.Nullable @__Options, [global::System.Data.Linq.Mapping.ParameterAttribute(Name = "@ItemID", DbType = "Int")] System.Nullable _ItemID, [global::System.Data.Linq.Mapping.ParameterAttribute(Name = "@IntParam1", DbType = "Int")] System.Nullable _IntParam1, [global::System.Data.Linq.Mapping.ParameterAttribute(Name = "@IntParam2", DbType = "Int")] System.Nullable _IntParam2, [global::System.Data.Linq.Mapping.ParameterAttribute(Name = "@IntParam3", DbType = "Int")] System.Nullable _IntParam3, [global::System.Data.Linq.Mapping.ParameterAttribute(Name = "@StrParam1", DbType = "VarChar(200)")] string _StrParam1, [global::System.Data.Linq.Mapping.ParameterAttribute(Name = "@StrParam2", DbType = "VarChar(MAX)")] string _StrParam2, [global::System.Data.Linq.Mapping.ParameterAttribute(Name = "@DateParam1", DbType = "DateTime")] System.Nullable _DateParam1, [global::System.Data.Linq.Mapping.ParameterAttribute(Name = "@DateParam2", DbType = "DateTime")] System.Nullable _DateParam2) { - IExecuteResult result = this.ExecuteMethodCall(this, ((MethodInfo)(MethodInfo.GetCurrentMethod())), operation, @__Options, _ItemID, _IntParam1, _IntParam2, _IntParam3, _StrParam1, _StrParam2, _DateParam1, _DateParam2); - return ((ISingleResult)(result.ReturnValue)); - } - } - -} -#pragma warning restore 1591 diff --git a/client/PlanAIRClient/TrafficClient.csproj b/client/PlanAIRClient/TrafficClient.csproj index 9fc03e5b..bc47cf89 100644 --- a/client/PlanAIRClient/TrafficClient.csproj +++ b/client/PlanAIRClient/TrafficClient.csproj @@ -90,12 +90,13 @@ - - + - - + + + + Component @@ -114,14 +115,6 @@ TrafficLookupResultSelector.cs - - TrafficClasses.dbml - - - True - True - TrafficClasses.dbml - @@ -129,7 +122,6 @@ True Settings.settings - UserControl @@ -147,14 +139,6 @@ Always - - MSLinqToSQLGenerator - TrafficClasses.designer.cs - Designer - - - TrafficClasses.dbml - SettingsSingleFileGenerator Settings.Designer.cs diff --git a/client/PlanAIRClient/TrafficIDSelector.cs b/client/PlanAIRClient/TrafficIDSelector.cs index 85dc21cd..0249fcb5 100644 --- a/client/PlanAIRClient/TrafficIDSelector.cs +++ b/client/PlanAIRClient/TrafficIDSelector.cs @@ -1,17 +1,19 @@ -using System.Windows.Forms; -using System; -using System.Linq; -using System.Collections.Generic; +using Interfaces; using MaestroShared.Commons; using MaestroShared.Configuration; -using System.Text.RegularExpressions; using MaestroShared.MessageBus; +using MaestroShared.Metadata; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text.RegularExpressions; +using System.Windows.Forms; namespace TrafficClient { - public delegate void OnSelectedIDChanged(string ID, int variantID, string text); + public delegate void OnSelectedIDChanged(string ID, int variantID, string text, List selected); public partial class TrafficIDSelector : UserControl { - public TrafficAPI trafficAPI { get; private set; } + public ITrafficAPI trafficAPI { get; private set; } public OnSelectedIDChanged IDChangedEvent { get; set; } private DataGridViewCheckBoxCell selectedCell; private bool refreshDisabled; @@ -26,14 +28,12 @@ namespace TrafficClient { } - private void InitializeTexts() { + private void Initialize() { TrafficMetadata metadata = parameters?.Configuration ?? new TrafficMetadata(); - dgTraffic.AutoGenerateColumns = false; - chkProblematic.Text = metadata.Resource("PROBLEMATIC", Resources.PROBLEMATIC); rbMaterial.Text = metadata.Resource("MATERIAL", Resources.MATERIAL); - rbPromo.Text = metadata.Resource("PROMOTION", Resources.PROMOTION); + rbPromo.Text = metadata.Resource("PROMOTION", Resources.PROMOTION); rbAD.Text = metadata.Resource("ADVERTISEMENT", Resources.ADVERTISEMENT); } @@ -42,8 +42,8 @@ namespace TrafficClient { parameters = value; var server = parameters.Configuration?.Server; if (server != null && server.Address != null) - trafficAPI = new TrafficAPI(server.Address.OriginalString, server.UserName, server.Password, server.Timeout, parameters.Configuration?.FunctionName, value.MessageBus); - InitializeTexts(); + trafficAPI = new TrafficAPI(parameters); + Initialize(); RefreshResults(); } } @@ -61,7 +61,10 @@ namespace TrafficClient { dgTraffic.Columns.Clear(); TrafficMetadata metadata = parameters?.Configuration ?? new TrafficMetadata(); if (rbMaterial.Checked) { - dgTraffic.Columns.AddRange(GetMaterialColumns(metadata)); + if (true.Equals(parameters?.Configuration?.MultiSegmentEnabled)) + dgTraffic.Columns.AddRange(GetMultiMaterialColumns(metadata)); + else + dgTraffic.Columns.AddRange(GetSingleMaterialColumns(metadata)); string searchText = Regex.Replace(txtFilter.Text, "[^0-9]", ""); items = trafficAPI.GetMaterials(searchText, chkProblematic.Checked, scheduledDate, scheduledDate); } else if (rbAD.Checked) { @@ -114,22 +117,47 @@ namespace TrafficClient { private void OnSelectionChanged(DataGridViewRow actualRow) { TrafficItem trafficItem = actualRow.DataBoundItem as TrafficItem; DataGridViewCheckBoxCell actualCell = actualRow.Cells[0] as DataGridViewCheckBoxCell; - if (!actualCell.Equals(selectedCell)) { - ClearSelection(); - selectedCell = actualRow.Cells[0] as DataGridViewCheckBoxCell; - } + List items = trafficAPIBindingSource.DataSource as List; + + bool selfClick = actualCell.Equals(selectedCell); + + selectedCell = actualRow.Cells[0] as DataGridViewCheckBoxCell; selectedCell.Value = !(bool)selectedCell.Value; bool selected = (bool)selectedCell.Value; - if (selected) { - CreateVersionIfMissing(trafficItem); - IDChangedEvent?.Invoke(trafficItem.MediaID, trafficItem.VariantID, trafficItem.Title); + if (true.Equals(parameters?.Configuration?.MultiSegmentEnabled)) { + bool clear = true; + List selectedOthers = null; + if (selected) { + selectedOthers = new List(); + foreach (DataGridViewRow r in dgTraffic.Rows) { + TrafficItem item = r.DataBoundItem as TrafficItem; + if (item.Selected && item.VariantID != trafficItem.VariantID) + selectedOthers.Add(r); + } + if (selectedOthers?.Count() == 0) + clear = false; + } + if (clear) + selectedOthers?.ForEach(r => r.Cells[0].Value = false); + } else { + foreach (DataGridViewRow r in dgTraffic.Rows) { + TrafficItem item = r.DataBoundItem as TrafficItem; + if (actualRow != r && item.Selected) + r.Cells[0].Value = false; + } } - else - IDChangedEvent?.Invoke(null, 0, null); + + List selectedItems = items?.Where(i => i.Selected).ToList(); + if (selectedItems?.Count() > 0) { + CreateVersionIfMissing(trafficItem); + IDChangedEvent?.Invoke(trafficItem.MediaID, trafficItem.VariantID, trafficItem.Title, selectedItems); + } else + IDChangedEvent?.Invoke(null, 0, null, null); } private void CreateVersionIfMissing(TrafficItem trafficItem) { + /* if (String.IsNullOrEmpty(trafficItem.MediaID)) { var currentVersion = trafficAPI.GetMaterials(trafficItem.EpisodeID, false)?.FirstOrDefault(); if (currentVersion == null || String.IsNullOrEmpty(currentVersion.MediaID)) { @@ -152,13 +180,15 @@ namespace TrafficClient { RefreshResults(); } } + */ } public void ClearSelection() { - if (selectedCell == null) - return; - selectedCell.Value = false; - selectedCell = null; + foreach (DataGridViewRow r in dgTraffic.Rows) { + TrafficItem item = r.DataBoundItem as TrafficItem; + if (item.Selected) + r.Cells[0].Value = false; + } } private void OnDataGridKeyDown(object sender, KeyEventArgs e) { @@ -252,35 +282,6 @@ namespace TrafficClient { } } - public class TrafficItem { - public bool Selected { get; set; } - public string MediaID { get; set; } - public bool OK { get; set; } - public string Title { get; set; } - public DateTime? NextBroadcastDate { get; set; } - public DateTime? FirstBroadcastDate { get; set; } - public short SegmentCount { get; set; } - public short EpisodeNumber { get; set; } - public string EpisodeTitle { get; set; } - public int VariantID { get; set; } - public string EpisodeID { get; set; } - } - - public class TrafficVersion { - public string MediaID { get; set; } - public int VariantID { get; set; } - } - - public class TrafficItemMetadata { - public string ProgTitle { get; set; } - public string ProgDescription { get; set; } - public string ProgID { get; set; } - public string EpisodeTitle { get; set; } - public string EpisodeDescription { get; set; } - public string EpisodeID { get; set; } - public bool OK { get; set; } - } - public class TrafficAPIMessage : MaestroMessage { public TrafficAPIMessage(string message) : base(message) { } diff --git a/client/PlanAIRClient/TrafficIDSelectorColumns.cs b/client/PlanAIRClient/TrafficIDSelectorColumns.cs index 68cda895..2858a86c 100644 --- a/client/PlanAIRClient/TrafficIDSelectorColumns.cs +++ b/client/PlanAIRClient/TrafficIDSelectorColumns.cs @@ -4,7 +4,7 @@ using System.Windows.Forms; namespace TrafficClient { public partial class TrafficIDSelector { - DataGridViewColumn[] GetMaterialColumns(TrafficMetadata metadata) { + DataGridViewColumn[] GetSingleMaterialColumns(TrafficMetadata metadata) { return new DataGridViewColumn[] { new DataGridViewCheckBoxColumn() { AutoSizeMode = DataGridViewAutoSizeColumnMode.DisplayedCells, @@ -42,7 +42,7 @@ namespace TrafficClient { }, new DataGridViewTextBoxColumn() { AutoSizeMode = DataGridViewAutoSizeColumnMode.None, - DataPropertyName = "FirsBroadcastDate", + DataPropertyName = "FirstBroadcastDate", HeaderText = metadata.Resource("FIRSTBROADCASTDATE", Resources.FIRSTBROADCASTDATE), Width = 100 }, @@ -67,6 +67,70 @@ namespace TrafficClient { }; } + DataGridViewColumn[] GetMultiMaterialColumns(TrafficMetadata metadata) { + return new DataGridViewColumn[] { + new DataGridViewCheckBoxColumn() { + AutoSizeMode = DataGridViewAutoSizeColumnMode.DisplayedCells, + DataPropertyName = "Selected", + Frozen = true + }, + new DataGridViewTextBoxColumn() { + AutoSizeMode = DataGridViewAutoSizeColumnMode.None, + DataPropertyName = "MediaID", + HeaderText = metadata.Resource("TRAFFICID", Resources.TRAFFICID), + Width = 100 + }, + new DataGridViewTextBoxColumn() { + AutoSizeMode = DataGridViewAutoSizeColumnMode.None, + DataPropertyName = "Segment", + HeaderText = metadata.Resource("SEGMENT", Resources.SEGMENT), + Width = 100 + }, + new DataGridViewTextBoxColumn() { + AutoSizeMode = DataGridViewAutoSizeColumnMode.None, + DataPropertyName = "Title", + HeaderText = metadata.Resource("TITLE", Resources.TITLE), + Width = 100 + }, + new DataGridViewTextBoxColumn() { + AutoSizeMode = DataGridViewAutoSizeColumnMode.None, + DataPropertyName = "EpisodeTitle", + HeaderText = metadata.Resource("EPISODETITLE", Resources.EPISODETITLE), + Width = 100 + }, + new DataGridViewCheckBoxColumn() { + AutoSizeMode = DataGridViewAutoSizeColumnMode.DisplayedCells, + DataPropertyName = "OK", + ReadOnly = true + }, + new DataGridViewTextBoxColumn() { + AutoSizeMode = DataGridViewAutoSizeColumnMode.None, + DataPropertyName = "EpisodeNumber", + HeaderText = metadata.Resource("EPISODENUMBER", Resources.EPISODENUMBER), + Width = 100 + }, + new DataGridViewTextBoxColumn() { + AutoSizeMode = DataGridViewAutoSizeColumnMode.None, + DataPropertyName = "EpisodeID", + HeaderText = metadata.Resource("EPISODEID", Resources.EPISODEID), + Width = 100 + }, + new DataGridViewTextBoxColumn() { + AutoSizeMode = DataGridViewAutoSizeColumnMode.None, + DataPropertyName = "FirstBroadcastDate", + HeaderText = metadata.Resource("FIRSTBROADCASTDATE", Resources.FIRSTBROADCASTDATE), + Width = 100 + }, + new DataGridViewTextBoxColumn() { + AutoSizeMode = DataGridViewAutoSizeColumnMode.None, + DataPropertyName = "NextBroadcastDate", + HeaderText = metadata.Resource("NEXTBROADCASTDATE", Resources.NEXTBROADCASTDATE), + Width = 100 + }, + }; + } + + DataGridViewColumn[] GetADColumns(TrafficMetadata metadata) { return new DataGridViewColumn[] { new DataGridViewCheckBoxColumn() { diff --git a/client/PlanAIRClient/TrafficLookupResultSelector.cs b/client/PlanAIRClient/TrafficLookupResultSelector.cs index 2a05da24..8bf9f3ee 100644 --- a/client/PlanAIRClient/TrafficLookupResultSelector.cs +++ b/client/PlanAIRClient/TrafficLookupResultSelector.cs @@ -1,4 +1,5 @@ -using System; +using MaestroShared.Metadata; +using System; using System.Collections.Generic; using System.Windows.Forms; diff --git a/client/PlanAIRClient/TrafficConfiguration.cs b/client/PlanAIRClient/TrafficParameters.cs similarity index 100% rename from client/PlanAIRClient/TrafficConfiguration.cs rename to client/PlanAIRClient/TrafficParameters.cs diff --git a/client/PlanAIRClient/Workers/ADWorker.cs b/client/PlanAIRClient/Workers/ADWorker.cs index 4e70aa44..57e2b4ef 100644 --- a/client/PlanAIRClient/Workers/ADWorker.cs +++ b/client/PlanAIRClient/Workers/ADWorker.cs @@ -5,6 +5,7 @@ using System; using System.Collections.Generic; using System.Data; using System.Data.SqlClient; +using TrafficClient.Model; namespace TrafficClient.Workers { public class ADWorker : TrafficWorker { @@ -55,7 +56,7 @@ namespace TrafficClient.Workers { while (reader.Read()) { if (result == null) result = new List(); - PlanAirADResult item = cliFSPReader.ToclIFsp_MAMAdvertisementResult(reader); + PlanAirADResult item = dataReader.ToADResult(reader); result.Add(ToTrafficItem(item)); } } @@ -112,7 +113,7 @@ namespace TrafficClient.Workers { while (reader.Read()) { if (result == null) result = new List(); - PlanAirADResult item = cliFSPReader.ToclIFsp_MAMAdvertisementResult(reader); + PlanAirADResult item = dataReader.ToADResult(reader); result.Add(ToTrafficItemMetadata(item)); } } @@ -170,7 +171,7 @@ namespace TrafficClient.Workers { while (reader.Read()) { if (result == null) result = new List(); - PlanAirADResult item = cliFSPReader.ToclIFsp_MAMAdvertisementResult(reader); + PlanAirADResult item = dataReader.ToADResult(reader); MovieSegment segment = ToSegment(item); if (segment.TCOut.Frames != 0) result.Add(segment); diff --git a/client/PlanAIRClient/Workers/MultiSegmentMaterialWorker.cs b/client/PlanAIRClient/Workers/MultiSegmentMaterialWorker.cs index 67f95b34..e7646f1c 100644 --- a/client/PlanAIRClient/Workers/MultiSegmentMaterialWorker.cs +++ b/client/PlanAIRClient/Workers/MultiSegmentMaterialWorker.cs @@ -1,9 +1,33 @@ -using NLog; +using LinkDotNet.MessageHandling.Contracts; +using MaestroShared.Metadata; +using NLog; +using System.Data.SqlClient; +using TrafficClient.Model; namespace TrafficClient.Workers { - public class MultiSegmentMaterialWorker : TrafficWorker { - + public class MultiSegmentMaterialWorker : SingleSegmentMaterialWorker { private static Logger logger = LogManager.GetCurrentClassLogger(); + + public MultiSegmentMaterialWorker(SqlConnection connection, PlanAirDataReader cliFSPReader, string functionName, IMessageBus messageBus) + : base(connection, cliFSPReader, functionName, messageBus) { + } + + protected override int GetMaterialsID { + get => 6002; + } + + protected override TrafficItem CreateTrafficItem(SqlDataReader reader) { + PlanAirMaterialResult item = dataReader.ToMultiMaterialResult(reader); + TrafficItem trafficItem = ToTrafficItem(item); + return trafficItem; + } + + protected override int AddMaterialSegmentsID { + get => 6115; + } + + } + } diff --git a/client/PlanAIRClient/Workers/PromoWorker.cs b/client/PlanAIRClient/Workers/PromoWorker.cs index 03972a83..6b2a5e8b 100644 --- a/client/PlanAIRClient/Workers/PromoWorker.cs +++ b/client/PlanAIRClient/Workers/PromoWorker.cs @@ -6,6 +6,7 @@ using System.Collections.Generic; using System.Data; using System.Data.SqlClient; using System.Diagnostics; +using TrafficClient.Model; namespace TrafficClient.Workers { public class PromoWorker : TrafficWorker { @@ -61,7 +62,7 @@ namespace TrafficClient.Workers { while (reader.Read()) { if (result == null) result = new List(); - PlanAirPromoResult item = cliFSPReader.ToclIFsp_MAMPromotionalResult(reader); + PlanAirPromoResult item = dataReader.ToPromoResult(reader); result.Add(ToTrafficItem(item)); } } @@ -108,7 +109,7 @@ namespace TrafficClient.Workers { while (reader.Read()) { if (result == null) result = new List(); - PlanAirPromoResult item = cliFSPReader.ToclIFsp_MAMPromotionalResult(reader); + PlanAirPromoResult item = dataReader.ToPromoResult(reader); result.Add(ToTrafficItemMetadata(item)); } } @@ -167,7 +168,7 @@ namespace TrafficClient.Workers { if (result == null) result = new List(); - PlanAirPromoResult item = cliFSPReader.ToclIFsp_MAMPromotionalResult(reader); + PlanAirPromoResult item = dataReader.ToPromoResult(reader); MovieSegment segment = ToSegment(item); if (segment.TCOut.Frames != 0) result.Add(segment); diff --git a/client/PlanAIRClient/Workers/SingleSegmentMaterialWorker.cs b/client/PlanAIRClient/Workers/SingleSegmentMaterialWorker.cs index 7bc9463f..95953902 100644 --- a/client/PlanAIRClient/Workers/SingleSegmentMaterialWorker.cs +++ b/client/PlanAIRClient/Workers/SingleSegmentMaterialWorker.cs @@ -5,6 +5,7 @@ using System; using System.Collections.Generic; using System.Data; using System.Data.SqlClient; +using TrafficClient.Model; namespace TrafficClient.Workers { @@ -16,10 +17,8 @@ namespace TrafficClient.Workers { : base(connection, cliFSPReader, functionName, messageBus) { } - private TrafficItem ToTrafficItem(clIFsp_EC_MAMBradocastResult data) { - //Debug.WriteLine(data.v_OkForAir); - - return new TrafficItem() { + protected TrafficItem ToTrafficItem(PlanAirMaterialResult data) { + var result = new TrafficItem() { MediaID = data.v_MediaID, EpisodeTitle = data.v_EpTitle, Title = data.v_ProgTitle, @@ -28,12 +27,23 @@ namespace TrafficClient.Workers { NextBroadcastDate = data.v_NextBroadcastDate, FirstBroadcastDate = data.v_FirstBroadcastDate, EpisodeID = data.v_EpisodeID, - SegmentCount = (short)data.v_VariantNrSegments, - OK = data.v_OkForAir != null && true.Equals(data.v_OkForAir) + OK = data.v_OkForAir != null && true.Equals(data.v_OkForAir), + SegmentCount = data.v_VariantNrSegments, + SegmentNr = data.v_SegNr, + SegmentId = data.v_SegID }; + if (data.v_SegID != null && data.v_SegTcOut > 0) { + result.MovieSegment = new MovieSegment { + TCIn = new Timecode((int)data.v_SegTcIn), + TCOut = new Timecode((int)data.v_SegTcOut), + Comment = data.v_SegTitle, + Optional = true.Equals(data.v_SegDropable) + }; + } + return result; } - private TrafficItemMetadata ToTrafficItemMetadata(clIFsp_EC_MAMBradocastResult data) { + private TrafficItemMetadata ToTrafficItemMetadata(PlanAirMaterialResult data) { return new TrafficItemMetadata() { EpisodeID = data.v_EpisodeID, EpisodeTitle = data.v_EpTitle, @@ -71,8 +81,8 @@ namespace TrafficClient.Workers { while (reader.Read()) { if (result == null) result = new List(); - clIFsp_EC_MAMBradocastResult item = cliFSPReader.ToclIFsp_MAMBroadcastResult(reader); - result.Add(ToTrafficItem(item)); + TrafficItem trafficItem = CreateTrafficItem(reader); + result.Add(trafficItem); } } } @@ -84,6 +94,11 @@ namespace TrafficClient.Workers { return result; } + protected virtual TrafficItem CreateTrafficItem(SqlDataReader reader) { + PlanAirMaterialResult item = dataReader.ToSingleMaterialResult(reader); + TrafficItem trafficItem = ToTrafficItem(item); + return trafficItem; + } public List GetMaterialArchiveMetadata(string strParam) { List result = null; @@ -91,7 +106,7 @@ namespace TrafficClient.Workers { TryConnect(); using (SqlCommand cmd = CreateCommmad()) { cmd.CommandType = CommandType.StoredProcedure; - cmd.Parameters.AddWithValue("@Operation", GetMaterialsID); + cmd.Parameters.AddWithValue("@Operation", 1002); cmd.Parameters.AddWithValue("@@@Options", 0); cmd.Parameters.AddWithValue("@@ItemID", DBNull.Value); cmd.Parameters.AddWithValue("@@StrParam1", strParam); @@ -100,7 +115,7 @@ namespace TrafficClient.Workers { while (reader.Read()) { if (result == null) result = new List(); - clIFsp_EC_MAMBradocastResult item = cliFSPReader.ToclIFsp_MAMBroadcastResult(reader); + PlanAirMaterialResult item = dataReader.ToSingleMaterialResult(reader); result.Add(ToTrafficItemMetadata(item)); } } @@ -153,16 +168,45 @@ namespace TrafficClient.Workers { get => 1100; } - public void SetMaterialOK(int itemID, bool ok) { + public void SetMaterialOK(int itemID, bool ok, bool ifCompleted = false) { try { + if (ifCompleted) { + logger.Info("Checking if material {0} can be approved", itemID); + List items = GetMaterials(itemID.ToString(), false, null, null); + if (items == null || items.Count == 0) { + logger.Info("Material {0} not exists", itemID); + return; + } + var allCount = items[0].SegmentCount; + if (allCount == 0) { + logger.Info("Material {0} has no segments", itemID); + } + + List segments = GetMaterialSegments(itemID); + if (allCount != segments.Count) { + logger.Info("Material {0} needs more segments", itemID); + } + + if (segments == null || segments.Count == 0) { + logger.Info("Material {0} not exists", itemID); + } + foreach (MovieSegment segment in segments) { + if (segment.TCOut.Frames == 0) { + logger.Info("Material {0} has untouched segment", itemID); + return; + } + } + + logger.Info("Approving material {0}", itemID); + } + TryConnect(); - int options = ok ? 1 : 0; using (SqlCommand cmd = CreateCommmad()) { cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@Operation", SetMaterialOKID); cmd.Parameters.AddWithValue("@@ItemID", itemID); cmd.Parameters.AddWithValue("@@@Options", DBNull.Value); - cmd.Parameters.AddWithValue("@@IntParam1", options); + cmd.Parameters.AddWithValue("@@IntParam1", ok ? 1 : 0); cmd.ExecuteNonQuery(); } } catch (Exception e) { @@ -181,24 +225,20 @@ namespace TrafficClient.Workers { }; } - protected virtual int GetMaterialSegmentsID { - get => 1010; - } - public List GetMaterialSegments(int itemID) { List result = null; try { TryConnect(); using (SqlCommand cmd = CreateCommmad()) { cmd.CommandType = CommandType.StoredProcedure; - cmd.Parameters.AddWithValue("@Operation", GetMaterialSegmentsID); + cmd.Parameters.AddWithValue("@Operation", 1010); cmd.Parameters.AddWithValue("@@@Options", DBNull.Value); cmd.Parameters.AddWithValue("@@ItemID", itemID); using (SqlDataReader reader = cmd.ExecuteReader()) { while (reader.Read()) { if (result == null) result = new List(); - PlanAirMaterialSegmentResult item = cliFSPReader.ToclIFsp_SegmentResult(reader); + PlanAirMaterialSegmentResult item = dataReader.ToMaterialSegmentResult(reader); result.Add(ToSegment(item)); } } @@ -248,21 +288,28 @@ namespace TrafficClient.Workers { } } - public void AddMaterialSegment(int itemID, MovieSegment segment) { - object comment = segment.Comment; - if (String.IsNullOrEmpty(segment.Comment)) - comment = DBNull.Value; + protected virtual int AddMaterialSegmentsID { + get => 1115; + } + + public string AddMaterialSegment(int itemID, MovieSegment segment, string fileName = null, int segNr = 0) { try { TryConnect(); using (SqlCommand cmd = CreateCommmad()) { int optionalParam = segment.Optional ? 1 : 0; cmd.CommandType = CommandType.StoredProcedure; - cmd.Parameters.AddWithValue("@Operation", 1115); + cmd.Parameters.AddWithValue("@Operation", AddMaterialSegmentsID); cmd.Parameters.AddWithValue("@@ItemID", itemID); cmd.Parameters.AddWithValue("@@IntParam1", segment.TCIn.Frames); cmd.Parameters.AddWithValue("@@IntParam2", segment.TCOut.Frames); - cmd.Parameters.AddWithValue("@@StrParam1", comment); + cmd.Parameters.AddWithValue("@@IntParam3", segNr); + if (segment.Comment == null) + cmd.Parameters.AddWithValue("@@StrParam1", DBNull.Value); + else + cmd.Parameters.AddWithValue("@@StrParam1", segment.Comment); cmd.Parameters.AddWithValue("@@StrParam2", DBNull.Value); + if (fileName != null) + cmd.Parameters.AddWithValue("@@StrParam3", fileName); cmd.Parameters.AddWithValue("@@@Options", optionalParam); cmd.ExecuteNonQuery(); } @@ -271,6 +318,7 @@ namespace TrafficClient.Workers { } finally { connection.Close(); } + return null; } } diff --git a/client/PlanAIRClient/Workers/TrafficWorker.cs b/client/PlanAIRClient/Workers/TrafficWorker.cs index 508a7367..e96e6acd 100644 --- a/client/PlanAIRClient/Workers/TrafficWorker.cs +++ b/client/PlanAIRClient/Workers/TrafficWorker.cs @@ -8,13 +8,13 @@ namespace TrafficClient.Workers { public class TrafficWorker { protected IMessageBus messageBus; - protected PlanAirDataReader cliFSPReader; + protected PlanAirDataReader dataReader; private readonly string functionName; protected SqlConnection connection; - public TrafficWorker(SqlConnection connection, PlanAirDataReader cliFSPReader, string functionName, IMessageBus messageBus) { + public TrafficWorker(SqlConnection connection, PlanAirDataReader dataReader, string functionName, IMessageBus messageBus) { this.connection = connection; - this.cliFSPReader = cliFSPReader; + this.dataReader = dataReader; this.functionName = functionName; this.messageBus = messageBus; } diff --git a/client/PlanAIRClient/clIFsp_EC_MAMBradocastResult.cs b/client/PlanAIRClient/clIFsp_EC_MAMBradocastResult.cs deleted file mode 100644 index 6a49b0da..00000000 --- a/client/PlanAIRClient/clIFsp_EC_MAMBradocastResult.cs +++ /dev/null @@ -1,259 +0,0 @@ -namespace TrafficClient { - public partial class clIFsp_EC_MAMBradocastResult { - - private int _v_ProgrammeID; - - private bool _v_Live; - - private string _v_EpisodeID; - - private System.Nullable _v_VariantID; - - private System.Nullable _v_VariantTypeID; - - private string _v_ProgTitle; - - private string _v_EpTitle; - - private System.Nullable _v_Episode; - - private string _v_VariantType; - - private string _v_VariantKeywords; - - private string _v_VariantLengthTC; - - private System.Nullable _v_VariantLengthFrame; - - private System.Nullable _v_VariantNrSegments; - - private System.Nullable _v_FirstBroadcastDate; - - private System.Nullable _v_NextBroadcastDate; - - private System.Nullable _v_OkForAir; - - private System.Nullable _v_ForTransm; - - private string _v_MediaID; - - public clIFsp_EC_MAMBradocastResult() { - } - - [global::System.Data.Linq.Mapping.ColumnAttribute(Storage = "_v_ProgrammeID", DbType = "Int NOT NULL")] - public int v_ProgrammeID { - get { - return this._v_ProgrammeID; - } - set { - if ((this._v_ProgrammeID != value)) { - this._v_ProgrammeID = value; - } - } - } - - [global::System.Data.Linq.Mapping.ColumnAttribute(Storage = "_v_Live", DbType = "Bit NOT NULL")] - public bool v_Live { - get { - return this._v_Live; - } - set { - if ((this._v_Live != value)) { - this._v_Live = value; - } - } - } - - [global::System.Data.Linq.Mapping.ColumnAttribute(Storage = "_v_EpisodeID", DbType = "VarChar(6) NOT NULL", CanBeNull = false)] - public string v_EpisodeID { - get { - return this._v_EpisodeID; - } - set { - if ((this._v_EpisodeID != value)) { - this._v_EpisodeID = value; - } - } - } - - [global::System.Data.Linq.Mapping.ColumnAttribute(Storage = "_v_VariantID", DbType = "Int")] - public System.Nullable v_VariantID { - get { - return this._v_VariantID; - } - set { - if ((this._v_VariantID != value)) { - this._v_VariantID = value; - } - } - } - - [global::System.Data.Linq.Mapping.ColumnAttribute(Storage = "_v_VariantTypeID", DbType = "Int")] - public System.Nullable v_VariantTypeID { - get { - return this._v_VariantTypeID; - } - set { - if ((this._v_VariantTypeID != value)) { - this._v_VariantTypeID = value; - } - } - } - - [global::System.Data.Linq.Mapping.ColumnAttribute(Storage = "_v_ProgTitle", DbType = "NVarChar(60)")] - public string v_ProgTitle { - get { - return this._v_ProgTitle; - } - set { - if ((this._v_ProgTitle != value)) { - this._v_ProgTitle = value; - } - } - } - - [global::System.Data.Linq.Mapping.ColumnAttribute(Storage = "_v_EpTitle", DbType = "NVarChar(60)")] - public string v_EpTitle { - get { - return this._v_EpTitle; - } - set { - if ((this._v_EpTitle != value)) { - this._v_EpTitle = value; - } - } - } - - [global::System.Data.Linq.Mapping.ColumnAttribute(Storage = "_v_Episode", DbType = "SmallInt")] - public System.Nullable v_Episode { - get { - return this._v_Episode; - } - set { - if ((this._v_Episode != value)) { - this._v_Episode = value; - } - } - } - - [global::System.Data.Linq.Mapping.ColumnAttribute(Storage = "_v_VariantType", DbType = "VarChar(40)")] - public string v_VariantType { - get { - return this._v_VariantType; - } - set { - if ((this._v_VariantType != value)) { - this._v_VariantType = value; - } - } - } - - [global::System.Data.Linq.Mapping.ColumnAttribute(Storage = "_v_VariantKeywords", DbType = "VarChar(25)")] - public string v_VariantKeywords { - get { - return this._v_VariantKeywords; - } - set { - if ((this._v_VariantKeywords != value)) { - this._v_VariantKeywords = value; - } - } - } - - [global::System.Data.Linq.Mapping.ColumnAttribute(Storage = "_v_VariantLengthTC", DbType = "VarChar(150)")] - public string v_VariantLengthTC { - get { - return this._v_VariantLengthTC; - } - set { - if ((this._v_VariantLengthTC != value)) { - this._v_VariantLengthTC = value; - } - } - } - - [global::System.Data.Linq.Mapping.ColumnAttribute(Storage = "_v_VariantLengthFrame", DbType = "Int")] - public System.Nullable v_VariantLengthFrame { - get { - return this._v_VariantLengthFrame; - } - set { - if ((this._v_VariantLengthFrame != value)) { - this._v_VariantLengthFrame = value; - } - } - } - - [global::System.Data.Linq.Mapping.ColumnAttribute(Storage = "_v_VariantNrSegments", DbType = "Int")] - public System.Nullable v_VariantNrSegments { - get { - return this._v_VariantNrSegments; - } - set { - if ((this._v_VariantNrSegments != value)) { - this._v_VariantNrSegments = value; - } - } - } - - [global::System.Data.Linq.Mapping.ColumnAttribute(Storage = "_v_FirstBroadcastDate", DbType = "DateTime")] - public System.Nullable v_FirstBroadcastDate { - get { - return this._v_FirstBroadcastDate; - } - set { - if ((this._v_FirstBroadcastDate != value)) { - this._v_FirstBroadcastDate = value; - } - } - } - - [global::System.Data.Linq.Mapping.ColumnAttribute(Storage = "_v_NextBroadcastDate", DbType = "DateTime")] - public System.Nullable v_NextBroadcastDate { - get { - return this._v_NextBroadcastDate; - } - set { - if ((this._v_NextBroadcastDate != value)) { - this._v_NextBroadcastDate = value; - } - } - } - - [global::System.Data.Linq.Mapping.ColumnAttribute(Storage = "_v_OkForAir", DbType = "Bit")] - public System.Nullable v_OkForAir { - get { - return this._v_OkForAir; - } - set { - if ((this._v_OkForAir != value)) { - this._v_OkForAir = value; - } - } - } - - [global::System.Data.Linq.Mapping.ColumnAttribute(Storage = "_v_ForTransm", DbType = "Bit")] - public System.Nullable v_ForTransm { - get { - return this._v_ForTransm; - } - set { - if ((this._v_ForTransm != value)) { - this._v_ForTransm = value; - } - } - } - - [global::System.Data.Linq.Mapping.ColumnAttribute(Storage = "_v_MediaID", DbType = "VarChar(6) NOT NULL", CanBeNull = false)] - public string v_MediaID { - get { - return this._v_MediaID; - } - set { - if ((this._v_MediaID != value)) { - this._v_MediaID = value; - } - } - } - } -} diff --git a/server/-dependencies/pom.xml b/server/-dependencies/pom.xml index 6c4ff157..ceb004d3 100644 --- a/server/-dependencies/pom.xml +++ b/server/-dependencies/pom.xml @@ -119,6 +119,9 @@ default-cli + + + humble.video:linux:0.2.1 diff --git a/server/hu.user.mediacube.executors.tests/src/hu/user/mediacube/executors/tests/Support.java b/server/hu.user.mediacube.executors.tests/src/hu/user/mediacube/executors/tests/Support.java index bb610fc8..7c7ca260 100644 --- a/server/hu.user.mediacube.executors.tests/src/hu/user/mediacube/executors/tests/Support.java +++ b/server/hu.user.mediacube.executors.tests/src/hu/user/mediacube/executors/tests/Support.java @@ -8,6 +8,9 @@ import java.nio.file.Files; import java.nio.file.attribute.BasicFileAttributes; import java.sql.Timestamp; +import org.jboss.resteasy.client.jaxrs.ResteasyClient; +import org.jboss.resteasy.client.jaxrs.ResteasyClientBuilder; +import org.jboss.resteasy.client.jaxrs.ResteasyWebTarget; import org.junit.AfterClass; import org.junit.BeforeClass; import org.junit.Test; @@ -58,6 +61,23 @@ public class Support { assertTrue(actual.length() > 0); } + @Test + public void test_Solr() throws Exception { + //http://lucene.apache.org/solr/guide/7_5/using-solrj.html#using-solrj + ResteasyClient client = new ResteasyClientBuilder().build(); + ResteasyWebTarget webTarget = client.target(""); + + String query = "SELECT * FROM MEDIADESCRIPTION FETCH FIRST ROW ONLY"; + manager.executeQuery(query, rs -> { + rs.getLong("itemid"); + rs.getLong("mediaid"); + rs.getLong("mediafileid"); + rs.getString("description"); + return true; + }, null); + + } + @Test public void test1() throws Exception { File sourceFile = new File("c:\\thumbnail - generali\\ShellExtractLoadTest.exe"); diff --git a/server/user.jobengine.osgi.server/test/user/jobengine/server/IT/Support.java b/server/user.jobengine.osgi.server/test/user/jobengine/server/IT/Support.java index d5408eb5..d9b58311 100644 --- a/server/user.jobengine.osgi.server/test/user/jobengine/server/IT/Support.java +++ b/server/user.jobengine.osgi.server/test/user/jobengine/server/IT/Support.java @@ -592,4 +592,5 @@ public class Support { String idToCheck = houseid.substring(0, houseid.lastIndexOf("-")); System.out.println(idToCheck); } + } -- 2.54.0