public ClassBenchmark(string Mailbox, ExchangeCredentials Credentials, ClassStats Stats, ClassLogger Logger, string EWSUrl = "") { _service = new ExchangeService(ExchangeVersion.Exchange2013_SP1); ServicePointManager.ServerCertificateValidationCallback = ValidateCertificate; _service.Credentials = Credentials; _mailbox = Mailbox; _stats = Stats; _logger = Logger; long startTicks = DateTime.Now.Ticks; if (!String.IsNullOrEmpty(EWSUrl)) { _logger.Log($"Using EWS URL: {EWSUrl}"); _service.Url = new Uri(EWSUrl); } else { _logger.Log(String.Format("Performing autodiscover for {0}", Mailbox)); try { _service.AutodiscoverUrl(Mailbox, AutodiscoverCallback); } catch (Exception ex) { _logger.Log(String.Format("Autodiscover failed: {0}", ex.Message)); } finally { long endTicks = DateTime.Now.Ticks; Stats.AddStat("Autodiscover", endTicks - startTicks); } } }
public Form1() { InitializeComponent(); _stats = new ClassStats(); _stats.StatUpdated += _stats_StatUpdated; _logger = new ClassLogger("EWSBenchmark.log"); _logger.LogAdded += _logger_LogAdded; }
public void LogStats(ClassLogger Logger) { // Write the current stats to the logger foreach (string sStat in _responseTimes.Keys) { try { int iAverage = (int)_responseTimes[sStat].Average(); int iMinimum = (int)_responseTimes[sStat].Min(); int iMaximum = (int)_responseTimes[sStat].Max(); int iTotal = _responseTimes[sStat].Count; Logger.Log(String.Format("{0}: Average {1}ms, Min {2}ms, Max {3}ms, {4} total requests", sStat, iAverage, iMinimum, iMaximum, iTotal)); } catch { } } }