using System; using System.Collections.Generic; using System.Diagnostics.Eventing.Reader; using System.Linq; using System.Text; using System.Threading.Tasks; using Aitex.Core.Account; using Aitex.Core.Util; using Aitex.Core.WCF; using MECF.Framework.Common.Account.Extends; using LoginResult = Aitex.Core.Account.LoginResult; namespace MECF.Framework.UI.Core.Accounts { public class AccountClient : Singleton { public bool InProcess { get; set; } public Account CurrentUser { get; set; } private IAccountService _service; public IAccountService Service { get { if (_service == null) { if (InProcess) _service = new AccountService(); else { _service = new AccountServiceClient(); } } return _service; } } } public class AccountServiceClient : ServiceClientWrapper, IAccountService { public AccountServiceClient() : base("Client_IAccountService", "AccountService") { } /// /// user login verify /// /// /// /// public LoginResult Login(string accountId, string accountPwd) { LoginResult result = null; Invoke(svc => { result = svc.Login(accountId, accountPwd); }); return result; } LoginResult IAccountService.Login(string accountId, string password) { return Login(accountId, password); } /// /// user logout system /// /// public void Logout(string accountId) { Invoke(svc => { svc.Logout(accountId); }); } /// /// get user data by accountId /// /// /// public GetAccountInfoResult GetAccountInfo(string accountId) { GetAccountInfoResult result = null; Invoke(svc => { result = svc.GetAccountInfo(accountId); }); return result; } public void RegisterViews(List views) { Invoke(svc => { svc.RegisterViews(views); }); } /// /// change account password /// /// /// public ChangePwdResult ChangePassword(string accountId, string newPassword) { ChangePwdResult result = null; Invoke(svc => { result = svc.ChangePassword(accountId, newPassword); }); return result; } /// /// create account /// /// /// public CreateAccountResult CreateAccount(Account newAccount) { CreateAccountResult result = null; Invoke(svc => { result = svc.CreateAccount(newAccount); }); return result; } /// /// Administrator user calls this method to delete an account. /// /// /// public DeleteAccountResult DeleteAccount(string accountId) { DeleteAccountResult result = null; Invoke(svc => { result = svc.DeleteAccount(accountId); }); return result; } /// /// Update account information /// /// /// public UpdateAccountResult UpdateAccount(Account account) { UpdateAccountResult result = null; Invoke(svc => { result = svc.UpdateAccount(account); }); return result; } /// /// get account list /// /// public GetAccountListResult GetAccountList() { GetAccountListResult result = null; Invoke(svc => { result = svc.GetAccountList(); }); return result; } /// /// 获取当前所有已登录的用户列表 /// /// public List GetLoginUsers() { List result = null; Invoke(svc => { result = svc.GetLoginUsers(); }); return result; } /// /// 强制注销用户登录 /// /// /// public void KickUserOut(string accountId, string kickoutReason) { Invoke(svc => { svc.KickUserOut(accountId, kickoutReason); }); } /// /// get all roles' perrmission /// /// public SerializableDictionary> GetAllRolesPermission() { SerializableDictionary> result = null; Invoke(svc => { result = svc.GetAllRolesPermission(); }); return result; } /// /// save all roles' permission /// /// /// public bool SaveAllRolesPermission(Dictionary> data) { bool result = false; Invoke(svc => { result = svc.SaveAllRolesPermission(data); }); return result; } /// /// get all view's list /// /// public SerializableDictionary GetAllViewList() { SerializableDictionary result = null; Invoke(svc => { result = svc.GetAllViewList(); }); return result; } /// /// Get all defined roles /// /// public IEnumerable GetAllRoles() { IEnumerable result = null; Invoke(svc => { result = svc.GetAllRoles(); }); return result; } /// /// 检查账号是否仍旧有效 /// /// public void CheckAlive(string accountId) { Invoke(svc => { svc.CheckAlive(accountId); }); } /// /// 获取流程视图的许可 /// /// public string GetProcessViewPermission() { string result = null; Invoke(svc => { result = svc.GetProcessViewPermission(); }); return result; } /// /// 保存流程视图的许可 /// /// /// public bool SaveProcessViewPermission(string viewXML) { bool result = false; Invoke(svc => { result = svc.SaveProcessViewPermission(viewXML); }); return result; } public List GetAllRoleList() { var result = new List(); Invoke(svc => { result = svc.GetAllRoleList(); }); return result; } public List GetAllAccountExList() { var result = new List(); Invoke(svc => { result = svc.GetAllAccountExList(); }); return result; } public List GetRoles() { var result = new List(); Invoke(svc => { result = svc.GetRoles(); }); return result; } public List GetAccounts() { var result = new List(); Invoke(svc => { result = svc.GetAccounts(); }); return result; } public bool UpdateRole(Role p_newRole) { bool result = false; Invoke(svc => { result = svc.UpdateRole(p_newRole); }); return result; } public bool DeleteRole(string p_strRoleID) { bool result = false; Invoke(svc => { result = svc.DeleteRole(p_strRoleID); }); return result; } public List GetMenusByRole(string roleid, List menulist) { var result = new List(); Invoke(svc => { result = svc.GetMenusByRole(roleid, menulist); }); return result; } public int GetMenuPermission(string roleId, string menuName) { int result = 0; Invoke(svc => { result = svc.GetMenuPermission(roleId, menuName); }); return result; } public bool UpdateAccountEx(AccountEx account) { bool result = false; Invoke(svc => { result = svc.UpdateAccountEx(account); }); return result; } public bool DeleteAccountEx(string accountId) { bool result = false; Invoke(svc => { result = svc.DeleteAccountEx(accountId); }); return result; } public LoginResult LoginEx(string accountId, string password, string role) { var result = new LoginResult(); Invoke(svc => { result = svc.LoginEx(accountId, password, role); }); return result; } public void LogoutEx(string accountId, string loginId) { Invoke(svc => { svc.LogoutEx(accountId, loginId); }); } } }