| | |
| | | using Microsoft.AspNetCore.Http; |
| | | using Microsoft.AspNetCore.Mvc.RazorPages; |
| | | using Microsoft.Extensions.Options; |
| | | using Newtonsoft.Json; |
| | | using OfficeOpenXml.FormulaParsing.Excel.Functions.Text; |
| | | using SqlSugar; |
| | | using System.Drawing.Drawing2D; |
| | |
| | | Dictionary<string, OrderByType> orderbyDic = GetPageDataSort(options, TProperties); |
| | | |
| | | PageGridData<TEntity> pageGridData = new PageGridData<TEntity>(); |
| | | //if (QueryRelativeExpression != null) |
| | | //{ |
| | | // queryable = QueryRelativeExpression.Invoke(queryable); |
| | | //} |
| | | //if (options.Export) |
| | | //{ |
| | | // queryable = queryable.GetIQueryableOrderBy(orderbyDic); |
| | | // if (Limit > 0) |
| | | // { |
| | | // queryable = queryable.Take(Limit); |
| | | // } |
| | | // pageGridData.rows = queryable.ToList(); |
| | | //} |
| | | //else |
| | | //{ |
| | | // pageGridData.rows = repository.IQueryablePage(queryable, |
| | | // options.Page, |
| | | // options.Rows, |
| | | // out int rowCount, |
| | | // orderbyDic).ToList(); |
| | | // pageGridData.total = rowCount; |
| | | // //查询界面统计求等字段 |
| | | // if (SummaryExpress != null) |
| | | // { |
| | | // pageGridData.summary = SummaryExpress.Invoke(queryable); |
| | | // //Func<T, T> groupExpress = x =>x; |
| | | // //pageGridData.summary = queryable.GroupBy(groupExpress).Select(SummaryExpress).FirstOrDefault(); |
| | | // } |
| | | //} |
| | | //GetPageDataOnExecuted?.Invoke(pageGridData); |
| | | |
| | | pageGridData = BaseDal.QueryPage(wheres, options.Page, options.Rows, orderbyDic); |
| | | |
| | | return pageGridData; |
| | |
| | | } |
| | | } |
| | | TEntity entity = saveModel.MainData.DicToModel<TEntity>(); |
| | | if (saveModel.DetailData == null && saveModel.DetailData.Count == 0) |
| | | if (saveModel.DetailData == null || saveModel.DetailData.Count == 0) |
| | | { |
| | | BaseDal.AddData(entity); |
| | | return WebResponseContent.Instance.OK(); |
| | |
| | | } |
| | | |
| | | Type detailType = typeof(TEntity).GetDetailType(); |
| | | MethodInfo? methodInfo = GetType().GetMethod("AddDataIncludesDetail"); |
| | | MethodInfo? methodInfo = GetType().GetMethod(nameof(AddDataIncludesDetail)); |
| | | methodInfo = methodInfo?.MakeGenericMethod(new Type[] { detailType }); |
| | | object? obj = methodInfo?.Invoke(this, new object[] { entity, detailType, saveModel.DetailData }); |
| | | return obj as WebResponseContent; |
| | |
| | | |
| | | TEntity entity = saveModel.MainData.DicToModel<TEntity>(); |
| | | |
| | | List<string> listCol = new List<string>(); |
| | | foreach (var item in saveModel.MainData) |
| | | { |
| | | PropertyInfo propertyInfo = typeof(TEntity).GetProperty(item.Key); |
| | | if (propertyInfo == null) |
| | | { |
| | | propertyInfo = typeof(TEntity).GetProperty(item.Key.FirstLetterToLower()); |
| | | if (propertyInfo == null) |
| | | { |
| | | propertyInfo = typeof(TEntity).GetProperty(item.Key.FirstLetterToUpper()); |
| | | } |
| | | } |
| | | //List<string> listCol = new List<string>(); |
| | | //foreach (var item in saveModel.MainData) |
| | | //{ |
| | | // PropertyInfo propertyInfo = typeof(TEntity).GetProperty(item.Key); |
| | | // if (propertyInfo == null) |
| | | // { |
| | | // propertyInfo = typeof(TEntity).GetProperty(item.Key.FirstLetterToLower()); |
| | | // if (propertyInfo == null) |
| | | // { |
| | | // propertyInfo = typeof(TEntity).GetProperty(item.Key.FirstLetterToUpper()); |
| | | // } |
| | | // } |
| | | |
| | | listCol.Add(propertyInfo?.Name); |
| | | } |
| | | // listCol.Add(propertyInfo?.Name); |
| | | //} |
| | | |
| | | if (saveModel.DetailData == null && saveModel.DetailData.Count == 0) |
| | | if (saveModel.DetailData == null || saveModel.DetailData.Count == 0) |
| | | { |
| | | if (list != null) |
| | | listCol = listCol.Where(x => !list.Contains(x)).ToList(); |
| | | bool result = BaseDal.UpdateData(entity, listCol, list); |
| | | //if (list != null) |
| | | // listCol = listCol.Where(x => !list.Contains(x)).ToList(); |
| | | bool result = BaseDal.UpdateData(entity); |
| | | return WebResponseContent.Instance.OK(); |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | Type detailType = typeof(TEntity).GetDetailType(); |
| | | MethodInfo? methodInfo = GetType().GetMethod("UpdateDataInculdesDetail"); |
| | | MethodInfo? methodInfo = GetType().GetMethod(nameof(UpdateDataInculdesDetail)); |
| | | methodInfo = methodInfo?.MakeGenericMethod(new Type[] { detailType }); |
| | | object? obj = methodInfo?.Invoke(this, new object[] { entity, detailType, saveModel.DetailData, saveModel.DelKeys }); |
| | | return obj as WebResponseContent; |
| | |
| | | content = WebResponseContent.Instance.OK(data: savePath + "\\" + fileName); |
| | | return content; |
| | | } |
| | | |
| | | public WebResponseContent ExportSeedData() |
| | | { |
| | | WebResponseContent content = new WebResponseContent(); |
| | | try |
| | | { |
| | | string seedDataFolder = $"WIDESEAWCS_DB.DBSeed.Json/{typeof(TEntity).Name}.tsv"; |
| | | List<TEntity> deviceInfos = BaseDal.QueryData(); |
| | | string str = JsonConvert.SerializeObject(deviceInfos, Formatting.Indented); |
| | | List<Dictionary<string, object>> keyValuePairs = JsonConvert.DeserializeObject<List<Dictionary<string, object>>>(str); |
| | | FileHelper.WriteFileAndDelOldFile($"{AppDomain.CurrentDomain.BaseDirectory}wwwroot/{seedDataFolder}", str); |
| | | content = WebResponseContent.Instance.OK(); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | content = WebResponseContent.Instance.Error(ex.Message); |
| | | } |
| | | return content; |
| | | } |
| | | } |
| | | } |