//// GET: UserProfiles/Details/5 //public ActionResult Details(Guid? id) //{ // if (id == null) // { // return new HttpStatusCodeResult(HttpStatusCode.BadRequest); // } // UserProfile userProfile = db.UserProfiles.Find(id); // if (userProfile == null) // { // return HttpNotFound(); // } // return View(userProfile); //} // GET: UserProfiles/Create public ActionResult Create() { HomeController.UserAuth user = new HomeController.UserAuth(); if (ConfigurationManager.AppSettings["requireGroupMembership"] == "true") { user = HomeController.AuthorizeUser(User.Identity.Name.ToString()); if (!user.authorized && !user.authorizedAdmin) { //return new HttpStatusCodeResult(HttpStatusCode.Unauthorized); return(RedirectToAction("Unauthorized", "Home")); } } UserProfile_Conf UserProfile_Conf = db.UserProfile_Conf.SingleOrDefault(x => x.NTUserName == User.Identity.Name.ToString()); // web.config debug setting ViewBag.debug = HttpContext.IsDebuggingEnabled; ViewBag.agency = ConfigurationManager.AppSettings["agency"]; ViewBag.ori = ConfigurationManager.AppSettings["ori"]; ViewBag.admin = user.authorizedAdmin; if (User.Identity.IsAuthenticated && UserProfile_Conf == null) { return(View()); } else { return(RedirectToAction("Index", "Home")); } }
// GET: Regulation public ActionResult Index() { UserAuth user = new UserAuth(); if (ConfigurationManager.AppSettings["requireGroupMembership"] == "true") { user = AuthorizeUser(User.Identity.Name.ToString()); if (!user.authorized && !user.authorizedAdmin) { //return new HttpStatusCodeResult(HttpStatusCode.Unauthorized); return(RedirectToAction("Unauthorized")); } } // Gotta grab the conf table because that is where the NTUserName can be matched. UserProfile_Conf UserProfile_Conf = db.UserProfile_Conf.SingleOrDefault(x => x.NTUserName == User.Identity.Name.ToString()); if (User.Identity.IsAuthenticated && UserProfile_Conf != null) { UserProfile UserProfile = db.UserProfiles.SingleOrDefault(x => x.ID == UserProfile_Conf.UserProfileID); ViewBag.admin = user.authorizedAdmin; } //UserProfile_Conf uid = db.UserProfile_Conf.SingleOrDefault(x => x.NTUserName == User.Identity.Name.ToString()); ViewBag.UserProfileID = UserProfile_Conf.UserProfileID; // web.config debug setting ViewBag.debug = HttpContext.IsDebuggingEnabled; return(View()); }
public async Task <IHttpActionResult> GetStop() { UserProfile_Conf uid = db.UserProfile_Conf.SingleOrDefault(x => x.NTUserName == User.Identity.Name.ToString()); List <Stop> Stops = await db.Stop.Where(x => x.UserProfileID == uid.UserProfileID).OrderByDescending(x => x.Time).Take(10).ToListAsync(); return(Ok(Stops)); }
public async Task <IHttpActionResult> GetStop(int id) { UserProfile_Conf uid = db.UserProfile_Conf.SingleOrDefault(x => x.NTUserName == User.Identity.Name.ToString()); string stopJson = await db.Stop.Where(x => x.ID == id).Select(x => x.JsonStop).FirstOrDefaultAsync(); return(Ok(stopJson)); }
// GET: Regulation public ActionResult Index() { UserProfile_Conf uid = db.UserProfile_Conf.SingleOrDefault(x => x.NTUserName == User.Identity.Name.ToString()); ViewBag.UserProfileID = uid.UserProfileID; // web.config debug setting ViewBag.debug = HttpContext.IsDebuggingEnabled; return(View()); }
// GET: StopsEdit/Edit/5 // To protect from overposting attacks, please enable the specific properties you want to bind to, for // more details see https://go.microsoft.com/fwlink/?LinkId=317598. //[HttpPost] //[ValidateAntiForgeryToken] public ActionResult Edit(int?stopid, int pid, int pidCount, int submissionId, string submissionEndDate, bool postSubRedact) { HomeController.UserAuth user = new HomeController.UserAuth(); if (ConfigurationManager.AppSettings["requireGroupMembership"] == "true") { user = HomeController.AuthorizeUser(User.Identity.Name.ToString()); if (!user.authorizedAdmin) { return(RedirectToAction("Unauthorized", "Home")); } } UserProfile_Conf uid = dbr.UserProfile_Conf.SingleOrDefault(x => x.NTUserName == User.Identity.Name.ToString()); ViewBag.UserProfileID = uid.UserProfileID; ViewBag.admin = user.authorizedAdmin; // web.config debug setting ViewBag.debug = HttpContext.IsDebuggingEnabled; ViewBag.stopID = stopid; ViewBag.pid = pid; ViewBag.personCount = pidCount; ViewBag.submissionID = submissionId; ViewBag.submissionEndDate = ViewBag.submissionEndDate; if (submissionId == 0) { ViewBag.submissionEdit = 0; } else { ViewBag.submissionEdit = 1; } ViewBag.submissionEndDate = submissionEndDate; ViewBag.expireCacheDays = ConfigurationManager.AppSettings["expireCacheDays"]; ViewBag.reverseGeoURI = ConfigurationManager.AppSettings["reverseGeoURI"]; ViewBag.reverseBeatURI = ConfigurationManager.AppSettings["reverseBeatURI"]; ViewBag.server = System.Environment.MachineName; ViewBag.forceCacheUpdate = ConfigurationManager.AppSettings["forceCacheUpdate"]; ViewBag.allowedBackDateHours = ConfigurationManager.AppSettings["allowedBackDateHours"]; ViewBag.useBeats = ConfigurationManager.AppSettings["useBeats"]; ViewBag.test = ConfigurationManager.AppSettings["test"]; ViewBag.useAdditionalQuestions = ConfigurationManager.AppSettings["useAdditionalQuestions"]; ViewBag.useContractCity = ConfigurationManager.AppSettings["useContractCity"]; ViewBag.useContractEvent = ConfigurationManager.AppSettings["useContractEvent"]; ViewBag.editStop = 1; ViewBag.postSubRedact = postSubRedact; return(View()); }
// GET: Stops public async Task<ActionResult> Index() { UserProfile_Conf uid = db.UserProfile_Conf.SingleOrDefault(x => x.NTUserName == User.Identity.Name.ToString()); ViewBag.UserProfileID = uid.UserProfileID; List<Stop> Stops = await db.Stop.Where(x => x.UserProfileID == uid.UserProfileID).OrderByDescending(x => x.Time).ToListAsync(); foreach(Stop st in Stops) { st.JsonStop = JValue.Parse(st.JsonStop).ToString(Formatting.Indented); } // web.config debug setting ViewBag.debug = HttpContext.IsDebuggingEnabled; return View(Stops); }
//[ValidateAntiForgeryToken] //[AllowAnonymous] public async Task<ActionResult> Create([Bind(Include = "ID,JsonStop,JsonInstrumentation,latitude,longitude,beat,UserProfileID,PersonCount")] Stop stop) { UserProfile_Conf uid = db.UserProfile_Conf.SingleOrDefault(x => x.NTUserName == User.Identity.Name.ToString()); //stop.ID = Guid.NewGuid(); stop.Time = DateTime.Now; stop.Latitude = string.IsNullOrEmpty(stop.Latitude) ? null : stop.Latitude; stop.Longitude = string.IsNullOrEmpty(stop.Longitude) ? null : stop.Longitude; stop.Beat = string.IsNullOrEmpty(stop.Beat) ? null : stop.Beat; stop.UserProfileID = uid.UserProfileID; //Todo: extract info from JsonStop string[] OfficerIDDateTime = getOfficerIDDateTime(stop.JsonStop); //Todo: Check for existing before proceeding. Using only OfficerID & Date/Time per DOJ service validation. Comparing the // whole json payload would potentially introduce duplicate OfficerID & Date/Time combinations. string officerID = OfficerIDDateTime[0]; string stopDate = OfficerIDDateTime[1]; string StopTime = OfficerIDDateTime[2]; bool exist = db_lookup.StopOfficerIDDateTime_JSON_vw .Any(x => x.officerID == officerID && x.stopDate == stopDate && x.StopTime == StopTime); if (!exist) { db.Stop.Add(stop); try { db.SaveChanges(); //return RedirectToAction("Index"); string dojJson = dojTransform(stop); stop.JsonDojStop = dojJson; db.Entry(stop).State = EntityState.Modified; await db.SaveChangesAsync(); return RedirectToAction("Index"); } catch (Exception ex) { return new HttpStatusCodeResult(HttpStatusCode.InternalServerError); } } else { return new HttpStatusCodeResult(HttpStatusCode.Conflict); } }
//// GET: UserProfiles/Details/5 //public ActionResult Details(Guid? id) //{ // if (id == null) // { // return new HttpStatusCodeResult(HttpStatusCode.BadRequest); // } // UserProfile userProfile = db.UserProfiles.Find(id); // if (userProfile == null) // { // return HttpNotFound(); // } // return View(userProfile); //} // GET: UserProfiles/Create public ActionResult Create() { UserProfile_Conf UserProfile_Conf = db.UserProfile_Conf.SingleOrDefault(x => x.NTUserName == User.Identity.Name.ToString()); // web.config debug setting ViewBag.debug = HttpContext.IsDebuggingEnabled; ViewBag.agency = ConfigurationManager.AppSettings["agency"]; ViewBag.ori = ConfigurationManager.AppSettings["ori"]; if (User.Identity.IsAuthenticated && UserProfile_Conf == null) { return(View()); } else { return(RedirectToAction("Index", "Home")); } }
// GET: Stops public ActionResult Index() { HomeController.UserAuth user = new HomeController.UserAuth(); if (ConfigurationManager.AppSettings["requireGroupMembership"] == "true") { user = HomeController.AuthorizeUser(User.Identity.Name.ToString()); ViewBag.admin = user.authorizedAdmin; if (!user.authorized && !user.authorizedAdmin) { //return new HttpStatusCodeResult(HttpStatusCode.Unauthorized); return(RedirectToAction("Unauthorized", "Home")); } uid = db.UserProfile_Conf.SingleOrDefault(x => x.NTUserName == User.Identity.Name.ToString()); } else { // Anonymous user without Authentication can still run this app uid = db.UserProfile_Conf.SingleOrDefault(x => x.NTUserName == "AnonymousUser"); } ViewBag.admin = user.authorizedAdmin; ViewBag.UserProfileID = uid.UserProfileID; ViewBag.test = ConfigurationManager.AppSettings["test"]; List <Stop> Stops = db.Stop.Where(x => x.UserProfileID == uid.UserProfileID).OrderByDescending(x => x.Time).ToList(); foreach (Stop st in Stops) { if (st.JsonStop != null) { st.JsonStop = JValue.Parse(st.JsonStop).ToString(Formatting.Indented); } } // web.config debug setting ViewBag.debug = HttpContext.IsDebuggingEnabled; //return View(Stops); some words here return(View()); }
public ActionResult SubmissionStatusGet(int?sid, DateTime?endDate) { UserAuth user = new UserAuth(); ViewBag.server = System.Environment.MachineName; DataSet dsStop = new DataSet(); user = AuthorizeUser(User.Identity.Name.ToString()); if (!user.authorizedAdmin) { return(RedirectToAction("Unauthorized", "Home")); } UserProfile_Conf uid = db.UserProfile_Conf.SingleOrDefault(x => x.NTUserName == User.Identity.Name.ToString()); ViewBag.UserProfileID = uid.UserProfileID; ViewBag.admin = user.authorizedAdmin; // web.config debug setting ViewBag.debug = HttpContext.IsDebuggingEnabled; Submissions submission = entitiesdb.Submissions.Find(sid); if (endDate == null) { endDate = submission.EndDate; } ViewBag.submissionEndDate = endDate; if (endDate < submission.StartDate || endDate > DateTime.Now) { TempData["CustomError"] = "Invalid Date Range"; return(RedirectToAction("Index", "StopsSubmission", sid)); } else { submission.statusMsgs = entitiesdb.StatusMessage_JSON_vw .Where(x => x.submissionID == sid && x.StopStatus != "success" && x.StopStatus != "postSubRedact") .ToList(); submission.subList = entitiesdb.Submissions .Where(x => x.StartDate == submission.StartDate && x.EndDate == submission.EndDate).ToList(); } bool fixedFlag = false; SQLDBDataAccessorClass sql = new SQLDBDataAccessorClass(); string sqlStr = ""; sqlStr = "Select * from Stops" + " Where SubmissionsID = " + submission.ID + " and Status != '" + "success' " + " and JsonSubmissions is not null " + " and Right(JsonSubmissions, 15) like '%true%'"; dsStop = sql.mds_ExecuteQuery(sqlStr, "StopsTbl"); int rowsCount = dsStop.Tables["StopsTbl"].Rows.Count; if (rowsCount != 0) { fixedFlag = true; } sql = new SQLDBDataAccessorClass(); sqlStr = ""; sqlStr = "SELECT * FROM Stops as S " + "INNER JOIN StopOfficerIDDateTime_JSON_vw as J ON J.ID = S.ID " + " Where CONVERT(datetime, '" + submission.StartDate + "') <= J.stopDate and J.stopDate <= CONVERT(datetime, '" + endDate + "')"; dsStop = sql.mds_ExecuteQuery(sqlStr, "StopOfficeVWTbl"); int stopsCount = dsStop.Tables["StopOfficeVWTbl"].Rows.Count; ViewBag.fixedFlag = fixedFlag; ViewBag.totalStops = stopsCount; return(View(submission)); }
//[ValidateAntiForgeryToken] //[AllowAnonymous] public async Task <ActionResult> Create([Bind(Include = "ID,JsonStop,JsonInstrumentation,latitude,longitude,beat,UserProfileID,PersonCount")] Stop stop) { UserProfile_Conf uid = db.UserProfile_Conf.SingleOrDefault(x => x.NTUserName == User.Identity.Name.ToString()); if (ConfigurationManager.AppSettings["requireGroupMembership"] == "true") { HomeController.UserAuth user = new HomeController.UserAuth(); user = HomeController.AuthorizeUser(User.Identity.Name.ToString()); if (!user.authorized && !user.authorizedAdmin) { //return new HttpStatusCodeResult(HttpStatusCode.Unauthorized); return(RedirectToAction("Unauthorized", "Home")); } } //stop.ID = Guid.NewGuid(); stop.Time = DateTime.Now; stop.Latitude = string.IsNullOrEmpty(stop.Latitude) ? null : stop.Latitude; stop.Longitude = string.IsNullOrEmpty(stop.Longitude) ? null : stop.Longitude; stop.Beat = string.IsNullOrEmpty(stop.Beat) ? null : stop.Beat; stop.UserProfileID = uid.UserProfileID; stop.JsonStop = Regex.Replace(stop.JsonStop, @"\p{Cs}", ""); // remove emojies //Todo: extract info from JsonStop CommonRoutines cr = new CommonRoutines(); string[] OfficerIDDateTime = cr.getOfficerIDDateTime(stop.JsonStop); // Dedupe. Check for existing before proceeding. Using only OfficerID & Date/Time per DOJ service validation. Comparing the // whole json payload would potentially introduce duplicate OfficerID & Date/Time combinations. string officerID = OfficerIDDateTime[0]; string stopDate = OfficerIDDateTime[1]; string StopTime = OfficerIDDateTime[2]; bool exist = db_lookup.StopOfficerIDDateTime_JSON_vw .Any(x => x.officerID == officerID && x.stopDate == stopDate && x.StopTime == StopTime); if (!exist) { db.Stop.Add(stop); try { db.SaveChanges(); //return RedirectToAction("Index"); string dojJson = cr.dojTransform(stop, "I"); stop.JsonDojStop = dojJson; db.Entry(stop).State = EntityState.Modified; await db.SaveChangesAsync(); return(RedirectToAction("Index")); } catch (Exception ex) { return(new HttpStatusCodeResult(HttpStatusCode.InternalServerError)); } } else { return(new HttpStatusCodeResult(HttpStatusCode.Conflict)); } }
public async Task <ActionResult> SubmissionStats(Submissions submission, int?sid, DateTime startDate, DateTime?endDate) { UserAuth user = new UserAuth(); user = AuthorizeUser(User.Identity.Name.ToString()); if (!user.authorizedAdmin) { return(RedirectToAction("Unauthorized", "Home")); } if (ModelState.IsValid) { UserProfile_Conf uid = db.UserProfile_Conf.SingleOrDefault(x => x.NTUserName == User.Identity.Name.ToString()); ViewBag.UserProfileID = uid.UserProfileID; ViewBag.admin = user.authorizedAdmin; // web.config debug setting ViewBag.debug = HttpContext.IsDebuggingEnabled; ViewBag.submissionEndDate = endDate; DOJSubmitController dOJSubmit = new DOJSubmitController(); //Make sure the connection to DOJ url is available DOJSubmitController.connectionStatus connectStat = dOJSubmit.HTTP_Connection(); if (!connectStat.connected) { TempData["CustomError"] = connectStat.error; return(RedirectToAction("Index", "StopsSubmission", sid)); } // If submission record in this date range is In Progress do not allow another submission Submissions submissionInProgress = entitiesdb.Submissions .Where(x => x.StartDate == startDate && x.EndDate == endDate && x.Status == "In Progress") .FirstOrDefault(); if (submissionInProgress != null) { TempData["CustomError"] = "A submission in this date range is already 'In Progress'"; return(RedirectToAction("Index", "StopsSubmission", sid)); } if (sid != 0) { Submissions submissionOld = entitiesdb.Submissions.Find(sid); submission = submissionOld; } submission.StartDate = startDate; if (endDate < submission.StartDate || endDate > DateTime.Now) { TempData["CustomError"] = "Invalid Date Range"; return(RedirectToAction("Index", "StopsSubmission", sid)); } else { //int stopsCount = entitiesdb.StopOfficerIDDateTime_JSON_vw.ToList() // .Where(x => submission.StartDate <= Convert.ToDateTime(x.stopDate) && Convert.ToDateTime(x.stopDate) < submission.EndDate).Count(); //ViewBag.totalToBeSubmitted = stopsCount; bool fixedFlag = false; List <Stop> Stops = db.Stop.Where(x => x.SubmissionsID == submission.ID).ToList(); // Check if any records have been edited foreach (Stop st in Stops) { JObject submissionO = JObject.Parse(st.JsonSubmissions); JObject lastSubmission = (JObject)submissionO["SubmissionInfo"].Last(); int submissionID = (int)lastSubmission["submissionID"]; bool edited = (bool)lastSubmission["edited"]; if (submissionID == submission.ID && edited == true) { fixedFlag = true; break; } } ViewBag.fixedFlag = fixedFlag; // Change the status of the current submission record, with edited Stops, to "resumbit", // and create a new submission record to Resubmit all the fixed records again if (Stops.Count != 0) { submission.Status = "Resubmit"; if (ModelState.IsValid) { entitiesdb.Entry(submission).State = EntityState.Modified; await entitiesdb.SaveChangesAsync(); } Submissions newSubmission = new Submissions(); newSubmission.StartDate = submission.StartDate; submission = newSubmission; } submission.Status = "In Progress"; submission.DateSubmitted = DateTime.Now; submission.EndDate = endDate; var state = await dOJSubmit.GetStops(submission); entitiesdb.Entry(submission).State = state; if (submission.TotalProcessed == submission.TotalSuccess) { submission.Status = "Finished"; } else { submission.Status = "Pending Fixes"; submission.statusMsgs = entitiesdb.StatusMessage_JSON_vw .Where(x => x.submissionID == submission.ID && x.StopStatus != "success") .ToList(); submission.subList = entitiesdb.Submissions.ToList(); } if (ModelState.IsValid) { state = entitiesdb.Entry(submission).State; await entitiesdb.SaveChangesAsync(); ViewBag.submissionID = submission.ID; } } } else { TempData["CustomError"] = "End Date is required."; } return(RedirectToAction("Index", "StopsSubmission", submission.ID)); }
public ActionResult SubmissionStatusGet(int?sid, DateTime?endDate) { UserAuth user = new UserAuth(); ViewBag.server = System.Environment.MachineName; user = AuthorizeUser(User.Identity.Name.ToString()); if (!user.authorizedAdmin) { return(RedirectToAction("Unauthorized", "Home")); } UserProfile_Conf uid = db.UserProfile_Conf.SingleOrDefault(x => x.NTUserName == User.Identity.Name.ToString()); ViewBag.UserProfileID = uid.UserProfileID; ViewBag.admin = user.authorizedAdmin; // web.config debug setting ViewBag.debug = HttpContext.IsDebuggingEnabled; Submissions submission = entitiesdb.Submissions.Find(sid); if (endDate == null) { endDate = submission.EndDate; } ViewBag.submissionEndDate = endDate; if (endDate < submission.StartDate || endDate > DateTime.Now) { TempData["CustomError"] = "Invalid Date Range"; return(RedirectToAction("Index", "StopsSubmission", sid)); } else { submission.statusMsgs = entitiesdb.StatusMessage_JSON_vw .Where(x => x.submissionID == sid && x.StopStatus != "success" && x.StopStatus != "postSubRedact") .ToList(); submission.subList = entitiesdb.Submissions .Where(x => x.StartDate == submission.StartDate && x.EndDate == submission.EndDate).ToList(); } bool fixedFlag = false; List <Stop> Stops = db.Stop.Where(x => x.SubmissionsID == submission.ID && x.Status != "success" && x.JsonSubmissions != null && x.JsonSubmissions.Substring(x.JsonSubmissions.Length - 15).IndexOf("true") != -1).ToList(); if (Stops.Count != 0) { fixedFlag = true; } int stopsCount = entitiesdb.StopOfficerIDDateTime_JSON_vw.ToList() .Join(db.Stop, j => j.ID, s => s.ID, (j, s) => new { StopOfficerIDDateTime_JSON_vw = j, Stop = s }) .Where(x => submission.StartDate <= Convert.ToDateTime(x.StopOfficerIDDateTime_JSON_vw.stopDate) && Convert.ToDateTime(x.StopOfficerIDDateTime_JSON_vw.stopDate) <= endDate).Count(); ViewBag.fixedFlag = fixedFlag; ViewBag.totalStops = stopsCount; return(View(submission)); }
public async Task <ActionResult> SubmissionStats(Submissions submission, int?sid, DateTime startDate, DateTime?endDate) { UserAuth user = new UserAuth(); DataSet dsStop = new DataSet(); user = AuthorizeUser(User.Identity.Name.ToString()); if (!user.authorizedAdmin) { return(RedirectToAction("Unauthorized", "Home")); } if (ModelState.IsValid) { UserProfile_Conf uid = db.UserProfile_Conf.SingleOrDefault(x => x.NTUserName == User.Identity.Name.ToString()); ViewBag.UserProfileID = uid.UserProfileID; ViewBag.admin = user.authorizedAdmin; // web.config debug setting ViewBag.debug = HttpContext.IsDebuggingEnabled; ViewBag.submissionEndDate = endDate; DOJSubmitController dOJSubmit = new DOJSubmitController(); //Make sure the connection to DOJ url is available //DOJSubmitController.connectionStatus connectStat = dOJSubmit.HTTP_Connection(); //if (!connectStat.connected) //{ // TempData["CustomError"] = connectStat.error; // return RedirectToAction("Index", "StopsSubmission", sid); //} bool connected = dOJSubmit.HTTP_Connection2(); if (!connected) { TempData["CustomError"] = "Can not connect to DOJ endpoint\r\n"; return(RedirectToAction("Index", "StopsSubmission", sid)); } // If submission record in this date range is In Progress do not allow another submission Submissions submissionInProgress = entitiesdb.Submissions .Where(x => x.StartDate == startDate && x.EndDate == endDate && x.Status == "In Progress") .FirstOrDefault(); if (submissionInProgress != null) { TempData["CustomError"] = "A submission in this date range is already 'In Progress'"; return(RedirectToAction("Index", "StopsSubmission", sid)); } if (sid != 0) { Submissions submissionOld = entitiesdb.Submissions.Find(sid); if (submissionOld.TotalHTTPErrors == 0 || submissionOld.TotalHTTPErrors == null) { submission = submissionOld; } } submission.StartDate = startDate; if (endDate < submission.StartDate || endDate > DateTime.Now) { TempData["CustomError"] = "Invalid Date Range"; return(RedirectToAction("Index", "StopsSubmission", sid)); } else { bool fixedFlag = false; SQLDBDataAccessorClass sql = new SQLDBDataAccessorClass(); string sqlStr = ""; sqlStr = "Select * from Stops" + " Where SubmissionsID = " + submission.ID + " and JsonSubmissions is not null " + " and Right(JsonSubmissions, 15) like '%true%'"; dsStop = sql.mds_ExecuteQuery(sqlStr, "StopsTbl"); int rowsCount = dsStop.Tables["StopsTbl"].Rows.Count; if (rowsCount != 0) { fixedFlag = true; } ViewBag.fixedFlag = fixedFlag; // Change the status of the current submission record, with edited Stops, to "resumbit", // and create a new submission record to Resubmit all the fixed records again if (rowsCount != 0) { submission.Status = "Resubmit"; if (ModelState.IsValid) { entitiesdb.Entry(submission).State = EntityState.Modified; await entitiesdb.SaveChangesAsync(); } Submissions newSubmission = new Submissions(); newSubmission.StartDate = submission.StartDate; submission = newSubmission; } submission.Status = "In Progress"; submission.DateSubmitted = DateTime.Now; submission.EndDate = endDate; var state = await dOJSubmit.GetStops(submission); entitiesdb.Entry(submission).State = state; if (submission.TotalProcessed == submission.TotalSuccess) { submission.Status = "Finished"; } else { submission.Status = "Pending Fixes"; submission.statusMsgs = entitiesdb.StatusMessage_JSON_vw .Where(x => x.submissionID == submission.ID && x.StopStatus != "success" && x.StopStatus != "postSubRedact") .ToList(); submission.subList = entitiesdb.Submissions.ToList(); } //If ModelState.IsValid is not True this might //cause submission to stay in 'In Progress' status // //if (ModelState.IsValid) //{ //state = entitiesdb.Entry(submission).State; //entitiesdb.Entry(submission).State = EntityState.Modified; entitiesdb.SaveChanges(); ViewBag.submissionID = submission.ID; //} } } else { TempData["CustomError"] = "End Date is required."; } return(RedirectToAction("Index", "StopsSubmission", submission.ID)); }
// GET: StopsEdit public ActionResult Index(StopChangeAudits stopChangeAudit, int stopid, int submissionId, string submissionEndDate) { HomeController.UserAuth user = new HomeController.UserAuth(); if (ConfigurationManager.AppSettings["requireGroupMembership"] == "true") { user = HomeController.AuthorizeUser(User.Identity.Name.ToString()); if (!user.authorizedAdmin) { return(RedirectToAction("Unauthorized", "Home")); } } UserProfile_Conf uid = dbr.UserProfile_Conf.SingleOrDefault(x => x.NTUserName == User.Identity.Name.ToString()); ViewBag.UserProfileID = uid.UserProfileID; ViewBag.admin = user.authorizedAdmin; // web.config debug setting ViewBag.debug = HttpContext.IsDebuggingEnabled; ViewBag.personCount = 0; ViewBag.test = ConfigurationManager.AppSettings["test"]; //If Id is being passed from submission portal if (stopid != 0) { stopChangeAudit.StopID = stopid; } else { ViewBag.submissionID = 0; } ViewBag.submissionID = submissionId; ViewBag.submissionEndDate = submissionEndDate; if (stopChangeAudit.StopID != 0) { ViewBag.stopID = stopChangeAudit.StopID; DateTime fromDate = Convert.ToDateTime("2018-07-01"); Stop stop = dbr.Stop .Where(x => x.ID == stopChangeAudit.StopID && x.Time >= fromDate) .Select(x => x).FirstOrDefault(); if (stop == null) { ModelState.AddModelError(string.Empty, "The Stop ID you entered does not exists or is older than July 1st 2018!"); } else { ViewBag.postSubRedact = stopChangeAudit.postSubRedact; //if (stopChangeAudit.postSubRedact) //{ // stop.Status = "postSubRedact"; // state = dbr.Entry(stop).State; // dbr.SaveChanges(); //} if (stop.Status == "success" && !stopChangeAudit.postSubRedact) { ModelState.AddModelError(string.Empty, "The Stop ID #" + stopChangeAudit.StopID + " has been successfully submitted to DOJ. It cannot be modified."); } else { JObject o = JObject.Parse(stop.JsonStop); JArray personList = (JArray)o["ListPerson_Stopped"]; ViewBag.personCount = personList.Count; } } } return(View(stopChangeAudit)); }
public ActionResult Index() { UserAuth user = new UserAuth(); if (ConfigurationManager.AppSettings["requireGroupMembership"] == "true") { user = AuthorizeUser(User.Identity.Name.ToString()); if (!user.authorized && !user.authorizedAdmin) { //return new HttpStatusCodeResult(HttpStatusCode.Unauthorized); return(RedirectToAction("Unauthorized")); } } // Gotta grab the conf table because that is where the NTUserName can be matched. UserProfile_Conf UserProfile_Conf = db.UserProfile_Conf.SingleOrDefault(x => x.NTUserName == User.Identity.Name.ToString()); if (User.Identity.IsAuthenticated && UserProfile_Conf != null) { UserProfile UserProfile = db.UserProfiles.SingleOrDefault(x => x.ID == UserProfile_Conf.UserProfileID); ViewBag.admin = user.authorizedAdmin; ViewBag.officerYearsExperience = UserProfile.Years; ViewBag.officerAssignment = UserProfile.Assignment; ViewBag.officerAssignmentKey = UserProfile.AssignmentKey; ViewBag.officerAssignmentOther = UserProfile.AssignmentOther; ViewBag.ori = UserProfile.ORI; ViewBag.agency = UserProfile.Agency; ViewBag.UserProfileID = UserProfile.ID; ViewBag.reverseGeoURI = ConfigurationManager.AppSettings["reverseGeoURI"]; ViewBag.reverseBeatURI = ConfigurationManager.AppSettings["reverseBeatURI"]; var referer = Request.Headers["Referer"]; if (referer != null) { string refererStr = referer.ToString(); if (refererStr.IndexOf("UserProfiles") > -1) { ViewBag.userProfileUpdate = "True"; } } // web.config debug setting ViewBag.debug = HttpContext.IsDebuggingEnabled; ViewBag.test = ConfigurationManager.AppSettings["test"]; ViewBag.server = System.Environment.MachineName; ViewBag.forceCacheUpdate = ConfigurationManager.AppSettings["forceCacheUpdate"]; ViewBag.expireCacheDays = ConfigurationManager.AppSettings["expireCacheDays"]; ViewBag.allowedBackDateHours = ConfigurationManager.AppSettings["allowedBackDateHours"]; ViewBag.useBeats = ConfigurationManager.AppSettings["useBeats"]; ViewBag.useAdditionalQuestions = ConfigurationManager.AppSettings["useAdditionalQuestions"]; ViewBag.editStop = 0; ViewBag.submissionEdit = 0; return(View(UserProfile_Conf)); } else { return(RedirectToAction("Create", "UserProfiles")); } }
public ActionResult Index() { // Gotta grab the conf table because that is where the NTUserName can be matched. UserProfile_Conf UserProfile_Conf = db.UserProfile_Conf.SingleOrDefault(x => x.NTUserName == User.Identity.Name.ToString()); //string UserId = User.Identity.Name.ToString().ToUpper(); //if (UserId.IndexOf(@"SDSHERIFF\") > -1) // UserId = UserId.Replace(@"SDSHERIFF\", ""); //// set up domain context //PrincipalContext ctx = new PrincipalContext(ContextType.Domain); //// find the group in question //GroupPrincipal group = GroupPrincipal.FindByIdentity(ctx, "RIPA Admins"); //UserPrincipal usr = new UserPrincipal(ctx, UserID); //ViewBag.admin = usr; //// if found.... //if (group != null) //{ // // iterate over members // //foreach (Principal p in group.GetMembers()) // //{ // // ViewBag.admin = string.Format("{0}: {1}", p.StructuralObjectClass, p.DisplayName); // //} // ViewBag.admin = usr.SamAccountName; // if (usr.IsMemberOf(group)) // { // ViewBag.admin = usr.SamAccountName; // } //} if (User.Identity.IsAuthenticated && UserProfile_Conf != null) { UserProfile UserProfile = db.UserProfiles.SingleOrDefault(x => x.ID == UserProfile_Conf.UserProfileID); ViewBag.officerYearsExperience = UserProfile.Years; ViewBag.officerAssignment = UserProfile.Assignment; ViewBag.officerAssignmentKey = UserProfile.AssignmentKey; ViewBag.officerAssignmentOther = UserProfile.AssignmentOther; ViewBag.ori = UserProfile.ORI; ViewBag.agency = UserProfile.Agency; ViewBag.UserProfileID = UserProfile.ID; ViewBag.reverseGeoURI = ConfigurationManager.AppSettings["reverseGeoURI"]; var referer = Request.Headers["Referer"]; if (referer != null) { string refererStr = referer.ToString(); if (refererStr.IndexOf("UserProfiles") > -1) { ViewBag.userProfileUpdate = "True"; } } // web.config debug setting ViewBag.debug = HttpContext.IsDebuggingEnabled; ViewBag.test = ConfigurationManager.AppSettings["test"]; ViewBag.server = System.Environment.MachineName; ViewBag.forceCacheUpdate = ConfigurationManager.AppSettings["forceCacheUpdate"]; ViewBag.expireCacheDays = ConfigurationManager.AppSettings["expireCacheDays"]; ViewBag.allowedBackDateHours = ConfigurationManager.AppSettings["allowedBackDateHours"]; ViewBag.useBeats = ConfigurationManager.AppSettings["useBeats"]; return(View(UserProfile_Conf)); } else { return(RedirectToAction("Create", "UserProfiles")); } }
// GET: Admin public ActionResult Index(int?sid) { UserAuth user = new UserAuth(); ViewBag.server = System.Environment.MachineName; user = AuthorizeUser(User.Identity.Name.ToString()); if (!user.authorizedAdmin) { return(RedirectToAction("Unauthorized", "Home")); } UserProfile_Conf uid = db.UserProfile_Conf.SingleOrDefault(x => x.NTUserName == User.Identity.Name.ToString()); ViewBag.UserProfileID = uid.UserProfileID; ViewBag.admin = user.authorizedAdmin; // web.config debug setting ViewBag.debug = HttpContext.IsDebuggingEnabled; // Check if there are "Pending Fixes" before allowing them to submit again if (sid != 0) { Submissions submitedRec = entitiesdb.Submissions.Find(sid); //Submissions submitedRec = entitiesdb.Submissions // .Where(x => x.Status == "Pending Fixes") // .OrderByDescending(x => x.ID) // .Select(x => x).FirstOrDefault(); if (submitedRec != null) { return(RedirectToAction("SubmissionStatusGet", "StopsSubmission", new { sid = submitedRec.ID, endDate = submitedRec.EndDate })); } } Submissions dateRec = entitiesdb.Submissions .OrderByDescending(x => x.EndDate) .Select(x => x).FirstOrDefault(); if (dateRec != null) { startDate = Convert.ToDateTime(dateRec.EndDate).AddDays(1); } else { string InitStrtSubDate = ConfigurationManager.AppSettings["InitStrtSubDate"]; startDate = Convert.ToDateTime(InitStrtSubDate); } //List<Stop> Stops = db.Stop // .Where(x => x.Status.Trim() != "success").ToList(); //ExtractJNode eJson; //foreach (Stop st in Stops) //{ // //extract date from JsonStop // JObject JsonStopO; // JsonStopO = JObject.Parse(st.JsonStop); // eJson = new ExtractJNode("date", JsonStopO); // startDate = Convert.ToDateTime(eJson.traverseNode()); // // Only stops after July 1st 2018 should be submitted // //if (startDate >= Convert.ToDateTime("2018-07-01")) // if (startDate >= Convert.ToDateTime("2018-04-17")) // { // break; // } //} Submissions submission = new Submissions(); if (startDate.ToString() == "1/1/0001 12:00:00 AM") { ModelState.AddModelError(string.Empty, "There are no records to submit"); } else { submission.StartDate = startDate; ViewBag.StartDate = startDate.ToString(); if (TempData["CustomError"] != null) { ModelState.AddModelError(string.Empty, TempData["CustomError"].ToString()); } } submission.subList = entitiesdb.Submissions .OrderByDescending(x => x.StartDate) .ThenByDescending(y => y.DateSubmitted).ToList(); return(View(submission)); }
public ActionResult SubmissionStatusGet(int?sid, DateTime?endDate) { UserAuth user = new UserAuth(); user = AuthorizeUser(User.Identity.Name.ToString()); if (!user.authorizedAdmin) { return(RedirectToAction("Unauthorized", "Home")); } UserProfile_Conf uid = db.UserProfile_Conf.SingleOrDefault(x => x.NTUserName == User.Identity.Name.ToString()); ViewBag.UserProfileID = uid.UserProfileID; ViewBag.admin = user.authorizedAdmin; // web.config debug setting ViewBag.debug = HttpContext.IsDebuggingEnabled; Submissions submission = entitiesdb.Submissions.Find(sid); if (endDate == null) { endDate = submission.EndDate; } ViewBag.submissionEndDate = endDate; if (endDate < submission.StartDate || endDate > DateTime.Now) { TempData["CustomError"] = "Invalid Date Range"; return(RedirectToAction("Index", "StopsSubmission", sid)); } else { submission.statusMsgs = entitiesdb.StatusMessage_JSON_vw .Where(x => x.submissionID == sid && x.StopStatus != "success") .ToList(); submission.subList = entitiesdb.Submissions .Where(x => x.StartDate == submission.StartDate && x.EndDate == submission.EndDate).ToList(); } bool fixedFlag = false; List <Stop> Stops = db.Stop.Where(x => x.SubmissionsID == submission.ID).ToList(); foreach (Stop st in Stops) { JObject submissionO = JObject.Parse(st.JsonSubmissions); JObject lastSubmission = (JObject)submissionO["SubmissionInfo"].Last(); int submissionID = (int)lastSubmission["submissionID"]; bool edited = (bool)lastSubmission["edited"]; if (submissionID == submission.ID && edited == true) { fixedFlag = true; break; } } //int stopsCount = entitiesdb.StopOfficerIDDateTime_JSON_vw.ToList() // .Where(x => submission.StartDate <= Convert.ToDateTime(x.stopDate) && Convert.ToDateTime(x.stopDate) <= endDate).Count(); int stopsCount = entitiesdb.StopOfficerIDDateTime_JSON_vw.ToList() .Join(db.Stop, j => j.ID, s => s.ID, (j, s) => new { StopOfficerIDDateTime_JSON_vw = j, Stop = s }) .Where(x => submission.StartDate <= Convert.ToDateTime(x.StopOfficerIDDateTime_JSON_vw.stopDate) && Convert.ToDateTime(x.StopOfficerIDDateTime_JSON_vw.stopDate) <= endDate).Count(); ViewBag.fixedFlag = fixedFlag; ViewBag.totalStops = stopsCount; return(View(submission)); }