internal AppData(Guid token, string mechineCode, SecretkeyData secretData, IniProfile <SystemSetting> setting, MainFormMenu menu) { Token = token; MachineCode = mechineCode; SecretData = secretData; Setting = setting; Menu = menu; AuthorizeStatus = AuthorizeStatus.NotAuthorized; }
public DynamicMenuItem(MainFormMenu menu, string name, bool isOther, bool hasRecent) : base(name) { this.name = name; this.menu = menu; this.isOther = isOther; this.hasRecent = hasRecent; MenuItems.Add(new MenuItem(" ")); Popup += OnPopup; }
public ActionResult <AppData> Initialization(string appid) { if (!appid.Equals(AppID)) { return(ActionResult <AppData> .SetError("系统配置不正确")); } var errorMessage = ""; var secretkeyData = GetSecretkeyData(out errorMessage); var menu = new MainFormMenu(); var data = new AppData(SecurityToken, machineCode, secretkeyData, IniProfile <SystemSetting> .Instance, menu); if (secretkeyData == null) { data.AuthorizeStatus = AuthorizeStatus.NotAuthorized; return(ActionResult <AppData> .SetError(errorMessage, data)); //没有授权 } var now = DateTime.Now; if (dbMode) { foreach (var dbConn in secretkeyData.Database) { DbFactory.Initialization( dbConn.Key, dbConn.Value.Provider, dbConn.Value.ConnectionString); if (dbConn.Key == DbClientType.MsSql) { try { now = DbFactory.Repository <DatabaseRepository>().GetServerDate(DateTime.Now); DbFactory.Repository <DatabaseRepository>().CheckDataBase(); } catch (Exception ex) { data.AuthorizeStatus = AuthorizeStatus.AuthorizeDatabaseError; return(ActionResult <AppData> .SetError($"数据库连接失败,请网络和设置, {ex.Message}", data)); //数据连接失败 } } } } if (secretkeyData.LicensingDate == null || secretkeyData.ExpirationDate == null || secretkeyData.LicensingDate > now || secretkeyData.ExpirationDate < now) { secretkeyData.LicensingDate = now; SaveSecretkey(secretkeyData); data.AuthorizeStatus = AuthorizeStatus.AuthorizeExpirationed; return(ActionResult <AppData> .SetError("授权过期", data)); //授权过期 } DbFactory.SetFtpSetting( secretkeyData.Ftp.Server, secretkeyData.Ftp.Port, secretkeyData.Ftp.UserID, secretkeyData.Ftp.Password); SetRoles(); data.AuthorizeStatus = AuthorizeStatus.Succeeded; return(ActionResult <AppData> .SetSuccess("初始化成功", data)); }
private static void CreateMainFormMenu(MainFormMenu menu) { var unlogin = BusinessLogic.Model.RoleInfo.UnLoginRole.RoleID; var logined = BusinessLogic.Model.RoleInfo.LoginedRole.RoleID; #region 作业菜单 var menu1 = menu.Add( Guid.Empty, "作业(&W)", Guid.Empty, Keys.None, null, null, MainFormMenuItemDisplayType.NormalItem ); foreach (var item in testSystemTypes) { var id = item.Key; var text = item.Value.SystemName; if (id < 1 || !SystemData.Setting.Profile.EnabledSystemTypes.Contains(id) || string.IsNullOrEmpty(text)) { continue; } menu1.Add( Guid.Empty, text, Guid.Empty, Keys.None, null, (o, e) => { if (id > 5 || MeasurementTestCloseForm()) { LoadSystem(id); } }, MainFormMenuItemDisplayType.HideItem); } menu1.Add( Guid.Empty, "-", Guid.Empty, Keys.None, null, null, MainFormMenuItemDisplayType.NormalItem); menu1.Add( Guid.Empty, "退出测试系统", Guid.Empty, Keys.None, null, (o, e) => { AppFramework.Context.MainForm.Close(); }, MainFormMenuItemDisplayType.NormalItem); #endregion #region 视图菜单 var menu2 = menu.Add( Guid.Empty, "视图(&V)", Guid.Empty, Keys.None, null, null, MainFormMenuItemDisplayType.MdiWindowListItem ); #endregion #region 管理菜单 var menu3 = menu.Add( Guid.Empty, "管理(&S)", Guid.Empty, Keys.None, null, null, MainFormMenuItemDisplayType.NormalItem ); menu3.Add( Guid.Empty, "系统登录", unlogin, Keys.None, null, (o, e) => { AppFramework.Context.LoadSubForm <FormCPITLogin>(true, Size.Empty, Point.Empty); }, MainFormMenuItemDisplayType.HideItem); menu3.Add( Guid.Empty, "退出登录", logined, Keys.None, null, (o, e) => { SignInManager.SignOut(); AppFramework.Context.GetMainForm <FormMain>().SetUserName("未登录"); }, MainFormMenuItemDisplayType.HideItem); menu3.Add( Guid.Empty, "修改密码", logined, Keys.None, null, (o, e) => { AppFramework.Context.LoadSubForm <FormModifyPassword>(true, Size.Empty, Point.Empty); }, MainFormMenuItemDisplayType.NormalItem); menu3.Add( Guid.Empty, "用户管理", Guid.Parse("5d85b7f9-2827-44ae-976d-88b263b400e7"), Keys.None, null, (o, e) => { AppFramework.Context.LoadSubForm <FormUserInfoManage>(true, Size.Empty, Point.Empty); }, MainFormMenuItemDisplayType.NormalItem); menu3.Add( Guid.Empty, "-", Guid.Empty, Keys.None, null, null, MainFormMenuItemDisplayType.NormalItem); menu3.Add( Guid.Empty, "模型架构设置", Guid.Parse("3dc8775c-a3bb-422c-8162-42039126cbb2"), Keys.None, null, (o, e) => { AppFramework.Context.LoadSubForm <FormProductTypeManage>(true, Size.Empty, Point.Empty); }, MainFormMenuItemDisplayType.NormalItem); menu3.Add( Guid.Empty, "测试结果分级", Guid.Parse("93d745f2-212e-4f17-a084-7b3c959e708c"), Keys.None, null, (o, e) => { AppFramework.Context.LoadSubForm <FormResultSettingManage>(true, Size.Empty, Point.Empty); }, MainFormMenuItemDisplayType.NormalItem); menu3.Add( Guid.Empty, "测试工位站点", Guid.Parse("0aec6e2b-9f7f-469c-8b6c-2a9fa414a414"), Keys.None, null, (o, e) => { AppFramework.Context.LoadSubForm <FormStationInfoManage>(true, Size.Empty, Point.Empty); }, MainFormMenuItemDisplayType.NormalItem); menu3.Add( Guid.Empty, "-", Guid.Empty, Keys.None, null, null, MainFormMenuItemDisplayType.NormalItem); menu3.Add( Guid.Empty, "产品信息管理", Guid.Parse("20aae8b3-b30b-4f73-83b0-6ea78391e4b7"), Keys.None, null, (o, e) => { AppFramework.Context.LoadSubForm <FormProductInfoManage>(true, Size.Empty, Point.Empty); }, MainFormMenuItemDisplayType.NormalItem); menu3.Add( Guid.Empty, "测试规格管理", Guid.Parse("08d084c0-628e-474e-8951-6f0cf299f4a9"), Keys.None, null, (o, e) => { AppFramework.Context.LoadSubForm <FormSpecInfoManage>(true, Size.Empty, Point.Empty); }, MainFormMenuItemDisplayType.NormalItem); menu3.Add( Guid.Empty, "-", Guid.Empty, Keys.None, null, null, MainFormMenuItemDisplayType.NormalItem); menu3.Add( Guid.Empty, "平台系统配置", Guid.Parse("7e640bf5-f939-47da-9723-1346498f0359"), Keys.None, null, (o, e) => { AppFramework.Context.LoadSubForm <PointTestSystem.FormSystemSetting>(true, Size.Empty, Point.Empty); }, MainFormMenuItemDisplayType.NormalItem); menu3.Add( Guid.Empty, "测试仪器配置", Guid.Parse("06b1a807-544b-46e4-a967-04660c71c634"), Keys.None, null, (o, e) => { AppFramework.Context.LoadSubForm <PointTestSystem.FormInstrumentSetting>(true, Size.Empty, Point.Empty); }, MainFormMenuItemDisplayType.NormalItem); #endregion #region 查询菜单 var menu4 = menu.Add( Guid.Empty, "查询(&Q)", Guid.Empty, Keys.None, null, null, MainFormMenuItemDisplayType.NormalItem ); menu4.Add( Guid.Empty, "测试结果查询", Guid.Empty, Keys.None, null, (o, e) => { AppFramework.Context.LoadSubForm <PointTestSystem.FormQuery>(true, Size.Empty, Point.Empty); }, MainFormMenuItemDisplayType.NormalItem); /* * menu4.Add( * Guid.Empty, * "按参数汇总", * Guid.Empty, * Keys.None, * null, * (o, e) => * { * AppFramework.Context.LoadSubForm<PointTestSystem.FormQueryByTestSystem>(true, Size.Empty, Point.Empty); * }, * MainFormMenuItemDisplayType.NormalItem); */ menu4.Add( Guid.Empty, "-", Guid.Empty, Keys.None, null, null, MainFormMenuItemDisplayType.NormalItem); menu4.Add( Guid.Empty, "测试良率统计", Guid.Empty, Keys.None, null, (o, e) => { AppFramework.Context.LoadSubForm <PointTestSystem.FormQueryByYield>(true, Size.Empty, Point.Empty); }, MainFormMenuItemDisplayType.NormalItem); menu4.Add( Guid.Empty, "人员作业统计", Guid.Empty, Keys.None, null, (o, e) => { AppFramework.Context.LoadSubForm <PointTestSystem.FormQueryByOperator>(true, Size.Empty, Point.Empty); }, MainFormMenuItemDisplayType.NormalItem); #endregion #region 帮助菜单 var menu5 = menu.Add( Guid.Empty, "帮助(&H)", Guid.Empty, Keys.None, null, null, MainFormMenuItemDisplayType.NormalItem ); /* * menu5.Add( * Guid.Empty, * "帮助文档", * Guid.Empty, * Keys.None, * null, * (o, e) => * { * AppFramework.Context.LoadSubForm<FormDocument>(true, Size.Empty, Point.Empty); * }, * MainFormMenuItemDisplayType.NormalItem); * * menu5.Add( * Guid.Empty, * "联系我们", * Guid.Empty, * Keys.None, * null, * (o, e) => * { * AppFramework.Context.LoadSubForm<FormContactUs>(true, Size.Empty, Point.Empty); * }, * MainFormMenuItemDisplayType.NormalItem); */ menu5.Add( Guid.Empty, "更新历史", Guid.Empty, Keys.None, null, (o, e) => { AppFramework.Context.LoadSubForm <FormHistory>(true, Size.Empty, Point.Empty); }, MainFormMenuItemDisplayType.NormalItem); if (SystemData == null || SystemData.SecretData == null || (SystemData.SecretData.ExpirationDate - DateTime.Now).TotalDays < 90D) { menu5.Add( Guid.Empty, "测试系统授权", Guid.Empty, Keys.None, null, (o, e) => { AppFramework.Context.LoadSubForm <FormLicenseExpired>(true, Size.Empty, Point.Empty); }, MainFormMenuItemDisplayType.NormalItem); } menu5.Add( Guid.Empty, "-", Guid.Empty, Keys.None, null, null, MainFormMenuItemDisplayType.NormalItem); menu5.Add( Guid.Empty, "关于系统", Guid.Empty, Keys.None, null, (o, e) => { new AboutBox().ShowDialog(AppFramework.Context.MainForm); }, MainFormMenuItemDisplayType.NormalItem); #endregion }
override protected bool Prebuild() { textBoxToFocus = textBox; if (textBox == null) { return(false); } KeyMapNode node = textBox.KeyMap; List <KeyAction> actions = new List <KeyAction>(); Dictionary <KeyAction, bool> actionSet = new Dictionary <KeyAction, bool>(); Dictionary <KeyAction, List <KeyItem> > keysByAction = new Dictionary <KeyAction, List <KeyItem> >(); List <KeyItem> keyItems = new List <KeyItem>(); foreach (KeyMap keyMapI in node.ToList()) { keyItems.AddRange(keyMapI.items); foreach (KeyItem keyItem in keyMapI.items) { if (keyItem.action != KeyAction.Nothing && !actionSet.ContainsKey(keyItem.action)) { actionSet.Add(keyItem.action, true); actions.Add(keyItem.action); } } } foreach (KeyItem keyItem in keyItems) { List <KeyItem> list; keysByAction.TryGetValue(keyItem.action, out list); if (list == null) { list = new List <KeyItem>(); keysByAction[keyItem.action] = list; } list.Add(keyItem); } items.Clear(); Dictionary <string, Menu> itemByPath = new Dictionary <string, Menu>(); KeysConverter keysConverter = new KeysConverter(); int length = 0; foreach (KeyAction action in actions) { if (action.name == "-" || action.name.EndsWith("\\-")) { continue; } Item item = new Item(); item.name = action.name.Replace("&", ""); if (action != null && action.getText != null) { item.name += action.getText(); } List <KeyItem> keys; keysByAction.TryGetValue(action, out keys); if (keys != null && keys.Count > 0) { item.keys = MainFormMenu.GetShortcutText(action, keys, keysConverter).Replace("\t", ""); } else { item.keys = ""; } item.action = action; items.Add(item); if (item.name.Length + item.keys.Length + 2 > length) { length = item.name.Length + item.keys.Length + 2; } } foreach (Item item in items) { if (!string.IsNullOrEmpty(item.keys)) { item.text = item.name + new string(' ', length - item.name.Length - item.keys.Length) + item.keys; } else { item.text = item.name; } } return(true); }