修复sql错误导致程序崩溃的问题

This commit is contained in:
2023-05-19 11:24:18 +08:00
parent 0670387658
commit 23dd5a7604
4 changed files with 40 additions and 18 deletions

View File

@@ -300,8 +300,8 @@ public class DataBaseManager : IDataBaseManager, ITransient
{
if (link != null && _sqlSugarClient.CurrentConnectionConfig.ConfigId != link.Id) _sqlSugarClient = ChangeDataBase(link);
try
{
//try
//{
int total = 0;
if (_sqlSugarClient.CurrentConnectionConfig.DbType == SqlSugar.DbType.Oracle) strSql = strSql.Replace(";", string.Empty);
@@ -316,7 +316,7 @@ public class DataBaseManager : IDataBaseManager, ITransient
if (pageInput.superQueryJson.IsNotEmptyOrNull()) superQueryJson = _sqlSugarClient.Utilities.JsonToConditionalModels(pageInput.superQueryJson);
// var sql = _sqlSugarClient.SqlQueryable<object>(strSql)
// .Where(querJson).Where(superQueryJson).Where(dataPermissions).ToSqlString();
DataTable dt = _sqlSugarClient.CopyNew().SqlQueryable<object>(strSql)
DataTable dt = _sqlSugarClient.SqlQueryable<object>(strSql)
.Where(querJson).Where(superQueryJson).Where(dataPermissions)
.OrderByIF(sidx, pageInput.sidx + " " + pageInput.sort).OrderByIF(!sidx && defaultSidx, columnDesign.defaultSidx + " " + columnDesign.sort)
.ToDataTablePage(pageInput.currentPage, pageInput.pageSize, ref total);
@@ -339,11 +339,11 @@ public class DataBaseManager : IDataBaseManager, ITransient
},
list = dt.ToObject<List<Dictionary<string, string>>>().ToObject<List<Dictionary<string, object>>>()
};
}
catch (Exception ex)
{
throw;
}
//}
//catch (Exception ex)
//{
// throw;
//}
}
/// <summary>
@@ -419,7 +419,7 @@ WHERE pcolumn.table_name='{0}' ORDER BY ordinal_position";
{
if (link != null && _sqlSugarClient.CurrentConnectionConfig.ConfigId != link.Id) _sqlSugarClient = ChangeDataBase(link);
return _sqlSugarClient.CopyNew().DbMaintenance.GetPrimaries(tableName);
return _sqlSugarClient.DbMaintenance.GetPrimaries(tableName);
}
/// <summary>

View File

@@ -1106,6 +1106,13 @@ public enum ErrorCode
[ErrorCodeItemMetadata("该流程已发起,无法删除")]
D1417,
/// <summary>
/// 该功能不存在,可能已被删除.
/// </summary>
[ErrorCodeItemMetadata("该功能( id: {0} )不存在,可能已被删除")]
D1418,
#endregion
#region 15

View File

@@ -1892,16 +1892,27 @@ public class FormDataParsing : ITransient
sort = columnDesign.sort,
pageSize = 999999
};
Scoped.Create(async (_, scope) =>
{
var services = scope.ServiceProvider;
var _runService = App.GetService<IRunService>(services);
var res = await _runService.GetRelationFormList(relationFormModel, listQueryInput);
_cacheManager.Set(redisName, res.list.ToList(), TimeSpan.FromMinutes(10)); // 缓存10分钟
});
//Scoped.Create(async (_, scope) =>
//{
// var services = scope.ServiceProvider;
// var _runService = App.GetService<IRunService>(services);
// var res = await _runService.GetRelationFormList(relationFormModel, listQueryInput);
// _cacheManager.Set(redisName, res.list.ToList(), TimeSpan.FromMinutes(10)); // 缓存10分钟
//});
var cacheStr = _cacheManager.Get(redisName);
if (cacheStr.IsNotEmptyOrNull()) relationFormDataList = _cacheManager.Get(redisName).ToObject<List<Dictionary<string, object>>>();
//modified by PhilPan
if (string.IsNullOrEmpty(cacheStr))
{
await Scoped.CreateAsync(async (_, scope) =>
{
var services = scope.ServiceProvider;
var _runService = App.GetService<IRunService>(services);
var res = await _runService.GetRelationFormList(relationFormModel, listQueryInput);
_cacheManager.Set(redisName, res.list.ToList(), TimeSpan.FromMinutes(10)); // 缓存10分钟
cacheStr = _cacheManager.Get(redisName);
});
}
if (cacheStr.IsNotEmptyOrNull()) relationFormDataList = cacheStr.ToObject<List<Dictionary<string, object>>>();
}
var relationFormRealData = relationFormDataList.Where(it => it["id"].Equals(dataMap[key])).FirstOrDefault();

View File

@@ -175,6 +175,8 @@ public class VisualDevService : IVisualDevService, IDynamicApiController, ITrans
public async Task<dynamic> GetFormDataFields(string id)
{
VisualDevEntity? templateEntity = await _visualDevRepository.AsQueryable().FirstAsync(v => v.Id == id && v.DeleteMark == null);
//modified by PhilPan
if (templateEntity == null) throw Oops.Oh(ErrorCode.D1418, id);
TemplateParsingBase? tInfo = new TemplateParsingBase(templateEntity); // 解析模板
List<FieldsModel>? fieldsModels = tInfo.SingleFormData.FindAll(x => x.__vModel__.IsNotEmptyOrNull() && !JnpfKeyConst.RELATIONFORM.Equals(x.__config__.jnpfKey));
List<VisualDevFormDataFieldsOutput>? output = fieldsModels.Select(x => new VisualDevFormDataFieldsOutput()
@@ -198,6 +200,8 @@ public class VisualDevService : IVisualDevService, IDynamicApiController, ITrans
if (!string.IsNullOrWhiteSpace(input.relationField) && !string.IsNullOrWhiteSpace(input.keyword)) queryDic.Add(input.relationField, input.keyword);
VisualDevEntity? templateEntity = await _visualDevRepository.AsQueryable().FirstAsync(v => v.Id == id && v.DeleteMark == null); // 取数据
//modified by PhilPan
if (templateEntity == null) throw Oops.Oh(ErrorCode.D1418, id);
TemplateParsingBase? tInfo = new TemplateParsingBase(templateEntity); // 解析模板
// 指定查询字段