zoule 1 month ago
parent
commit
0ede4b1f68
4 changed files with 38 additions and 13 deletions
  1. 4 0
      DbMigrate/DbMigrate.csproj
  2. 5 0
      DbMigrate/Form1.cs
  3. 1 1
      XdCxRhDW.App/App.config
  4. 28 12
      XdCxRhDW.App/UserControl/CtrlHome.cs

+ 4 - 0
DbMigrate/DbMigrate.csproj

@@ -160,6 +160,10 @@
       <Project>{068C649C-81A7-4BE1-A74C-D5745959D0EA}</Project>
       <Name>03.XdCxRhDW.Entity</Name>
     </ProjectReference>
+    <ProjectReference Include="..\XdCxRhDW.Framework\01.XdCxRhDW.Framework.csproj">
+      <Project>{cd41cedf-e0b8-41cc-867b-3b57f476b450}</Project>
+      <Name>01.XdCxRhDW.Framework</Name>
+    </ProjectReference>
     <ProjectReference Include="..\XdCxRhDW.Repostory\04.XdCxRhDW.Repostory.csproj">
       <Project>{9cb2f5d6-6d22-454e-8b47-b51ff7fa1794}</Project>
       <Name>04.XdCxRhDW.Repostory</Name>

+ 5 - 0
DbMigrate/Form1.cs

@@ -14,6 +14,7 @@ using System.Xml.Linq;
 using XdCxRhDW.Repostory;
 using Dapper;
 using XdCxRhDW.Entity;
+using XdCxRhDW.Framework;
 namespace DbMigrate
 {
     public partial class Form1 : Form
@@ -97,6 +98,7 @@ namespace DbMigrate
                         }
                         catch (Exception ex)
                         {
+                            LogHelper.Error("创建MySql数据库失败", ex);
                             Log($"{ex.Message}");
                         }
                     }
@@ -105,6 +107,7 @@ namespace DbMigrate
             }
             catch (Exception ex)
             {
+                LogHelper.Error("创建MySql数据库及表结构失败", ex);
                 Log($"创建MySql数据库及表结构失败.{ex.Message}");
             }
             finally
@@ -202,6 +205,7 @@ namespace DbMigrate
             }
             catch (Exception ex)
             {
+                LogHelper.Error("数据迁移失败", ex);
                 Log($"数据迁移失败.{ex.Message}");
             }
             finally
@@ -346,6 +350,7 @@ namespace DbMigrate
             }
             catch (Exception ex)
             {
+                LogHelper.Error("分区创建异常", ex);
                 Log($"分区创建异常.{ex.Message}");
             }
             finally

+ 1 - 1
XdCxRhDW.App/App.config

@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="utf-8"?>
 <configuration>
 	<connectionStrings>
-		<add name="MySql" connectionString="server=192.168.101.3;uid=root;pwd=123456;database=DWPT;" />
+		<add name="MySql" connectionString="server=192.168.101.5;uid=root;pwd=123456;database=DWPT;" />
 	</connectionStrings>
 	<appSettings>
 		<!--程序标题-->

+ 28 - 12
XdCxRhDW.App/UserControl/CtrlHome.cs

@@ -346,18 +346,24 @@ namespace XdCxRhDW.App.UserControl
             var btnEdit = (layoutControlGroup1.CustomHeaderButtons[1] as GroupBoxButton);
             var btnDel = (layoutControlGroup1.CustomHeaderButtons[2] as GroupBoxButton);
             btnDel.Enabled = btnEdit.Enabled = tsk.TaskState != EnumTaskState.Running;
-            List<ModelPosRes> listPos = null;
             if (txtTimeCho.Text == "自定义" && (txtStartTime.EditValue == null || txtEndTime.EditValue == null || txtStartTime.DateTime > txtEndTime.DateTime))
             {
-                listPos = new List<ModelPosRes>();
-                this.gridHomePosRes.DataSource = listPos;
-                mapControl1.SetPosDataSource(listPos);
+                var tmp = new List<ModelPosRes>();
+                lock (this)
+                {
+                    this.gridHomePosRes.DataSource = tmp;
+                    mapControl1.SetPosDataSource(tmp);
+                }
             }
             else
             {
-                listPos = await searchPos(cts.Token);
-                this.gridHomePosRes.DataSource = listPos;
-                mapControl1.SetPosDataSource(listPos);
+
+                var tmp  = await searchPos(cts.Token);
+                lock (this)
+                {
+                    this.gridHomePosRes.DataSource = tmp;
+                    mapControl1.SetPosDataSource(tmp);
+                }
             }
             SatInfo sat1, sat2, sat3;
             using (MySqlContext db = new MySqlContext())
@@ -827,8 +833,11 @@ namespace XdCxRhDW.App.UserControl
                     itemEnd.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Never;
                     layoutControlItemSearch.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Never;
                     var list = await searchPos(cts.Token);
-                    this.gridHomePosRes.DataSource = list;
-                    this.mapControl1.SetPosDataSource(list);
+                    lock (this)
+                    {
+                        this.gridHomePosRes.DataSource = list;
+                        this.mapControl1.SetPosDataSource(list);
+                    }
                     break;
                 case "自定义":
                     itemStart.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Always;
@@ -851,7 +860,11 @@ namespace XdCxRhDW.App.UserControl
                 }
                 var cts = new CancellationTokenSource();
                 listCts.Add(cts);
-                this.gridHomePosRes.DataSource = await searchPos(cts.Token);
+                var list = await searchPos(cts.Token);
+                lock (this)
+                {
+                    this.gridHomePosRes.DataSource = list;
+                }
             }
         }
         private async void btnSearch_Click(object sender, EventArgs e)
@@ -876,8 +889,11 @@ namespace XdCxRhDW.App.UserControl
             var cts = new CancellationTokenSource();
             listCts.Add(cts);
             var listPos = await searchPos(cts.Token);
-            this.gridHomePosRes.DataSource = listPos;
-            this.mapControl1.SetPosDataSource(listPos);
+            lock (this)
+            {
+                this.gridHomePosRes.DataSource = listPos;
+                this.mapControl1.SetPosDataSource(listPos);
+            }
         }
         private async Task<List<ModelPosRes>> searchPos(CancellationToken ct = default)
         {