示例#1
0
 private void MainFormTabImpl_Load(object sender, EventArgs e)
 {
     WindowState = FormWindowState.Maximized;
     Text        = string.Format("{0} v{1}", ConstString.ApplicationTitle, PrintingApp.GetVersionManager().ApplicationVersion);
     BindQueryGroup();
     BindDataGrid();
 }
示例#2
0
        static void Main()
        {
            log4net.Config.XmlConfigurator.Configure();
            Log.Info("Application start");

            PrintingApp.Initialize();
            ReportTemplateFileProvider.Initialize(PrintingApp.GetVersionManager().ReportTemplateVersion);

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new LoginForm());
        }
示例#3
0
        private void DoWorkInBackgroud()
        {
            try
            {
                string username = txtUsername.Text;
                string password = txtPassword.Text;

                BeginInvoke(new Action <String, MessageType>(ShowMessage), "用户认证中...", MessageType.Infomation);
                var userService          = ServiceFactory.GetClientApplicationService();
                var authenticateResponse = userService.Authenticate(new AuthenticateRequest()
                {
                    Username = username,
                    Password = password,
                    HostMac  = LocalMachineInfomationProvider.GetMac(),
                });
                if (authenticateResponse.ResultType != ResultTypes.Ok)
                {
                    Log.Info("Authenticate fail.");
                    Invoke(new Action <String, MessageType>(ShowMessage), "用户认证失败...", MessageType.Warning);
                    Invoke(new Action <bool>(ControlButtons), true);
                    return;
                }
                Log.Info("Authenticate OK.");
                PrintingApp.CurrentUserInfo = authenticateResponse.UserInfo;
                PrintingApp.UserCredential  = new UserCredential()
                {
                    UserName = username, Password = password
                };


                BeginInvoke(new Action <String, MessageType>(ShowMessage), "用户授权中...", MessageType.Infomation);
                var authorizeResponse = userService.Authorize(new AuthorizeRequest()
                {
                    Username = username,
                    Password = password,
                });
                if (authorizeResponse.ResultType != ResultTypes.Ok)
                {
                    Log.Info("Authorize fail.");
                    Invoke(new Action <String, MessageType>(ShowMessage), "用户授权失败...", MessageType.Warning);
                    Invoke(new Action <bool>(ControlButtons), true);
                    return;
                }
                Log.Info("Authorize OK.");
                PrintingApp.LabAssociations          = authorizeResponse.LabAssociations.ToList();
                PrintingApp.OrganizationAssociations = authorizeResponse.OrganizationAssociations.ToList();
                PrintingApp.ReportTemplates          = authorizeResponse.ReportTemplates.ToList();

                Log.Info("Check updates");
                BeginInvoke(new Action <String, MessageType>(ShowMessage), "检查更新中...", MessageType.Infomation);
                ApplicationUpdateChecker updateChecker = new ApplicationUpdateChecker();
                updateChecker.Initialize();

                var applicationUpdateEventInfo = updateChecker.CheckUpdates();
                if (applicationUpdateEventInfo.Type == ApplicationUpdateEventType.ApplicationVersionChanged)
                {
                    Log.Info("New application version detected.");
                    string url = applicationUpdateEventInfo.LatestVersion.DownloadUrl;
                    Invoke(new Action <string>(ShowAutoUpdateForm), url);
                    return; // stop process to forbid login to system
                }
                else if (applicationUpdateEventInfo.Type == ApplicationUpdateEventType.ReportTemplateVersionChanged)
                {
                    var applicationVersionManager = PrintingApp.GetVersionManager();
                    applicationVersionManager.UpdateReportTemplateVersion(applicationUpdateEventInfo.LatestVersion.ReportTemplateVersion);
                }

                Invoke(new Action <String, MessageType>(ShowMessage), "登陆成功...", MessageType.Infomation);
                Invoke(new Action(ShowMainForm));
            }
            catch (Exception ex)
            {
                Invoke(new Action <String, MessageType>(ShowMessage), "发生登陆异常,请联系管理员...", MessageType.Warning);
                Invoke(new Action <bool>(ControlButtons), true);
                Log.Error("Login fail.", ex);
            }
        }