예제 #1
0
파일: SMS.cs 프로젝트: ratsil/bethe.ingenie
 public List<EffectVideo> GetEffect(SMS cSMS, ushort nMaxWidth)
 {
     _cSMS = cSMS;
     _nMaxWidth = nMaxWidth;
     List<EffectVideo> aRetVal = new List<EffectVideo>();
     Text cText;
     switch (eType)
     {
         case Type.smile:
             Animation cAnim = stSmile.cAnimation;
             if (null != cAnim)
                 aRetVal.Add(stSmile.cAnimation);
             else
             {
                 (new Logger()).WriteNotice("-------SMILE------ попытка создать Animation из смайла [" + stSmile.sText + "] не удалась. Смс вышла c текстовым смайлом.");
                 cText = new BTL.Play.Text(stSmile.sText, cSMS.cPreferences.cFont, cSMS.cPreferences.nBorderWidth);
                 cText.bCUDA = false;
                 cText.stColor = SMILE.stTextSmileColor;
                 cText.stColorBorder = cSMS.cPreferences.stBorderColor;
                 aRetVal.Add(cText);
             }
             return aRetVal;
         case Type.flag:
             if (null != cSMS._cFlagAnim)
                 aRetVal.Add(cSMS._cFlagAnim);
             else
                 (new Logger()).WriteError(new Exception("-------FLAG------ попытка получить Animation флага из SMS с телефоном [" + cSMS._sPhone + "] не удалась. Смс вышла без флага."));
             return aRetVal;
         case Type.text:
             cText = new BTL.Play.Text(sText, cSMS.cPreferences.cFont, cSMS.cPreferences.nBorderWidth);
             if (nMaxWidth < cText.stArea.nWidth)
             {
                 aRetVal.AddRange(SplitLongWord(sText));
             }
             else
             {
                 cText.bCUDA = false;
                 cText.stColor = cSMS.cPreferences.stColor;
                 cText.stColorBorder = cSMS.cPreferences.stBorderColor;
                 aRetVal.Add(cText);
             }
             return aRetVal;
     }
     return null;
 }
예제 #2
0
		private Queue<SMS> GetSMSs(int nQtty)
        {
			Queue<SMS> aRetVal = new Queue<SMS>();
			try
            {
				Queue<Message> aqMessages = null;
				Message cMessage = null;
                SMS cSMS = null;
                DBInteract cDBI = new DBInteract();
                try
                {
                    if (_cPreferences.eBroadcastType == Preferences.BroadcastType.linear && cDBI.IsThereAnyStartedLiveBroadcast())
                    {
                        cSMS = new SMS() { cPreferences = _cPreferences.cRoll.cSMSVIP };

                        //cSMS.Color = null;
                        //cSMS.Color = Color.FromArgb(0, 0, 0, 0);
                        cSMS.ID = -123456;
                        cSMS.sText = "По техническим причинам SMS-чат временно заблокирован! Приносим извинения за причиненные неудобства! :)";
                        cSMS.Phone = "+70000000003";
                        cSMS.eType = SMS.Type.Promo;
						aRetVal.Enqueue(cSMS);
                        return aRetVal;
                    }
                }
                catch (Exception ex)
                {
                    (new Logger()).WriteError(ex);
                }

                Preferences.Promo cPromo;
                Preferences.Promo cPromoLast = _cPromoLast;
                if (null != cPromoLast)
                {
					aqMessages = new Queue<Message>();
					DateTime dtNow = DateTime.Now;
                    if (dtNow >= cPromoLast.dtLastShow.Add(_cPreferences.cVIP.tsPromoPeriod) && null != (cPromo = GetNextPromo(cPromoLast, dtNow)))
					{
						cMessage = new Message(-109, "-109", null, 1, 70000000002, 0, "PROMO " + cPromo.sText, null, dtNow, dtNow);
						cPromo.dtLastShow = dtNow;
                        _cPromoLast = cPromo;
						aqMessages.Enqueue(cMessage);
					}
					if (1 > aqMessages.Count)
						aqMessages = null;
                }

				if (null == aqMessages)
				{
					aqMessages = cDBI.MessagesQueuedGet(_cPreferences.cVIP.sPrefix);
					if (null == aqMessages || 1 > aqMessages.Count)
						aqMessages = cDBI.MessagesQueuedGet();
				}

				while (null != aqMessages && 0 < aqMessages.Count)
				{
                    try
                    {
						cMessage = aqMessages.Dequeue();
						cSMS = new SMS();
						cSMS.ID = cMessage.nID;
						cSMS.sText = cMessage.sText.ToString();
                        if (cSMS.sText.StartsWith(_cPreferences.cVIP.sPrefix))
                        {
                            //if (bRemovePrefix)
                            cSMS.sText = cSMS.sText.Remove(0, _cPreferences.cVIP.sPrefix.Length);
                            cSMS.eType = SMS.Type.VIP;
                            cSMS.cPreferences = _cPreferences.cRoll.cSMSVIP;
							if (_cPreferences.cRoll.cSMSVIP.bToUpper)
								cSMS.sText = cSMS.sText.ToUpper();
						}
                        else if (cSMS.sText.StartsWith(_cPreferences.sPhotoPrefix))
                        {
                            cSMS.eType = SMS.Type.Photo;
                            cSMS.cPreferences = _cPreferences.cRoll.cSMSPhoto;
							if (_cPreferences.cRoll.cSMSPhoto.bToUpper)
								cSMS.sText = cSMS.sText.ToUpper();
                        }
                        else if (cSMS.sText.StartsWith("PROMO "))
                        {
                            cSMS.sText = cSMS.sText.Remove(0, ("PROMO ").Length);
                            cSMS.eType = SMS.Type.Promo;
							cSMS.cPreferences = _cPreferences.cRoll.cSMSPromo;
							if (_cPreferences.cRoll.cSMSPromo.bToUpper)
								cSMS.sText = cSMS.sText.ToUpper();
						}
                        else
                        {
                            cSMS.eType = SMS.Type.Common;
                            cSMS.cPreferences = _cPreferences.cRoll.cSMSCommon;
							if (_cPreferences.cRoll.cSMSCommon.bToUpper)
								cSMS.sText = cSMS.sText.ToUpper();
						}
						cSMS.Phone = "+" + cMessage.nSourceNumber;
						aRetVal.Enqueue(cSMS);
                    }
                    catch (Exception ex)
                    {
						if (null == _cSMSChat)
							break;
						(new Logger()).WriteWarning("[msgsc:" + aqMessages.Count + "]");
                        (new Logger()).WriteWarning("ERROR:" + ex.Message + ex.StackTrace.ToString());
                    }
                }
            }
            catch (Exception ex)
            {
                (new Logger()).WriteError(ex);
            }
            return aRetVal;
        }
예제 #3
0
        private Queue <SMS> GetSMSs(int nQtty)
        {
            Queue <SMS> aRetVal = new Queue <SMS>();

            try
            {
                List <Message>  aM         = null;
                Queue <Message> aqMessages = null;
                Message         cMessage   = null;
                SMS             cSMS       = null;
                DBInteract      cDBI       = new DBInteract();
                try
                {
                    if (_cPreferences.eBroadcastType == Preferences.BroadcastType.linear && cDBI.IsThereAnyStartedLiveBroadcast())
                    {
                        if (_cPreferences.bAnotherAirError)
                        {
                            (new Logger()).WriteError("there is another broadcast on air. chat is off. see DB scr.shifts");
                        }
                        else
                        {
                            (new Logger()).WriteNotice("there is another broadcast on air. chat is off. see DB scr.shifts");
                        }
                        System.Threading.Thread.Sleep(6000);
                        return(aRetVal);  // do not display errors to people



                        cSMS = new SMS()
                        {
                            cPreferences = _cPreferences.cRoll.cSMSVIP
                        };

                        //cSMS.Color = null;
                        //cSMS.Color = Color.FromArgb(0, 0, 0, 0);
                        cSMS.ID    = -123456;
                        cSMS.sText = "По техническим причинам SMS-чат временно заблокирован! Приносим извинения за причиненные неудобства! :)";
                        cSMS.Phone = "+70000000003";
                        cSMS.eType = SMS.Type.Promo;
                        aRetVal.Enqueue(cSMS);
                        Preferences.nUndisplayedMessages = 1;
                        return(aRetVal);
                    }
                }
                catch (Exception ex)
                {
                    (new Logger()).WriteError(ex);
                }

                Preferences.nUndisplayedMessages = cDBI.MessagesUndisplayedCountGet();
                Preferences.Promo cPromo;
                Preferences.Promo cPromoLast = _cPromoLast;
                aM = new List <Message>();

                if (null != cPromoLast)
                {
                    DateTime dtNow = DateTime.Now;
                    if (dtNow >= cPromoLast.dtLastShow.Add(_cPreferences.cVIP.tsPromoPeriod) && null != (cPromo = GetNextPromo(cPromoLast, dtNow)))
                    {
                        cMessage          = new Message(-109, "-109", null, 1, 70000000002, 0, "PROMO " + cPromo.sText, null, dtNow, dtNow);
                        cPromo.dtLastShow = dtNow;
                        _cPromoLast       = cPromo;
                        aM.Add(cMessage);
                    }
                }
                if (aM.Count < nQtty)
                {
                    aqMessages = cDBI.MessagesQueuedGet(_cPreferences.cVIP.sPrefix);
                    if (!aqMessages.IsNullOrEmpty())
                    {
                        aM.AddRange(aqMessages.ToArray());
                    }
                }

                if (aM.Count < nQtty)
                {
                    aqMessages = cDBI.MessagesQueuedGet();
                    if (!aqMessages.IsNullOrEmpty())
                    {
                        aM.AddRange(aqMessages.ToArray());
                    }
                }

                for (int nI = 0; nI < aM.Count; nI++)
                {
                    try
                    {
                        cMessage   = aM[nI];
                        cSMS       = new SMS();
                        cSMS.ID    = cMessage.nID;
                        cSMS.sText = cMessage.sText.ToString();
                        if (cSMS.sText.StartsWith(_cPreferences.cVIP.sPrefix))
                        {
                            //if (bRemovePrefix)
                            cSMS.sText        = cSMS.sText.Remove(0, _cPreferences.cVIP.sPrefix.Length);
                            cSMS.eType        = SMS.Type.VIP;
                            cSMS.cPreferences = _cPreferences.cRoll.cSMSVIP;
                            if (_cPreferences.cRoll.cSMSVIP.bToUpper)
                            {
                                cSMS.sText = cSMS.sText.ToUpper();
                            }
                        }
                        else if (cSMS.sText.StartsWith(_cPreferences.sPhotoPrefix))
                        {
                            cSMS.eType        = SMS.Type.Photo;
                            cSMS.cPreferences = _cPreferences.cRoll.cSMSPhoto;
                            if (_cPreferences.cRoll.cSMSPhoto.bToUpper)
                            {
                                cSMS.sText = cSMS.sText.ToUpper();
                            }
                        }
                        else if (cSMS.sText.StartsWith("PROMO "))
                        {
                            cSMS.sText        = cSMS.sText.Remove(0, ("PROMO ").Length);
                            cSMS.eType        = SMS.Type.Promo;
                            cSMS.cPreferences = _cPreferences.cRoll.cSMSPromo;
                            if (_cPreferences.cRoll.cSMSPromo.bToUpper)
                            {
                                cSMS.sText = cSMS.sText.ToUpper();
                            }
                        }
                        else
                        {
                            cSMS.eType        = SMS.Type.Common;
                            cSMS.cPreferences = _cPreferences.cRoll.cSMSCommon;
                            if (_cPreferences.cRoll.cSMSCommon.bToUpper)
                            {
                                cSMS.sText = cSMS.sText.ToUpper();
                            }
                        }
                        cSMS.Phone = "+" + cMessage.nSourceNumber;
                        aRetVal.Enqueue(cSMS);
                        if (aRetVal.Count >= nQtty)
                        {
                            break;
                        }
                    }
                    catch (Exception ex)
                    {
                        if (null == _cSMSChat)
                        {
                            break;
                        }
                        (new Logger()).WriteWarning("[msgsc:" + aM.Count + "][msg:" + aM[nI]?.sText + "]");
                        (new Logger()).WriteWarning("ERROR:" + ex.Message + ex.StackTrace.ToString());
                    }
                }
            }
            catch (Exception ex)
            {
                (new Logger()).WriteError(ex);
            }
            return(aRetVal);
        }