/// <summary> /// 刷新配置 /// </summary> public static void Refresh(ISession session) { lock (lockobject) { IList <ExtendFuncBizModel> configures = LoadExtendConfigureFromDataSource(session); AddinCache.ClearExtendFunc(); configures.ToList().ForEach(p => AddinCache.AddExtendFunc(p.MstModel.FuncName, p)); } }
/// <summary> /// 判断当前用户是否是操作员 /// </summary> /// <param name="loginId"></param> /// <returns></returns> public static bool CurrentUserIsOperator() { if (string.IsNullOrEmpty(NG3.AppInfoBase.LoginID)) { return(false); } string loginId = NG3.AppInfoBase.LoginID.ToLower(); return(AddinCache.ContainOper(loginId.ToLower())); }
/// <summary> /// 发布配置 /// </summary> /// <returns></returns> public static bool DeployConfigure(long mstPhid) { var data = AddinCache.GetCfg(mstPhid); if (data == null) { return(false); } data.MstModel.DeployFlag = 1; return(AddinCache.AddDeployedCfg(data.MstModel.Phid, data)); }
//根据扩展功能的名称获取配置类 public static ExtendFuncBizModel GetConfigureEntity(string name) { if (!_inited) { return(null); } if (string.IsNullOrEmpty(name)) { return(null); } return(AddinCache.GetExtendFuncConfigure(name)); }
/// <summary> /// 取消发布配置 /// </summary> /// <returns></returns> public static bool UnDeployConfigure(long mstPhid) { var data = AddinCache.GetDeployedCfg(mstPhid); if (data == null) { return(false); } data.MstModel.DeployFlag = 0; return(AddinCache.RemoveDeployCfg(data.MstModel.Phid)); }
/// <summary> /// 重新加载配置 /// </summary> /// <param name="session"></param> /// <returns></returns> public static bool ReloadConfigure(ISession session) { var data = LoadAllPluginConfigureFromDataSource(session); lock (alllockobject) { AddinCache.ClearCfg(); foreach (var item in data) { AddinCache.AddCfg(item.MstModel.Phid, item); } } return(true); }
/// <summary> /// 重新加载 /// </summary> /// <param name="session"></param> /// <returns></returns> public static bool ReloadOperator(ISession session) { var data = GetOperators(session); if (data == null) { return(false); } lock (operlockobject) { AddinCache.ClearAllOpers(); data.ToList().ForEach(p => { AddinCache.AddOper(p); }); } return(true); }
/// <summary> /// 初始化 /// </summary> public static void InitConfigure(ISession session) { if (_inited) { return; } lock (lockobject) { if (_inited) { return; } IList <ExtendFuncBizModel> configures = LoadExtendConfigureFromDataSource(session); configures.ToList().ForEach(p => AddinCache.AddExtendFunc(p.MstModel.FuncName, p)); _inited = true; //设置初始化完成标志 } }
public static void SaveServiceRequestParam(AddinMethodInvocation invocation) { var requestParams = RequestParams(); string className = invocation.Target.ToString(); string method = invocation.Method.Name; AddinConfigureEntityKey entityKey = new AddinConfigureEntityKey(className, method, EnumInterceptorType.None); foreach (string param in requestParams) { //key string key = entityKey.GetKey() + "_" + param; ServiceUIParamBizModel model = new ServiceUIParamBizModel { ClassName = className, MethodName = method, ParamName = param, ParamValue = requestParams[param] }; AddinCache.AddUIParam(key, model); } }
/// <summary> /// 初始化 /// </summary> /// <param name="session"></param> public static void Init(ISession session) { if (_inited) { return; } lock (lockobject) { //所有服务加入到缓存中 var serviceData = LoadAllPluginService(session); serviceData.ToList().ForEach(p => { AddinCache.AddService(p.Phid, p); }); if (_inited) { return; } IList <MethodAroundBizModel> configures = LoadAllPluginConfigureFromDataSource(session); foreach (var item in configures) { //通过ID填充Service记录 var service = AddinCache.GetService(item.MstModel.TargetServiceId); if (service != null) { item.MstModel.TargetAssemblyName = service.TargetAssemblyName; item.MstModel.TargetClassName = service.TargetClassName; item.MstModel.TargetMethodName = service.TargetMethodName; } AddinCache.AddCfg(item.MstModel.Phid, item); } //已经发布了的程序 var deployconfigures = configures.Where(p => p.MstModel.DeployFlag == 1).ToList(); foreach (var item in deployconfigures) { AddinCache.AddDeployedCfg(item.MstModel.Phid, item); } _inited = true; //设置初始化完成标志 } }
private static IList <MethodAroundBizModel> GetPluginConfigure(AddinConfigureEntityKey entityKey) { if (!_inited) { return(null); } var bizModel = AddinCache.GetDeployedCfgList(entityKey.GetKey()); if (bizModel.Count != 0) { return(bizModel); } if (AddinOperator.CurrentUserIsOperator()) { //如果是未发布,但是测试人员可以进行测试 bizModel = AddinCache.GetCfgList(entityKey.GetKey()); } return(bizModel); }
/// <summary> /// 初始化加载二开操作员 /// </summary> /// <param name="session"></param> /// <returns></returns> public static void Init(ISession session) { if (_inited) { return; } lock (lockobject) { if (_inited) { return; } //操作员 var operators = GetOperators(session); if (operators == null) { return; } operators.ToList().ForEach(p => { AddinCache.AddOper(p); }); _inited = true; //设置初始化完成标志 } }
/// <summary> /// 根据调用信息获取注入信息 /// </summary> /// <param name="methodName"></param> /// <param name="args"></param> /// <param name="target"></param> /// <param name="type"></param> /// <returns></returns> public static MethodAroundBizModel GetPluginConfigure(string methodName, object[] args, object target, EnumInterceptorType type) { AddinConfigureEntityKey entityKey = new AddinConfigureEntityKey (target.ToString(), methodName, type); //取不到配置信息 var entitys = AddinConfigure.GetPluginConfigure(entityKey); if (entitys.Count == 0) { return(null); } //如果只有一个则直接返回 if (entitys.Count == 1) { return(entitys[0]); } foreach (var entity in entitys) { //如果判断 var service = AddinCache.GetService(entity.MstModel.TargetServiceId); if (service == null) { LogHelper <AddinServiceModel> .Info("In AddinConfigure GetPluginConfigure method 通过addin_method_m中的servicePHid未能取得对应的service"); return(null); } string matchCondition = service.MatchCondition; //如果不存在条件则直接返回 if (string.IsNullOrEmpty(matchCondition)) { continue; } string[] eles = matchCondition.Split(new char[] { ':' }); if (eles.Length != 2) { LogHelper <AddinServiceModel> .Info("In AddinConfigure GetPluginConfigure method 条件定义出错" + matchCondition); continue; } int index = -1; if (!int.TryParse(eles[0].Trim(), out index)) { LogHelper <AddinServiceModel> .Info("In AddinConfigure GetPluginConfigure method 条件定义出错" + matchCondition); continue; } if (index < 0 || index > args.Length) { LogHelper <AddinServiceModel> .Info("In AddinConfigure GetPluginConfigure method 条件定义出错" + matchCondition); continue; } if (args[index] == null) { LogHelper <AddinServiceModel> .Info(string.Format("In AddinConfigure GetPluginConfigure args{0} is null", index)); continue; } if (!args[index].ToString().Equals(eles[1], StringComparison.OrdinalIgnoreCase)) { LogHelper <AddinServiceModel> .Info(string.Format("In AddinConfigure GetPluginConfigure args{0} is {1},MatchCondition value {2}", index, args[index].ToString(), eles[1])); continue; } return(entity); } return(null); }
/// <summary> /// 当前已经运行过的参数集合 /// </summary> /// <returns></returns> public static IList <ServiceUIParamBizModel> GetServiceUIParams() { return(AddinCache.GetUIParams()); }