public FormMain(ClassLogger Logger) { InitializeComponent(); _formConfig = new ClassFormConfig(this); LoadCertificate(textBoxAuthCertificate.Text); this.Text = Application.ProductName + " v" + Application.ProductVersion; _logger = Logger; _logger.DebugLog(this.Text); // Hook up the cert callback. ServicePointManager.ServerCertificateValidationCallback = ValidateCertificate; GetUserSMTPAddress(); UpdateTextBoxState(); UpdateHTTPHeaderControls(); UpdateHTTPCookieControls(); xmlEditorResponse.XmlValidationComplete += xmlEditorResponse_XmlValidationComplete; _logger.DebugLog("Initialisation complete"); /* * if (System.Diagnostics.Debugger.IsAttached) * { * FormUserControlTest oForm = new FormUserControlTest(); * oForm.Show(this); * } */ }
public FormMain(bool DebugLogging) { InitializeComponent(); // Add our form configuration helper _formConfig = new ConfigurationManager.ClassFormConfig(this, true); _formConfig.AddControlTypeRecurseExclusion("SOAPe.XmlEditor"); _formConfig.ExcludedControls.Add(groupBoxResponse); _formConfig.ExcludedControls.Add(xmlEditorResponse); _formConfig.ExcludedControls.Add(textBoxHTTPHeaderName); _formConfig.ExcludedControls.Add(textBoxHTTPHeaderValue); ClassFormConfig.ApplyConfiguration(); // Configure log file if (String.IsNullOrEmpty(textBoxLogFolder.Text)) { textBoxLogFolder.Text = System.IO.Path.GetDirectoryName(Application.ExecutablePath); } if (String.IsNullOrEmpty(textBoxLogFileName.Text)) { textBoxLogFileName.Text = "SOAPe.log"; } _logger = new ClassLogger(LogFileName(), DebugLogging); LoadCertificate(textBoxAuthCertificate.Text); this.Text = Application.ProductName + " v" + Application.ProductVersion; _logger.DebugLog(this.Text); // Hook up the cert callback. ServicePointManager.ServerCertificateValidationCallback = ValidateCertificate; GetUserSMTPAddress(); UpdateAuthUI(); UpdateHTTPHeaderControls(); UpdateHTTPCookieControls(); xmlEditorResponse.XmlValidationComplete += xmlEditorResponse_XmlValidationComplete; try { if (!NativeMethods.IsProcessElevated()) { // The HTTP listener requires elevation, check if we have this hTTPListenerToolStripMenuItem hTTPListenerToolStripMenuItem.Image = NativeMethods.GetStockIcon(NativeMethods.SHSTOCKICONID.SIID_SHIELD, NativeMethods.SHGSI.SHGSI_ICON).ToBitmap(); } } catch { } /* * if (System.Diagnostics.Debugger.IsAttached) * { * FormUserControlTest oForm = new FormUserControlTest(); * oForm.Show(this); * } */ _logger.DebugLog("Initialisation complete"); this.Shown += FormMain_Shown; }
void GetUserSMTPAddressWorker(object a) { // We will try to retrieve SMTP address of current user. _logger.DebugLog("Attempting to retrieve SMTP address of current user"); try { // Populate domain first of all string sDomain; using (DirectoryEntry rootDSE = new DirectoryEntry("LDAP://RootDSE")) { sDomain = rootDSE.Properties["defaultNamingContext"].Value.ToString(); } if (sDomain == "") { return; } sDomain = sDomain.Replace("DC=", "").Replace(",", "."); if (String.IsNullOrEmpty(textBoxDomain.Text) && String.IsNullOrEmpty(textBoxUsername.Text)) { if (textBoxDomain.InvokeRequired) { textBoxDomain.Invoke(new MethodInvoker(delegate() { textBoxDomain.Text = sDomain; })); } else { textBoxDomain.Text = sDomain; } } _logger.DebugLog("Current domain: " + sDomain); using (DirectoryEntry userDE = new DirectoryEntry("LDAP://" + UserPrincipal.Current.DistinguishedName.ToString())) { _userSMTPAddress = userDE.Properties["mail"].Value.ToString(); } _logger.DebugLog("Current user's SMTP address: " + _userSMTPAddress); } catch (Exception ex) { // Failed to resolve name, so don't update _logger.DebugLogError(ex, "GetUserSMTPAddress"); return; } }
private void ShowLogIndex() { // Read the logs and update the UI if (_logger.LogDataTable == null) { return; } int iTraceCount = _logger.LogDataTable.Rows.Count; if (iTraceCount == 0) { return; } string sOrderBy = (String)listViewLogIndex.Tag; if (String.IsNullOrEmpty(sOrderBy)) { sOrderBy = "Time ASC,Tid ASC"; } DataRow[] logRows = null; string sFilter = GetLogFilter(); try { logRows = _logger.LogDataTable.Select(sFilter, sOrderBy); } catch (Exception ex) { System.Windows.Forms.MessageBox.Show(String.Format("Error querying logs, please check filter{0}Error: {1}", Environment.NewLine, ex.Message), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); _logger.DebugLog(String.Format("Error retrieving logs rows, filter: {0}", sFilter)); _logger.DebugLogError(ex); return; } xmlEditor1.Text = "No data found for this session."; int i = -1; if (listViewLogIndex.InvokeRequired) { listViewLogIndex.Invoke(new MethodInvoker(delegate() { listViewLogIndex.BeginUpdate(); listViewLogIndex.Items.Clear(); })); } else { listViewLogIndex.BeginUpdate(); listViewLogIndex.Items.Clear(); } iTraceCount = logRows.Length; while (i < iTraceCount - 1) { ShowStatus(String.Format("Processing {0} of {1}", i++, iTraceCount), ((double)i / (double)iTraceCount) * 100); ListViewItem item = new ListViewItem(logRows[i]["Time"].ToString()); item.Tag = logRows[i]["Data"].ToString(); StringBuilder sDescription = new StringBuilder(logRows[i]["Tag"].ToString()); item.SubItems.Add(sDescription.ToString()); item.SubItems.Add(logRows[i]["Tid"].ToString()); item.SubItems.Add(logRows[i]["SOAPMethod"].ToString()); item.SubItems.Add(((Int64)logRows[i]["Size"]).ToString("0,0")); if (listViewLogIndex.InvokeRequired) { listViewLogIndex.Invoke(new MethodInvoker(delegate() { listViewLogIndex.Items.Add(item); })); } else { listViewLogIndex.Items.Add(item); } } if (listViewLogIndex.InvokeRequired) { listViewLogIndex.Invoke(new MethodInvoker(delegate() { listViewLogIndex.EndUpdate(); })); } else { listViewLogIndex.EndUpdate(); } if (String.IsNullOrEmpty(sFilter)) { ShowStatus(null); } else { ShowStatus("Filter Active", 100, Color.MintCream); } ThreadPool.QueueUserWorkItem(new WaitCallback(CheckForErrors), null); }