using System;
|
|
using System.Collections.Generic;
|
|
using System.IO;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace ButcherFactory.BO.Utils
|
|
{
|
|
public static class ButcherFactoryUtil
|
|
{
|
|
public static List<List<T>> SplitList<T>(List<T> list, int size)
|
|
where T : new()
|
|
{
|
|
List<List<T>> result = new List<List<T>>();
|
|
for (int i = 0; i < list.Count() / size; i++)
|
|
{
|
|
T[] clist = new T[size];
|
|
list.CopyTo(i * size, clist, 0, size);
|
|
result.Add(clist.ToList());
|
|
}
|
|
|
|
int r = list.Count() % size;
|
|
if (r != 0)
|
|
{
|
|
T[] cclist = new T[r];
|
|
list.CopyTo(list.Count() - r, cclist, 0, r);
|
|
result.Add(cclist.ToList());
|
|
}
|
|
return result;
|
|
}
|
|
|
|
static ClientRpc clientRpc;
|
|
|
|
public static T SecondUrlCall<T>(string method, params object[] args)
|
|
{
|
|
InitClientRpc();
|
|
return clientRpc.Call<T>(method, args);
|
|
}
|
|
|
|
static void InitClientRpc()
|
|
{
|
|
if (clientRpc != null)
|
|
return;
|
|
if (string.IsNullOrEmpty(AppContext.ConnectInfo.SecondUrl))
|
|
throw new Exception(string.Format("请先配置{0}服务器地址", AppContext.ConnectInfo.ServerMode == 0 ? "B3" : "MES"));
|
|
clientRpc = new ClientRpc(AppContext.ConnectInfo.SecondUrl);
|
|
}
|
|
}
|
|
}
|