using System.IO; using System.Linq; using Aitex.Common.Util; using OpenSEMI.ClientBase.UI; using OpenSEMI.ClientBase.Handlers; using log4net; using MECF.Framework.Common.Account.Extends; namespace OpenSEMI.ClientBase { public class BaseApp { public BaseApp() { this.UserMode = UserMode.None; this.Initialized = false; //load configuration files... this.Configure(); } public void Initialize(bool force = false) { if (this.Initialized && !force) return; this.MenuLoader = new MenuLoader(Path.Combine(PathManager.GetCfgDir(), "Menu.xml")); this.MenuLoader.Load(); this.MenuManager = new MenuManager(); this.UserContext = new UserContext(); this.UIHandler = new ClientBase.UI.UIHandler(); this.UIHandler.Looper.Run(); this.OnInitialize(); this.Initialized = true; } public virtual void Dispose() { this.UIHandler.Looper.Terminate(); } protected void Configure() { //config skin/language... this.OnConfiguration(); //config log4net log4net.Config.XmlConfigurator.Configure(); this.Log = log4net.LogManager.GetLogger("loginfo"); this.SysEvent = log4net.LogManager.GetLogger("sysEvent"); } protected virtual void OnInitialize() { } protected virtual void OnConfiguration() { } public void SetCurrentPage(PageID page) { //set page to get real data every 500 ms ... } public int GetPermission(string menuid) { int per = 1; if (this.UserContext != null) { string[] list = this.UserContext.Role.MenuPermission.Split(';'); var result = from r in list where r.Split(',')[0] == menuid select r; if (result.Count() > 0) per = int.Parse(result.ToArray()[0].Split(',')[1]); } return per; } public static BaseApp Instance { get { return _instance; } set { _instance = value; } } public UserContext UserContext { get; private set; } public MenuManager MenuManager { get; private set; } public MenuLoader MenuLoader { get; private set; } public UserMode UserMode { get; set; } public UIHandler UIHandler { get; set; } public bool Initialized { get; private set; } public ILog Log { get; private set; } public ILog SysEvent { get; private set; } public StatesHandler StatesManager { get; protected set; } public WaferStatusHandler WaferStatusManager { get; protected set; } private static BaseApp _instance = null; public virtual void SwitchPage(string mainMenu, string subMenu, object parameter) { } } }