From 8bed85a4141b35be0e6ecb83ec94c3db2b77fdf4 Mon Sep 17 00:00:00 2001 From: =?utf8?q?V=C3=A1s=C3=A1ry=20D=C3=A1niel?= Date: Fri, 7 Dec 2018 14:26:26 +0000 Subject: [PATCH] =?utf8?q?#115=20Multiszegmens=20Traffic=20list=C3=A1z?= =?utf8?q?=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;C31364 --- ...ertismentsResult.cs => PlanAirADResult.cs} | 12 +- .../{Reader.cs => PlanAirDataReader.cs} | 14 +- ...ult.cs => PlanAirMaterialSegmentResult.cs} | 14 +- ...otionalResult.cs => PlanAirPromoResult.cs} | 4 +- client/PlanAIRClient/TrafficAPI.cs | 26 +- .../PlanAIRClient/TrafficClasses.designer.cs | 431 ++---------------- client/PlanAIRClient/TrafficClient.csproj | 14 +- client/PlanAIRClient/Workers/ADWorker.cs | 91 +++- .../PlanAIRClient/Workers/MaterialWorker.cs | 170 ------- .../Workers/MultiSegmentMaterialWorker.cs | 9 + client/PlanAIRClient/Workers/PromoWorker.cs | 100 +++- ...rker.cs => SingleSegmentMaterialWorker.cs} | 304 ++++++------ client/PlanAIRClient/Workers/TrafficWorker.cs | 4 +- .../clIFsp_EC_MAMBradocastResult.cs | 259 +++++++++++ 14 files changed, 663 insertions(+), 789 deletions(-) rename client/PlanAIRClient/{clIFsp_EC_MAMAdvertismentsResult.cs => PlanAirADResult.cs} (92%) rename client/PlanAIRClient/{Reader.cs => PlanAirDataReader.cs} (88%) rename client/PlanAIRClient/{clIFsp_EC_SegmentResult.cs => PlanAirMaterialSegmentResult.cs} (92%) rename client/PlanAIRClient/{clIFsp_EC_MAMPromotionalResult.cs => PlanAirPromoResult.cs} (95%) delete mode 100644 client/PlanAIRClient/Workers/MaterialWorker.cs create mode 100644 client/PlanAIRClient/Workers/MultiSegmentMaterialWorker.cs rename client/PlanAIRClient/Workers/{SegmentWorker.cs => SingleSegmentMaterialWorker.cs} (53%) create mode 100644 client/PlanAIRClient/clIFsp_EC_MAMBradocastResult.cs diff --git a/client/PlanAIRClient/clIFsp_EC_MAMAdvertismentsResult.cs b/client/PlanAIRClient/PlanAirADResult.cs similarity index 92% rename from client/PlanAIRClient/clIFsp_EC_MAMAdvertismentsResult.cs rename to client/PlanAIRClient/PlanAirADResult.cs index d3fdab2f..5d34b50e 100644 --- a/client/PlanAIRClient/clIFsp_EC_MAMAdvertismentsResult.cs +++ b/client/PlanAIRClient/PlanAirADResult.cs @@ -1,11 +1,5 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace TrafficClient { - public partial class clIFsp_EC_MAMAdvertismentResult { +namespace TrafficClient { + public partial class PlanAirADResult { private int _t_SpotID; @@ -33,7 +27,7 @@ namespace TrafficClient { private string _v_OkForAirs; - public clIFsp_EC_MAMAdvertismentResult() { + public PlanAirADResult() { } [global::System.Data.Linq.Mapping.ColumnAttribute(Storage = "_t_SpotID", DbType = "Int NOT NULL")] diff --git a/client/PlanAIRClient/Reader.cs b/client/PlanAIRClient/PlanAirDataReader.cs similarity index 88% rename from client/PlanAIRClient/Reader.cs rename to client/PlanAIRClient/PlanAirDataReader.cs index 1b9cf432..d28422c7 100644 --- a/client/PlanAIRClient/Reader.cs +++ b/client/PlanAIRClient/PlanAirDataReader.cs @@ -2,7 +2,7 @@ using System.Data.SqlClient; namespace TrafficClient { - public class CliFSPReader { + public class PlanAirDataReader { private string ReadString(SqlDataReader reader, ref int f) { string result = null; @@ -64,8 +64,8 @@ namespace TrafficClient { return item; } - public clIFsp_EC_MAMPromotionalResult ToclIFsp_MAMPromotionalResult(SqlDataReader reader) { - clIFsp_EC_MAMPromotionalResult item = new clIFsp_EC_MAMPromotionalResult(); + public PlanAirPromoResult ToclIFsp_MAMPromotionalResult(SqlDataReader reader) { + PlanAirPromoResult item = new PlanAirPromoResult(); int f = 0; item.t_SpotID = (int)ReadInt(reader, ref f); item.t_MediaID = ReadString(reader, ref f); @@ -89,8 +89,8 @@ namespace TrafficClient { return item; } - public clIFsp_EC_MAMAdvertismentResult ToclIFsp_MAMAdvertisementResult(SqlDataReader reader) { - clIFsp_EC_MAMAdvertismentResult item = new clIFsp_EC_MAMAdvertismentResult(); + public PlanAirADResult ToclIFsp_MAMAdvertisementResult(SqlDataReader reader) { + PlanAirADResult item = new PlanAirADResult(); int f = 0; item.t_SpotID = (int)ReadInt(reader, ref f); item.t_MediaID = ReadString(reader, ref f); @@ -108,8 +108,8 @@ namespace TrafficClient { return item; } - public clIFsp_EC_SegmentResult ToclIFsp_SegmentResult(SqlDataReader reader) { - clIFsp_EC_SegmentResult item = new clIFsp_EC_SegmentResult(); + public PlanAirMaterialSegmentResult ToclIFsp_SegmentResult(SqlDataReader reader) { + PlanAirMaterialSegmentResult item = new PlanAirMaterialSegmentResult(); int f = 0; item.v_SegID = (int)ReadInt(reader, ref f); item.v_VariantID = ReadInt(reader, ref f); diff --git a/client/PlanAIRClient/clIFsp_EC_SegmentResult.cs b/client/PlanAIRClient/PlanAirMaterialSegmentResult.cs similarity index 92% rename from client/PlanAIRClient/clIFsp_EC_SegmentResult.cs rename to client/PlanAIRClient/PlanAirMaterialSegmentResult.cs index 6226e315..9fb85701 100644 --- a/client/PlanAIRClient/clIFsp_EC_SegmentResult.cs +++ b/client/PlanAIRClient/PlanAirMaterialSegmentResult.cs @@ -1,11 +1,5 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace TrafficClient { - public partial class clIFsp_EC_SegmentResult { +namespace TrafficClient { + public partial class PlanAirMaterialSegmentResult { private int _v_SegID; @@ -33,7 +27,7 @@ namespace TrafficClient { private bool? _v_Dropable; - public clIFsp_EC_SegmentResult() { + public PlanAirMaterialSegmentResult() { } [global::System.Data.Linq.Mapping.ColumnAttribute(Storage = "v_SegID", DbType = "Int NOT NULL")] @@ -191,6 +185,6 @@ namespace TrafficClient { } } - + } } diff --git a/client/PlanAIRClient/clIFsp_EC_MAMPromotionalResult.cs b/client/PlanAIRClient/PlanAirPromoResult.cs similarity index 95% rename from client/PlanAIRClient/clIFsp_EC_MAMPromotionalResult.cs rename to client/PlanAIRClient/PlanAirPromoResult.cs index 01ffebac..4171aaa6 100644 --- a/client/PlanAIRClient/clIFsp_EC_MAMPromotionalResult.cs +++ b/client/PlanAIRClient/PlanAirPromoResult.cs @@ -1,5 +1,5 @@ namespace TrafficClient { - public partial class clIFsp_EC_MAMPromotionalResult { + public partial class PlanAirPromoResult { private int _t_SpotID; @@ -39,7 +39,7 @@ private System.Nullable _v_IsInactive; - public clIFsp_EC_MAMPromotionalResult() { + public PlanAirPromoResult() { } [global::System.Data.Linq.Mapping.ColumnAttribute(Storage = "_t_SpotID", DbType = "Int NOT NULL")] diff --git a/client/PlanAIRClient/TrafficAPI.cs b/client/PlanAIRClient/TrafficAPI.cs index b30ddc5b..4ddd6b86 100644 --- a/client/PlanAIRClient/TrafficAPI.cs +++ b/client/PlanAIRClient/TrafficAPI.cs @@ -11,24 +11,20 @@ namespace TrafficClient { private static readonly Logger logger = LogManager.GetCurrentClassLogger(); private TrafficContext context = new TrafficContext(); private string connectionString; - private CliFSPReader cliFSPReader; + private PlanAirDataReader cliFSPReader; private SqlConnection connection; - private MaterialWorker materialWorker; + private SingleSegmentMaterialWorker materialWorker; private PromoWorker promoWorker; private ADWorker adWorker; - private SegmentWorker segmentWorker; - private readonly string functionName; 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); connection = new SqlConnection(connectionString); - cliFSPReader = new CliFSPReader(); - materialWorker = new MaterialWorker(connection, cliFSPReader, functionName, messageBus); + cliFSPReader = new PlanAirDataReader(); + materialWorker = new SingleSegmentMaterialWorker(connection, cliFSPReader, functionName, messageBus); promoWorker = new PromoWorker(connection, cliFSPReader, functionName, messageBus); adWorker = new ADWorker(connection, cliFSPReader, functionName, messageBus); - segmentWorker = new SegmentWorker(connection, cliFSPReader, functionName, messageBus); - this.functionName = functionName; } public List GetMaterials(string strParam, bool problematic, DateTime? from = null, DateTime? to = null) { @@ -61,19 +57,19 @@ namespace TrafficClient { case MetadataType.TrafficMaterial: { //egyebkent nem fogadja el a szegmnesadatokat? materialWorker.SetMaterialOK(itemID, false); - segmentWorker.DeleteMaterialSegments(itemID); + materialWorker.DeleteMaterialSegments(itemID); foreach (MovieSegment actualSegment in segments) - segmentWorker.AddMaterialSegment(itemID, actualSegment); + materialWorker.AddMaterialSegment(itemID, actualSegment); break; } case MetadataType.TrafficAD: { if (segments != null && segments.Count == 1) - segmentWorker.SaveADSegment(itemID, segments[0]); + adWorker.SaveADSegment(itemID, segments[0]); break; } case MetadataType.TrafficPromo: { if (segments != null && segments.Count == 1) - segmentWorker.SavePromoSegment(itemID, segments[0]); + promoWorker.SavePromoSegment(itemID, segments[0]); break; } } @@ -96,15 +92,15 @@ namespace TrafficClient { } public List GetMaterialSegments(int itemID) { - return segmentWorker.GetMaterialSegments(itemID); + return materialWorker.GetMaterialSegments(itemID); } public List GetPromoSegments(string strParam) { - return segmentWorker.GetPromoSegments(strParam); + return promoWorker.GetPromoSegments(strParam); } public List GetADSegments(string strParam) { - return segmentWorker.GetADSegments(strParam); + return adWorker.GetADSegments(strParam); } public TrafficVersion CreateMaterialVersion(string episodeID, bool recut) { diff --git a/client/PlanAIRClient/TrafficClasses.designer.cs b/client/PlanAIRClient/TrafficClasses.designer.cs index 390d87a9..555d8e07 100644 --- a/client/PlanAIRClient/TrafficClasses.designer.cs +++ b/client/PlanAIRClient/TrafficClasses.designer.cs @@ -9,397 +9,52 @@ // //------------------------------------------------------------------------------ -namespace TrafficClient -{ - using System.Data.Linq; - using System.Data.Linq.Mapping; - using System.Data; - using System.Collections.Generic; - using System.Reflection; - using System.Linq; - using System.Linq.Expressions; - using System.ComponentModel; - using System; - - - [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)); - } - } - - 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; +namespace TrafficClient { + using System.Data.Linq; + using System.Data.Linq.Mapping; + using System.Reflection; - 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; - } - } + [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 5f485281..9fc03e5b 100644 --- a/client/PlanAIRClient/TrafficClient.csproj +++ b/client/PlanAIRClient/TrafficClient.csproj @@ -68,6 +68,7 @@ x64 prompt MinimumRecommendedRules.ruleset + true @@ -89,18 +90,19 @@ + + + + + - - - Component CustomDataGridView.cs - True True @@ -134,10 +136,10 @@ TrafficIDSelector.cs - + + - diff --git a/client/PlanAIRClient/Workers/ADWorker.cs b/client/PlanAIRClient/Workers/ADWorker.cs index 40498b50..4e70aa44 100644 --- a/client/PlanAIRClient/Workers/ADWorker.cs +++ b/client/PlanAIRClient/Workers/ADWorker.cs @@ -1,20 +1,21 @@ -using System; +using LinkDotNet.MessageHandling.Contracts; +using MaestroShared.Metadata; +using NLog; +using System; using System.Collections.Generic; using System.Data; using System.Data.SqlClient; -using NLog; -using LinkDotNet.MessageHandling.Contracts; namespace TrafficClient.Workers { public class ADWorker : TrafficWorker { private static Logger logger = LogManager.GetCurrentClassLogger(); - public ADWorker(SqlConnection connection, CliFSPReader cliFSPReader, string functionName, IMessageBus messageBus) : + public ADWorker(SqlConnection connection, PlanAirDataReader cliFSPReader, string functionName, IMessageBus messageBus) : base(connection, cliFSPReader, functionName, messageBus) { } - private TrafficItem ToTrafficItem(clIFsp_EC_MAMAdvertismentResult data) { + private TrafficItem ToTrafficItem(PlanAirADResult data) { return new TrafficItem() { MediaID = data.t_MediaID, Title = data.v_Title, @@ -23,7 +24,7 @@ namespace TrafficClient.Workers { }; } - private TrafficItemMetadata ToTrafficItemMetadata(clIFsp_EC_MAMAdvertismentResult data) { + private TrafficItemMetadata ToTrafficItemMetadata(PlanAirADResult data) { return new TrafficItemMetadata() { EpisodeID = data.t_MediaID, EpisodeTitle = data.v_Title, @@ -54,16 +55,14 @@ namespace TrafficClient.Workers { while (reader.Read()) { if (result == null) result = new List(); - clIFsp_EC_MAMAdvertismentResult item = cliFSPReader.ToclIFsp_MAMAdvertisementResult(reader); + PlanAirADResult item = cliFSPReader.ToclIFsp_MAMAdvertisementResult(reader); result.Add(ToTrafficItem(item)); } } } - } - catch (Exception e) { + } catch (Exception e) { OnError(logger, e); - } - finally { + } finally { connection.Close(); } return result; @@ -92,11 +91,9 @@ namespace TrafficClient.Workers { cmd.Parameters.AddWithValue("@@IntParam2", DBNull.Value); cmd.ExecuteNonQuery(); } - } - catch (Exception e) { + } catch (Exception e) { OnError(logger, e); - } - finally { + } finally { connection.Close(); } } @@ -115,16 +112,74 @@ namespace TrafficClient.Workers { while (reader.Read()) { if (result == null) result = new List(); - clIFsp_EC_MAMAdvertismentResult item = cliFSPReader.ToclIFsp_MAMAdvertisementResult(reader); + PlanAirADResult item = cliFSPReader.ToclIFsp_MAMAdvertisementResult(reader); result.Add(ToTrafficItemMetadata(item)); } } } + } catch (Exception e) { + OnError(logger, e); + } finally { + connection.Close(); } - catch (Exception e) { + return result; + } + + private MovieSegment ToSegment(PlanAirADResult item) { + return new MovieSegment() { + TCIn = item.t_TcIn.HasValue ? new Timecode(item.t_TcIn.Value) : new Timecode(), + TCOut = item.t_TcOut.HasValue ? new Timecode(item.t_TcOut.Value) : new Timecode() + }; + } + + public void SaveADSegment(int itemID, MovieSegment segment) { + object comment = segment.Comment; + if (String.IsNullOrEmpty(segment.Comment)) + comment = DBNull.Value; + try { + TryConnect(); + using (SqlCommand cmd = CreateCommmad()) { + int optionalParam = segment.Optional ? 1 : 0; + cmd.CommandType = CommandType.StoredProcedure; + cmd.Parameters.AddWithValue("@Operation", 3100); + cmd.Parameters.AddWithValue("@@ItemID", itemID); + cmd.Parameters.AddWithValue("@@@Options", DBNull.Value); + cmd.Parameters.AddWithValue("@@IntParam1", segment.TCIn.Frames); + cmd.Parameters.AddWithValue("@@IntParam2", segment.TCOut.Frames); + cmd.Parameters.AddWithValue("@@StrParam1", comment); + cmd.ExecuteNonQuery(); + } + } catch (Exception e) { OnError(logger, e); + } finally { + connection.Close(); } - finally { + } + + public List GetADSegments(string strParam) { + List result = null; + try { + TryConnect(); + using (SqlCommand cmd = CreateCommmad()) { + cmd.CommandType = CommandType.StoredProcedure; + cmd.Parameters.AddWithValue("@Operation", 3001); + cmd.Parameters.AddWithValue("@@@Options", 0); + cmd.Parameters.AddWithValue("@@ItemID", DBNull.Value); + cmd.Parameters.AddWithValue("@@StrParam1", strParam); + using (SqlDataReader reader = cmd.ExecuteReader()) { + while (reader.Read()) { + if (result == null) + result = new List(); + PlanAirADResult item = cliFSPReader.ToclIFsp_MAMAdvertisementResult(reader); + MovieSegment segment = ToSegment(item); + if (segment.TCOut.Frames != 0) + result.Add(segment); + } + } + } + } catch (Exception e) { + OnError(logger, e); + } finally { connection.Close(); } return result; diff --git a/client/PlanAIRClient/Workers/MaterialWorker.cs b/client/PlanAIRClient/Workers/MaterialWorker.cs deleted file mode 100644 index 9b1f19b9..00000000 --- a/client/PlanAIRClient/Workers/MaterialWorker.cs +++ /dev/null @@ -1,170 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Data; -using System.Data.SqlClient; -using NLog; -using LinkDotNet.MessageHandling.Contracts; - -namespace TrafficClient.Workers { - - public class MaterialWorker : TrafficWorker { - - private static Logger logger = LogManager.GetCurrentClassLogger(); - - public MaterialWorker(SqlConnection connection, CliFSPReader cliFSPReader, string functionName, IMessageBus messageBus) - : base(connection, cliFSPReader, functionName, messageBus) { - } - - private TrafficItem ToTrafficItem(clIFsp_EC_MAMBradocastResult data) { - //Debug.WriteLine(data.v_OkForAir); - - return new TrafficItem() { - MediaID = data.v_MediaID, - EpisodeTitle = data.v_EpTitle, - Title = data.v_ProgTitle, - VariantID = data.v_VariantID.HasValue ? data.v_VariantID.Value : 0, - EpisodeNumber = data.v_Episode.HasValue ? data.v_Episode.Value : (short)0, - 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) - }; - } - - private TrafficItemMetadata ToTrafficItemMetadata(clIFsp_EC_MAMBradocastResult data) { - return new TrafficItemMetadata() { - EpisodeID = data.v_EpisodeID, - EpisodeTitle = data.v_EpTitle, - ProgID = data.v_ProgrammeID.ToString(), - ProgTitle = data.v_ProgTitle, - OK = data.v_OkForAir != null && true.Equals(data.v_OkForAir) - }; - } - - public List GetMaterials(string search, bool problematic, DateTime? from, DateTime? to) { - List result = null; - try { - TryConnect(); - using (SqlCommand cmd = CreateCommmad()) { - cmd.CommandType = CommandType.StoredProcedure; - cmd.Parameters.AddWithValue("@Operation", 1002); - if (problematic) - cmd.Parameters.AddWithValue("@@@Options", 1); - else - cmd.Parameters.AddWithValue("@@@Options", 0); - - cmd.Parameters.AddWithValue("@@ItemID", DBNull.Value); - if (!String.IsNullOrEmpty(search)) - cmd.Parameters.AddWithValue("@@StrParam1", search); - if (from != null) - cmd.Parameters.AddWithValue("@@DateParam1", from.Value.Date); - if (to != null) - cmd.Parameters.AddWithValue("@@DateParam2", to.Value.Date); - - using (SqlDataReader reader = cmd.ExecuteReader()) { - while (reader.Read()) { - if (result == null) - result = new List(); - clIFsp_EC_MAMBradocastResult item = cliFSPReader.ToclIFsp_MAMBroadcastResult(reader); - result.Add(ToTrafficItem(item)); - } - } - } - } - catch (Exception e) { - OnError(logger, e); - } - finally { - connection.Close(); - } - return result; - } - - - public List GetMaterialArchiveMetadata(string strParam) { - List result = null; - try { - TryConnect(); - using (SqlCommand cmd = CreateCommmad()) { - cmd.CommandType = CommandType.StoredProcedure; - cmd.Parameters.AddWithValue("@Operation", 1002); - cmd.Parameters.AddWithValue("@@@Options", 0); - cmd.Parameters.AddWithValue("@@ItemID", DBNull.Value); - cmd.Parameters.AddWithValue("@@StrParam1", strParam); - - using (SqlDataReader reader = cmd.ExecuteReader()) { - while (reader.Read()) { - if (result == null) - result = new List(); - clIFsp_EC_MAMBradocastResult item = cliFSPReader.ToclIFsp_MAMBroadcastResult(reader); - result.Add(ToTrafficItemMetadata(item)); - } - } - } - } - catch (Exception e) { - OnError(logger, e); - } - finally { - connection.Close(); - } - return result; - } - - public TrafficVersion CreateMaterialVersion(string episodeID, bool recut) { - TrafficVersion result = null; - try { - TryConnect(); - using (SqlCommand cmd = CreateCommmad()) { - cmd.CommandType = CommandType.StoredProcedure; - cmd.Parameters.AddWithValue("@Operation", 1105); - cmd.Parameters.AddWithValue("@@@Options", DBNull.Value); - cmd.Parameters.AddWithValue("@@IntParam1", recut ? 12 : 1); - cmd.Parameters.AddWithValue("@@ItemID", DBNull.Value); - cmd.Parameters.AddWithValue("@@StrParam1", episodeID); - cmd.Parameters.AddWithValue("@@StrParam2", DBNull.Value); - - using (SqlDataReader reader = cmd.ExecuteReader()) { - if (reader.Read()) { - result = new TrafficVersion(); - if (!reader.IsDBNull(0)) - result.VariantID = reader.GetInt32(0); - - if (!reader.IsDBNull(1)) - result.MediaID = reader.GetString(1); - } - } - } - } - catch (Exception e) { - OnError(logger, e); - } - finally { - connection.Close(); - } - return result; - } - - public void SetMaterialOK(int itemID, bool ok) { - try { - TryConnect(); - int options = ok ? 1 : 0; - using (SqlCommand cmd = CreateCommmad()) { - cmd.CommandType = CommandType.StoredProcedure; - cmd.Parameters.AddWithValue("@Operation", 1100); - cmd.Parameters.AddWithValue("@@ItemID", itemID); - cmd.Parameters.AddWithValue("@@@Options", DBNull.Value); - cmd.Parameters.AddWithValue("@@IntParam1", options); - cmd.ExecuteNonQuery(); - } - } - catch (Exception e) { - OnError(logger, e); - } - finally { - connection.Close(); - } - } - } -} diff --git a/client/PlanAIRClient/Workers/MultiSegmentMaterialWorker.cs b/client/PlanAIRClient/Workers/MultiSegmentMaterialWorker.cs new file mode 100644 index 00000000..67f95b34 --- /dev/null +++ b/client/PlanAIRClient/Workers/MultiSegmentMaterialWorker.cs @@ -0,0 +1,9 @@ +using NLog; + +namespace TrafficClient.Workers { + + public class MultiSegmentMaterialWorker : TrafficWorker { + + private static Logger logger = LogManager.GetCurrentClassLogger(); + } +} diff --git a/client/PlanAIRClient/Workers/PromoWorker.cs b/client/PlanAIRClient/Workers/PromoWorker.cs index 4fa6b06c..03972a83 100644 --- a/client/PlanAIRClient/Workers/PromoWorker.cs +++ b/client/PlanAIRClient/Workers/PromoWorker.cs @@ -1,21 +1,22 @@ -using System; +using LinkDotNet.MessageHandling.Contracts; +using MaestroShared.Metadata; +using NLog; +using System; using System.Collections.Generic; using System.Data; using System.Data.SqlClient; -using NLog; using System.Diagnostics; -using LinkDotNet.MessageHandling.Contracts; namespace TrafficClient.Workers { public class PromoWorker : TrafficWorker { private static Logger logger = LogManager.GetCurrentClassLogger(); - public PromoWorker(SqlConnection connection, CliFSPReader cliFSPReader, string functionName, IMessageBus messageBus) + public PromoWorker(SqlConnection connection, PlanAirDataReader cliFSPReader, string functionName, IMessageBus messageBus) : base(connection, cliFSPReader, functionName, messageBus) { } - private TrafficItem ToTrafficItem(clIFsp_EC_MAMPromotionalResult data) { + private TrafficItem ToTrafficItem(PlanAirPromoResult data) { Debug.WriteLine(data.v_OkForAirs); return new TrafficItem() { MediaID = data.t_MediaID, @@ -29,11 +30,11 @@ namespace TrafficClient.Workers { } - private TrafficItemMetadata ToTrafficItemMetadata(clIFsp_EC_MAMPromotionalResult data) { + private TrafficItemMetadata ToTrafficItemMetadata(PlanAirPromoResult data) { return new TrafficItemMetadata() { - EpisodeID = data.t_MediaID, - ProgID = data.t_SpotID.ToString(), - ProgTitle = data.v_Title, + EpisodeID = data.t_MediaID, + ProgID = data.t_SpotID.ToString(), + ProgTitle = data.v_Title, }; } @@ -60,21 +61,19 @@ namespace TrafficClient.Workers { while (reader.Read()) { if (result == null) result = new List(); - clIFsp_EC_MAMPromotionalResult item = cliFSPReader.ToclIFsp_MAMPromotionalResult(reader); + PlanAirPromoResult item = cliFSPReader.ToclIFsp_MAMPromotionalResult(reader); result.Add(ToTrafficItem(item)); } } } - } - catch (Exception e) { + } catch (Exception e) { OnError(logger, e); - } - finally { + } finally { connection.Close(); } return result; } - + public void SetPromoOK(int itemID, bool ok) { try { TryConnect(); @@ -88,11 +87,9 @@ namespace TrafficClient.Workers { cmd.Parameters.AddWithValue("@@IntParam2", DBNull.Value); cmd.ExecuteNonQuery(); } - } - catch (Exception e) { + } catch (Exception e) { OnError(logger, e); - } - finally { + } finally { connection.Close(); } } @@ -111,16 +108,75 @@ namespace TrafficClient.Workers { while (reader.Read()) { if (result == null) result = new List(); - clIFsp_EC_MAMPromotionalResult item = cliFSPReader.ToclIFsp_MAMPromotionalResult(reader); + PlanAirPromoResult item = cliFSPReader.ToclIFsp_MAMPromotionalResult(reader); result.Add(ToTrafficItemMetadata(item)); } } } + } catch (Exception e) { + OnError(logger, e); + } finally { + connection.Close(); } - catch (Exception e) { + return result; + } + + private MovieSegment ToSegment(PlanAirPromoResult item) { + return new MovieSegment() { + TCIn = item.t_TcIn.HasValue ? new Timecode(item.t_TcIn.Value) : new Timecode(), + TCOut = item.t_TcOut.HasValue ? new Timecode(item.t_TcOut.Value) : new Timecode(), + }; + } + + public void SavePromoSegment(int itemID, MovieSegment segment) { + object comment = segment.Comment; + if (String.IsNullOrEmpty(segment.Comment)) + comment = DBNull.Value; + try { + TryConnect(); + using (SqlCommand cmd = CreateCommmad()) { + int optionalParam = segment.Optional ? 1 : 0; + cmd.CommandType = CommandType.StoredProcedure; + cmd.Parameters.AddWithValue("@Operation", 2100); + cmd.Parameters.AddWithValue("@@ItemID", itemID); + cmd.Parameters.AddWithValue("@@@Options", DBNull.Value); + cmd.Parameters.AddWithValue("@@IntParam1", segment.TCIn.Frames); + cmd.Parameters.AddWithValue("@@IntParam2", segment.TCOut.Frames); + cmd.Parameters.AddWithValue("@@StrParam2", comment); + cmd.ExecuteNonQuery(); + } + } catch (Exception e) { OnError(logger, e); + } finally { + connection.Close(); } - finally { + } + + public List GetPromoSegments(string strParam) { + List result = null; + try { + TryConnect(); + using (SqlCommand cmd = CreateCommmad()) { + cmd.CommandType = CommandType.StoredProcedure; + cmd.Parameters.AddWithValue("@Operation", 2001); + cmd.Parameters.AddWithValue("@@@Options", 0); + cmd.Parameters.AddWithValue("@@ItemID", DBNull.Value); + cmd.Parameters.AddWithValue("@@StrParam1", strParam); + using (SqlDataReader reader = cmd.ExecuteReader()) { + while (reader.Read()) { + if (result == null) + result = new List(); + + PlanAirPromoResult item = cliFSPReader.ToclIFsp_MAMPromotionalResult(reader); + MovieSegment segment = ToSegment(item); + if (segment.TCOut.Frames != 0) + result.Add(segment); + } + } + } + } catch (Exception e) { + OnError(logger, e); + } finally { connection.Close(); } return result; diff --git a/client/PlanAIRClient/Workers/SegmentWorker.cs b/client/PlanAIRClient/Workers/SingleSegmentMaterialWorker.cs similarity index 53% rename from client/PlanAIRClient/Workers/SegmentWorker.cs rename to client/PlanAIRClient/Workers/SingleSegmentMaterialWorker.cs index 71802d8d..7bc9463f 100644 --- a/client/PlanAIRClient/Workers/SegmentWorker.cs +++ b/client/PlanAIRClient/Workers/SingleSegmentMaterialWorker.cs @@ -1,252 +1,276 @@ -using System; +using LinkDotNet.MessageHandling.Contracts; +using MaestroShared.Metadata; +using NLog; +using System; using System.Collections.Generic; using System.Data; using System.Data.SqlClient; -using NLog; -using LinkDotNet.MessageHandling.Contracts; -using MaestroShared.Metadata; namespace TrafficClient.Workers { - public class SegmentWorker : TrafficWorker { + + public class SingleSegmentMaterialWorker : TrafficWorker { private static Logger logger = LogManager.GetCurrentClassLogger(); - public SegmentWorker(SqlConnection connection, CliFSPReader cliFSPReader, string functionName, IMessageBus messageBus) : - base(connection, cliFSPReader, functionName, messageBus) { + public SingleSegmentMaterialWorker(SqlConnection connection, PlanAirDataReader cliFSPReader, string functionName, IMessageBus messageBus) + : base(connection, cliFSPReader, functionName, messageBus) { } - private MovieSegment ToSegment(clIFsp_EC_MAMPromotionalResult item) { - return new MovieSegment() { - TCIn = item.t_TcIn.HasValue ? new Timecode(item.t_TcIn.Value) : new Timecode(), - TCOut = item.t_TcOut.HasValue ? new Timecode(item.t_TcOut.Value) : new Timecode(), + private TrafficItem ToTrafficItem(clIFsp_EC_MAMBradocastResult data) { + //Debug.WriteLine(data.v_OkForAir); + + return new TrafficItem() { + MediaID = data.v_MediaID, + EpisodeTitle = data.v_EpTitle, + Title = data.v_ProgTitle, + VariantID = data.v_VariantID.HasValue ? data.v_VariantID.Value : 0, + EpisodeNumber = data.v_Episode.HasValue ? data.v_Episode.Value : (short)0, + 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) }; } - private MovieSegment ToSegment(clIFsp_EC_SegmentResult item) { - return new MovieSegment() { - TCIn = item.v_TcIn.HasValue ? new Timecode(item.v_TcIn.Value) : new Timecode(), - TCOut = item.v_TcOut.HasValue ? new Timecode(item.v_TcOut.Value) : new Timecode(), - Comment = item.v_SegTitle, - Optional = item.v_Dropable.HasValue ? item.v_Dropable.Value : false + private TrafficItemMetadata ToTrafficItemMetadata(clIFsp_EC_MAMBradocastResult data) { + return new TrafficItemMetadata() { + EpisodeID = data.v_EpisodeID, + EpisodeTitle = data.v_EpTitle, + ProgID = data.v_ProgrammeID.ToString(), + ProgTitle = data.v_ProgTitle, + OK = data.v_OkForAir != null && true.Equals(data.v_OkForAir) }; } - private MovieSegment ToSegment(clIFsp_EC_MAMAdvertismentResult item) { - return new MovieSegment() { - TCIn = item.t_TcIn.HasValue ? new Timecode(item.t_TcIn.Value) : new Timecode(), - TCOut = item.t_TcOut.HasValue ? new Timecode(item.t_TcOut.Value) : new Timecode() - }; + protected virtual int GetMaterialsID { + get => 1002; } - public List GetMaterialSegments(int itemID) { - List result = null; + public List GetMaterials(string search, bool problematic, DateTime? from, DateTime? to) { + List result = null; try { TryConnect(); using (SqlCommand cmd = CreateCommmad()) { cmd.CommandType = CommandType.StoredProcedure; - cmd.Parameters.AddWithValue("@Operation", 1010); - cmd.Parameters.AddWithValue("@@@Options", DBNull.Value); - cmd.Parameters.AddWithValue("@@ItemID", itemID); + cmd.Parameters.AddWithValue("@Operation", GetMaterialsID); + if (problematic) + cmd.Parameters.AddWithValue("@@@Options", 1); + else + cmd.Parameters.AddWithValue("@@@Options", 0); + + cmd.Parameters.AddWithValue("@@ItemID", DBNull.Value); + if (!String.IsNullOrEmpty(search)) + cmd.Parameters.AddWithValue("@@StrParam1", search); + if (from != null) + cmd.Parameters.AddWithValue("@@DateParam1", from.Value.Date); + if (to != null) + cmd.Parameters.AddWithValue("@@DateParam2", to.Value.Date); + using (SqlDataReader reader = cmd.ExecuteReader()) { while (reader.Read()) { if (result == null) - result = new List(); - clIFsp_EC_SegmentResult item = cliFSPReader.ToclIFsp_SegmentResult(reader); - result.Add(ToSegment(item)); + result = new List(); + clIFsp_EC_MAMBradocastResult item = cliFSPReader.ToclIFsp_MAMBroadcastResult(reader); + result.Add(ToTrafficItem(item)); } } } - } - catch (Exception e) { + } catch (Exception e) { OnError(logger, e); - } - finally { + } finally { connection.Close(); } return result; } - public void DeleteMaterialSegments(int itemID) { + + public List GetMaterialArchiveMetadata(string strParam) { + List result = null; try { TryConnect(); using (SqlCommand cmd = CreateCommmad()) { cmd.CommandType = CommandType.StoredProcedure; - cmd.Parameters.AddWithValue("@Operation", 1110); - cmd.Parameters.AddWithValue("@@ItemID", itemID); - cmd.Parameters.AddWithValue("@@@Options", DBNull.Value); - cmd.ExecuteNonQuery(); - logger.Info(String.Format("Segments deleted from itemID {0}", itemID)); + cmd.Parameters.AddWithValue("@Operation", GetMaterialsID); + cmd.Parameters.AddWithValue("@@@Options", 0); + cmd.Parameters.AddWithValue("@@ItemID", DBNull.Value); + cmd.Parameters.AddWithValue("@@StrParam1", strParam); + + using (SqlDataReader reader = cmd.ExecuteReader()) { + while (reader.Read()) { + if (result == null) + result = new List(); + clIFsp_EC_MAMBradocastResult item = cliFSPReader.ToclIFsp_MAMBroadcastResult(reader); + result.Add(ToTrafficItemMetadata(item)); + } + } } - } - catch (Exception e) { + } catch (Exception e) { OnError(logger, e); - } - finally { + } finally { connection.Close(); } + return result; } - public void DeleteMaterialSegment(int itemID, int segmentID) { + protected virtual int GetMaterialVersionID { + get => 1105; + } + + public TrafficVersion CreateMaterialVersion(string episodeID, bool recut) { + TrafficVersion result = null; try { TryConnect(); using (SqlCommand cmd = CreateCommmad()) { cmd.CommandType = CommandType.StoredProcedure; - cmd.Parameters.AddWithValue("@Operation", 1111); - cmd.Parameters.AddWithValue("@@ItemID", itemID); - cmd.Parameters.AddWithValue("@@IntParam1", segmentID); + cmd.Parameters.AddWithValue("@Operation", GetMaterialVersionID); cmd.Parameters.AddWithValue("@@@Options", DBNull.Value); - cmd.ExecuteNonQuery(); - logger.Info(String.Format("{0} segment deleted from itemID: {1}", segmentID, itemID)); + cmd.Parameters.AddWithValue("@@IntParam1", recut ? 12 : 1); + cmd.Parameters.AddWithValue("@@ItemID", DBNull.Value); + cmd.Parameters.AddWithValue("@@StrParam1", episodeID); + cmd.Parameters.AddWithValue("@@StrParam2", DBNull.Value); + + using (SqlDataReader reader = cmd.ExecuteReader()) { + if (reader.Read()) { + result = new TrafficVersion(); + if (!reader.IsDBNull(0)) + result.VariantID = reader.GetInt32(0); + + if (!reader.IsDBNull(1)) + result.MediaID = reader.GetString(1); + } + } } - } - catch (Exception e) { + } catch (Exception e) { OnError(logger, e); - } - finally { + } finally { connection.Close(); } + return result; } - public void AddMaterialSegment(int itemID, MovieSegment segment) { - object comment = segment.Comment; - if (String.IsNullOrEmpty(segment.Comment)) - comment = DBNull.Value; + protected virtual int SetMaterialOKID { + get => 1100; + } + + public void SetMaterialOK(int itemID, bool ok) { try { TryConnect(); + int options = ok ? 1 : 0; using (SqlCommand cmd = CreateCommmad()) { - int optionalParam = segment.Optional ? 1 : 0; cmd.CommandType = CommandType.StoredProcedure; - cmd.Parameters.AddWithValue("@Operation", 1115); + cmd.Parameters.AddWithValue("@Operation", SetMaterialOKID); 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("@@StrParam2", DBNull.Value); - cmd.Parameters.AddWithValue("@@@Options", optionalParam); + cmd.Parameters.AddWithValue("@@@Options", DBNull.Value); + cmd.Parameters.AddWithValue("@@IntParam1", options); cmd.ExecuteNonQuery(); } - } - catch (Exception e) { + } catch (Exception e) { OnError(logger, e); - } - finally { + } finally { connection.Close(); } } - public void SaveADSegment(int itemID, MovieSegment segment) { - object comment = segment.Comment; - if (String.IsNullOrEmpty(segment.Comment)) - comment = DBNull.Value; + private MovieSegment ToSegment(PlanAirMaterialSegmentResult item) { + return new MovieSegment() { + TCIn = item.v_TcIn.HasValue ? new Timecode(item.v_TcIn.Value) : new Timecode(), + TCOut = item.v_TcOut.HasValue ? new Timecode(item.v_TcOut.Value) : new Timecode(), + Comment = item.v_SegTitle, + Optional = item.v_Dropable.HasValue ? item.v_Dropable.Value : false + }; + } + + protected virtual int GetMaterialSegmentsID { + get => 1010; + } + + public List GetMaterialSegments(int itemID) { + List result = null; try { TryConnect(); using (SqlCommand cmd = CreateCommmad()) { - int optionalParam = segment.Optional ? 1 : 0; cmd.CommandType = CommandType.StoredProcedure; - cmd.Parameters.AddWithValue("@Operation", 3100); - cmd.Parameters.AddWithValue("@@ItemID", itemID); + cmd.Parameters.AddWithValue("@Operation", GetMaterialSegmentsID); cmd.Parameters.AddWithValue("@@@Options", DBNull.Value); - cmd.Parameters.AddWithValue("@@IntParam1", segment.TCIn.Frames); - cmd.Parameters.AddWithValue("@@IntParam2", segment.TCOut.Frames); - cmd.Parameters.AddWithValue("@@StrParam1", comment); - cmd.ExecuteNonQuery(); + 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); + result.Add(ToSegment(item)); + } + } } - } - catch (Exception e) { + } catch (Exception e) { OnError(logger, e); - } - finally { + } finally { connection.Close(); } + return result; } - public void SavePromoSegment(int itemID, MovieSegment segment) { - object comment = segment.Comment; - if (String.IsNullOrEmpty(segment.Comment)) - comment = DBNull.Value; + public void DeleteMaterialSegments(int itemID) { try { TryConnect(); using (SqlCommand cmd = CreateCommmad()) { - int optionalParam = segment.Optional ? 1 : 0; cmd.CommandType = CommandType.StoredProcedure; - cmd.Parameters.AddWithValue("@Operation", 2100); + cmd.Parameters.AddWithValue("@Operation", 1110); cmd.Parameters.AddWithValue("@@ItemID", itemID); cmd.Parameters.AddWithValue("@@@Options", DBNull.Value); - cmd.Parameters.AddWithValue("@@IntParam1", segment.TCIn.Frames); - cmd.Parameters.AddWithValue("@@IntParam2", segment.TCOut.Frames); - cmd.Parameters.AddWithValue("@@StrParam2", comment); cmd.ExecuteNonQuery(); + logger.Info(String.Format("Segments deleted from itemID {0}", itemID)); } - } - catch (Exception e) { + } catch (Exception e) { OnError(logger, e); - } - finally { + } finally { connection.Close(); } } - public List GetPromoSegments(string strParam) { - List result = null; + public void DeleteMaterialSegment(int itemID, int segmentID) { try { TryConnect(); using (SqlCommand cmd = CreateCommmad()) { cmd.CommandType = CommandType.StoredProcedure; - cmd.Parameters.AddWithValue("@Operation", 2001); - cmd.Parameters.AddWithValue("@@@Options", 0); - cmd.Parameters.AddWithValue("@@ItemID", DBNull.Value); - cmd.Parameters.AddWithValue("@@StrParam1", strParam); - using (SqlDataReader reader = cmd.ExecuteReader()) { - while (reader.Read()) { - if (result == null) - result = new List(); - - clIFsp_EC_MAMPromotionalResult item = cliFSPReader.ToclIFsp_MAMPromotionalResult(reader); - MovieSegment segment = ToSegment(item); - if (segment.TCOut.Frames != 0) - result.Add(segment); - } - } + cmd.Parameters.AddWithValue("@Operation", 1111); + cmd.Parameters.AddWithValue("@@ItemID", itemID); + cmd.Parameters.AddWithValue("@@IntParam1", segmentID); + cmd.Parameters.AddWithValue("@@@Options", DBNull.Value); + cmd.ExecuteNonQuery(); + logger.Info(String.Format("{0} segment deleted from itemID: {1}", segmentID, itemID)); } - } - catch (Exception e) { + } catch (Exception e) { OnError(logger, e); - } - finally { + } finally { connection.Close(); } - return result; } - public List GetADSegments(string strParam) { - List result = null; + public void AddMaterialSegment(int itemID, MovieSegment segment) { + object comment = segment.Comment; + if (String.IsNullOrEmpty(segment.Comment)) + comment = DBNull.Value; try { TryConnect(); using (SqlCommand cmd = CreateCommmad()) { + int optionalParam = segment.Optional ? 1 : 0; cmd.CommandType = CommandType.StoredProcedure; - cmd.Parameters.AddWithValue("@Operation", 3001); - cmd.Parameters.AddWithValue("@@@Options", 0); - cmd.Parameters.AddWithValue("@@ItemID", DBNull.Value); - cmd.Parameters.AddWithValue("@@StrParam1", strParam); - using (SqlDataReader reader = cmd.ExecuteReader()) { - while (reader.Read()) { - if (result == null) - result = new List(); - clIFsp_EC_MAMAdvertismentResult item = cliFSPReader.ToclIFsp_MAMAdvertisementResult(reader); - MovieSegment segment = ToSegment(item); - if (segment.TCOut.Frames != 0) - result.Add(segment); - } - } + cmd.Parameters.AddWithValue("@Operation", 1115); + 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("@@StrParam2", DBNull.Value); + cmd.Parameters.AddWithValue("@@@Options", optionalParam); + cmd.ExecuteNonQuery(); } - } - catch (Exception e) { + } catch (Exception e) { OnError(logger, e); - } - finally { + } finally { connection.Close(); } - return result; } } diff --git a/client/PlanAIRClient/Workers/TrafficWorker.cs b/client/PlanAIRClient/Workers/TrafficWorker.cs index 9d30dea7..508a7367 100644 --- a/client/PlanAIRClient/Workers/TrafficWorker.cs +++ b/client/PlanAIRClient/Workers/TrafficWorker.cs @@ -8,11 +8,11 @@ namespace TrafficClient.Workers { public class TrafficWorker { protected IMessageBus messageBus; - protected CliFSPReader cliFSPReader; + protected PlanAirDataReader cliFSPReader; private readonly string functionName; protected SqlConnection connection; - public TrafficWorker(SqlConnection connection, CliFSPReader cliFSPReader, string functionName, IMessageBus messageBus) { + public TrafficWorker(SqlConnection connection, PlanAirDataReader cliFSPReader, string functionName, IMessageBus messageBus) { this.connection = connection; this.cliFSPReader = cliFSPReader; this.functionName = functionName; diff --git a/client/PlanAIRClient/clIFsp_EC_MAMBradocastResult.cs b/client/PlanAIRClient/clIFsp_EC_MAMBradocastResult.cs new file mode 100644 index 00000000..6a49b0da --- /dev/null +++ b/client/PlanAIRClient/clIFsp_EC_MAMBradocastResult.cs @@ -0,0 +1,259 @@ +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; + } + } + } + } +} -- 2.54.0