public async Task <GetFilesResponse> GetFiles(string folderId, int offSet) { GetFilesRequest request = _requestFactorty.CreateGetFilesRequest(_host, _token, folderId, offSet); GetFilesResponse result = await HttpProcessor.GetFiles(request); return(result); }
public GetFilesResponse GetFiles(string sessionId, string shipmentCode, string imageType) { if (!AllowOperates.Contains(imageType)) { return(new GetFilesResponse() { Code = ImageErrorCode.InvalidOperation, Message = "非法操作" }); } try { var alctResponse = imageAgent.GetImages(GetToken(sessionId).AccessToken, shipmentCode, imageType); var response = new GetFilesResponse(); response.Files = alctResponse.Select(x => new CommonFileModel() { FileName = x.FileName, FileUrl = x.FileData }).ToList(); return(response); } catch (Exception ex) { logger.LogError(ex, "Get file failed"); return(new GetFilesResponse() { Code = ImageErrorCode.GetImageFailed, Message = "获取图片失败,请重试" }); } }
private static void DownFile(string host, string clientId, string clientSecret, List<string> folderIds, string savePath) { MarketoClient client = new MarketoClient(host, clientId, clientSecret); foreach (string folderId in folderIds) { Console.WriteLine(folderId); GetFilesResponse fileResult = client.GetFiles(folderId, 0).Result; string saveRootPath = Path.Combine(savePath, folderId); if (fileResult?.Result != null) { if (!Directory.Exists(saveRootPath)) { Directory.CreateDirectory(saveRootPath); } WriteFileToDisk(fileResult, saveRootPath); if (fileResult.Result.Count >= 200) { MarketoClient client200 = new MarketoClient(host, clientId, clientSecret); GetFilesResponse fileResult200 = client200.GetFiles(folderId, 200).Result; if (fileResult200?.Result != null) { WriteFileToDisk(fileResult200, saveRootPath); } } } Console.WriteLine("Done!"); } Console.ReadKey(); }
private async Task <List <MarketoFile> > GetFileResults(MarketoClient client, string id) { List <MarketoFile> fileResults = new List <MarketoFile>(); GetFilesResponse fileResult = await client.GetFiles(id, 0); if (fileResult?.Result != null) { fileResults.AddRange(fileResult.Result); int fileCounts = fileResult.Result.Count; int callTimes = 0; while (fileCounts >= 200) { callTimes += 1; //var clientNext = new MarketoClient(host, clientId, clientSecret); GetFilesResponse fileResultNext = await client.GetFiles(id, callTimes * 200); if (fileResultNext?.Result != null) { fileResults.AddRange(fileResultNext.Result); fileCounts = fileResultNext.Result.Count; } } } return(fileResults); }
public void GetFiles() { GetFilesRequest request = new GetFilesRequest(connection, "DEV/64"); GetFilesResponse response = request.Send(); Assert.AreEqual(response.StatusCode, System.Net.HttpStatusCode.OK); }
/// <summary> /// 获取下载任务的文件列表 /// </summary> /// <param name="gid"></param> /// <returns></returns> public async Task <List <FileModel> > GetFiles(string gid) { var res = new GetFilesResponse(await _client.SendRequestAsync(new GetFilesRequest { GID = gid })); return(res?.Info); }
private static void WriteFileToDisk(GetFilesResponse fileResult, string saveRootPath) { if (fileResult?.Result == null) return; foreach (MarketoFile file in fileResult?.Result) { string fileName = Path.Combine(saveRootPath, file.Name); FileDownloader.DownFile(file.Url, fileName); Console.WriteLine(file?.Url); } }
// Set the workflow status. public void setWorkFlowStatus(ErrorIndexType indexType, bool resetService) { // Add a context. CreateNewStackHashContextResponse resp = m_Utils.CreateNewContext(indexType); String testPath = "c:\\stackhashunittests\\testindex\\"; resp.Settings.ErrorIndexSettings.Folder = testPath; resp.Settings.ErrorIndexSettings.Name = "TestIndex"; m_Utils.SetContextSettings(resp.Settings); m_Utils.DeleteIndex(0); // Make sure it is empty. m_Utils.ActivateContext(0); // Create a test index with one cab file. StackHashTestIndexData testIndexData = new StackHashTestIndexData(); testIndexData.NumberOfProducts = 1; testIndexData.NumberOfFiles = 1; testIndexData.NumberOfEvents = 1; testIndexData.NumberOfEventInfos = 0; testIndexData.NumberOfCabs = 0; m_Utils.CreateTestIndex(0, testIndexData); GetProductsResponse getProductsResp = m_Utils.GetProducts(0); Assert.AreEqual(1, getProductsResp.Products.Count()); GetFilesResponse allFiles = m_Utils.GetFiles(0, getProductsResp.Products[0].Product); Assert.AreEqual(1, allFiles.Files.Count()); GetProductEventPackageResponse allEvents = m_Utils.GetProductEventPackages(0, getProductsResp.Products[0].Product); Assert.AreEqual(1, allEvents.EventPackages.Count()); // Set the workflow status int workFlowStatus = 10; m_Utils.SetWorkFlowStatus(0, getProductsResp.Products[0].Product, allFiles.Files[0], allEvents.EventPackages[0].EventData, workFlowStatus); if (resetService) { m_Utils.RestartService(); } allEvents = m_Utils.GetProductEventPackages(0, getProductsResp.Products[0].Product); Assert.AreEqual(1, allEvents.EventPackages.Count()); Assert.AreEqual(workFlowStatus, allEvents.EventPackages[0].EventData.WorkFlowStatus); Assert.AreEqual("Resolved - Responded", allEvents.EventPackages[0].EventData.WorkFlowStatusName); m_Utils.DeactivateContext(0); m_Utils.DeleteIndex(0); }
public GetFilesResponse Delete(GetFilesRequest request) { var time = Stopwatch.StartNew(); var response = new GetFilesResponse() { Server = Environment.MachineName }; Directory.Delete(request.Path, request.Recursive); response.Milliseconds = time.Elapsed.TotalMilliseconds; return(response); }
// Get the public void getCabPackage(ErrorIndexType indexType) { // Add a context. CreateNewStackHashContextResponse resp = m_Utils.CreateNewContext(indexType); String testPath = "c:\\stackhashunittests\\testindex\\"; resp.Settings.ErrorIndexSettings.Folder = testPath; resp.Settings.ErrorIndexSettings.Name = "TestIndex"; m_Utils.SetContextSettings(resp.Settings); m_Utils.DeleteIndex(0); // Make sure it is empty. m_Utils.ActivateContext(0); // Create a test index with one cab file. StackHashTestIndexData testIndexData = new StackHashTestIndexData(); testIndexData.NumberOfProducts = 1; testIndexData.NumberOfFiles = 1; testIndexData.NumberOfEvents = 1; testIndexData.NumberOfEventInfos = 0; testIndexData.NumberOfCabs = 1; m_Utils.CreateTestIndex(0, testIndexData); GetProductsResponse getProductsResp = m_Utils.GetProducts(0); Assert.AreEqual(1, getProductsResp.Products.Count()); GetFilesResponse allFiles = m_Utils.GetFiles(0, getProductsResp.Products[0].Product); Assert.AreEqual(1, allFiles.Files.Count()); GetProductEventPackageResponse allEvents = m_Utils.GetProductEventPackages(0, getProductsResp.Products[0].Product); Assert.AreEqual(1, allEvents.EventPackages.Count()); Assert.AreEqual(1, allEvents.EventPackages[0].Cabs.Count); // Get the Cab package. GetCabPackageResponse cabPackageResp = m_Utils.GetCabPackage(0, getProductsResp.Products[0].Product, allFiles.Files[0], allEvents.EventPackages[0].EventData, allEvents.EventPackages[0].Cabs[0].Cab); Assert.AreEqual("c:\\stackhashunittests\\testindex\\TestIndex\\00\\00\\00\\00\\CAB_0000000001\\1-Crash 32bit-0.cab", cabPackageResp.CabPackage.FullPath); }
public Task <IResponse> RunAsync() { var rootPath = Path.Combine(_command.RootPath); try { var files = PackedFile.PackFiles(rootPath, _command.Paths); IResponse response = new GetFilesResponse { Status = GetFilesStatus.Successful, Files = files }; if (_command.UseCompression) { response = new CompressedResponse(response); } return(Task.FromResult(response)); } catch (FileNotFoundException) { return(Task.FromResult <IResponse>(new GetFilesResponse { Status = GetFilesStatus.FileNotFound })); } catch (DirectoryNotFoundException) { return(Task.FromResult <IResponse>(new GetFilesResponse { Status = GetFilesStatus.FileNotFound })); } catch (UnauthorizedAccessException) { return(Task.FromResult <IResponse>(new GetFilesResponse { Status = GetFilesStatus.FileNotFound })); } catch (IOException) { return(Task.FromResult <IResponse>(new GetFilesResponse { Status = GetFilesStatus.OtherIOError })); } }
/// <summary> /// Gets the File data associated with a particular Product. /// </summary> /// <returns>Response result code.</returns> public GetFilesResponse GetFiles(GetFilesRequest requestData) { if (requestData == null) { throw new ArgumentNullException("requestData"); } GetFilesResponse resp = new GetFilesResponse(); StackHashFileCollection files = StaticObjects.TheStaticObjects.TheController.GetFiles( requestData.ContextId, requestData.Product); resp.Files = files; resp.ResultData = new StackHashServiceResultData( StackHashServiceResult.Success, s_OperationSuccessful, null); return(resp); }
public ObjectResult Post(GetFilesRequest request) { if (request is null || request.Path is null) { var problemDetail = new ProblemDetails { Status = 400, Title = "Invalid request", Detail = "Request", Instance = "https://api.contoso.com/errors/400" }; return(new ObjectResult(problemDetail) { StatusCode = problemDetail.Status }); } var time = Stopwatch.StartNew(); var options = new EnumerationOptions() { RecurseSubdirectories = request.Recursive }; var entries = Directory.EnumerateFileSystemEntries(request.Path, request.Filter, options); var response = new GetFilesResponse() { Server = Environment.MachineName }; foreach (var entry in entries) { response.Files.Add(entry); } response.Milliseconds = time.Elapsed.TotalMilliseconds; return(new ObjectResult(response)); }
// // 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 public void streamCabs(ErrorIndexType errorIndexType, bool useBigCabs, int numProducts, int numFiles, int numEvents, int numEventInfos, int numCabs, String fileName, String cabFileName) { // Add a context. CreateNewStackHashContextResponse resp = m_Utils.CreateNewContext(errorIndexType); String testPath = "c:\\stackhashunittests\\testindex\\"; resp.Settings.ErrorIndexSettings.Folder = testPath; resp.Settings.ErrorIndexSettings.Name = "TestIndex"; resp.Settings.ErrorIndexSettings.Type = errorIndexType; m_Utils.SetContextSettings(resp.Settings); m_Utils.DeleteIndex(0); m_Utils.ActivateContext(0); // Create a test index with one cab file. StackHashTestIndexData testIndexData = new StackHashTestIndexData(); testIndexData.NumberOfProducts = numProducts; testIndexData.NumberOfFiles = numFiles; testIndexData.NumberOfEvents = numEvents; testIndexData.NumberOfEventInfos = numEventInfos; testIndexData.NumberOfCabs = numCabs; testIndexData.UseLargeCab = useBigCabs; testIndexData.CabFileName = cabFileName; m_Utils.CreateTestIndex(0, testIndexData); // Find the cab. GetProductsResponse getProductsResp = m_Utils.GetProducts(0); Assert.AreEqual(numProducts, getProductsResp.Products.Count()); int productId = 1; int fileId = 1; int eventId = 1; try { foreach (StackHashProductInfo productInfo in getProductsResp.Products) { StackHashProduct product = productInfo.Product; Assert.AreEqual(productId++, product.Id); GetFilesResponse getFilesResp = m_Utils.GetFiles(0, product); Assert.AreEqual(numFiles, getFilesResp.Files.Count()); foreach (StackHashFile file in getFilesResp.Files) { Assert.AreEqual(fileId++, file.Id); GetEventsResponse getEventsResp = m_Utils.GetEvents(0, product, file); Assert.AreEqual(numEvents, getEventsResp.Events.Count()); foreach (StackHashEvent theEvent in getEventsResp.Events) { Assert.AreEqual(eventId++, theEvent.Id); GetEventPackageResponse getEventPackageResp = m_Utils.GetEventPackage(0, product, file, theEvent); Assert.AreEqual(numCabs, getEventPackageResp.EventPackage.Cabs.Count); Assert.AreEqual(numEventInfos, getEventPackageResp.EventPackage.EventInfoList.Count); // Stream the cabs. foreach (StackHashCabPackage cab in getEventPackageResp.EventPackage.Cabs) { String tempCabFileName = Path.GetTempFileName(); File.Delete(tempCabFileName); m_Utils.GetCab(tempCabFileName, 0, product, file, theEvent, cab.Cab, fileName); try { if (String.IsNullOrEmpty(fileName)) { Assert.AreEqual(true, File.Exists(tempCabFileName)); FileInfo fileInfo = new FileInfo(tempCabFileName); if (useBigCabs) { Assert.AreEqual(true, fileInfo.Length > 64 * 1024); } else if (cabFileName != null) { FileInfo sourceCabFileInfo = new FileInfo(cabFileName); Assert.AreEqual(true, fileInfo.Length == sourceCabFileInfo.Length); Assert.AreEqual(true, fileInfo.Length > 20000000); } else { Assert.AreEqual(true, fileInfo.Length <= 64 * 1024); } } else if (String.Compare("version.txt", fileName, StringComparison.OrdinalIgnoreCase) == 0) { String allText = File.ReadAllText(tempCabFileName); Assert.AreEqual(true, allText.Contains("Architecture:")); } } finally { File.Delete(tempCabFileName); } } } } } } finally { m_Utils.DeactivateContext(0); m_Utils.DeleteIndex(0); } }
public void getProductsNProductsNFilesNEvents(ErrorIndexType indexType, int numProducts, int numFiles, int numEvents, int numEventInfos, int numCabs) { // Add a context. CreateNewStackHashContextResponse resp = m_Utils.CreateNewContext(indexType); String testPath = "c:\\stackhashunittests\\testindex\\"; resp.Settings.ErrorIndexSettings.Folder = testPath; resp.Settings.ErrorIndexSettings.Name = "TestIndex"; m_Utils.SetContextSettings(resp.Settings); m_Utils.DeleteIndex(0); // Make sure it is empty. m_Utils.ActivateContext(0); // Create a test index with one cab file. StackHashTestIndexData testIndexData = new StackHashTestIndexData(); testIndexData.NumberOfProducts = numProducts; testIndexData.NumberOfFiles = numFiles; testIndexData.NumberOfEvents = numEvents; testIndexData.NumberOfEventInfos = numEventInfos; testIndexData.NumberOfCabs = numCabs; m_Utils.CreateTestIndex(0, testIndexData); // Service is now started with the specified index. // Make sure we can get at least the list of products. GetProductsResponse getProductsResp = m_Utils.GetProducts(0); Assert.AreNotEqual(new DateTime(0), getProductsResp.LastSiteUpdateTime); Assert.AreEqual(true, Math.Abs((DateTime.Now - getProductsResp.LastSiteUpdateTime).TotalDays) <= 15); Assert.AreEqual(numProducts, getProductsResp.Products.Count()); int productId = 1; int fileId = 1; int eventId = 1; foreach (StackHashProductInfo productInfo in getProductsResp.Products) { StackHashProduct product = productInfo.Product; Assert.AreEqual(productId++, product.Id); GetFilesResponse getFilesResp = m_Utils.GetFiles(0, product); Assert.AreEqual(numFiles, getFilesResp.Files.Count()); foreach (StackHashFile file in getFilesResp.Files) { Assert.AreEqual(fileId++, file.Id); GetEventsResponse getEventsResp = m_Utils.GetEvents(0, product, file); Assert.AreEqual(numEvents, getEventsResp.Events.Count()); foreach (StackHashEvent theEvent in getEventsResp.Events) { Assert.AreEqual(eventId++, theEvent.Id); GetEventPackageResponse getEventPackageResp = m_Utils.GetEventPackage(0, product, file, theEvent); Assert.AreEqual(numCabs, getEventPackageResp.EventPackage.Cabs.Count); Assert.AreEqual(numEventInfos, getEventPackageResp.EventPackage.EventInfoList.Count); } } } m_Utils.DeactivateContext(0); m_Utils.DeleteIndex(0); }
public void runAnalyzeJustAutoScripts(ErrorIndexType indexType, int numberOfProducts, int numberOfFiles, int numberOfEvents, int numberOfCabs, int numberOfAutoUnmanagedAndManagedScripts, int numberOfManualUnmanagedAndManagedScripts, bool useUnmanagedCabs, int numberOfAutoManagedScripts, int numberOfManualManagedScripts, int numberOfAutoUnmanagedScripts, int numberOfManualUnmanagedScripts) { int numberOfEventInfos = 1; // Use the dummy winqual. StackHashTestData testData = new StackHashTestData(); testData.DummyWinQualSettings = new StackHashTestDummyWinQualSettings(); testData.DummyWinQualSettings.UseDummyWinQual = true; testData.DummyWinQualSettings.ObjectsToCreate = new StackHashTestIndexData(); testData.DummyWinQualSettings.ObjectsToCreate.UseLargeCab = false; testData.DummyWinQualSettings.ObjectsToCreate.NumberOfProducts = numberOfProducts; testData.DummyWinQualSettings.ObjectsToCreate.NumberOfFiles = numberOfFiles; testData.DummyWinQualSettings.ObjectsToCreate.NumberOfEvents = numberOfEvents; testData.DummyWinQualSettings.ObjectsToCreate.NumberOfEventInfos = numberOfEventInfos; testData.DummyWinQualSettings.ObjectsToCreate.NumberOfCabs = numberOfCabs; testData.DummyWinQualSettings.ObjectsToCreate.UseUnmanagedCab = useUnmanagedCabs; m_Utils.SetTestData(testData); m_Utils.RegisterForNotifications(true, m_Utils.ApplicationGuid); m_Utils.CreateNewContext(indexType); // Set the username and password to something valid. GetStackHashPropertiesResponse settings = m_Utils.GetContextSettings(); String testPath = "c:\\stackhashunittest\\testindex\\"; settings.Settings.ContextCollection[0].ErrorIndexSettings.Folder = testPath; settings.Settings.ContextCollection[0].ErrorIndexSettings.Name = "TestIndex"; settings.Settings.ContextCollection[0].WinQualSettings.UserName = m_UserName; settings.Settings.ContextCollection[0].WinQualSettings.Password = m_Password; m_Utils.SetContextSettings(settings.Settings.ContextCollection[0]); // Make sure the index starts off empty. m_Utils.DeleteIndex(0); m_Utils.ActivateContext(0); for (int i = 0; i < numberOfAutoUnmanagedAndManagedScripts; i++) { StackHashScriptSettings scriptSettings = m_Utils.MakeScriptSettings(i, true, StackHashScriptDumpType.UnmanagedAndManaged, true); m_Utils.AddDebuggerScript(scriptSettings, false); } for (int i = 0; i < numberOfManualUnmanagedAndManagedScripts; i++) { StackHashScriptSettings scriptSettings = m_Utils.MakeScriptSettings(i + 100, true, StackHashScriptDumpType.UnmanagedAndManaged, false); m_Utils.AddDebuggerScript(scriptSettings, false); } for (int i = 0; i < numberOfAutoManagedScripts; i++) { StackHashScriptSettings scriptSettings = m_Utils.MakeScriptSettings(i + 200, true, StackHashScriptDumpType.ManagedOnly, true); m_Utils.AddDebuggerScript(scriptSettings, false); } for (int i = 0; i < numberOfManualManagedScripts; i++) { StackHashScriptSettings scriptSettings = m_Utils.MakeScriptSettings(i + 300, true, StackHashScriptDumpType.ManagedOnly, false); m_Utils.AddDebuggerScript(scriptSettings, false); } for (int i = 0; i < numberOfAutoUnmanagedScripts; i++) { StackHashScriptSettings scriptSettings = m_Utils.MakeScriptSettings(i + 400, true, StackHashScriptDumpType.UnmanagedOnly, true); m_Utils.AddDebuggerScript(scriptSettings, false); } for (int i = 0; i < numberOfManualUnmanagedScripts; i++) { StackHashScriptSettings scriptSettings = m_Utils.MakeScriptSettings(i + 500, true, StackHashScriptDumpType.UnmanagedOnly, false); m_Utils.AddDebuggerScript(scriptSettings, false); } try { // Synchronize so we have a copy of just the product list. StartSynchronizationResponse resp = m_Utils.StartSynchronization(0, 60000); StackHashClientData clientData = m_Utils.LastClientData; StackHashWinQualSyncCompleteAdminReport adminReport = m_Utils.WinQualSyncAdminReport as StackHashWinQualSyncCompleteAdminReport; Assert.AreNotEqual(null, adminReport); Assert.AreEqual(clientData.ApplicationGuid, adminReport.ClientData.ApplicationGuid); Assert.AreEqual(clientData.ClientId, adminReport.ClientData.ClientId); Assert.AreEqual(clientData.ClientName, adminReport.ClientData.ClientName); Assert.AreEqual(clientData.ClientRequestId, adminReport.ClientData.ClientRequestId); Assert.AreEqual(0, adminReport.ContextId); Assert.AreEqual(null, adminReport.LastException); Assert.AreEqual(StackHashAdminOperation.WinQualSyncCompleted, adminReport.Operation); Assert.AreEqual(StackHashAsyncOperationResult.Success, adminReport.ResultData); Assert.AreEqual(numberOfProducts, adminReport.ErrorIndexStatistics.Products); Assert.AreEqual(0, adminReport.ErrorIndexStatistics.Files); Assert.AreEqual(0, adminReport.ErrorIndexStatistics.Events); Assert.AreEqual(0, adminReport.ErrorIndexStatistics.Cabs); Assert.AreEqual(0, adminReport.ErrorIndexStatistics.EventInfos); // Enable sync for all the products. GetProductsResponse getProducts = m_Utils.GetProducts(0); foreach (StackHashProductInfo productInfo in getProducts.Products) { Assert.AreEqual(false, productInfo.SynchronizeEnabled); m_Utils.SetProductSynchronizationState(0, productInfo.Product.Id, true); // Make sure there are no files for this product yet. GetFilesResponse getFiles = m_Utils.GetFiles(0, productInfo.Product); Assert.AreEqual(0, getFiles.Files.Count); } // Start the sync and wait for the sync and analyze to complete. resp = m_Utils.StartSynchronization(0, 120000, false, false, null); clientData = m_Utils.LastClientData; adminReport = m_Utils.WinQualSyncAdminReport as StackHashWinQualSyncCompleteAdminReport; Assert.AreNotEqual(null, adminReport); Assert.AreEqual(clientData.ApplicationGuid, adminReport.ClientData.ApplicationGuid); Assert.AreEqual(clientData.ClientId, adminReport.ClientData.ClientId); Assert.AreEqual(clientData.ClientName, adminReport.ClientData.ClientName); Assert.AreEqual(clientData.ClientRequestId, adminReport.ClientData.ClientRequestId); Assert.AreEqual(0, adminReport.ContextId); Assert.AreEqual(null, adminReport.LastException); Assert.AreEqual(StackHashAdminOperation.WinQualSyncCompleted, adminReport.Operation); Assert.AreEqual(StackHashAsyncOperationResult.Success, adminReport.ResultData); Assert.AreEqual(0, adminReport.ErrorIndexStatistics.Products); // Should have already added the product. Assert.AreEqual(numberOfFiles * numberOfProducts, adminReport.ErrorIndexStatistics.Files); Assert.AreEqual(numberOfEvents * numberOfFiles * numberOfProducts, adminReport.ErrorIndexStatistics.Events); Assert.AreEqual(numberOfCabs * numberOfEvents * numberOfFiles * numberOfProducts, adminReport.ErrorIndexStatistics.Cabs); Assert.AreEqual(numberOfEventInfos * numberOfEvents * numberOfFiles * numberOfProducts, adminReport.ErrorIndexStatistics.EventInfos); // Make sure the task is no longer running. GetStackHashServiceStatusResponse statusResp = m_Utils.GetServiceStatus(); Assert.AreEqual(false, m_Utils.IsTaskRunning(statusResp.Status.ContextStatusCollection[0].TaskStatusCollection, StackHashTaskType.WinQualSynchronizeTask)); Assert.AreEqual(false, m_Utils.IsTaskRunning(statusResp.Status.ContextStatusCollection[0].TaskStatusCollection, StackHashTaskType.AnalyzeTask)); // Check that the scripts have been run ok. Both auto scripts should be run. StackHashProductInfoCollection products = m_Utils.GetProducts(0).Products; foreach (StackHashProductInfo product in products) { StackHashFileCollection files = m_Utils.GetFiles(0, product.Product).Files; foreach (StackHashFile file in files) { StackHashEventCollection events = m_Utils.GetEvents(0, product.Product, file).Events; foreach (StackHashEvent currentEvent in events) { StackHashEventPackage eventPackage = m_Utils.GetEventPackage(0, product.Product, file, currentEvent).EventPackage; foreach (StackHashCabPackage cab in eventPackage.Cabs) { StackHashScriptResultFiles scriptResults = m_Utils.GetDebugResultFiles(0, product.Product, file, currentEvent, cab.Cab).ResultFiles; int numberOfAutoScripts = 2; int expectedResults = numberOfAutoScripts + numberOfAutoUnmanagedAndManagedScripts; if (!useUnmanagedCabs) { expectedResults += numberOfAutoManagedScripts; } else { expectedResults += numberOfAutoUnmanagedScripts; } Assert.AreEqual(expectedResults, scriptResults.Count); } } } } } finally { m_Utils.DeactivateContext(0); m_Utils.DeleteIndex(0); } }
public void MoveNonEmptyIndex() { try { m_Utils.RegisterForNotifications(true, m_Utils.ApplicationGuid); SetStackHashPropertiesResponse newContextResp = m_Utils.CreateAndSetNewContext(); // Create a context and give it a non-default name. GetStackHashPropertiesResponse getResp = m_Utils.GetContextSettings(); Assert.AreEqual(ErrorIndexStatus.NotCreated, getResp.Settings.ContextCollection[0].ErrorIndexSettings.Status); m_Utils.ActivateContext(0); // Create the index. getResp = m_Utils.GetContextSettings(); Assert.AreEqual(ErrorIndexStatus.Created, getResp.Settings.ContextCollection[0].ErrorIndexSettings.Status); // Create a small error index. StackHashTestIndexData testIndexData = new StackHashTestIndexData(); testIndexData.NumberOfProducts = 1; testIndexData.NumberOfFiles = 1; testIndexData.NumberOfEvents = 1; testIndexData.NumberOfEventInfos = 1; testIndexData.NumberOfCabs = 1; m_Utils.CreateTestIndex(0, testIndexData); String originalIndexPath = getResp.Settings.ContextCollection[0].ErrorIndexSettings.Folder; String originalIndexName = getResp.Settings.ContextCollection[0].ErrorIndexSettings.Name; String indexName = "NewIndexName"; String testPath = "c:\\stackhashunittests\\testindex\\"; // TODO: This won't work if testing across machines. // Make sure the destination folder does not exist. String fullDestPath = Path.Combine(testPath, indexName); if (Directory.Exists(fullDestPath)) { PathUtils.DeleteDirectory(fullDestPath, true); } m_Utils.DeactivateContext(0); // Must be inactive before the move. m_Utils.MoveIndex(0, testPath, indexName, 20000, newContextResp.Settings.ContextCollection[0].SqlSettings); m_Utils.ActivateContext(0); // Must be inactive before the move. Assert.AreEqual(false, Directory.Exists(Path.Combine(originalIndexPath, originalIndexName))); Assert.AreEqual(true, Directory.Exists(Path.Combine(testPath, indexName))); Assert.AreEqual(null, m_Utils.MoveCompleteAdminReport.LastException); Assert.AreEqual(StackHashAsyncOperationResult.Success, m_Utils.MoveCompleteAdminReport.ResultData); getResp = m_Utils.GetContextSettings(); Assert.AreEqual(ErrorIndexStatus.Created, getResp.Settings.ContextCollection[0].ErrorIndexSettings.Status); Assert.AreEqual(testPath.ToUpperInvariant(), getResp.Settings.ContextCollection[0].ErrorIndexSettings.Folder.ToUpperInvariant()); Assert.AreEqual(indexName.ToUpperInvariant(), getResp.Settings.ContextCollection[0].ErrorIndexSettings.Name.ToUpperInvariant()); // Check that the products etc.. have been moved. GetProductsResponse products = m_Utils.GetProducts(0); Assert.AreEqual(1, products.Products.Count); foreach (StackHashProductInfo productInfo in products.Products) { StackHashProduct product = productInfo.Product; GetFilesResponse files = m_Utils.GetFiles(0, product); Assert.AreEqual(1, files.Files.Count); foreach (StackHashFile file in files.Files) { GetEventsResponse events = m_Utils.GetEvents(0, product, file); Assert.AreEqual(1, events.Events.Count); foreach (StackHashEvent theEvent in events.Events) { GetEventPackageResponse eventPackage = m_Utils.GetEventPackage(0, product, file, theEvent); Assert.AreEqual(1, eventPackage.EventPackage.Cabs.Count); Assert.AreEqual(1, eventPackage.EventPackage.EventInfoList.Count); } } } } finally { m_Utils.DeactivateContext(0); m_Utils.DeleteIndex(0); } }