public void SimpleQueryTest() { var facadeStub = new AVRFacadeStub(123); var receiver = new AvrCacheReceiver(facadeStub); AvrDataTable dataTable; using (new StopwathTransaction("+++GetCachedQueryTable+++")) { CachedQueryResult result = receiver.GetCachedQueryTable(1, "en", false, string.Empty, new LayoutSilentValidatorWaiter()); dataTable = result.QueryTable; Assert.IsNotNull(dataTable); } Assert.IsNotNull(dataTable); Assert.AreEqual(54 * 2, dataTable.Columns.Count); Assert.AreEqual(31, dataTable.Rows.Count); var caseIdIndex = dataTable.Columns["sflHC_CaseID"].Ordinal; AvrDataRowBase lastRow = dataTable.Rows.Find(r => Utils.Str(r[caseIdIndex]) == "HC1000031"); Assert.AreEqual(new DateTime(1990, 02, 01), lastRow[0]); Assert.AreEqual(23, lastRow[1]); Assert.AreEqual(DBNull.Value, lastRow[3]); Assert.AreEqual("xxx", lastRow[4]); Assert.AreEqual("Male", lastRow[6]); Assert.AreEqual(DBNull.Value, lastRow[7]); Assert.AreEqual(DateTime.Now.Year, ((DateTime)lastRow[50]).Year); Assert.AreEqual(DateTime.Now.Year, lastRow[51]); Assert.AreEqual(25460000000m, lastRow[52]); Assert.AreEqual("Yes", lastRow[53]); }
public static AvrDataTable GetPivotData(LayoutDetailDataSet ds, long queryId, long layoutId, bool useArchiveData, string filter, out bool isNewObject, out string errorMessage) { CachedQueryResult queryResult = ServiceClientHelper.ExecQuery(queryId, useArchiveData, filter); isNewObject = ds.LayoutSearchField.Count == 0; errorMessage = queryResult.ErrorMessage; return(AvrPivotGridHelper.GetPreparedDataSource(ds.LayoutSearchField, queryId, layoutId, queryResult.QueryTable, isNewObject)); }
private CachedQueryResult QueryExecutor(long queryId, string lang, bool isArchive, string filter) { var receiver = new AvrCacheReceiver(new AVRFacade(m_Container)); var validatorWaiter = new LayoutSilentValidatorWaiter(); CachedQueryResult result = receiver.GetCachedQueryTable(queryId, lang, isArchive, filter, validatorWaiter); return(result); }
public void AvrServiceHelperGetAvrServiceQueryResultTest() { ServiceClientHelper.CallAvrServiceToForceLOHMemoryAllocations(); CachedQueryResult result = ServiceClientHelper.GetAvrServiceQueryResult(49539640000000, false, string.Empty); Assert.IsNotNull(result); Assert.IsNotNull(result.QueryTable); }
private static string ExportToAccess(AvrAccessExportResult result) { //using (new CultureInfoTransaction(new CultureInfo(CustomCultureHelper.SupportedLanguages[lang]))) ModelUserContext.CurrentLanguage = result.Language; CachedQueryResult queryResult = ServiceClientHelper.ExecQuery(result.QueryId, false, string.Empty, true); if (string.IsNullOrEmpty(queryResult.ErrorMessage)) { AccessDataAdapter.QueryLineListToAccess(result.ResultFilePath, queryResult.QueryTable); } return(queryResult.ErrorMessage); }
public void LongQueryTest() { var facadeStub = new AVRFacadeStub(123, 200); var receiver = new AvrCacheReceiver(facadeStub); AvrDataTable dataTable; using (new StopwathTransaction("+++GetCachedQueryTable+++")) { CachedQueryResult result = receiver.GetCachedQueryTable(1, "en", false, string.Empty, new LayoutSilentValidatorWaiter()); dataTable = result.QueryTable; } Assert.IsNotNull(dataTable); Assert.AreEqual(54 * 2, dataTable.Columns.Count); Assert.AreEqual(31 * 200, dataTable.Rows.Count); }
public void AvrServiceArchiveTest() { const long humQueryId = 49539640000000; using (var wrapper = new AvrServiceClientWrapper(m_HostKeeper.CurrentServiceHostURL)) { var receiver = new AvrCacheReceiver(wrapper); AvrDataTable dataTable; using (new StopwathTransaction("++++ Hum - GetCachedQueryTable - en 1")) { CachedQueryResult result = receiver.GetCachedQueryTable(humQueryId, "en", true, string.Empty, new LayoutSilentValidatorWaiter()); Assert.IsNotNull(result); dataTable = result.QueryTable; } Assert.IsNotNull(dataTable); Assert.AreEqual(m_HumanFieldCount * 2, dataTable.Columns.Count); Assert.IsTrue(1500 * 2 < dataTable.Rows.Count); } }
public void DoesCachedQueryExistsTest() { ServiceClientHelper.CallAvrServiceToForceLOHMemoryAllocations(); bool exists = ServiceClientHelper.DoesCachedQueryExists(-1, "en", false); Assert.IsFalse(exists); var queryId = 49539640000000; ServiceClientHelper.AvrServiceClearQueryCache(queryId); exists = ServiceClientHelper.DoesCachedQueryExists(queryId, ModelUserContext.CurrentLanguage, false); Assert.IsFalse(exists); CachedQueryResult result = ServiceClientHelper.GetAvrServiceQueryResult(queryId, false, string.Empty); Assert.IsNotNull(result); exists = ServiceClientHelper.DoesCachedQueryExists(queryId, ModelUserContext.CurrentLanguage, false); Assert.IsTrue(exists); exists = ServiceClientHelper.DoesCachedQueryExists(queryId, ModelUserContext.CurrentLanguage, true); Assert.IsFalse(exists); }
/// <summary> /// Commits the changes made to the repository. /// </summary> public void CommitChanges() { try { // Clear the cache and save. this.context.SaveChanges(); } catch (DbEntityValidationException e) { foreach (var validationErrors in e.EntityValidationErrors) { foreach (var validationError in validationErrors.ValidationErrors) { Trace.TraceInformation("Property: {0} Error: {1}", validationError.PropertyName, validationError.ErrorMessage); } } } // Clean the cache if dirty. if (this.isDirty) { CachedQueryResult.ClearCachedQueries(); } }
public void AvrServiceFullProcessTest() { const long humQueryId = 49539640000000; const long vetQueryId = 49542020000000; using (var wrapper = new AvrServiceClientWrapper(m_HostKeeper.CurrentServiceHostURL)) { AvrDataTable dataTable; using (new StopwathTransaction("++++ Hum - GetCachedQueryTable - en 1")) { var receiver = new AvrCacheReceiver(wrapper); receiver.GetCachedQueryTable(humQueryId, "en", false, string.Empty, new LayoutSilentValidatorWaiter()); } using (new StopwathTransaction("++++ Hum - GetCachedQueryTable - ru")) { var receiver = new AvrCacheReceiver(wrapper); receiver.GetCachedQueryTable(humQueryId, "ru", false, string.Empty, new LayoutSilentValidatorWaiter()); } using (new StopwathTransaction("++++ Hum - GetCachedQueryTable - en 2")) { var receiver = new AvrCacheReceiver(wrapper); CachedQueryResult result = receiver.GetCachedQueryTable(humQueryId, "en", false, string.Empty, new LayoutSilentValidatorWaiter()); Assert.IsNotNull(result); dataTable = result.QueryTable; } Assert.IsNotNull(dataTable); Assert.AreEqual(m_HumanFieldCount * 2, dataTable.Columns.Count); Assert.IsTrue(1500 < dataTable.Rows.Count); using (new StopwathTransaction("++++ Vet - InvalidateQueryCache - en")) { wrapper.InvalidateQueryCacheForLanguage(vetQueryId, "en"); } using (new StopwathTransaction("++++ Vet - GetCachedQueryTable - en 1")) { var receiver = new AvrCacheReceiver(wrapper); receiver.GetCachedQueryTable(vetQueryId, "en", false, string.Empty, new LayoutSilentValidatorWaiter()); } using (new StopwathTransaction("++++ Vet - GetCachedQueryTable - en 2")) { var receiver = new AvrCacheReceiver(wrapper); CachedQueryResult result = receiver.GetCachedQueryTable(vetQueryId, "en", false, string.Empty, new LayoutSilentValidatorWaiter()); Assert.IsNotNull(result); dataTable = result.QueryTable; } Assert.IsNotNull(dataTable); Assert.AreEqual(m_VetFieldCount * 2, dataTable.Columns.Count); Assert.IsTrue(1000 < dataTable.Rows.Count); } using (var wrapper = new AvrServiceClientWrapper(m_HostKeeper.CurrentServiceHostURL)) { using (new StopwathTransaction("++++ Hum - new Client - GetCachedQueryTable - en 1")) { var receiver = new AvrCacheReceiver(wrapper); receiver.GetCachedQueryTable(humQueryId, "en", false, string.Empty, new LayoutSilentValidatorWaiter()); } using (new StopwathTransaction("++++ Hum - new Client - GetCachedQueryTable - en 2")) { var receiver = new AvrCacheReceiver(wrapper); receiver.GetCachedQueryTable(humQueryId, "en", false, string.Empty, new LayoutSilentValidatorWaiter()); } } }
public FileResult ExportQueryRoutines(long queryId, int exportType) { if (exportType != 0 && exportType != 1 && exportType != 2) { throw new ArgumentException(EidssMessages.Get("ExportTypeError"), "exportType"); } // export to Access. It's impossible without creating temp file if (exportType == 2) { const int effortCount = 10; int effortNum = 1; WindowsLogHelper.WriteToEventLogWindows("Try to export data to MS Access", EventLogEntryType.Information); //var path = Path.Combine(Path.GetTempPath(), DateTime.Now.Ticks.ToString()); string path = Path.Combine(Server.MapPath("~/App_Data/ExportQueryFiles"), DateTime.Now.Ticks.ToString()); string filename = Path.ChangeExtension(path, "mdb"); WindowsLogHelper.WriteToEventLogWindows(String.Format("Full path = {0}", filename), EventLogEntryType.Information); AccessExporter.ExportAnyCPU(queryId, ModelUserContext.CurrentLanguage, filename); //Thread.Sleep(6000); var fileBytes = new byte[0]; while (effortNum <= effortCount) { try { effortNum++; fileBytes = System.IO.File.ReadAllBytes(filename); break; } catch (Exception) { Thread.Sleep(1000); } } if (fileBytes.Length == 0) { throw new ArgumentException(EidssMessages.Get("Cantreadfile")); } //пробуем удалить файл effortNum = 1; while (effortNum <= effortCount) { try { effortNum++; System.IO.File.Delete(filename); break; } // ReSharper disable EmptyGeneralCatchClause catch (Exception) // ReSharper restore EmptyGeneralCatchClause { } } return(File(fileBytes, MediaTypeNames.Application.Octet, Path.GetFileName(filename))); } // Export to Excel ExportType type = exportType == 0 ? ExportType.Xls : ExportType.Xlsx; CachedQueryResult queryResult = ServiceClientHelper.ExecQuery(queryId, false, string.Empty, true); if (!string.IsNullOrEmpty(queryResult.ErrorMessage)) { //todo:[mike] return queryResult.ErrorMessage to user } List <byte[]> fileBytesList = NpoiExcelWrapper.QueryLineListToExcel(queryResult.QueryTable, type); if (fileBytesList.Count == 0) { throw new AvrDataException(string.Format("Could not export query '{0}' to Excel", queryId)); } // todo: [ELeonov] Should return multifile result if fileBytesList contains more than one element (see task 9516) return(File(fileBytesList[0], MediaTypeNames.Application.Octet, "QueryLineList." + type)); }