Пример #1
0
        public void UpdateThridDBSource(ThridDBSourceData thridDbSource)
        {
            SQL sql = SqlHelper.CreateSQL("更新三方数据源", "Update 影像数据源信息 " +
                                          " Set 数据源别名=:数据源别名, 数据源信息=:数据源信息 where 数据源ID=:数据源ID");

            sql.AddParameter("数据源ID", DbType.String, thridDbSource.数据源ID);
            sql.AddParameter("数据源别名", DbType.String, thridDbSource.数据源别名);
            sql.AddParameter("数据源信息", DbType.String, thridDbSource.数据源信息.ToString());

            _dbHelper.ExecuteSQL(sql);
        }
Пример #2
0
        public void NewThridDBSource(ThridDBSourceData thridDbSource)
        {
            SQL sql = SqlHelper.CreateSQL("插入三方数据源", "insert into 影像数据源信息(数据源ID, 数据源别名, 数据源信息)" +
                                          " values(:数据源ID, :数据源别名, :数据源信息)");


            sql.AddParameter("数据源ID", DbType.String, thridDbSource.数据源ID);
            sql.AddParameter("数据源别名", DbType.String, thridDbSource.数据源别名);
            sql.AddParameter("数据源信息", DbType.String, thridDbSource.数据源信息.ToString());

            DataTable dtResult = _dbHelper.ExecuteSQL(sql);
        }
Пример #3
0
        static public IDBQuery GetThridDBHelper(string dbServerAlias, IDBQuery dbSys, ref string strErr, bool blnForceRefresh = false)
        {
            strErr = "";

            if (string.IsNullOrEmpty(dbServerAlias))
            {
                return(dbSys);
            }

            if (_thridDbBuffer == null)
            {
                _thridDbBuffer = new Dictionary <string, IDBQuery>();
            }

            if (blnForceRefresh)
            {
                //如果是强制刷新,则先移除缓存对象
                if (_thridDbBuffer.ContainsKey(dbServerAlias))
                {
                    _thridDbBuffer.Remove(dbServerAlias);
                }
            }

            if (_thridDbBuffer.ContainsKey(dbServerAlias))
            {
                return(_thridDbBuffer[dbServerAlias]);
            }
            else
            {
                SQL sql = CreateSQL("查询三方数据源信息", "Select 数据源ID, 数据源别名,数据源信息 From 影像数据源信息 where 数据源别名=:数据源别名");
                sql.AddParameter("数据源别名", DbType.String, dbServerAlias);

                DataTable dtThridDb = dbSys.ExecuteSQL(sql);
                if (dtThridDb == null || dtThridDb.Rows.Count <= 0)
                {
                    return(dbSys);
                }

                ThridDBSourceData thridDbSource = new ThridDBSourceData();
                thridDbSource.BindRowData(dtThridDb.Rows[0]);


                IDBProvider dbProvider = ServerEnum.GetDBProvider(thridDbSource.数据源信息.驱动文件);
                if (dbProvider == null)
                {
                    strErr = "数据访问实例 [" + thridDbSource.数据源信息.驱动文件 + "] 创建失败,将返回默认数据提供对象。";
                    return(null);
                }


                dbProvider.Init(thridDbSource.数据源信息.务器IP, thridDbSource.数据源信息.端口, thridDbSource.数据源信息.数据实例,
                                thridDbSource.数据源信息.授权账号, ThridDBSourceModel.DecryPwd(thridDbSource.数据源信息.授权密码));

                IDbConnection dc = dbProvider.Open(ref strErr);

                if (dc == null)
                {
                    strErr = "数据服务访问失败:" + strErr;
                    return(null);
                }

                //缓存有效的数据源链接对象
                if (dbProvider != null)
                {
                    _thridDbBuffer.Add(dbServerAlias, dbProvider);
                }

                return(dbProvider);
            }
        }