|
|
|
@ -11,7 +11,7 @@ namespace BO.Utils |
|
|
|
{ |
|
|
|
public interface IAfterLogin |
|
|
|
{ |
|
|
|
string RoleName { get; } |
|
|
|
List<string> RoleName { get; } |
|
|
|
|
|
|
|
Form Generate(); |
|
|
|
} |
|
|
|
@ -19,19 +19,20 @@ namespace BO.Utils |
|
|
|
public static class AfterLoginUtil |
|
|
|
{ |
|
|
|
#if DEBUG
|
|
|
|
static List<Tuple<string, string>> roleToAssemblies = new List<Tuple<string, string>>(){new Tuple<string,string>("排宰员",@"C:\BwpB3Project\src\B3ButcherManageClient\ButcherOrder\bin\Debug\ButcherOrder"), |
|
|
|
new Tuple<string,string>("过磅员",@"C:\BwpB3Project\src\B3ButcherManageClient\ButcherWeight\bin\Debug\ButcherWeight"), |
|
|
|
new Tuple<string,string>("验质员",@"C:\BwpB3Project\src\B3ButcherManageClient\QualityAndOrder\bin\Debug\QualityAndOrder"), |
|
|
|
new Tuple<string,string>("验质排宰",@"C:\BwpB3Project\src\B3ButcherManageClient\OffLineQualityAndOrder\bin\Debug\OffLineQualityAndOrder"), |
|
|
|
new Tuple<string,string>("定级员",@"C:\BwpB3Project\src\B3ButcherManageClient\WeighAndGrading\bin\Debug\WeighAndGrading"), |
|
|
|
new Tuple<string,string>("窒晕员",@"C:\BwpB3Project\src\B3ButcherManageClient\OrderConfirm\bin\Debug\OrderConfirm"), |
|
|
|
new Tuple<string,string>("白条入库",@"C:\BwpB3Project\src\B3ButcherManageClient\TrunksIousOutInStore\bin\Debug\TrunksIousOutInStore"), |
|
|
|
new Tuple<string,string>("掉猪处理员",@"C:\BwpB3Project\src\B3ButcherManageClient\DropPigReOrder\bin\Debug\DropPigReOrder"), |
|
|
|
new Tuple<string,string>("配货员",@"C:\BwpB3Project\src\B3ButcherManageClient\Distribution\bin\Debug\Distribution"), |
|
|
|
new Tuple<string,string>("分割称重",@"C:\BwpB3Project\src\B3ButcherManageClient\SegmentationWeight\bin\Debug\SegmentationWeight"), |
|
|
|
new Tuple<string,string>("分割入库",@"C:\BwpB3Project\src\B3ButcherManageClient\SegmentationInStore\bin\Debug\SegmentationInStore"), |
|
|
|
new Tuple<string,string>("定级校验",@"C:\BwpB3Project\src\B3ButcherManageClient\WeighAndGrading\bin\Debug\WeighAndGrading"), |
|
|
|
new Tuple<string,string>("领料退料",@"C:\BwpB3Project\src\B3ButcherManageClient\MaterialRequisition\bin\Debug\MaterialRequisition"), |
|
|
|
static List<Tuple<string, string>> roleToAssemblies = new List<Tuple<string, string>>(){ |
|
|
|
new Tuple<string,string>("收购业务.过磅单",@"C:\BwpB3Project\src\B3ButcherManageClient\ButcherWeight\bin\Debug\ButcherWeight"), |
|
|
|
new Tuple<string,string>("收购业务.验质分圈,收购业务.排宰顺序,收购业务.急宰打码",@"C:\BwpB3Project\src\B3ButcherManageClient\QualityAndOrder\bin\Debug\QualityAndOrder"), |
|
|
|
new Tuple<string,string>("收购业务.线下验质分圈,收购业务.线下排宰顺序",@"C:\BwpB3Project\src\B3ButcherManageClient\OffLineQualityAndOrder\bin\Debug\OffLineQualityAndOrder"), |
|
|
|
new Tuple<string,string>("收购业务.顺序确认",@"C:\BwpB3Project\src\B3ButcherManageClient\OrderConfirm\bin\Debug\OrderConfirm"), |
|
|
|
new Tuple<string,string>("收购业务.烫毛计数",@"C:\BwpB3Project\src\B3ButcherManageClient\ButcherOrder\bin\Debug\ButcherOrder"), |
|
|
|
new Tuple<string,string>("收购业务.掉猪处理",@"C:\BwpB3Project\src\B3ButcherManageClient\DropPigReOrder\bin\Debug\DropPigReOrder"), |
|
|
|
new Tuple<string,string>("收购业务.称重定级,收购业务.定级校验",@"C:\BwpB3Project\src\B3ButcherManageClient\WeighAndGrading\bin\Debug\WeighAndGrading"), |
|
|
|
|
|
|
|
new Tuple<string,string>("车间业务.白条入库",@"C:\BwpB3Project\src\B3ButcherManageClient\TrunksIousOutInStore\bin\Debug\TrunksIousOutInStore"), |
|
|
|
new Tuple<string,string>("车间业务.领料退料",@"C:\BwpB3Project\src\B3ButcherManageClient\MaterialRequisition\bin\Debug\MaterialRequisition"), |
|
|
|
new Tuple<string,string>("车间业务.分割称重",@"C:\BwpB3Project\src\B3ButcherManageClient\SegmentationWeight\bin\Debug\SegmentationWeight"), |
|
|
|
new Tuple<string,string>("车间业务.分割入库",@"C:\BwpB3Project\src\B3ButcherManageClient\SegmentationInStore\bin\Debug\SegmentationInStore"), |
|
|
|
new Tuple<string,string>("车间业务.车间配货",@"C:\BwpB3Project\src\B3ButcherManageClient\Distribution\bin\Debug\Distribution"), |
|
|
|
}; |
|
|
|
|
|
|
|
//luanhui 公司电脑
|
|
|
|
@ -51,41 +52,49 @@ namespace BO.Utils |
|
|
|
#else
|
|
|
|
static List<Tuple<string, string>> roleToAssemblies = new List<Tuple<string, string>>() |
|
|
|
{ |
|
|
|
new Tuple<string,string>("排宰员",@"ButcherOrder"), |
|
|
|
new Tuple<string,string>("过磅员",@"ButcherWeight"), |
|
|
|
new Tuple<string,string>("验质员",@"QualityAndOrder"), |
|
|
|
new Tuple<string,string>("验质排宰",@"OffLineQualityAndOrder"), |
|
|
|
new Tuple<string,string>("定级员",@"WeighAndGrading"), |
|
|
|
new Tuple<string,string>("窒晕员",@"OrderConfirm"), |
|
|
|
new Tuple<string,string>("掉猪处理员",@"DropPigReOrder"), |
|
|
|
new Tuple<string,string>("分割称重",@"SegmentationWeight"), |
|
|
|
new Tuple<string,string>("分割入库",@"SegmentationInStore"), |
|
|
|
new Tuple<string,string>("定级校验",@"WeighAndGrading"), |
|
|
|
new Tuple<string,string>("白条入库",@"TrunksIousOutInStore"), |
|
|
|
new Tuple<string,string>("领料退料",@"MaterialRequisition"), |
|
|
|
new Tuple<string,string>("收购业务.过磅单",@"ButcherWeight"), |
|
|
|
new Tuple<string,string>("收购业务.验质分圈,收购业务.排宰顺序,收购业务.急宰打码",@"QualityAndOrder"), |
|
|
|
new Tuple<string,string>("收购业务.线下验质分圈,收购业务.线下排宰顺序",@"OffLineQualityAndOrder"), |
|
|
|
new Tuple<string,string>("收购业务.顺序确认",@"OrderConfirm"), |
|
|
|
new Tuple<string,string>("收购业务.烫毛计数",@"ButcherOrder"), |
|
|
|
new Tuple<string,string>("收购业务.掉猪处理",@"DropPigReOrder"), |
|
|
|
new Tuple<string,string>("收购业务.称重定级,收购业务.定级校验",@"WeighAndGrading"), |
|
|
|
|
|
|
|
new Tuple<string,string>("车间业务.白条入库",@"TrunksIousOutInStore"), |
|
|
|
new Tuple<string,string>("车间业务.领料退料",@"MaterialRequisition"), |
|
|
|
new Tuple<string,string>("车间业务.分割称重",@"SegmentationWeight"), |
|
|
|
new Tuple<string,string>("车间业务.分割入库",@"SegmentationInStore"), |
|
|
|
new Tuple<string,string>("车间业务.车间配货",@"Distribution"), |
|
|
|
}; |
|
|
|
#endif
|
|
|
|
|
|
|
|
public static Form CreateForm(string role) |
|
|
|
public static Form CreateForm() |
|
|
|
{ |
|
|
|
var first = roleToAssemblies.FirstOrDefault(x => x.Item1 == role); |
|
|
|
if (first == null) |
|
|
|
throw new Exception("未注册的角色:"+role); |
|
|
|
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", first.Item2); |
|
|
|
var filePath = string.Format("{0}.dll", item.Item2); |
|
|
|
#else
|
|
|
|
var filePath = Path.Combine(Application.StartupPath, string.Format("{0}.dll", first.Item2)); |
|
|
|
var filePath = Path.Combine(Application.StartupPath, string.Format("{0}.dll", item.Item2)); |
|
|
|
#endif
|
|
|
|
if (!File.Exists(filePath)) |
|
|
|
throw new Exception("相关模块不存在"); |
|
|
|
var formType = typeof(IAfterLogin); |
|
|
|
foreach (var type in Assembly.LoadFile(filePath).GetTypes()) |
|
|
|
{ |
|
|
|
if (formType.IsAssignableFrom(type)) |
|
|
|
{ |
|
|
|
var instance = (IAfterLogin)Activator.CreateInstance(type); |
|
|
|
if (role == instance.RoleName) |
|
|
|
return instance.Generate(); |
|
|
|
if (!File.Exists(filePath)) |
|
|
|
throw new Exception("相关模块不存在"); |
|
|
|
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; |
|
|
|
|