Example #1
0
        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;
            }
        }
Example #2
0
        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);
        }