Exemplo n.º 1
0
 static CacheManager()
 {
     Console.WriteLine($"{DateTime.Now}...开始缓存的初始化.....");
     cache = DIFactory.GetService <ICacheProvider>();
     //可以创建不同的cache对象
     //cache = (ICacheProvider)Activator.CreateInstance(typeof(MemoryCacheCache));
     // 这里可以根据配置文件来选择
     //cache = (ICacheProvider)Activator.CreateInstance(typeof(CustomCache));
 }
Exemplo n.º 2
0
        public static IBaseRepository CreateService(Type type)
        {
            var server = CallContext.GetData(type.FullName) as IBaseRepository;

            if (server == null)
            {
                server = DIFactory.GetService <IBaseRepository>();
                CallContext.SetData(type.FullName, server);
            }
            return(server);
        }
Exemplo n.º 3
0
        public JsonResult Login(JObject data)
        {
            string   UserCode = data.Value <string>("username");
            string   Password = data.Value <string>("password");
            string   IP       = data.Value <string>("ip");
            string   City     = data.Value <string>("city");
            Sys_User user     = new Sys_User()
            {
                Code     = UserCode,
                Password = MD5Encrypt.Encrypt(Password, 64)
            };

            ISys_UserService bLL = DIFactory.GetService <ISys_UserService>();
            var loginResult      = bLL.Login(user);

            if (loginResult.Succeed && loginResult.ResultData != null)
            {
                //登录成功后,查询当前用户数据
                user = loginResult.ResultData as Sys_User;

                //调用框架中的登录机制
                var loginer = new BaseLoginer
                {
                    UserId   = 0,// user.UserId,
                    ID       = user.Id,
                    UserCode = user.Code,
                    Password = user.Password,
                    UserName = user.Name,
                    Data     = user,
                    IsAdmin  = user.Explain == "管理员用户" //根据用户Explain判断。用户类型:0=未定义 1=超级管理员 2=普通用户 3=其他
                };

                //读取配置登录默认失效时长:小时
                var effectiveHours = Convert.ToInt32(60 * ConfigUtil.GetConfigDecimal("LoginEffectiveHours"));


                //执行web登录
                FormsAuth.SignIn(loginer.ID.ToString(), loginer, effectiveHours);
                log.Info("登录成功!用户:" + loginer.UserName + ",账号:" + loginer.UserCode + ",密码:---");
                //设置服务基类中,当前登录用户信息
                // this.CurrentBaseLoginer = loginer;
                //登陆后处理
                //更新用户登陆次数及时间(存储过程登录,数据库已经处理)
                //添加登录日志
                string userinfo = string.Format("用户姓名:{0},用户编号:{1},登录账号:{2},登录密码:{3}",
                                                loginer.UserName, loginer.UserCode, loginer.UserCode, "---" /*loginer.Password*/);
                //更新其它业务
            }
            else
            {
                log.Info("登录失败!账号:" + UserCode + ",密码:" + Password + "。原因:" + loginResult.ResultMsg);
            }
            return(Json(loginResult, JsonRequestBehavior.DenyGet));
        }
Exemplo n.º 4
0
        public static ICacheProvider GetCacheProvider()
        {
            var key = typeof(T).FullName;

            if (!CacheProvider.ContainsKey(key))
            {
                var cache = DIFactory.GetService <ICacheProvider>();
                CacheProvider.TryAdd(key, cache);
            }
            return(CacheProvider[key]);
        }
Exemplo n.º 5
0
        public static IBaseRepository <T> CreateService <T>() where T : BaseModel
        {
            var key    = typeof(T).FullName;
            var server = CallContext.GetData(key) as IBaseRepository <T>;

            if (server == null)
            {
                Type type = typeof(IBaseRepository <>).GetTypeEx <T>();
                server = DIFactory.GetService(type) as IBaseRepository <T>;
                CallContext.SetData(key, server);
            }
            return(server);
        }
Exemplo n.º 6
0
        // GET: Test
        public string Index()
        {
            var service = DIFactory.GetService <IBaseService>();

            return("123");// View();
        }
Exemplo n.º 7
0
 /// <summary>
 /// 获取业务逻辑层
 /// </summary>
 /// <param name="type"></param>
 /// <returns></returns>
 protected static IBaseService GetService(Type type)
 {
     return(DIFactory.GetService(typeof(IAppService <>).MakeGenericType(type)) as IBaseService);
 }
Exemplo n.º 8
0
 /// <summary>
 /// 获取业务逻辑访问层
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <returns></returns>
 protected static T GetService <T>()
 {
     return(DIFactory.GetService <T>());
 }
Exemplo n.º 9
0
        /// <summary>
        /// 工具栏所有按钮
        /// </summary>
        /// <param name="module"></param>
        protected virtual void CreateButton(IModule module)
        {
            var server = DIFactory.GetService <ISysModuleService>();

            module.Buttons = server.GetButton(module);
        }