Ejemplo n.º 1
0
 public bool Login(string str, string password, out string msg, out User userInfo)
 {
     userInfo = IocUtils.Resolve <IUserRepository>().GetModel(name: str);
     if (userInfo != null)
     {
         if (userInfo.State == true)
         {
             if (DESEncrypt.Encrypt(password).Equals(userInfo.Password))
             {
                 //登录成功了,写其他业务;
                 userInfo.Last_Login_IP   = Net.Ip;
                 userInfo.Last_Login_Time = DateTime.Now;
                 IocUtils.Resolve <IUserRepository>().Update(userInfo);
                 msg = "ok,恭喜:登录成功!";
                 return(true);
             }
             else
             {
                 msg = "no,提示:密码错误!";
                 return(false);
             }
         }
         else
         {
             msg = "no,账户被系统锁定,请联系管理员!";
             return(false);
         }
     }
     else
     {
         msg = "no,账户不存在,请重新输入!";
         return(false);
     }
 }
 private void InitRoleWebMenu(AfxContext db)
 {
     using (db.BeginTransaction(IsolationLevel.ReadCommitted))
     {
         foreach (var kv in RoleWebMenuList)
         {
             foreach (var webmenuId in kv.Value)
             {
                 var m = db.RoleWebMenu.Where(q => q.RoleId == kv.Key && q.WebMenuId == webmenuId).FirstOrDefault();
                 if (m == null)
                 {
                     m = new RoleWebMenu()
                     {
                         Id        = this.GetIdentity <RoleWebMenu>(),
                         RoleId    = kv.Key,
                         WebMenuId = webmenuId
                     };
                     db.RoleWebMenu.Add(m);
                     db.SaveChanges();
                 }
             }
             db.AddCommitCallback((num) =>
             {
                 using (var cache = IocUtils.Get <IRoleWebMenuCache>())
                 {
                     cache.Remove(kv.Key);
                 }
             });
         }
         db.Commit();
     }
 }
Ejemplo n.º 3
0
        public ActionResult SendVcode(string phone, string vcode)
        {
            var validatecode = Session["user_vcode"].ToString() == null ? "" : Session["user_vcode"].ToString();

            if (string.IsNullOrEmpty(vcode))
            {
                return(Content("提示:验证码错误!"));
            }
            if (!validatecode.Equals(vcode, StringComparison.CurrentCultureIgnoreCase))
            {
                return(Content("提示:验证码错误!"));
            }
            if (phone.Length != 11 && phone.ToString() == null)
            {
                return(Content("提示:手机号码不正确"));
            }
            Random r       = new Random();
            string code2   = r.Next(100000, 999999).ToString();
            string ip      = Net.Ip;
            string outCode = IocUtils.Resolve <IUserService>().OutCode(phone, code2, ip);

            if (outCode != null)
            {
                string msg = VCode.SendVCode(phone, outCode);
                return(Content(msg));
            }
            else
            {
                return(Content("您的验证码短信仍在30分钟有效期内"));
            }
        }
Ejemplo n.º 4
0
        public virtual void OnAuthorization(AuthorizationFilterContext context)
        {
            var actionDescriptor = context.ActionDescriptor as Microsoft.AspNetCore.Mvc.Controllers.ControllerActionDescriptor;

            if (actionDescriptor != null)
            {
                var arr = actionDescriptor.MethodInfo.GetCustomAttributes(typeof(AnonymousAttribute), true);
                if (arr != null && arr.Length > 0)
                {
                    return;
                }
            }

            var user = context.HttpContext.GetUserSession();

            if (user == null)
            {
                this.SetError(context, ApiStatus.NeedLogin, "未登录或登录已超时!");
            }
            else if (!string.IsNullOrEmpty(this.ActionId))
            {
                using (var servce = IocUtils.Get <IRoleWebMenuService>())
                {
                    if (!servce.Exist(user.RoleId, this.ActionId))
                    {
                        this.SetError(context, ApiStatus.NeedAuth, "无权限访问!");
                    }
                }
            }
        }
 public void SetServerPath(int id)
 {
     using (var fileclient = IocUtils.Get <IFileInfoService>(new object[] { MainForm.Current.FileClient }))
     {
         this.ServerPath = fileclient.Get(id);
     }
 }
Ejemplo n.º 6
0
        public void SetPropertyByConfig(string objectId)
        {
            string        testlibraryPath = Path.Combine(Environment.CurrentDirectory, "..\\..\\..\\..\\TestLibrary\\bin\\Debug\\netcoreapp3.1");
            DirectoryInfo di = new DirectoryInfo(testlibraryPath);

            IocUtils.AddSearchPath(di.FullName);

            string config = Path.Combine(Environment.CurrentDirectory, "..\\..\\..\\ioc.xml");

            IocUtils.LoadConfig(config);

            object obj = IocUtils.GetObjectById(objectId);

            Assert.IsNotNull(obj);
            Console.WriteLine(objectId + ": " + obj);

            IocUtils.RemoveSearchPath(di.FullName);

            Assert.IsInstanceOfType(obj, typeof(TestLibrary.Person));

            TestLibrary.Person pobj = obj as TestLibrary.Person;

            Assert.AreEqual(pobj.Name, "王小明");
            Assert.AreEqual(pobj.Age, 18);
            Assert.AreEqual(pobj.IsPerson, true);
        }
        private void listView_Server_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            var item = this.listView_Server.GetItemAt(e.X, e.Y);

            if (item != null && item.Tag != null)
            {
                var m = item.Tag as FileInfoDto;
                if (m.Type == FileInfoType.Directory)
                {
                    this.ServerPath = m;
                    this.GetServerList();
                }
                else if (m.Type == (int)FileInfoType.None)
                {
                    if (this.ServerPath != null)
                    {
                        using (var fileclient = IocUtils.Get <IFileInfoService>(new object[] { MainForm.Current.FileClient }))
                        {
                            this.ServerPath = fileclient.Get(this.ServerPath.ParentId);
                        }
                    }
                    this.GetServerList();
                }
            }
        }
 public static void Register(IConfiguration configuration)
 {
     IocUtils.LoadDefaultImplement(DEFAULT_IMPLEMENT_FILE);
     IocUtils.Default.Register(configuration);
     ConfigUtils.SetThreads();
     LoadAll();
 }
        public static UserSessionDto GetUserSession(this HttpContext httpContext)
        {
            if (httpContext == null)
            {
                throw new ArgumentNullException(nameof(httpContext));
            }
            UserSessionDto m = httpContext.Items[USER_SESSION_KEY] as UserSessionDto;

            if (m == null)
            {
                var sid = GetSid(httpContext);
                if (!string.IsNullOrEmpty(sid))
                {
                    using (var userSessionService = IocUtils.Get <IUserSessionService>())
                    {
                        m = userSessionService.Get(sid);
                        if (m != null)
                        {
                            httpContext.Items[USER_SESSION_KEY] = m;
                        }
                    }
                }
            }

            return(m);
        }
Ejemplo n.º 10
0
        public JsonResult GetGameRatingList(int gameId)
        {
            var ratingList = IocUtils.Resolve <IGameRatingService>().GetList(gameId).ToJson();
            var areaList   = IocUtils.Resolve <IGameAreaService> ().GetList(gameId).ToJson();

            return(Json(new { Rating = ratingList, Area = areaList }, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 11
0
        public ActionResult ManitoFunPlay()
        {
            User user = new User()
            {
                UserId        = new OperatorProvider <FrontCurrentUser>().GetCurrent().UserId,
                HomePage_Img  = Request["homeImg"],
                Sex           = int.Parse(Request["sex"]),
                CurrentCity   = Request["city"],
                PersonalPhoto = Request["photo"],
                PersonalAudio = Request["audio"],
            };
            R_Game_User_Play game = new R_Game_User_Play()
            {
                Games_GameId      = int.Parse(Request["gameId"]),
                GameAreaId        = int.Parse(Request["areaId"]),
                GameRatingId      = int.Parse(Request["ratingId"]),
                GameRating_CutImg = Request["ratingImg"],
                OnlinePrice       = int.Parse(Request["onPrice"]),
                OfflinePrice      = int.Parse(Request["offPrice"]),
                TagName           = Request["tagName"],
                ServiceNote       = Request["serviceNote"],
                GameScore_CutImg  = Request["scoreImg"],
                Type = (int)ProjectType.FunPlay
            };

            if (IocUtils.Resolve <IR_Game_User_PlayService>().InsertFunPlay(game, user))
            {
                return(Content("ok,恭喜:信息提交成功!"));
            }
            else
            {
                return(Content("no,提示:游戏信息认证失败了!"));
            }
        }
Ejemplo n.º 12
0
        public void BuildByClassName()
        {
            string        testlibraryPath = Path.Combine(Environment.CurrentDirectory, "..\\..\\..\\..\\TestLibrary\\bin\\Debug\\netcoreapp3.1");
            DirectoryInfo di = new DirectoryInfo(testlibraryPath);

            IocUtils.AddSearchPath(di.FullName);

            object a = IocUtils.GetObject("TestLibrary.Person");

            Assert.IsNotNull(a);
            Console.WriteLine("a: " + a);

            dynamic b = IocUtils.GetObject("TestLibrary.Person", "张三");

            Assert.IsNotNull(b);
            Assert.AreEqual("张三", b.Name);
            Console.WriteLine("b: " + b);

            object c = IocUtils.GetObject("TestLibrary.Person", "李四", true);

            Assert.IsNotNull(c);
            Console.WriteLine("c: " + c);

            object d = IocUtils.GetObject("TestLibrary.Person", "王五", (Int16)18, true);

            Assert.IsNotNull(d);
            Console.WriteLine("d: " + d);

            IocUtils.RemoveSearchPath(di.FullName);
        }
Ejemplo n.º 13
0
        /// <summary>
        /// 大神主页
        /// </summary>
        /// <returns></returns>
        public ActionResult ManitoHomepage()
        {
            var user = new OperatorProvider <FrontCurrentUser>().GetCurrent();

            ViewData.Model     = user as FrontCurrentUser;
            ViewBag.FocusCount = IocUtils.Resolve <IFocusService>().GetFocusList(user.UserId, true).Count;
            ViewBag.FansCount  = IocUtils.Resolve <IFocusService>().GetFocusList(user.UserId, false).Count;
            return(View());
        }
 private void toolStripMenuItem_ServerPrve_Click(object sender, EventArgs e)
 {
     if (this.ServerPath != null)
     {
         using (var fileclient = IocUtils.Get <IFileInfoService>(new object[] { MainForm.Current.FileClient }))
         {
             this.ServerPath = fileclient.Get(this.ServerPath.ParentId);
         }
         this.GetServerList();
     }
 }
Ejemplo n.º 15
0
        public MainForm()
        {
            InitializeComponent();

            Current         = this;
            this.FileClient = IocUtils.Get <IFileClient>();
            this.Login();

            try { File.WriteAllText(WinAPIs.GetHandleFile(), this.Handle.ToString(), Encoding.UTF8); }
            catch { }
        }
Ejemplo n.º 16
0
        // GET: UserManage/User
        public ActionResult Index()
        {
            var user = new OperatorProvider <FrontCurrentUser>().GetCurrent();

            ViewData.Model      = user as FrontCurrentUser;
            ViewBag.FreezeMoney = IocUtils.Resolve <IMoneyService>().UserMoney(user.UserId, false);
            ViewBag.UsableMoney = IocUtils.Resolve <IMoneyService>().UserMoney(user.UserId, true);
            ViewBag.FocusCount  = IocUtils.Resolve <IFocusService>().GetFocusList(user.UserId, true).Count;
            ViewBag.FansCount   = IocUtils.Resolve <IFocusService>().GetFocusList(user.UserId, false).Count;
            return(View());
        }
Ejemplo n.º 17
0
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);
            IocUtils.Init();
            FileInfo configFile = new FileInfo(HttpContext.Current.Server.MapPath("/Config/log4net.config"));

            log4net.Config.XmlConfigurator.Configure(configFile);
        }
Ejemplo n.º 18
0
 public ActionResult IsUserWhere(string where)
 {
     if (IocUtils.Resolve <IUserService>().IsExistUserWhere(where))
     {
         return(Content("exist"));
     }
     else
     {
         return(Content("noExist"));
     }
 }
Ejemplo n.º 19
0
 public ActionResult CheckMobileCode(string mobile, string code)
 {
     if (IocUtils.Resolve <IVCodeService>().CheckMobileCode(mobile, code))
     {
         return(Content("ok"));
     }
     else
     {
         return(Content("no"));
     }
 }
        public static void Register()
        {
            IocUtils.RegisterSingle <CacheKey>(new CacheKey(PathUtils.GetFileFullPath(CACHE_KEY_FILE)));
            IocUtils.RegisterSingle <XmlConfig>(new XmlConfig(PathUtils.GetFileFullPath(CONFIG_FILE)));

            IocUtils.LoadDefaultImplement(DEFAULT_IMPLEMENT_FILE);

            LoadIoc();

            LoadRedis();
        }
        private static void LoadRedis()
        {
            var con = ConnectionMultiplexer.Connect(ConfigUtils.RedisConfig);

            con.ConnectionFailed  += OnConnectionFailed;
            con.ErrorMessage      += OnErrorMessage;
            con.InternalError     += OnInternalError;
            con.PreserveAsyncOrder = false;

            IocUtils.RegisterSingle <IConnectionMultiplexer>(con);
        }
        protected virtual T GetRepository <T>(string name, object[] args) where T : IBaseRepository
        {
            var             type       = typeof(T);
            IBaseRepository repository = null;

            if (!repositoryDic.TryGetValue(type, out repository))
            {
                repositoryDic[type] = repository = IocUtils.Get <T>(name, args);
            }

            return((T)repository);
        }
        protected virtual T GetCache <T>(string name, object[] args) where T : IBaseCache
        {
            var        type  = typeof(T);
            IBaseCache cache = null;

            if (!cacheDic.TryGetValue(type, out cache))
            {
                cacheDic[type] = cache = IocUtils.Get <T>(name, args);
            }

            return((T)cache);
        }
        protected virtual T GetService <T>(string name, object[] args) where T : IBaseService
        {
            var          type    = typeof(T);
            IBaseService service = null;

            if (!serviceDic.TryGetValue(type, out service))
            {
                serviceDic[type] = service = IocUtils.Get <T>(name, args);
                service.SetCurrentUser(this.UserSession);
            }

            return((T)service);
        }
Ejemplo n.º 25
0
        public bool CheckMobileCode(string mobile, string code)
        {
            int i = IocUtils.Resolve <IVCodeRepository>().CheckMobileCode(mobile, code);

            if (i > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Ejemplo n.º 26
0
        public bool IsExistUserWhere(string where)
        {
            User userInfo = IocUtils.Resolve <IUserRepository>().GetModel(name: where);

            if (userInfo != null)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Ejemplo n.º 27
0
 public void Start()
 {
     try
     {
         this.host.Start(ConfigUtils.Port);
         var fileInfoService = IocUtils.Get <IFileInfoService>();
         fileInfoService.CheckFileInfo();
     }
     catch (Exception ex)
     {
         LogUtils.Error("【Start】", ex);
         throw ex;
     }
 }
Ejemplo n.º 28
0
 private void OnClientClosedEvent(TcpHost server, Session session)
 {
     try
     {
         UserInfo user = session[USER_INFO_KEY] as UserInfo;
         SessionUtils.UserInfo = user;
         var userService = IocUtils.Get <IUserService>();
         userService.Logout();
     }
     catch (Exception ex)
     {
         LogUtils.Error("【OnClientClosedEvent】", ex);
     }
 }
        private void btn_Save_Click(object sender, EventArgs e)
        {
            string oldpwd  = this.txt_OldPwd.Text.Trim();
            string newpwd  = this.txt_NewPwd.Text.Trim();
            string newpwd2 = this.txt_NewPwd2.Text.Trim();

            if (string.IsNullOrEmpty(oldpwd))
            {
                this.txt_OldPwd.Focus();
                this.lb_msg.Text = "原密码不能为空!";
                return;
            }

            if (string.IsNullOrEmpty(newpwd))
            {
                this.txt_NewPwd.Focus();
                this.lb_msg.Text = "新密码不能为空!";
                return;
            }

            if (newpwd != newpwd2)
            {
                this.txt_NewPwd2.Focus();
                this.lb_msg.Text = "两次输入新密码不一致!";
                return;
            }

            if (newpwd == oldpwd)
            {
                this.txt_NewPwd2.Focus();
                this.lb_msg.Text = "新旧密码不能相同!";
                return;
            }

            using (var userService = IocUtils.Get <IUserService>(new object[] { MainForm.Current.FileClient }))
            {
                if (userService.UpdatePwd(oldpwd, newpwd))
                {
                    if (ConfigUtils.IsRememberPassword && ConfigUtils.Account.ToLower() == MainForm.Current.FileClient.UserInfo.Account.ToLower())
                    {
                        ConfigUtils.Password = newpwd;
                    }
                    this.DialogResult = System.Windows.Forms.DialogResult.OK;
                }
                else
                {
                    this.lb_msg.Text = "修改密码失败!";
                }
            }
        }
 public void LoadData()
 {
     this.SetEnabled(false);
     ThreadPool.QueueUserWorkItem((o) => {
         using (var client = IocUtils.Get <IRoleService>(new object[] { MainForm.Current.FileClient }))
         {
             var list = client.GetList(this.selectParam);
             this.Sync.Post((obj) => {
                 this.BindListView(obj as List <RoleInfoDto>);
                 this.SetEnabled(true);
             }, list);
         }
     });
 }