屠宰场客户端
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.

51 lines
1.5 KiB

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using BO.BO.BaseInfo;
using Forks.EnterpriseServices.DomainObjects2.DQuery;
using Forks.JsonRpc.Client;
using Newtonsoft.Json;
namespace BO.Utils.BillRpc
{
public class CustomerRpc
{
/// <summary>
/// 获取客户档案 在线则在线查询 同时更新本地数据库 ,不在线则从本地数据查
/// </summary>
/// <param name="input">查询用的</param>
/// <param name="updateLocalDb">是否更新本地数据库,如果更新则尽量减少使用该方法的次数, 因为客户会有很多</param>
/// <returns></returns>
public static List<Customer> SyncList(string input="", bool updateLocalDb=true)
{
if (LoginRpcUtil.TestConnection(1000))
{
//在线
var json = RpcFacade.Call<string>("/MainSystem/B3ClientService/Rpcs/BillRpc/BaseInfoRpc/SyncCustomer",input);
var list = JsonConvert.DeserializeObject<List<Customer>>(json);
if (updateLocalDb)
{
using (var session = LocalDmoSession.New())
{
foreach (Customer dmo in list)
{
session.Insert(dmo);
}
session.Commit();
}
}
return list;
}
var dmoquery = new DmoQuery(typeof(Customer));
using (var session = LocalDmoSession.New())
{
return session.ExecuteList(dmoquery).Cast<Customer>().ToList();
}
}
}
}