private void CreateFormForEmployee(Employee emp, Settings settings) { try { Employee.GetEmployeeUserProfileInfo(emp); if (emp != null && !string.IsNullOrEmpty(emp.AccountName)) { var previousForm = OGEForm450.GetPreviousFormByUser(emp.AccountName, settings); OGEForm450 form; if (previousForm == null) { form = OGEForm450.Create(emp); } else { form = OGEForm450.Create(emp, previousForm, settings); } form.ProcessEmails(); } } catch (Exception ex) { HandleException(ex); } }
public void GenerateFormsByDivision(string div) { var list = Employee.GetAll().Where(x => x.FilerType == Constants.FilerType._450_FILER && (x.Division.ToLower() == div.ToLower() || x.Division.ToLower().Contains(div.ToLower() + ",") || x.Division.ToLower().Contains(", " + div.ToLower()))).ToList(); foreach (Employee emp in list) { try { var form = OGEForm450.GetCurrentFormByUser(emp.AccountName); if (form == null) { if (emp.ReportingStatus != Constants.ReportingStatus.NEW_ENTRANT) { emp.ReportingStatus = Constants.ReportingStatus.NEW_ENTRANT; emp.Save(); } Employee.GetEmployeeUserProfileInfo(emp); form = OGEForm450.Create(emp); form.ProcessEmails(); } } catch (Exception ex) { HandleException(ex); } } }
public IHttpActionResult Get(int id) { try { var identity = HttpContext.Current.User.Identity as ClaimsIdentity; OGE450User = UserInfo.GetUser(identity); var form = OGEForm450.Get(id); if (form != null) { // Return unauthorized if user is not admin or reviewer and trying to access someone elses filing if (!OGE450User.IsAdmin && !OGE450User.IsReviewer && form.Filer != OGE450User.Upn) { return(Unauthorized()); } SetReportableInformation(form); return(Json(form, CamelCase)); } else { return(BadRequest("Form not found.")); } } catch (Exception ex) { return(HandleException(ex)); } }
public IHttpActionResult Get(string a) { var identity = HttpContext.Current.User.Identity as ClaimsIdentity; OGE450User = UserInfo.GetUser(identity); List <OGEForm450> list; try { switch (a) { case "myforms": list = GetMyForms(OGE450User); break; case "certifyblank": if (OGE450User.IsAdmin || OGE450User.IsReviewer) { list = OGEForm450.CertifyBlankForms(OGE450User); break; } else { return(Unauthorized()); } case "certifyunchanged": if (OGE450User.IsAdmin || OGE450User.IsReviewer) { list = OGEForm450.CertifyUnchangedForms(OGE450User); break; } else { return(Unauthorized()); } case "reviewer": if (OGE450User.IsAdmin || OGE450User.IsReviewer) { list = GetReviewerForms(OGE450User); break; } else { return(Unauthorized()); } default: return(BadRequest("No such action.")); } return(Json(list, CamelCase)); } catch (Exception ex) { return(HandleException(ex)); } }
private List <OGEForm450> GetReviewerForms(UserInfo user) { List <OGEForm450> list; list = OGEForm450.GetAllReviewable(); return(list); }
private OGEForm450 ClearEmptyReportableInformation(OGEForm450 form) { if (form.ReportableInformationList != null) { form.ReportableInformationList.RemoveAll(x => x.Id == 0 && x.IsEmpty()); } return(form); }
private List <Timeline> GetTimeline() { var timeline = new List <Timeline>(); var forms = OGEForm450.GetAllByUser("Filer", AppUser.Id); foreach (OGEForm450 form in forms) { timeline.Add(new Timeline() { Type = "OGEForm450", Title = "OGE Form 450 Assigned", Date = form.Created, Id = form.Id }); if (form.DateReceivedByAgency != null) { timeline.Add(new Timeline() { Type = "OGEForm450", Title = "OGE Form 450 Submitted", Date = form.DateReceivedByAgency, Id = form.Id }); } if (form.DateOfReviewerSignature != null) { timeline.Add(new Timeline() { Type = "OGEForm450", Title = "OGE Form 450 Certified", Date = form.DateOfReviewerSignature, Id = form.Id }); } } var trainings = Data.SharePoint.Models.Training.GetAllByUser("Employee", AppUser.Id).OrderByDescending(x => x.DateAndTime).ToList(); foreach (Data.SharePoint.Models.Training t in trainings) { timeline.Add(new Timeline() { Type = "Training", Title = "Annual Ethics Training Completed", Date = t.DateAndTime, Id = t.Id }); } var events = GetMyEvents(AppUser); foreach (Data.SharePoint.Models.EventRequest e in events) { timeline.Add(new Timeline() { Type = "Event", Title = e.EventName, Date = e.EventStartDate, Id = e.Id }); } timeline = timeline.OrderByDescending(x => x.Date).ToList(); return(timeline); }
private static void GenerateEmailsForOGEForm450(NotificationTemplates template) { var items = OGEForm450.GetAllByView(template.ViewName); foreach (OGEForm450 item in items) { var user = UserInfo.GetUser(item.Filer); var email = GetEmail(template, user, item.GetEmailData(user)); EmailHelper.AddEmail(email); } }
private void SetReportableInformation(OGEForm450 form) { var count = form.ReportableInformationList.Count(x => x.InfoType == InfoType.AssetsAndIncome); for (int i = count; i < MIN_ASSETS; i++) { form.ReportableInformationList.Add(new ReportableInformation() { InfoType = InfoType.AssetsAndIncome, Name = "", NoLongerHeld = false }); } count = form.ReportableInformationList.Count(x => x.InfoType == InfoType.Liabilities); for (int i = count; i < MIN_LIABILITIES; i++) { form.ReportableInformationList.Add(new ReportableInformation() { InfoType = InfoType.Liabilities, Name = "", Description = "" }); } count = form.ReportableInformationList.Count(x => x.InfoType == InfoType.OutsidePositions); for (int i = count; i < MIN_POSITIONS; i++) { form.ReportableInformationList.Add(new ReportableInformation() { InfoType = InfoType.OutsidePositions, Name = "", Description = "", AdditionalInfo = "", NoLongerHeld = false }); } count = form.ReportableInformationList.Count(x => x.InfoType == InfoType.AgreementsOrArrangements); for (int i = count; i < MIN_AGREEMENTS; i++) { form.ReportableInformationList.Add(new ReportableInformation() { InfoType = InfoType.AgreementsOrArrangements, Name = "", AdditionalInfo = "" }); } count = form.ReportableInformationList.Count(x => x.InfoType == InfoType.GiftsOrTravelReimbursements); for (int i = count; i < MIN_GIFTS; i++) { form.ReportableInformationList.Add(new ReportableInformation() { InfoType = InfoType.GiftsOrTravelReimbursements, Name = "", AdditionalInfo = "" }); } }
private void StartAnnualFiling() { var settings = Settings.GetAll().FirstOrDefault(); var expiredForms = OGEForm450.GetAllBy("Year", settings.CurrentFilingYear); expiredForms = expiredForms.Where(x => x.FormStatus != Constants.FormStatus.CERTIFIED && x.FormStatus != Constants.FormStatus.CANCELED).ToList(); // Any incomplete filing for settings.currentFilingYear filing year will be marked as 'expired' foreach (OGEForm450 form in expiredForms) { form.FormStatus = form.FormStatus + " - " + Constants.FormStatus.EXPIRED; form.Save(); } // The filing year will move to settings.currentFilingYear + 1 settings.CurrentFilingYear += 1; settings.AnnualDueDate = settings.AnnualDueDate.AddYears(1); settings.Save(); // All employees with a filer type of '450 Filer' who are not 'On Leave' or 'On Detail' will be assigned a new 'Annual' OGE Form 450 // New forms will be a copy of the previous filing year's form if applicable var emps = Employee.GetAllBy("FilerType", "450 Filer"); emps = emps.Where(x => x.EmployeeStatus != Constants.EmployeeStatus.ON_DETAIL && x.EmployeeStatus != Constants.EmployeeStatus.ON_LEAVE && x.Inactive == false).ToList(); foreach (Employee emp in emps) { if (emp.ReportingStatus != Constants.ReportingStatus.ANNUAL) { emp.ReportingStatus = Constants.ReportingStatus.ANNUAL; emp.Save(); } CreateFormForEmployee(emp, settings); } var email = new Notifications(); email.Title = "Annual Filing Complete"; email.Subject = "OGE Form 450: Annual Filing Initialization - COMPLETE"; email.Body = "The OGE Form 450 Annual Filing Initiation process has completed. Access to the application has been restored."; email.Recipient = settings.CcEmail; email.Status = "Pending"; email.Application = "OGE450"; email.Save(); Settings.IN_MAINTENANCE_MODE = false; }
public IHttpActionResult Update(Employee item) { try { var identity = HttpContext.Current.User.Identity as ClaimsIdentity; OGE450User = UserInfo.GetUser(identity); if (OGE450User.IsAdmin) { if (item.Inactive || item.EmployeeStatus == Constants.EmployeeStatus.INACTIVE) { item.Deactivate(); } var oldItem = Employee.Get(item.Id); oldItem.FilerType = item.FilerType; oldItem.AppointmentDate = item.AppointmentDate; oldItem.ReportingStatus = item.ReportingStatus; oldItem.GenerateForm = item.GenerateForm; oldItem.EmployeeStatus = item.EmployeeStatus; oldItem.Inactive = item.Inactive || item.EmployeeStatus == Constants.EmployeeStatus.INACTIVE; oldItem.InactiveDate = item.InactiveDate; var emp = oldItem.Save(); if (oldItem.GenerateForm && !oldItem.Inactive) { var form = OGEForm450.Create(item); form.ProcessEmails(); } return(Json(emp, CamelCase)); } else { return(Unauthorized()); } } catch (Exception ex) { return(HandleException(ex)); } }
public IHttpActionResult Get() { var identity = HttpContext.Current.User.Identity as ClaimsIdentity; OGE450User = UserInfo.GetUser(identity); List <OGEForm450> list; if (OGE450User.IsAdmin || OGE450User.IsReviewer) { list = OGEForm450.GetAll().OrderByDescending(x => x.Year).ThenBy(x => x.FormStatus).ToList(); } else { list = GetMyForms(OGE450User); } return(Json(list, CamelCase)); }
public IHttpActionResult Update(ExtensionRequest item) { var oldItem = ExtensionRequest.Get(item.Id); var identity = HttpContext.Current.User.Identity as ClaimsIdentity; OGE450User = UserInfo.GetUser(identity); try { // Can only access extensions if is a reviewer or admin or if it is your extension request if (OGE450User.IsReviewer || OGE450User.IsAdmin || OGE450User.CurrentFormId == item.OGEForm450Id) { var result = item.RunBusinessRules(OGE450User, oldItem); if (result == "") { var ext = item.Save(); if (item.Status == "Approved") { var form = OGEForm450.Get(item.OGEForm450Id); form.Extend(item); } item.ProcessEmails(); return(Json(ext, CamelCase)); } else { throw new Exception(result); } } else { return(Unauthorized()); } } catch (Exception ex) { return(HandleException(ex)); } }
private IHttpActionResult GetOGE450ChartData() { var data = new OGE450ChartData(); data.Labels = new List <string>(new string[] { "Not-Started", "Draft", "Missing Information", "Overdue", "Submitted", "Certified" }); var settings = Settings.GetAll().FirstOrDefault(); var forms = OGEForm450.GetAllBy("Year", settings.CurrentFilingYear); var notStarted = forms.Where(x => x.FormStatus == Constants.FormStatus.NOT_STARTED).Count(); var draft = forms.Where(x => x.FormStatus == Constants.FormStatus.DRAFT).Count(); var missingInfo = forms.Where(x => x.FormStatus == Constants.FormStatus.MISSING_INFORMATION).Count(); var overdue = forms.Where(x => x.IsOverdue == true).Count(); var submitted = forms.Where(x => x.FormStatus == Constants.FormStatus.SUBMITTED || x.FormStatus == Constants.FormStatus.RE_SUBMITTED).Count(); var certified = forms.Where(x => x.FormStatus == Constants.FormStatus.CERTIFIED).Count(); data.Data = new List <int>(new int[] { notStarted, draft, missingInfo, overdue, submitted, certified }); return(Json(data, CamelCase)); }
private List <OGEForm450> GetMyForms(UserInfo user) { var list = OGEForm450.GetAllByUser("Filer", user.Id).OrderByDescending(x => x.DueDate).ToList(); return(list); }
public IHttpActionResult Update(OGEForm450 item) { try { var identity = HttpContext.Current.User.Identity as ClaimsIdentity; OGE450User = UserInfo.GetUser(identity); // Return unauthorized if user is not admin or reviewer and trying to update someone elses filing if (!OGE450User.IsAdmin && !OGE450User.IsReviewer && item.Filer != OGE450User.Upn) { return(Unauthorized()); } item = ClearEmptyReportableInformation(item); var oldItem = OGEForm450.Get(item.Id); var filer = UserInfo.GetUser(item.Filer); item.AppUser = OGE450User.DisplayName; item.CorrelationId = Guid.NewGuid().ToString(); if (item.ReportableInformationList != null) { item.ReportableInformationList.ForEach(x => x.CorrelationId = item.CorrelationId); item.ReportableInformationList.ForEach(x => x.AppUser = item.AppUser); } item.RunBusinessRules(OGE450User, filer, oldItem); if (item.ReportableInformationList != null) { item.SaveReportableInformation(); } var form = item.Save(); if (form.FormStatus == Constants.FormStatus.CERTIFIED) { Employee.FormCertified(form); var extensions = ExtensionRequest.GetPendingExtensions(form.Id); foreach (ExtensionRequest ext in extensions) { // If there are any pending requests for this form, cancel them. ext.Status = Constants.ExtensionStatus.CANCELED; ext.Save(); } } // wait until after Save to process emails, if an error occurs it will be caught and the emails will not get processed. item.ProcessEmails(); SetReportableInformation(form); return(Json(form, CamelCase)); } catch (Exception ex) { return(HandleException(ex)); } }