Ejemplo n.º 1
0
        private ListViewItem ConstructListViewItem(MOG_DBEventInfo info)
        {
            ListViewItem item = null;

            if (info != null && mVisibleColumns != null && mVisibleColumns.Count > 0)
            {
                // construct listviewitem
                item = new ListViewItem();

                for (int i = 0; i < mVisibleColumns.Count; i++)
                {
                    string text = GetCommandData(mVisibleColumns[i], info);
                    if (text.Length >= 260)
                    {
                        text = text.Substring(0, 259);
                    }

                    if (i == 0)
                    {
                        item.Text = text;
                    }
                    else
                    {
                        item.SubItems.Add(text);
                    }
                }

                EventData eventData = new EventData();
                eventData.eventInfo = info;
                item.Tag            = eventData;
            }

            return(item);
        }
Ejemplo n.º 2
0
        internal void LoadEvent(int index)
        {
            if (mListView != null)
            {
                if (index >= 0 && index < mListView.Items.Count)
                {
                    mCurrentIndex = index;

                    EventData data = mListView.Items[index].Tag as EventData;
                    if (data != null)
                    {
                        info = data.eventInfo;
                        if (info != null)
                        {
                            //"ID", "Type", "Timestamp", "Description", "EventID", "Username", "Computer", "Project", "Branch" } );
                            tbID.Text           = info.mID.ToString();
                            tbType.Text         = info.mType;
                            tbDate.Text         = EventDate;
                            tbTime.Text         = EventTime;
                            tbEventID.Text      = info.mEventID;
                            tbUser.Text         = info.mUserName;
                            tbComputer.Text     = info.mComputerName;
                            tbProject.Text      = info.mProjectName;
                            tbBranch.Text       = info.mBranchName;
                            rtbDescription.Text = EventVerboseDescription;
                        }
                    }

                    PrevButton.Enabled = index > 0;
                    NextButton.Enabled = index < mListView.Items.Count - 1;
                }
            }
        }
Ejemplo n.º 3
0
        private string EventToString(ListViewItem item)
        {
            string s = "";

            if (!(item.Tag is EventData))
            {
                return(s);
            }

            MOG_DBEventInfo info = ((EventData)item.Tag).eventInfo;

            foreach (string colName in mAllColumns)
            {
                s += GetCommandData(colName, info) + "\t";
            }

            return(s);
        }
Ejemplo n.º 4
0
        private void FilterEvents()
        {
            lock (mAllListViewItems)
            {
                lock (mFilteredListViewItems)
                {
                    // Set VirtualListSize to zero to prevent it from trying to retrieve items while we operate on it below
                    lvfEvents.VirtualListSize = 0;
                    lvfEvents.TopItem         = null;

                    mFilteredListViewItems.Clear();

                    foreach (ListViewItem item in mAllListViewItems)
                    {
                        EventData eventData = item.Tag as EventData;
                        if (eventData != null)
                        {
                            MOG_DBEventInfo info = eventData.eventInfo as MOG_DBEventInfo;
                            if (info != null)
                            {
                                if (mFilter.Contains("Types", info.mType) &&
                                    mFilter.Contains("Users", info.mUserName) &&
                                    mFilter.Contains("Computers", info.mComputerName) &&
                                    mFilter.Contains("Projects", info.mProjectName) &&
                                    mFilter.Contains("Branches", info.mBranchName))
                                {
                                    mFilteredListViewItems.Add(item);
                                }
                            }
                        }
                    }
                }
            }

            // Check if we have anything in mFilteredListViewItems?
            if (mFilteredListViewItems.Count > 0)
            {
                lvfEvents.VirtualListSize = mFilteredListViewItems.Count;
                lvfEvents.TopItem         = mFilteredListViewItems[0];
            }

            lvfEvents.Refresh();
            UpdateStatusBar();
        }
Ejemplo n.º 5
0
        private bool SaveEvent(MOG_DBEventInfo eventInfo)
        {
            if (mDatabase != null && eventInfo != null)
            {
                if (eventInfo.mType == "")
                {
                    eventInfo.mType = "<type>";
                }
                if (eventInfo.mTimeStamp == "")
                {
                    eventInfo.mTimeStamp = "<timestamp>";
                }
                if (eventInfo.mDescription == "")
                {
                    eventInfo.mDescription = "<description>";
                }
                if (eventInfo.mEventID == "")
                {
                    eventInfo.mEventID = "<eventid>";
                }
                if (eventInfo.mUserName == "")
                {
                    eventInfo.mUserName = "******";
                }
                if (eventInfo.mComputerName == "")
                {
                    eventInfo.mComputerName = "<computername>";
                }
                if (eventInfo.mProjectName == "")
                {
                    eventInfo.mProjectName = "<projectname>";
                }
                if (eventInfo.mBranchName == "")
                {
                    eventInfo.mBranchName = "<current>";
                }

                MOG_DBEventAPI.AddEvent(eventInfo.mType, eventInfo.mTimeStamp, eventInfo.mTitle, eventInfo.mDescription, eventInfo.mStackTrace, eventInfo.mEventID, eventInfo.mUserName, eventInfo.mComputerName, false);
                return(true);
            }

            return(false);
        }
Ejemplo n.º 6
0
        public static string GetCommandData(string colName, MOG_DBEventInfo info)
        {
            if (colName != null && info != null)
            {
                switch (colName)
                {
                case "Id":
                    return(info.mID.ToString());

                case "Type":
                    return(info.mType.Replace("MOG_COMMAND_", ""));

                case "Timestamp":
                    return(new MOG_Time(info.mTimeStamp).FormatString(""));

                case "Description":
                    string description = info.mDescription;
                    description = description.Replace("\n", " ");
                    return(description);

                case "Eventid":
                    return(info.mEventID);

                case "Username":
                    return(info.mUserName);

                case "Computer":
                    return(info.mComputerName);

                case "Project":
                    return(info.mProjectName);

                case "Branch":
                    return(info.mBranchName);

                default:
                    return("Unknown column name: \"" + colName + "\"");
                }
            }

            return("");
        }
Ejemplo n.º 7
0
        private ListViewItem CreateItemFromDBEventInfo(MOG_DBEventInfo eventInfo, bool fromDB)
        {
            ListViewItem item = ConstructListViewItem(eventInfo);

            ((EventData)item.Tag).existsInDB = fromDB;

            switch (eventInfo.mType.ToUpper())
            {
            case "MOG_COMMAND_NOTIFYSYSTEMERROR":
            case "MOG_COMMAND_ERROR":
            case "ERROR":
            case "SYSTEMERROR":
                item.ImageIndex = ERROR_INDEX;
                item.ForeColor  = Color.Red;
                break;

            case "MOG_COMMAND_NOTIFYSYSTEMWARNING":
            case "WARNING":
            case "SYSTEMWARNING":
                item.ImageIndex = WARNING_INDEX;
                item.ForeColor  = Color.Black;
                break;

            case "MOG_COMMAND_NOTIFYSYSTEMEXCEPTION":
            case "MOG_COMMAND_EXCEPTION":
            case "EXCEPTION":
            case "SYSTEMEXCEPTION":
                item.ImageIndex = EXCEPTION_INDEX;
                item.ForeColor  = Color.Black;
                break;

            case "MOG_COMMAND_NOTIFYSYSTEMALERT":
            case "MOG_COMMAND_ALERT":
            case "ALERT":
            case "SYSTEMALERT":
                item.ImageIndex = WARNING_INDEX;
                item.ForeColor  = Color.Blue;
                break;
            }

            return(item);
        }