using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using BO.BO.BaseInfo;
using BO.BO.Bill;
using Forks.JsonRpc.Client;
using System.Web.Script.Serialization;


namespace BO.Utils.BillRpc
{
  public static class CarcassStateWeightRpc
  {

    static JavaScriptSerializer serializer = new JavaScriptSerializer();

    public static List<CarcassStateWeight> GetCarcassStateWeightList(DateTime date, long? maxID = null)
    {
      const string method = "/MainSystem/B3ClientService/Rpcs/BillRpc/CarcassStateWeightRpc/GetCarcassStateWeightList";
      var result = RpcFacade.Call<string>(method, date, maxID);
      return serializer.Deserialize<List<CarcassStateWeight>>(result);
    }

    
    public static List<GradeAndWeight_Detail> GetGradeAndWeight_DetailByCode(long code)
    {
      const string method = "/MainSystem/B3ClientService/Rpcs/BillRpc/CarcassStateWeightRpc/GetGradeAndWeight_DetailByCode";
      var obj = RpcFacade.Call<string>(method, code);
      obj = obj.ESerializeDateTime();
      return serializer.Deserialize<List<GradeAndWeight_Detail>>(obj);
    }

    public static void UpdateOrInsertDetail(CarcassStateWeight detail, bool fillTechnics = false)
    {
      const string method = "/MainSystem/B3ClientService/Rpcs/BillRpc/CarcassStateWeightRpc/UpdateOrInsertDetail";
      detail.GradeAndWeight_ID = RpcFacade.Call<long>(method, serializer.Serialize(detail), fillTechnics);
    }

  }
}
