|
@@ -1,87 +1,87 @@
|
|
|
-@page "/docsload"
|
|
|
-@using System.IO;
|
|
|
-
|
|
|
-<EditForm Model="@articleModel" OnValidSubmit="@HandleValidSubmit">
|
|
|
- <DataAnnotationsValidator />
|
|
|
- <ValidationSummary />
|
|
|
-
|
|
|
- <h1>Загрузка материала</h1>
|
|
|
-
|
|
|
- <div style="width: 50%;">
|
|
|
- <p><InputFile id="inputDefault" OnChange="@HandleSelection" accept="application/pdf, application/msword, application/vnd.openxmlformats-officedocument.wordprocessingml.document" /></p>
|
|
|
- <p><InputText id="article_name" class="form-control" @bind-Value="articleModel.Name" placeholder="Наименование статьи" /></p>
|
|
|
- <p><InputDate id="date_publish" class="form-control" @bind-Value="articleModel.PublishDate" placeholder="Дата издания" /></p>
|
|
|
- <p><InputText id="author" class="form-control" @bind-Value="articleModel.Author" placeholder="Автор" /></p>
|
|
|
- <p><InputTextArea id="keywords" class="form-control" @bind-Value="articleModel.Keywords" placeholder="Ключевые слова" /></p>
|
|
|
- <p><InputTextArea rows="5" id="annotation" class="form-control" @bind-Value="articleModel.Annotation" placeholder="Аннотация" /></p>
|
|
|
- <p><InputTextArea rows="10" id="text" class="form-control" @bind-Value="@text" placeholder="Текст" /></p>
|
|
|
- <p><button class="btn btn-primary" type="submit">Загрузить</button></p>
|
|
|
- <p>Статус: @status</p>
|
|
|
- </div>
|
|
|
-
|
|
|
- @*<div class="row">
|
|
|
- <div class="col-2">
|
|
|
- <label>Address</label>
|
|
|
- </div>
|
|
|
-
|
|
|
- <div class="col-3">
|
|
|
- <InputText style="width: 100%;" @bind-Value="articleModel.Name" placeholder="Postcode" />
|
|
|
- </div>
|
|
|
-
|
|
|
- <div class="col-3">
|
|
|
- <InputText style="width: 100%;" @bind-Value="articleModel.Name" placeholder="House Nb" />
|
|
|
- </div>
|
|
|
-
|
|
|
- <div class="col-4">
|
|
|
- <InputText style="width: 100%;" @bind-Value="articleModel.Name" placeholder="Street" />
|
|
|
- </div>
|
|
|
- </div>*@
|
|
|
-
|
|
|
-</EditForm>
|
|
|
-
|
|
|
-@code {
|
|
|
- private Models.ArticleModel articleModel = new Models.ArticleModel();
|
|
|
-
|
|
|
- string status;
|
|
|
- string text;
|
|
|
-
|
|
|
- private void HandleValidSubmit()
|
|
|
- {
|
|
|
- MySQLConnector dbCon = MySQLConnector.Instance();
|
|
|
-
|
|
|
- string stringSQL = $"INSERT INTO articles (filename, article_name, authors)" +
|
|
|
- $"VALUES ('{articleModel.Filename}', '{articleModel.Name}', '{articleModel.Author}')";
|
|
|
- long id = dbCon.SQLInsert(stringSQL);
|
|
|
-
|
|
|
- stringSQL = $"INSERT INTO actions_history (article_id, action_type, acc_id)" +
|
|
|
- $"VALUES ('{id}', {1}, {1})";
|
|
|
- dbCon.SQLInsert(stringSQL);
|
|
|
-
|
|
|
- dbCon.Close();
|
|
|
- status = "Data sent";
|
|
|
- }
|
|
|
-
|
|
|
- async Task HandleSelection(InputFileChangeEventArgs e)
|
|
|
- {
|
|
|
- IBrowserFile file = e.File;
|
|
|
- if (file != null)
|
|
|
- {
|
|
|
- status = $"Finished loading {file.Size} bytes from {file.Name}";
|
|
|
-
|
|
|
-
|
|
|
- //передавать из парсинга ArticleModel!!!
|
|
|
-
|
|
|
- DocParse docParse = new DocParse();
|
|
|
- Dictionary<string, string> docFields = await DocParse.ReadPDF(file);
|
|
|
- articleModel.Filename = file.Name;
|
|
|
- articleModel.Name = docFields["name"];
|
|
|
- //articleModel.PublishDate = docFields["date"];
|
|
|
- articleModel.Author = docFields["authors"];
|
|
|
- articleModel.Keywords = docFields["keywords"];
|
|
|
- articleModel.Annotation = docFields["annotation"];
|
|
|
- text = docFields["text"];
|
|
|
-
|
|
|
- //Console.WriteLine("HandleSelection finished");
|
|
|
- }
|
|
|
- }
|
|
|
-}
|
|
|
+@page "/docsupload"
|
|
|
+@using System.IO;
|
|
|
+
|
|
|
+<EditForm Model="@articleModel" OnValidSubmit="@HandleValidSubmit">
|
|
|
+ <DataAnnotationsValidator />
|
|
|
+ <ValidationSummary />
|
|
|
+
|
|
|
+ <h1>Загрузка материала</h1>
|
|
|
+
|
|
|
+ <div style="width: 50%;">
|
|
|
+ <p><InputFile id="inputDefault" OnChange="@HandleSelection" accept="application/pdf, application/msword, application/vnd.openxmlformats-officedocument.wordprocessingml.document" /></p>
|
|
|
+ <p><InputText id="article_name" class="form-control" @bind-Value="articleModel.Name" placeholder="Наименование статьи" /></p>
|
|
|
+ <p><InputDate id="date_publish" class="form-control" @bind-Value="articleModel.PublishDate" placeholder="Дата издания" /></p>
|
|
|
+ <p><InputText id="author" class="form-control" @bind-Value="articleModel.Author" placeholder="Автор" /></p>
|
|
|
+ <p><InputTextArea id="keywords" class="form-control" @bind-Value="articleModel.Keywords" placeholder="Ключевые слова" /></p>
|
|
|
+ <p><InputTextArea rows="5" id="annotation" class="form-control" @bind-Value="articleModel.Annotation" placeholder="Аннотация" /></p>
|
|
|
+ <p><InputTextArea rows="10" id="text" class="form-control" @bind-Value="@text" placeholder="Текст" /></p>
|
|
|
+ <p><button class="btn btn-primary" type="submit">Загрузить</button></p>
|
|
|
+ <p>Статус: @status</p>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ @*<div class="row">
|
|
|
+ <div class="col-2">
|
|
|
+ <label>Address</label>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <div class="col-3">
|
|
|
+ <InputText style="width: 100%;" @bind-Value="articleModel.Name" placeholder="Postcode" />
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <div class="col-3">
|
|
|
+ <InputText style="width: 100%;" @bind-Value="articleModel.Name" placeholder="House Nb" />
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <div class="col-4">
|
|
|
+ <InputText style="width: 100%;" @bind-Value="articleModel.Name" placeholder="Street" />
|
|
|
+ </div>
|
|
|
+ </div>*@
|
|
|
+
|
|
|
+</EditForm>
|
|
|
+
|
|
|
+@code {
|
|
|
+ private Models.ArticleModel articleModel = new Models.ArticleModel();
|
|
|
+
|
|
|
+ string status;
|
|
|
+ string text;
|
|
|
+
|
|
|
+ private void HandleValidSubmit()
|
|
|
+ {
|
|
|
+ MySQLConnector dbCon = MySQLConnector.Instance();
|
|
|
+
|
|
|
+ string stringSQL = $"INSERT INTO articles (filename, article_name, authors, date_publish, annotation, keywords)" +
|
|
|
+ $"VALUES ('{articleModel.Filename}', '{articleModel.Name}', '{articleModel.Author}', '{articleModel.PublishDate}', '{articleModel.Annotation}', '{articleModel.Keywords}')";
|
|
|
+ long id = dbCon.SQLInsert(stringSQL);
|
|
|
+
|
|
|
+ stringSQL = $"INSERT INTO actions_history (article_id, action_type, acc_id)" +
|
|
|
+ $"VALUES ('{id}', {1}, {1})";
|
|
|
+ dbCon.SQLInsert(stringSQL);
|
|
|
+
|
|
|
+ dbCon.Close();
|
|
|
+ status = "Data sent";
|
|
|
+ }
|
|
|
+
|
|
|
+ async Task HandleSelection(InputFileChangeEventArgs e)
|
|
|
+ {
|
|
|
+ IBrowserFile file = e.File;
|
|
|
+ if (file != null)
|
|
|
+ {
|
|
|
+ status = $"Finished loading {file.Size} bytes from {file.Name}";
|
|
|
+
|
|
|
+
|
|
|
+ //передавать из парсинга ArticleModel!!!
|
|
|
+
|
|
|
+ DocParse docParse = new DocParse();
|
|
|
+ Dictionary<string, string> docFields = await DocParse.ReadPDF(file);
|
|
|
+ articleModel.Filename = file.Name;
|
|
|
+ articleModel.Name = docFields["name"];
|
|
|
+ //articleModel.PublishDate = docFields["date"];
|
|
|
+ articleModel.Author = docFields["authors"];
|
|
|
+ articleModel.Keywords = docFields["keywords"];
|
|
|
+ articleModel.Annotation = docFields["annotation"];
|
|
|
+ text = docFields["text"];
|
|
|
+
|
|
|
+ //Console.WriteLine("HandleSelection finished");
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|