private List <ActionRequestLog> GetLogs(int startingId = 0, int endingId = 1000) { if (endingId <= startingId) { return(new List <ActionRequestLog>()); } using (OsbideContext db = OsbideContext.DefaultWebConnection) { DateTime startDate = new DateTime(2014, 01, 01); DateTime endDate = new DateTime(2014, 05, 15); var sql = from log in db.ActionRequestLogs join user in db.Users on log.CreatorId equals user.Id join cur in db.CourseUserRelationships on user.Id equals cur.UserId join course in db.Courses on cur.CourseId equals course.Id where course.Id == 3 && log.AccessDate >= startDate && log.AccessDate <= endDate && log.Id >= startingId && log.Id <= endingId && user.HasInformedConsent == true select log; return(sql.ToList()); } }
public override void OnActionExecuting(ActionExecutingContext filterContext) { Authentication auth = new Authentication(); string key = auth.GetAuthenticationKey(); OsbideUser user = auth.GetActiveUser(key); //check web.config to see if we are requiring VS plugin install if (ConfigurationManager.AppSettings["RequireVsPlugin"].Equals("true")) { //is the user a student? if (user.Email != null && user.Role == SystemRole.Student) { DateTime lastActivity = DateTime.UtcNow; using (OsbideContext db = OsbideContext.DefaultWebConnection) { lastActivity = db.Users.Where(u => u.Id == user.Id).Select(u => u.LastVsActivity).FirstOrDefault(); } //only allow access if they've been active in Visual Studio in the last 7 days if (lastActivity < DateTime.UtcNow.Subtract(new TimeSpan(7, 0, 0, 0, 0))) { filterContext.Result = new RedirectToRouteResult(new RouteValueDictionary(new { controller = "Error", action = "RequiresActiveVsConnection" })); } } } }
public OsbideWebService() { #if DEBUG Db = new OsbideContext("OsbideDebugContext"); Database.SetInitializer <OsbideContext>(new DropCreateDatabaseIfModelChanges <OsbideContext>()); #else Db = new OsbideContext("OsbideReleaseContext"); #endif }
public StudentSubscriptionsQuery(OsbideContext db, OsbideUser observer) { if (db == null || observer == null) { throw new Exception("Parameters cannot be null"); } _db = db; _observer = observer; }
public Authentication() { //set up DB _db = OsbideContext.DefaultWebConnection; //set up cache _cache = FileCacheHelper.GetGlobalCacheInstance(); _cache.DefaultRegion = "AuthenticationService"; //have our cache kill things after 2 days _cache.DefaultPolicy = new CacheItemPolicy() { SlidingExpiration = new TimeSpan(2, 0, 0, 0, 0) }; }
public AssignmentSubmissionsViewModel(OsbideContext db) { DownloadCommand = new DelegateCommand(Download, CanIssueCommand); RefreshAssignments = new DelegateCommand(RefreshAssignmentList, CanIssueCommand); AvailableAssignments = new ObservableCollection <string>(); SubmissionEntries = new ObservableCollection <SubmissionEntryViewModel>(); /* AC: turned off for fall study * _timer.Interval = new TimeSpan(0, 0, 1, 0, 0); * _timer.Tick += new EventHandler(timer_Tick); * _timer.Start(); * * _db = db; * UpdateAssignmentListing(); * */ }
/// <summary> /// Returns the build event that is related to this exception. Note that the underlying EF DB connection /// will be closed at the end of this function call, thereby preventing access to some BuildEvent member objects. /// </summary> /// <param name="exEvent"></param> /// <returns></returns> public static BuildEvent GetBuildEvent(this ExceptionEvent exEvent) { BuildEvent evt = new BuildEvent(); using (OsbideContext db = OsbideContext.DefaultWebConnection) { var query = from log in db.EventLogs join be in db.BuildEvents on log.Id equals be.EventLogId where log.Id < exEvent.EventLogId && log.LogType == BuildEvent.Name orderby log.Id descending select be; var result = query.Take(1); evt = result.FirstOrDefault(); } return(evt); }
/// <summary> /// Will return the build event associated with the given exception event. /// </summary> /// <param name="exEvent"></param> /// <returns></returns> public static List <CodeDocument> GetCodeDocuments(this ExceptionEvent exEvent) { List <CodeDocument> docs = new List <CodeDocument>(); using (OsbideContext db = OsbideContext.DefaultWebConnection) { var query = from log in db.EventLogs join be in db.BuildEvents on log.Id equals be.EventLogId where log.Id < exEvent.EventLogId && log.LogType == BuildEvent.Name orderby log.Id descending select be; var result = query.Take(1); BuildEvent build = result.FirstOrDefault(); if (build != null) { foreach (BuildDocument doc in build.Documents) { docs.Add(doc.Document); } } } return(docs); }
public BuildErrorQuery(OsbideContext db) { _db = db; }
public ActionResult Index(OsbideUser user) { if (Db.Schools.Count() == 0) { School wsu = new School() { Name = "Washington State University" }; School other = new School() { Name = "Other Instituion" }; Db.Schools.Add(wsu); Db.Schools.Add(other); Db.SaveChanges(); } if (Db.ChatRooms.Count() == 0) { Db.ChatRooms.Add(new Library.Models.ChatRoom() { IsDefaultRoom = true, Name = "Class Chat", SchoolId = 1 } ); Db.ChatRooms.Add(new Library.Models.ChatRoom() { IsDefaultRoom = false, Name = "Chat Room #1", SchoolId = 1 } ); Db.ChatRooms.Add(new Library.Models.ChatRoom() { IsDefaultRoom = false, Name = "Chat Room #2", SchoolId = 1 } ); Db.ChatRooms.Add(new Library.Models.ChatRoom() { IsDefaultRoom = true, Name = "Class Chat", SchoolId = 2 } ); Db.SaveChanges(); } if (Db.Courses.Count() == 0) { OsbideContext context = Db; context.Courses.Add(new Course() { Name = "OSBIDE 101", Year = 2014, Season = "Spring", SchoolId = 1, Description = "Everything you ever wanted to know about OSBIDE." } ); context.Courses.Add(new Course() { Name = "CptS 121", Year = 2014, Season = "Spring", SchoolId = 1, Description = "Formulation of problems and top-down design of programs in a modern structured language for their solution on a digital computer." } ); context.Courses.Add(new Course() { Name = "CptS 122", Year = 2014, Season = "Spring", SchoolId = 1, Description = "This course is about advanced programming techniques, data structures, recursion, sorting, searching, and basic algorithm analysis." } ); context.Courses.Add(new Course() { Name = "CptS 223", Year = 2014, Season = "Spring", SchoolId = 1, Description = "Advanced data structures, object oriented programming concepts, concurrency, and program design principles." } ); context.Courses.Add(new Course() { Name = "CptS 483", Year = 2014, Season = "Spring", SchoolId = 1, Description = "Web development" } ); context.SaveChanges(); } return(RedirectToAction("Index", "Home")); }
public TimelineAnalysisViewModel() { _db = OsbideContext.DefaultWebConnection; Timeline = new Dictionary <int, StudentTimeline>(); }