using Forks.JsonRpc.Client; using Forks.JsonRpc.Client.Data; using System; using System.Collections.Generic; using System.Linq; using System.Net; using System.Text; using System.Threading.Tasks; namespace BO.Utils { public class LoginRpcUtil { public static string GetUserNameByCode(string code, out string error) { try { error = string.Empty; const string wpfUserMethod = "/MainSystem/B3ClientService/Rpcs/UserInfoRpc/GetUserName"; return RpcFacade.Call(wpfUserMethod, code); } catch (Exception ex) { error = ex.ToString(); } return string.Empty; } public static void FillUserEmpInfo(string name, LoginUserInfo userInfo) { const string wpfUserMethod = "/MainSystem/B3ClientService/Rpcs/UserInfoRpc/GetUserEmpInfo"; var obj = RpcFacade.Call(wpfUserMethod, name); if (obj != null) { userInfo.ID = obj.Get("User_ID"); userInfo.UserName = obj.Get("User_Name"); userInfo.Domain_ID = obj.Get("Domain_ID"); userInfo.AccountingUnit_ID = obj.Get("AccountingUnit_ID"); userInfo.AccountingUnit_Name = obj.Get("AccountingUnit_Name"); userInfo.Department_ID = obj.Get("Department_ID"); userInfo.Department_Name = obj.Get("Department_Name"); userInfo.Employee_ID = obj.Get("Employee_ID"); userInfo.Employee_Name = obj.Get("Employee_Name"); userInfo.Role = obj.Get("Role"); } } public static bool TestConnection() { var url = ButcherAppContext.Context.UrlConfig.ServerUrl; if (string.IsNullOrEmpty(url)) return false; try { HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url); HttpWebResponse resp = (HttpWebResponse)req.GetResponse(); return resp.StatusCode == HttpStatusCode.OK; } catch { return false; } } } }