소스 검색

more fixes

ganahrhr 3 년 전
부모
커밋
b5f1faa9f1
3개의 변경된 파일12개의 추가작업 그리고 29개의 파일을 삭제
  1. 2 2
      Models/ArticleModel.cs
  2. 4 24
      MySQLConnector.cs
  3. 6 3
      Pages/DocEdit.razor.cs

+ 2 - 2
Models/ArticleModel.cs

@@ -76,7 +76,7 @@ namespace HyperCube.Models
                 stringSQL += $"WHERE article_id={this.ID} AND acc_id='{acc_id}'";
 
             int count = await dbCon.SQLSelectCount(stringSQL);
-            dbCon.Close();
+            //dbCon.Close();
             return count;
         }
 
@@ -94,7 +94,7 @@ namespace HyperCube.Models
                     $"WHERE articles.id={this.ID} AND action_type={(int)ArticleStatus.Added}";
 
                 initiatorUUID = await dbCon.SQLSelectUUID(stringSQL);
-                dbCon.Close();                
+                //dbCon.Close();                
             }
             else
                 Console.WriteLine("initiatorUUID already set");

+ 4 - 24
MySQLConnector.cs

@@ -29,29 +29,10 @@ namespace HyperCube
         }
 
         public async Task<bool> IsConnect()
-        {
-           
+        {           
             string connstring = $"Server={Server}; database={DatabaseName}; UID={UserName}; password={Password}";
             if (Connection != null)
-            {
-                //Console.WriteLine($"IsConnect {Connection.State}");
-                //try
-                //{
-                    await SQLSelectComplex("select COUNT(*) from accounts", false);
-                //    }
-                //    catch (Exception e)
-                //    {
-                //        Console.WriteLine("SQL Exception " + e.Message + "stack trace" + e.StackTrace);
-                //        Console.WriteLine($"catch SQL IsConnect making NEW Connection!");
-                //        Connection = new MySqlConnection(connstring);
-                //        Connection.Open();
-                //    }
-                //    //finally
-                //    //{
-
-                //    //}
-                //    Console.WriteLine($"SQL IsConnect state: {Connection.State}");
-            }
+                await SQLSelectComplex("select COUNT(*) from accounts", false);
             else
                 Console.WriteLine($"SQL IsConnect Connection null");
 
@@ -109,7 +90,6 @@ namespace HyperCube
                     //if (!rdr.IsDBNull(15))
                     //    newacc.eth_address = rdr.GetString(15);
 
-
                     if (!accs.ContainsKey(newacc.UUID))
                         accs.Add(newacc.UUID, newacc);
                     newacc.bsel = rdr.GetByte(17);
@@ -249,7 +229,7 @@ namespace HyperCube
             if (connected)
             {
                 //Console.WriteLine($"SQLSelectComplex connected");
-                List<Dictionary<string, object>> retval = new List<Dictionary<string, object>>();
+                List<Dictionary<string, object>> retval = new();
                 MySqlCommand SQLcom2 = new(request, Connection);
                 //Console.WriteLine($"SQLSelectComplex new SQLcom");
                 //try
@@ -259,7 +239,7 @@ namespace HyperCube
                 while (Reader.Read())
                     {
                         //Console.WriteLine($"SQLSelectComplex Reader.Read");
-                        Dictionary<string, object> data = new Dictionary<string, object>();
+                        Dictionary<string, object> data = new();
 
                         for (int i = 0; i < Reader.FieldCount; i++)
                         {

+ 6 - 3
Pages/DocEdit.razor.cs

@@ -133,9 +133,9 @@ namespace HyperCube.Pages
                     $"'{articleModel.Annotation}', '{articleModel.Keywords}')";
                 id = await dbCon.SQLInsert(stringSQL);
                 NewProjectSmopp(id);
-            }
+            }          
 
-            ///temp
+            /// tmp
             int action_type = docID > 0 ? 2 : 1;
 
             stringSQL = $"INSERT INTO actions_history (article_id, action_type, acc_id) " +
@@ -152,7 +152,7 @@ namespace HyperCube.Pages
                 await dbCon.SQLInsert(stringSQL);
             }
 
-            dbCon.Close();
+            //dbCon.Close();
 
             if (docID > 0)
             {
@@ -184,6 +184,9 @@ namespace HyperCube.Pages
                 else
                     NavigationManager.NavigateTo("");
             }
+
+            /// reloading articles
+            await AppData.LoadArticles();
         }
 
         private async Task HandleSelection(InputFileChangeEventArgs e)