From 9ffd50c8ed26e0be4ccdb500f261132c19600e96 Mon Sep 17 00:00:00 2001
From: hutongqing <hutongqing@hnkhzn.com>
Date: 星期二, 03 九月 2024 15:34:59 +0800
Subject: [PATCH] 增加注释

---
 WIDESEAWCS_Server/WIDESEAWCS_Core/BaseServices/ServiceBase.cs |   57 +++++++++++++++++++++++----------------------------------
 1 files changed, 23 insertions(+), 34 deletions(-)

diff --git a/WIDESEAWCS_Server/WIDESEAWCS_Core/BaseServices/ServiceBase.cs b/WIDESEAWCS_Server/WIDESEAWCS_Core/BaseServices/ServiceBase.cs
index d72dc1e..8f5d041 100644
--- a/WIDESEAWCS_Server/WIDESEAWCS_Core/BaseServices/ServiceBase.cs
+++ b/WIDESEAWCS_Server/WIDESEAWCS_Core/BaseServices/ServiceBase.cs
@@ -4,6 +4,7 @@
 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;
@@ -53,37 +54,6 @@
             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;
@@ -122,7 +92,7 @@
                 if (property == null) continue;
 
                 List<(bool, string, object)> results = property.ValidationValueForDbType(searchParametersList[i].Value.Split(',')).ToList();
-                if (results == null || results.Count() == 0)
+                if (results == null || results.Count() > 0)
                 {
                     continue;
                 }
@@ -281,7 +251,7 @@
                     }
                 }
                 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();
@@ -419,7 +389,7 @@
                     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();
@@ -735,5 +705,24 @@
             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;
+        }
     }
 }

--
Gitblit v1.9.3