using System;
|
|
using Forks.JsonRpc.Client;
|
|
|
|
namespace B3ButcherWeightClient {
|
|
public static class RpcUtil {
|
|
|
|
public static bool IsInited { set; get; }
|
|
|
|
const string WpfUserMethod = "/MainSystem/B3TianJinMeatUnite/Rpcs/ClientRpc/GetWpfUserInfoByIds";
|
|
public const string GetGoodsBatch = "/MainSystem/BWP/B3_WuFeng/Rpcs/WeightClientRpc/GetGoodsBatch";
|
|
public const string InsertCarcassPicking = "/MainSystem/BWP/B3_WuFeng/Rpcs/WeightClientRpc/InsertCarcassPicking";
|
|
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);
|
|
}
|
|
}
|
|
}
|