/// <summary> /// Returns True or False dependant on conversion of the itv file /// </summary> /// <returns></returns> public bool StartItvMapping() { try { ItvFailure = false; B_IsSuccess = false; log.Info("Loading and parsing itv File"); ITVParser = new ITV_Parser(); ITVParser.ParseItvFile(ITV_FILE); if (FilterItvFile()) { ITVParser.ProductsComponentMappingList = new Dictionary <string, string>(); log.Info("ITV Successfully parsed"); BuildProductLists(); } return(B_IsSuccess); } catch (Exception SIM_EX) { log.Error($"Failed to MAP ITV file: {ITV_FILE} - {SIM_EX.Message}"); if (log.IsDebugEnabled) { log.Debug($"STACK TRACE: {SIM_EX.StackTrace}"); } return(false); } }
/// <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()); }