Beispiel #1
0
        public void LoadStateFromIsoStorage()
        {
            if (!MainDataSource.Instance.IsActive)
            {
                UserDataSource        user      = CoreExtensions.LoadFromFile <UserDataSource>("user.xml");
                PinnedItemsCollection pins      = CoreExtensions.LoadFromFile <PinnedItemsCollection>("pins.xml");
                ForumCollection       forums    = CoreExtensions.LoadFromFile <ForumCollection>("forums.xml");
                UserBookmarks         bookmarks = CoreExtensions.LoadFromFile <UserBookmarks>("bookmarks.xml");
                ThreadTable           threads   = CoreExtensions.LoadFromFile <ThreadTable>("threads.xml");

                MainDataSource.Instance.CurrentUser = user;
                MainDataSource.Instance.Pins        = pins;
                MainDataSource.Instance.Forums      = forums;
                MainDataSource.Instance.Bookmarks   = bookmarks;
                MainDataSource.Instance.ThreadTable = threads;
            }
        }
Beispiel #2
0
        public ObservableSetWrapper <ThreadDataSource> FindForumThreadsByID(string forumId)
        {
            ObservableSetWrapper <ThreadDataSource> threads = null;

            if (forumId == Bookmarks.ForumID)
            {
                threads = Bookmarks;
            }

            else if (ThreadTable.ContainsKey(forumId))
            {
                threads = ThreadTable[forumId];
            }

            else
            {
                var forumThreads = new ForumThreadCollection(forumId);
                ThreadTable.Add(forumId, forumThreads);
                threads = forumThreads;
            }

            return(threads);
        }
        public ActionResult LogOn(LogOnUserModel user)
        {
            ViewBag.EnterpriseName     = this.service.SysConfig.GetSysConfig(Model.Enums.SysConfigEnum.EnterpriseName);
            ViewBag.EnableLogOnCaptcha = IsEnableLogOnCaptcha();
            ViewBag.YearAccount        = HelperExtensions.SelectListData <YearAccount>("YearValue", "ID", "IsRun=1", "ID", true, null);
            if (ViewBag.EnableLogOnCaptcha)
            {
                if (Session["CaptchaCode"] == null || user.CaptchaCode == null || Session["CaptchaCode"].ToString() != user.CaptchaCode.ToLower())
                {
                    ModelState.AddModelError("CaptchaCode", Lang.Account_LogOn_CaptchaCodeIncorrect);
                    Session["CaptchaCode"] = null;
                    return(View());
                }
            }

            ModelState.Remove("CaptchaCode");
            if (ModelState.IsValid)
            {
                LogOnStatus status = UserLogOn(user);
                switch (status)
                {
                case LogOnStatus.Success:

                    HttpCookie cookie = new HttpCookie("UserName", HttpUtility.UrlEncode(user.UserName));

                    cookie.Expires = DateTime.Now.AddYears(1);
                    Response.Cookies.Add(cookie);
                    this.service.SysLog.Log(Model.Enums.SysLogType.LoginSuccess, user.UserName, null, null);

                    //if (_LicenseInfo.Date <= 30) //zjy
                    //{
                    //    TempData["LicenseInfo"] =
                    //        string.Format(Lang.License_Expire_CountDown
                    //        , _LicenseInfo.Edition
                    //        , _LicenseInfo.DaysLeftInTrial);
                    //}
                    ThreadTable t = new ThreadTable();
                    try
                    {
                        lock (obj)
                        {
                            if (!this.service.GoodsIn.table.Contains(user.UserName))
                            {
                                this.service.ThreadTable.table.Add(user.UserName, new object());
                                t.value = user.UserName + "|" + this.service.ThreadTable.table["date"].ToString();
                                this.service.ThreadTable.Add(t);
                            }
                        }
                    }
                    catch (Exception e) {
                        t.value = e.Message;
                        this.service.ThreadTable.Add(t);
                    }

                    return(RedirectToAction("Index", "Home"));

                case LogOnStatus.UserNotFound:
                    ModelState.AddModelError("UserName", Lang.Account_LogOn_UserNotFound);
                    break;

                case LogOnStatus.UserLocked:
                    ModelState.AddModelError("UserName", Lang.Account_LogOn_UserIsLocked);
                    break;

                case LogOnStatus.PasswordError:
                    this.service.SysLog.Log(Model.Enums.SysLogType.LoginPasswordError, user.UserName, user, null);
                    ModelState.AddModelError("Password", Lang.Account_LogOn_PasswordIncorrect);
                    break;

                case LogOnStatus.IPNotAllowed:
                    this.service.SysLog.Log(Model.Enums.SysLogType.LoginNotAllowedIP, user.UserName, null, null);
                    ModelState.AddModelError("form", Lang.Account_LogOn_IPNotAllowed + Request.UserHostAddress);
                    break;

                default:
                    ModelState.AddModelError("", Lang.Account_LogOn_Failed);
                    break;
                }
            }
            return(View());
        }