private BaseWatcher MonitoringAux(string watchType, BaseWatchingObject watchingObject) { BaseWatcher baseWatcher = null; switch (watchType) { case "file": WatchingFileObject watchingFileObject = (WatchingFileObject)watchingObject; string path = watchingFileObject.GetPath(); string fileName = watchingFileObject.GetFileName(); baseWatcher = new FileWatcher(watchingFileObject.GetWatchId(), path, "*." + watchingFileObject.GetFileType(), fileName, new FileInfo(path + "\\" + fileName).Length); if (fileName.Equals("watcher.config")) { ((FileWatcher)baseWatcher).ConfigFileUpdated += MainConfigFileUpdated; } break; case "database": WatchingDatabaseObject watchingDataObject = (WatchingDatabaseObject)watchingObject; baseWatcher = new DatabaseWatcher(watchingDataObject.GetWatchId(), watchingDataObject.GetDataSource(), watchingDataObject.GetDatabaseName(), watchingDataObject.GetUserId()); break; } return(baseWatcher); }
private BaseWatchingObject PopulatingWatchingListAux(XmlNode watcher) { watcher = watcher.NodeType.ToString().Equals("Document") ? ((XmlDocument)watcher).GetElementsByTagName("watcher").Item(0) : watcher; string watchType = watcher.Attributes["watchType"].Value; int watchId = -1; Int32.TryParse(watcher.Attributes["watchId"].Value, out watchId); BaseWatchingObject watchingObject = null; if (watchType.Equals("file")) { watchingObject = new WatchingFileObject(watchType, watchId, watcher.Attributes["fileType"].Value, watcher.Attributes["name"].Value, watcher.Attributes["path"].Value); } else if (watchType.Equals("database")) { watchingObject = new WatchingDatabaseObject(watchType, watchId, watcher.Attributes["dataSource"].Value, watcher.Attributes["databaseName"].Value, watcher.Attributes["userId"].Value); } return(watchingObject); }