public override void EntryPoint() { try { IErrorIndex errorIndex = m_TaskParameters.ErrorIndex; SetTaskStarted(m_TaskParameters.ErrorIndex); StackHashUtilities.SystemInformation.DisableSleep(); ErrorIndexEventParser parser = new ErrorIndexEventParser(); parser.ParseEvent += new EventHandler <ErrorIndexParseEventsEventArgs>(this.processEvent); DateTime purgeDate = DateTime.Now.ToUniversalTime().AddDays(-1 * m_TaskParameters.PurgeOptions.FindMostRecentPurgeAge()); try { // Get the list of products. StackHashProductCollection products = errorIndex.LoadProductList(); foreach (StackHashProduct product in products) { if (this.CurrentTaskState.AbortRequested) { throw new OperationCanceledException("Purging product"); } // Get the files associated with this product. StackHashFileCollection files = errorIndex.LoadFileList(product); foreach (StackHashFile file in files) { if (this.CurrentTaskState.AbortRequested) { throw new OperationCanceledException("Purging file"); } // Now parse the events one at a time. Instead of getting a list of all the events - use a // callback to analyze each event. Note this allows for an abort by returning false // from the callback. parser.Product = product; parser.File = file; parser.SearchCriteriaCollection = new StackHashSearchCriteriaCollection() { new StackHashSearchCriteria( new StackHashSearchOptionCollection() { new IntSearchOption(StackHashObjectType.Product, "Id", StackHashSearchOptionType.Equal, product.Id, 0), new IntSearchOption(StackHashObjectType.File, "Id", StackHashSearchOptionType.Equal, file.Id, 0), new DateTimeSearchOption(StackHashObjectType.CabInfo, "DateCreatedLocal", StackHashSearchOptionType.LessThanOrEqual, purgeDate, purgeDate), new IntSearchOption(StackHashObjectType.CabInfo, "Purged", StackHashSearchOptionType.Equal, 0, 0), // 0 is false. new IntSearchOption(StackHashObjectType.CabInfo, "CabDownloaded", StackHashSearchOptionType.Equal, 1, 0), // 1 is true. }) }; if (!errorIndex.ParseEvents(product, file, parser)) { throw new OperationCanceledException("Aborted while purging events"); } } } } finally { parser.ParseEvent -= new EventHandler <ErrorIndexParseEventsEventArgs>(this.processEvent); } } catch (Exception ex) { DiagnosticsHelper.LogException(DiagSeverity.Information, "Purge task failed", ex); LastException = ex; } finally { StackHashUtilities.SystemInformation.EnableSleep(); SetTaskCompleted(m_TaskParameters.ErrorIndex); } }
public bool ParseEvents(StackHashProduct product, StackHashFile file, ErrorIndexEventParser parser) { return(true); }