Exemplo n.º 1
0
        static void Main(string[] args)
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            // System.Console.WriteLine(WindowsIdentity.GetCurrent().Name);

            // 主应用程序集名
            BaseSystemInfo.MainAssembly = System.Reflection.Assembly.GetEntryAssembly().GetName().Name;
            BaseSystemInfo.StartupPath  = Application.StartupPath;
            BaseSystemInfo.AppIco       = Path.Combine(Application.StartupPath, "Resource/Form.ico");

            // PermissionItemService permissionItemService = new Business.PermissionItemService();
            // BasePermissionItemEntity permissionItemEntity = permissionItemService.GetEntityByCode(BaseSystemInfo.UserInfo, "UserAdmin");
            // System.Console.WriteLine(permissionItemEntity);

            // 获取配置信息
            GetConfig();
            // 强制使用表数据权限
            // BaseSystemInfo.UseTablePermission = true;
            BaseSystemInfo.WebHostUrl = ConfigurationManager.AppSettings["WebHostUrl"];

            // 这里检查是否有外部用户名密码传输进来过
            if (args.Length > 0)
            {
                for (int i = 0; i < args.Length; i++)
                {
                    if (args[i].ToString().StartsWith("UserName"))
                    {
                        BaseSystemInfo.CurrentUserName = args[i].ToString().Substring("UserName".Length + 1);
                    }
                    else if (args[i].ToString().StartsWith("Password"))
                    {
                        BaseSystemInfo.CurrentPassword = args[i].ToString().Substring("Password".Length + 1);
                        if (BaseSystemInfo.ClientEncryptPassword)
                        {
                            BaseSystemInfo.CurrentPassword = SecretUtil.Encrypt(BaseSystemInfo.CurrentPassword);
                        }
                    }
                    // Console.WriteLine(i.ToString() + ":" + args[i].ToString());
                }
            }

            if (BaseSystemInfo.MultiLanguage)
            {
                // 多语言国际化加载
                ResourceManagerWrapper.Instance.LoadResources(Path.Combine(Application.StartupPath, "Resources/Localization/"));
                // 从当前指定的语言包读取信息
                AppMessage.GetLanguageResource();
            }

            // 初始化服务
            DotNetService.Instance.InitService();

            // 按配置的登录页面进行登录,这里需要运行的是主程序才可以
            Form mainForm = BaseInterfaceLogic.GetForm(BaseSystemInfo.MainAssembly, BaseSystemInfo.MainForm);

            Application.Run(mainForm);
        }