public static void DeleteProgramRatingDO(int id) { EachProgramRatingDO apo = new EachProgramRatingDO(); apo.ID = id; baseLogic.Delete(apo); }
public static EachProgramRatingDO GetProgramRatingDOByName(string programName, DateTime effectiveDate, int beginSeconds) { EachProgramRatingDO projectDO = new EachProgramRatingDO(); string sql = @"select * from EachProgramRating where ProgramName=@programName and EffectiveDate=@EffectiveDate and EndSecond>@BeginSecond-1800 and EndSecond<@BeginSecond+1800 "; SqlParameter[] pars = new SqlParameter[3]; pars[0] = new SqlParameter("@programName", programName); pars[1] = new SqlParameter("@EffectiveDate", effectiveDate); pars[2] = new SqlParameter("@BeginSecond", beginSeconds); return((EachProgramRatingDO)baseLogic.Select(projectDO, sql, pars)); }
public static EachProgramRatingDO GetProgramRatingDOByName(string programName, DateTime effectiveDate) { EachProgramRatingDO projectDO = new EachProgramRatingDO(); string sql = @"select * from EachProgramRating where ProgramName=@programName and EffectiveDate=@EffectiveDate"; SqlParameter[] pars = new SqlParameter[2]; pars[0] = new SqlParameter("@programName", programName); pars[1] = new SqlParameter("@EffectiveDate", effectiveDate); DataTable dt = baseLogic.Select(sql, pars); if (dt != null && dt.Rows.Count == 1) { int id = 0; int.TryParse(dt.Rows[0]["ID"].ToString(), out id); projectDO = GetProgramRatingDOByID(id); } return(projectDO); }
private void ReadSpecialProgramSheet(string programName, DateTime reportDate, DataTable dtProgram) { DataRow row = dtProgram.Rows[2]; EachProgramRatingDO eachProgramDO = DRManager.GetProgramRatingDOByName(programName, reportDate); if (eachProgramDO.ID > 0) { string tvRate = row[2].ToString(); string tvPercentage = row[3].ToString(); string tvLoyalty = row[4].ToString(); decimal _tvRate = 0; decimal _tvPercentage = 0; decimal _tvLoyalty = 0; decimal.TryParse(tvRate, out _tvRate); decimal.TryParse(tvPercentage, out _tvPercentage); decimal.TryParse(tvLoyalty, out _tvLoyalty); eachProgramDO.TVRate = _tvRate; eachProgramDO.TVPercentage = _tvPercentage; eachProgramDO.TVLoyalty = _tvLoyalty; BusinessLogicBase.Default.Update(eachProgramDO); } }
public static EachProgramRatingDO GetProgramRatingDOByID(int id) { EachProgramRatingDO projectDO = new EachProgramRatingDO(); return((EachProgramRatingDO)baseLogic.Select(projectDO, id)); }
private void ReadEachProgramSheet(DateTime reportDate, DataTable dtEachProgram) { for (int i = 2; i < dtEachProgram.Rows.Count; i++) { DataRow row = dtEachProgram.Rows[i]; string name = row[1].ToString().Trim(); string channelName = row[2].ToString(); string categoryName = row[3].ToString().Trim(); string subCategoryName = row[4].ToString().Trim(); string matchedSpecialProgram = GetMatchedSpecialProgram(name); if (!string.IsNullOrEmpty(matchedSpecialProgram)) { EachProgramRatingDO programDO = DRManager.GetProgramRatingDOByName(matchedSpecialProgram, reportDate); if (programDO != null && programDO.ID > 0) { programDO.ChannelName = channelName; programDO.CategoryName = categoryName; programDO.SubCategoryName = subCategoryName; BusinessLogicBase.Default.Update(programDO); } continue; } DataTable dt = DRManager.GetProgramRatingsByName(name, reportDate); if (dt != null && dt.Rows.Count == 1) { int id = 0; int.TryParse(dt.Rows[0]["ID"].ToString(), out id); EachProgramRatingDO eachProgramDO = DRManager.GetProgramRatingDOByID(id); if (eachProgramDO != null && eachProgramDO.ID > 0) { string tvRate = row[5].ToString(); string tvPercentage = row[6].ToString(); string tvLoyalty = row[7].ToString(); decimal _tvRate = 0; decimal _tvPercentage = 0; decimal _tvLoyalty = 0; decimal.TryParse(tvRate, out _tvRate); decimal.TryParse(tvPercentage, out _tvPercentage); decimal.TryParse(tvLoyalty, out _tvLoyalty); eachProgramDO.ChannelName = channelName; eachProgramDO.CategoryName = categoryName; eachProgramDO.SubCategoryName = subCategoryName; eachProgramDO.TVRate = _tvRate; eachProgramDO.TVPercentage = _tvPercentage; eachProgramDO.TVLoyalty = _tvLoyalty; BusinessLogicBase.Default.Update(eachProgramDO); } } else if (dt != null && dt.Rows.Count > 1) { foreach (DataRow rateRow in dt.Rows) { int id = 0; int.TryParse(rateRow["ID"].ToString(), out id); EachProgramRatingDO eachProgramDO = DRManager.GetProgramRatingDOByID(id); if (eachProgramDO != null && eachProgramDO.ID > 0) { eachProgramDO.ChannelName = channelName; eachProgramDO.CategoryName = categoryName; eachProgramDO.SubCategoryName = subCategoryName; BusinessLogicBase.Default.Update(eachProgramDO); } } } } }
private void ReadEachMinuteSheet(DateTime reportDate, DataTable dtEachMinute) { int currentMinuteIndex = 0; string currentProgramName = ""; EachProgramRatingDO programDO = new EachProgramRatingDO(); for (int i = 1; i < dtEachMinute.Rows.Count; i++) { DataRow row = dtEachMinute.Rows[i]; string name = row[0].ToString().Trim(); string tvRate = row[5].ToString(); string tvPercentage = row[6].ToString(); string tvLoyalty = row[7].ToString(); decimal _tvRate = 0; decimal _tvPercentage = 0; decimal _tvLoyalty = 0; decimal.TryParse(tvRate, out _tvRate); decimal.TryParse(tvPercentage, out _tvPercentage); decimal.TryParse(tvLoyalty, out _tvLoyalty); if (name.Contains("<<") && name.Contains(">>")) { currentMinuteIndex++; string strMinute = name.Trim(new char[] { ' ', '<', '>' }); decimal rate = 0; decimal.TryParse(tvRate, out rate); EachMinuteRatingDO minuteDO = new EachMinuteRatingDO(); minuteDO.ProgramName = currentProgramName; minuteDO.StrMinute = strMinute; minuteDO.MinuteIndex = currentMinuteIndex; minuteDO.EffectiveDate = reportDate; minuteDO.TVRate = _tvRate; minuteDO.TVPercentage = _tvPercentage; minuteDO.TVLoyalty = _tvLoyalty; BusinessLogicBase.Default.Insert(minuteDO); } else { string strBeginTime = row[3].ToString().Trim(new char[] { ' ', '<', '>' }); string strEndTime = row[4].ToString().Trim(new char[] { ' ', '<', '>' }); int beginSeconds = CommonFunction.GetTimeToSeconds(strBeginTime); int endSeconds = CommonFunction.GetTimeToSeconds(strEndTime); if (beginSeconds > 24 * 3600) { //only calculate program started before 23:00 break; } string matchedProgramName = GetMatchedSpecialProgram(name); if (!string.IsNullOrEmpty(matchedProgramName)) { //need to handle special program case name = matchedProgramName; } programDO = DRManager.GetProgramRatingDOByName(name, reportDate, beginSeconds); if (programDO != null && string.IsNullOrEmpty(programDO.ProgramName) == false) { programDO.StrEndTime = strEndTime; programDO.EndSecond = endSeconds; BusinessLogicBase.Default.Update(programDO); } else { programDO = new EachProgramRatingDO(); programDO.EffectiveDate = reportDate; programDO.ProgramName = name; programDO.StrBeginTime = strBeginTime; programDO.StrEndTime = strEndTime; programDO.BeginSecond = beginSeconds; programDO.EndSecond = endSeconds; programDO.TVRate = _tvRate; programDO.TVPercentage = _tvPercentage; programDO.TVLoyalty = _tvLoyalty; BusinessLogicBase.Default.Insert(programDO); currentMinuteIndex = 0; } currentProgramName = name; } } }