public async Task <IActionResult> CreateAGS(Guid Id, Guid tablemapId, string[] agstables, string options, string format = "view", Boolean save = false) { if (Id == Guid.Empty || tablemapId == Guid.Empty) { return(NotFound()); } var _data = await _dataTableFileService.GetDataByIdWithAll(Id); var _tablemapId = await _dataTableFileService.GetDataByIdWithAll(tablemapId); var _user = await GetUserAsync(); if (_data == null || _tablemapId == null) { return(NotFound()); } ITableFileAGSService _tableFileAGSService = new TableFileAGSService(); IAGSGroupTables _ags_tables = await _tableFileAGSService.CreateAGS(Id, tablemapId, agstables, options, _dataTableFileService); if (save == true) { await _dataAGSService.CreateData(_data.projectId, _user.Id, _ags_tables, _data.FileNameNoExtention() + ".ags", $"AGS Conversion from data table {_data.filename} using table map {_tablemapId.filename}", "ags"); } if (format == "view") { return(View(_ags_tables)); } return(Ok(_ags_tables)); }
public async Task <IActionResult> ProcessFileToAGS(Guid Id, Guid?templateId, string table, string sheet, Guid?tablemapId, string[] agstables, Guid?agslibraryId, string options = "", string format = "view", Boolean save = false) { Boolean save_file = true; Boolean save_ags = save; if (options == null) { options = ""; } if (options.Contains("background")) { if (save == true && !options.Contains("save_ags")) { options += ",save_ags"; } return(await ProcessFileBackground(Id, templateId, table, sheet, tablemapId, agstables, options)); } if (options.Contains("read_file_only")) { save_file = false; } var calc_resp = await ReadFile(Id, templateId.Value, table, sheet, "", save_file); var okResult = calc_resp as OkObjectResult; if (okResult == null) { var vwResult = calc_resp as ViewResult; if (vwResult == null) { return(Json(calc_resp)); } return(calc_resp); // return View ("OperationRequest",calc_resp); } ge_data_table _dt_file = okResult.Value as ge_data_table; if (options.Contains("view_file")) { if (format == "view") { return(View("ReadData", _dt_file)); } if (format == "json") { return(Json(_dt_file)); } return(Ok(_dt_file)); } if (save_file == false) { ITableFileAGSService _tableFileAGSService = new TableFileAGSService(); ge_table_map _tm = await _dataTableFileService.GetFileAsClass <ge_table_map>(tablemapId.Value); if (_tm == null) { return(Json($"table map for field not found for id={tablemapId.Value}")); } IAGSGroupTables _ags_tables = _tableFileAGSService.CreateAGS(_dt_file, _tm, agstables, options); if (agslibraryId != null) { await _dataAGSService.SetLibraryAGSData(agslibraryId.Value, null); } await _dataAGSService.AddLibraryAGSData(_ags_tables, null); if (save_ags == true) { var _data = await _dataTableFileService.GetDataByIdWithAll(Id); var _tablemap = await _dataTableFileService.GetDataByIdWithAll(tablemapId.Value); var _user = await GetUserAsync(); await _dataAGSService.CreateData(_data.projectId, _user.Id, _ags_tables, _data.FileNameNoExtention() + ".ags", $"AGS Conversion from data table {_data.filename} using table map {_tablemap.filename}", "ags"); } if (format == "view") { return(View(_ags_tables)); } if (format == "json") { return(Json(_ags_tables)); } return(Ok(_ags_tables)); // return await View (mond, format); } return(await CreateAGS(Id, tablemapId.Value, agstables, options, format, save_ags)); }