Exemplo n.º 1
0
        public void IphoneEnter(
            [Argument(Source.Arguments)] object[] arguments)
        {
            #region 注入
            ILogService LogService = AutofacUtil.GetScopeService <ILogService>();
            #endregion

            LogService.LogCollectPushApple("LogIphone", JsonConvert.SerializeObject(arguments), LogService.GetLoggerRepository());
        }
Exemplo n.º 2
0
        /// <summary>
        /// 是否拥有权限
        /// </summary>
        /// <param name="permission">权限值</param>
        /// <returns></returns>
        public static bool IsHas(string permission)
        {
            ISySession sySession = AutofacUtil.GetService <ISySession>();

            if (sySession.Permission != null && sySession.Permission.Contains(permission))
            {
                return(true);
            }
            return(false);
        }
Exemplo n.º 3
0
        /// <summary>
        /// 应用程序的主入口点。
        /// </summary>
        static void Main()
        {
            //在希望开始调试的地方加入这一行代码
            System.Diagnostics.Debugger.Launch();

            //启动日志框架
            log4net.Config.XmlConfigurator.Configure();

            //windows服务初始化工作
            AutofacUtil.InitAutofac();

            ServiceBase[] ServicesToRun;
            ServicesToRun = new ServiceBase[]
            {
                new Service1()
            };
            ServiceBase.Run(ServicesToRun);
        }
Exemplo n.º 4
0
        public void Intercept(IInvocation invocation)
        {
            Console.WriteLine($"Feign start:{invocation.Method.Name}");
            try
            {
                if (true)
                {
                    FeignOptions   feignOptions  = AppConfig.GetSection <FeignOptions>("Feign");
                    IJsonSerialize jsonSerialize = AutofacUtil.GetService <IJsonSerialize>();
                    Console.WriteLine($"Feign arguments:{jsonSerialize.ObjectToJSON(invocation.Arguments)}");
                    var url = RoutingHelper.GetRouteUrlByInterface(feignOptions.Service.FirstOrDefault(p => p.DllName == invocation.TargetType.Assembly.GetName().Name)?.ServiceName, invocation.Method);
                    Console.WriteLine($"Feign url:{url}");
                    var apiMethodAttribute = ReflectionHelper.GetSingleAttributeOrDefault <ApiMethodAttribute>(invocation.Method);
                    var paramInfo          = invocation.Method.GetParameters();
                    var parameterType      = paramInfo.Select(it => it.ParameterType).ToArray();



                    var     returnType = invocation.Method.ReturnType;
                    IClient client     = AutofacUtil.GetService <IClient>();


                    RequestTemplate  requestTemplate  = new RequestTemplate(apiMethodAttribute.HttpMethod, url);
                    ResponseTemplate responseTemplate = client.ExecuteAsync(requestTemplate, new System.Threading.CancellationToken()).Result;


                    //throw new Exception();
                    invocation.ReturnValue = invocation.Arguments[0];
                }
                Console.WriteLine($"Feign end:{invocation.Method.Name} | ReturnValue: Success = {invocation.ReturnValue}");
            }
            catch
            {
                invocation.Proceed();
                Console.WriteLine($"Feign end:{invocation.Method.Name} | ReturnValue: Fallback = {invocation.ReturnValue}");
            }
        }
Exemplo n.º 5
0
 private SysRoleAppService GetRoleAppService()
 {
     return(AutofacUtil.GetScopeService <SysRoleAppService>());
 }
Exemplo n.º 6
0
 /// <summary>
 /// 获取请求
 /// </summary>
 /// <returns></returns>
 private IAtlassRequest GetAtlassRequest()
 {
     return(AutofacUtil.GetScopeService <IAtlassRequest>());
 }
Exemplo n.º 7
0
        public void CodeVerificationEnter(
            [Argument(Source.Name)] string name,
            [Argument(Source.Arguments)] object[] arguments)
        {
            #region 注入
            IValidateCodeManager ValidateCodeManager = AutofacUtil.GetScopeService <IValidateCodeManager>();
            #endregion

            if (GlobalsConfig.Configuration[ConfigurationKeys.Verification_Code].ToLower() == "false")
            {
                return;
            }
            Type t = arguments[0].GetType();
            List <PropertyInfo> lPropertyInfo = t.GetProperties().ToList();
            //取得Code
            var    p    = lPropertyInfo.FirstOrDefault(x => x.Name == "Code");
            string Code = p == null ? "" : ((p.GetValue(arguments[0], null)) ?? "").ToString();
            //取得CodeKey
            p = lPropertyInfo.FirstOrDefault(x => x.Name == "CodeKey");
            string CodeKey = p == null ? "" : ((p.GetValue(arguments[0], null)) ?? "").ToString();
            //取得Email
            p = lPropertyInfo.FirstOrDefault(x => x.Name == "Email");
            string Email = p == null ? "" : ((p.GetValue(arguments[0], null)) ?? "").ToString();
            //取得Phone
            p = lPropertyInfo.FirstOrDefault(x => x.Name == "Phone");
            string Phone = p == null ? "" : ((p.GetValue(arguments[0], null)) ?? "").ToString();

            if (string.IsNullOrWhiteSpace(CodeKey))
            {
                throw new AppException("验证码Key不能为空");
            }
            if (ValidateCodeManager.ExistsImage(CodeKey).Result)
            {
                if (string.IsNullOrWhiteSpace(Code))
                {
                    throw new AppException("验证码不能为空");
                }
                string code = ValidateCodeManager.GetImage(CodeKey).Result;
                if (string.IsNullOrWhiteSpace(code))
                {
                    throw new AppException("验证码错误或已过期");
                }
                if (code.ToLower() != Code.ToLower())
                {
                    throw new AppException("验证码错误或已过期");
                }
            }
            else if (ValidateCodeManager.ExistsMail(CodeKey).Result)
            {
                if (string.IsNullOrWhiteSpace(Email))
                {
                    throw new AppException("邮箱不能为空");
                }
                Code code = ValidateCodeManager.GetMail(CodeKey).Result;
                if (code == null)
                {
                    throw new AppException("验证码错误或已过期");
                }
                if (string.IsNullOrWhiteSpace(code.email) || string.IsNullOrWhiteSpace(code.code))
                {
                    throw new AppException("验证码错误或已过期");
                }
                if (code.email.ToLower() != Email.ToLower())
                {
                    throw new AppException("验证码错误或已过期");
                }
                if (code.code.ToLower() != Code.ToLower())
                {
                    throw new AppException("验证码错误或已过期");
                }
            }
            else
            {
                throw new AppException("验证码错误或已过期");
            }
        }
Exemplo n.º 8
0
 public DomainModel()
 {
     _dbContext = AutofacUtil.GetScopeService <TDbContext>();
     _dbSet     = _dbContext.Set <TEntity>();
 }