using System; using Forks.JsonRpc.Client; namespace BLUtil { public static class RpcUtil { const string WpfUserMethod = "/MainSystem/B3TianJinMeatUnite/Rpcs/ClientRpc/GetWpfUserInfoByIds"; public const string GetGoods = "/MainSystem/B3TianJinMeatUnite/Rpcs/ClientRpc/GetGoodsInfor"; public const string GetStore = "/MainSystem/B3TianJinMeatUnite/Rpcs/ClientRpc/GetStoreInfor"; public static string OnLineLoadNameByCode(string code, out string error) { try { error = string.Empty; return RpcFacade.Call(WpfUserMethod, code); } catch (Exception ex) { error = ex.ToString(); } return string.Empty; } public static bool Login(string name, string password, out string error) { error = string.Empty; try { RpcFacade.Login(name, password); } catch (Exception e) { error = e.Message; return false; } return true; } public static bool Logout(out string error) { error = string.Empty; try { RpcFacade.Logout(); } catch (Exception e) { error = e.Message; return false; } return true; } public static T Call(string relativeMethod, params object[] parameters) { bool logedIn; try { logedIn = RpcFacade.IsLogedIn; } catch { logedIn = false; } if (!logedIn) { RpcFacade.Login(EncodeString.UserName, EncodeString.Password); } return RpcFacade.Call(relativeMethod, parameters); } } }