Пример #1
0
        /// <summary>
        /// 获取帐套库的数据库写入HasTable
        /// </summary>
        public static void GetDbAccount()
        {
            if (SG.Parameters.SGParameter.hAccountConn != null)
            {
                SG.Parameters.SGParameter.hAccountConn.Clear();
            }
            else
            {
                SG.Parameters.SGParameter.hAccountConn = new System.Collections.Hashtable();
            }
            string dbType = DbConfiguration_Factory.DbType;
            string sConn  = DbConfiguration_Factory.GetAccountConnString();
            string sSQL   = "SELECT     T_Account.FID, T_Account.FNumber, T_Account.FName, T_Account.FDatabase, T_Account.FServerName, T_Account.FUser, T_Account.FPwd, T_Account.FDataType, " +
                            " T_Account.FOrgID, T_Account.FCreateDate, T_Account.FBackUpDate, T_Account.FVer, T_Account.FProductName, T_Account.FOnlineCount, T_Account.FServerIP, T_DbType.FSign " +
                            " FROM         T_Account INNER JOIN T_DbType ON T_Account.FID = T_DbType.FID  ";
            DataTable sAccount = new DataBaseLayer(sConn, dbType).ExecuteQueryDataTable(sSQL);

            foreach (DataRow myRow in sAccount.Rows)
            {
                SG.Parameters.SGParameter.sAccountConn sAC = new Parameters.SGParameter.sAccountConn();
                sAC.sServer   = myRow["FServerName"].ToString();
                sAC.sDatabase = myRow["FDatabase"].ToString();
                sAC.sUser     = myRow["FUser"].ToString();
                sAC.sPwd      = myRow["FPwd"].ToString();
                sAC.sDbType   = myRow["FSign"].ToString();
                SG.Parameters.SGParameter.hAccountConn.Add(myRow["FNumber"].ToString(), sAC);
            }
        }
Пример #2
0
        public DataTable GetSystemOrganization()
        {
            string dbType = DbConfiguration_Factory.DbType;
            string sConn  = DbConfiguration_Factory.GetAccountConnString();
            string sSQL   = "select FID,FNumber,FName from T_Organization";

            return(new DataBaseLayer(sConn, dbType).ExecuteQueryDataTable(sSQL.ToUpper()));
        }
Пример #3
0
        public System.Data.DataTable GetSystemDataSetByOrg(string sOrgID)
        {
            string dbType = DbConfiguration_Factory.DbType;
            string sConn  = DbConfiguration_Factory.GetAccountConnString();
            string sSQL   = string.Format(@"SELECT    T_Account.FID, T_Account.FNumber, T_Account.FName, T_Account.FDatabase, T_Account.FServerName, T_Account.FUser, T_Account.FPwd, T_Account.FDataType, T_Account.FOrgID, T_Account.FCreateDate, T_Account.FBackUpDate, T_Account.FVer, T_Account.FProductName, T_Account.FOnlineCount,   T_Account.FServerIP,T_DbType.FSign " +
                                          " FROM         T_Account inner join T_DbType ON T_Account.FID = T_DbType.FID  where T_Account.FIsUse=1 and T_Account.FOrgID='{0}'", sOrgID);

            return(new DataBaseLayer(sConn, dbType).ExecuteQueryDataTable(sSQL.ToUpper()));
        }
Пример #4
0
        /// <summary>
        /// 测试AdoDirect连接
        /// </summary>
        /// <returns></returns>
        private static bool TestADOConnection()
        {
            // 数据访问层的模块文件
            string DalFile = Application.StartupPath + @"\" + DLL_FILE_NAME;

            bool exists = File.Exists(DalFile);

            if (false == exists)
            {
                throw new CustomException(LOST_DAL_FILE + "\r\n\r\nFile:" + DalFile);
            }
            return(exists && DbConfiguration_Factory.TestConnection());  //SqlConfiguration().TestConnection();
        }
Пример #5
0
        /// <summary>
        /// 初始化桥接功能
        /// </summary>
        public static bool InitializeBridge()
        {
            bool connected = false;

            try
            {
                //ADODirect方式,从INI文件读配置信息
                if (BridgeType.ADODirect == BridgeType)
                {
                    //获取连接配置.支持4种连接配置:1.INI, 2.注册表 3.SQLExpress INI 4.Web.Config
                    //IWriteSQLConfigValue cfgRegistry = new RegisterWriter(SqlConfiguration.REG_SQL_CFG);

                    //开发环境,直接从INI文件读取SQL连接配置
                    //IWriteSQLConfigValue cfgSQLExpress = new SQLExpressCfg(Application.StartupPath + @"\CSFramework.ini");

                    //生产环境连接配置
                    IWriteSQLConfigValue cfgNormal = new IniFileWriter(Application.StartupPath + DbConfiguration_Factory.INI_CFG_PATH);

                    //设置配置信息
                    //SqlConfiguration.SetSQLConfig(cfgNormal);
                    DbConfiguration_Factory.SetSQLConfig(cfgNormal);
                    connected = TestADOConnection();//测试AdoDirect连接
                }

                if (BridgeType.WebService == BridgeType)
                {
                    //初始化服务端的SQL连接
                    connected = TestWebServiceConnection();//测试WebService连接
                }

                if (BridgeType.WcfHost == BridgeType)
                {
                    //初始化服务端SQL连接
                    connected = TestWcfHostConnection();//测试WebService连接
                }
            }
            catch (Exception ex)
            {
                Msg.ShowException(ex);
            }

            //测试桥接是否成功
            if (false == connected)
            {
                Msg.Warning(TEST_BRIDGE_FAILED + "\r\n\r\nBridgeType:" + BridgeFactory.BridgeType.ToString());
            }

            return(connected);
        }
Пример #6
0
 public bool TestConnection()
 {
     try
     {
         string dbType = DbConfiguration_Factory.DbType;
         string sConn  = DbConfiguration_Factory.GetAccountConnString();
         string sSQL   = "SELECT    T_Account.FID, T_Account.FNumber, T_Account.FName, T_Account.FDatabase, T_Account.FServerName, T_Account.FUser, T_Account.FPwd, T_Account.FDataType, T_Account.FOrgID, T_Account.FCreateDate, T_Account.FBackUpDate, T_Account.FVer, T_Account.FProductName, T_Account.FOnlineCount,   T_Account.FServerIP,T_DbType.FSign " +
                         " FROM         T_Account inner join T_DbType ON T_Account.FID = T_DbType.FID  ";
         DataTable dt = new DataBaseLayer(sConn, dbType).ExecuteQueryDataTable(sSQL);
         if (dt == null)
         {
             return(false);
         }
         else
         {
             return(true);
         }
     }
     catch
     {
         return(false);
     }
 }