Ejemplo n.º 1
0
 public ShowViewsController(Helpers helpers, MovieGameContext context, SessionUser sessionUser, ManageUsersController manageUsers)
 {
     _helpers     = helpers;
     _context     = context;
     _sessionUser = sessionUser;
     _manageUsers = manageUsers;
 }
        public PartialViewResult _Mailbox(MaxIdForm MaxId)
        {
            int EmployeeId = SessionUser.GetUser().Id;
            IEnumerable <MailboxForm> form = MessageService.GetResponsesToEmployeeWithoutSome(EmployeeId, MaxId.Max_id).Select(message => new MailboxForm(message, EmployeeId));

            return(PartialView(form));
        }
Ejemplo n.º 3
0
        public IActionResult Index(UserViewModel model)
        {
            if (ModelState.IsValid)
            {
                model.Password = ToPasswordRepository.PasswordCryptographyCombine(model.Password);

                User foundUser = userService.Get(x => x.UserName.Equals(model.UserName) && x.Password.Equals(model.Password));
                if (foundUser != null)
                {
                    foundUser.UpdateDate   = DateTime.UtcNow;
                    foundUser.UpdateUserid = foundUser.id;
                    userService.Update(foundUser);
                    userService.Save();
                    SessionUser session = new SessionUser();
                    foundUser.UserToSession(ref session);
                    userSessionService.Set(session, "LoginUser");
                    return(RedirectToAction("Index", "Home", new { area = "" }));
                }
                else
                {
                    ViewBag.AlertMassage = "Girdiginiz bilgiler ile eslesen bir kayit bulunamadi.";
                }
            }
            else
            {
                ViewBag.AlertMassage = "Lutfen bilgileri dogru giriniz.";
            }
            return(View(model));
        }
        public ActionResult TeamTasks(int taskId)
        {
            int             Employee_Id = SessionUser.GetUser().Id;
            List <ListForm> list        = new List <ListForm>();

            foreach (Task Task in TaskService.GetForTeam(taskId, Employee_Id))
            {
                ListForm form = new ListForm()
                {
                    Id          = Task.Id,
                    ProjectId   = Task.ProjectId,
                    CreatorId   = Task.CreatorId,
                    Name        = Task.Title,
                    Description = Task.Description,
                    StartDate   = Task.Start,
                    EndDate     = Task.End,
                    Deadline    = Task.Deadline,
                    SubtaskOf   = Task.SubtaskOf,
                    StatusName  = Task.StatusName,
                    StatusDate  = Task.StatusDate,
                    StatusId    = Task.StatusId,
                    TeamId      = Task.TeamId
                };
                list.Add(form);
            }
            return(View(list));
        }
 public ActionResult AddSubtask(CreateForm form)
 {
     if (ModelState.IsValid)
     {
         Task t = new Task()
         {
             ProjectId   = form.ProjectId,
             Title       = form.Name,
             Description = form.Description,
             Start       = form.StartDate,
             Deadline    = form.Deadline,
             SubtaskOf   = form.SubtaskOf,
             TeamId      = form.SelectedTeamId
         };
         try
         {
             int?NewTaskId = TaskService.Create(t, SessionUser.GetUser().Id);
             if (NewTaskId != null)
             {
                 return(RedirectToAction("Details", "Task", new { projectId = form.ProjectId, taskId = NewTaskId }));
             }
         }
         catch (System.Data.SqlClient.SqlException exception)
         {
             throw (exception);
         }
     }
     return(RedirectToAction("Details", "Task", new { projectId = form.ProjectId, taskId = form.SubtaskOf }));
 }
Ejemplo n.º 6
0
        public ActionResult BuyItems()
        {
            ShoppingCartX    cart   = new ShoppingCartX();
            List <ICartItem> myList = cart.GetItems();

            if (SessionUser.UserLoggedIn())
            {
                foreach (var item in myList)
                {
                    ECommerceEntities entities = new ECommerceEntities();
                    Product           product  = entities.Product.Where(x => x.ProductID == item.Product.ProductID).FirstOrDefault();
                    product.StockCount -= item.ItemCount;
                    Orders order = new Orders();
                    order.CustomerID    = SessionUser.Current.CustomerID;
                    order.DateOrdered   = DateTime.Now;
                    order.PaymentAmount = cart.TotalAmount;
                    order.PaymentDate   = DateTime.Now;
                    //entities.SaveChanges();
                    OrderDetail detail = new OrderDetail();
                    //OrderDetail detail = entities.OrderDetail.Where(x => x.OrderID == order.OrderID).FirstOrDefault();
                    detail.OrderID      = order.OrderID;
                    detail.OrderTime    = DateTime.Now;
                    detail.ProductID    = item.Product.ProductID;
                    detail.ProductPrice = item.Product.Price;

                    entities.SaveChanges();
                }
            }


            return(View(myList));
        }
Ejemplo n.º 7
0
        //CreditCardRefund
        private bool CreditCardRefund(decimal amount, string transactionID, string CCNumber, string note, out string refundTransactionID)
        {
            SessionUser cuser = AppHelper.CurrentUser;
            bool        res   = false;

            refundTransactionID = string.Empty;
            try
            {
                long profile_id = AN_Functions.CreateCustomerProfile(cuser.ID, cuser.Email, String.Empty);
                if (profile_id <= 0)
                {
                    return(res);
                }

                refundTransactionID = AN_Functions.RefundTransaction(profile_id, amount, CCNumber.Substring(1, 4), transactionID, note);

                if (!AN_Functions.DeleteCustomerProfile(profile_id))
                {
                    return(res);
                }

                res = !String.IsNullOrEmpty(refundTransactionID);
            }
            catch (Exception ex)
            {
                Logger.LogException("Refunding deposit via Authorize.NET", ex);
            }
            return(res);
        }
Ejemplo n.º 8
0
        protected override bool DoSuccess(int userId, out IUser user)
        {
            user = null;
            Console.WriteLine("登录成功!");
            user = null;
            //原因:重登录时,数据会回档问题
            var      cacheSet = new GameDataCacheSet <GameUser>();
            GameUser userInfo = cacheSet.FindKey(userId.ToString());

            if (userInfo == null)
            {
                //通知客户跳转到创建角色接口
                GuideId = 1005;
                return(true);
            }
            else
            {
                user = new SessionUser(userInfo);
                userInfo.LoginTime = DateTime.Now;
                Console.WriteLine(DateTime.Now);
                userInfo.SessionID = Sid;
                userInfo.IsOnline  = true;
                userInfo.ServerId  = ServerID;
                userInfo.GameId    = GameType;
            }
            return(true);
            //如写登录日志
        }
Ejemplo n.º 9
0
        /// <summary>
        /// 用户登录
        /// </summary>
        /// <param name="context"></param>
        private void UserLogin(HttpContext context)
        {
            string        name     = context.Request["name"] ?? "";
            string        password = context.Request["password"] ?? "";
            Sys_AdminUser userM;
            var           result = new Sys_AdminUser_BLL().UserLogin(name, password, out userM);

            if (result == 1)
            {
                #region 登录人信息

                SessionUser sessionUser = new SessionUser()
                {
                    UserId   = userM.Id.ToString(),
                    UserName = userM.Name,
                    RoleId   = userM.RoleId.ToString()
                };
                RequestSession.AddSessionUser(sessionUser);

                #endregion

                //LogHelper.InserLog((int)EnumClass.OperateType.登录系统, PageBase.CurrentOperatName, "登录");
            }
            context.Response.Write(result);
        }
Ejemplo n.º 10
0
        public SessionService(IHttpContextAccessor httpContextAccessor)
        {
            _httpContextAccessor = httpContextAccessor;
            var httpContext = httpContextAccessor.HttpContext;

            if (string.IsNullOrEmpty(httpContext.Session.GetString("user")))
            {
                if (httpContext.User?.Identity?.IsAuthenticated == true && httpContext.User?.Claims?.Count() > 0)
                {
                    try
                    {
                        SessionUser sessionUser = new SessionUser
                        {
                            Id         = Convert.ToInt32(httpContext.User.Claims.FirstOrDefault(c => c.Type == ClaimTypes.NameIdentifier)?.Value),
                            UserName   = httpContext.User.Claims.FirstOrDefault(c => c.Type == ClaimTypes.Name)?.Value,
                            FullNameAr = httpContext.User.Claims.FirstOrDefault(c => c.Type == Constants.FullNameClaimType)?.Value,
                            FullNameEn = httpContext.User.Claims.FirstOrDefault(c => c.Type == Constants.FullNameClaimType)?.Value,
                            Role       = httpContext.User.Claims.FirstOrDefault(c => c.Type == Constants.RoleClaimType)?.Value,
                        };

                        httpContext.Session.SetString("user", JsonConvert.SerializeObject(sessionUser));
                    }
                    catch (Exception ex) { }
                }
            }


            Culture  = Thread.CurrentThread.CurrentCulture.Name.ToString();
            IsArabic = Thread.CurrentThread.CurrentCulture.Name == Constants.ARCultureCode;

            if (!string.IsNullOrEmpty(httpContext.Session.GetString("user")))
            {
                User = JsonConvert.DeserializeObject <SessionUser>(httpContext.Session.GetString("user"));
            }
        }
Ejemplo n.º 11
0
        public async Task LoginUser(HttpContext httpContext, SessionUser loggedInUser)
        {
            Claim[] claims = new[]
            {
                new Claim(ClaimTypes.NameIdentifier, loggedInUser.Id.ToString()),
                new Claim(ClaimTypes.Name, loggedInUser.UserName),
                new Claim(Constants.FullNameClaimType, IsArabic ? loggedInUser.FullNameAr : loggedInUser.FullNameEn),
                new Claim(Constants.RoleClaimType, loggedInUser.Role)
            };

            var identity  = new ClaimsIdentity(claims, CookieAuthenticationDefaults.AuthenticationScheme);
            var principal = new ClaimsPrincipal(identity);
            var props     = new AuthenticationProperties
            {
                IsPersistent = false,
                ExpiresUtc   = DateTimeOffset.UtcNow.AddHours(1),
            };

            await httpContext.SignInAsync(CookieAuthenticationDefaults.AuthenticationScheme, principal, props);

            // Fill Session
            httpContext.Session.SetString("user", JsonConvert.SerializeObject(loggedInUser));

            this.User = loggedInUser;
        }
        public ActionResult Details(int id)
        {
            C.Event Event = EventService.Get(id);
            IEnumerable <C.EmployeeEvent> SubscribedEmployees = EventService.GetSubscriptionStatus(id);
            bool subscribed = false;

            foreach (C.EmployeeEvent Subscription in SubscribedEmployees)
            {
                if (Subscription.EmployeeId == SessionUser.GetUser().Id&& !(bool)Subscription.Cancelled)
                {
                    subscribed = true;
                }
            }
            DetailsForm form = new DetailsForm
            {
                Id               = (int)Event.Id,
                CreatorId        = Event.CreatorId,
                Name             = Event.Title,
                Description      = Event.Description,
                Address          = Event.Address,
                StartDate        = Event.Start,
                EndDate          = Event.End,
                CreationDate     = Event.Created,
                OpenSubscription = Event.Open,
                Subscribed       = subscribed,
                Documents        = DocumentService.GetForEvent((int)Event.Id).Select(d => new Doc.ListForm {
                    Name = d.Filename, Id = (int)d.Id
                })
            };

            return(View(form));
        }
Ejemplo n.º 13
0
        public ActionResult SaveTargetLang(int projectId, int fileId, string targetLang)
        {
            ControllerResult oControllerResult = new ControllerResult();

            try
            {
                if (User.Identity.IsAuthenticated && GetUserPermission(SessionUser.GetUserId(), projectId))
                {
                    TranslateModel translateModel = new TranslateModel();
                    ProjectFile    oProjectFile   = translateModel.GetFile(projectId, fileId);
                    if (oProjectFile != null && !String.IsNullOrEmpty(targetLang))
                    {
                        translateModel.SaveTargetLang(projectId, fileId, targetLang);
                    }
                    else
                    {
                        oControllerResult.IsSuccess = false;
                        oControllerResult.Message   = "project or file don't exists!";
                    }
                }
                else
                {
                    oControllerResult.IsSuccess = false;
                    oControllerResult.Message   = "You don't had permission in file!";
                }
            }
            catch (Exception ex)
            {
                oControllerResult.IsSuccess = false;
                oControllerResult.Message   = ex.Message;
            }
            return(Json(new { success = oControllerResult.IsSuccess, responseText = oControllerResult.Message }, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 14
0
        protected override bool AuthorizeCore(HttpContextBase httpContext)
        {
            bool   accessAllowed = false;
            string teamId        = httpContext.Request.Params.Get("teamId");
            int    UserId        = SessionUser.GetUser().Id;

            try
            {
                if (!(teamId is null))
                {
                    int TeamId = int.Parse(teamId);
                    if (UserId == TeamService.GetTeamLeaderId(TeamId))
                    {
                        accessAllowed = true;
                    }
                    else
                    {
                        Team Team = TeamService.GetTeamById(TeamId);
                        if (UserId == ProjectService.GetProjectManagerId(Team.Project_Id))
                        {
                            accessAllowed = true;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return(accessAllowed);
        }
Ejemplo n.º 15
0
        public JsonResult getAccumulated(bool statusAccumulated, double?sumMoney)
        {
            if (statusAccumulated)
            {
                double scroreAccumulated = 0;
                var    customer          = SessionUser.GetSession();

                scroreAccumulated = Math.Ceiling(double.Parse(db.KHACHHANGs.Where(x => x.Id_KhachHang == customer.Id)
                                                              .Select(x => x.DiemTichLuy).FirstOrDefault().ToString()));
                scroreAccumulated = scroreAccumulated * Constant.DiemQuyDoi;

                if (sumMoney == null && sumMoney != 0)
                {
                    return(Json(new { status = true, scroreAccumulated }, JsonRequestBehavior.AllowGet));
                }
                else
                {
                    if (SessionUser.GetSession() != null)
                    {
                        var lastTotal = sumMoney - scroreAccumulated;
                        if (lastTotal < 0)
                        {
                            lastTotal = 0;
                        }
                        return(Json(new { status = true, lastTotal }, JsonRequestBehavior.AllowGet));
                    }
                }
            }
            return(Json(new { status = false }, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 16
0
        public async Task <ActionResult> ActualizarAsync(Actividad_Web actividad)
        {
            if (actividad.ValidarActividad(actividad, false))
            {
                bool retorno = await actividad.Update();

                if (retorno)
                {
                    SessionUser userSesion = new SessionUser();

                    Tarea_Terminada task = new Tarea_Terminada()
                    {
                        LayoutNombre   = "_LayoutAdmin",
                        Titulo         = "Actividad Actualizada",
                        Mensaje        = "La actividad ha sido actualizada exitosamente.",
                        ActionName     = "Index",
                        ControllerName = "Actividad",
                        LinkTexto      = "Volver a la lista de actividades"
                    };

                    userSesion.SesionTareaTerminada = task;

                    return(RedirectToAction("Exito", "Home"));
                }
            }
            foreach (var item in actividad._dictionaryError)
            {
                ModelState.AddModelError(item.Key, item.Value);
            }
            return(View("Editar", "_LayoutAdmin", actividad));
        }
Ejemplo n.º 17
0
        public static void Login(User user, HttpContextBase context)
        {

            using (EPDataContext dbContext = new EPDataContext())
            {
                SessionUser userSession = new SessionUser()
                {
                    CreateDT = DateTime.Now,
                    Id = Guid.NewGuid(),
                    IsDeleted = false,
                    LastActivityDT = DateTime.Now,
                    LoginDT = DateTime.Now,
                    ModifiedDT = DateTime.Now,
                    RemoteIP = context.Request.ServerVariables["REMOTE_ADDR"],
                    UserId = user.Id,
                    Status = UserLoginStatus.Active.ToString()

                };
                dbContext.SessionUsers.Add(userSession);
                dbContext.SaveChanges();

                HttpCookie cookie = new HttpCookie(SESSION_ID, userSession.Id.ToString());
                context.Response.AppendCookie(cookie);

            }
        }
 public ActionResult EditPass(EditPassForm form)
 {
     if (ModelState.IsValid)
     {
         string     OldPass = form.OldPass;
         D.Employee e       = new D.Employee()
         {
             Employee_Id = SessionUser.GetUser().Id,
             Passwd      = form.NewPass
         };
         try
         {
             if (EmployeeService.UpdatePassword(e, OldPass))
             {
                 return(RedirectToAction("Index"));
             }
             ModelState.AddModelError("OldPass", "Mot de passe incorrect");
         }
         catch (Exception exception)
         {
             throw (exception);
         }
     }
     return(View());
 }
 public ActionResult Edit(EditProfileForm form)
 {
     if (ModelState.IsValid)
     {
         D.Employee e = new D.Employee()
         {
             Employee_Id = SessionUser.GetUser().Id,
             FirstName   = form.FirstName,
             LastName    = form.LastName,
             Address     = form.Address,
             Phone       = form.Phone
         };
         try
         {
             if (EmployeeService.Update(e))
             {
                 return(RedirectToAction("Index"));
             }
         }
         catch (Exception exception)
         {
             throw (exception);
         }
     }
     return(View(form));
 }
Ejemplo n.º 20
0
        public async Task <ActionResult> UpdatePageId(string pageId, string authToken)
        {
            var currentUser = ScheduleContext.Users.FirstOrDefault(x => x.Id == user.Id);

            using (var client = new HttpClient())
            {
                string url      = $@"https://graph.facebook.com/v7.0/{pageId}?fields=instagram_business_account&access_token={authToken}";
                var    response = await client.GetAsync(url);

                var result = await response.Content.ReadAsStringAsync();

                try
                {
                    var jsonObject = JsonConvert.DeserializeObject <IGUser>(result);

                    if (jsonObject.instagram_business_account == null || string.IsNullOrWhiteSpace(jsonObject.instagram_business_account.id))
                    {
                        return(Json("noAccount"));
                    }
                    else
                    {
                        currentUser.InstagramUserId = jsonObject.instagram_business_account.id;
                    }
                }
                catch (Exception)
                {
                    return(Json("noAccount"));
                }
            }

            currentUser.FacebookPageId = pageId;
            ScheduleContext.SaveChanges();
            Session["User"] = new SessionUser(currentUser);
            return(Json(true));
        }
Ejemplo n.º 21
0
        protected void InitData(Guid pageNumbers, SessionUser sessionUser)
        {
            PageNumber = pageNumbers;

            //TODO
            //SessionUser = sessionUser;
            var value = HttpContext.Current.Request.Cookies[SessionVariables.sessionUserId].Value;

            if (!string.IsNullOrEmpty(value))
            {
                int id = Convert.ToInt32(value);
                if (id == 409)
                {
                    id = 2;
                }
                var user = new SessionUser(
                    id, "Jan", "Kowalski", "*****@*****.**", false, false, true, false);

                Session[SessionVariables.user] = user;
                SessionUser = user;

                HttpContext.Current.Response.Cookies[SessionVariables.sessionUserId].Value     = value.ToString();
                HttpContext.Current.Response.Cookies[SessionVariables.sessionUserId].Expires   = DateTime.Now.AddDays(1);
                HttpContext.Current.Response.Cookies[SessionVariables.sessionUserId].HttpOnly  = true;
                HttpContext.Current.Response.Cookies[SessionVariables.sessionUserId].Shareable = true;
            }
        }
Ejemplo n.º 22
0
        public ActionResult Create(CreateForm form)
        {
            if (ModelState.IsValid)
            {
                C.Department Department = new C.Department(form.Title, DateTime.Now, form.Description, SessionUser.GetUser().Id, true);

                int?DepId = DepartmentService.Create(Department, SessionUser.GetUser().Id);
                if (DepId != null)
                {
                    if (DepartmentService.ChangeHeadOfDepartment((int)DepId, form.SelectedHeadOfDepartmentId, SessionUser.GetUser().Id))
                    {
                        return(RedirectToAction("Index"));
                    }
                }
                IEnumerable <C.Employee> Employees = EmployeeService.GetAllActive();
                List <SelectListItem>    HeadOfDepartmentCandidates = new List <SelectListItem>();
                foreach (C.Employee emp in Employees)
                {
                    HeadOfDepartmentCandidates.Add(new SelectListItem()
                    {
                        Text  = emp.FirstName + " " + emp.LastName + " (" + emp.Email + ")",
                        Value = emp.Employee_Id.ToString()
                    });
                }
                form.HeadOfDepartmentCandidateList = HeadOfDepartmentCandidates;
            }
            return(View(form));
        }
        public KHACHHANG FindById(int id)
        {
            var userlogin = SessionUser.GetSession();

            id = userlogin.Id;
            return(context.KHACHHANGs.Find(id));
        }
        public ActionResult Create(CreateForm Form)
        {
            if (ModelState.IsValid)
            {
                if (Form.SelectedDepartmentId == -1)
                {
                    Form.SelectedDepartmentId = null;
                }
                EventService.Create(
                    new C.Event(SessionUser.GetUser().Id, Form.SelectedDepartmentId, Form.Name, Form.Description, Form.Address, Form.StartDate, Form.EndDate.AddHours(23.99), Form.OpenEvent),
                    SessionUser.GetUser().Id);
                return(RedirectToAction("Index"));
            }
            List <SelectListItem> DepartmentList = new List <SelectListItem>
            {
                new SelectListItem
                {
                    Text  = "Toute l'entreprise",
                    Value = "-1"
                }
            };

            foreach (C.Department dep in DepartmentService.GetAllActive())
            {
                DepartmentList.Add(new SelectListItem
                {
                    Text  = dep.Title,
                    Value = dep.Id.ToString()
                });
            }
            Form.DepartmentList = DepartmentList;
            return(View(Form));
        }
Ejemplo n.º 25
0
        public ActionResult AddAuction(long id)
        {
            SessionUser usr = AppHelper.CurrentUser;
            List <EventCategoryDetail> cats = CategoryRepository.GetAllowedCategoriesForTheEvent(id);

            ViewData["AllowedCategories"] = cats;
            string path = Server.MapPath(string.Format(AppHelper.UserImageFolder(usr.ID)));

            if (!Directory.Exists(path))
            {
                Directory.CreateDirectory(path);
            }
            Event          evnt = EventRepository.GetEventByID(id);
            AuctionListing al   = new AuctionListing();

            al.Event_ID        = id;
            al.Location        = usr.SellerLocation;
            al.IsConsignorShip = usr.IsConsignorShip;
            al.Quantity        = 1;
            al.Price           = al.Reserve = al.Cost = 1;
            al.Owner_ID        = usr.ID;
            al.DateIN          = DateTime.Now;
            al.Auction_ID      = null;
            al.InternalID      = al.Descr = String.Empty;
            al.IsBold          = al.IsFeatured = al.IsTaxable = false;
            al.Title           = " ";
            al.Category_ID     = cats != null?cats.First().EventCategory_ID : 0;

            al               = AuctionRepository.UpdateLotToAuctionListing(al);
            al.Title         = String.Empty;
            al.EventCategory = null;
            al.Event         = evnt;
            return(View(al));
        }
Ejemplo n.º 26
0
        public async Task <ActionResult> Nuevo()
        {
            var misPupilos = new List <Alumno>();
            var sesion     = new SessionUser();
            var apoderado  = new Apoderado_Web();
            //Se busca al apoderado del alumno según el rut de usuario...
            await apoderado.ReadPorRut(sesion.SesionWeb.Rut);

            Colecciones col = new Colecciones();

            if (apoderado.Id != 0)
            {
                misPupilos = await col.ListaAlumnos();

                misPupilos = misPupilos.Where(n => n.Apoderado.Id == apoderado.Id).ToList();
            }
            return(View("Nuevo", "_LayoutApoderado", new PagoViewModel()
            {
                MisAlumnos = misPupilos.Select(n => new SelectListItem()
                {
                    Value = n.Rut.ToString(),
                    Text = String.Format("{0} {1}", n.Nombre, n.APaterno)
                }).ToList()
            }));
        }
Ejemplo n.º 27
0
        public void AddPlayer(int uid, GameSession session, PlayerInfo userInfo)
        {
            SessionUser user = new SessionUser();

            user.UserId = uid;

            Player oldPlayer = null;

            if (mPlayersMap.TryGetValue(uid, out oldPlayer))
            {
                oldPlayer.OnReplace();
                mPlayers.Remove(oldPlayer);
                mPlayersMap.Remove(uid);
            }

            session.Bind(user);

            Player player = new Player();

            player.mUserID     = uid;
            player.mSession    = session;
            player.mPlayerInfo = userInfo;
            player.mStatus     = PlayerStatus.Online;

            mPlayers.Add(player);
            mPlayersMap[uid] = player;
        }
Ejemplo n.º 28
0
    public Player AddPlayer(int uid, GameSession session)
    {
        SessionUser user = new SessionUser();

        user.UserId = uid;

        Player oldPlayer = null;

        if (mPlayersMap.TryGetValue(uid, out oldPlayer))
        {
            oldPlayer.OnReplace();
            mPlayers.Remove(oldPlayer);
            mPlayersMap.Remove(uid);
        }

        session.Bind(user);

        Player player = new Player();

        player.UserID   = uid;
        player.gid      = GIDManger.Instance.GetGID();
        player.mSession = session;
        player.mStatus  = PlayerStatus.Online;

        mPlayers.Add(player);
        mPlayersMap[player.UserID] = player;

        return(player);
    }
Ejemplo n.º 29
0
        private void ReloadAll(Guid userId)
        {
            var service = Ioc.Get <IUserService>();

            _user             = service.GetSessionUser(userId);
            this.WeixinUserId = userId;
        }
Ejemplo n.º 30
0
        void Session_Start(object sender, EventArgs e)
        {
            string host = Request.Url.Host;
            Organization org = DataService.GetOrganization(host);

            SessionUser SessionUser = new SessionUser {};

            if (org == null)
            {
                Session[Constants.SessionKeys.User] = SessionUser;
                Response.Redirect(Constants.SiteKeys.BASE_URL, true);
                return;
            }

            SessionUser.OrganizationID = org.OrganizationID;
            SessionUser.OrganizationName = org.Name;

            if (Request.IsAuthenticated)
            {
                var user = DataService.GetUser(User.Identity.Name);
                if (user == null)
                {
                    // Something weird happened
                    FormsAuthentication.SignOut();
                }
                else
                {
                    SessionUser.Email = user.Email;
                    SessionUser.UserID = user.UserID;
                }
            }

            Session[Constants.SessionKeys.User] = SessionUser;
        }
 public ActionResult EditEmail(EditEmailForm form)
 {
     if (ModelState.IsValid)
     {
         D.Employee e = new D.Employee()
         {
             Employee_Id = SessionUser.GetUser().Id,
             Email       = form.Email,
             Passwd      = form.Passwd
         };
         try
         {
             if (EmployeeService.UpdateEmail(e))
             {
                 return(RedirectToAction("Index"));
             }
             ModelState.AddModelError("Passwd", "Mot de passe incorrect");
         }
         catch (System.Data.SqlClient.SqlException exeption)
         {
             if (exeption.Number == 2627)
             {
                 if (exeption.Message.Contains("UC_Email"))
                 {
                     ModelState.AddModelError("Email", "Cet email est déjà utilisé");
                 }
             }
         }
     }
     return(View(form));
 }
Ejemplo n.º 32
0
        public async Task <ActionResult> CambiarPassword(string password, string password_again)
        {
            var salida = false;

            try
            {
                var sesion = new SessionUser();

                if (string.IsNullOrEmpty(password) || string.IsNullOrEmpty(password_again))
                {
                    return(Json("Las contraseñas no pueden ser vacias.", JsonRequestBehavior.AllowGet));
                }

                if (!password.Equals(password_again))
                {
                    return(Json("Las contraseñas no coinciden.", JsonRequestBehavior.AllowGet));
                }

                Usuario_Web usuario_update = new Usuario_Web()
                {
                    Rut = sesion.SesionWeb.Rut, Password = password
                };
                salida = await usuario_update.UpdatePassword();

                return(Json(salida, JsonRequestBehavior.AllowGet));
            }
            catch (Exception)
            {
                return(Json(salida, JsonRequestBehavior.AllowGet));
            }
        }
Ejemplo n.º 33
0
 public static string AddSessionUser(SessionUser user)
 {
     // HttpContext rq = HttpContext.Current;
     // rq.Session[RequestSession.SESSION_USER] = user;
     //��ֹһ���������ε�½��ֵ
     if (GetSessionUser() == null)
     {
         user.SessionId = HttpContext.Current.Session.SessionID;
         HttpContext.Current.Session["SESSION_USER"] = user;
         return "1";
     }
     if (GetSessionUser().SessionId == HttpContext.Current.Session.SessionID)
     {
         return "2";
     }
     return "2";
 }
Ejemplo n.º 34
0
        private static SessionUser LoginPrivate(User user)
        {
            if (user != null)
            {

                SessionUser sUser = new SessionUser(user.UID, user.ItCode, user.FullName);

                User = sUser;

                List<string> perms = new List<string>();
                perms.AddRange(new string[] { "0", "1", "2", "4", "8", "16", "32", "64", "128", "256"});

                sUser.NavCfg = NavCfgMgr.GetUserNavCfg(perms.ToArray());

                return sUser;
            }
            else
                return null;
        }