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; }
public Boolean UpdateScheduleForScreens(ScheduleCollection scheduleCollection) { InitDB(); try { ScheduleCollection currentSchedule = new ScheduleCollection(); ScheduleCollection newSchedule = new ScheduleCollection(); //currentSchedule.LoadAll(); currentSchedule.Query.Where(currentSchedule.Query.Screenname.NotEqual("")); currentSchedule.Query.Load(); if (scheduleCollection.Count > 0) currentSchedule.MarkAllAsDeleted(); currentSchedule.Save(); foreach (Schedule schedule in scheduleCollection) { Schedule newSch = new Schedule(); newSch.Loopname = schedule.Loopname; newSch.Screenname = schedule.Screenname; newSch.Groupname = schedule.Groupname; newSch.Loopstart = schedule.Loopstart; newSch.Loopend = schedule.Loopend; newSchedule.Add(newSch); } newSchedule.Save(); SerializeScheduleCollection(); SerializeLoopCollection(); SerializeLoopContentCollection(); SerializeContentCollection(); SerializeTemplateCollection(); AddUpdateDelta("schedule"); } catch (Exception ex) { } return true; }