public static IQueryable <RecordModel> GetRecords(CheckInContext context) { AutoConfirm(context); var records = context.UserCheckInInfo.Join(context.UserInfo, x => x.UserID, x => x.UserID, (x, y) => new { x = x, y = y }).Join(context.DepartmentInfo, x => x.y.DepartmentID, x => x.DepartmentID, (x, y) => (new RecordModel { CheckInID = x.x.CheckInID, EmployeeID = x.y.EmployeeID, Name = x.y.Name, CheckInTime = x.x.CheckInTime, CheckOutTime = x.x.CheckOutTime, OriCheckInTime = x.x.OriCheckInTime, OriCheckOutTime = x.x.OriCheckOutTime, Reason1 = x.x.Reason1, Reason2 = x.x.Reason2, HasCheckOut = x.x.HasCheckOut, DepartmentID = x.y.DepartmentID, DepartmentName = y.DepartmentName, IsNormal = x.x.HasConfirmed })); return(records); }
private static void AutoConfirm(CheckInContext context) { var records = context.UserCheckInInfo.Where(x => x.HasConfirmed == false); foreach (var record in records) { if (record.HasCheckOut == true && record.CheckInTime == record.OriCheckInTime && record.CheckOutTime == record.OriCheckOutTime && record.CheckOutTime - record.CheckInTime < new TimeSpan(12, 0, 0) && record.CheckOutTime - record.CheckInTime > new TimeSpan(8, 0, 0)) { record.HasConfirmed = true; } } context.SaveChanges(); }
public ActionResult Update(CheckInUpdateModel model) { try { using (var dataContext = new HuntingEntities()) { int languageId = (int)Session[LocalizationAttribute.SESSION_LANGUAGE_ID]; var language = LanguageContext.GetLanguage(languageId); var user = AclUserContext.GetDetail(dataContext, User.Identity.Name); if (user == null) { ContextUtils.CreateActionStateCookie(Response, ActionTypeEnum.Warning, GlobalRes.ERROR_NOT_ALLOWED); return(RedirectToAction("Index", "Home")); } var checkIn = CheckInContext.GetDetail(dataContext, model.Id); if (checkIn == null) { ContextUtils.CreateActionStateCookie(Response, ActionTypeEnum.Warning, GlobalRes.ERROR_NOT_FOUND); return(RedirectToAction("Index", "Home")); } if (user.CanUpdateTerritory(checkIn.MapItem.Territory) == false) { ContextUtils.CreateActionStateCookie(Response, ActionTypeEnum.Warning, GlobalRes.ERROR_NOT_ALLOWED); return(RedirectToAction("Index", "CheckIn", new { id = checkIn.MapItemId })); } CheckInContext.Validate(dataContext, model, ModelState); if (ModelState.IsValid) { var newItemId = CheckInContext.Update(dataContext, checkIn, model, user, language); if (newItemId.HasValue) { ContextUtils.CreateActionStateCookie(Response, ActionTypeEnum.Success, CheckInRes.SUCCESS_UPDATE); return(RedirectToAction("Index", "CheckIn", new { id = model.MapItemId })); } else { ContextUtils.CreateActionStateCookie(Response, ActionTypeEnum.Warning, CheckInRes.ERROR_UPDATE); } } model.FillCodeLists(dataContext, checkIn.MapItem); return(View(model)); } } catch (Exception exception) { logger.Error(exception, "CheckInController"); ContextUtils.CreateActionStateCookie(Response, ActionTypeEnum.Danger, GlobalRes.ERROR_EXCEPTION); return(RedirectToAction("Index", "Home")); } }
public IHttpActionResult CheckIn(CreateCheckInModel model) { try { using (var dataContext = new HuntingEntities()) { var session = GetSession(); if (session == null) { return(Content(HttpStatusCode.Unauthorized, SESSION_INVALID_MESSAGE)); } var userSession = AclUserContext.GetUserSession(dataContext, session); if (userSession == null) { return(Content(HttpStatusCode.Unauthorized, SESSION_INVALID_MESSAGE)); } var mapItem = MapItemContext.GetDetail(dataContext, model.MapItemId); if (mapItem == null) { return(Content(HttpStatusCode.NotFound, NOT_FOUND_MESSAGE)); } if (userSession.AclUser.CanViewTerritory(mapItem.Territory) == false) { return(Content(HttpStatusCode.Forbidden, FORBIDDEN_MESSAGE)); } Questionnaire questionnaire = null; if (model.QuestionnaireId.HasValue) { questionnaire = QuestionnaireContext.GetDetail(dataContext, model.QuestionnaireId.Value); } if (model.IsValid(dataContext, questionnaire) == false) { return(Content(HttpStatusCode.BadRequest, BAD_REQUEST_MESSAGE)); } var updateModel = new CheckInUpdateModel(model, questionnaire); var pointId = CheckInContext.Update(dataContext, null, updateModel, userSession.AclUser, null); if (pointId == null) { return(Content(HttpStatusCode.InternalServerError, FAILED_MESSAGE)); } return(Ok(pointId.Value.ToString())); } } catch (Exception exception) { logger.Error(exception, "MobileController"); return(InternalServerError()); } }
// GET: CheckIn/id public ActionResult Index(int id, CheckInFilter filter, int?page) { try { using (var dataContext = new HuntingEntities()) { int languageId = (int)Session[LocalizationAttribute.SESSION_LANGUAGE_ID]; var language = LanguageContext.GetLanguage(languageId); var user = AclUserContext.GetDetail(dataContext, User.Identity.Name); if (user == null) { ContextUtils.CreateActionStateCookie(Response, ActionTypeEnum.Warning, GlobalRes.ERROR_NOT_ALLOWED); return(RedirectToAction("Index", "Home")); } var mapItem = MapItemContext.GetDetail(dataContext, id); if (mapItem == null) { ContextUtils.CreateActionStateCookie(Response, ActionTypeEnum.Warning, GlobalRes.ERROR_NOT_FOUND); return(RedirectToAction("Index", "Home")); } if (user.CanViewTerritory(mapItem.Territory) == false) { ContextUtils.CreateActionStateCookie(Response, ActionTypeEnum.Warning, GlobalRes.ERROR_NOT_ALLOWED); return(RedirectToAction("Index", "Home")); } filter.PrepareFilter(); filter.MapItemId = mapItem.Id; int pageIndex = page ?? 0; var itemList = CheckInContext.GetList(dataContext, filter, pageIndex); var itemListModel = new CheckInListModel(itemList, pageIndex, language); var model = new CheckInPageModel(itemListModel, filter, mapItem); model.CanUpdate = user.CanUpdateTerritory(mapItem.Territory); return(View(model)); } } catch (Exception exception) { logger.Error(exception, "CheckInController"); ContextUtils.CreateActionStateCookie(Response, ActionTypeEnum.Danger, GlobalRes.ERROR_EXCEPTION); return(RedirectToAction("Index", "Home")); } }
public ActionResult Delete(int id) { try { using (var dataContext = new HuntingEntities()) { var user = AclUserContext.GetDetail(dataContext, User.Identity.Name); if (user == null) { ContextUtils.CreateActionStateCookie(Response, ActionTypeEnum.Warning, GlobalRes.ERROR_NOT_ALLOWED); return(RedirectToAction("Index", "Home")); } var checkIn = CheckInContext.GetDetail(dataContext, id); if (checkIn == null) { ContextUtils.CreateActionStateCookie(Response, ActionTypeEnum.Warning, GlobalRes.ERROR_NOT_FOUND); return(RedirectToAction("Index", "Home")); } if (user.CanUpdateTerritory(checkIn.MapItem.Territory) == false) { ContextUtils.CreateActionStateCookie(Response, ActionTypeEnum.Warning, GlobalRes.ERROR_NOT_ALLOWED); return(RedirectToAction("Index", "CheckIn", new { id = checkIn.MapItemId })); } var isSuccess = CheckInContext.Delete(dataContext, checkIn, user); if (isSuccess) { ContextUtils.CreateActionStateCookie(Response, ActionTypeEnum.Success, CheckInRes.SUCCESS_DELETE); } else { ContextUtils.CreateActionStateCookie(Response, ActionTypeEnum.Warning, CheckInRes.ERROR_DELETE); } return(RedirectToAction("Index", "CheckIn", new { id = checkIn.MapItemId })); } } catch (Exception exception) { logger.Error(exception, "CheckInController"); ContextUtils.CreateActionStateCookie(Response, ActionTypeEnum.Danger, GlobalRes.ERROR_EXCEPTION); return(RedirectToAction("Index", "Home")); } }
private async Task RunAsync(CancellationToken cancellationToken) { CheckInContext db = new CheckInContext(); while (!cancellationToken.IsCancellationRequested) { Trace.TraceInformation("Working"); DbSqlQuery <UserCheckIn> query = db.UserCheckIns.SqlQuery("SELECT * FROM dbo.UserCheckIns WHERE returnTime <= @p0", DateTime.UtcNow); List <UserCheckIn> expiredCheckIns = query.ToList(); foreach (UserCheckIn checkIn in expiredCheckIns) { sendMissingEmail(checkIn); db.UserCheckIns.Remove(checkIn); db.SaveChanges(); } await Task.Delay(checkEvery * 1000); } }
// GET: CheckIn/Detail/id public ActionResult Detail(int id) { try { using (var dataContext = new HuntingEntities()) { int languageId = (int)Session[LocalizationAttribute.SESSION_LANGUAGE_ID]; var language = LanguageContext.GetLanguage(languageId); var user = AclUserContext.GetDetail(dataContext, User.Identity.Name); if (user == null) { ContextUtils.CreateActionStateCookie(Response, ActionTypeEnum.Warning, GlobalRes.ERROR_NOT_ALLOWED); return(RedirectToAction("Index", "Home")); } var checkIn = CheckInContext.GetDetail(dataContext, id); if (checkIn == null) { ContextUtils.CreateActionStateCookie(Response, ActionTypeEnum.Warning, GlobalRes.ERROR_NOT_FOUND); return(RedirectToAction("Index", "Home")); } if (user.CanViewTerritory(checkIn.MapItem.Territory) == false) { ContextUtils.CreateActionStateCookie(Response, ActionTypeEnum.Warning, GlobalRes.ERROR_NOT_ALLOWED); return(RedirectToAction("Index", "Home")); } var model = new CheckInDetailModel(checkIn, language); model.CanUpdate = user.CanUpdateTerritory(checkIn.MapItem.Territory); return(View(model)); } } catch (Exception exception) { logger.Error(exception, "CheckInController"); ContextUtils.CreateActionStateCookie(Response, ActionTypeEnum.Danger, GlobalRes.ERROR_EXCEPTION); return(RedirectToAction("Index", "Home")); } }
public static IQueryable <RecordModel> GetAbnormalRecords(CheckInContext context) { AutoConfirm(context); var records = context.UserCheckInInfo.Where(x => x.HasConfirmed == false).Join(context.UserInfo, x => x.UserID, x => x.UserID, (x, y) => new { x = x, y = y }).Join(context.DepartmentInfo, x => x.y.DepartmentID, x => x.DepartmentID, (x, y) => (new RecordModel { CheckInID = x.x.CheckInID, EmployeeID = x.y.EmployeeID, Name = x.y.Name, CheckInTime = x.x.CheckInTime, CheckOutTime = x.x.CheckOutTime, OriCheckInTime = x.x.OriCheckInTime, OriCheckOutTime = x.x.OriCheckOutTime, Reason1 = x.x.Reason1, Reason2 = x.x.Reason2, HasCheckOut = x.x.HasCheckOut, DepartmentName = y.DepartmentName })).Where(x => (x.HasCheckOut == false && x.CheckInTime.Date != DateTime.Now.Date) || x.CheckInTime != x.OriCheckInTime || x.CheckOutTime != x.OriCheckOutTime || (x.HasCheckOut && (x.CheckOutTime - x.CheckInTime > new TimeSpan(12, 0, 0) || x.CheckOutTime - x.CheckInTime < new TimeSpan(8, 0, 0)))).OrderBy(x => x.CheckInID); return(records); }
public HomeController(CheckInContext context) : base(context) { }
public RecordController(CheckInContext context) : base(context) { }
public LocationController(CheckInContext context) : base(context) { }
public AppointmentRepository(CheckInContext context) : base(context) { this.context = context; appointments = context.Set <Appointment> (); }
public TelephoneController(CheckInContext context) { this.context = context; }
public ControllerWithAuthorize(CheckInContext context) { this.context = context; }
public NoticeController(CheckInContext context) : base(context) { }
public DepartmentController(CheckInContext context) { this.context = context; }
public UsersController(CheckInContext context) : base(context) { }
public NoticeController(CheckInContext context) { this.context = context; }
public UserController(CheckInContext context) { this.context = context; }
public LocationController(CheckInContext context) { this.context = context; }
public ReportController(CheckInContext context) { this.context = context; }
public EFRepository(CheckInContext context) { this.context = context; entities = context.Set <T> (); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory, CheckInContext dbContext) { loggerFactory.AddConsole(Configuration.GetSection("Logging")); loggerFactory.AddDebug(); if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } else { app.UseStatusCodePages(); } app.UseCors(builder => builder.AllowAnyOrigin().AllowAnyMethod().AllowAnyHeader()); app.UseMvc(); DbInitializer.Initialize(dbContext); }
public AbnormalRecordController(CheckInContext context) : base(context) { }