// Add the same file twice with different data - should replace. // A file is the same if its ID, filename and version are the same. public void testAddSameFileTwice(IErrorIndex index) { index.Activate(); StackHashProduct product = new StackHashProduct(DateTime.Now, DateTime.Now, "http://www.cucku.com", 1, "TestProduct1", 20, 30, "2.10.02123.1293"); StackHashFile file = new StackHashFile(new DateTime(100), new DateTime(101), 1, new DateTime(102), "filename.dll", "1.2.3.4"); index.AddProduct(product); index.AddFile(product, file); // Use same ID - should replace existing file data. file = new StackHashFile(new DateTime(200), new DateTime(201), 1, new DateTime(101), "filename.dll", "1.2.3.4"); index.AddFile(product, file); StackHashFileCollection files = index.LoadFileList(product); Assert.AreEqual(1, files.Count); Assert.AreEqual(file.DateCreatedLocal, files[0].DateCreatedLocal); Assert.AreEqual(file.DateModifiedLocal, files[0].DateModifiedLocal); Assert.AreEqual(file.Id, files[0].Id); Assert.AreEqual(file.LinkDateLocal, files[0].LinkDateLocal); Assert.AreEqual(file.Name, files[0].Name); Assert.AreEqual(file.Version, files[0].Version); }
private void testAdd1FileOk(IErrorIndex index) { index.Activate(); StackHashProduct product = new StackHashProduct(DateTime.Now, DateTime.Now, "http://www.cucku.com", 1, "TestProduct1", 20, 30, "2.10.02123.1293"); StackHashFile file = new StackHashFile(new DateTime(100), new DateTime(101), 1, new DateTime(102), "filename.dll", "1.2.3.4"); index.AddProduct(product); index.AddFile(product, file); StackHashFileCollection files = index.LoadFileList(product); Assert.AreEqual(1, files.Count); Assert.AreEqual(file.DateCreatedLocal, files[0].DateCreatedLocal); Assert.AreEqual(file.DateModifiedLocal, files[0].DateModifiedLocal); Assert.AreEqual(file.Id, files[0].Id); Assert.AreEqual(file.LinkDateLocal, files[0].LinkDateLocal); Assert.AreEqual(file.Name, files[0].Name); Assert.AreEqual(file.Version, files[0].Version); // Also test the GetFile interface. StackHashFile gotFile = index.GetFile(product, file.Id); Assert.AreNotEqual(null, gotFile); Assert.AreEqual(file.DateCreatedLocal, gotFile.DateCreatedLocal); Assert.AreEqual(file.DateModifiedLocal, gotFile.DateModifiedLocal); Assert.AreEqual(file.Id, gotFile.Id); Assert.AreEqual(file.LinkDateLocal, gotFile.LinkDateLocal); Assert.AreEqual(file.Name, gotFile.Name); Assert.AreEqual(file.Version, gotFile.Version); }
public void filesCount(int numFiles) { m_Index = new SqlErrorIndex(StackHashSqlConfiguration.Default, SqlUtils.UnitTestDatabase, m_RootCabFolder); m_Index.DeleteIndex(); m_Index.Activate(); DateTime creationDateTime = new DateTime(2010, 04, 04, 22, 9, 0, DateTimeKind.Utc); DateTime modifiedDateTime = new DateTime(2010, 05, 05, 23, 10, 0, DateTimeKind.Utc); StackHashProduct product1 = new StackHashProduct(creationDateTime, modifiedDateTime, null, 1, "TestProduct1", 20, 30, "2.10.02123.1293"); m_Index.AddProduct(product1); for (int i = 0; i < numFiles; i++) { StackHashFile file1 = new StackHashFile(creationDateTime, modifiedDateTime, 20 + i, creationDateTime, "File1.dll", "2.3.4.5"); m_Index.AddFile(product1, file1); } long filesCount = m_Index.TotalFiles; Assert.AreEqual(numFiles, filesCount); }
/// <summary> /// Unpack the cab file if not already unpacked. /// </summary> /// <param name="product">Product to which the cab belongs.</param> /// <param name="file">File to which the cab belongs.</param> /// <param name="theEvent">Event to which the cab belongs.</param> /// <param name="cab">The cab object to unpack.</param> /// <param name="forceUnpack">True - force an unpack even if the cab has already been unpacked.</param> /// <returns></returns> private void unpackCab(StackHashProduct product, StackHashFile file, StackHashEvent theEvent, StackHashCab cab, bool forceUnpack) { String cabFileName = m_TaskParameters.ErrorIndex.GetCabFileName(product, file, theEvent, cab); String cabFileFolder = Path.GetDirectoryName(cabFileName); if (!Cabs.IsUncabbed(cabFileName, cabFileFolder) || forceUnpack) { try { Cabs.ExtractCab(cabFileName, cabFileFolder); } catch (System.Exception ex) { if (ex.Message.Contains("The file is not a cabinet") || ex.Message.Contains("corrupt") || ex.Message.Contains("Corrupt")) { // Set the downloaded flag appropriately if different. StackHashCab loadedCab = m_TaskParameters.ErrorIndex.GetCab(product, file, theEvent, cab.Id); if (loadedCab != null) { if (loadedCab.CabDownloaded) { loadedCab.CabDownloaded = false; m_TaskParameters.ErrorIndex.AddCab(product, file, theEvent, loadedCab, false); } } } throw new StackHashException("Cab file cannot be unpackaged. Try downloading the file from again.", ex, StackHashServiceErrorCode.CabIsCorrupt); } } }
private StackHashEvent setPlugInBugReference(StackHashProduct product, StackHashFile file, StackHashEvent theEvent, String newBugId) { if (newBugId != null) { if (theEvent.PlugInBugId != null) { if (String.Compare(newBugId, theEvent.PlugInBugId, StringComparison.OrdinalIgnoreCase) != 0) { theEvent.PlugInBugId = newBugId; // Update the event - but don't report the change to bug tracking S/W. m_Index.AddEvent(product, file, theEvent, true, false); // BugId is a non-winqual field. } else { theEvent.PlugInBugId = newBugId; } } else { // No bug Id yet. theEvent.PlugInBugId = newBugId; // Update the event - but don't report the change to bug tracking S/W. m_Index.AddEvent(product, file, theEvent, true, false); // BugId is a non-winqual field. } } return(theEvent); }
/// <summary> /// Process a file table update. This may indicate a new item or the change to an existing item. /// </summary> private bool processFileUpdate(StackHashBugTrackerUpdate update) { // Get the associated product and file information. StackHashProduct product = m_Index.GetProduct((int)update.ProductId); StackHashFile file = m_Index.GetFile(product, (int)update.FileId); if (product == null) { DiagnosticsHelper.LogMessage(DiagSeverity.Warning, "Processing File: Inconsistent Update Table Entry = product not found: " + update.ProductId.ToString(CultureInfo.InvariantCulture)); return(false); } if (file == null) { DiagnosticsHelper.LogMessage(DiagSeverity.Warning, "Processing File: Inconsistent Update Table Entry = file not found: " + update.FileId.ToString(CultureInfo.InvariantCulture)); return(false); } BugTrackerProduct btProduct = new BugTrackerProduct(product.Name, product.Version, product.Id); BugTrackerFile btFile = new BugTrackerFile(file.Name, file.Version, file.Id); if (update.TypeOfChange == StackHashChangeType.NewEntry) { m_TaskParameters.PlugInContext.FileAdded(null, BugTrackerReportType.Automatic, btProduct, btFile); } else { m_TaskParameters.PlugInContext.FileUpdated(null, BugTrackerReportType.Automatic, btProduct, btFile); } return(true); }
public void Conflict2EventsAndEventSameAsSecondDifferentProductAndFile() { StackHashProduct product1 = new StackHashProduct(DateTime.Now, DateTime.Now, null, 1, "StackHash", 0, 0, "1.2.3.4"); StackHashFile file1 = new StackHashFile(DateTime.Now, DateTime.Now, 1, DateTime.Now, "File1", "1.2.3.4"); StackHashEvent event1 = new StackHashEvent(1, "EventTypeName1"); StackHashEvent event2 = new StackHashEvent(2, "EventTypeName1"); StackHashBugReportData data1 = new StackHashBugReportData(product1, file1, event1, null, null, StackHashReportOptions.IncludeAllObjects); StackHashBugReportData data2 = new StackHashBugReportData(product1, file1, event2, null, null, StackHashReportOptions.IncludeAllObjects); StackHashBugReportDataCollection allData1 = new StackHashBugReportDataCollection() { data1, data2, }; StackHashProduct product2 = new StackHashProduct(DateTime.Now, DateTime.Now, null, 1, "StackHash", 0, 0, "1.2.3.4"); StackHashFile file2 = new StackHashFile(DateTime.Now, DateTime.Now, 1, DateTime.Now, "File1", "1.2.3.4"); StackHashBugReportData data3 = new StackHashBugReportData(product2, file2, event2, null, null, StackHashReportOptions.IncludeAllObjects); StackHashBugReportDataCollection allData2 = new StackHashBugReportDataCollection() { data3 }; Assert.AreEqual(true, allData1.IsConflicting(allData2)); }
public void UpdateFile() { m_Index = new SqlErrorIndex(StackHashSqlConfiguration.Default, SqlUtils.UnitTestDatabase, m_RootCabFolder); m_Index.DeleteIndex(); m_Index.Activate(); DateTime creationDateTime = new DateTime(2010, 04, 04, 22, 9, 0, DateTimeKind.Utc); DateTime modifiedDateTime = new DateTime(2010, 05, 05, 23, 10, 0, DateTimeKind.Utc); StackHashProduct product1 = new StackHashProduct(creationDateTime, modifiedDateTime, null, 1, "TestProduct1", 20, 30, "2.10.02123.1293"); StackHashFile file1 = new StackHashFile(creationDateTime, modifiedDateTime, 20, creationDateTime, "File1.dll", "2.3.4.5"); m_Index.AddProduct(product1); m_Index.AddFile(product1, file1); StackHashFile dbFile1 = m_Index.GetFile(product1, file1.Id); Assert.AreEqual(0, file1.CompareTo(dbFile1)); StackHashFile file2 = new StackHashFile(creationDateTime.AddDays(1), modifiedDateTime.AddDays(2), 20, creationDateTime.AddDays(3), "File2.dll", "1.3.4.5"); m_Index.AddFile(product1, file2); StackHashFile dbFile2 = m_Index.GetFile(product1, file2.Id); Assert.AreEqual(0, file2.CompareTo(dbFile2)); Assert.AreNotEqual(0, file1.CompareTo(dbFile2)); }
public void GetFilesForProduct2FilesOnly1ForSelectedProduct() { m_Index = new SqlErrorIndex(StackHashSqlConfiguration.Default, SqlUtils.UnitTestDatabase, m_RootCabFolder); m_Index.DeleteIndex(); m_Index.Activate(); DateTime creationDateTime = new DateTime(2010, 04, 04, 22, 9, 0, DateTimeKind.Utc); DateTime modifiedDateTime = new DateTime(2010, 05, 05, 23, 10, 0, DateTimeKind.Utc); StackHashProduct product1 = new StackHashProduct(creationDateTime, modifiedDateTime, null, 1, "TestProduct1", 20, 30, "2.10.02123.1293"); StackHashProduct product2 = new StackHashProduct(creationDateTime, modifiedDateTime, null, 2, "TestProduct1", 21, 31, "2.10.02123.1293"); StackHashFile file1 = new StackHashFile(creationDateTime, modifiedDateTime, 20, creationDateTime, "File1.dll", "2.3.4.5"); StackHashFile file2 = new StackHashFile(creationDateTime, modifiedDateTime, 21, creationDateTime, "File2.dll", "2.3.4.5"); m_Index.AddProduct(product1); m_Index.AddProduct(product2); m_Index.AddFile(product1, file1); m_Index.AddFile(product2, file2); StackHashFileCollection files = m_Index.LoadFileList(product1); Assert.AreNotEqual(null, files); Assert.AreEqual(1, files.Count); Assert.AreEqual(0, file1.CompareTo(files[0])); files = m_Index.LoadFileList(product2); Assert.AreNotEqual(null, files); Assert.AreEqual(1, files.Count); Assert.AreEqual(0, file2.CompareTo(files[0])); }
private void testAddEventInfoNullEventInfo(IErrorIndex index) { try { index.Activate(); StackHashProduct product = new StackHashProduct(DateTime.Now, DateTime.Now, "http://www.cucku.com", 1, "TestProduct1", 20, 30, "2.10.02123.1293"); StackHashFile file = new StackHashFile(new DateTime(100), new DateTime(101), 39, new DateTime(102), "filename.dll", "1.2.3.4"); StackHashParameterCollection parameters = new StackHashParameterCollection(); parameters.Add(new StackHashParameter("param1", "param1value")); parameters.Add(new StackHashParameter("param2", "param2value")); StackHashEventSignature signature = new StackHashEventSignature(parameters); StackHashEvent theEvent = new StackHashEvent(new DateTime(102), new DateTime(103), "EventType1", 20000, signature, 99, 2); index.AddProduct(product); index.AddFile(product, file); index.AddEvent(product, file, theEvent); index.AddEventInfoCollection(product, file, theEvent, null); } catch (ArgumentNullException ex) { Assert.AreEqual("eventInfoCollection", ex.ParamName); throw; } }
public void FileExistsForDifferentProduct() { m_Index = new SqlErrorIndex(StackHashSqlConfiguration.Default, SqlUtils.UnitTestDatabase, m_RootCabFolder); m_Index.DeleteIndex(); m_Index.Activate(); DateTime creationDateTime = new DateTime(2010, 04, 04, 22, 9, 0, DateTimeKind.Utc); DateTime modifiedDateTime = new DateTime(2010, 05, 05, 23, 10, 0, DateTimeKind.Utc); StackHashProduct product1 = new StackHashProduct(creationDateTime, modifiedDateTime, null, 1, "TestProduct1", 20, 30, "2.10.02123.1293"); StackHashProduct product2 = new StackHashProduct(creationDateTime, modifiedDateTime, null, 2, "TestProduct1", 21, 31, "2.10.02123.1293"); StackHashFile file1 = new StackHashFile(creationDateTime, modifiedDateTime, 20, creationDateTime, "File1.dll", "2.3.4.5"); m_Index.AddProduct(product1); m_Index.AddProduct(product2); m_Index.AddFile(product1, file1); StackHashFile dbFile1 = m_Index.GetFile(product1, file1.Id); Assert.AreEqual(0, file1.CompareTo(dbFile1)); Assert.AreEqual(true, m_Index.FileExists(product1, file1)); Assert.AreEqual(false, m_Index.FileExists(product2, file1)); }
private void testAddEventInfoUnknownFile(IErrorIndex index) { try { index.Activate(); StackHashProduct product = new StackHashProduct(DateTime.Now, DateTime.Now, "http://www.cucku.com", 1, "TestProduct1", 20, 30, "2.10.02123.1293"); StackHashFile file = new StackHashFile(new DateTime(100), new DateTime(101), 1, new DateTime(102), "filename.dll", "1.2.3.4"); index.AddProduct(product); index.AddFile(product, file); // Change the file id so it isn't recognised. file.Id++; StackHashEvent theEvent = new StackHashEvent(); StackHashEventInfoCollection eventInfoCollection = new StackHashEventInfoCollection(); index.AddEventInfoCollection(product, file, theEvent, eventInfoCollection); } catch (ArgumentException ex) { Assert.AreEqual("file", ex.ParamName); throw; } }
/// <summary> /// Processes a specific product. /// </summary> private void processProduct(StackHashBugReportData request, StackHashProduct product) { if (this.CurrentTaskState.AbortRequested) { throw new OperationCanceledException("Reporting events to Bug Tracker plug-ins"); } BugTrackerProduct btProduct = new BugTrackerProduct(product.Name, product.Version, product.Id); if (((request.Options & StackHashReportOptions.IncludeProducts) != 0) || ((request.Options & StackHashReportOptions.IncludeAllObjects) != 0)) { m_TaskParameters.PlugInContext.ProductAdded(m_PlugIns, m_ReportType, btProduct); checkPlugInStatus(m_PlugIns); } if (request.File == null) { StackHashFileCollection allFiles = m_Index.LoadFileList(product); foreach (StackHashFile file in allFiles) { processFile(request, product, file); } } else { StackHashFile file = m_Index.GetFile(product, request.File.Id); if (file != null) { processFile(request, product, file); } } }
/// <summary> /// Downloads a specific cab and stores in the specified index. /// </summary> /// <param name="errorIndex">Error index to store the cab.</param> /// <param name="product">Product to which the cab belongs.</param> /// <param name="file">File to which the cab belongs</param> /// <param name="theEvent">Event to which the cab belongs.</param> /// <param name="cab">The cab to download.</param> /// <returns>Cab file name.</returns> public String GetCab(IErrorIndex errorIndex, StackHashProduct product, StackHashFile file, StackHashEvent theEvent, StackHashCab cab) { if (errorIndex == null) { throw new ArgumentNullException("errorIndex"); } if (cab == null) { throw new ArgumentNullException("cab"); } cab.CabDownloaded = true; errorIndex.AddCab(product, file, theEvent, cab, false); String cabFile = errorIndex.GetCabFileName(product, file, theEvent, cab); String cabFolder = errorIndex.GetCabFolder(product, file, theEvent, cab); if (!Directory.Exists(cabFolder)) { Directory.CreateDirectory(cabFolder); } FileStream fileStream = File.Create(cabFile); fileStream.Close(); return(cabFile); }
public void updateProductStatsNoEvents(IErrorIndex index, int numProducts, int numFiles, int numEvents) { DateTime creationDateTime = new DateTime(2010, 04, 04, 22, 9, 0, DateTimeKind.Utc); DateTime modifiedDateTime = new DateTime(2010, 05, 05, 23, 10, 0, DateTimeKind.Utc); StackHashProduct product = new StackHashProduct(creationDateTime, modifiedDateTime, "www.files.com", 25, @"P""r:o?d:u@(XP_2k)", 0, 0, "1:2:3:4"); if (numProducts != 0) { index.AddProduct(product); } int eventId = 2000; for (int i = 0; i < numFiles; i++) { StackHashFile file = new StackHashFile(DateTime.Now, DateTime.Now, i + 1000, DateTime.Now, "FileName", "1.2.3.4"); index.AddFile(product, file); for (int j = 0; j < numEvents; j++) { StackHashEvent theEvent = new StackHashEvent(DateTime.Now, DateTime.Now, "Event type", eventId++, new StackHashEventSignature(), j, i + 1000); theEvent.EventSignature.Parameters = new StackHashParameterCollection(); index.AddEvent(product, file, theEvent); } } product = index.UpdateProductStatistics(product); Assert.AreEqual(numFiles * numEvents, product.TotalStoredEvents); }
// A single File object which hasn't been initialised. Should reject. private void testAdd1FileDefaultData(IErrorIndex index) { index.Activate(); StackHashProduct product = new StackHashProduct(DateTime.Now, DateTime.Now, "http://www.cucku.com", 1, "TestProduct1", 20, 30, "2.10.02123.1293"); // Default file data - should fail. StackHashFile file = new StackHashFile(); index.AddProduct(product); try { index.AddFile(product, file); } catch (ArgumentException ex) { Assert.AreEqual("file", ex.ParamName); throw; } // Should be no files. StackHashFileCollection files = index.LoadFileList(product); Assert.AreEqual(0, files.Count); // Check that the dates are stored in UTC. Assert.AreEqual(true, files[0].DateCreatedLocal.Kind == DateTimeKind.Utc); Assert.AreEqual(true, files[0].DateModifiedLocal.Kind == DateTimeKind.Utc); }
public void XmlIndexGetGetFileFolderInvalidCharsInVersion() { StackHashFile file = new StackHashFile(DateTime.Now, DateTime.Now, 123456, DateTime.Now, @"F""i:l?e:n\a/me@(XP/2k)", "1:2/3/4"); String filePath = XmlErrorIndex.GetFileFolder(file); Assert.AreEqual("F_123456_F_i_l_e_n_a_me@(XP_2k)_1_2_3_4", filePath); }
public void XmlIndexGetGetFileFolderValidChars() { StackHashFile file = new StackHashFile(DateTime.Now, DateTime.Now, 123456, DateTime.Now, "FileName", "1.2.3.4"); String filePath = XmlErrorIndex.GetFileFolder(file); Assert.AreEqual("F_123456_FileName_1.2.3.4", filePath); }
private void checkIndexData(IErrorIndex index) { int numProducts = 100; int cabId = 12345678; int fileId = 2000; int eventId = 1000; for (int productCount = 0; productCount < numProducts; productCount++) { StackHashProduct retrievedProduct = index.GetProduct(productCount + 10); DateTime creationDateTime = new DateTime(2010, 04, 04, 22, 9, 0, DateTimeKind.Utc); DateTime modifiedDateTime = new DateTime(2010, 05, 05, 23, 10, 0, DateTimeKind.Utc); StackHashProduct product1 = new StackHashProduct(creationDateTime, modifiedDateTime, null, (productCount + 10), "TestProduct1", 20, 30, "2.10.02123.1293"); Assert.AreEqual(0, product1.CompareTo(retrievedProduct)); StackHashFile file1 = new StackHashFile(creationDateTime, modifiedDateTime, fileId++, creationDateTime, "FileName", "1.2.3.4"); StackHashFile retrievedFile = index.GetFile(product1, file1.Id); Assert.AreEqual(0, file1.CompareTo(retrievedFile)); StackHashEventSignature eventSignature = new StackHashEventSignature(); eventSignature.Parameters = new StackHashParameterCollection(); eventSignature.Parameters.Add(new StackHashParameter(StackHashEventSignature.ParamApplicationName, "AppName")); eventSignature.Parameters.Add(new StackHashParameter(StackHashEventSignature.ParamApplicationVersion, "1.2.3.4")); eventSignature.Parameters.Add(new StackHashParameter(StackHashEventSignature.ParamApplicationTimeStamp, creationDateTime.ToString())); eventSignature.Parameters.Add(new StackHashParameter(StackHashEventSignature.ParamModuleName, "ModuleName")); eventSignature.Parameters.Add(new StackHashParameter(StackHashEventSignature.ParamModuleVersion, "2.3.4.5")); eventSignature.Parameters.Add(new StackHashParameter(StackHashEventSignature.ParamModuleTimeStamp, creationDateTime.ToString())); eventSignature.Parameters.Add(new StackHashParameter(StackHashEventSignature.ParamExceptionCode, "1234")); eventSignature.Parameters.Add(new StackHashParameter(StackHashEventSignature.ParamOffset, "0x1234")); eventSignature.InterpretParameters(); StackHashEvent thisEvent = new StackHashEvent(creationDateTime, modifiedDateTime, "CLR20", eventId++, eventSignature, 1, file1.Id); StackHashEvent retrievedEvent = index.GetEvent(product1, file1, thisEvent); Assert.AreEqual(0, thisEvent.CompareTo(retrievedEvent)); StackHashCab cab = new StackHashCab(creationDateTime, modifiedDateTime, thisEvent.Id, thisEvent.EventTypeName, "cab12345_23232.cab", cabId++, 12000); cab.DumpAnalysis = new StackHashDumpAnalysis("2 days, 5 hours, 2 mins", "1 hour, 2 mins", "2.120.222.1121212", "Microsoft Windows Vista X64 6.0.212121212 (Build 2500)", "64 bit windows"); cab.CabDownloaded = true; StackHashCab retrievedCab = index.GetCab(product1, file1, thisEvent, cab.Id); Assert.AreEqual(0, cab.CompareTo(retrievedCab)); String cabFolder = index.GetCabFolder(product1, file1, thisEvent, cab); String cabFileName = index.GetCabFileName(product1, file1, thisEvent, cab); Assert.AreEqual(true, Directory.Exists(cabFolder)); Assert.AreEqual(true, File.Exists(cabFileName)); } }
private void copyCabFiles(IErrorIndex sourceIndex, IErrorIndex destinationIndex, StackHashProduct product, StackHashFile file, StackHashEventPackage eventPackage, StackHashCab cab) { // Copy the actual Cab file and any results files. String sourceCabFolder = sourceIndex.GetCabFolder(product, file, eventPackage.EventData, cab); String destCabFolder = destinationIndex.GetCabFolder(product, file, eventPackage.EventData, cab); if (Directory.Exists(sourceCabFolder)) { String sourceCabFileName = sourceIndex.GetCabFileName(product, file, eventPackage.EventData, cab); if (File.Exists(sourceCabFileName)) { if (!Directory.Exists(destCabFolder)) { Directory.CreateDirectory(destCabFolder); } String destinationCabFileName = String.Format(CultureInfo.InvariantCulture, "{0}\\{1}", destCabFolder, Path.GetFileName(sourceCabFileName)); if (!File.Exists(destinationCabFileName)) { File.Copy(sourceCabFileName, destinationCabFileName); } } // Copy the analysis data if it exists. String sourceAnalysisFolder = String.Format(CultureInfo.InvariantCulture, "{0}\\Analysis", sourceCabFolder); String destAnalysisFolder = String.Format(CultureInfo.InvariantCulture, "{0}\\Analysis", destCabFolder); if (Directory.Exists(sourceAnalysisFolder)) { String[] allFiles = Directory.GetFiles(sourceAnalysisFolder, "*.log"); if (allFiles.Length != 0) { if (!Directory.Exists(destAnalysisFolder)) { Directory.CreateDirectory(destAnalysisFolder); } foreach (String fileName in allFiles) { String destAnalysisFile = String.Format(CultureInfo.InvariantCulture, "{0}\\{1}", destAnalysisFolder, Path.GetFileName(fileName)); if (!File.Exists(destAnalysisFile)) { File.Copy(fileName, destAnalysisFile); } } } } } }
private void addDataToIndex(IErrorIndex index) { int numProducts = 100; int cabId = 12345678; int fileId = 2000; int eventId = 1000; for (int productCount = 0; productCount < numProducts; productCount++) { DateTime creationDateTime = new DateTime(2010, 04, 04, 22, 9, 0, DateTimeKind.Utc); DateTime modifiedDateTime = new DateTime(2010, 05, 05, 23, 10, 0, DateTimeKind.Utc); StackHashProduct product1 = new StackHashProduct(creationDateTime, modifiedDateTime, null, (productCount + 10), "TestProduct1", 20, 30, "2.10.02123.1293"); index.AddProduct(product1); StackHashFile file1 = new StackHashFile(creationDateTime, modifiedDateTime, fileId++, creationDateTime, "FileName", "1.2.3.4"); index.AddFile(product1, file1); StackHashEventSignature eventSignature = new StackHashEventSignature(); eventSignature.Parameters = new StackHashParameterCollection(); eventSignature.Parameters.Add(new StackHashParameter(StackHashEventSignature.ParamApplicationName, "AppName")); eventSignature.Parameters.Add(new StackHashParameter(StackHashEventSignature.ParamApplicationVersion, "1.2.3.4")); eventSignature.Parameters.Add(new StackHashParameter(StackHashEventSignature.ParamApplicationTimeStamp, creationDateTime.ToString())); eventSignature.Parameters.Add(new StackHashParameter(StackHashEventSignature.ParamModuleName, "ModuleName")); eventSignature.Parameters.Add(new StackHashParameter(StackHashEventSignature.ParamModuleVersion, "2.3.4.5")); eventSignature.Parameters.Add(new StackHashParameter(StackHashEventSignature.ParamModuleTimeStamp, creationDateTime.ToString())); eventSignature.Parameters.Add(new StackHashParameter(StackHashEventSignature.ParamExceptionCode, "1234")); eventSignature.Parameters.Add(new StackHashParameter(StackHashEventSignature.ParamOffset, "0x1234")); eventSignature.InterpretParameters(); StackHashEvent thisEvent = new StackHashEvent(creationDateTime, modifiedDateTime, "CLR20", eventId++, eventSignature, 1, file1.Id); index.AddEvent(product1, file1, thisEvent); StackHashCab cab = new StackHashCab(creationDateTime, modifiedDateTime, thisEvent.Id, thisEvent.EventTypeName, "cab12345_23232.cab", cabId++, 12000); cab.DumpAnalysis = new StackHashDumpAnalysis("2 days, 5 hours, 2 mins", "1 hour, 2 mins", "2.120.222.1121212", "Microsoft Windows Vista X64 6.0.212121212 (Build 2500)", "64 bit windows"); cab.CabDownloaded = true; index.AddCab(product1, file1, thisEvent, cab, true); String cabFolder = index.GetCabFolder(product1, file1, thisEvent, cab); String cabFileName = index.GetCabFileName(product1, file1, thisEvent, cab); if (!Directory.Exists(cabFolder)) { Directory.CreateDirectory(cabFolder); } File.Copy(TestSettings.TestDataFolder + @"Cabs\1641909485-Crash32bit-0773522646.cab", cabFileName); FileAttributes originalAttributes = File.GetAttributes(cabFileName); File.SetAttributes(cabFileName, originalAttributes & ~FileAttributes.ReadOnly); } }
/// <summary> /// Constructor. /// </summary> /// <param name="progressType">Progress type - e.g. downloading cabs.</param> /// <param name="product">The owning product.</param> /// <param name="file">The owning file.</param> /// <param name="theEvent">The owning event.</param> /// <param name="cab">The cab being downloaded.</param> /// <param name="currentPage">The current page being downloaded.</param> /// <param name="totalPages">Total pages to download.</param> public WinQualProgressEventArgs(WinQualProgressType progressType, StackHashProductInfo product, StackHashFile file, StackHashEvent theEvent, StackHashCab cab, int currentPage, int totalPages) { m_ProgressType = progressType; m_Product = product; m_File = file; m_Event = theEvent; m_Cab = cab; m_TotalPages = totalPages; m_CurrentPage = currentPage; }
public bool CabMatchesSearchCriteria(StackHashProduct product, StackHashFile file, StackHashEvent theEvent, StackHashCab cab, StackHashSearchCriteria searchCriteria) { if (product == null) { throw new ArgumentNullException("product"); } if (file == null) { throw new ArgumentNullException("file"); } if (theEvent == null) { throw new ArgumentNullException("theEvent"); } if (cab == null) { throw new ArgumentNullException("cab"); } if (searchCriteria == null) { throw new ArgumentNullException("searchCriteria"); } // Get a list of script result files for this cab. StackHashScriptResultFiles resultFiles = GetResultFiles(product, file, theEvent, cab); if ((resultFiles == null) || (resultFiles.Count == 0)) { return(false); } foreach (StackHashScriptResultFile resultFile in resultFiles) { try { StackHashScriptResult resultFileData = GetResultFileData(product, file, theEvent, cab, resultFile.ScriptName); if (resultFileData.Search(searchCriteria)) { return(true); } } catch (System.Exception ex) { // Don't allow corrupt files to stop the search. DiagnosticsHelper.LogException(DiagSeverity.Warning, "Corrupt or missing results file: " + resultFile.ScriptName + " for cab " + cab.Id.ToString(CultureInfo.InvariantCulture), ex); } } return(false); }
public static StackHashFileCollection GetFilesApi(ref Login login, Product product) { ApplicationFileCollection apiFiles = product.GetApplicationFiles(ref login); StackHashFileCollection apiStackHashFiles = new StackHashFileCollection(); foreach (ApplicationFile file in apiFiles) { StackHashFile stackHashFile = ObjectConversion.ConvertFile(file); apiStackHashFiles.Add(stackHashFile); } return(apiStackHashFiles); }
/// <summary> /// Determines if the specified file should be searched for cabs to process. /// </summary> /// <param name="product">The product to check.</param> /// <param name="file">The file to check.</param> /// <returns>True - process the file, false - don't process.</returns> private bool shouldProcessFile(StackHashProduct product, StackHashFile file) { if (product == null) { return(false); } if (file == null) { return(false); } return(true); }
/// <summary> /// Process a cab note table update. This may indicate a new item or the change to an existing item. /// </summary> private bool processCabNoteUpdate(StackHashBugTrackerUpdate update) { // Get the associated product and file information. StackHashProduct product = m_Index.GetProduct((int)update.ProductId); StackHashFile file = m_Index.GetFile(product, (int)update.FileId); StackHashEvent theEvent = m_Index.GetEvent(product, file, new StackHashEvent((int)update.EventId, update.EventTypeName)); StackHashCab cab = m_Index.GetCab(product, file, theEvent, (int)update.CabId); StackHashNoteEntry note = m_Index.GetCabNote((int)update.ChangedObjectId); if ((product == null) || (file == null) || (theEvent == null) || (cab == null) || (note == null)) { DiagnosticsHelper.LogMessage(DiagSeverity.Warning, "Processing Cab Note: Inconsistent Update Table Entry"); return(false); } BugTrackerProduct btProduct = new BugTrackerProduct(product.Name, product.Version, product.Id); BugTrackerFile btFile = new BugTrackerFile(file.Name, file.Version, file.Id); NameValueCollection eventSignature = new NameValueCollection(); foreach (StackHashParameter param in theEvent.EventSignature.Parameters) { eventSignature.Add(param.Name, param.Value); } BugTrackerEvent btEvent = new BugTrackerEvent(theEvent.BugId, theEvent.PlugInBugId, theEvent.Id, theEvent.EventTypeName, theEvent.TotalHits, eventSignature); NameValueCollection analysis = new NameValueCollection(); analysis.Add("DotNetVersion", cab.DumpAnalysis.DotNetVersion); analysis.Add("MachineArchitecture", cab.DumpAnalysis.MachineArchitecture); analysis.Add("OSVersion", cab.DumpAnalysis.OSVersion); analysis.Add("ProcessUpTime", cab.DumpAnalysis.ProcessUpTime); analysis.Add("SystemUpTime", cab.DumpAnalysis.SystemUpTime); String cabFileName = m_Index.GetCabFileName(product, file, theEvent, cab); BugTrackerCab btCab = new BugTrackerCab(cab.Id, cab.SizeInBytes, cab.CabDownloaded, cab.Purged, analysis, cabFileName); BugTrackerNote btCabNote = new BugTrackerNote(note.TimeOfEntry, note.Source, note.User, note.Note); String newBugId = null; if (update.TypeOfChange == StackHashChangeType.NewEntry) { newBugId = m_TaskParameters.PlugInContext.CabNoteAdded(null, BugTrackerReportType.Automatic, btProduct, btFile, btEvent, btCab, btCabNote); } setPlugInBugReference(product, file, theEvent, newBugId); return(true); }
// // You can use the following additional attributes as you write your tests: // // Use ClassInitialize to run code before running the first test in the class // [ClassInitialize()] // public static void MyClassInitialize(TestContext testContext) { } // // Use ClassCleanup to run code after all tests in a class have run // [ClassCleanup()] // public static void MyClassCleanup() { } // // Use TestInitialize to run code before running each test // [TestInitialize()] // public void MyTestInitialize() { } // // Use TestCleanup to run code after each test has run // [TestCleanup()] // public void MyTestCleanup() { } // #endregion private void testAddFileNullPruduct(IErrorIndex index) { try { index.Activate(); StackHashFile file = new StackHashFile(); index.AddFile(null, file); } catch (ArgumentNullException ex) { Assert.AreEqual("product", ex.ParamName); throw; } }
public void testAddFileProductDoesntExist(IErrorIndex index) { try { index.Activate(); StackHashProduct product = new StackHashProduct(DateTime.Now, DateTime.Now, "www", 25, "Product", 1, 2, "1.2.3.4"); StackHashFile file = new StackHashFile(); index.AddFile(product, file); } catch (ArgumentException ex) { Assert.AreEqual("product", ex.ParamName); throw; } }
/// <summary> /// Converts a WinQual ApplicationFile into a StackHashFile. /// </summary> /// <param name="file">WinQual application file to convert.</param> /// <returns>Converted file.</returns> public static StackHashFile ConvertFile(ApplicationFile file) { if (file == null) { throw new ArgumentNullException("file"); } StackHashFile newFile = new StackHashFile( file.DateCreatedLocal.ToUniversalTime(), file.DateModifiedLocal.ToUniversalTime(), file.ID, file.LinkDateLocal.ToUniversalTime(), file.Name, file.Version); return(newFile); }
/// <summary> /// Determines if the specified event should be searched for cabs to process. /// </summary> /// <param name="product">The product to check.</param> /// <param name="file">The file to check.</param> /// <param name="theEvent">The event to check.</param> /// <returns>True - process the event, false - don't process.</returns> private bool shouldProcessEvent(StackHashProduct product, StackHashFile file, StackHashEvent theEvent) { if (product == null) { return(false); } if (file == null) { return(false); } if (theEvent == null) { return(false); } return(true); }