Browse Source

article.charcount save/load

ganahrhr 3 years ago
parent
commit
67266b0239
5 changed files with 118 additions and 119 deletions
  1. 15 5
      MySQLConnector.cs
  2. 4 10
      Pages/Desktop.razor.cs
  3. 2 7
      Pages/DocEdit.razor.cs
  4. 95 95
      Pages/ModalAssets.razor
  5. 2 2
      Shared/Sidebar.razor.cs

+ 15 - 5
MySQLConnector.cs

@@ -285,19 +285,28 @@ namespace HyperCube
             return null;
         }
 
-        public async Task<ArticleModel> SQLSelectArticle(string sql)
+        public async Task<ArticleModel> SQLSelectArticle(int docid)
         {
-            Console.WriteLine($"SQLSelectArticle");
+            Console.WriteLine($"SQLSelectArticle, docid: [{docid}]");
             ArticleModel article = new();
 
+            string stringSQL = $"SELECT articles.id, filename, article_name, authors, date_publish, annotation, keywords, action_type, rating, file_hash, " +
+                    $"doc_noungroups, doc_entities, doc_morph, doc_keywords1, doc_keywords2, char_count " +
+                    $"FROM articles " +
+                    $"JOIN actions_history ON actions_history.article_id = articles.id " +
+                    $"WHERE articles.id={docid} " +
+                    $"ORDER BY actions_history.id DESC LiMIT 1";
+
+            Console.WriteLine($"{stringSQL}");
+
             bool connected = await IsConnect();
             if (connected)
             {                
-                SQLcom = new(sql, Connection);
+                SQLcom = new(stringSQL, Connection);
                 MySqlDataReader rdr = SQLcom.ExecuteReader();
 
                 ///0=id, filename, article_name, authors, date_publish, annotation, keywords, action_type/status, rating, file_hash, 
-                ///10=doc_noungroups, doc_entities, doc_morph, doc_keywords1, doc_keywords2
+                ///10=doc_noungroups, doc_entities, doc_morph, doc_keywords1, doc_keywords2, char_count
                 while (rdr.Read())
                 {
                     article.ID = rdr.GetInt32(0);
@@ -314,7 +323,8 @@ namespace HyperCube
                     if (!rdr.IsDBNull(11)) article.Entities = rdr.GetString(11);
                     if (!rdr.IsDBNull(12)) article.Morph = rdr.GetString(12);
                     if (!rdr.IsDBNull(13)) article.Keywords1 = rdr.GetString(13);
-                    if (!rdr.IsDBNull(14)) article.Keywords2 = rdr.GetString(14);                    
+                    if (!rdr.IsDBNull(14)) article.Keywords2 = rdr.GetString(14);
+                    if (!rdr.IsDBNull(15)) article.CharCount = rdr.GetInt32(15);
 
                     Console.WriteLine($"Got article, ID: {article.ID}.");
                 }                

+ 4 - 10
Pages/Desktop.razor.cs

@@ -228,6 +228,7 @@ namespace HyperCube.Pages
                     _articleClone = DocParse.GetBaseProperties(plainText);
                     _articleClone.Filename = file.Name;
                     _articleClone.HashSum = hash;
+                    _articleClone.CharCount = plainText.Length;
                     _article = (ArticleModel)_articleClone.Clone();
 
                     ///tmp
@@ -413,10 +414,10 @@ namespace HyperCube.Pages
                     _modalLoading.Open();
 
                     stringSQL = $"INSERT INTO articles (filename, article_name, authors, date_publish, annotation, keywords, file_hash, " +
-                        $"doc_noungroups, doc_entities, doc_morph, doc_keywords1, doc_keywords2) " +
+                        $"doc_noungroups, doc_entities, doc_morph, doc_keywords1, doc_keywords2, char_count) " +
                         $"VALUES ('{_article.Filename}', '{_article.Name}', '{_article.Authors}', '{_article.PublishDate:yyyy-MM-dd}'," +
                         $"'{_article.Annotation}', '{_article.Keywords}', '{_article.HashSum}'," +
-                        $"'{_article.NounGroups}', '{_article.Entities}', '{_article.Morph}', '{_article.Keywords1}', '{_article.Keywords2}' )";
+                        $"'{_article.NounGroups}', '{_article.Entities}', '{_article.Morph}', '{_article.Keywords1}', '{_article.Keywords2}', '{_article.CharCount}' )";
                     id = await dbCon.SQLInsert(stringSQL);
                     _article.ID = (int)id;
 
@@ -460,15 +461,8 @@ namespace HyperCube.Pages
             if (docid > 0)
             {
                 MySQLConnector dbCon = MySQLConnector.Instance();
-
-                string stringSQL = $"SELECT articles.id, filename, article_name, authors, date_publish, annotation, keywords, action_type, rating, file_hash, " +
-                    $"doc_noungroups, doc_entities, doc_morph, doc_keywords1, doc_keywords2 " +
-                    $"FROM articles " +
-                    $"JOIN actions_history ON actions_history.article_id = articles.id " +
-                    $"WHERE articles.id={docid} " +
-                    $"ORDER BY actions_history.id DESC LiMIT 1";
                 
-                AppData.CurrentArticleClone = await dbCon.SQLSelectArticle(stringSQL);
+                AppData.CurrentArticleClone = await dbCon.SQLSelectArticle(docid);
                 await AppData.CurrentArticleClone.GetVerificationHistory(_currentAccount.UUID);
                 if (AppData.CurrentArticleClone.VerificationHistory.Count > 0)
                     _verificationPoint = AppData.CurrentArticleClone.VerificationHistory.Values.Last();

+ 2 - 7
Pages/DocEdit.razor.cs

@@ -63,13 +63,8 @@ namespace HyperCube.Pages
                 header = "Проверка материала";
 
                 MySQLConnector dbCon = MySQLConnector.Instance();
-
-                string stringSQL = $"SELECT articles.id, filename, article_name, authors, date_publish, annotation, keywords, action_type, rating " +
-                    $"FROM articles " +
-                    $"JOIN actions_history ON actions_history.article_id = articles.id " +
-                    $"WHERE articles.id={DocID} " +
-                    $"ORDER BY actions_history.id DESC LiMIT 1";
-                articleClone = await dbCon.SQLSelectArticle(stringSQL);
+                
+                articleClone = await dbCon.SQLSelectArticle(DocID);
                 article = (ArticleModel)articleClone.Clone();
 
                 string initiator = await article.GetInitiatorUUID(ArticleStatus.Saved);

+ 95 - 95
Pages/ModalAssets.razor

@@ -1,93 +1,93 @@
-<div class="modal" tabindex="-1" role="dialog" style="display:none" id="@elementid">
-    <div class="modal-container">
-        <div class="modal__body">
-            <div class="modal__body__header">
-                <div class="modal__body__header__info">
-                    <img src="img/packet.svg" alt="">
-                    <p>Цифровые активы</p>
-                </div>
-                @*<div class="modal__body__header__href">
-                        <a href="">Balans</a>
-                        <a href="">Swap</a>
-                        <a href="">Liquidity</a>
-                    </div>*@
-            </div>
-            <div class="modal__body__container">
-                <div class="modal__body__container__left">
-                    <div class="modal__body__calc__balance__header">
-                        <p>БАЛАНС</p>
-                        @*<button class="btn_orange">История</button>*@
-                    </div>
-                    <div class="modal__body__calc__balance__numbers">
-                        <div class="modal__body__calc__balance__numbers__name">
-                            <p>Системы</p>
-                        </div>
-                        <div class="modal__body__calc__balance__numbers__value">
-                            <div class="modal__body__calc__balance__numbers__value__item">
-                                <p>---</p>
-                                <p>ETH</p>
-
-                            </div>
-                            <div class="modal__body__calc__balance__numbers__value__item">
-                                <p>---</p>
-                                <p>HCB</p>
-                            </div>
-                        </div>
-                    </div>
-                    <div class="modal__body__calc__balance__numbers">
-                        <div class="modal__body__calc__balance__numbers__name">
-                            <p>Ваше</p>
-                        </div>
-                        <div class="modal__body__calc__balance__numbers__value">
-                            <div class="modal__body__calc__balance__numbers__value__item">
-                                <p>@ethBalance</p>
-                                <p>ETH</p>
-                            </div>
-                            <div class="modal__body__calc__balance__numbers__value__item">
-                                <p>@tokenBalance</p>
-                                <p>HCB</p>
-                            </div>
-                        </div>
-                    </div>
-                    @*<div class="modal__body__calc__balance__button">
-                            <button class="btn_orange btn_center">Пополнение</button>
-                            <button class="btn_orange btn_center">Вывод</button>
-                        </div>*@
-                </div>
-                @*<div class="modal__body__container__right">
-                        <p class="modal__body__calc__change__header">Обмен</p>
-                        <p class="modal__body__calc__change__desc">Trade tokens in an istant</p>
-                        <div class="modal__input__box" place="From" balanc='0.00000410' currency='ETH'>
-                            <input type="text" class="modal__input">
-                            <select type="select" class="modal__select">
-                                <option>ETH</option>
-                                <option>2DH</option>
-                            </select>
-                        </div>
-                        <div class="modal__input__box" place="To" balanc='0.00000410' currency='2DH'>
-                            <input type="text" class="modal__input">
-                            <select type="select" class="modal__select">
-                                <option>2DH</option>
-                                <option>ETH</option>
-                            </select>
-                        </div>
-                        <div class="modal__input__total">
-                            <p>Price</p>
-                            <div class="modal_input_total_value">
-                                <p>1.000000050</p>
-                                <p>2DH</p>
-                            </div>
-                        </div>
-                        <div class="modal__input__button">
-                            <button class="btn_orange btn_center">ОК</button>
-                        </div>
-                    </div>*@
-            </div>
-        </div>
-        <a class="modal_close" style="cursor:pointer" @onclick="@Close">&#10006;</a>
-    </div>
-</div>
-
+<div class="modal" tabindex="-1" role="dialog" style="display:none" id="@elementid">
+    <div class="modal-container">
+        <div class="modal__body">
+            <div class="modal__body__header">
+                <div class="modal__body__header__info">
+                    <img src="img/packet.svg" alt="">
+                    <p>Цифровые активы</p>
+                </div>
+                @*<div class="modal__body__header__href">
+                        <a href="">Balans</a>
+                        <a href="">Swap</a>
+                        <a href="">Liquidity</a>
+                    </div>*@
+            </div>
+            <div class="modal__body__container">
+                <div class="modal__body__container__left">
+                    <div class="modal__body__calc__balance__header">
+                        <p>БАЛАНС</p>
+                        @*<button class="btn_orange">История</button>*@
+                    </div>
+                    <div class="modal__body__calc__balance__numbers">
+                        <div class="modal__body__calc__balance__numbers__name">
+                            <p>Системы</p>
+                        </div>
+                        <div class="modal__body__calc__balance__numbers__value">
+                            <div class="modal__body__calc__balance__numbers__value__item">
+                                <p>---</p>
+                                <p>ETH</p>
+
+                            </div>
+                            <div class="modal__body__calc__balance__numbers__value__item">
+                                <p>---</p>
+                                <p>HCB</p>
+                            </div>
+                        </div>
+                    </div>
+                    <div class="modal__body__calc__balance__numbers">
+                        <div class="modal__body__calc__balance__numbers__name">
+                            <p>Ваше</p>
+                        </div>
+                        <div class="modal__body__calc__balance__numbers__value">
+                            <div class="modal__body__calc__balance__numbers__value__item">
+                                <p>@ethBalance</p>
+                                <p>ETH</p>
+                            </div>
+                            <div class="modal__body__calc__balance__numbers__value__item">
+                                <p>@tokenBalance</p>
+                                <p>HCB</p>
+                            </div>
+                        </div>
+                    </div>
+                    @*<div class="modal__body__calc__balance__button">
+                            <button class="btn_orange btn_center">Пополнение</button>
+                            <button class="btn_orange btn_center">Вывод</button>
+                        </div>*@
+                </div>
+                @*<div class="modal__body__container__right">
+                        <p class="modal__body__calc__change__header">Обмен</p>
+                        <p class="modal__body__calc__change__desc">Trade tokens in an istant</p>
+                        <div class="modal__input__box" place="From" balanc='0.00000410' currency='ETH'>
+                            <input type="text" class="modal__input">
+                            <select type="select" class="modal__select">
+                                <option>ETH</option>
+                                <option>2DH</option>
+                            </select>
+                        </div>
+                        <div class="modal__input__box" place="To" balanc='0.00000410' currency='2DH'>
+                            <input type="text" class="modal__input">
+                            <select type="select" class="modal__select">
+                                <option>2DH</option>
+                                <option>ETH</option>
+                            </select>
+                        </div>
+                        <div class="modal__input__total">
+                            <p>Price</p>
+                            <div class="modal_input_total_value">
+                                <p>1.000000050</p>
+                                <p>2DH</p>
+                            </div>
+                        </div>
+                        <div class="modal__input__button">
+                            <button class="btn_orange btn_center">ОК</button>
+                        </div>
+                    </div>*@
+            </div>
+        </div>
+        <a class="modal_close" style="cursor:pointer" @onclick="@Close">&#10006;</a>
+    </div>
+</div>
+
 @code {[Inject]
     public IJSRuntime JsRuntime { get; set; }
 
@@ -98,8 +98,8 @@
 
     string elementid = "modal_assets";
 
-    Models.AccountModel _account = new();
-
+    Models.AccountModel _account = new();
+
         @using Models;Blockchain bcMain;
 
     public async Task Balances()
@@ -108,15 +108,15 @@
         tokenBalance = await bcMain.BalanceOf("0xe5D682717955d6C35d465A3485625C64655a04f4", _account.GetActualAddress(bcMain));
     }
 
-    public async void Open(Models.AccountModel account)
+    public async Task Open(Models.AccountModel account)
     {
         _account = account;
         await Balances();
-        JsRuntime.InvokeVoidAsync("OpenModal", elementid);
+        await JsRuntime.InvokeVoidAsync("OpenModal", elementid);
     }
 
     public void Close()
     {
         JsRuntime.InvokeVoidAsync("CloseModal", elementid);
-    }
+    }
 }

+ 2 - 2
Shared/Sidebar.razor.cs

@@ -83,9 +83,9 @@ namespace HyperCube.Shared
             modalRules.Open();
         }
 
-        void AssetsClick()
+        async Task AssetsClick()
         {
-            modalAssets.Open(_currentAccount);
+            await modalAssets.Open(_currentAccount);
         }
 
         void ExitClick()