public static void AddLogItem(this ListBox listView, ReadPortEvent guiEvent) { string parameter; if (guiEvent.Code == ResponseCode.BLACKLISTED) { parameter = String.Format(ResourceManagerProvider.GetLocalizedString("LOG_NUMBER_BLACKLISTED", Application.CurrentCulture), guiEvent.Telephone, guiEvent.DialingSeconds, guiEvent.RingingSeconds); } else if (guiEvent.Code == ResponseCode.NO_ANSWER_MODEM) { parameter = String.Format(ResourceManagerProvider.GetLocalizedString("LOG_NUMBER_NO_ANSWER_MODEM", Application.CurrentCulture), guiEvent.Telephone, guiEvent.DialingSeconds, guiEvent.RingingSeconds); } else if (guiEvent.Code == ResponseCode.ERROR) { parameter = String.Format(ResourceManagerProvider.GetLocalizedString("LOG_NUMBER_ERROR", Application.CurrentCulture), guiEvent.Telephone, guiEvent.DialingSeconds, guiEvent.RingingSeconds); } else { parameter = String.Format(ResourceManagerProvider.GetLocalizedString("LOG_NUMBER_PROCESSED", Application.CurrentCulture), guiEvent.Telephone, guiEvent.DialingSeconds, guiEvent.RingingSeconds); } listView.AddLogItem(parameter); }
private void PortReader_TelephoneReadReady(object sender, ReadPortEvent e) { BeginInvoke((MethodInvoker) delegate { var culture = Application.CurrentCulture; _currentSessionStatistics.ProcessedCount++; _currentSessionStatistics.RemainedCount--; if (e.Activated) { listTelephones.UpdateDateActivated(_xmlWrapper, e.Telephone, DateTime.Now); _currentSessionStatistics.ActivatedCount++; if (e.Code == ResponseCode.TIMEOUT) { listTelephones.FindItem(e.Telephone).BackColor = Color.Yellow; } else { listTelephones.FindItem(e.Telephone).BackColor = Color.Aqua; } Logger.Write(String.Format(ResourceManagerProvider.GetLocalizedString("MSG_ACTIVATED_NUMBER", culture), e.Telephone)); } else { switch (e.Code) { case ResponseCode.BLACKLISTED: case ResponseCode.NO_ANSWER_MODEM: case ResponseCode.ERROR: listTelephones.FindItem(e.Telephone).BackColor = Color.Red; break; default: listTelephones.FindItem(e.Telephone).BackColor = Color.Aqua; break; } } UpdateStatusBarInfo(); lbLog.AddLogItem(e); }); }
private void PortReader_NotificationReadReady(object sender, ReadPortEvent e) { BeginInvoke((MethodInvoker) delegate { var culture = Application.CurrentCulture; _currentSessionStatistics.ProcessedCount++; _currentSessionStatistics.RemainedCount--; if (e.Code == ResponseCode.ERROR) { listTelephones.FindItem(e.Telephone).BackColor = Color.Red; } else { _currentSessionStatistics.ActivatedCount++; listTelephones.FindItem(e.Telephone).BackColor = Color.Aqua; } UpdateStatusBarInfo(); }); }