Skip to content

Commit 3b80faf

Browse files
author
yangzhiqin
committed
代码优化
1 parent aa798ca commit 3b80faf

File tree

12 files changed

+300
-101
lines changed

12 files changed

+300
-101
lines changed

OMDb.Core/Services/DataCenterDbService/EntryLabelClassService.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public static class EntryLabelClassService
1818
public static List<EntryLabelClassLinkDb> SelectAllEntryLabel()
1919
{
2020
StringBuilder sb = new StringBuilder();
21-
sb.AppendFormat(@"select * from EntryLabel ");
21+
sb.AppendFormat(@"select * from EntryLabelClassLink ");
2222
return DbService.DCDb.Ado.SqlQuery<EntryLabelClassLinkDb>(sb.ToString());
2323
}
2424

@@ -31,7 +31,7 @@ public static List<EntryLabelClassLinkDb> SelectAllEntryLabel()
3131
public static List<EntryLabelClassLinkDb> SelectAllEntryLabel(string dbId)
3232
{
3333
StringBuilder sb = new StringBuilder();
34-
sb.AppendFormat($@"select * from EntryLabel where DbId='{dbId}'");
34+
sb.AppendFormat($@"select * from EntryLabelClassLink where DbId='{dbId}'");
3535
return DbService.DCDb.Ado.SqlQuery<EntryLabelClassLinkDb>(sb.ToString());
3636
}
3737

OMDb.Core/Services/DataCenterDbService/EntryLabelPropertyService.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public static class EntryLabelPropertyService
1818
public static List<EntryLabelPropertyLinkDb> SelectAllEntryLabel()
1919
{
2020
StringBuilder sb = new StringBuilder();
21-
sb.AppendFormat(@"select * from EntryLabel ");
21+
sb.AppendFormat(@"select * from EntryLabelPropertyLink");
2222
return DbService.DCDb.Ado.SqlQuery<EntryLabelPropertyLinkDb>(sb.ToString());
2323
}
2424

@@ -31,7 +31,7 @@ public static List<EntryLabelPropertyLinkDb> SelectAllEntryLabel()
3131
public static List<EntryLabelPropertyLinkDb> SelectAllEntryLabel(string dbId)
3232
{
3333
StringBuilder sb = new StringBuilder();
34-
sb.AppendFormat($@"select * from EntryLabel where DbId='{dbId}'");
34+
sb.AppendFormat($@"select * from EntryLabelPropertyLink where DbId='{dbId}'");
3535
return DbService.DCDb.Ado.SqlQuery<EntryLabelPropertyLinkDb>(sb.ToString());
3636
}
3737

OMDb.Core/Services/DataCenterDbService/LabelPropertyService.cs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,12 @@ public static async Task<List<LabelPropertyDb>> GetAllLabelAsync(string currentD
4747
else return null;
4848
}
4949

50-
50+
public static List<LabelPropertyDb> Get1stLabel()
51+
{
52+
if (IsLocalDbValid())
53+
return DbService.DCDb.Queryable<LabelPropertyDb>().Where(a=>a.Level==1).ToList();
54+
else return null;
55+
}
5156

5257
/// <summary>
5358
/// 获取属性标签数量
@@ -279,7 +284,7 @@ public static List<string> GetLKId(string DbCenterId, string lpid)
279284
var lst1 = DbService.DCDb.Ado.SqlQuery<string>(sb1.ToString());
280285
var lst2 = DbService.DCDb.Ado.SqlQuery<string>(sb2.ToString());
281286
lst1.AddRange(lst2);
282-
var lst=lst1.Distinct();
287+
var lst = lst1.Distinct();
283288
return lst.ToList();
284289
}
285290

@@ -291,7 +296,10 @@ public static List<string> GetLKId(string DbCenterId, string lpid)
291296
/// <returns></returns>
292297
public static void ClearLabelPropertyLK(string DbCenterId, string lpid)
293298
{
294-
DbService.DCDb.Deleteable<LabelPropertyLinkDb>(p => p.LPIdA == lpid||p.LPIdB==lpid).ExecuteCommand();
299+
DbService.DCDb.Deleteable<LabelPropertyLinkDb>(p => p.LPIdA == lpid || p.LPIdB == lpid).ExecuteCommand();
295300
}
301+
302+
303+
296304
}
297305
}

OMDb.Core/Services/StorageDbService/EntryCommonService.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public static List<dynamic> SelectEntry(string dbId)
2121
sb.AppendFormat(@"select
2222
t13.Eid,NameStr,ReleaseDate,MyRating,SaveType,path_entry,path_cover,path_source from
2323
(select distinct t1.EntryId as Eid,t1.Path as path_entry,t1.SaveType,t1.CoverImg as path_cover,t1.ReleaseDate,t1.MyRating,group_concat(t3.path,'>,<') as path_source from Entry t1
24-
left join EntrySource t3 on t1.EntryId=t3.EntryId and ((t1.SaveType=t3.FileType) or (t1.SaveType=2 and t3.FileType!=1) or (t1.SaveType=3))
24+
left join EntrySource t3 on t1.EntryId=t3.EntryId and ((t1.SaveType=t3.PathType) or (t1.SaveType=2 and t3.PathType<>1) or (t1.SaveType=3))
2525
group by t1.EntryId) t13
2626
inner join
2727
(select distinct t1.EntryId as Eid,group_concat(t2.Name,'/') as NameStr from Entry t1

OMDb.Core/Services/StorageDbService/EntryService.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,7 @@ public static void UpdateOrAddEntry(Entry entry)
378378
entry.EntryId = Guid.NewGuid().ToString();
379379
entry.CoverImg = entry.CoverImg.GetDefaultCoverName();
380380
var existingEntry = DbService.GetConnection(entry.DbId).Queryable<EntryDb>().Where(s => s.EntryId == entry.EntryId).First();
381-
if (existingEntry != null)
381+
if (existingEntry == null)
382382
DbService.GetConnection(entry.DbId).Insertable(entry as EntryDb).ExecuteCommand();
383383
else
384384
DbService.GetConnection(entry.DbId).Updateable<EntryDb>(entry as EntryDb).RemoveDataCache().ExecuteCommand();
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
using CommunityToolkit.Mvvm.ComponentModel;
2+
using System;
3+
using System.Collections.Generic;
4+
using System.Collections.ObjectModel;
5+
using System.Linq;
6+
using System.Text;
7+
using System.Threading.Tasks;
8+
9+
namespace OMDb.WinUI3.Models
10+
{
11+
public class EntrySortInfoResult : ObservableObject
12+
{
13+
private string _title;
14+
public string Title
15+
{
16+
get => _title;
17+
set => SetProperty(ref _title, value);
18+
}
19+
20+
private string _sortType;
21+
public string SortType
22+
{
23+
get => _sortType;
24+
set => SetProperty(ref _sortType, value);
25+
}
26+
27+
public List<string> SortTypes= new List<string>() { "升序","降序"};
28+
29+
public EntrySortInfoResult(string title)
30+
{
31+
_title = title;
32+
_sortType = "升序";
33+
}
34+
}
35+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
using CommunityToolkit.Mvvm.ComponentModel;
2+
using System;
3+
using System.Collections.Generic;
4+
using System.Collections.ObjectModel;
5+
using System.Linq;
6+
using System.Text;
7+
using System.Threading.Tasks;
8+
9+
namespace OMDb.WinUI3.Models
10+
{
11+
public class EntrySortInfoTree : ObservableObject
12+
{
13+
private string _title;
14+
public string Title
15+
{
16+
get => _title;
17+
set => SetProperty(ref _title, value);
18+
}
19+
20+
private ObservableCollection<EntrySortInfoTree> _children;
21+
public ObservableCollection<EntrySortInfoTree> Children
22+
{
23+
get => _children;
24+
set => SetProperty(ref _children, value);
25+
}
26+
27+
public EntrySortInfoTree(string title)
28+
{
29+
_title = title;
30+
}
31+
public EntrySortInfoTree()
32+
{
33+
34+
}
35+
}
36+
}

OMDb.WinUI3/OMDb.WinUI3/MyControls/StorageCard.xaml.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ private async void Export_Click(object sender, RoutedEventArgs e)
102102
//var outputPath = System.IO.Path.Combine(((OMDb.WinUI3.Models.EnrtyStorage)((Microsoft.UI.Xaml.FrameworkElement)e.OriginalSource).DataContext).StoragePath, name);
103103
var dbId = ((OMDb.WinUI3.Models.EnrtyStorage)((Microsoft.UI.Xaml.FrameworkElement)e.OriginalSource).DataContext).StorageName;
104104
var enrtyStorage = ((OMDb.WinUI3.Models.EnrtyStorage)((Microsoft.UI.Xaml.FrameworkElement)e.OriginalSource).DataContext);
105-
var outputPath = await Helpers.PickHelper.PickSaveFileAsync(".xlsx");
105+
var outputPath = await Helpers.PickHelper.PickSaveFileAsync(".xls");
106106
if (outputPath== null )
107107
{
108108
InfoHelper.ShowError("導出路徑有誤!");

OMDb.WinUI3/OMDb.WinUI3/Services/EntryService.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,10 +112,10 @@ private static async Task SaveToDbAsync(Models.EntryDetail ed)
112112
{
113113
await Task.Run(() =>
114114
{
115+
TreatEntry(ed);//处理词条主表Entry
115116
Core.Services.EntryService.UpdateOrAddEntry(ed.Entry);//词条
116117
Core.Services.EntryNameSerivce.UpdateOrAddDefaultNames(ed.Entry.EntryId, ed.Entry.DbId, ed.Entry.Name);//更新或插入词条默认名称
117118

118-
TreatEntry(ed);//处理词条主表Entry
119119
TreatEntrySource(ed);//资源路径表EntrySource更新
120120
TreatLabelLink(ed);//词条标签关联表
121121

OMDb.WinUI3/OMDb.WinUI3/Services/ExcelService.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@ public static void ExportExcel(string filePath, EnrtyStorage enrtyStorage)
152152
//DataTable的列名和excel的列名对应字典,因为excel的列名一般是中文的,DataTable的列名是英文的,字典主要是存储excel和DataTable列明的对应关系,当然我们也可以把这个对应关系存在配置文件或者其他地方
153153
Dictionary<string, string> dir = new Dictionary<string, string>();
154154
dir.Add("Name", "詞條名稱");
155+
dir.Add("Alias", "别稱");
155156
dir.Add("ReleaseDate", "發行日期");
156157
dir.Add("MyRating", "評分");
157158

0 commit comments

Comments
 (0)