private bool SetProviderContentTierData() { ProviderContentTierMapping contentTierMapping = new ProviderContentTierMapping(); using (ITVConversionContext ctm_Context = new ITVConversionContext()) { string distributor_val = ITVParser.GET_ITV_VALUE("Distributor"); foreach (ProviderContentTierMapping ctm_entry in ctm_Context.ProviderContentTierMapping) { try { if (ctm_entry.Distributor == distributor_val) { AdiMapping.SetProviderContentTierValue(ctm_entry.ProviderContentTier); break; } } catch (Exception SPCTD_EX) { log.Error($"Failed while Mapping distributor data: {ctm_entry.Distributor} to Provider content tier: {ctm_entry.ProviderContentTier} - {SPCTD_EX.Message}"); if (SPCTD_EX.InnerException != null) { log.Debug($"Inner Exception: {SPCTD_EX.InnerException.Message}"); } return(false); } } } return(true); }
/// <summary> /// Function in order to setout the workflows variables in order to reduce overhead later on /// </summary> /// <param name="item_keyname"></param> /// <param name="comp_keyname"></param> /// <param name="ctype"></param> /// <returns></returns> private bool SetRequiredPackageVars(string item_keyname, string comp_keyname, string ctype) { //Below items required earlier for reference and processing. //get the component ID (asset section matching product) and adds the productid and component id to a dictionary //in order of component name to avoid key exists errors as the product key is shared across components. ITVParser.ProductsComponentMappingList.Add($"{comp_keyname},{ctype}", item_keyname); ITVParser.AssetSectionID = $"metadata_{comp_keyname}"; ITVParser.SECTION_ID = $"metadata_{item_keyname}"; //ITVPaser.ITV_PAID = Regex.Replace(ITVPaser.GET_ITV_VALUE("ProviderAssetId"), "[A-Za-z ]", ""); ITVParser.ITV_PAID = ITVParser.GET_ITV_VALUE("ProviderAssetId"); ///Set the directory name for the working directory needed later during parsing as a single entity WorkDirname = $"{ITVParser.ITV_PAID}_{ DateTime.Now.ToString("yyyyMMdd-HHmm")}"; ///Full working directory path WorkingDirectory = Path.Combine(ITV2ADI_CONFIG.TempWorkingDirectory, WorkDirname); ///Media directory for placement of the required video assets MediaDirectory = Path.Combine(WorkingDirectory, "media"); ///Correct program title ProgramTitle = ITVParser.GET_ITV_VALUE("Title"); ///Correct ITV Product ID ProductId = item_keyname; ///Correct ITV Asset ide AssetId = comp_keyname; ///License start and end date required for mapping and requires a particular format LicenseStart = Convert.ToDateTime(ITVParser.GET_ITV_VALUE("ActivateTime")); LicenseEnd = Convert.ToDateTime(ITVParser.GET_ITV_VALUE("DeactivateTime")); ///Provider Name and ID for use in mapping and logging ProviderName = ITVParser.GET_ITV_VALUE("Provider"); ProviderId = ITVParser.GET_ITV_VALUE("ProviderId"); ///Publication data required to determine if the package is an update or initial ingest Publication_Date = Convert.ToDateTime(ITVParser.GET_ITV_VALUE("Publication_Date")); ///Physical asset file name MediaFileName = ITVParser.GET_ASSET_DATA("FileName"); ///Physical asset active date ActiveDate = ITVParser.GET_ASSET_DATA("ActiveDate"); ///physical asset deactive date DeactiveDate = ITVParser.GET_ASSET_DATA("DeactiveDate"); if (ITVParser.IsMovieContentType()) { if ((string.IsNullOrEmpty(ActiveDate)) || (string.IsNullOrEmpty(DeactiveDate))) { log.Error($"Rejected: Source ITV does not contain one of the following mandatory fields: ActiveData, DeactiveDate at asset level"); return(false); } else { return(true); } } else { return(false); } }
/// <summary> /// Main Method for processing the product entries 1 by 1 /// this will enure the required methods are invoked for parsing and packaging /// plus will process failed objects. /// </summary> /// <param name="productData"></param> /// <param name="ComponentData"></param> private void ProcessProductList(KeyData productData, KeyData ComponentData) { if (!string.IsNullOrEmpty(ComponentData.KeyName)) { string ctype = ITVParser.ComponentType(ComponentData.Value); if (ComponentData.Value == "1") { log.Info("Setting packaging variables for use during workflow."); if (SetRequiredPackageVars(productData.KeyName, ComponentData.KeyName, ctype)) { log.Info("Variables set Successfully"); string programName = ITVParser.GET_ITV_VALUE("Title"); log.Info($"*************** Generating Package For PAID: { ITVParser.ITV_PAID}, Program name: {programName} ***************\r\n"); log.Info($"Matching ComponentID: {ComponentData.KeyName},{ctype}"); if (StartProcessing()) { B_IsSuccess = true; CleanUp(); log.Info($"All operations completed Successfully, removing temporary Files/Directories for PAID: {ITVParser.ITV_PAID}"); log.Info($"***************Packaging FINISHED For PAID: { ITVParser.ITV_PAID}, Program name: {programName} ***************\r\n"); } else { log.Error("Failed during Conversion Process, the relevant error should be logged above for the problem area, check logs for errors and rectify."); FileDirectoryOperations.ProcessITVFailure(ITV2ADI_CONFIG.FailedDirectory, WorkDirname, ITV_FILE); ItvFailure = true; if (Directory.Exists(WorkingDirectory)) { CleanUp(); } if (ItvData_RowId > 0) { using (ITVConversionContext db = new ITVConversionContext()) { var rData = db.ItvConversionData.Where(i => i.Id == ItvData_RowId).FirstOrDefault(); if (rData != null) { db.Remove(rData); db.SaveChanges(); } } } B_IsSuccess = false; log.Error($"***************Packaging FAILED For PAID: { ITVParser.ITV_PAID}, Program name: {programName} ***************\r\n"); } } } } }
/// <summary> /// Updates the ADI file AMS Sections /// </summary> /// <returns></returns> private bool SetAmsData() { try { AdiMapping.SetAMSClass(); //Match MatchValue = Regex.Match(ITVParser.ITV_PAID, "[A-Za-z]"); //if (MatchValue.Success) //{ // IsQam = true; //} //else //{ // IsQam = false; //} AdiMapping.SetAMSPAID(ITV_Parser.Padding(ITVParser.ITV_PAID), ITVParser.ITV_PAID); AdiMapping.SetAMSAssetName(ProgramTitle); AdiMapping.SetAMSCreationDate(ITVParser.GET_ITV_VALUE("Publication_Date")); AdiMapping.SetAMSDescription(ProgramTitle); AdiMapping.SetAMSProvider(ProviderName); AdiMapping.SetAMSProviderId(ProviderId); AdiMapping.SetAmsVersions(Convert.ToString(Version_Major)); return(true); } catch (Exception AMS_EX) { log.Error($"Failed to Map AMS Section - {AMS_EX.Message}"); if (log.IsDebugEnabled) { log.Debug($"STACK TRACE: {AMS_EX.StackTrace}"); } return(false); } }
/// <summary> /// Function that iterates the mappings table in the database and ensures the correct adi fields /// are set with the mapped data, also the valueparser dictionary allows func calls for fields that require /// further parsing outside of a one to one mapping /// </summary> /// <returns></returns> private bool SetProgramData() { iTVConversion = new ITVConversionFunctions(); using (db = new ITVConversionContext()) { iTVConversion.Db = db; bool B_IsFirst = true; if (!IsUpdate) { SeedItvData(); } foreach (var entry in db.FieldMappings.OrderBy(x => x.ItvElement)) { try { string itvValue = ITVParser.GET_ITV_VALUE(entry.ItvElement); bool IsMandatoryField = entry.IsMandatoryField; SetAdiAssetId(entry.IsTitleMetadata); if (B_IsFirst) { //In place to get the showtype string tmpVal = ITVParser.GET_ITV_VALUE("ReportingClass"); iTVConversion.ParseReportingClass(tmpVal, entry.AdiElement, true); B_IsFirst = false; } Dictionary <string, Func <string> > ValueParser = new Dictionary <string, Func <string> >() { { "none", () => ITVParser.GetNoneTypeValue(entry.ItvElement) }, { "BillingId", () => ITV_Parser.GetBillingId(ITVParser.ITV_PAID) }, { "SummaryLong", () => AdiMapping.ConcatTitleDataXmlValues(itvValue, ITVParser.GET_ITV_VALUE("ContentGuidance")) }, { "Length", () => GetVideoRuntime() }, //VideoFileProperties.GetMediaInfoDuration(FullAssetName, IsUpdate) }, { "RentalTime", () => ITVParser.GetRentalTime(entry.ItvElement, itvValue, iTVConversion.IsMovie, iTVConversion.IsAdult) }, { "ReportingClass", () => iTVConversion.ParseReportingClass(itvValue, entry.AdiElement, entry.IsTitleMetadata) }, { "ServiceCode", () => AdiMapping.ProcessServiceCode(iTVConversion.IsAdult, ITVParser.GET_ITV_VALUE("ServiceCode")) }, { "HDContent", () => AdiMapping.SetEncodingFormat(itvValue) }, { "CanBeSuspended", () => ITVParser.CanBeSuspended(itvValue) }, { "Language", () => ITV_Parser.GetISO6391LanguageCode(itvValue) }, { "AnalogCopy", () => AdiMapping.CGMSMapping(itvValue) } }; if (ValueParser.ContainsKey(entry.ItvElement)) { itvValue = ValueParser[entry.ItvElement](); } if (!string.IsNullOrEmpty(itvValue)) { AdiMapping.SetOrUpdateAdiValue(entry.AdiAppType, entry.AdiElement, itvValue, entry.IsTitleMetadata); } else if (entry.IsMandatoryField && string.IsNullOrEmpty(itvValue)) { log.Error($"Rejected: Mandatory itv Field: {entry.ItvElement} not Found in the source ITV File."); return(false); } } catch (Exception SPD_EX) { log.Error($"Failed while Mapping Title MetaData itv value: {entry.ItvElement} to Adi value: {entry.AdiElement} - {SPD_EX.Message}"); if (log.IsDebugEnabled) { log.Debug($"STACK TRACE: {SPD_EX.StackTrace}"); } return(false); } } } return(CheckTvodUpdate()); }