using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Reflection; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace BO.Utils { public interface IAfterLogin { List RoleName { get; } Form Generate(); } public static class AfterLoginUtil { #if DEBUG static List> roleToAssemblies = new List>(){ new Tuple("收购业务.过磅单",@"C:\BwpB3Project\src\B3ButcherManageClient\ButcherWeight\bin\Debug\ButcherWeight"), new Tuple("收购业务.验质分圈,收购业务.排宰顺序,收购业务.急宰打码",@"C:\BwpB3Project\src\B3ButcherManageClient\QualityAndOrder\bin\Debug\QualityAndOrder"), new Tuple("收购业务.线下验质分圈,收购业务.线下排宰顺序",@"C:\BwpB3Project\src\B3ButcherManageClient\OffLineQualityAndOrder\bin\Debug\OffLineQualityAndOrder"), new Tuple("收购业务.顺序确认",@"C:\BwpB3Project\src\B3ButcherManageClient\OrderConfirm\bin\Debug\OrderConfirm"), new Tuple("收购业务.烫毛计数",@"C:\BwpB3Project\src\B3ButcherManageClient\ButcherOrder\bin\Debug\ButcherOrder"), new Tuple("收购业务.掉猪处理",@"C:\BwpB3Project\src\B3ButcherManageClient\DropPigReOrder\bin\Debug\DropPigReOrder"), new Tuple("收购业务.称重定级,收购业务.定级校验",@"C:\BwpB3Project\src\B3ButcherManageClient\WeighAndGrading\bin\Debug\WeighAndGrading"), new Tuple("车间业务.白条入库",@"C:\BwpB3Project\src\B3ButcherManageClient\TrunksIousOutInStore\bin\Debug\TrunksIousOutInStore"), new Tuple("车间业务.领料退料",@"C:\BwpB3Project\src\B3ButcherManageClient\MaterialRequisition\bin\Debug\MaterialRequisition"), new Tuple("车间业务.分割称重",@"C:\BwpB3Project\src\B3ButcherManageClient\SegmentationWeight\bin\Debug\SegmentationWeight"), new Tuple("车间业务.分割入库",@"C:\BwpB3Project\src\B3ButcherManageClient\SegmentationInStore\bin\Debug\SegmentationInStore"), new Tuple("车间业务.车间配货",@"C:\BwpB3Project\src\B3ButcherManageClient\Distribution\bin\Debug\Distribution"), }; //luanhui 公司电脑 //static List> roleToAssemblies = new List>(){ // new Tuple("排宰员",@"D:\BWP\BWPB3\src\B3ButcherManageClient\ButcherOrder\bin\Debug\ButcherOrder"), // new Tuple("过磅员",@"D:\BWP\BWPB3\src\B3ButcherManageClient\ButcherWeight\bin\Debug\ButcherWeight"), // new Tuple("验质员",@"D:\BWP\BWPB3\src\B3ButcherManageClient\QualityAndOrder\bin\Debug\QualityAndOrder"), // new Tuple("定级员",@"C:\BwpB3Project\src\B3ButcherManageClient\WeighAndGrading\bin\Debug\WeighAndGrading"), // new Tuple("窒晕员",@"D:\BWP\BWPB3\src\B3ButcherManageClient\OrderConfirm\bin\Debug\OrderConfirm"), // new Tuple("白条入库",@"D:\BWP\BWPB3\src\B3ButcherManageClient\TrunksIousOutInStore\bin\Debug\TrunksIousOutInStore"), // new Tuple("掉猪处理员",@"D:\BWP\BWPB3\src\B3ButcherManageClient\DropPigReOrder\bin\Debug\DropPigReOrder"), // new Tuple("配货员",@"D:\BWP\BWPB3\src\B3ButcherManageClient\Distribution\bin\Debug\Distribution"), // new Tuple("分割称重",@"D:\BWP\BWPB3\src\B3ButcherManageClient\SegmentationWeight\bin\Debug\SegmentationWeight"), // new Tuple("分割入库",@"D:\BWP\BWPB3\src\B3ButcherManageClient\SegmentationInStore\bin\Debug\SegmentationInStore"), // new Tuple("定级校验",@"D:\BWP\BWPB3\src\B3ButcherManageClient\WeighAndGrading\bin\Debug\WeighAndGrading"), //}; #else static List> roleToAssemblies = new List>() { new Tuple("收购业务.过磅单",@"ButcherWeight"), new Tuple("收购业务.验质分圈,收购业务.排宰顺序,收购业务.急宰打码",@"QualityAndOrder"), new Tuple("收购业务.线下验质分圈,收购业务.线下排宰顺序",@"OffLineQualityAndOrder"), new Tuple("收购业务.顺序确认",@"OrderConfirm"), new Tuple("收购业务.烫毛计数",@"ButcherOrder"), new Tuple("收购业务.掉猪处理",@"DropPigReOrder"), new Tuple("收购业务.称重定级,收购业务.定级校验",@"WeighAndGrading"), new Tuple("车间业务.白条入库",@"TrunksIousOutInStore"), new Tuple("车间业务.领料退料",@"MaterialRequisition"), new Tuple("车间业务.分割称重",@"SegmentationWeight"), new Tuple("车间业务.分割入库",@"SegmentationInStore"), new Tuple("车间业务.车间配货",@"Distribution"), }; #endif public static Form CreateForm() { foreach (var item in roleToAssemblies) { var roleArr = item.Item1.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); foreach (var role in roleArr) { if (LoginRpcUtil.UserIsInRole(role)) { #if DEBUG var filePath = string.Format("{0}.dll", item.Item2); #else var filePath = Path.Combine(Application.StartupPath, string.Format("{0}.dll", item.Item2)); #endif if (!File.Exists(filePath)) continue; var formType = typeof(IAfterLogin); foreach (var type in Assembly.LoadFile(filePath).GetTypes()) { if (formType.IsAssignableFrom(type)) { var instance = (IAfterLogin)Activator.CreateInstance(type); if (instance.RoleName.Contains(role)) return instance.Generate(); } } } } } return null; } } }