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> SplitList(List list, int size) where T : new() { List> result = new List>(); 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 SimpleMESCall(string method, params object[] args) { InitClientRpc(); return clientRpc.Call(method, args); } static void InitClientRpc() { if (clientRpc != null) return; if (!File.Exists("MESUrl.cfg")) throw new Exception("缺少配置文件MESUrl.cfg"); var url = File.ReadAllText("MESUrl.cfg"); if (string.IsNullOrEmpty(url)) throw new Exception("MESUrl.cfg 配置文件错误"); clientRpc = new ClientRpc(url); } } }