Exemplo n.º 1
0
        private void btEnter_Click(object sender, EventArgs e)
        {
            var validate = vm.Validate();

            if (validate.HasError)
            {
                validate.ShowErrorMessage("授权错误");
                return;
            }

            this.GetService <SystemController>().ExecuteAsync(
                c => c.SaveExpirationDate(MeasurementSystemSetting.SystemData.Token, vm.Model),
                (result) =>
            {
                if (!result.Status)
                {
                    AppFramework.Context.ShowError(result.Message, "授权失败");
                }
                else
                {
                    AppFramework.Context.ShowAlert("授权成功,需要重启软件系统生效", "授权成功");
                    AppFramework.Exit();
                }
            });
        }
Exemplo n.º 2
0
        private void btOK_Click(object sender, EventArgs e)
        {
            if (tbPws.Text != "2233")
            {
                AppFramework.Context.ShowError("密码错误");
                return;
            }
            var validate = vm.Validate();

            if (validate.HasError)
            {
                validate.ShowErrorMessage("保存数据库设置");
                return;
            }

            this.GetService <SystemController>().ExecuteAsync(
                c => c.SaveDatabase(MeasurementSystemSetting.SystemData.Token, vm.Model),
                (result) =>
            {
                if (!result.Status)
                {
                    AppFramework.Context.ShowError(result.Message, "保存数据库设置");
                }
                else
                {
                    AppFramework.Context.ShowAlert("设置数据库成功,需要重启软件系统生效", "保存数据库设置");
                    AppFramework.Exit();
                }
            });
        }
Exemplo n.º 3
0
        /// <summary>
        /// 初始主窗体
        /// </summary>
        /// <param name="mainForm"></param>
        public static void InitializationMainForm(FormMain mainForm)
        {
            if (isInit)
            {
                return;
            }
            isInit = true;
            try
            {
                //Windows XP不支持
                if (Environment.OSVersion.Platform == PlatformID.Win32NT && Environment.OSVersion.Version.Major > 5)
                {
                    mainForm.Icon = Windows.FontImages.FontAwesome.GetFontAwesomeIcon(Windows.FontImages.FontAwesomeType.FA_DESKTOP, 24, Color.DeepPink);//   Properties.Resources.icon;
                }
            }
            catch
            { }
            mainForm.Text = "正在进行系统升级检查...";

            UpgradEngine.Utility.AutoUpdater.Run((status, message) =>
            {
                AppFramework.Context.Execute(new Action(() =>
                {
                    mainForm.TipMessage(message);

                    if (status != 1)
                    {
                        return;
                    }

                    mainForm.Text = "正在载入系统...";
                    mainForm.GetService <SystemController>().ExecuteAsync(
                        c =>
                        c.Initialization(AppID),
                        (result) =>
                    {
                        SystemData = result.Data;

                        mainForm.Text    = $"{SystemData.Setting.Profile.AppTitle} v{Application.ProductVersion}";
                        mainForm.TopMost = MainFormTopMost;
                        mainForm.TipMessage("技术支持: 深圳市宸平信息技术有限公司");

                        var days = 0D;
                        if (SystemData != null && SystemData.SecretData != null)
                        {
                            days = (SystemData.SecretData.ExpirationDate - DateTime.Now).TotalDays;
                        }

                        if (days <= 0D)
                        {
                            mainForm.SetInfo("请联系供应商授权。");
                        }
                        else if (days < 10D)
                        {
                            mainForm.SetInfo($"您的系统将于{Math.Ceiling(days)}天内过期,请联系供应商授权。");
                        }

                        MenuItem modifyDbItem = CreateContextMenu();

                        if (result.Status && SystemData != null && SystemData.AuthorizeStatus == AuthorizeStatus.Succeeded)
                        {
                            GetCustomerLogo();

                            //注册仪器
                            PointTestSystem.MeasurementController.Regisry();

                            CreateMainFormMenu(result.Data.Menu);
                            AppFramework.Context.BindingMenu(result.Data.Menu);

                            if (SystemData.Setting.Profile.EnabledSystemTypes.Length < 1)
                            {
                                return;
                            }

                            LoadSystem(SystemData.Setting.Profile.EnabledSystemTypes[0]);
                            return;
                        }

                        AppFramework.Context.ShowError(result.Message);
                        if (SystemData != null && SystemData.AuthorizeStatus == AuthorizeStatus.AuthorizeDatabaseError)
                        {
                            if (!SystemData.Setting.Profile.EnabledSystemTypes.Contains(0))
                            {
                                return;
                            }

                            //载入数据库修改 FormDatabase
                            modifyDbItem.Visible = true;

                            return;
                        }
                        else if (SystemData != null && SystemData.AuthorizeStatus == AuthorizeStatus.NotAuthorized)
                        {
                            AppFramework.Context.MainForm.ContextMenu = null;
                            //载入授权窗体 FormLicensing
                            AppFramework.Context.LoadSubForm <FormLicensing>(true, Size.Empty, Point.Empty);
                            return;
                        }
                        else if (SystemData != null && SystemData.AuthorizeStatus == AuthorizeStatus.AuthorizeExpirationed)
                        {
                            //载入重新授权窗体 FormLicenseExpired
                            AppFramework.Context.LoadSubForm <FormLicenseExpired>(true, Size.Empty, Point.Empty);
                            return;
                        }
                        else
                        {
                            AppFramework.Exit();
                        }
                    });
                }));
            });
        }