public SyncForm(SyncTask task) { InitializeComponent(); ShowInTaskbar = false;// 不能放到OnLoad里,会导致窗体消失 if (task.TimeOut <= 0) task.TimeOut = 30; m_task = task; }
SyncTask GetTask() { string strSourceConn, strTargetConn; if (!CheckConn(out strSourceConn, out strTargetConn)) { return null; } if (lvTables.CheckedItems.Count <= 0) { MessageBox.Show("请选择要同步的源表"); return null; } var arr = new Dictionary<string, SyncItem>(); foreach (ListViewItem item in lvTables.CheckedItems) { string target = item.SubItems[COL_TARGET].Text.Trim(); string key = target.ToLower(); if (arr.ContainsKey(key)) { MessageBox.Show(target + " 目标表选择重复,请重新指定"); return null; } string source = item.SubItems[COL_SOURCE].Text.Trim(); arr.Add(key, new SyncItem { Source = source, Target = target, IsSqlSource = !string.IsNullOrEmpty(item.SubItems[COL_SOURCEBACK].Text), TruncateOld = item.SubItems[COL_TRUNCATE].Text == "true", UseIdentifier = item.SubItems[COL_IDENTIFIER].Text == "true", }); } var task = new SyncTask { Items = arr.Values, ErrContinue = chkErrContinue.Checked, AddNoLock = chkWithNolock.Checked, UseTruncate = chkUseTruncate.Checked, SourceConstr = strSourceConn, TargetConstr = strTargetConn, }; return task; }