啊鑫
2024-07-09 0552fcc8cb73fc3021e2915129f55a42ed3f20e5
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#region
 
using System.Windows.Forms;
using CSFrameworkV5.Business;
using CSFrameworkV5.Common;
using CSFrameworkV5.Core;
using CSFrameworkV5.Core.Common;
using CSFrameworkV5.DataAccess;
 
#endregion
 
namespace CSFrameworkV5.ClientFoundationTester
{
    /// <summary>
    ///     测试公共类
    /// </summary>
    public class TesterTools
    {
        private static string _KEY = "%SaFz$^p";
        private static string _IV = "3aW%^&Fd";
 
        /// <summary>
        ///     模拟登陆用户信息
        /// </summary>
        public static Loginer Loginer
        {
            get
            {
                var user = new Loginer();
                user.Account = "admin";
                user.AccountName = "管理员";
                user.DatasetIDs = "Normal;";
                user.DBID = "Normal";
                user.DBName = "CSFrameworkV5_Normal";
                user.FlagAdmin = "Y";
                return user;
            }
        }
 
        /// <summary>
        ///     初始化测试环境
        /// </summary>
        public static void InitTestEnviroment()
        {
            Loginer.CurrentUser = Loginer;
 
            KeyProvider.Default =
                new KeyProviderRijndael(_KEY,
                    _IV); //初始化对称加密预设秘钥                       
 
            //读取SQL连接配置信息
            IWriteSQLConfigValue cfgNormal =
                new IniFileWriter(Application.StartupPath +
                                  @"\config\db.ini"); //用户配置
 
            //加载账套数据库信息                    
            DatabaseProvider.LoadSystemDatabase(cfgNormal);
 
            //加载当前登陆用户的账号
            DatabaseProvider.LoadDatabase(Loginer.CurrentUser.DBID);
 
            //读取系统数据库名称
            Globals.DEF_SYSTEM_DBName = cfgNormal.DatabaseName;
 
            DatabaseProvider.IsAdoDirect = true;
            DatabaseProvider.IsLocalConnection = true;
            BridgeFactory.BridgeType = BridgeType.ADODirect;
            BridgeFactory.AdoDirectType = AdoDirectType.LAN;
        }
    }
}