123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154 |
- using Aitex.Common.Util;
- using log4net;
- using log4net.Config;
- using MECF.Framework.Common.Account.Extends;
- using OpenSEMI.ClientBase.Handlers;
- using OpenSEMI.ClientBase.UI;
- using System.Collections.Generic;
- using System.IO;
- using System.Linq;
- namespace OpenSEMI.ClientBase
- {
- public class BaseApp
- {
- private static BaseApp _instance = null;
- 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;
- }
- public BaseApp()
- {
- UserMode = UserMode.None;
- Initialized = false;
- Configure();
- }
- public void Initialize(bool force = false)
- {
- if (!Initialized || force)
- {
- MenuLoader = new MenuLoader(Path.Combine(PathManager.GetCfgDir(), "Menu.xml"));
- MenuLoader.Load();
- MenuManager = new MenuManager();
- UserContext = new UserContext();
- UIHandler = new UIHandler();
- UIHandler.Looper.Run();
- OnInitialize();
- Initialized = true;
- }
- }
- public virtual void Dispose()
- {
- UIHandler.Looper.Terminate(false);
- }
- protected void Configure()
- {
- OnConfiguration();
- XmlConfigurator.Configure();
- Log = LogManager.GetLogger("loginfo");
- SysEvent = LogManager.GetLogger("sysEvent");
- }
- protected virtual void OnInitialize()
- {
- }
- protected virtual void OnConfiguration()
- {
- }
- public void SetCurrentPage(PageID page)
- {
- }
- public int GetPermission(string menuid)
- {
- int result = 1;
- if (UserContext != null)
- {
- string[] source = UserContext.Role.MenuPermission.Split(';');
- IEnumerable<string> source2 = from r in source
- where r.Split(',')[0] == menuid
- select r;
- if (source2.Count() > 0)
- {
- result = int.Parse(source2.ToArray()[0].Split(',')[1]);
- }
- }
- return result;
- }
- }
- }
|