123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Reflection;
- using WMS.BZServices.UserCenterManager;
- using WMS.Info;
- using WMS.Util;
- namespace WMS.BZServices
- {
- public class BZBLLCore
- {
-
- const string CacheKeys = "BLLList";
- private static IBLL GetBLLObj(string BLLNo, EAppType eAppType)
- {
- try
- {
- string ck = CacheKeys + (int)eAppType;
- var BLLClassList = new Dictionary<string, Type>();
- Assembly asm = Assembly.GetExecutingAssembly();
- foreach (var t in asm.GetTypes())
- {
- if (t.GetInterfaces().Contains(typeof(IBLL)))
- {
- BLLClassList.Add(GetBLLClassNo(t), t);
- }
- }
- if (!BLLClassList.ContainsKey(BLLNo.ToUpper()))
- {
- throw new Exception("请求业务不存在。");
- }
- return Activator.CreateInstance(BLLClassList[BLLNo.ToUpper()]) as IBLL;
- }
- catch (Exception ex)
- {
- throw ex;
- }
- }
- public static string GetBLLClassNo(Type T)
- {
- return (T.Namespace + "." + T.Name).ToUpper();
- }
- public static string GetBLLClassNo(object obj)
- {
- return GetBLLClassNo(obj.GetType());
- }
- public static ResInfo BLLExec(ReqInfo ReqData)
- {
- var BLLExec = new BZBLLExecInfo();
- try
- {
- if (ReqData == null)
- {
- throw new Exception("请求数据为空。");
- }
- if (string.IsNullOrWhiteSpace(ReqData.BLLNo))
- {
- throw new Exception("请求业务编号为空。");
- }
- BLLExec.BLLObj = GetBLLObj(ReqData.BLLNo, ReqData.AppType);
- BLLExec.BLLObj.InJsonData = ReqData.JsonData;
- BLLExec.BLLObj.LoginUser = BZLoginBLLCore.GetLoginUser(ReqData.EncryptTokenNo);
- BLLExec.BLLObj.Exec();
- //写日志
- SysLogService.WriteLog(BLLExec, ELogType.Work);
- return BZSysExCore.GetResSucc(BLLExec.BLLObj.SuccessMsg, BLLExec.BLLObj.OutObjData);
- }
- catch (Exception ex)
- {
- BLLExec.Ex = ex;
- SysLogService.WriteLog(BLLExec, ELogType.Work);
- return BZSysExCore.GetResErr(ex, BLLExec.BLLObj == null ? null : BLLExec.BLLObj.OutObjData);
- }
- }
- public static ResInfo BLLExec(LoginUserInfo LoginUser, string InJsonData, string BLLNo, ELogType eLogType)
- {
- var BLLExec = new BZBLLExecInfo();
- try
- {
- if (string.IsNullOrWhiteSpace(BLLNo))
- {
- throw BZSysExCore.ThrowFailException("请求业务编号为空。");
- }
- BLLExec.BLLObj = GetBLLObj(BLLNo, LoginUser.AppType);
- BLLExec.BLLObj.InJsonData = InJsonData;
- BLLExec.BLLObj.LoginUser = LoginUser;
- BLLExec.BLLObj.Exec();
- //写日志
- SysLogService.WriteLog(BLLExec, eLogType);
- return BZSysExCore.GetResSucc(BLLExec.BLLObj.SuccessMsg, BLLExec.BLLObj.OutObjData);
- }
- catch (Exception ex)
- {
- BLLExec.Ex = ex;
- SysLogService.WriteLog(BLLExec, eLogType);
- return BZSysExCore.GetResErr(ex, BLLExec.BLLObj == null ? null : BLLExec.BLLObj.OutObjData);
- }
- }
- }
- }
|