Exemple #1
0
 public ActionResult ManageStationLinksGridData(GridSettings gridSettings, long userId)
 {
     using (var dataTable = CRCDataAccess.GetStationsForUserId(userId))
     {
         return(InfJqGridData(dataTable, gridSettings));
     }
 }
Exemple #2
0
        protected void Application_AuthenticateRequest(Object sender, EventArgs e)
        {
            var authCookie = Request.Cookies[FormsAuthentication.FormsCookieName];

            if (authCookie != null)
            {
                var authTicket = FormsAuthentication.Decrypt(authCookie.Value);
                var userEmail  = authTicket.Name;

                var drUser = CRCDataAccess.GetCRCUserByEmail(userEmail);
                if (drUser != null)
                {
                    var userRoles = new List <string>();

                    if (drUser["AdministratorInd"].ToString().Equals("Y", StringComparison.OrdinalIgnoreCase))
                    {
                        userRoles.Add(CRCUserRoles.Administrator);
                    }

                    if (drUser["CRCManagerInd"].ToString().Equals("Y", StringComparison.OrdinalIgnoreCase))
                    {
                        userRoles.Add(CRCUserRoles.CRCManager);
                    }

                    if (userRoles.Count < 1)
                    {
                        userRoles.Add(CRCUserRoles.StationUser);
                    }

                    var userPrincipal = new CRCUserPrincipal(new GenericIdentity(userEmail), userRoles.ToArray());
                    drUser.MapTo(userPrincipal);
                    userPrincipal.UserId    = (long)drUser["UserId"];
                    userPrincipal.Email     = drUser["Email"].ToString();
                    userPrincipal.FirstName = drUser["FirstName"].ToString();
                    userPrincipal.LastName  = drUser["LastName"].ToString();
                    userPrincipal.IsActive  = drUser["DisabledDate"] as DateTime? != null;

                    if (userPrincipal.IsInRole(CRCUserRoles.StationUser))
                    {
                        var dtStations = CRCDataAccess.GetStationsForUserId(userPrincipal.UserId);
                        foreach (DataRow drStation in dtStations.Rows)
                        {
                            var stationId = (long)drStation["StationId"];
                            var gridWritePermissionsInd = drStation["GridWritePermissionsInd"].ToString().Equals("Y", StringComparison.OrdinalIgnoreCase);

                            userPrincipal.Stations.Add(stationId, gridWritePermissionsInd);
                        }
                    }

                    Context.User = userPrincipal;
                }
            }
        }