private void button1_Click(object sender, EventArgs e) { string SQL = "select tableName from Transfer2PDA"; QuerySelectPDA query = new QuerySelectPDA(); query.Select(SQL); List <DataRows> rows = query.GetRows(); PDATables.Items.Clear(); foreach (DataRows row in rows) { PDATables.Items.Add(row.FieldByName("tableName")); } SQL = "select distinct Table_Name from user_tables"; QuerySelectOracle Oraquery = new QuerySelectOracle(); Oraquery.Select(SQL); rows = Oraquery.GetRows(); OraTables.Items.Clear(); foreach (DataRows row in rows) { if (!PDATables.Items.Contains(row.FieldByName("Table_Name"))) { OraTables.Items.Add(row.FieldByName("Table_Name")); } } }
private void OraTables_SelectedIndexChanged(object sender, EventArgs e) { string SQL = "select Column_Name from user_tab_columns where Table_Name='{0}'"; QuerySelectOracle OraQuery = new QuerySelectOracle(); OraQuery.Select(String.Format(SQL, OraTables.SelectedItem)); List <DataRows> rows = OraQuery.GetRows(); FieldList.Items.Clear(); foreach (DataRows row in rows) { FieldList.Items.Add(row.FieldByName("Column_Name")); } }
private void button1_Click(object sender, EventArgs e) { QuerySelectOracle q = new QuerySelectOracle(); q.Select("select username, status, program, machine from gv$session where username is not null"); List <DataRows> rows = q.GetRows(); listView1.Items.Clear(); foreach (DataRows row in rows) { //listView1.Items.Add("Имя пользователя : " + row.FieldByName("username") + "; Статус : " + row.FieldByName("status") + "; Программа : " + row.FieldByName("program") + "; Компьютер : " + row.FieldByName("machine")); ListViewItem item = new ListViewItem(row.FieldByName("username")); item.SubItems.Add(row.FieldByName("status")); item.SubItems.Add(row.FieldByName("program")); item.SubItems.Add(row.FieldByName("machine")); listView1.Items.Add(item); } }
public override void Run() { /// это пример использования /// Считали данные из таблицы /// Формируем для каждого изменения соответствующую отмену // заполняем if (Running) { string predsost = "select idGU, offGU, offText from UserBM"; QuerySelectOracle q = new QuerySelectOracle(); QueryExecOracle qe = new QueryExecOracle(); q.Select(predsost); List <DataRows> lst = q.GetRows(); foreach (DataRows rows in lst) { UserInfo userInfo = new UserInfo(); userInfo.idGU = int.Parse(rows.FieldByName("idGU")); userInfo.offGU = int.Parse(rows.FieldByName("offGu")); userInfo.offText = rows.FieldByName("offText"); FinallyStack.Add(RestoreUser, userInfo); } string running = "update UserBM set offGU=1, offText='Идет импорт'"; qe.Execute(running); // Удалять все сеансы кроме SYSTEM string showsessions = "SELECT s.sid,s.serial#,s.osuser,s.program FROM v$session s"; q.Select(showsessions); lst = q.GetRows(); foreach (DataRows rows in lst) { if (rows.FieldByName("osuser") != "SYSTEM") { string kill = "ALTER SYSTEM KILL SESSION '" + rows.FieldByName("sid") + "," + rows.FieldByName("serial#") + "' IMMEDIATE"; qe.Execute(kill); } } //Реконнект DataBaseOracle.Disconnect(); DataBaseOracle.Get(); } }
private void PDATables_SelectedIndexChanged(object sender, EventArgs e) { string SQL = "select * from Transfer2PDA where tableName='{0}'"; QuerySelectPDA query = new QuerySelectPDA(); query.Select(String.Format(SQL, PDATables.SelectedItem)); List <DataRows> rows = query.GetRows(); if (rows.Count > 0) { if (rows[0].FieldByName("isLight") == "1") { checkBox1.Checked = true; } else { checkBox1.Checked = false; } if (rows[0].FieldByName("needExport") == "1") { checkBox2.Checked = true; } else { checkBox2.Checked = false; } textBox1.Text = rows[0].FieldByName("idTransferTable"); SQL = "select fieldname from TransferFields where idTransferTable={0}"; query.Select(String.Format(SQL, textBox1.Text)); List <DataRows> rows1 = query.GetRows(); PDAFields.Items.Clear(); foreach (DataRows row in rows1) { PDAFields.Items.Add(row.FieldByName("fieldname")); } /// запросы /// SQL = "select text from QrySelect where idQrySelect={0}"; query.Select(String.Format(SQL, rows[0].FieldByName("idQrySelectBM"))); rows1 = query.GetRows(); SelectText.Text = rows1[0].FieldByName("text"); SQL = "select text from QrySelect where idQrySelect={0}"; query.Select(String.Format(SQL, rows[0].FieldByName("idQrySelectPDA"))); rows1 = query.GetRows(); SelectPDAText.Text = rows1[0].FieldByName("text"); SQL = "select text from QryDelete where idQryDelete={0}"; query.Select(String.Format(SQL, rows[0].FieldByName("idQryDelete"))); rows1 = query.GetRows(); DeleteText.Text = rows1[0].FieldByName("text"); SQL = "select text from QryClear where idQryClear={0}"; query.Select(String.Format(SQL, rows[0].FieldByName("idQryClear"))); rows1 = query.GetRows(); ClearText.Text = rows1[0].FieldByName("text"); SQL = "select text from QryInsert where idQryInsert={0}"; query.Select(String.Format(SQL, rows[0].FieldByName("idQryInsert"))); rows1 = query.GetRows(); InsertText.Text = rows1[0].FieldByName("text"); } else { checkBox2.Checked = false; checkBox1.Checked = false; PDAFields.Items.Clear(); textBox1.Text = ""; } SQL = "select Column_Name from user_tab_columns where Table_Name='{0}'"; QuerySelectOracle OraQuery = new QuerySelectOracle(); OraQuery.Select(String.Format(SQL, PDATables.SelectedItem)); rows = OraQuery.GetRows(); OraFields.Items.Clear(); foreach (DataRows row in rows) { if (!PDAFields.Items.Contains(row.FieldByName("Column_Name"))) { OraFields.Items.Add(row.FieldByName("Column_Name")); } } }
public void Exec() { count = 1; foreach (TableInfo info in lst) { string ins = ""; string temp; if (Running) { QuerySelectOracle q = new QuerySelectOracle(); QueryExecPDA qu = new QueryExecPDA(); if (!q.Select("select * from BMEXPORT." + info.tableName)) { Loging.Loging.WriteLog("Error:select * from BMEXPORT." + info.tableName, true, true); } else { Loging.Loging.WriteLog("OK:select * from BMEXPORT." + info.tableName, false, false); List <DataRows> dr = q.GetRows(); foreach (DataRows rows in dr) { temp = ""; ins = "insert into " + info.tableName + "("; foreach (FieldInfo field in info.fields) { ins += field.fieldName + ", "; if (rows.FieldByName(field.fieldName) != "") { temp += "'" + rows.FieldByName(field.fieldName).Replace(',', '.').Replace("'", "''").ToString() + "', "; } else { temp += "null, "; } } ins = ins.Remove(ins.LastIndexOf(','), 1); temp = temp.Remove(temp.LastIndexOf(','), 1); ins += ") values (" + temp + ")"; if (!qu.Execute(ins)) { Loging.Loging.WriteLog("Error: " + ins, true, true); } else { Loging.Loging.WriteLog("OK: " + ins, false, false); } } } Coordinator.ExecuteDelegateArgs args = new Coordinator.ExecuteDelegateArgs(); args.Maximum = lst.Count;//передавать в args кол-во таблиц и номер текущей (для прогресс бара) args.Pos = count; args.runningAction = this; args.Name = Name(); OnExecute(this, args); count++; } else { break; } } }