示例#1
0
 public UserCollection CollectUsers()
 {
     try
     {
         //Console.WriteLine(DateTime.Now.ToShortTimeString()+"  "+"CTCU");
         InitDB();
         Console.WriteLine(DateTime.Now.ToShortTimeString()+"  "+"DBINIT_CALL_COLLECT USERS");
         UserCollection scrc = new UserCollection();
         scrc.LoadAll();
         return scrc;
     }
     catch (Exception ex)
     {
         Console.WriteLine(DateTime.Now.ToShortTimeString()+"  "+ex.Message);
         return null;
     }
 }
示例#2
0
        public User VerifyLogin(string login, string passwd)
        {
            InitDB();

            //Purge Schedules older than 7 days from current day5
            try
            {
                DateTime dtNow = DateTime.Now;
                DateTime ts = dtNow.AddDays(-7);

                var sc = new ScheduleCollection();
                sc.Query.Where(sc.Query.Loopend.LessThan(ts));
                sc.LoadAll();
                sc.MarkAllAsDeleted();
                sc.Save();
            }
            catch (Exception ex)
            {
                Console.WriteLine(DateTime.Now.ToShortTimeString()+"  "+ex.Message);
            }

            //Purge all schedules on finding deleteschedule.txt
            if (File.Exists(@"c:\content\deleteschedule.txt") || File.Exists(@"c:\content\deleteschedule.txt.txt"))
            {
                CoreHost.Properties.Settings.Default.DefaultPort = "null";
                try
                {
                    File.Delete(@"c:\content\deleteschedule.txt");
                }
                catch (Exception ex)
                {
                }
                try
                {
                    File.Delete(@"c:\content\deleteschedule.txt.txt");
                }
                catch (Exception ex)
                {
                }
                Console.WriteLine(DateTime.Now.ToShortTimeString() + "  " + " -- Schedule Purge Requested --");
                ScheduleCollection sc = new ScheduleCollection();
                sc.LoadAll();
                sc.MarkAllAsDeleted();
                sc.Save();
                Console.WriteLine(DateTime.Now.ToShortTimeString() + "  " + " -- Schedules Purged OK --");
            }

            User _verifieduser = new User();
            Boolean Verified = false;
            UserCollection _usr = new UserCollection();
            _usr.LoadAll();
            foreach (User item in _usr)
            {
                if (!Verified) _verifieduser = item;
                if (item.Password == passwd && item.Loginid == login)
                {
                    Verified = true;
                }
            }
            if (Verified == true)
            {
                Console.WriteLine(DateTime.Now.ToShortTimeString()+"  "+DateTime.Now.ToString() + "Login OK");
                return _verifieduser;
            }
            else
            {
                Console.WriteLine(DateTime.Now.ToShortTimeString()+"  "+DateTime.Now.ToString()+" :Failed Login Attempt");
                try
                {
                    User _newuser = new User();
                    _newuser.Id = 99999;
                    _newuser.Fullname = "failed";
                    _newuser.Loginid = "sys";
                    _newuser.Password = "******";
                    _newuser.Groupid = "sys";
                    //_newuser.Save();
                    Console.WriteLine(DateTime.Now.ToShortTimeString()+"  "+DateTime.Now.ToString()+" :"+_newuser.Fullname + " - Failed Login Attempt");
                    return _newuser;
                }
                catch (Exception ex)
                {
                   // Console.Write(ex.Message);
                }
            }
            return null;
        }