Breakpoint
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
using Godot;
|
||||
using System;
|
||||
using BITKit;
|
||||
|
||||
namespace BITFactory;
|
||||
@@ -37,13 +36,20 @@ public partial class CourseElement : Node
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (CurrentScene?.Name == CourseScene?.ResourceName)
|
||||
{
|
||||
BIT4Log.Log<CourseElement>($"已返回当前课程");
|
||||
UXService.Open(CurrentScene as Control);
|
||||
return;
|
||||
}
|
||||
if (CurrentScene is not null)
|
||||
{
|
||||
BIT4Log.Log<CourseElement>($"正在释放课程:\t{CurrentScene.Name}");
|
||||
CurrentScene.QueueFree();
|
||||
BIT4Log.Log<CourseElement>($"已释放当前课程:\t{CurrentScene.Name}");
|
||||
}
|
||||
CurrentScene = CourseScene.Instantiate();
|
||||
CurrentScene = CourseScene!.Instantiate();
|
||||
GetTree().Root.AddChild(CurrentScene);
|
||||
UXService.Open(CurrentScene as Control);
|
||||
BIT4Log.Log<CourseElement>($"已加载新的课程:\t{CurrentScene.Name}");
|
||||
|
@@ -2,6 +2,7 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Diagnostics;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using BITKit;
|
||||
@@ -36,6 +37,7 @@ public class SearchResult:ISearchEntry
|
||||
public interface ISearchEngine
|
||||
{
|
||||
SearchResult[] GetSearchResults(string key);
|
||||
void SaveChanges();
|
||||
void Add(SearchResult result);
|
||||
void Remove(string key, string id);
|
||||
}
|
||||
@@ -91,11 +93,22 @@ public partial class SearchEngine:Node,ISearchEngine
|
||||
QueueContainerFree();
|
||||
searchProgressBar.Show();
|
||||
var list = await Context.context.ToListAsync();
|
||||
Spawn(string.IsNullOrEmpty(key) ? list : list.Where(x => x.Key.Contains(key)));
|
||||
var result = (string.IsNullOrEmpty(key) ? list : list.Where(x => x.Key.Contains(key))).ToArray();
|
||||
|
||||
//Fallback
|
||||
if (result.Any() is false)
|
||||
{
|
||||
result = list.Where(x => x.Display.Contains(key!)).ToArray();
|
||||
}
|
||||
if (result.Any() is false)
|
||||
{
|
||||
result = list.Where(x => x.Id.Contains(key!)).ToArray();
|
||||
}
|
||||
|
||||
Spawn(result);
|
||||
_logBuilder.AppendLine($"已获取到集合");
|
||||
_logBuilder.AppendLine($"{string.Join("\n",list)}");
|
||||
searchProgressBar.Hide();
|
||||
//searchLogLabel.Text = _logBuilder.ToString();
|
||||
}
|
||||
|
||||
private void QuickSearch()
|
||||
@@ -109,12 +122,6 @@ public partial class SearchEngine:Node,ISearchEngine
|
||||
var index = i;
|
||||
var element = searchResults[i];
|
||||
quickSearchButton.GetPopup().AddItem(element.Key);
|
||||
// quickSearchButton.GetPopup().IdPressed = id =>
|
||||
// {
|
||||
// var entry = searchResults[index];
|
||||
// searchInput.Text = entry.Key;
|
||||
// Search(entry.Key);
|
||||
// };
|
||||
}
|
||||
}
|
||||
private void OnPressedIndex(long index)
|
||||
@@ -133,6 +140,9 @@ public partial class SearchEngine:Node,ISearchEngine
|
||||
|
||||
instance.titleLabel.Text = entry.Display ?? entry.Id ?? entry.Key;
|
||||
instance.Text = entry.Value;
|
||||
instance.updateTimeLabel.Text = entry.UpdateDate.ToString(CultureInfo.InvariantCulture);
|
||||
instance.createTimeLabel.Text = entry.CreateDate.ToString(CultureInfo.InvariantCulture);
|
||||
instance.headerLabel.Text = entry.Key;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -145,6 +155,7 @@ public partial class SearchEngine:Node,ISearchEngine
|
||||
}
|
||||
|
||||
public SearchResult[] GetSearchResults(string key)=>Context.context.Where(x=>x.Key.Contains(key)).ToArray();
|
||||
public void SaveChanges() => Context.SaveChanges();
|
||||
|
||||
public void Add(SearchResult result)
|
||||
{
|
||||
|
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using BITKit;
|
||||
using Godot;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
@@ -13,6 +14,7 @@ public partial class SearchRegister:Node
|
||||
[Export] private LineEdit idLine;
|
||||
[Export] private LineEdit registryRecordLine;
|
||||
[Export] private Button registryButton;
|
||||
[Export] private RichTextLabel registryResultLabel;
|
||||
public override void _Ready()
|
||||
{
|
||||
registryButton.Pressed += Create;
|
||||
@@ -20,16 +22,51 @@ public partial class SearchRegister:Node
|
||||
|
||||
private void Create()
|
||||
{
|
||||
var result = new SearchResult()
|
||||
var searchEngine = DI.Get<ISearchEngine>();
|
||||
registryResultLabel.Text = $"正在注册标识";
|
||||
|
||||
var current = searchEngine
|
||||
.GetSearchResults(keyLine.Text)
|
||||
.Where(x=>x.Key == keyLine.Text && x.Id == idLine.Text)
|
||||
;
|
||||
|
||||
SearchResult result=default;
|
||||
|
||||
var searchResults = current as SearchResult[] ?? current.ToArray();
|
||||
if (searchResults.Any())
|
||||
{
|
||||
Key = keyLine.Text,
|
||||
Value = valueLine.Text,
|
||||
Display = nameLine.Text,
|
||||
Id = idLine.Text,
|
||||
RegistryRecord = registryRecordLine.Text,
|
||||
CreateDate = DateTime.Now,
|
||||
UpdateDate = DateTime.Now,
|
||||
};
|
||||
DI.Get<ISearchEngine>().Add(result);
|
||||
result = searchResults.First();
|
||||
result.Value = valueLine.Text;
|
||||
result.Display = nameLine.Text;
|
||||
result.RegistryRecord = registryRecordLine.Text;
|
||||
result.UpdateDate = DateTime.Now;
|
||||
|
||||
searchEngine.SaveChanges();
|
||||
|
||||
registryResultLabel.Text = $"标识:{result.Key}已完成更新";
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
result = new SearchResult()
|
||||
{
|
||||
Key = keyLine.Text,
|
||||
Value = valueLine.Text,
|
||||
Display = nameLine.Text,
|
||||
Id = idLine.Text,
|
||||
RegistryRecord = registryRecordLine.Text,
|
||||
CreateDate = DateTime.Now,
|
||||
UpdateDate = DateTime.Now,
|
||||
};
|
||||
try
|
||||
{
|
||||
registryResultLabel.Text = $"标识:{result.Key}已完成注册";
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
registryResultLabel.Text = $"标识:{result.Key}注册失败,原因:\n{e.Message}";
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user