Esempio n. 1
0
        public override string[] GetRolesForUser(string username)
        {
            HertsOnlineEntities db = new HertsOnlineEntities();
            String s = db.UserEntity.Where(x => x.Username == username).FirstOrDefault().UserRole;

            String[] results = { s };
            return(results);
        }
        public void collectVisitorData(String browserName, String ipAddr, String userAgent, bool isMobileDev, bool isLocalCon, String sessionID)
        {
            HertsOnlineEntities db = new HertsOnlineEntities();
            VisitorStatistics   visitorStatisticsModel = new VisitorStatistics();
            String visitStamp = DateTime.Now.ToString("dd/MM/yyyy H:mm");

            visitorStatisticsModel.UserSession = sessionID;

            if (isLocalCon)
            {
                //local connection
                visitorStatisticsModel.IPAddress = ipAddr;
                visitorStatisticsModel.Country   = "localhost";
            }
            else
            {
                //external connection
                visitorStatisticsModel.IPAddress = ipAddr;
                visitorStatisticsModel.Country   = getVisitorCountry(ipAddr);
            }
            if (isMobileDev)
            {
                //Mobile device
                visitorStatisticsModel.OperatingSystem = getMobileOS(userAgent);
                visitorStatisticsModel.Device          = getMobileDevice(userAgent);
            }
            else
            {
                //Desktop Device
                visitorStatisticsModel.OperatingSystem = getDesktopOS(userAgent);
                visitorStatisticsModel.Device          = "Desktop";
            }
            visitorStatisticsModel.VisitTimeStamp = visitStamp;

            visitorStatisticsModel.BrowserName = browserName;

            db.VisitorStatisticsEntity.Add(visitorStatisticsModel);
            db.SaveChanges();
        }