天肉客户端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 

60 lines
1.6 KiB

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<string>(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<T>(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<T>(relativeMethod, parameters);
}
}
}