Ejemplo n.º 1
0
        public void DBgen()
        {
            SQL_CONTEXT db = new SQL_CONTEXT();

            if (!db.Database.Exists())
            {
                db.Database.Delete();
                db.SaveChanges();
                db.Database.CreateIfNotExists();
                db.SaveChanges();
            }
        }
Ejemplo n.º 2
0
        public static void migrate(string tableName, DateTime dateFrom, DateTime dateTo)
        {
            StringsToCommand st = Connections.stringsToCommand.Where(s => s.TableName == tableName).FirstOrDefault();

            ORCLconn.ConnectionString = Connections.ORCLconnectionString
                                        .Replace(@":userID", @"neprintsev_ia")
                                        .Replace(@":password", @"awsedrDRSEAW");
            ORCLconn.Open();

            SQLconn.ConnectionString = @"data source=.\SQLEXPRESS;initial catalog=DWH_REPLICA;integrated security=True;";
            SQLconn.Open();

            OracleCommand oSelcomm = new OracleCommand(st.ORCLSelectCommand, ORCLconn);
            SqlCommand    sDelcomm = new SqlCommand(st.SQLDeleteCommand, SQLconn);
            SqlCommand    sInscomm = new SqlCommand(st.SQLInsertCommand, SQLconn);

            oSelcomm.Parameters.Add("DateFrom", OracleDbType.Date);
            oSelcomm.Parameters.Add("DateTo", OracleDbType.Date);
            oSelcomm.Parameters["DateFrom"].Value = dateFrom;
            oSelcomm.Parameters["DateTo"].Value   = dateTo;

            sDelcomm.Parameters.Add("DateFrom", SqlDbType.DateTime);
            sDelcomm.Parameters.Add("DateTo", SqlDbType.DateTime);
            sDelcomm.Parameters["DateFrom"].Value = dateFrom;
            sDelcomm.Parameters["DateTo"].Value   = dateTo;

            if (Connections.stringsToCommand.Select(s => s.TableName == tableName) != null)
            {
                sDelcomm.ExecuteNonQuery();
                OracleDataReader reader = oSelcomm.ExecuteReader();
                SQL_CONTEXT      db     = new SQL_CONTEXT();


                if (tableName == "FD_ACQ_D")
                {
                    sInscomm.Parameters.Add("dt_trn", SqlDbType.Date);
                    sInscomm.Parameters.Add("dt_reg", SqlDbType.Date);
                    sInscomm.Parameters.Add("acquire_bank", SqlDbType.Char);
                    sInscomm.Parameters.Add("pay_sys", SqlDbType.Char);
                    sInscomm.Parameters.Add("issuer_type", SqlDbType.Char);
                    sInscomm.Parameters.Add("type_transaction", SqlDbType.Char);
                    sInscomm.Parameters.Add("tran_name", SqlDbType.Char);
                    sInscomm.Parameters.Add("merchantID", SqlDbType.Char);
                    sInscomm.Parameters.Add("terminal_type", SqlDbType.Char);
                    sInscomm.Parameters.Add("is_linked", SqlDbType.Char);
                    sInscomm.Parameters.Add("amt", SqlDbType.Decimal);
                    sInscomm.Parameters.Add("fee", SqlDbType.Decimal);
                    sInscomm.Parameters.Add("cnt", SqlDbType.BigInt);
                }
                while (reader.Read())
                {
                    var b = reader[12].GetType();

                    sInscomm.Parameters["dt_trn"].Value           = (DateTime)reader[0];
                    sInscomm.Parameters["dt_reg"].Value           = (DateTime)reader[1];
                    sInscomm.Parameters["acquire_bank"].Value     = (string)reader[2];
                    sInscomm.Parameters["pay_sys"].Value          = (string)reader[3];
                    sInscomm.Parameters["issuer_type"].Value      = (string)reader[4];
                    sInscomm.Parameters["type_transaction"].Value = (string)reader[5];
                    sInscomm.Parameters["tran_name"].Value        = (string)reader[6];
                    sInscomm.Parameters["merchantID"].Value       = (string)reader[7];
                    sInscomm.Parameters["terminal_type"].Value    = (string)reader[8];
                    sInscomm.Parameters["is_linked"].Value        = (string)reader[9];
                    sInscomm.Parameters["amt"].Value = (double)reader[10];
                    sInscomm.Parameters["fee"].Value = (double)reader[11];
                    sInscomm.Parameters["cnt"].Value = (Int64)reader[12];
                    sInscomm.ExecuteNonQuery();
                }
            }
        }