Example #1
0
        private void buttonTestConnect_Click(object sender, EventArgs ev)
        {
            try
            {
                OracleProvider   oracleProvider = new OracleProvider();
                string           conString      = oracleProvider.BuildConnectionString(comboBoxTNSname.SelectedValue.ToString(), textBoxUser.Text, textBoxPass.Text);
                OracleConnection oracConnection = oracleProvider.GetConnection(conString);

                if (oracConnection != null)
                {
                    oracleConnection           = oracConnection;
                    DBName                     = textBoxUser.Text;
                    labelTestConnect.Text      = "SUCCESS!";
                    labelTestConnect.ForeColor = Color.Green;
                    char x = '"';
                    schemaName = x + textBoxUser.Text + x + ".";
                }
                else
                {
                    labelTestConnect.Text      = "FAIL!";
                    labelTestConnect.ForeColor = Color.Red;
                }
            }
            catch (Exception e)
            {
                Logger.ShowMsg(e.Message);
                Logger.Logging(e.Message, DateTime.Now.ToString());
                labelTestConnect.Text      = "FAIL!";
                labelTestConnect.ForeColor = Color.Red;
            }
        }
Example #2
0
        private void buttonExpData_Click(object sender, EventArgs ev)
        {
            if (MessageBox.Show("The process take many times, Are you sure you want to continue?", "", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes)
            {
                try
                {
                    OracleProvider   oracleProvider = new OracleProvider();
                    string           conString      = oracleProvider.BuildConnectionString(comboBoxTNSname.SelectedValue.ToString(), textBoxUser.Text, textBoxPass.Text);
                    OracleConnection oracConnection = oracleProvider.GetConnection(conString);

                    if (oracleConnection != null)
                    {
                        oracleConnection = oracConnection;
                        DBName           = textBoxUser.Text;
                    }

                    progressBarExpDt.Maximum = 0;

                    if (checkBoxExpObj.Checked)
                    {
                        if (oracleConnection != null && oracleConnection.State == ConnectionState.Open)
                        {
                            // get list view
                            List <string> listViewName = getListObject("VIEW");
                            // get list trigger
                            List <string> listTriggerName = getListObject("TRIGGER");
                            // get list procedure
                            List <string> listProcedureName = getListObject("PROCEDURE");
                            // get list function
                            List <string> listFunctionName = getListObject("FUNCTION");
                            // get list package
                            List <string> listPackageName = getListObject("PACKAGE");
                            // get list type
                            List <string> listType = getListObject("TYPE");

                            progressBarExpDt.Maximum += listViewName.Count + listTriggerName.Count +
                                                        listProcedureName.Count + listFunctionName.Count +
                                                        +listPackageName.Count + listType.Count;
                            progressBarExpDt.Step = 1;
                            // gen view
                            genObject(listViewName, "VIEW", progressBarExpDt);
                            //gen trigger
                            genObject(listTriggerName, "TRIGGER", progressBarExpDt);
                            // gen procedure
                            genObject(listProcedureName, "PROCEDURE", progressBarExpDt);
                            // gen function
                            genObject(listFunctionName, "FUNCTION", progressBarExpDt);
                            // gen package
                            genObject(listPackageName, "PACKAGE", progressBarExpDt);
                            // gen type
                            genObject(listType, "TYPE", progressBarExpDt);

                            progressBarExpDt.Value = 0;
                        }
                    }

                    if (checkBoxExpTbl.Checked)
                    {
                        string[] lsTable      = getListTableNameFromFile();
                        int      progressSize = 0;
                        for (int index = 0; index < lsTable.Length; index++)
                        {
                            string[]      tbl            = lsTable[index].Split('_');
                            List <string> listObjKeyName = GenScript.getListObjKeyName(tbl[0], tbl[1], oracleConnection);
                            progressSize += listObjKeyName.Count;
                        }
                        progressSize            += GenScript.getListObjKeyName("tltx", "tltxcd", oracleConnection).Count;
                        progressBarExpDt.Maximum = progressSize;

                        for (int index = 0; index < lsTable.Length; index++)
                        {
                            string[] tbl     = lsTable[index].Split('_');
                            string   tblName = tbl[0].ToLower();

                            if (tblName != "tltx" && tblName != "fldmaster" && tblName != "fldval" &&
                                tblName != "appchk" && tblName != "appmap")
                            {
                                GenScript.GenInsertCommand(tbl[0], tbl[1], oracConnection, pathMaster.ListPath, progressBarExpDt);
                            }
                        }
                        GenScript.GenInsertCommandForTransTable(oracConnection, pathMaster.ListPath, progressBarExpDt);
                    }
                    MessageBox.Show("Export completed!", "", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                catch (Exception e)
                {
                    Logger.ShowMsg(e.Message);
                    Logger.Logging(e.Message, DateTime.Now.ToString());
                }

                progressBarExpDt.Value = 0;
                oracleConnection.Close();
                oracleConnection.Dispose();
            }
        }