public void AvrServiceCopyLayoutTest() { long id = VirtualLayoutCopierTests.GetFirstlayoutId(); if (id > 0) { var tasks = new List <Action>(); // todo [ivan] change VirtualLayoutCopier to use different connections and test multithread for (int i = 0; i < 1; i++) { var copyTask = new Action(() => { //Assert.IsTrue(false); AvrServiceCopyLayoutResult result = ServiceClientHelper.AvrServiceCopyLayout(id); Assert.IsNotNull(result); Assert.IsTrue(result.IsOk, result.ErrorMessage); Assert.IsTrue(result.Model > 0); }); tasks.Add(copyTask); } Parallel.Invoke(new ParallelOptions { MaxDegreeOfParallelism = 2 }, tasks.ToArray()); } }
private object GetModelFromService(long layoutId) { AvrServiceAccessability access = AvrServiceAccessability.Check(); if (!access.IsOk) { return(access.ErrorMessage); } AvrServicePivotResult pivotResult = ServiceClientHelper.GetAvrServicePivotResult(Session.SessionID, layoutId); if (!pivotResult.IsOk) { return(pivotResult.ErrorMessage); } pivotResult.Model.ViewHeader.AssignOwnerAndUniquePath(); DataTable dt = pivotResult.Model.ViewData; AvrViewHelper.AddIDColumn(ref dt); AvrViewHelper.RemoveHASCadditions(pivotResult.Model.ViewHeader, ref dt); pivotResult.Model.ViewData = dt; return(pivotResult); }
public ActionResult OnRefreshDataPost(long layoutId, bool save) { string error; var viewModel = GetModelFromSession(layoutId, out error); if (viewModel == null) { return(View("AvrServiceError", (object)error)); } if (save) { SaveModelInDb(viewModel.ViewHeader); } ServiceClientHelper.AvrServiceClearQueryCache(GetQueryIdFromSession(layoutId)); ObjectStorage.Remove(Session.SessionID, layoutId, LayoutController.StoragePrefix); object ret = GetModelFromService(layoutId); if (ret is string) { return(View("AvrServiceError", (object)ret)); } var pivotResult = ret as AvrServicePivotResult; AdjustToNew(layoutId, viewModel.ViewHeader, pivotResult.Model); viewModel.ViewHeader.GridViewSettings = null; ViewBag.LayoutId = layoutId; return(RedirectToAction("ViewLayout", new { layoutId = layoutId })); }
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)); }
public void AvrServiceHelperGetAvrServiceQueryResultTest() { ServiceClientHelper.CallAvrServiceToForceLOHMemoryAllocations(); CachedQueryResult result = ServiceClientHelper.GetAvrServiceQueryResult(49539640000000, false, string.Empty); Assert.IsNotNull(result); Assert.IsNotNull(result.QueryTable); }
public SecretManagerConfigurationSource(SecretManagerConfigurationOptions options, ServiceClientHelper clientHelper = null) { if (options == null) { throw new ArgumentNullException(nameof(options)); } _options = options; _clientHelper = clientHelper ?? new ServiceClientHelper(); }
public void AvrServiceHelperGetAvrServicePivotResultTest() { ServiceClientHelper.CallAvrServiceToForceLOHMemoryAllocations(); AvrServicePivotResult result = ServiceClientHelper.GetAvrServicePivotResult("xxx", -1); Assert.IsNotNull(result); Assert.IsNotNull(result.Model); Assert.IsNotNull(result.Model.ViewHeader); Assert.IsNotNull(result.Model.ViewData); }
private string RefreshQueryData(long queryId) { AvrServiceAccessability access = AvrServiceAccessability.Check(); if (!access.IsOk) { return(access.ErrorMessage); } ServiceClientHelper.AvrServiceClearQueryCache(queryId); ServiceClientHelper.RefreshQuery(queryId); return(string.Empty); }
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 AvrServiceHelperGetAvrServiceChartResultTest() { var tableModel = new ChartTableModel(-1, ModelUserContext.CurrentLanguage, ExportChartToJpgTests.CreateChartData(), null, null, null, 1000, 750); AvrServiceChartResult result = ServiceClientHelper.GetAvrServiceChartResult(tableModel); Assert.IsNotNull(result); Assert.IsTrue(result.IsOk, result.ErrorMessage); Assert.IsNotNull(result.Model); Assert.IsNotNull(result.Model.JpgBytes); Assert.IsTrue(result.Model.JpgBytes.Length > 0); ExportTests.AssertJpeg(result.Model.JpgBytes); //File.WriteAllBytes("filexxx.jpg", result.Model); }
public static async Task <IEnumerable <courseLocationList> > GetCourseLocationList(courseLocationList_Filter[] filter, string subscriptionKey, string accountKey, int size = 0) { try { var service = ServiceClientHelper.CourseLocationListServiceClient(accountKey, subscriptionKey); var response = service.ReadMultipleAsync(filter, "", size).Result; await service.CloseAsync(); return(response.ReadMultiple_Result.ToList()); } catch (Exception exception) { throw new Exception("Fejl i async Task", exception); } }
private string RefreshPivotData() { AvrServiceAccessability access = AvrServiceAccessability.Check(); if (!access.IsOk) { return(access.ErrorMessage); } AvrPivotGridModel model = GetModelFromSession(); if (model != null) { ServiceClientHelper.AvrServiceClearQueryCache(model.PivotSettings.QueryId); RemovePivotViewObjects(model.PivotSettings.LayoutId); } return(string.Empty); }
public JsonResult CheckLayout(long layoutId, bool forceViewShowing, bool forceLayoutShowing) { bool isNewLayout = false; bool isQueryCasheExists = false; string error = String.Empty; try { using (var manager = DbManagerFactory.Factory.Create(ModelUserContext.Instance)) { var ps = new List <object> { manager.Parameter("LayoutID", layoutId), }; var command = manager.SetSpCommand("dbo.spAsLayoutIsNew", ps.ToArray()); isNewLayout = command.ExecuteScalar <int>(ScalarSourceType.ReturnValue) == 1; List <AvrTreeElement> tree = GetQueryTree(); AvrTreeElement elem = tree.FirstOrDefault(c => c.ID == layoutId); if (elem != null) { isQueryCasheExists = ServiceClientHelper.DoesCachedQueryExists(elem.QueryID, ModelUserContext.CurrentLanguage, elem.IsUseArchiveData); } } } catch (Exception ex) { error = ex.Message; } return(new JsonResult { JsonRequestBehavior = JsonRequestBehavior.AllowGet, Data = new { err = error, isQueryExists = isQueryCasheExists? "Yes": "No", isNewLayout = isNewLayout? "Yes" : "No", okFunction = string.Format("queryTreeList.showLayoutViewInternal({0}, {1}, {2}, {3}, '{4}');", layoutId, Bool2JsBool(isNewLayout), Bool2JsBool(forceViewShowing), Bool2JsBool(forceLayoutShowing), isNewLayout ? Translator.GetMessageString("msgCantShowView") : ""), Message = !isQueryCasheExists?Translator.GetMessageString("msgShouldOpenLayout") : (isNewLayout ? Translator.GetMessageString("msgCantShowView") : "") } }); }
public JsonResult CopyNode(long id) { //проверим, что это именно Layout List <AvrTreeElement> tree = GetQueryTree(); AvrTreeElement elem = tree.FirstOrDefault(c => c.ID == id); bool wasError = false; string errStr = String.Empty; long idLayoutCopy = 0; if ((elem == null) || !elem.IsLayout) { wasError = true; } else { AvrServiceCopyLayoutResult result = ServiceClientHelper.AvrServiceCopyLayout(id); if (result.IsOk) { idLayoutCopy = result.Model; } else { errStr = result.ErrorMessage; wasError = true; } } if (!wasError) { RefreshTree(); } return(new JsonResult { JsonRequestBehavior = JsonRequestBehavior.AllowGet, Data = new { result = wasError ? "ERROR" : "OK", idflLayoutCopy = idLayoutCopy, errorString = errStr, url = Url.Action("QueryLayoutTree", GetQueryTree()), } }); }
private byte[] GetChartBytesFromService(long layoutId, AvrPivotViewModel viewModel, int width, int height) { m_ErrorMessage = ""; DBChartType?chtp = null; if (viewModel.ViewHeader.ChartType != null && viewModel.ViewHeader.ChartType != "") { chtp = (DBChartType)Enum.Parse(typeof(DBChartType), viewModel.ViewHeader.ChartType); } var toTable = GetChartDataFromSession(layoutId, viewModel); var textPatterns = new Dictionary <string, object>(); foreach (DataColumn col in toTable.Columns) { if (col.ExtendedProperties.ContainsKey("TextPattern")) { textPatterns.Add(col.ColumnName, col.ExtendedProperties["TextPattern"]); } } var tbl = new ChartTableModel(viewModel.ViewHeader.ViewID, EidssUserContext.CurrentLanguage, toTable, viewModel.ViewHeader.ChartLocalSettingsZip, chtp, textPatterns, width, height); AvrServiceChartResult result = ServiceClientHelper.GetAvrServiceChartResult(tbl); if (!result.IsOk) { m_ErrorMessage = result.ErrorMessage; return(null); } ObjectStorage.Put(Session.SessionID, 0, layoutId, storagePrefix, result.Model.JpgBytes); return(result.Model.JpgBytes); }
private ActionResult SaveData() { AvrPivotGridModel model = GetModelFromSession(); if (model == null) { return(View("AvrServiceError", (object)m_ErrorMessage)); } var helper = new LayoutHelper(model.PivotSettings.LayoutDataset); if (helper.SaveData(model.PivotSettings)) { model.PivotSettings.HasChanges = false; model.PivotSettings.Fields.ForEach(f => f.HasChanges = false); ObjectStorage.Remove(Session.SessionID, model.PivotSettings.LayoutId, ViewLayoutController.StoragePrefix); ServiceClientHelper.AvrServiceClearViewCache(model.PivotSettings.LayoutId); } return(new JsonResult { Data = String.Empty, JsonRequestBehavior = JsonRequestBehavior.AllowGet }); }
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); }
static OrderServiceClient() { var channel = ServiceClientHelper.GetChannelByApiName("OrderApi"); Client = new OrderService.OrderServiceClient(channel); }
static ProductServiceClient() { var channel = ServiceClientHelper.GetChannelByApiName("ProductApi"); Client = new ProductService.ProductServiceClient(channel); }
public DeviceElementController() { _serviceClientHelper = new ServiceClientHelper("HostName=home-automation-iothub.azure-devices.net;SharedAccessKeyName=iothubowner;SharedAccessKey=H22EJy8VsdA0jbzes+lDbXXtg0sC1PMIvphDXfYT0FM="); }
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)); }