示例#1
0
        public void UpdateForumSession(string username, string sessionhash, int loggedin)
        {
            int forumUserId = 0;

            using (NtxfcDbContext db = new NtxfcDbContext())
            {
                Login login = db.Logins.FirstOrDefault(x => x.Username == username);
                if (login != null)
                {
                    forumUserId = login.ForumUserId;
                }
            }

            if (forumUserId != 0)
            {
                using (ExternalDbContext db = new ExternalDbContext())
                {
                    var session = db.Sessions.FirstOrDefault(x => x.sessionhash == sessionhash);
                    if (session != null)
                    {
                        session.loggedin = loggedin;
                        session.userid   = forumUserId;
                        db.Sessions.Attach(session);
                        db.Entry(session).Property(u => u.loggedin).IsModified = true;
                        db.Entry(session).Property(u => u.userid).IsModified   = true;
                        db.SaveChanges();
                    }
                }
            }
        }
示例#2
0
 public AccessDbImporter()
 {
     _dbContext = new NtxfcDbContext();
     LoadSourceData();
     ImportUsers();
     ImportAircraft();
     ImportSchedule();
     ImportInstructors();
     ImportReviews();
     ImportSquawks();
     ImportCheckouts();
 }
示例#3
0
        public bool IsExistingEmail(string email)
        {
            using (NtxfcDbContext db = new NtxfcDbContext())
            {
                var login = db.Logins.FirstOrDefault(x => x.Email == email);

                if (login != null)
                {
                    return(true);
                }
            }

            return(false);
        }
示例#4
0
        public bool IsExistingUsername(string username)
        {
            using (NtxfcDbContext db = new NtxfcDbContext())
            {
                var login = db.Logins.FirstOrDefault(x => x.Username == username);

                if (login != null)
                {
                    return(true);
                }
            }

            return(false);
        }
示例#5
0
        public string SaveForumSession(string username, string host, string useragent, string forwardedfor)
        {
            int forumUserId = 0;

            using (NtxfcDbContext db = new NtxfcDbContext())
            {
                Login login = db.Logins.FirstOrDefault(x => x.Username == username);
                if (login != null)
                {
                    forumUserId = login.ForumUserId;
                }
            }

            if (forumUserId != 0)
            {
                Session session = new Session();
                session.sessionhash = Guid.NewGuid().ToString("N");
                session.userid      = forumUserId;
                session.host        = host;
                session.idhash      = CalculateMD5Hash(String.Concat(useragent, GetSubIP(GetRealIP(host, forwardedfor))));
                TimeSpan ts = (DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0));
                session.lastactivity   = Convert.ToInt32(ts.TotalSeconds);
                session.location       = "/login.php";
                session.useragent      = useragent;
                session.loggedin       = 1;
                session.apiaccesstoken = string.Empty;

                using (ExternalDbContext db = new ExternalDbContext())
                {
                    db.Sessions.Add(session);
                    db.SaveChanges();
                }

                return(session.sessionhash);
            }

            return(string.Empty);
        }