public void Post(ExistingCourses[] ExistingCoursesToSave, string dateToUpdate, string Comments) { DateTime dateUpdate = DateTime.Parse(dateToUpdate); int result = 0; using (var ctx = new ScheduleDB()) { SqlParameter date, orderNumber, courseIndex, groupIndex, updateUntilDate, comments; foreach (ExistingCourses item in ExistingCoursesToSave) { date = new SqlParameter("@date", item.Date); orderNumber = new SqlParameter("@orderNumber", item.OrderNumber); courseIndex = new SqlParameter("@courseIndex", item.CourseId); groupIndex = new SqlParameter("@groupIndex", item.GroupId); updateUntilDate = new SqlParameter("@updateUntilDate", dateUpdate); comments = Comments != "undifined"?new SqlParameter("@Comments", Comments) : new SqlParameter("@Comments", null); result = ctx.Database.ExecuteSqlCommand("insertOrUpdateLessonsUntilDate @date,@orderNumber,@courseIndex,@groupIndex,@updateUntilDate,@Comments", date, orderNumber, courseIndex, groupIndex, updateUntilDate, comments); } //int h = 0; //SqlParameter courseName= new SqlParameter("@courseName", "cobol"); //SqlParameter coursId = new SqlParameter("@coursId", 1); //result = ctx.Database.ExecuteSqlCommand("SaveTry @courseName,@coursId", courseName,coursId); } }
public ActionResult SaveAvailSvc(string json) { Availability avail = JsonConvert.DeserializeObject <Availability>(json); ScheduleDB.SaveAvailability(avail, GetConfiguration().GetConnectionString("DefaultConnection")); return(Json(TutorDB.FetchProfile(1)));// new { data= "Tutor data" }); }
public IActionResult GetMiniNotifications(int page = 1, int pageSize = 5) { int langId = 1; LoginModel model = base.TutorModel != null ? base.TutorModel : base.StudentModel; if (model != null) { QAResponse <ICollection <Notif> > notifs = ScheduleDB.GetNotificationsPage ( model.User.UserId, Notification.NotificationType.Push, 0 - (short)DateTimeOffset.Now.Offset.TotalMinutes, //DateTime.Now.AddHours(-100), //DateTime.Now.AddHours(100), null, null, langId, page, pageSize, GetConfiguration().GetConnectionString(DEFAULT_CONNECTION), false ); notifs.Extras.Remove("RemainingPages"); notifs.Extras.Add("RemainingPages", "-1"); return(Json(notifs)); } return(null); }
public virtual void Delete(T entityToDelete) { using (var context = new ScheduleDB()) { context.Entry(entityToDelete).State = System.Data.Entity.EntityState.Deleted; context.SaveChanges(); } }
public virtual void Update(T entityToUpdate) { using (var context = new ScheduleDB()) { context.Entry(entityToUpdate).State = EntityState.Modified; context.SaveChanges(); //Must be in using block } }
public IActionResult GetDisciplineList() { using (var db = new ScheduleDB()) { var model = db.discipline.ToList(); return(View("Discipline", model)); } }
public IActionResult CreateDiscipline(discipline item) { using (var db = new ScheduleDB()) { db.discipline.Add(item); db.SaveChanges(); } return(Redirect("/Discipline")); }
public IActionResult SaveRoom(string json, int tzOffset, int lang = 1) { VirtualRoom room = null; if (json != null && json.Length > 0) { room = JsonConvert.DeserializeObject <VirtualRoom>(json); } return(Json(ScheduleDB.SaveRoom(room, tzOffset, lang, GetConfiguration().GetConnectionString(DEFAULT_CONNECTION)))); }
public IActionResult Confirm(long eventId, long user, int tZOS, int lang = 1) { bool confirmed = ScheduleDB.Confirm(eventId, user, tZOS, lang, GetConfiguration().GetConnectionString(DEFAULT_CONNECTION)); string jsFunction = "greet(\"Meeting confirmed!\");"; if (!confirmed) { jsFunction = "warn(\"Meeting could not be confirmed! please contact our staff. Thank you\");"; } TempData["JavaScriptFunction"] = jsFunction; return(RedirectToAction("Index", "Home")); }
public IActionResult Index() { using (var db = new ScheduleDB()) { var model = db.schedule .Include(x => x.Discipline) .Include(x => x.TimeBegin) .Include(x => x.TimeEnd) .ToList(); return(View(model)); } }
protected override async Task ExecuteAsync(CancellationToken stoppingToken) { while (!stoppingToken.IsCancellationRequested) { //_logger.LogInformation("Worker running at: {time}", DateTimeOffset.Now); EmailNotifier.SysRecipients = AppContentDB.GetSourceRecipients(_configuration.GetConnectionString(DEFAULT_CONNECTION)); DataList <Notification> notifs = ScheduleDB.GetNotifications(Notification.NotificationType.Email, 0 - (short)DateTimeOffset.Now.Offset.TotalMinutes, DateTime.Now.AddMilliseconds(-DelayMS), DateTime.Now.AddMilliseconds(DelayMS), 1, _configuration.GetConnectionString(DEFAULT_CONNECTION)); Console.WriteLine(string.Concat(notifs.Data.Count, "notifications ready to send.")); new NotificationProcessor <Notification>(notifs.Data, this).Start(); Console.WriteLine("Sending notifications..."); System.GC.Collect(); await Task.Delay(DelayMS, stoppingToken); } }
protected override async void Execute() { IList <Task <IList <NotificationResponse> > > tasks = new List <Task <IList <NotificationResponse> > >(); IList <NotificationResponse> responses = new List <NotificationResponse>(); foreach (Notification notification in this.notifications) { Task <IList <NotificationResponse> > task = await Task.FromResult(notification.NotifyAsync()); foreach (NotificationResponse response in task.Result) { responses.Add(response); } } int rows = ScheduleDB.UpdateNotifStatus(responses, this.Notifier.Configuration.GetConnectionString(Notifier.DEFAULT_CONNECTION)); }
public IActionResult Room(long id, int tZOS, int lang) { LoginModel model = base.TutorModel != null ? base.TutorModel : base.StudentModel; if (model != null) { DataList <Event> events = ScheduleDB.Room(id, tZOS, lang, GetConfiguration().GetConnectionString(DEFAULT_CONNECTION)); if (events.Data.Count > 0) { IEnumerator <Event> enumerator = events.Data.GetEnumerator(); enumerator.MoveNext(); if (enumerator.Current.Running && enumerator.Current.Joined.Contains(model.User.UserId)) { string jsFunction = "warn(\"You are alrady in room! If you feel anything wrong please login again.\");"; TempData["JavaScriptFunction"] = jsFunction; return(RedirectToAction("Index", "Home")); } ViewBag.Event = enumerator.Current; } return(View(model)); } return(base.AssureLogin(this.CurrentController, this.CurrentAction)); }
public ICollection <ReportDetails> GetReportDetails(string startDateString, string endDateString, string courseName)//show { DateTime startDate = DateTime.Parse(startDateString); DateTime endDate = DateTime.Parse(endDateString); try { using (ScheduleDB db = new ScheduleDB()) { var name = new SqlParameter { ParameterName = "@CourseName", Value = courseName }; var start = new SqlParameter { ParameterName = "@StartDate", Value = startDate }; var end = new SqlParameter { ParameterName = "@EndDate", Value = endDate }; ICollection <ReportDetails> dataList = db.Database.SqlQuery <ReportDetails>("exec ReportResponse @CourseName, @StartDate, @EndDate ", name, start, end).ToList <ReportDetails>(); return(dataList.ToList()); } } catch (Exception ex) { Console.Write(ex); } return(null); }
public NonActiveDaysService() { context = new ScheduleDB(); repository = new NonActiveDaysRepository(context); }
public NonActiveDaysRepository(ScheduleDB context) : base(context) { }
public IActionResult Notifications(long id, int tzOffset, DateTime?from = null, DateTime?to = null, int lang = 1, byte limit = 5) { return(Json(ScheduleDB.GetNotifications(id, NotificationType.Push, tzOffset, from, to, lang, limit, GetConfiguration().GetConnectionString(DEFAULT_CONNECTION)))); }
/// <summary> /// 在将要挂起应用程序执行时调用。 在不知道应用程序 /// 无需知道应用程序会被终止还是会恢复, /// 并让内存内容保持不变。 /// </summary> /// <param name="sender">挂起的请求的源。</param> /// <param name="e">有关挂起请求的详细信息。</param> private void OnSuspending(object sender, SuspendingEventArgs e) { isSuspend = true; var deferral = e.SuspendingOperation.GetDeferral(); //TODO: 保存应用程序状态并停止任何后台活动 //Get the frame navigation state serialized as a string and save in settings Frame frame = Window.Current.Content as Frame; ApplicationData.Current.LocalSettings.Values["NavigationState"] = frame.GetNavigationState(); /* * using (var conn = ScheduleDB.GetDbConnection()) * { * var listItemDBs = conn.Table<ListItemDB>(); * * foreach (ListItem listitem in MainPage.ViewModel1.AllItems) * { * bool flag = true; * foreach(ListItemDB listitemDB in listItemDBs) * if (listitemDB.Id == listitem.Id) * { * listitemDB.ImgPath = listitem.ImgPath; * listitemDB.Size = listitem.Size; * listitemDB.Title = listitem.Title; * listitemDB.Detail = listitem.Detail; * listitemDB.Date = listitem.Date; * listitemDB.Finish = listitem.Finish; * conn.Update(listitemDB); * flag = false; * break; * } * if (flag) * { * ListItemDB listItemDB = new ListItemDB(listitem.Id, listitem.ImgPath, listitem.Size, listitem.Title, listitem.Detail, listitem.Date, listitem.Finish); * conn.Insert(listItemDB); * } * } * * foreach (ListItemDB listitemDB in listItemDBs) * { * bool flag = false; * foreach (ListItem listitem in MainPage.ViewModel1.AllItems) * { * if (listitem.Id == listitemDB.Id) * { * flag = true; * break; * } * } * if (flag == false) * conn.Delete(listitemDB); * } * } */ using (var conn = ScheduleDB.GetDbConnection()) { conn.DeleteAll <ListItemDB>(); foreach (ListItem listitem in MainPage.ViewModel1.AllItems) { //System.Diagnostics.Debug.WriteLine("!!!!!!!!!!!!!!!!!!!!" + listitem.Date.ToLocalTime().ToString() + "!!!!!!!!!!!!!!!!!\n"); ListItemDB listItemDB = new ListItemDB(listitem.Id, listitem.ImgPath, listitem.Size, listitem.Title, listitem.Detail, listitem.Date, listitem.Finish); conn.Insert(listItemDB); } } deferral.Complete(); }
public ExistingCourseService() { context = new ScheduleDB(); repository = new ExistinCourseRepository(context); }
/// <summary> /// 在应用程序由最终用户正常启动时进行调用。 /// 将在启动应用程序以打开特定文件等情况下使用。 /// </summary> /// <param name="e">有关启动请求和过程的详细信息。</param> protected async override void OnLaunched(LaunchActivatedEventArgs e) { var composite = ApplicationData.Current.LocalSettings.Values["allItems"] as ApplicationDataCompositeValue; var compositeInfo = ApplicationData.Current.LocalSettings.Values["info"] as ApplicationDataCompositeValue; using (var conn = ScheduleDB.GetDbConnection()) { var listItemDBs = conn.Table <ListItemDB>(); foreach (var listItemDB in listItemDBs) { //System.Diagnostics.Debug.WriteLine("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" + listItemDB.Date); BitmapImage bitmapImage = new BitmapImage(); var picName = listItemDB.ImgPath.Substring(listItemDB.ImgPath.LastIndexOf('\\') + 1); if (picName == "pic1.ico") { bitmapImage = new BitmapImage(new Uri("ms-appx:///Assets\\pic1.ico")); } else { var file = await ApplicationData.Current.LocalFolder.GetFileAsync(picName); IRandomAccessStream fileStream = await file.OpenAsync(FileAccessMode.Read); await bitmapImage.SetSourceAsync(fileStream); } ListItem listItem = new ListItem(listItemDB.Id, bitmapImage, listItemDB.ImgPath, listItemDB.Size, listItemDB.Title, listItemDB.Detail, listItemDB.Date); listItem.Finish = listItemDB.Finish; MainPage.ViewModel1.AllItems.Add(listItem); if (ApplicationData.Current.LocalSettings.Values.ContainsKey("allItems") && (string)composite["seleted"] != "" && listItem.Id == (string)composite["seleted"]) { MainPage.ViewModel1.SelectedItem = listItem; } if (ApplicationData.Current.LocalSettings.Values.ContainsKey("info") && (string)compositeInfo["seleted"] != "" && listItem.Id == (string)compositeInfo["seleted"]) { MainPage.ViewModel1.SelectedItem = listItem; } } } TileService.UpdateTile(); Frame rootFrame = Window.Current.Content as Frame; // 不要在窗口已包含内容时重复应用程序初始化, // 只需确保窗口处于活动状态 if (rootFrame == null) { // 创建要充当导航上下文的框架,并导航到第一页 rootFrame = new Frame(); rootFrame.Navigated += OnNavigated; SystemNavigationManager.GetForCurrentView().BackRequested += OnBackRequested; rootFrame.NavigationFailed += OnNavigationFailed; if (e.PreviousExecutionState == ApplicationExecutionState.Terminated) { //TODO: 从之前挂起的应用程序加载状态 if (ApplicationData.Current.LocalSettings.Values.ContainsKey("NavigationState")) { rootFrame.SetNavigationState((string)ApplicationData.Current.LocalSettings.Values["NavigationState"]); } } // 将框架放在当前窗口中 Window.Current.Content = rootFrame; } if (e.PrelaunchActivated == false) { if (rootFrame.Content == null) { // 当导航堆栈尚未还原时,导航到第一页, // 并通过将所需信息作为导航参数传入来配置 // 参数 rootFrame.Navigate(typeof(MainPage), e.Arguments); } // 确保当前窗口处于活动状态 Window.Current.Activate(); } }
public CourseService() { context = new ScheduleDB(); repository = new CourseRepository(context); }
public GroupRepository(ScheduleDB context) : base(context) { }
public ActionResult AvailSvc(string json, long id, byte entityType) { Availability avail = json != null?JsonConvert.DeserializeObject <Availability>(json) : null; return(Json(ScheduleDB.Availability(id, entityType, avail, GetConfiguration().GetConnectionString(DEFAULT_CONNECTION)))); }
public HourOfLessonService() { context = new ScheduleDB(); repository = new HourOfLessonRepository(context); }
public GroupService() { context = new ScheduleDB(); repository = new GroupRepository(context); }
public ExistinCourseRepository(ScheduleDB context) : base(context) { }
public ActionResult GetAvailSvc() { Availability avail = ScheduleDB.GetAvailability(GetConfiguration().GetConnectionString("DefaultConnection")); return(Json(avail));// new { data= "Tutor data" }); }
public IActionResult RoomInf(long id, int tZOS, int lang = 1) { return(Json(ScheduleDB.Room(id, tZOS, lang, GetConfiguration().GetConnectionString(DEFAULT_CONNECTION)))); }
public ScheduleRepository(ScheduleDB context) { this.context = context; this.dbSet = context.Set <T>(); }
public HourOfLessonRepository(ScheduleDB context) : base(context) { }