|
@@ -35,29 +35,17 @@
|
|
|
<p><InputTextArea rows="10" id="text" class="form-control" @bind-Value="articleModel.Text" placeholder="Текст" /></p>
|
|
|
|
|
|
@if (docID < 1)
|
|
|
- {
|
|
|
+ {
|
|
|
<p><button class="btn btn-primary" type="submit">Загрузить</button></p>
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- @*<p>
|
|
|
- <InputRadioGroup @bind-Value="articleModel.Status">
|
|
|
- Оценка:
|
|
|
- <br>
|
|
|
- @foreach (var status in (ArticleStatus[])Enum.GetValues(typeof(ArticleStatus)))
|
|
|
- {
|
|
|
- <InputRadio Value="status" />
|
|
|
- @status
|
|
|
- <br />
|
|
|
- }
|
|
|
- </InputRadioGroup>
|
|
|
- </p>*@
|
|
|
<p>
|
|
|
<InputRadioGroup @bind-Value="articleModel.Rating">
|
|
|
Оценка:
|
|
|
<br>
|
|
|
@for (int i = 1; i < 6; i++)
|
|
|
- {
|
|
|
+ {
|
|
|
<InputRadio Value="i" />
|
|
|
@i
|
|
|
<br />
|
|
@@ -66,10 +54,33 @@
|
|
|
</p>
|
|
|
<p>
|
|
|
<button class="btn btn-danger" type="button" @onclick="@Cancel">Отклонить</button>
|
|
|
- <button @onclick="Verify" class="btn btn-primary" type="submit">Утвердить</button>
|
|
|
+ <button class="btn btn-primary" type="submit">Утвердить</button>
|
|
|
</p>
|
|
|
}
|
|
|
<p>Статус: @status</p>
|
|
|
+
|
|
|
+ @*<button class="btn btn-primary" @onclick="() => modal.Open()">Modal!</button>*@
|
|
|
+ <Modal @ref="modal">
|
|
|
+ <Title>Результат операции</Title>
|
|
|
+ <Body>
|
|
|
+ <p>
|
|
|
+ Инициатор: <mark>@initiatorAcc.Name</mark> Сумма: овердофига <b>ETH</b><br>
|
|
|
+ Рейтинг статьи: @articleModel.Rating<br>
|
|
|
+ </p>
|
|
|
+ <p>
|
|
|
+ Верификатор: <mark>@currentAcc.Name</mark> Сумма: овердофига <b>ETH</b><br>
|
|
|
+ Кол-во исправлений: @editsCount
|
|
|
+ </p>
|
|
|
+ <p>
|
|
|
+ Вознаграждение системы: овердофига <b>ETH</b>.
|
|
|
+ </p>
|
|
|
+ </Body>
|
|
|
+ <Footer>
|
|
|
+ @*<button type="button" class="btn btn-primary">Save changes</button>*@
|
|
|
+ <button type="button" class="btn btn-secondary" data-dismiss="modal" @onclick="() => modal.Close()">Закрыть</button>
|
|
|
+ </Footer>
|
|
|
+ </Modal>
|
|
|
+
|
|
|
</div>
|
|
|
</EditForm>
|
|
|
|
|
@@ -79,18 +90,24 @@
|
|
|
|
|
|
const string FOLDER_NAME = "articles_storage";
|
|
|
const long MAX_FILE_SIZE = 5120000; //bytes
|
|
|
- //const int ACC_ID = 1; //temp
|
|
|
|
|
|
- ArticleModel oldArticleModel = new();
|
|
|
+ ArticleModel articleModelClone = new();
|
|
|
ArticleModel articleModel = new();
|
|
|
AccountModel currentAcc = new();
|
|
|
+ AccountModel initiatorAcc = new();
|
|
|
string status;
|
|
|
string header;
|
|
|
string storageFolderPath;
|
|
|
MemoryStream memoryStream;
|
|
|
+ Modal modal { get; set; }
|
|
|
+ int editsCount;
|
|
|
|
|
|
async Task Verify()
|
|
|
{
|
|
|
+ ///tmp
|
|
|
+ editsCount = await articleModel.GetEditsCount(currentAcc.UUID);
|
|
|
+ modal.Open();
|
|
|
+
|
|
|
try
|
|
|
{
|
|
|
VerifyContract verifyContract = SmartContract.Find("Verify") as VerifyContract;
|
|
@@ -127,11 +144,13 @@
|
|
|
$"JOIN actions_history ON actions_history.article_id = articles.id " +
|
|
|
$"WHERE articles.id={docID} " +
|
|
|
$"ORDER BY actions_history.id DESC LiMIT 1";
|
|
|
- oldArticleModel = await dbCon.SQLSelectArticle(stringSQL);
|
|
|
- articleModel = (ArticleModel)oldArticleModel.Clone();
|
|
|
+ articleModelClone = await dbCon.SQLSelectArticle(stringSQL);
|
|
|
+ articleModel = (ArticleModel)articleModelClone.Clone();
|
|
|
|
|
|
string initiator = await articleModel.GetInitiatorUUID();
|
|
|
- status = $"Article ID={docID} loaded, status: {articleModel.Status}, initiatorUUID: {await articleModel.GetInitiatorUUID()}";
|
|
|
+ initiatorAcc = AccountModel.Find(initiator);
|
|
|
+ status = $"Article ID={docID} loaded, status: {articleModel.Status}, initiator: {initiatorAcc.Name}";
|
|
|
+
|
|
|
}
|
|
|
else
|
|
|
header = "Загрузка материала";
|
|
@@ -175,13 +194,13 @@
|
|
|
$"VALUES ('{id}', '{action_type}', '{currentAcc.UUID}')";
|
|
|
dbCon.SQLInsert(stringSQL);
|
|
|
|
|
|
- Dictionary<string, PropertyInfo> propDict = Compare.SimpleCompare<ArticleModel>(articleModel, oldArticleModel);
|
|
|
+ Dictionary<string, PropertyInfo> propDict = Compare.SimpleCompare<ArticleModel>(articleModel, articleModelClone);
|
|
|
foreach (KeyValuePair<string, PropertyInfo> prop in propDict)
|
|
|
{
|
|
|
//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(oldArticleModel, null)}', '{prop.Value.GetValue(articleModel, null)}')";
|
|
|
+ $"VALUES ('{id}', '{currentAcc.UUID}', '{prop.Key}', '{prop.Value.GetValue(articleModelClone, null)}', '{prop.Value.GetValue(articleModel, null)}')";
|
|
|
dbCon.SQLInsert(stringSQL);
|
|
|
}
|
|
|
|
|
@@ -190,6 +209,7 @@
|
|
|
if (docID > 0)
|
|
|
{
|
|
|
status = propDict.Count > 0 ? "All changes saved, article has veryfied." : "Article verifyed without any changes.";
|
|
|
+ await Verify();
|
|
|
}
|
|
|
else
|
|
|
{
|
|
@@ -224,9 +244,9 @@
|
|
|
status = $"Finished loading {memoryStream.Length} bytes from {file.Name}";
|
|
|
|
|
|
DocParse docParse = new DocParse();
|
|
|
- oldArticleModel = DocParse.ReadPDF(memoryStream);
|
|
|
- oldArticleModel.Filename = file.Name;
|
|
|
- articleModel = (ArticleModel)oldArticleModel.Clone();
|
|
|
+ articleModelClone = DocParse.ReadPDF(memoryStream);
|
|
|
+ articleModelClone.Filename = file.Name;
|
|
|
+ articleModel = (ArticleModel)articleModelClone.Clone();
|
|
|
}
|
|
|
}
|
|
|
|