-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
NianChen
authored and
NianChen
committed
Oct 19, 2022
1 parent
9dcd935
commit dbee25c
Showing
24 changed files
with
393 additions
and
112 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
using SQLite; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace AiPrompt.Data; | ||
|
||
public class BaseModel | ||
{ | ||
[PrimaryKey] | ||
public string Id { get; set; } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
using SQLite; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace AiPrompt.Data; | ||
|
||
public class Config:BaseModel{ | ||
public string SourcePath { get; set; } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
using AiPrompt.Data; | ||
|
||
namespace AiPrompt.Service; | ||
|
||
public interface IConfigService | ||
{ | ||
public Task SaveConfig(Config config); | ||
public Task<Config> GetConfig(); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
using AiPrompt.Data; | ||
using AiPrompt.Util; | ||
|
||
namespace AiPrompt.Service.Impl; | ||
|
||
public class ConfigService : IConfigService{ | ||
public ConfigService(Db db) | ||
{ | ||
this.db = db; | ||
} | ||
private readonly Db db; | ||
|
||
private string path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "config.json"); | ||
|
||
|
||
public async Task SaveConfig(Config config) | ||
{ | ||
config.Id = nameof(config); | ||
await db.SaveAsync(config); | ||
//using(var fs = new FileStream(path, FileMode.Create, FileAccess.Write)) | ||
//{ | ||
// try | ||
// { | ||
// await JsonSerializer.SerializeAsync<Config>(fs, config,new JsonSerializerOptions(){ WriteIndented = true }); | ||
// } | ||
// catch { } | ||
//} | ||
} | ||
|
||
public async Task<Config> GetConfig() | ||
{ | ||
return await db.GetAsync<Config>(); | ||
//using (var fs = new FileStream(path, FileMode.Open, FileAccess.Read)) | ||
//{ | ||
// try | ||
// { | ||
// var config = await JsonSerializer.DeserializeAsync<Config>(fs); | ||
// return config; | ||
// } | ||
// catch { return null; } | ||
|
||
//} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.