//*************************************************************DANE NIELSENA public static List<Break> DataTableToListNielsen(DataTable dt) { int checker = 0; string pattern = "dd-MM-yyyy"; List<Break> result = new List<Break>(); try { long iteratorID1 = 0; foreach (DataRow dr in dt.Rows) { Break tmpBreak = new Break(); tmpBreak.ID1 = iteratorID1; iteratorID1++; tmpBreak.channel = ChannelNielsenToAMOAD(dr["Channel"].ToString()); DateTime tmpDate; if(DateTime.TryParseExact(dr["Date"].ToString(), pattern, null, DateTimeStyles.None, out tmpDate)) tmpBreak.date = tmpDate; else tmpBreak.date = DateTime.MinValue; tmpBreak.description = dr["Programme"].ToString(); tmpBreak.startTimeString = dr["Start Time"].ToString(); //tmpBreak.startTime = TimeSpan.Parse(dr["Start time"].ToString()); TimeSpan tmpSpan; if (TimeSpan.TryParseExact(dr["Start Time"].ToString(), "c", CultureInfo.CurrentCulture, out tmpSpan)) tmpBreak.startTime = tmpSpan; else { tmpBreak.startTime = TimeSpan.Parse(tmpBreak.startTimeString.Split(' ')[1]); tmpBreak.date = tmpBreak.date.AddDays(1); //********************************PRZERABIAMY DATĘ NA DZIEŃ KOLEJNY W CELU PORÓWNANIA! } if (TimeSpan.TryParseExact(dr["End Time"].ToString(), "c", CultureInfo.CurrentCulture, out tmpSpan)) tmpBreak.endTime = tmpSpan; else { tmpBreak.endTime = TimeSpan.Parse(dr["End Time"].ToString().Split(' ')[1]); } if (tmpBreak.startTime != TimeSpan.MinValue) { tmpBreak.date += tmpBreak.startTime; if (tmpBreak.endTime != TimeSpan.MinValue) { tmpBreak.duration = tmpBreak.endTime - tmpBreak.startTime; } } result.Add(tmpBreak); checker++; } } catch (Exception err1) { MessageBox.Show("Problem w linii: " + checker + " -> " + err1.ToString()); } return result; }
public AriannaBreak(Break sourceBreak) { if ((sourceBreak.startTime <= TimeSpan.Parse("02:00:00"))&&(sourceBreak.date > DateTime.MinValue)) { this.date = ZeroFormatHelper(sourceBreak.date.AddDays(-1).Day.ToString()) + @"/" + ZeroFormatHelper(sourceBreak.date.AddDays(-1).Month.ToString()) + @"/" + sourceBreak.date.AddDays(-1).Year.ToString(); int outputHelper = sourceBreak.startTime.Hours * 10000 + sourceBreak.startTime.Minutes * 100 + sourceBreak.startTime.Seconds; outputHelper += 240000; string backToString = outputHelper.ToString().PadLeft(6, '0'); this.startTime = backToString.Substring(0,2) + ":" + backToString.Substring(2,2) + ":" + backToString.Substring(4,2); } else { this.date = ZeroFormatHelper(sourceBreak.date.Day.ToString()) + @"/" + ZeroFormatHelper(sourceBreak.date.Month.ToString()) + @"/" + sourceBreak.date.Year.ToString(); this.startTime = sourceBreak.startTime.ToString(); } this.endTime = sourceBreak.endTime; switch (sourceBreak.channel) { case "TVP1": this.channelID = "1101"; break; case "TVP2": this.channelID = "1102"; break; case "TVP3": this.channelID = "30008"; break; case "TV4": this.channelID = "20050"; break; case "Polsat": this.channelID = "1103"; break; case "TVN": this.channelID = "2018"; break; case "TVN7": this.channelID = "2024"; break; case "TVN 24": this.channelID = "12146"; break; default: this.channelID = "-99999"; break; } this.fieldTypology = "F"; this.ID1 = sourceBreak.ID1; this.ID2 = sourceBreak.ID2; }
//*************************************************************DANE AMOAD public static List<Break> DataTableToListAMOAD(DataTable dt) { int checker = 0; string pattern = "yyyy.MM.dd"; List<Break> result = new List<Break>(); try { long iteratorID2 = 0; foreach (DataRow dr in dt.Rows) { Break tmpBreak = new Break(); tmpBreak.ID2 = iteratorID2; iteratorID2++; tmpBreak.channel = dr["Channel"].ToString(); DateTime tmpDate; if (DateTime.TryParseExact(dr["Date"].ToString(), pattern, null, DateTimeStyles.None, out tmpDate)) tmpBreak.date = tmpDate; else tmpBreak.date = DateTime.MinValue; tmpBreak.description = dr["Program"].ToString(); tmpBreak.startTimeString = dr["Time"].ToString(); //tmpBreak.startTime = TimeSpan.Parse(dr["Time"].ToString()); TimeSpan tmpSpan; if (TimeSpan.TryParseExact(dr["Time"].ToString(),"c", CultureInfo.CurrentCulture, out tmpSpan)) { tmpBreak.startTime = tmpSpan; } else { //tmpBreak.startTime = TimeSpan.MinValue; int tmpIntTime = Int32.Parse(dr["Time"].ToString().Replace(":", "")) ; if (tmpIntTime >= 240000) // godzina powyżej północy { tmpIntTime -= 240000; string backToString = tmpIntTime.ToString().PadLeft(6, '0'); TimeSpan tmpSkipSpan = new TimeSpan(Int32.Parse(backToString.Substring(0,2)), Int32.Parse(backToString.Substring(2,2)), Int32.Parse(backToString.Substring(4,2))); tmpBreak.startTime = tmpSkipSpan; tmpBreak.date = tmpBreak.date.AddDays(1); //********************************PRZERABIAMY DATĘ NA DZIEŃ KOLEJNY W CELU PORÓWNANIA! } } //tmpBreak.startTime = tmpBreak.breakCode = dr["Break Code"].ToString(); if (TimeSpan.TryParse("0:00:" + dr[@"Copy Length"].ToString(), out tmpSpan)) tmpBreak.duration = tmpSpan; else tmpBreak.duration = TimeSpan.MinValue; if (tmpBreak.startTime != TimeSpan.MinValue) { tmpBreak.date += tmpBreak.startTime; if (tmpBreak.duration != TimeSpan.MinValue) { tmpBreak.endTime = tmpBreak.startTime + tmpBreak.duration; } } result.Add(tmpBreak); checker++; } } catch (Exception err1) { MessageBox.Show("Problem w linii: " + checker + " -> " + err1.ToString()); } return result; }