Example #1
0
        private void PortReader_NotificationFinishedReady(object sender, FinishPortEvent e)
        {
            var culture = Application.CurrentCulture;

            if (e.Exception != null)
            {
                MessageBox.Show(e.Exception.Message, ResourceManagerProvider.GetLocalizedString("MSG_ERROR_MODEM_TITLE", Application.CurrentCulture),
                                MessageBoxButtons.OK, MessageBoxIcon.Error);

                // Enable gui as call process is finished
                SetGUIAvailableForCallProcess(true);
                SetCallButtonAvailability(true);
            }
            else
            {
                // Enable gui as call process is finished
                SetGUIAvailableForCallProcess(true);
                SetCallButtonAvailability(true);

                if (_xmlWrapper.CallSettings.PlaySound)
                {
                    PlaySystemSound();
                }
            }

            lbLog.AddLogItem(String.Format(ResourceManagerProvider.GetLocalizedString("LOG_NOTIFICATION_FINISHED", culture), _currentSessionStatistics.ActivatedCount));
        }
Example #2
0
        private void PortReader_TelephoneFinishedReady(object sender, FinishPortEvent e)
        {
            var culture = Application.CurrentCulture;

            if (e.Exception != null)
            {
                MessageBox.Show(e.Exception.Message, ResourceManagerProvider.GetLocalizedString("MSG_ERROR_MODEM_TITLE", Application.CurrentCulture),
                                MessageBoxButtons.OK, MessageBoxIcon.Error);

                // Enable gui as call process is finished
                SetGUIAvailableForCallProcess(true);
                SetCallButtonAvailability(true);
            }
            else
            {
                var nonActivatedList = _currentSessionStatistics.Telephones.Where(tel => !tel.IsActivated()).ToList();
                // If we have to repeat call process and stop button was not pressed and list contains any not activated telephone
                if (_xmlWrapper.CallSettings.Repeatable && btnCall.Enabled && nonActivatedList.Any())
                {
                    StartOperation(nonActivatedList, PortReaderOperation.Call);

                    lbLog.AddLogItem(ResourceManagerProvider.GetLocalizedString("LOG_CALL_RESTARTED", culture), _currentSessionStatistics);
                    return;
                }

                // Enable gui as call process is finished
                SetGUIAvailableForCallProcess(true);
                SetCallButtonAvailability(true);

                if (_xmlWrapper.CallSettings.PlaySound)
                {
                    PlaySystemSound();
                }

                if (_xmlWrapper.CallSettings.Shutdown)
                {
                    _xmlWrapper.SaveXml();
                    try
                    {
                        Process.Start("Shutdown", "-s -t 10");
                    }
                    catch (Exception ex)
                    {
                        Logger.Write(ex.Message + ex.StackTrace);
                    }
                    Application.Exit();
                }
            }

            lbLog.AddLogItem(ResourceManagerProvider.GetLocalizedString("LOG_CALL_FINISHED", culture), _currentSessionStatistics);
        }