コード例 #1
0
        private void AddEventGridEntry(FileSystemEvent fileSystemEvent)
        {
            Bitmap eventIcon;
            Color eventColor;
            string eventString;

            switch (fileSystemEvent.EventType)
            {
                case FileSystemEventType.Created:
                    eventIcon = Resources.EventCreatedBitmap;
                    eventColor = Color.Green;
                    eventString = "Created";
                    break;
                case FileSystemEventType.Deleted:
                    eventIcon = Resources.EventDeletedBitmap;
                    eventColor = Color.Red;
                    eventString = "Deleted";
                    break;
                case FileSystemEventType.Renamed:
                    eventIcon = Resources.EventRenamedBitmap;
                    eventColor = Color.Orange;
                    eventString = "Renamed";
                    break;
                default:
                    eventIcon = Resources.EventModifiedBitmap;
                    eventColor = Color.Blue;
                    eventString = "Modified";
                    break;
            }

            string fileNameColumnValue =
                (fileSystemEvent.EventType != FileSystemEventType.Renamed)
                    ? fileSystemEvent.NewFileName
                    : string.Format("{0} > {1}", fileSystemEvent.OldFileName, fileSystemEvent.NewFileName);
            int newRowIndex = gridEvents.Rows.Add(eventIcon, fileSystemEvent.EventDate.ToString("dd.MM.yyyy HH:mm:ss.ff"), eventString, fileNameColumnValue);
            gridEvents[colEventType.Index, newRowIndex].Style.ForeColor = eventColor;
        }
コード例 #2
0
        private void LoadEventsFromDatabase()
        {
            const string eventSelectQueryText =
                @"select * from FileSystemEvent where FolderTraceGUID = @FolderTraceGUID order by FileSystemEventDate desc";

            gridEvents.Rows.Clear();
            if (ActiveFolderTrace != null)
            {
                QueryParameterSet queryParameters = new QueryParameterSet();
                queryParameters.Add("@FolderTraceGUID", ActiveFolderTrace.GUID.ToString());
                IQueryResult queryResult = DataProvider.Database.Query(eventSelectQueryText, queryParameters, true);

                int rowCount = queryResult.Rows.Count;
                for (int i = 0; i < gridTraces.Rows.Count; i++)
                {
                    if (gridTraces.Rows[i].Tag == ActiveFolderTrace)
                    {
                        gridTraces[colTraceEventCount.Index, i].Value = rowCount;
                    }
                }

                for (int i = 0; i < rowCount; i++)
                {
                    int eventType = Convert.ToInt32(queryResult[i]["FileSystemEventType"]);
                    DateTime eventDate = Convert.ToDateTime(queryResult[i]["FileSystemEventDate"]);
                    string oldName = Convert.ToString(queryResult[i]["FileSystemEventOldName"]);
                    string newName = Convert.ToString(queryResult[i]["FileSystemEventNewName"]);

                    FileSystemEvent fsEvent = new FileSystemEvent((FileSystemEventType)eventType, oldName, newName, eventDate);
                    AddEventGridEntry(fsEvent);
                }
            }
        }