|
@@ -1,6 +1,8 @@
|
|
|
using HyperCube.Models;
|
|
|
using Microsoft.AspNetCore.Components;
|
|
|
+using Microsoft.AspNetCore.Components.Authorization;
|
|
|
using Microsoft.AspNetCore.Components.Forms;
|
|
|
+using Microsoft.AspNetCore.Identity;
|
|
|
using Pullenti.Unitext;
|
|
|
using System;
|
|
|
using System.Collections.Generic;
|
|
@@ -18,10 +20,17 @@ namespace HyperCube.Pages
|
|
|
{
|
|
|
public partial class Desktop : ComponentBase
|
|
|
{
|
|
|
+ [Parameter]
|
|
|
+ public int DocID { get; set; }
|
|
|
+
|
|
|
+ [Inject]
|
|
|
+ NavigationManager NavigationManager { get; set; }
|
|
|
[Inject]
|
|
|
- NavigationManager _navigationManager { get; set; }
|
|
|
+ AuthenticationStateProvider AuthenticationStateProvider { get; set; }
|
|
|
[Inject]
|
|
|
- AppData _appData { get; set; }
|
|
|
+ UserManager<IdentityUser> UserManager { get; set; }
|
|
|
+ [Inject]
|
|
|
+ AppData AppData { get; set; }
|
|
|
|
|
|
const string STORAGE_FOLDER_NAME = "articles_storage";
|
|
|
const long MAX_FILE_SIZE = 5120000; //bytes
|
|
@@ -40,7 +49,7 @@ namespace HyperCube.Pages
|
|
|
|
|
|
int _counter = 1;
|
|
|
|
|
|
- //string _event = "";
|
|
|
+ string _event = "";
|
|
|
string _status;
|
|
|
//string _header;
|
|
|
//string _storageFolderPath;
|
|
@@ -53,10 +62,15 @@ namespace HyperCube.Pages
|
|
|
|
|
|
UnitextDocument _document;
|
|
|
|
|
|
+ AccountModel _currentAccount;
|
|
|
+
|
|
|
protected override async Task OnInitializedAsync()
|
|
|
{
|
|
|
///tmp
|
|
|
await AppData.LoadArticles();
|
|
|
+
|
|
|
+ _currentAccount = await GetCurrentAcc();
|
|
|
+ Console.WriteLine($"Account: {_currentAccount.Name}");
|
|
|
}
|
|
|
protected override void OnAfterRender(bool firstRender) => _counter = 1;
|
|
|
|
|
@@ -116,7 +130,7 @@ namespace HyperCube.Pages
|
|
|
|
|
|
if (count < 1)
|
|
|
{
|
|
|
- ReportModel report = _appData.Report;
|
|
|
+ ReportModel report = AppData.Report;
|
|
|
report.FileName = file.Name;
|
|
|
report.FileSize = _memoryStream.Length.ToString();
|
|
|
|
|
@@ -182,7 +196,7 @@ namespace HyperCube.Pages
|
|
|
|
|
|
// запускаем обработку на пустом процессоре (без анализаторов NER)
|
|
|
Pullenti.Ner.AnalysisResult are = Pullenti.Ner.ProcessorService.EmptyProcessor.Process(new Pullenti.Ner.SourceOfAnalysis(plainText), null, null);
|
|
|
- System.Console.Write("Noun groups: ");
|
|
|
+ //System.Console.Write("Noun groups: ");
|
|
|
// перебираем токены
|
|
|
for (Pullenti.Ner.Token t = are.FirstToken; t != null; t = t.Next)
|
|
|
{
|
|
@@ -276,7 +290,7 @@ namespace HyperCube.Pages
|
|
|
//Console.WriteLine($"Name: {result.Name}, Count: {result.Count}");
|
|
|
}
|
|
|
|
|
|
- _navigationManager.NavigateTo("report");
|
|
|
+ NavigationManager.NavigateTo("report");
|
|
|
}
|
|
|
else
|
|
|
{
|
|
@@ -328,7 +342,7 @@ namespace HyperCube.Pages
|
|
|
int action_type = DocID > 0 ? 2 : 1;
|
|
|
|
|
|
stringSQL = $"INSERT INTO actions_history (article_id, action_type, acc_id) " +
|
|
|
- $"VALUES ('{id}', '{action_type}', '{currentAcc.UUID}')";
|
|
|
+ $"VALUES ('{id}', '{action_type}', '{_currentAccount.UUID}')";
|
|
|
await dbCon.SQLInsert(stringSQL);
|
|
|
|
|
|
Dictionary<string, PropertyInfo> propDict = Compare.SimpleCompare<ArticleModel>(_article, _articleClone);
|
|
@@ -337,7 +351,7 @@ namespace HyperCube.Pages
|
|
|
//Console.WriteLine($"property name: {prop.Key}, value: {prop.Value.GetValue(articleModel, null)}");
|
|
|
|
|
|
stringSQL = $"INSERT INTO articles_edit_log (article_id, acc_id, field_name, field_prevvalue, field_newvalue) " +
|
|
|
- $"VALUES ('{id}', '{currentAcc.UUID}', '{prop.Key}', '{prop.Value.GetValue(_articleClone, null)}', '{prop.Value.GetValue(_article, null)}')";
|
|
|
+ $"VALUES ('{id}', '{_currentAccount.UUID}', '{prop.Key}', '{prop.Value.GetValue(_articleClone, null)}', '{prop.Value.GetValue(_article, null)}')";
|
|
|
await dbCon.SQLInsert(stringSQL);
|
|
|
}
|
|
|
|
|
@@ -427,5 +441,25 @@ namespace HyperCube.Pages
|
|
|
.GetCustomAttribute<DisplayAttribute>()
|
|
|
.GetName();
|
|
|
}
|
|
|
+
|
|
|
+ async Task<AccountModel> GetCurrentAcc()
|
|
|
+ {
|
|
|
+ if (_currentAccount == null)
|
|
|
+ {
|
|
|
+ var authState = await AuthenticationStateProvider.GetAuthenticationStateAsync();
|
|
|
+ var user = authState.User;
|
|
|
+
|
|
|
+ if (user.Identity.IsAuthenticated)
|
|
|
+ {
|
|
|
+ ///tmp
|
|
|
+ Dictionary<string, AccountModel> accounts = await MySQLConnector.Instance().SQLSelectASPUsers();
|
|
|
+
|
|
|
+ var currentUser = await UserManager.GetUserAsync(user);
|
|
|
+ if (accounts.ContainsKey(currentUser.Id))
|
|
|
+ _currentAccount = accounts[currentUser.Id];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return _currentAccount;
|
|
|
+ }
|
|
|
}
|
|
|
}
|