public void Prepare() { try { _bStopped = true; _aqSMSs = new Queue <SMS>(); (_cSMSChat = new SMSChat(_cPreferences)).Init(); _eStatus = BTL.EffectStatus.Preparing; _dtStatusChanged = DateTime.Now; if (null != Prepared) { Plugin.EventSend(Prepared, this); } (new Logger()).WriteDebug3("ok"); } catch (Exception ex) { (new Logger()).WriteError(ex); } }
public void Stop() { lock (_oLockStop) { if (_bStopped) { return; } _bStopped = true; } try { _cSMSChat.IsChatTerminating = true; (new Logger()).WriteNotice("Stop: IsChatTerminating = true"); DateTime dtNow = DateTime.Now.AddSeconds(5); while ((_cSMSChat.IsChatTerminating || _cSMSChat.IsInfoOnAir) && DateTime.Now < dtNow) { Thread.Sleep(50); } while (!_bWorkerSMSEnd && !_bWorkerEnd) { Thread.Sleep(50); } _cSMSChat.Stop(); _cSMSChat.Release(); (new Logger()).WriteNotice("Stop: after _cSMSChat.Release();"); lock (_oLock) { _cSMSChat = null; } } catch (Exception ex) { (new Logger()).WriteError(ex); } finally { try { DBInteract cDBI = new DBInteract(); bool bIsAir = cDBI.IsThereAnyStartedLiveBroadcast(); (new Logger()).WriteDebug2("ChatLogStopAdd [isair=" + bIsAir + "][type=" + _cPreferences.eBroadcastType + "][release=" + _cPreferences.bMessagesRelease + "]"); if (_cPreferences.bMessagesRelease && !(_cPreferences.eBroadcastType == Preferences.BroadcastType.linear && bIsAir) && !(_cPreferences.eBroadcastType == Preferences.BroadcastType.live && !bIsAir)) { bool bOk = cDBI.ChatLogStopAdd(DateTime.Now.AddSeconds(4)); (new Logger()).WriteNotice("ChatLogStopAdd - " + bOk); } else if (_bChatWasAddedToLogsOnStart) { bool bOk = cDBI.ChatLogStopAdd(DateTime.Now.AddSeconds(4)); (new Logger()).WriteNotice("ChatLogStopAdd-2 - " + bOk); } _bChatWasAddedToLogsOnStart = false; _eStatus = BTL.EffectStatus.Stopped; _dtStatusChanged = DateTime.Now; _cPreferences = null; if (null != Stopped) { Plugin.EventSend(Stopped, this); } } catch (Exception ex) { (new Logger()).WriteError("Stop: ", ex); } } }