/// <summary> /// 数据库中默认的表 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void tablesDefaultTable_Click(object sender, RoutedEventArgs e) { var dal = DALFacotry.Create(cbbDbtype.Text, txtConn.Text); var tablelist = dal.Query <DataTableItem>("with a as (select distinct schema as Domain,tablename as TableName, tablecomment as TableDescription from public.hdr_columns) select row_number() over() TableNo, domain, tablename, TableDescription from a"); if (tablelist == null || tablelist.Count() == 0) { MessageBox.Show("标准表集合hdr_columns获取失败!", "提示", MessageBoxButton.OK, MessageBoxImage.Information); } IList <string> selected = new List <string>(); for (int i = 0; i < this.ckbTables.Items.Count; i++) { var tablefullname = this.ckbTables.Items[i].ToString(); var hdrtableitems = tablelist.FirstOrDefault(p => tablefullname == $"{p.Domain }.{p.TableName}"); if (hdrtableitems != null) { this.ckbTables.SelectedItems.Add(this.ckbTables.Items.GetItemAt(i)); selected.Add(tablefullname); } } if (!(selected.Count == tablelist.Count())) { var logpath = System.IO.Path.Combine(AppContext.BaseDirectory, $"{DateTime.Now.ToString("yyyyMMddHHmmss")}.log"); var difftables = tablelist.Where(p => !selected.Contains($"{p.Domain}.{p.TableName}")).Select(p => $"{p.Domain}.{p.TableName}"); File.WriteAllText(logpath, $"{DateTime.Now.ToString("yyyyMMddHHmmss")}日志:标准库中{string.Join(";", difftables)}"); MessageBox.Show("当前库中表不完整!", "提示", MessageBoxButton.OK, MessageBoxImage.Information); } }
private void btnConn_Click(object sender, EventArgs e) { if (txtConn.Text.Length == 0) { lblMessage.Text = "连接字符串不能为空"; return; } try { ThreadPool.QueueUserWorkItem(new WaitCallback((obj) => { try { dal = DALFacotry.Create(cbbDbtype.Text, txtConn.Text); if (dal == null) { lblMessage.Text = "数据库连接失败"; return; } lblMessage.Text = "成功连接数据库"; //成功连接之后将配置保存 ini.WriteValue("Set", "index", cbbDbtype.SelectedIndex); ini.WriteValue("Set", "index_" + cbbDbtype.SelectedIndex, txtConn.Text); //加载表信息 ckbTables.Items.Clear(); ckbData.Items.Clear(); var dt = dal.GetTables(); if (dt.Rows.Count == 0) { lblMessage.Text = "查询表信息异常,请选择正确的数据库!"; return; } foreach (DataRow dr in dt.Rows) { ckbTables.Items.Add(dr["表名"].ToString()); ckbData.Items.Add(dr["表名"].ToString()); } groupBox1.Enabled = true; lblMessage.Text = "数据库已连接"; } catch (Exception) { lblMessage.Text = "数据库操作失败"; } finally { this.CloseLoading(); } })); this.Loading(); lblMessage.Text = "正在连接数据库"; } catch (Exception) { lblMessage.Text = "数据库异常 请确认"; } }
private void btnConn_Click(object sender, RoutedEventArgs e) { if (txtConn.Text.Length == 0) { lblMessage.Content = "连接字符串不能为空"; return; } try { dal = DALFacotry.Create(cbbDbtype.Text, txtConn.Text); if (dal == null) { lblMessage.Content = "暂时不支持该数据库 敬请期待"; return; } } catch (Exception ex) { lblMessage.Content = $"数据库异常 请确认!{ex.Message}"; return; } lblMessage.Content = "成功连接数据库"; //成功连接之后将配置保存 ini.WriteValue("Set", "index", cbbDbtype.SelectedIndex); ini.WriteValue("Set", "index_" + cbbDbtype.SelectedIndex, txtConn.Text); //加载表信息 ckbTables.Items.Clear(); ckbData.Items.Clear(); var dt = dal.GetTables(); if (dt.Count == 0) { lblMessage.Content = "查询表信息异常,请选择正确的数据库!"; return; } ObservableCollection <string> tablesBind = new ObservableCollection <string>(); foreach (var dr in dt) { tablesBind.Add($"{dr.Domain}.{dr.TableName}"); } ckbTables.ItemsSource = tablesBind; ckbData.ItemsSource = tablesBind; groupbox1.IsEnabled = true; }
private void btnConn_Click(object sender, EventArgs e) { if (txtConn.Text.Length == 0) { lblMessage.Text = "连接字符串不能为空"; return; } try { dal = DALFacotry.Create(cbbDbtype.Text, "Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=issdb.iba.ECU911.GOB) (PORT=1521)))(CONNECT_DATA=(SERVICE_NAME=pimbabu.iba.ecu911.gob)));Persist Security Info=True;User Id=cawy_cas; Password=ECU911_db"); if (dal == null) { lblMessage.Text = "暂时不支持该数据库 敬请期待"; return; } } catch (Exception ex) { lblMessage.Text = "数据库异常 请确认"; return; } lblMessage.Text = "成功连接数据库"; //成功连接之后将配置保存 ini.WriteValue("Set", "index", cbbDbtype.SelectedIndex); ini.WriteValue("Set", "index_" + cbbDbtype.SelectedIndex, txtConn.Text); //加载表信息 ckbTables.Items.Clear(); ckbData.Items.Clear(); var dt = dal.GetTables(); if (dt.Rows.Count == 0) { lblMessage.Text = "查询表信息异常,请选择正确的数据库!"; return; } foreach (DataRow dr in dt.Rows) { ckbTables.Items.Add(dr["表名"].ToString()); ckbData.Items.Add(dr["表名"].ToString()); } groupBox1.Enabled = true; }
private void btnConn_Click(object sender, EventArgs e) { if (txtConn.Text.Length == 0) { lblMessage.Text = "连接字符串不能为空"; return; } try { dal = DALFacotry.Create(cbbDbtype.Text, txtConn.Text); if (dal == null) { lblMessage.Text = "暂时不支持该数据库 敬请期待"; return; } } catch (Exception) { lblMessage.Text = "数据库异常 请确认"; return; } lblMessage.Text = "成功连接数据库"; //成功连接之后将配置保存 ini.WriteValue("Set", "index", cbbDbtype.SelectedIndex); ini.WriteValue("Set", "index_" + cbbDbtype.SelectedIndex, txtConn.Text); //加载表信息 ckbTables.Items.Clear(); ckbData.Items.Clear(); var dt = dal.GetTables(); if (dt.Rows.Count == 0) { lblMessage.Text = "查询表信息异常,请选择正确的数据库!"; return; } foreach (DataRow dr in dt.Rows) { ckbTables.Items.Add(dr["表名"].ToString()); ckbData.Items.Add(dr["表名"].ToString()); } groupBox1.Enabled = true; }
/// <summary> /// 默认导出的数据的表 mdm /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void dataDefaultTableData_Click(object sender, RoutedEventArgs e) { var dal = DALFacotry.Create(cbbDbtype.Text, txtConn.Text); var tablelist = dal.Query <DataTableItem>("with a as (select distinct schema as Domain,tablename as TableName, tablecomment as TableDescription from public.hdr_columns) select row_number() over() TableNo, domain, tablename, TableDescription from a"); if (tablelist == null || tablelist.Count() == 0) { MessageBox.Show("未读取到hdr_columns表数据!", "提示", MessageBoxButton.OK, MessageBoxImage.Information); } for (int i = 0; i < this.ckbData.Items.Count; i++) { var tablefullname = this.ckbData.Items[i].ToString(); var hdrtableitems = tablelist.FirstOrDefault(p => tablefullname == $"{p.Domain}.{p.TableName}"); if (hdrtableitems != null && (hdrtableitems.Domain == "mdm" || hdrtableitems.TableName == "hdr_versions" || hdrtableitems.TableName == "hdr_versions_modify_rec")) { this.ckbData.SelectedItems.Add(this.ckbData.Items.GetItemAt(i)); } } }