/// <summary> /// 是否能否弹窗 /// </summary> /// <param name="broadcastInfoItem"></param> /// <returns></returns> private static bool CanPopupWin(PopupWinItem popupWinItem, PopupWinTimeItem lastPopupWinTimeItem, int hour, int minute) { if (null == popupWinItem.Times) { return(false); } int time2 = lastPopupWinTimeItem.Hour * 60 + lastPopupWinTimeItem.Minute; int time3 = hour * 60 + minute; for (int i = 0; i < popupWinItem.Times.Length; i++) { int time1 = popupWinItem.Times[i].Hour * 60 + popupWinItem.Times[i].Minute; if (time1 <= time2) //已经广播过了 { continue; } if (time3 >= time1) { return(true); } } return(false); }
private static bool CanPopupWin(PopupWinItem popupWinItem, PopupWinTimeItem lastPopupWinTimeItem, int hour, int minute) { bool result; if (null == popupWinItem.Times) { result = false; } else { int time2 = lastPopupWinTimeItem.Hour * 60 + lastPopupWinTimeItem.Minute; int time3 = hour * 60 + minute; for (int i = 0; i < popupWinItem.Times.Length; i++) { int time4 = popupWinItem.Times[i].Hour * 60 + popupWinItem.Times[i].Minute; if (time4 > time2) { if (time3 >= time4) { return(true); } } } result = false; } return(result); }
/// <summary> /// 解析时间段 /// </summary> /// <param name="times"></param> /// <returns></returns> private static PopupWinTimeItem[] ParsePopupWinTimeItems(string times) { string[] fields = times.Split('|'); if (fields.Length <= 0) { return(null); } PopupWinTimeItem[] popupWinTimeItemArray = new PopupWinTimeItem[fields.Length]; for (int i = 0; i < fields.Length; i++) { string str = fields[i].Trim(); if (string.IsNullOrEmpty(str)) { return(null); } string[] fields2 = str.Split(':'); if (null == fields2 || fields2.Length != 2) { return(null); } popupWinTimeItemArray[i] = new PopupWinTimeItem() { Hour = Global.SafeConvertToInt32(fields2[0]), Minute = Global.SafeConvertToInt32(fields2[1]), }; } return(popupWinTimeItemArray); }
private static PopupWinTimeItem[] ParsePopupWinTimeItems(string times) { string[] fields = times.Split(new char[] { '|' }); PopupWinTimeItem[] result; if (fields.Length <= 0) { result = null; } else { PopupWinTimeItem[] popupWinTimeItemArray = new PopupWinTimeItem[fields.Length]; for (int i = 0; i < fields.Length; i++) { string str = fields[i].Trim(); if (string.IsNullOrEmpty(str)) { return(null); } string[] fields2 = str.Split(new char[] { ':' }); if (fields2 == null || fields2.Length != 2) { return(null); } popupWinTimeItemArray[i] = new PopupWinTimeItem { Hour = Global.SafeConvertToInt32(fields2[0]), Minute = Global.SafeConvertToInt32(fields2[1]) }; } result = popupWinTimeItemArray; } return(result); }