示例#1
0
        public static AjaxReturn NewConnection()
        {
            AjaxReturn v_return = new AjaxReturn();

            System.Data.DataTable v_connections;
            int v_numconnections;

            Session v_session = (Session)System.Web.HttpContext.Current.Session ["OMNIDB_SESSION"];

            if (v_session == null)
            {
                v_return.v_error    = true;
                v_return.v_error_id = 1;
                return(v_return);
            }

            v_numconnections = int.Parse(v_session.v_omnidb_database.v_connection.ExecuteScalar("select count(*) from connections"));
            if (v_numconnections > 0)
            {
                v_connections = v_session.v_omnidb_database.v_connection.Query("select max(conn_id)+1 as next_id from connections", "Connections");
            }
            else
            {
                v_connections = v_session.v_omnidb_database.v_connection.Query("select 1 as next_id", "Connections");
            }

            v_session.v_omnidb_database.v_connection.Execute("insert into connections values ( " +
                                                             v_connections.Rows [0] ["next_id"].ToString() + "," +
                                                             v_session.v_user_id + "," +
                                                             "'sqlite','','','','','','')");

            v_session.RefreshDatabaseList();

            return(v_return);
        }
示例#2
0
        public static AjaxReturn GetProcedureDefinition(int p_database_index, string p_procedure)
        {
            AjaxReturn v_return  = new AjaxReturn();
            Session    v_session = (Session)System.Web.HttpContext.Current.Session["OMNIDB_SESSION"];

            if (v_session == null)
            {
                v_return.v_error    = true;
                v_return.v_error_id = 1;
                return(v_return);
            }

            OmniDatabase.Generic v_database = v_session.v_databases[p_database_index];

            try
            {
                string v_procedure_definition = v_database.GetProcedureDefinition(p_procedure);
                v_return.v_data = v_procedure_definition;
            }
            catch (Spartacus.Database.Exception e)
            {
                v_return.v_error = true;
                v_return.v_data  = e.v_message.Replace("<", "&lt;").Replace(">", "&gt;").Replace(System.Environment.NewLine, "<br/>");

                return(v_return);
            }

            return(v_return);
        }
示例#3
0
        public static AjaxReturn CheckSession()
        {
            AjaxReturn v_return  = new AjaxReturn();
            Session    v_session = (Session)System.Web.HttpContext.Current.Session ["OMNIDB_SESSION"];

            if (v_session == null)
            {
                v_return.v_error    = true;
                v_return.v_error_id = 1;
                return(v_return);
            }

            SessionState v_ses_state = new SessionState();


            v_ses_state.v_has_connections = true;

            if (v_session.v_databases.Count > 0)
            {
                v_ses_state.v_has_connections = true;
            }
            else
            {
                v_ses_state.v_has_connections = false;
            }


            v_return.v_data = v_ses_state;
            return(v_return);
        }
示例#4
0
        public static AjaxReturn GetConvLog(int p_conv_id)
        {
            AjaxReturn v_return = new AjaxReturn();

            string v_log = "";

            try {
                using (System.IO.StreamReader v_reader = new System.IO.StreamReader("log/conv_" + p_conv_id + ".txt"))
                {
                    string v_line;
                    while ((v_line = v_reader.ReadLine()) != null)
                    {
                        v_log += v_line.Replace("<", ".").Replace(">", ".") + "\n";
                    }
                }
            }
            catch (System.IO.FileNotFoundException) {
                v_log = "File does not exist.";
            }
            catch (System.IO.IOException e) {
                v_log = e.Message;
            }

            v_return.v_data = v_log;

            return(v_return);
        }
示例#5
0
        public static AjaxReturn GetTreeInfo()
        {
            AjaxReturn v_return    = new AjaxReturn();
            TreeReturn v_tree_data = new TreeReturn();
            Session    v_session   = (Session)System.Web.HttpContext.Current.Session ["OMNIDB_SESSION"];

            if (v_session == null)
            {
                v_return.v_error    = true;
                v_return.v_error_id = 1;
                return(v_return);
            }


            v_tree_data.v_mode = "database";

            TreeDatabaseReturn v_database_return = new TreeDatabaseReturn();

            OmniDatabase.Generic v_database = v_session.GetSelectedDatabase();

            v_database_return.v_database   = v_database.GetName();
            v_database_return.v_has_schema = v_database.v_has_schema;

            if (v_database_return.v_has_schema)
            {
                v_database_return.v_schema = v_database.v_schema;
            }

            v_tree_data.v_database_return = v_database_return;

            v_return.v_data = v_tree_data;

            return(v_return);
        }
示例#6
0
        public static AjaxReturn GetUsers()
        {
            AjaxReturn v_return      = new AjaxReturn();
            UsersData  v_return_data = new UsersData();
            Session    v_session     = (Session)System.Web.HttpContext.Current.Session ["OMNIDB_SESSION"];

            Spartacus.Utils.Cryptor v_cryptor = new Spartacus.Utils.Cryptor("omnidb_spartacus");

            if (v_session == null)
            {
                v_return.v_error    = true;
                v_return.v_error_id = 1;
                return(v_return);
            }

            System.Data.DataTable v_users = v_session.v_omnidb_database.v_connection.Query("select * from users order by user_id", "Users");

            System.Collections.Generic.List <System.Collections.Generic.List <string> > v_user_list = new System.Collections.Generic.List <System.Collections.Generic.List <string> >();
            System.Collections.Generic.List <string> v_user_id_list = new System.Collections.Generic.List <string>();

            int v_index = 0;

            foreach (System.Data.DataRow v_user in v_users.Rows)
            {
                System.Collections.Generic.List <string> v_user_data_list = new System.Collections.Generic.List <string>();

                v_user_data_list.Add(v_user["user_name"].ToString());

                try
                {
                    v_user_data_list.Add(v_cryptor.Decrypt(v_user["password"].ToString()));
                }
                catch (Spartacus.Utils.Exception)
                {
                    v_user_data_list.Add(v_user["password"].ToString());
                }

                if (v_user["user_name"].ToString() == "admin")
                {
                    v_user_data_list.Add("");
                }
                else
                {
                    v_user_data_list.Add("<img src='images/tab_close.png' class='img_ht' onclick='removeUser(" + v_user["user_id"].ToString() + ")'/>");
                }

                v_index++;

                v_user_list.Add(v_user_data_list);

                v_user_id_list.Add(v_user["user_id"].ToString());
            }

            v_return_data.v_data     = v_user_list;
            v_return_data.v_user_ids = v_user_id_list;

            v_return.v_data = v_return_data;
            return(v_return);
        }
示例#7
0
        public static AjaxReturn SaveConnections(System.Collections.Generic.List <System.Collections.Generic.List <string> > p_data, System.Collections.Generic.List <string> p_conn_id_list)
        {
            AjaxReturn v_return  = new AjaxReturn();
            Session    v_session = (Session)System.Web.HttpContext.Current.Session ["OMNIDB_SESSION"];

            Spartacus.Utils.Cryptor v_cryptor = new Spartacus.Utils.Cryptor("omnidb_spartacus");

            if (v_session == null)
            {
                v_return.v_error    = true;
                v_return.v_error_id = 1;
                return(v_return);
            }

            string v_update_format = "update connections " +
                                     "set dbt_st_name = '#p_dbt_st_name#', " +
                                     "server          = '#p_server#', " +
                                     "port            = '#p_port#', " +
                                     "service         = '#p_service#', " +
                                     "schema          = '#p_schema#', " +
                                     "user            = '******', " +
                                     "password        = '******', " +
                                     "alias           = '#p_alias#' " +
                                     "where conn_id   = #p_conn_id#";

            for (int i = 0; i < p_data.Count; i++)
            {
                string v_update = v_update_format;
                v_update = v_update.Replace("#p_conn_id#", p_conn_id_list[i]);
                v_update = v_update.Replace("#p_dbt_st_name#", p_data [i][0]);
                try
                {
                    v_update = v_update.Replace("#p_server#", v_cryptor.Encrypt(p_data [i][1]));
                    v_update = v_update.Replace("#p_port#", v_cryptor.Encrypt(p_data [i][2]));
                    v_update = v_update.Replace("#p_service#", v_cryptor.Encrypt(p_data [i][3]));
                    v_update = v_update.Replace("#p_schema#", v_cryptor.Encrypt(p_data [i][4]));
                    v_update = v_update.Replace("#p_user#", v_cryptor.Encrypt(p_data [i][5]));
                    v_update = v_update.Replace("#p_password#", v_cryptor.Encrypt(p_data [i][6]));
                    v_update = v_update.Replace("#p_alias#", v_cryptor.Encrypt(p_data [i][7]));
                }
                catch (Spartacus.Utils.Exception)
                {
                    v_update = v_update.Replace("#p_server#", p_data [i][1]);
                    v_update = v_update.Replace("#p_port#", p_data [i][2]);
                    v_update = v_update.Replace("#p_service#", p_data [i][3]);
                    v_update = v_update.Replace("#p_schema#", p_data [i][4]);
                    v_update = v_update.Replace("#p_user#", p_data [i][5]);
                    v_update = v_update.Replace("#p_password#", p_data [i][6]);
                    v_update = v_update.Replace("#p_alias#", p_data [i][7]);
                }

                v_session.v_omnidb_database.v_connection.Execute(v_update);
            }

            v_session.RefreshDatabaseList();

            return(v_return);
        }
示例#8
0
        public static AjaxReturn StartConversion(int p_conv_id)
        {
            AjaxReturn v_return  = new AjaxReturn();
            Session    v_session = (Session)System.Web.HttpContext.Current.Session ["OMNIDB_SESSION"];

            if (v_session == null)
            {
                v_return.v_error    = true;
                v_return.v_error_id = 1;
                return(v_return);
            }

            v_session.v_omnidb_database.v_connection.Execute("update conv_tables_data set ctd_in_totalrecords = 0, " +
                                                             "ctd_in_transfrecords = 0, " +
                                                             "ctd_re_transfperc = 0, " +
                                                             "ctd_re_transferrate = 0, " +
                                                             "ctd_st_starttransfer = '', " +
                                                             "ctd_st_endtransfer = '', " +
                                                             "ctd_st_duration = '', " +
                                                             "ctd_ch_droprecords  = (case when ctd_ch_droprecords<>'N' then 'R' else ctd_ch_droprecords end), " +
                                                             "ctd_ch_createtable  = (case when ctd_ch_createtable<>'N' then 'R' else ctd_ch_createtable end), " +
                                                             "ctd_ch_createpk     = (case when ctd_ch_createpk<>'N' then 'R' else ctd_ch_createpk end), " +
                                                             "ctd_ch_createfk     = (case when ctd_ch_createfk<>'N' then 'R' else ctd_ch_createfk end), " +
                                                             "ctd_ch_createuq     = (case when ctd_ch_createuq<>'N' then 'R' else ctd_ch_createuq end), " +
                                                             "ctd_ch_createidx    = (case when ctd_ch_createidx<>'N' then 'R' else ctd_ch_createidx end), " +
                                                             "ctd_ch_transferdata = (case when ctd_ch_transferdata<>'N' then 'R' else ctd_ch_transferdata end) " +
                                                             "where conv_id=" + p_conv_id);

            System.Diagnostics.Process          process   = new System.Diagnostics.Process();
            System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo();
            startInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;

            if (v_session.v_current_os == "unix")
            {
                startInfo.FileName  = "mono";
                startInfo.Arguments = " --gc=sgen bin/OmniConversion.exe " + p_conv_id;
            }
            else
            {
                startInfo.FileName  = Environment.CurrentDirectory + "/bin/OmniConversion.exe";
                startInfo.Arguments = p_conv_id.ToString();
            }
            process.StartInfo = startInfo;
            process.Start();

            v_session.v_omnidb_database.v_connection.Execute("update conversions set conv_st_end = '', conv_re_perc = 0, conv_st_duration= '', conv_ch_status='E', process_id=" + process.Id + " where conv_id=" + p_conv_id);

            return(v_return);
        }
示例#9
0
        public static AjaxReturn GetFKs(int p_database_index, string p_table)
        {
            AjaxReturn v_return  = new AjaxReturn();
            Session    v_session = (Session)System.Web.HttpContext.Current.Session ["OMNIDB_SESSION"];

            if (v_session == null)
            {
                v_return.v_error    = true;
                v_return.v_error_id = 1;
                return(v_return);
            }

            OmniDatabase.Generic v_database = v_session.v_databases[p_database_index];

            System.Collections.Generic.List <System.Collections.Generic.List <string> > v_list_fks = new System.Collections.Generic.List <System.Collections.Generic.List <string> > ();

            try
            {
                System.Data.DataTable v_table_fks = v_database.QueryTablesForeignKeys(p_table);

                foreach (System.Data.DataRow v_table_fk in v_table_fks.Rows)
                {
                    System.Collections.Generic.List <string> v_fk = new System.Collections.Generic.List <string>();

                    v_fk.Add(v_table_fk["constraint_name"].ToString());
                    v_fk.Add(v_table_fk["column_name"].ToString());
                    v_fk.Add(v_table_fk["r_table_name"].ToString());
                    v_fk.Add(v_table_fk["r_column_name"].ToString());
                    v_fk.Add(v_table_fk["delete_rule"].ToString());
                    v_fk.Add(v_table_fk["update_rule"].ToString());

                    v_list_fks.Add(v_fk);
                }
            }
            catch (Spartacus.Database.Exception e)
            {
                v_return.v_error = true;
                v_return.v_data  = e.v_message.Replace("<", "&lt;").Replace(">", "&gt;").Replace(System.Environment.NewLine, "<br/>");

                return(v_return);
            }


            v_return.v_data = v_list_fks;

            return(v_return);
        }
示例#10
0
        public static AjaxReturn GetTables(int p_database_index)
        {
            AjaxReturn v_return  = new AjaxReturn();
            Session    v_session = (Session)System.Web.HttpContext.Current.Session["OMNIDB_SESSION"];

            if (v_session == null)
            {
                v_return.v_error    = true;
                v_return.v_error_id = 1;
                return(v_return);
            }

            OmniDatabase.Generic v_database = v_session.v_databases[p_database_index];

            System.Collections.Generic.List <TableReturn> v_list_tables = new System.Collections.Generic.List <TableReturn>();

            try
            {
                System.Data.DataTable v_tables = v_database.QueryTables(false);

                foreach (System.Data.DataRow v_table in v_tables.Rows)
                {
                    TableReturn v_obj = new TableReturn();

                    v_obj.v_name             = v_table["table_name"].ToString();
                    v_obj.v_has_primary_keys = v_database.v_has_primary_keys;
                    v_obj.v_has_foreign_keys = v_database.v_has_foreign_keys;
                    v_obj.v_has_uniques      = v_database.v_has_uniques;
                    v_obj.v_has_indexes      = v_database.v_has_indexes;

                    v_list_tables.Add(v_obj);
                }
            }
            catch (Spartacus.Database.Exception e)
            {
                v_return.v_error = true;
                v_return.v_data  = e.v_message.Replace("<", "&lt;").Replace(">", "&gt;").Replace(System.Environment.NewLine, "<br/>");

                return(v_return);
            }


            v_return.v_data = v_list_tables;

            return(v_return);
        }
示例#11
0
        public static AjaxReturn SaveConfigUser(string p_pwd)
        {
            AjaxReturn v_return  = new AjaxReturn();
            Session    v_session = (Session)System.Web.HttpContext.Current.Session ["OMNIDB_SESSION"];

            if (v_session == null)
            {
                v_return.v_error    = true;
                v_return.v_error_id = 1;
                return(v_return);
            }

            Spartacus.Utils.Cryptor v_cryptor = new Spartacus.Utils.Cryptor("omnidb_spartacus");

            System.IO.File.WriteAllText("config/admin.txt", v_cryptor.Encrypt(p_pwd));

            return(v_return);
        }
示例#12
0
        public static AjaxReturn TestConnection(int p_index)
        {
            AjaxReturn v_return  = new AjaxReturn();
            Session    v_session = (Session)System.Web.HttpContext.Current.Session ["OMNIDB_SESSION"];

            if (v_session == null)
            {
                v_return.v_error    = true;
                v_return.v_error_id = 1;
                return(v_return);
            }

            v_return.v_data = v_session.v_databases [p_index].TestConnection();



            return(v_return);
        }
示例#13
0
        public static AjaxReturn GetColumns(int p_database_index, string p_table)
        {
            AjaxReturn v_return  = new AjaxReturn();
            Session    v_session = (Session)System.Web.HttpContext.Current.Session ["OMNIDB_SESSION"];

            if (v_session == null)
            {
                v_return.v_error    = true;
                v_return.v_error_id = 1;
                return(v_return);
            }

            OmniDatabase.Generic v_database = v_session.v_databases[p_database_index];

            System.Collections.Generic.List <System.Collections.Generic.List <string> > v_list_columns = new System.Collections.Generic.List <System.Collections.Generic.List <string> > ();

            try
            {
                System.Data.DataTable v_columns = v_database.QueryTablesFields(p_table);

                foreach (System.Data.DataRow v_column in v_columns.Rows)
                {
                    System.Collections.Generic.List <string> v_column_details = new System.Collections.Generic.List <string>();

                    v_column_details.Add(v_column["column_name"].ToString());
                    v_column_details.Add(v_column["data_type"].ToString());
                    v_column_details.Add(v_column["data_length"].ToString());
                    v_column_details.Add(v_column["nullable"].ToString());

                    v_list_columns.Add(v_column_details);
                }
            }
            catch (Spartacus.Database.Exception e)
            {
                v_return.v_error = true;
                v_return.v_data  = e.v_message.Replace("<", "&lt;").Replace(">", "&gt;").Replace(System.Environment.NewLine, "<br/>");

                return(v_return);
            }

            v_return.v_data = v_list_columns;

            return(v_return);
        }
示例#14
0
        public static AjaxReturn RemoveConnection(int p_id)
        {
            AjaxReturn v_return  = new AjaxReturn();
            Session    v_session = (Session)System.Web.HttpContext.Current.Session ["OMNIDB_SESSION"];

            if (v_session == null)
            {
                v_return.v_error    = true;
                v_return.v_error_id = 1;
                return(v_return);
            }

            v_session.v_omnidb_database.v_connection.Execute("delete from connections " +
                                                             "where conn_id=" + p_id);

            v_session.RefreshDatabaseList();

            return(v_return);
        }
示例#15
0
        public static AjaxReturn CheckSessionMessage()
        {
            AjaxReturn v_return = new AjaxReturn();

            string v_message;

            if (System.Web.HttpContext.Current.Session ["OMNIDB_ALERT_MESSAGE"] != null)
            {
                v_message = System.Web.HttpContext.Current.Session ["OMNIDB_ALERT_MESSAGE"].ToString();
            }
            else
            {
                v_message = "";
            }

            System.Web.HttpContext.Current.Session ["OMNIDB_ALERT_MESSAGE"] = "";

            v_return.v_data = v_message;
            return(v_return);
        }
示例#16
0
        public static AjaxReturn GetFunctions(int p_database_index)
        {
            AjaxReturn v_return  = new AjaxReturn();
            Session    v_session = (Session)System.Web.HttpContext.Current.Session["OMNIDB_SESSION"];

            System.Collections.Generic.List <FunctionReturn> v_function_data_list = new System.Collections.Generic.List <FunctionReturn>();

            if (v_session == null)
            {
                v_return.v_error    = true;
                v_return.v_error_id = 1;
                return(v_return);
            }

            OmniDatabase.Generic v_database = v_session.v_databases[p_database_index];

            try
            {
                System.Data.DataTable v_tables = v_database.QueryFunctions();

                foreach (System.Data.DataRow v_table in v_tables.Rows)
                {
                    FunctionReturn v_function_data = new FunctionReturn();
                    v_function_data.v_name = v_table["name"].ToString();
                    v_function_data.v_id   = v_table["id"].ToString();

                    v_function_data_list.Add(v_function_data);
                }
            }
            catch (Spartacus.Database.Exception e)
            {
                v_return.v_error = true;
                v_return.v_data  = e.v_message.Replace("<", "&lt;").Replace(">", "&gt;").Replace(System.Environment.NewLine, "<br/>");

                return(v_return);
            }

            v_return.v_data = v_function_data_list;

            return(v_return);
        }
示例#17
0
        public static AjaxReturn GetProcedureFields(int p_database_index, string p_procedure)
        {
            AjaxReturn v_return  = new AjaxReturn();
            Session    v_session = (Session)System.Web.HttpContext.Current.Session ["OMNIDB_SESSION"];

            if (v_session == null)
            {
                v_return.v_error    = true;
                v_return.v_error_id = 1;
                return(v_return);
            }

            OmniDatabase.Generic v_database = v_session.v_databases[p_database_index];

            System.Collections.Generic.List <ProcedureFieldReturn> v_list_fields = new System.Collections.Generic.List <ProcedureFieldReturn> ();

            try
            {
                System.Data.DataTable v_fields = v_database.QueryProcedureFields(p_procedure);

                foreach (System.Data.DataRow v_field in v_fields.Rows)
                {
                    ProcedureFieldReturn v_field_data = new ProcedureFieldReturn();
                    v_field_data.v_name = v_field["name"].ToString();
                    v_field_data.v_type = v_field["type"].ToString();

                    v_list_fields.Add(v_field_data);
                }
            }
            catch (Spartacus.Database.Exception e)
            {
                v_return.v_error = true;
                v_return.v_data  = e.v_message.Replace("<", "&lt;").Replace(">", "&gt;").Replace(System.Environment.NewLine, "<br/>");

                return(v_return);
            }

            v_return.v_data = v_list_fields;

            return(v_return);
        }
示例#18
0
        public static AjaxReturn DeleteConversion(int p_conv_id)
        {
            AjaxReturn v_return  = new AjaxReturn();
            Session    v_session = (Session)System.Web.HttpContext.Current.Session ["OMNIDB_SESSION"];

            if (v_session == null)
            {
                v_return.v_error    = true;
                v_return.v_error_id = 1;
                return(v_return);
            }

            v_session.v_omnidb_database.v_connection.Execute("delete from conv_tables_data where conv_id=" + p_conv_id);
            v_session.v_omnidb_database.v_connection.Execute("delete from conversions where conv_id=" + p_conv_id);

            if (System.IO.File.Exists("log/conv_" + p_conv_id + ".txt"))
            {
                System.IO.File.Delete("log/conv_" + p_conv_id + ".txt");
            }

            return(v_return);
        }
示例#19
0
        public static AjaxReturn SaveUsers(System.Collections.Generic.List <System.Collections.Generic.List <string> > p_data, System.Collections.Generic.List <string> p_user_id_list)
        {
            AjaxReturn v_return  = new AjaxReturn();
            Session    v_session = (Session)System.Web.HttpContext.Current.Session ["OMNIDB_SESSION"];

            Spartacus.Utils.Cryptor v_cryptor = new Spartacus.Utils.Cryptor("omnidb_spartacus");

            if (v_session == null)
            {
                v_return.v_error    = true;
                v_return.v_error_id = 1;
                return(v_return);
            }

            string v_update_format = "update users  " +
                                     "set user_name   = '#p_user_name#', " +
                                     "password        = '******'   " +
                                     "where user_id   = #p_user_id#";

            for (int i = 0; i < p_data.Count; i++)
            {
                string v_update = v_update_format;
                v_update = v_update.Replace("#p_user_id#", p_user_id_list[i]);
                v_update = v_update.Replace("#p_user_name#", p_data [i][0]);
                try
                {
                    v_update = v_update.Replace("#p_password#", v_cryptor.Encrypt(p_data [i][1]));
                }
                catch (Spartacus.Utils.Exception)
                {
                    v_update = v_update.Replace("#p_password#", p_data [i][1]);
                }

                v_session.v_omnidb_database.v_connection.Execute(v_update);
            }


            return(v_return);
        }
示例#20
0
        public static AjaxReturn StopConversion(int p_conv_id)
        {
            AjaxReturn v_return  = new AjaxReturn();
            Session    v_session = (Session)System.Web.HttpContext.Current.Session ["OMNIDB_SESSION"];

            if (v_session == null)
            {
                v_return.v_error    = true;
                v_return.v_error_id = 1;
                return(v_return);
            }

            System.Data.DataTable v_conversion_data = v_session.v_omnidb_database.v_connection.Query("select process_id from conversions where conv_id=" + p_conv_id, "ConversionData");

            if (v_session.v_current_os == "unix")
            {
                System.Diagnostics.Process          process   = new System.Diagnostics.Process();
                System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo();
                startInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
                startInfo.FileName    = "kill";
                startInfo.Arguments   = " -9 " + v_conversion_data.Rows [0] [0].ToString();
                process.StartInfo     = startInfo;
                process.Start();
            }
            else
            {
                try {
                    System.Diagnostics.Process process = System.Diagnostics.Process.GetProcessById(Convert.ToInt32(v_conversion_data.Rows [0] [0]));
                    process.Kill();
                }
                catch (System.ArgumentException) {
                }
            }

            v_session.v_omnidb_database.v_connection.Execute("update conversions set conv_ch_status='C' where conv_id=" + p_conv_id);

            return(v_return);
        }
示例#21
0
        public static AjaxReturn GetTables()
        {
            AjaxReturn v_return  = new AjaxReturn();
            Session    v_session = (Session)System.Web.HttpContext.Current.Session ["OMNIDB_SESSION"];

            if (v_session == null)
            {
                v_return.v_error    = true;
                v_return.v_error_id = 1;
                return(v_return);
            }

            OmniDatabase.Generic v_database = v_session.GetSelectedDatabase();

            System.Collections.Generic.List <string> v_list_tables = new System.Collections.Generic.List <string> ();

            try
            {
                System.Data.DataTable v_tables = v_database.QueryTables(false);

                foreach (System.Data.DataRow v_table in v_tables.Rows)
                {
                    v_list_tables.Add(v_table["table_name"].ToString());
                }
            }
            catch (Spartacus.Database.Exception e)
            {
                v_return.v_error = true;
                v_return.v_data  = e.v_message.Replace("<", "&lt;").Replace(">", "&gt;").Replace(System.Environment.NewLine, "<br/>");

                return(v_return);
            }


            v_return.v_data = v_list_tables;

            return(v_return);
        }
示例#22
0
        public static AjaxReturn GetTreeInfo(int p_database_index)
        {
            AjaxReturn v_return    = new AjaxReturn();
            TreeReturn v_tree_data = new TreeReturn();
            Session    v_session   = (Session)System.Web.HttpContext.Current.Session ["OMNIDB_SESSION"];

            if (v_session == null)
            {
                v_return.v_error    = true;
                v_return.v_error_id = 1;
                return(v_return);
            }


            v_tree_data.v_mode = "database";

            TreeDatabaseReturn v_database_return = new TreeDatabaseReturn();

            OmniDatabase.Generic v_database = v_session.v_databases[p_database_index];

            v_database_return.v_database       = v_database.GetName();
            v_database_return.v_has_schema     = v_database.v_has_schema;
            v_database_return.v_has_functions  = v_database.v_has_functions;
            v_database_return.v_has_procedures = v_database.v_has_procedures;
            v_database_return.v_has_sequences  = v_database.v_has_sequences;

            if (v_database_return.v_has_schema)
            {
                v_database_return.v_schema = v_database.v_schema;
            }

            v_tree_data.v_database_return = v_database_return;

            v_return.v_data = v_tree_data;

            return(v_return);
        }
示例#23
0
        public static AjaxReturn SignIn(string p_username, string p_pwd)
        {
            AjaxReturn v_return = new AjaxReturn();

            Spartacus.Utils.Cryptor v_cryptor = new Spartacus.Utils.Cryptor("omnidb_spartacus");

            // Instantiating tool management database.
            OmniDatabase.Generic v_omnidb_database = OmniDatabase.Generic.InstantiateDatabase("", "0",
                                                                                              "sqlite",
                                                                                              "",
                                                                                              "",
                                                                                              System.Web.Configuration.WebConfigurationManager.AppSettings ["OmniDB.Database"].ToString(),
                                                                                              "",
                                                                                              "",
                                                                                              "");


            if (p_username == "admin")
            {
                string v_encrypted_pwd = System.IO.File.ReadAllText("config/admin.txt");

                string v_pwd;
                try {
                    v_pwd = v_cryptor.Decrypt(v_encrypted_pwd);

                    if (v_pwd == p_pwd)
                    {
                        Session v_session = new Session("-1", p_username, v_omnidb_database, "", "", "", "");
                        v_session.v_omnidb_version = System.Web.Configuration.WebConfigurationManager.AppSettings ["OmniDB.Version"].ToString();
                        System.Web.HttpContext.Current.Session ["OMNIDB_SESSION"] = v_session;
                        v_return.v_data = true;
                    }
                    else
                    {
                        System.Web.HttpContext.Current.Session ["OMNIDB_SESSION"] = null;
                        v_return.v_data = false;
                    }
                } catch (Spartacus.Utils.Exception) {
                    System.Web.HttpContext.Current.Session ["OMNIDB_SESSION"] = null;
                    v_return.v_data = false;
                }

                return(v_return);
            }
            else
            {
                try {
                    // Querying user information.
                    System.Data.DataTable v_user_data = v_omnidb_database.v_connection.Query(
                        "select u.user_id,              " +
                        "       u.password,             " +
                        "       t.theme_id,             " +
                        "       t.theme_name,           " +
                        "       t.theme_type,           " +
                        "       u.editor_font_size      " +
                        "from users u,                  " +
                        "     themes t                  " +
                        " where u.theme_id = t.theme_id " +
                        "and u.user_name = '" + p_username + "' ", "db_data");

                    // If username exists, decrypt password.
                    if (v_user_data.Rows.Count > 0)
                    {
                        string v_pwd;
                        try {
                            v_pwd = v_cryptor.Decrypt(v_user_data.Rows [0] ["password"].ToString());
                        } catch (Spartacus.Utils.Exception) {
                            v_pwd = v_user_data.Rows [0] ["password"].ToString();
                        }

                        // If password is correct, set user as logged in, instantiate Session and return true.
                        if (v_pwd == p_pwd)
                        {
                            Session v_session = new Session(v_user_data.Rows [0] ["user_id"].ToString(), p_username, v_omnidb_database, v_user_data.Rows[0]["theme_name"].ToString(), v_user_data.Rows[0]["theme_type"].ToString(), v_user_data.Rows[0]["theme_id"].ToString(), v_user_data.Rows [0] ["editor_font_size"].ToString());
                            v_session.v_omnidb_version = System.Web.Configuration.WebConfigurationManager.AppSettings ["OmniDB.Version"].ToString();
                            System.Web.HttpContext.Current.Session ["OMNIDB_SESSION"] = v_session;

                            if (!((Dictionary <string, Session>)System.Web.HttpContext.Current.Application["OMNIDB_SESSION_LIST"]).ContainsKey(v_session.v_user_id))
                            {
                                ((Dictionary <string, Session>)System.Web.HttpContext.Current.Application["OMNIDB_SESSION_LIST"]).Add(v_session.v_user_id, v_session);
                            }
                            else
                            {
                                ((Dictionary <string, Session>)System.Web.HttpContext.Current.Application["OMNIDB_SESSION_LIST"])[v_session.v_user_id] = v_session;
                            }

                            v_return.v_data = true;
                        }
                        else
                        {
                            System.Web.HttpContext.Current.Session ["OMNIDB_SESSION"] = null;
                            v_return.v_data = false;
                        }
                    }
                    else
                    {
                        System.Web.HttpContext.Current.Session ["OMNIDB_SESSION"] = null;
                        v_return.v_data = false;
                    }
                } catch (Spartacus.Database.Exception e) {
                    v_return.v_error = true;
                    v_return.v_data  = e.v_message;
                }

                return(v_return);
            }
        }
示例#24
0
		public static AjaxReturn CompareBases(int p_second_db)
		{

			HttpContext.Current.Server.ScriptTimeout = 86400;

			AjaxReturn v_g1 = new AjaxReturn();

			Session v_session = (Session)System.Web.HttpContext.Current.Session ["OMNIDB_SESSION"];

			if (v_session == null) 
			{
				v_g1.v_error = true;
				v_g1.v_error_id = 1;
				return v_g1;
			} 

			System.Collections.Generic.List<System.Collections.Generic.List<string>> v_list_tables = new System.Collections.Generic.List<System.Collections.Generic.List<string>> ();


			CompareData v_d1 = new CompareData ();

			CompareColumns v_compare_columns;

			int v_num_orange_tables = 0;
			int v_num_green_tables = 0;
			int v_num_red_tables = 0;

			int v_num_orange_cols = 0;
			int v_num_green_cols = 0;
			int v_num_red_cols = 0;


			String v_html = "";	

			String v_log = "";

			System.Data.DataTable v_data1;
			System.Data.DataTable v_data2;

			OmniDatabase.Generic v_database1 = v_session.GetSelectedDatabase();
			OmniDatabase.Generic v_database2 = v_session.v_databases[p_second_db];

			try
			{

				System.Data.DataTable v_orig_data_columns1 = v_database1.QueryTablesFields(null);

				System.Data.DataView v_view = new System.Data.DataView(v_orig_data_columns1);
				v_view.Sort = "table_name asc, column_name asc";
				System.Data.DataTable v_data_columns1 = v_view.ToTable();

				System.Data.DataTable v_orig_data_columns2 = v_database2.QueryTablesFields(null);

				v_view = new System.Data.DataView(v_orig_data_columns2);
				v_view.Sort = "table_name asc, column_name asc";
				System.Data.DataTable v_data_columns2 = v_view.ToTable();


				int v_pos_counter = 0;
				int v_count_cols = 0;

				v_data1 = new System.Data.DataTable ();
				v_data1.Columns.Add ("table_name");
				v_data1.Columns.Add ("num_rows");
				v_data1.Columns.Add ("position");

				string v_curr_table = v_orig_data_columns1.Rows[0]["table_name"].ToString();

				foreach (System.Data.DataRow v_column in v_orig_data_columns1.Rows) {
					if (v_curr_table!=v_column["table_name"].ToString()) {
						System.Data.DataRow v_new_row = v_data1.NewRow ();
						v_new_row ["table_name"] = v_curr_table;
						v_new_row ["num_rows"] = v_count_cols;
						v_new_row ["position"] = v_pos_counter;
						v_data1.Rows.Add (v_new_row);

						v_pos_counter += v_count_cols;
						v_count_cols=0;
						v_curr_table=v_column["table_name"].ToString();
					}
	
					v_count_cols++;
				
				}
					
				System.Data.DataRow v_last_row = v_data1.NewRow ();
				v_last_row ["table_name"] = v_curr_table;
				v_last_row ["num_rows"] = v_count_cols;
				v_last_row ["position"] = v_pos_counter;
				v_data1.Rows.Add (v_last_row);



				//Console.WriteLine("--------------------");

				v_pos_counter = 0;
				v_count_cols = 0;

				v_data2 = new System.Data.DataTable ();
				v_data2.Columns.Add ("table_name");
				v_data2.Columns.Add ("num_rows");
				v_data2.Columns.Add ("position");

				v_curr_table = v_orig_data_columns2.Rows[0]["table_name"].ToString();

				foreach (System.Data.DataRow v_column in v_orig_data_columns2.Rows) {
					if (v_curr_table!=v_column["table_name"].ToString()) {
						System.Data.DataRow v_new_row = v_data2.NewRow ();
						v_new_row ["table_name"] = v_curr_table;
						v_new_row ["num_rows"] = v_count_cols;
						v_new_row ["position"] = v_pos_counter;
						v_data2.Rows.Add (v_new_row);

						v_pos_counter += v_count_cols;
						v_count_cols=0;
						v_curr_table=v_column["table_name"].ToString();
					}
					v_count_cols++;

				}

				v_last_row = v_data2.NewRow ();
				v_last_row ["table_name"] = v_curr_table;
				v_last_row ["num_rows"] = v_count_cols;
				v_last_row ["position"] = v_pos_counter;
				v_data2.Rows.Add (v_last_row);


				int v_counter1 = 0;

				int v_counter2 = 0;

				while (v_counter1 < v_data1.Rows.Count) {
					
					if (v_counter2 < v_data2.Rows.Count) {
						
						int v_compare = String.Compare( v_data2.Rows[v_counter2]["table_name"].ToString(), v_data1.Rows[v_counter1]["table_name"].ToString(), true );
						//Console.WriteLine("Compare " + v_compare);
						// data1[i] nao esta em data2[i]

						System.Collections.Generic.List<string> v_table_info = new System.Collections.Generic.List<string>();


						if (v_compare == 1) {
							v_table_info.Add(v_data1.Rows[v_counter1]["table_name"].ToString());
							v_table_info.Add("-1");

							v_html += PrintTable(v_data1.Rows[v_counter1]["table_name"].ToString(),"green","red");
							v_html += PrintTableColumns(v_data1.Rows[v_counter1],v_data_columns1,"green","red");
							v_num_red_cols += Convert.ToInt32(v_data1.Rows[v_counter1]["num_rows"]);
							v_counter1++;
						}
						// data2[i] nao esta em data1[i]
						else if (v_compare == -1) {
							v_table_info.Add(v_data2.Rows[v_counter2]["table_name"].ToString());
							v_table_info.Add("1");

							v_html += PrintTable(v_data2.Rows[v_counter2]["table_name"].ToString(),"red","green");
							v_html += PrintTableColumns(v_data2.Rows[v_counter2],v_data_columns2,"red","green");
							v_num_red_cols += Convert.ToInt32(v_data2.Rows[v_counter2]["num_rows"]);
							v_counter2++;
						}
						else {
							
							//Console.WriteLine("iguais");
							v_compare_columns = CompareTablesColumns(v_data1.Rows[v_counter1],v_data_columns1,v_data2.Rows[v_counter2],v_data_columns2);

							int v_total_cols = Math.Max(Convert.ToInt32(v_data1.Rows[v_counter1]["num_rows"]),Convert.ToInt32(v_data2.Rows[v_counter2]["num_rows"]));

							//Console.WriteLine(v_total_cols + " " + v_compare_columns.v_green_items + " " + v_compare_columns.v_orange_items);

							v_num_green_cols += v_compare_columns.v_green_items;
							v_num_orange_cols += v_compare_columns.v_orange_items;
							v_num_red_cols += v_total_cols - v_compare_columns.v_green_items - v_compare_columns.v_orange_items;

							if (v_total_cols==v_compare_columns.v_green_items) {
								v_table_info.Add(v_data1.Rows[v_counter1]["table_name"].ToString());
								v_table_info.Add("0");

								v_html += PrintTable(v_data1.Rows[v_counter1]["table_name"].ToString(),"green","green");
								v_num_green_tables++;
							}
							else {
								v_table_info.Add(v_data1.Rows[v_counter1]["table_name"].ToString());
								v_table_info.Add("2");

								v_html += PrintTable(v_data1.Rows[v_counter1]["table_name"].ToString(),"orange","orange");
								v_num_orange_tables++;
							}

							v_html += v_compare_columns.v_html;

							v_counter1++;
							v_counter2++;
						}

						v_list_tables.Add(v_table_info);

					}
					else {
						v_html += PrintTable(v_data1.Rows[v_counter1]["table_name"].ToString(),"green","red");
						v_html += PrintTableColumns(v_data1.Rows[v_counter1],v_data_columns1,"green","red");
						v_counter1++;
					}
				}

				while (v_counter2 < v_data2.Rows.Count) {
					System.Collections.Generic.List<string> v_table_info = new System.Collections.Generic.List<string>();

					v_table_info.Add(v_data2.Rows[v_counter2]["table_name"].ToString());
					v_table_info.Add("0");



					v_list_tables.Add(v_table_info);

					v_html += PrintTable(v_data2.Rows[v_counter2]["table_name"].ToString(),"red","green");
					v_html += PrintTableColumns(v_data2.Rows[v_counter2],v_data_columns2,"red","green");
					v_counter2++;
				}

				int v_total_tables = Math.Max(v_data1.Rows.Count,v_data2.Rows.Count);

				v_num_red_tables = v_total_tables - v_num_green_tables - v_num_orange_tables;

				//Console.WriteLine("TABLES -> Greens: " + v_num_green_tables + " - Oranges: " + v_num_orange_tables + " - Reds: " + v_num_red_tables);
				//Console.WriteLine("COLUMNS -> Greens: " + v_num_green_cols + " - Oranges: " + v_num_orange_cols + " - Reds: " + v_num_red_cols);

			}
			catch (Spartacus.Database.Exception e)
			{
				System.Console.WriteLine(e.v_message);
			}

			v_d1.v_html = v_html;
			v_d1.v_log = v_log;
			v_d1.v_num_green_tables = v_num_green_tables;
			v_d1.v_num_orange_tables = v_num_orange_tables;
			v_d1.v_num_red_tables = v_num_red_tables;
			v_d1.v_num_green_cols = v_num_green_cols;
			v_d1.v_num_orange_cols = v_num_orange_cols;
			v_d1.v_num_red_cols = v_num_red_cols;

			//v_g1.v_data = v_d1;
			v_g1.v_data = v_list_tables;


			return v_g1;

		}
示例#25
0
        public static AjaxReturn GetConversionDetails(int p_conv_id, int p_mode)
        {
            AjaxReturn      v_return      = new AjaxReturn();
            ConversionsData v_return_data = new ConversionsData();
            Session         v_session     = (Session)System.Web.HttpContext.Current.Session ["OMNIDB_SESSION"];

            if (v_session == null)
            {
                v_return.v_error    = true;
                v_return.v_error_id = 1;
                return(v_return);
            }

            string v_filter = "";

            if (p_mode == 1)
            {
                v_filter = " and ctd_ch_transferdata='F' ";
            }
            else if (p_mode == 2)
            {
                v_filter = " and ctd_ch_transferdata<>'F' ";
            }

            System.Data.DataTable v_conversions = v_session.v_omnidb_database.v_connection.Query("select * from conv_tables_data where conv_id=" + p_conv_id + v_filter + " order by conv_id desc", "Conversions");


            System.Collections.Generic.List <System.Collections.Generic.List <string> > v_conv_list = new System.Collections.Generic.List <System.Collections.Generic.List <string> >();

            int v_index = 0;

            foreach (System.Data.DataRow v_conv in v_conversions.Rows)
            {
                System.Collections.Generic.List <string> v_connection_data_list = new System.Collections.Generic.List <string>();

                string v_bar = "";

                if (v_conv ["ctd_re_transfperc"].ToString() == "100")
                {
                    v_bar = "bar_green";
                }
                else
                {
                    v_bar = "bar_yellow";
                }

                string v_perc = "<div id=\"progress\" class=\"progress\"><div class=\"" + v_bar + "\" style=\"width:" + v_conv["ctd_re_transfperc"].ToString().Replace(",", ".") + "%\"></div ><div class=\"percent\" >" + v_conv["ctd_re_transfperc"].ToString() + "%</div></div></div>";

                string v_estimate = "";

                if (v_conv["ctd_ch_transferdata"].ToString() == "E")
                {
                    double v_est = Convert.ToDouble(v_conv["ctd_re_transferrate"].ToString());

                    if (v_est != 0)
                    {
                        int v_total  = int.Parse(v_conv ["ctd_in_totalrecords"].ToString());
                        int v_transf = int.Parse(v_conv ["ctd_in_transfrecords"].ToString());
                        int v_remain = v_total - v_transf;

                        double v_time_left = v_remain / v_est;

                        v_estimate = string.Format("{0:00}:{1:00}:{2:00}", v_time_left / 3600, (v_time_left / 60) % 60, v_time_left % 60);
                    }
                }

                v_connection_data_list.Add(v_conv["ctd_st_table"].ToString());
                v_connection_data_list.Add("<div style='width: 100%; text-align: center;'><img class='img_ht' src='images/status/status_" + v_conv["ctd_ch_droprecords"].ToString() + ".png'/></div>");
                v_connection_data_list.Add("<div style='width: 100%; text-align: center;'><img class='img_ht' src='images/status/status_" + v_conv["ctd_ch_createtable"].ToString() + ".png'/></div>");
                v_connection_data_list.Add("<div style='width: 100%; text-align: center;'><img class='img_ht' src='images/status/status_" + v_conv["ctd_ch_createpk"].ToString() + ".png'/></div>");
                v_connection_data_list.Add("<div style='width: 100%; text-align: center;'><img class='img_ht' src='images/status/status_" + v_conv["ctd_ch_createfk"].ToString() + ".png'/></div>");
                v_connection_data_list.Add("<div style='width: 100%; text-align: center;'><img class='img_ht' src='images/status/status_" + v_conv["ctd_ch_createuq"].ToString() + ".png'/></div>");
                v_connection_data_list.Add("<div style='width: 100%; text-align: center;'><img class='img_ht' src='images/status/status_" + v_conv["ctd_ch_createidx"].ToString() + ".png'/></div>");
                v_connection_data_list.Add("<div style='width: 100%; text-align: center;'><img class='img_ht' src='images/status/status_" + v_conv["ctd_ch_transferdata"].ToString() + ".png'/></div>");
                v_connection_data_list.Add(v_conv["ctd_st_transferfilter"].ToString());
                v_connection_data_list.Add(String.Format("{0:0,0}", int.Parse(v_conv["ctd_in_totalrecords"].ToString())));
                v_connection_data_list.Add(String.Format("{0:0,0}", int.Parse(v_conv["ctd_in_transfrecords"].ToString())));
                v_connection_data_list.Add(v_perc);
                v_connection_data_list.Add(v_conv["ctd_re_transferrate"].ToString() + " records/s");
                v_connection_data_list.Add(v_estimate);
                v_connection_data_list.Add(v_conv["ctd_st_starttransfer"].ToString());
                v_connection_data_list.Add(v_conv["ctd_st_endtransfer"].ToString());
                v_connection_data_list.Add(v_conv["ctd_st_duration"].ToString());

                v_index++;

                v_conv_list.Add(v_connection_data_list);
            }

            v_return_data.v_data = v_conv_list;

            v_return.v_data = v_return_data;
            return(v_return);
        }
示例#26
0
        public static AjaxReturn GetConnections()
        {
            AjaxReturn      v_return      = new AjaxReturn();
            ConnectionsData v_return_data = new ConnectionsData();
            Session         v_session     = (Session)System.Web.HttpContext.Current.Session ["OMNIDB_SESSION"];

            Spartacus.Utils.Cryptor v_cryptor = new Spartacus.Utils.Cryptor("omnidb_spartacus");

            if (v_session == null)
            {
                v_return.v_error    = true;
                v_return.v_error_id = 1;
                return(v_return);
            }

            System.Data.DataTable v_connections = v_session.v_omnidb_database.v_connection.Query("select * from connections where user_id = " + v_session.v_user_id + " order by dbt_st_name, conn_id", "Connections");
            System.Data.DataTable v_techs       = v_session.v_omnidb_database.v_connection.Query("select dbt_st_name from db_type", "Technologies");

            System.Collections.Generic.List <System.Collections.Generic.List <string> > v_connection_list = new System.Collections.Generic.List <System.Collections.Generic.List <string> >();
            System.Collections.Generic.List <string> v_tech_list    = new System.Collections.Generic.List <string>();
            System.Collections.Generic.List <string> v_conn_id_list = new System.Collections.Generic.List <string>();

            foreach (System.Data.DataRow v_tech in v_techs.Rows)
            {
                v_tech_list.Add(v_tech["dbt_st_name"].ToString());
            }

            int v_index = 0;

            foreach (System.Data.DataRow v_connection in v_connections.Rows)
            {
                System.Collections.Generic.List <string> v_connection_data_list = new System.Collections.Generic.List <string>();

                v_connection_data_list.Add(v_connection["dbt_st_name"].ToString());

                try
                {
                    v_connection_data_list.Add(v_cryptor.Decrypt(v_connection["server"].ToString()));
                    v_connection_data_list.Add(v_cryptor.Decrypt(v_connection["port"].ToString()));
                    v_connection_data_list.Add(v_cryptor.Decrypt(v_connection["service"].ToString()));
                    v_connection_data_list.Add(v_cryptor.Decrypt(v_connection["schema"].ToString()));
                    v_connection_data_list.Add(v_cryptor.Decrypt(v_connection["user"].ToString()));
                    v_connection_data_list.Add(v_cryptor.Decrypt(v_connection["password"].ToString()));
                }
                catch (Spartacus.Utils.Exception)
                {
                    v_connection_data_list.Add(v_connection["server"].ToString());
                    v_connection_data_list.Add(v_connection["port"].ToString());
                    v_connection_data_list.Add(v_connection["service"].ToString());
                    v_connection_data_list.Add(v_connection["schema"].ToString());
                    v_connection_data_list.Add(v_connection["user"].ToString());
                    v_connection_data_list.Add(v_connection["password"].ToString());
                }

                v_connection_data_list.Add("<img src='images/tab_close.png' class='img_ht' onclick='removeConnection(" + v_connection["conn_id"].ToString() + ")'/>" +
                                           "<img src='images/test.png' class='img_ht' onclick='testConnection(" + v_index + ")'/>");

                v_index++;

                v_connection_list.Add(v_connection_data_list);

                v_conn_id_list.Add(v_connection["conn_id"].ToString());
            }

            v_return_data.v_data         = v_connection_list;
            v_return_data.v_technologies = v_tech_list;
            v_return_data.v_conn_ids     = v_conn_id_list;

            v_return.v_data = v_return_data;
            return(v_return);
        }
示例#27
0
        public static AjaxReturn GetConversions()
        {
            AjaxReturn      v_return      = new AjaxReturn();
            ConversionsData v_return_data = new ConversionsData();
            Session         v_session     = (Session)System.Web.HttpContext.Current.Session ["OMNIDB_SESSION"];

            if (v_session == null)
            {
                v_return.v_error    = true;
                v_return.v_error_id = 1;
                return(v_return);
            }

            System.Data.DataTable v_conversions = v_session.v_omnidb_database.v_connection.Query("select * from conversions where user_id = " + v_session.v_user_id + " order by conv_id desc", "Conversions");


            System.Collections.Generic.List <System.Collections.Generic.List <string> > v_conv_list = new System.Collections.Generic.List <System.Collections.Generic.List <string> >();

            int v_index = 0;

            foreach (System.Data.DataRow v_conv in v_conversions.Rows)
            {
                System.Collections.Generic.List <string> v_connection_data_list = new System.Collections.Generic.List <string>();

                string v_src_conn = "";
                string v_dst_conn = "";
                string v_src_tech = "";
                string v_dst_tech = "";

                foreach (OmniDatabase.Generic v_database in v_session.v_databases)
                {
                    if (v_database.v_conn_id == v_conv ["conn_id_src"].ToString())
                    {
                        v_src_conn = v_database.PrintDatabaseInfo();
                        v_src_tech = v_database.v_db_type;
                        break;
                    }
                }

                foreach (OmniDatabase.Generic v_database in v_session.v_databases)
                {
                    if (v_database.v_conn_id == v_conv ["conn_id_dst"].ToString())
                    {
                        v_dst_conn = v_database.PrintDatabaseInfo();
                        v_dst_tech = v_database.v_db_type;
                        break;
                    }
                }

                string v_bar = "";


                if (v_conv ["conv_re_perc"].ToString() == "100")
                {
                    v_bar = "bar_green";
                }
                else
                {
                    v_bar = "bar_yellow";
                }

                string v_perc = "<div id=\"progress\" class=\"progress\"><div class=\"" + v_bar + "\" style=\"width:" + v_conv["conv_re_perc"].ToString().Replace(",", ".") + "%\"></div ><div class=\"percent\" >" + v_conv["conv_re_perc"].ToString() + "%</div></div></div>";

                string v_actions = "<img src='images/table_edit.png' class='img_ht' onclick='conversionDetails(" + v_conv ["conv_id"].ToString() + ")'/>" +
                                   "<img src='images/log.png' class='img_ht' onclick='viewLog(" + v_conv ["conv_id"].ToString() + ")'/>";

                if (v_conv ["conv_ch_status"].ToString() != "E")
                {
                    v_actions += "<img src='images/start.png' class='img_ht' onclick='startConversion(" + v_conv ["conv_id"].ToString() + ")'/>" +
                                 "<img src='images/tab_close.png' class='img_ht' onclick='deleteConversion(" + v_conv ["conv_id"].ToString() + ")'/>";
                }
                else
                {
                    v_actions += "<img src='images/stop.png' class='img_ht' onclick='stopConversion(" + v_conv ["conv_id"].ToString() + ")'/>";
                }

                v_connection_data_list.Add("<img src='images/" + v_src_tech + "_medium.png' class='img_ht' style='margin-right: 5px;'/>" + v_src_conn);
                v_connection_data_list.Add("<img src='images/" + v_dst_tech + "_medium.png' class='img_ht' style='margin-right: 5px;'/>" + v_dst_conn);
                v_connection_data_list.Add(v_conv["conv_st_start"].ToString());
                v_connection_data_list.Add(v_conv["conv_st_end"].ToString());
                v_connection_data_list.Add(v_perc);
                v_connection_data_list.Add(v_conv["conv_ch_status"].ToString());
                v_connection_data_list.Add(v_conv["conv_st_comments"].ToString());
                v_connection_data_list.Add(v_conv["conv_st_duration"].ToString());
                v_connection_data_list.Add(v_actions);

                v_index++;

                v_conv_list.Add(v_connection_data_list);
            }

            v_return_data.v_data = v_conv_list;

            v_return.v_data = v_return_data;
            return(v_return);
        }
示例#28
0
        public static AjaxReturn ConversionData()
        {
            AjaxReturn v_return = new AjaxReturn();

            Session v_session = (Session)System.Web.HttpContext.Current.Session ["OMNIDB_SESSION"];

            if (v_session == null)
            {
                v_return.v_error    = true;
                v_return.v_error_id = 1;
                return(v_return);
            }

            ConversionDataReturn v_conversion_data = new ConversionDataReturn();

            string v_html = "<table class='conversion_table'>" +
                            "<tr>" +
                            "<th>Drop Existing Records</th>" +
                            "<th>Create Table</th>" +
                            "<th>Transfer Data</th>" +
                            "<th>Create Primary Keys</th>" +
                            "<th>Create Foreign Keys</th>" +
                            "<th>Create Uniques</th>" +
                            "<th>Create Indexes</th>" +
                            "<th>Transfer Filter</th>" +
                            "<th>Table</th>" +
                            "</tr>" +
                            "<tr>" +
                            "<td><input id='cb_all_drop_records' onchange='changeAllCheckboxes(this,0)' type='checkbox'/></td>" +
                            "<td><input id='cb_all_create_tables' onchange='changeAllCheckboxes(this,1)' type='checkbox'/></td>" +
                            "<td><input id='cb_all_transfer_data' onchange='changeAllCheckboxes(this,2)' type='checkbox'/></td>" +
                            "<td><input id='cb_all_create_pks' onchange='changeAllCheckboxes(this,3)' type='checkbox'/></td>" +
                            "<td><input id='cb_all_create_fks' onchange='changeAllCheckboxes(this,4)' type='checkbox'/></td>" +
                            "<td><input id='cb_all_create_uniques' onchange='changeAllCheckboxes(this,5)' type='checkbox'/></td>" +
                            "<td><input id='cb_all_create_indexes' onchange='changeAllCheckboxes(this,6)' type='checkbox'/></td>" +
                            "<td></td>" +
                            "<td></td>" +
                            "</tr>";

            System.Collections.Generic.List <string> v_tables_list = new System.Collections.Generic.List <string> ();

            OmniDatabase.Generic v_database = v_session.GetSelectedDatabase();

            try {
                System.Data.DataTable v_tables = v_database.QueryTables(false);

                int v_counter = 0;

                foreach (System.Data.DataRow v_table in v_tables.Rows)
                {
                    string tname = v_table ["table_name"].ToString();

                    v_tables_list.Add(tname);

                    string v_style = "";

                    if (v_counter % 2 == 0)
                    {
                        v_style = "style='background-color: rgb(234, 237, 249)'";
                    }

                    v_html += "<tr " + v_style + ">" +
                              "<td><input id='cb_" + tname + "_drop_records' type='checkbox'/></td>" +
                              "<td><input id='cb_" + tname + "_create_table' type='checkbox'/></td>" +
                              "<td><input id='cb_" + tname + "_transfer_data' type='checkbox'/></td>" +
                              "<td><input id='cb_" + tname + "_create_pks' type='checkbox'/></td>" +
                              "<td><input id='cb_" + tname + "_create_fks' type='checkbox'/></td>" +
                              "<td><input id='cb_" + tname + "_create_uniques' type='checkbox'/></td>" +
                              "<td><input id='cb_" + tname + "_create_indexes' type='checkbox'/></td>" +
                              "<td><input id='txt_" + tname + "_transferfilter' type='text'/></td>" +
                              "<td>" + tname + "</td>" +
                              "</tr>";

                    v_counter++;
                }

                v_html += "</table>";

                v_conversion_data.v_html   = v_html;
                v_conversion_data.v_tables = v_tables_list;

                v_return.v_data = v_conversion_data;
            }
            catch (Spartacus.Database.Exception e)
            {
                v_return.v_error = true;
                v_return.v_data  = e.v_message.Replace("<", "&lt;").Replace(">", "&gt;").Replace(System.Environment.NewLine, "<br/>");

                return(v_return);
            }


            return(v_return);
        }
示例#29
0
        public static AjaxReturn StartConversion(int p_dst_index, System.Collections.Generic.List <ConversionTableData> p_tables_data)
        {
            AjaxReturn v_return = new AjaxReturn();

            Session v_session = (Session)System.Web.HttpContext.Current.Session ["OMNIDB_SESSION"];

            if (v_session == null)
            {
                v_return.v_error    = true;
                v_return.v_error_id = 1;
                return(v_return);
            }

            int v_dst_index = p_dst_index;

            System.Data.DataTable v_max_conv_id = v_session.v_omnidb_database.v_connection.Query("select max(conv_id)+1 as next_id from conversions", "Conversions");

            string v_next_id = "";

            if (v_max_conv_id.Rows [0] ["next_id"].ToString() != "")
            {
                v_next_id = v_max_conv_id.Rows [0] ["next_id"].ToString();
            }
            else
            {
                v_next_id = "0";
            }

            OmniDatabase.Generic v_database = v_session.GetSelectedDatabase();

            v_session.v_omnidb_database.v_connection.Execute("insert into conversions values ( " +
                                                             v_next_id + "," +
                                                             v_database.v_conn_id + "," +
                                                             v_session.v_databases[v_dst_index].v_conn_id + "," +
                                                             "'','','0','R','',''," + v_session.v_user_id + ",'')");

            foreach (ConversionTableData v_table_data in p_tables_data)
            {
                string v_drop_records   = "N";
                string v_create_table   = "N";
                string v_create_pks     = "N";
                string v_create_fks     = "N";
                string v_create_uniques = "N";
                string v_create_indexes = "N";
                string v_transfer_data  = "N";

                bool v_create_record = false;

                if (v_table_data.v_drop_records)
                {
                    v_drop_records  = "R";
                    v_create_record = true;
                }
                if (v_table_data.v_create_table)
                {
                    v_create_table  = "R";
                    v_create_record = true;
                }
                if (v_table_data.v_transfer_data)
                {
                    v_transfer_data = "R";
                    v_create_record = true;
                }

                if (v_session.v_databases [v_dst_index].v_can_add_constraint)
                {
                    if (v_table_data.v_create_pks)
                    {
                        v_create_pks    = "R";
                        v_create_record = true;
                    }
                    if (v_table_data.v_create_fks)
                    {
                        v_create_fks    = "R";
                        v_create_record = true;
                    }
                    if (v_table_data.v_create_uniques)
                    {
                        v_create_uniques = "R";
                        v_create_record  = true;
                    }
                    if (v_table_data.v_create_indexes)
                    {
                        v_create_indexes = "R";
                        v_create_record  = true;
                    }
                }

                if (v_create_record)
                {
                    v_session.v_omnidb_database.v_connection.Execute("insert into conv_tables_data values ( " +
                                                                     v_next_id + ",'" +
                                                                     v_table_data.v_table + "','" +
                                                                     v_drop_records + "','" +
                                                                     v_create_table + "','" +
                                                                     v_create_pks + "','" +
                                                                     v_create_fks + "','" +
                                                                     v_create_uniques + "','" +
                                                                     v_create_indexes + "','" +
                                                                     v_transfer_data + "'," +
                                                                     "0,0,0,0,'','','','','','','','','','','" +
                                                                     v_table_data.v_transferfilter.Replace("'", "''") + "')");
                }
            }

            return(v_return);
        }