Пример #1
0
        protected void lbSearchResultSummaries_SelectedIndexChanged(object sender, EventArgs e)
        {
            string strSelectedSearchResultSummary = lbSearchResultSummaries.SelectedValue;

            if (strSelectedSearchResultSummary == null || !SearchResults.ContainsKey(strSelectedSearchResultSummary))
            {
                ClearSelectedSearchResultFields();
                return;
            }

            TargetLogRecord tlrSearchResult = SearchResults[strSelectedSearchResultSummary];

            tbLogRecordID.Text  = tlrSearchResult.LogID.ToString();
            tbTargetID.Text     = tlrSearchResult.TargetID.ToString();
            tbTimeStamp.Text    = MySqlUtils.DateTimeToString(tlrSearchResult.TimeStamp);
            tbStatus.Text       = tlrSearchResult.Status.ToString();
            tbMessage.Text      = tlrSearchResult.Message;
            tbErrorCode.Text    = tlrSearchResult.ErrorCode.ToString();
            tbLocationID.Text   = tlrSearchResult.LocationID.ToString();
            tbResponseTime.Text = tlrSearchResult.ResponseTime.ToString();
        }
Пример #2
0
        protected void btnSearch_Click(object sender, EventArgs e)
        {
            uint unTargetID = 0;

            if (rbTarget.Checked)
            {
                string strSelectedTargetName = lbTargetNames.SelectedValue;

                if (strSelectedTargetName == null)
                {
                    throw new Exception(@"Cannot search by target: no target name is selected");
                }

                unTargetID = m_dictTargets[strSelectedTargetName];
            }

            uint unAccountID = 0;

            if (rbAccount.Checked)
            {
                string strSelectedAccountName = lbAccountNames.SelectedValue;

                if (strSelectedAccountName == null)
                {
                    throw new Exception(@"Cannot search by account: no account name is selected");
                }

                unAccountID = m_dictAccounts[strSelectedAccountName];
            }

            bool     bFailedOnly       = cbFailuresOnly.Checked;
            DateTime?ndtStartTimeStamp = null;

            if (cbStartTimeStamp.Checked)
            {
                ndtStartTimeStamp = DateTime.Parse(tbStartTimeStamp.Text);
            }

            DateTime?ndtEndTimeStamp = null;

            if (cbEndTimeStamp.Checked)
            {
                ndtEndTimeStamp = DateTime.Parse(tbEndTimeStamp.Text);
            }

            string                 strCommandText   = TargetLogRecord.GetSelectCommand(unTargetID, unAccountID, bFailedOnly, ndtStartTimeStamp, ndtEndTimeStamp);
            MySqlConnection        con              = GetMySqlConnection();
            List <TargetLogRecord> lstSearchResults = TargetLogRecord.GetRecords(con, strCommandText);
            Dictionary <string, TargetLogRecord> dictSearchResults = new Dictionary <string, TargetLogRecord>();

            foreach (TargetLogRecord tlr in lstSearchResults)
            {
                uint   unTargetID2      = tlr.TargetID;
                string strRecordSummary = string.Format(@"{0} {1} {2}",
                                                        //tlr.TimeStamp.ToString(@"yyyy-MM-dd HH:mm:ss"),
                                                        MySqlUtils.DateTimeToString(tlr.TimeStamp),
                                                        tlr.Status,
                                                        m_dictTargetsIDToName.ContainsKey(unTargetID2) ? m_dictTargetsIDToName[unTargetID2] : unTargetID2.ToString());

                dictSearchResults.Add(strRecordSummary, tlr);
            }

            // Store (lstSearchResults and) dictSearchResults in the Session.
            SearchResults = dictSearchResults;

            WebUtils.PopulateListItemCollectionFromStringEnumerable(dictSearchResults.Keys, lbSearchResultSummaries.Items);

            ClearSelectedSearchResultFields();
        }