public HotList(string directory) { this.available = true; DateTime start = DateTime.Now; this.dataFiles = new DataFileCollection(); this.directory = directory; if (Directory.Exists(this.directory)) { string[] files = Directory.GetFiles(this.directory, HotListDataFile.SearchPattern); if (files != null) { foreach (string file in files) { this.dataFiles.Add(new HotListDataFile(file)); } ArrayList results = new ArrayList(); foreach (HotListDataFile hl in this.dataFiles) { results.Add(hl.BeginInitialize()); } for (int i = 0; i < results.Count; i++) { this.dataFiles[i].EndInitialize(results[i] as IAsyncResult); } } } this.eq = new PIPS.Utilities.EventQueue(); this.eq.EventOccurred += new PIPS.Utilities.EventQueueHandler(FindCallback); insertEvent = this.GetLastDataFile().HotList.CreateHotListDataEvent(); //PIPS.Logger.WriteLine(false, "Hotlist.Initialize({0}, {1})", (DateTime.Now - start).TotalMilliseconds, directory); }
public void Insert(HotListDataEvent ev) { if ((ev.VRM != null) && (ev.VRM != string.Empty)) { this.HotList.Save(ev); } if ((ev.PNCID != null) && (ev.PNCID != string.Empty)) { this.PNCID.Save(ev); } }
private void ImportDeltaInserts(string pipscsv, string filename, StringHandler msgCallback) { CSV csv = new CSV(PIPS.Utilities.FileEncrypter.IsEncrypted(filename) ? PIPS.Utilities.FileEncrypter.GetStreamReader(filename) : new StreamReader(filename)); try { //PIPS.Logger.WriteLine("HotList.DeltaInserts({0})", filename); string[] fields; int count = 1; int dataFileIndex = 0; Int64 bossId; HotListDataFile df = ((HotListDataFile)this.dataFiles[dataFileIndex]); df.BeginTransaction(); while ((fields = csv.ReadLine()) != null) { if ((++count % 1000) == 0) { if (null != msgCallback) { msgCallback(string.Format("Inserting '{0}' at line {1}...", Path.GetFileNameWithoutExtension(filename), count)); } df.CommitTransaction(); dataFileIndex = (dataFileIndex + 1) % this.dataFiles.Count; df.BeginTransaction(); } HotListDataEvent de = df.HotList.CreateDataEvent() as HotListDataEvent; de.ID = -1; de.VRM = fields[0]; de.Field1 = fields[1]; de.Field2 = fields[2]; de.Field3 = fields[3]; de.Field4 = fields[4]; de.Field5 = fields[5]; de.PNCID = fields[6]; de.Information = fields[7]; // Only BOSS provides a valid BOSS id if (fields.Length < 9 || !Int64.TryParse(fields[8], out bossId)) { bossId = -1; } de.BossID = bossId; de.Save(); } df.CommitTransaction(); } finally { csv.Close(); } GC.WaitForPendingFinalizers(); GC.Collect(0, GCCollectionMode.Forced); GC.Collect(1, GCCollectionMode.Forced); GC.Collect(2, GCCollectionMode.Forced); }
private HitsDataEvent CopyHotlistToHit(long hotlist_id, HotListDataEvent hotlist) { HitsDataEvent hit = (this.DataFile.DataRepository as SystemRepository).Events.Reads.Hits.CreateHitsDataEvent(); HotListsDataEvent hl = this.SelectByID(hotlist_id) as HotListsDataEvent; hit.Alarm = hl.Alarm; hit.DisplayColor = hl.DisplayColor; hit.Field1 = hotlist.Field1; hit.Field2 = hotlist.Field2; hit.Field3 = hotlist.Field3; hit.Field4 = hotlist.Field4; hit.Field5 = hotlist.Field5; hit.HotList = hl.Name; hit.Information = hotlist.Information; hit.IsCovert = hl.IsCovert; hit.PNCID = hotlist.PNCID; hit.Priority = hl.Priority; hit.VRM = hotlist.VRM; hit.Alerting = hl.Alerting; return(hit); }
private void ImportDeltaDeletes(string pipscsv, string filename, StringHandler msgCallback) { CSV csv = new CSV(PIPS.Utilities.FileEncrypter.IsEncrypted(filename) ? PIPS.Utilities.FileEncrypter.GetStreamReader(filename) : new StreamReader(filename)); try { //PIPS.Logger.WriteLine("HotList.DeltaDeletes({0})", filename); string[] fields; int count = 0; while ((fields = csv.ReadLine()) != null) { if ((msgCallback != null) && ((count % 1000) == 0)) { msgCallback(string.Format("Deleting '{0}' at line {1}...", Path.GetFileNameWithoutExtension(filename), count)); } foreach (HotListDataFile df in this.dataFiles) { df.BeginTransaction(); long[] IDs = df.HotList.SelectIDsByVRM(fields[0]); foreach (long ID in IDs) { HotListDataEvent de = df.HotList.SelectByID(ID) as HotListDataEvent; if (null != de && string.Equals(de.VRM, fields[0], StringComparison.OrdinalIgnoreCase)) { de.Delete(); } } df.CommitTransaction(); } count++; } } finally { csv.Close(); } }