Пример #1
0
        public IDatabaseHandler CreateDatabase(string providerName)
        {
            IDatabaseHandler database = null;

            switch (providerName.ToLower())
            {
            case "system.data.sqlclient":
                database = new SqlDataAccess(connectionStringSettings);
                break;

            case "system.data.oracleclient":
                database = new OracleDataAccess(connectionStringSettings);
                break;

            case "system.data.oleDb":
                database = new OledbDataAccess(connectionStringSettings);
                break;

            case "system.data.odbc":
                database = new OdbcDataAccess(connectionStringSettings);
                break;
            }

            return(database);
        }
Пример #2
0
 static void Main()
 {
     SqlDataAccess.GetData();
     OracleDataAccess.GetData();
     Circle.Draw();
     MyConsole.Write("Write This");
     MsAccessDataAccess.GetData();
 }
Пример #3
0
        //private readonly IEmployeeDataAccess _dataAccess;

        //public OracleDataFormatter(IEmployeeDataAccess dataAccess)
        //{
        //    _dataAccess = dataAccess;
        //}

        public override string FormatEmployeeData()
        {
            IEmployeeDataAccess dataAccess = new OracleDataAccess();

            Console.WriteLine("Getting Employee Data...");
            var employeesList = dataAccess.GetEmployeeData();

            Console.WriteLine("Formatting the Employee details...");
            return(string.Format("Employee Name of Employee ID {0} is {1} and Designation of the Employee is {2}",
                                 employeesList[0].EmployeeId,
                                 employeesList[0].EmployeeName,
                                 employeesList[0].Designation));
        }
Пример #4
0
 /// <summary>
 /// 更新云秒杀记录
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public int UpdateDsYmsUser(DsYmsUserModel model)
 {
     string sql = "update selfstock.DS_YMS_USER set showname=:showname,lastresults=:lastresults,sort=:sort where username=:username";
     var commandParameters = new[]
                                 {
                                     new OracleParameter(":showname", OracleDbType.Varchar2),
                                     new OracleParameter(":lastresults", OracleDbType.Decimal),
                                     new OracleParameter(":sort", OracleDbType.Int32),
                                     new OracleParameter(":username", OracleDbType.Varchar2)                                            
                                 };
     commandParameters[0].Value = model.ShowName;
     commandParameters[1].Value = model.LastResults;
     commandParameters[2].Value = model.Sort;
     commandParameters[3].Value = model.UserName;
     return OracleDataAccess.ExecuteNonQuery(OracleDataAccess.OracleConnectionUpdbString, CommandType.Text, sql, commandParameters);
 }
Пример #5
0
        static void Main(string[] args)
        {
            SqlDataAccess sql = new SqlDataAccess();

            Console.WriteLine(sql.GetData());

            MsAccessDataAccess ms = new MsAccessDataAccess();

            Console.WriteLine(ms.GetData());

            OracleDataAccess oracleDataAccess = new OracleDataAccess();

            Console.WriteLine(oracleDataAccess.GetData());

            //Circle circle = new Circle();
            //Console.WriteLine(circle.Draw());
        }
Пример #6
0
 /// <summary>
 /// 删除云秒杀记录
 /// </summary>
 /// <param name="UserName"></param>
 /// <returns></returns>
 public int DeleteDsYmsUser(string UserName)
 {
     try
     {
         string sql = "DELETE FROM selfstock.DS_YMS_USER WHERE USERNAME=:USERNAME";
         var commandParameters = new[]
                                     {
                                         new OracleParameter(":USERNAME", OracleDbType.Varchar2)
                                     };
         commandParameters[0].Value = UserName;
         return OracleDataAccess.ExecuteNonQuery(OracleDataAccess.OracleConnectionUpdbString, CommandType.Text, sql, commandParameters);
     }
     catch (OracleException ce)
     {
         Loger.Error(ce);
     }
     return 0;
 }
Пример #7
0
 /// <summary>
 /// 插入云秒杀记录
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public int InsertDsYmsUser(DsYmsUserModel model)
 {
     string sql = "INSERT INTO selfstock.DS_YMS_USER (username,showname,lastresults,sort,package)";
     sql += " VALUES(:username,:showname,:lastresults,:sort,:package)";
     var commandParameters = new[]
                                 {
                                     new OracleParameter(":username", OracleDbType.Varchar2),
                                     new OracleParameter(":showname", OracleDbType.Varchar2),
                                     new OracleParameter(":lastresults", OracleDbType.Decimal),
                                     new OracleParameter(":sort", OracleDbType.Int32),
                                     new OracleParameter(":package", OracleDbType.Varchar2)
                                 };
     commandParameters[0].Value = model.UserName;
     commandParameters[1].Value = model.ShowName;
     commandParameters[2].Value = model.LastResults;
     commandParameters[3].Value = model.Sort;
     commandParameters[4].Value = model.Package.ToLower();
     return OracleDataAccess.ExecuteNonQuery(OracleDataAccess.OracleConnectionUpdbString, CommandType.Text, sql, commandParameters);
 }
Пример #8
0
        /// <summary>
        /// Code by Ajit: to filter system
        /// This gives the information of the External Server. Here the code to fetch the connection should be written
        /// This can be called from class inheriting this Base class
        /// </summary>
        protected string[] GetKmOriginalSystem()
        {
            string sErrorMsg;          //to handle error msg.

            string[] Original_Systems; //array to hold original systems
            // Holds the Cached Array of original systems from which data to be fetched. //By AJIT :To exclude Systems
            Original_Systems = (string[])chConfig.Get("CSN_KM_CONFIG", "SystemConfig");
            if (Original_Systems == null || Original_Systems.Length == 0)
            {
                try
                {//if Cache is empty then, cache it from database as below.
                    string           sSql       = "SELECT SERVER_ID FROM CSN.KM_SYSTEMCONFIG WHERE SELECTED = 1";
                    OracleDataAccess objConn    = (OracleDataAccess)OracleDataAccess.GetObj("CSN");
                    DataSet          dsLanguage = objConn.ExecuteDataSet(CommandType.Text, sSql);
                    if (dsLanguage != null)
                    {
                        DataTable disClosLevel = dsLanguage.Tables[0];
                        if (disClosLevel.Rows.Count > 0)
                        {//dynamically assigning array lenth
                            Original_Systems = new string[disClosLevel.Rows.Count];
                            //adding values to array using for loop
                            for (int cnt = 0; cnt < disClosLevel.Rows.Count; cnt++)
                            {
                                Original_Systems[cnt] = disClosLevel.Rows[cnt]["SERVER_ID"].ToString();
                            }
                            chConfig.Insert("CSN_KM_CONFIG", "SystemConfig", Original_Systems);//caching the db values
                        }
                        disClosLevel = null;
                    }
                    dsLanguage = null;
                }
                catch (OracleException ex)
                {
                    sErrorMsg = "Unable to fetch server configuration from Database:" + ex.Message;
                    return(Original_Systems);//will return null array
                }
            }
            return(Original_Systems);//return array of system values
        }
Пример #9
0
        /// <summary>
        /// 查询云秒杀记录
        /// </summary>
        /// <param name="package"></param>
        /// <returns></returns>
        public IList<DsYmsUserModel> GetYmsUserList(string package)
        {
            try
            {
                string sql;
                if (string.IsNullOrEmpty(package))
                {
                    sql = "select y.username,y.showname,y.lastresults,y.sort,y.package,u.capital,u.pos_ratio FROM selfstock.DS_YMS_USER y join selfstock.DS_QR_USERINFO u on y.username=u.user_name WHERE u.user_type='1'";
                }
                else
                {
                    sql = "select y.username,y.showname,y.lastresults,y.sort,y.package,u.capital,u.pos_ratio FROM selfstock.DS_YMS_USER y join selfstock.DS_QR_USERINFO u on y.username=u.user_name WHERE y.package='" + package.ToLower() + "' and u.user_type='1'";
                }
                OracleDataReader reader = OracleDataAccess.ExecuteReader(OracleDataAccess.OracleConnectionUpdbString, CommandType.Text, sql);

                IList<DsYmsUserModel> list = new List<DsYmsUserModel>();
                while (reader.Read())
                {
                    var model = new DsYmsUserModel();
                    model.UserName = reader["username"].ToString();
                    model.ShowName = reader["showname"].ToString();
                    model.LastResults = (decimal)reader["lastresults"];
                    model.Sort = int.Parse(reader["sort"].ToString());
                    model.Package = reader["package"].ToString();
                    model.Capital = (decimal)reader["capital"];
                    model.PosRatio = (decimal)reader["pos_ratio"];
                    list.Add(model);
                }
                reader.Close();
                return list;
            }
            catch (OracleException ce)
            {
                Loger.Error(ce);
                return null;
            }
        }
Пример #10
0
        /// <summary>
        /// This gives the information of the External Service. Here the code to fetch the connection should be written
        /// This is can be set when in the constructor of the class inheriting the abstract class
        /// </summary>
        protected bool GetServiceConfig(string serviceName)
        {
            string sConfigName, sErrorMsg, sExpirationTime;

            string [] aExpirationTime = null;

            Hashtable htConfigData = ( Hashtable )chConfig.Get("CSN_KM_CONFIG", "ServiceGatewayConfigData");

            if (htConfigData == null)
            {
                try
                {
                    htConfigData = new Hashtable();
                    string sSql = "SELECT CONFIGNAME, CONFIGVALUE FROM CSN.SERVICECONFIG WHERE SERVICENAME = '" + serviceName + "'";
                    //ODP.Net 10.7 Changes
                    OracleDataAccess objConn = (OracleDataAccess)OracleDataAccess.GetObj("CSN");
                    //ODPDataAccess objConn = (ODPDataAccess)ODPDataAccess.GetObj("CSN");
                    IDataReader dataReader = objConn.ExecuteReader(CommandType.Text, sSql);

                    while (dataReader.Read())
                    {
                        sConfigName = dataReader["CONFIGNAME"].ToString();
                        switch (sConfigName)
                        {
                        case "TAXONOMYURL":
                            taxonomyUrl = dataReader["CONFIGVALUE"].ToString();
                            htConfigData.Add("TAXONOMYURL", taxonomyUrl);
                            break;

                        case "SEARCHURL":
                            searchUrl = dataReader["CONFIGVALUE"].ToString();
                            htConfigData.Add("SEARCHURL", searchUrl);
                            break;

                        case "PRESENTATIONURL":
                            presentationUrl = dataReader["CONFIGVALUE"].ToString();
                            htConfigData.Add("PRESENTATIONURL", presentationUrl);
                            break;

                        case "USERID":
                            userId = dataReader["CONFIGVALUE"].ToString();
                            htConfigData.Add("USERID", userId);
                            break;

                        case "PASSWORD":
                            userPassword = HP.Sasp.Utility.Cryptography.Decrypt(dataReader["CONFIGVALUE"].ToString());
                            htConfigData.Add("PASSWORD", userPassword);
                            break;

                        case "PORTALID":
                            portalId = dataReader["CONFIGVALUE"].ToString();
                            htConfigData.Add("PORTALID", portalId);
                            break;

                        case "TIMEOUT":
                            timeOut = Convert.ToInt32(dataReader["CONFIGVALUE"]);
                            htConfigData.Add("TIMEOUT", timeOut);
                            break;

                        case "MAX_RESULTS":
                            max_results = Convert.ToInt32(dataReader["CONFIGVALUE"]);
                            htConfigData.Add("MAX_RESULTS", max_results);
                            break;

                        case "RESULTS_PER_PAGE":
                            results_per_page = Convert.ToInt32(dataReader["CONFIGVALUE"]);
                            htConfigData.Add("RESULTS_PER_PAGE", results_per_page);
                            break;

                        case "PRODUCT_ROOT_OID":
                            product_root_oid = Convert.ToInt32(dataReader["CONFIGVALUE"]);
                            htConfigData.Add("PRODUCT_ROOT_OID", product_root_oid);
                            break;

                        case "COMPONENT_ROOT_OID":
                            component_root_oid = Convert.ToInt32(dataReader["CONFIGVALUE"]);
                            htConfigData.Add("COMPONENT_ROOT_OID", component_root_oid);
                            break;

                        case "OS_ROOT_OID":
                            os_root_oid = Convert.ToInt32(dataReader["CONFIGVALUE"]);
                            htConfigData.Add("OS_ROOT_OID", os_root_oid);
                            break;

                        case "TAXCACHE_RESET_TIME":
                            sExpirationTime = dataReader["CONFIGVALUE"].ToString();
                            aExpirationTime = sExpirationTime.Split(":".ToCharArray());
                            expiration_hrs  = Convert.ToInt32(aExpirationTime[0]);
                            expiration_min  = Convert.ToInt32(aExpirationTime[1]);
                            expiration_sec  = Convert.ToInt32(aExpirationTime[2]);
                            htConfigData.Add("TAXCACHE_RESET_TIME", sExpirationTime);
                            break;
                        }
                    }
                }
                catch (OracleException ex)
                {
                    sErrorMsg = "Unable to fetch service configuration from Database:" + ex.Message;
                    return(false);
                }
                chConfig.Insert("CSN_KM_CONFIG", "ServiceGatewayConfigData", htConfigData);
            }
            else
            {
                System.Collections.IDictionaryEnumerator configDataEnumerator = htConfigData.GetEnumerator();

                while (configDataEnumerator.MoveNext())
                {
                    sConfigName = configDataEnumerator.Key.ToString();
                    switch (sConfigName)
                    {
                    case "TAXONOMYURL":
                        taxonomyUrl = configDataEnumerator.Value.ToString();
                        break;

                    case "SEARCHURL":
                        searchUrl = configDataEnumerator.Value.ToString();
                        break;

                    case "PRESENTATIONURL":
                        presentationUrl = configDataEnumerator.Value.ToString();
                        break;

                    case "USERID":
                        userId = configDataEnumerator.Value.ToString();
                        break;

                    case "PASSWORD":
                        userPassword = configDataEnumerator.Value.ToString();
                        break;

                    case "PORTALID":
                        portalId = configDataEnumerator.Value.ToString();
                        break;

                    case "TIMEOUT":
                        timeOut = (int)configDataEnumerator.Value;
                        break;

                    case "MAX_RESULTS":
                        max_results = (int)configDataEnumerator.Value;
                        break;

                    case "RESULTS_PER_PAGE":
                        results_per_page = (int)configDataEnumerator.Value;
                        break;

                    case "PRODUCT_ROOT_OID":
                        product_root_oid = (int)configDataEnumerator.Value;
                        break;

                    case "COMPONENT_ROOT_OID":
                        component_root_oid = (int)configDataEnumerator.Value;
                        break;

                    case "OS_ROOT_OID":
                        os_root_oid = (int)configDataEnumerator.Value;
                        break;

                    case "TAXCACHE_RESET_TIME":
                        sExpirationTime = configDataEnumerator.Value.ToString();
                        aExpirationTime = sExpirationTime.Split(":".ToCharArray());
                        expiration_hrs  = Convert.ToInt32(aExpirationTime[0]);
                        expiration_min  = Convert.ToInt32(aExpirationTime[1]);
                        expiration_sec  = Convert.ToInt32(aExpirationTime[2]);
                        break;
                    }
                }
            }
            return(true);
        }
Пример #11
0
        /// <summary>
        /// 根据Provider字符串获取数据类型
        /// </summary>
        /// <param name="provider"></param>
        /// <returns></returns>
        public static DatabaseType GetDatabaseType(string provider)
        {
            DatabaseType dbType = DatabaseType.None;

            provider = provider.ToLower();
            if (provider == SQLServer.ToLower() || provider == SQLAzure.ToLower())
            {
                dbType = DatabaseType.SqlServer;
            }
            else if (provider == SqlServerCe.ToLower() || provider == SqlServerCe40.ToLower())
            {
                dbType = DatabaseType.SqlCe;
            }
            else if (provider == SQLite.ToLower())
            {
                dbType = DatabaseType.SQLite;
            }

            else if (provider == MySql.ToLower())
            {
                dbType = DatabaseType.MySql;
            }
            else if (provider == Oracle.ToLower())
            {
                dbType = DatabaseType.Oracle;
            }
            else if (provider == OracleDataAccess.ToLower())
            {
                dbType = DatabaseType.Oracle;
            }
            else if (provider == OracleManagedDataAccess.ToLower())
            {
                dbType = DatabaseType.Oracle;
            }
            else if (provider == Access.ToLower())
            {
                dbType = DatabaseType.Access;
            }
            else if (provider == OleDb.ToLower())
            {
                dbType = DatabaseType.OleDb;
            }
            else if (provider == Odbc.ToLower())
            {
                dbType = DatabaseType.OleDb;
            }
            else if (provider == PostgreSQL.ToLower())
            {
                dbType = DatabaseType.PostgreSQL;
            }
            else if (provider == DB2.ToLower())
            {
                dbType = DatabaseType.DB2;
            }
            else if (provider == FirebirdSql.ToLower())
            {
                dbType = DatabaseType.Firebird;
            }
            else if (provider == SybaseASA.ToLower())
            {
                dbType = DatabaseType.SybaseASA;
            }
            else if (provider == SybaseASE.ToLower())
            {
                dbType = DatabaseType.SybaseASE;
            }
            else if (provider == SybaseUltraLite.ToLower())
            {
                dbType = DatabaseType.SybaseUltraLite;
            }
            else if (provider == DM.ToLower())
            {
                dbType = DatabaseType.DM;
            }
            return(dbType);
        }
Пример #12
0
        public MainWindow()
        {
            InitializeComponent();

            oracleDataAccess = new OracleDataAccess("DB_HOST", "DB_PORT", "DB_SID", "db_UID", "db_PWD");
        }