Exemplo n.º 1
0
        public BulletinMsgData AddBulletinMsg(string msgID, int playMinutes, int playNum, string bulletinText, int msgType = 0)
        {
            BulletinMsgData bulletinMsgData = new BulletinMsgData
            {
                MsgID         = msgID,
                PlayMinutes   = playMinutes,
                ToPlayNum     = playNum,
                BulletinText  = bulletinText,
                BulletinTicks = TimeUtil.NOW(),
                MsgType       = msgType
            };

            if (playMinutes != 0)
            {
                lock (this._BulletinMsgDict)
                {
                    this._BulletinMsgDict[msgID] = bulletinMsgData;
                }
                if (playMinutes < 0)
                {
                    string fromDate = TimeUtil.NowDateTime().ToString("yyyy-MM-dd HH:mm:ss");
                    string toDate   = TimeUtil.NowDateTime().AddMinutes((double)playMinutes).ToString("yyyy-MM-dd HH:mm:ss");
                    Global.AddDBBulletinMsg(msgID, fromDate, toDate, 0, bulletinText);
                }
            }
            return(bulletinMsgData);
        }
Exemplo n.º 2
0
        public BulletinMsgData AddBulletinMsgBackground(string msgID, string fromDate, string toDate, int interval, string bulletinText)
        {
            BulletinMsgData bulletinMsgData = new BulletinMsgData
            {
                MsgID         = msgID,
                Interval      = interval,
                BulletinText  = bulletinText,
                BulletinTicks = DataHelper.ConvertToTicks(fromDate)
            };
            long PlayTicks = DataHelper.ConvertToTicks(toDate) - bulletinMsgData.BulletinTicks;

            bulletinMsgData.PlayMinutes = (int)(PlayTicks / 60000L);
            BulletinMsgData result;

            if (string.IsNullOrEmpty(msgID) || PlayTicks < 0L || interval <= 0)
            {
                LogManager.WriteLog(LogTypes.Error, string.Format("后台公告数据错误:{0} {1} {2} {3} {4}", new object[]
                {
                    msgID,
                    fromDate,
                    toDate,
                    interval,
                    bulletinText
                }), null, true);
                result = null;
            }
            else
            {
                lock (this._BulletinMsgDict)
                {
                    this._BulletinMsgDict[msgID] = bulletinMsgData;
                    Global.AddDBBulletinMsg(msgID, fromDate, toDate, interval, bulletinText);
                }
                result = bulletinMsgData;
            }
            return(result);
        }