public void Deactivate() { try { if (this.CurrentFormId == 0) { var f = OGEForm450.GetCurrentFormByUser(AccountName); CurrentFormId = f != null ? f.Id : 0; } // Set Current Form to Canceled if (this.CurrentFormId > 0) { var form = OGEForm450.Get(this.CurrentFormId); form.FormStatus = Constants.FormStatus.CANCELED; form.Save(); form.RemoveExtensions(); } this.Inactive = true; this.InactiveDate = DateTime.Now; this.EmployeeStatus = Constants.EmployeeStatus.INACTIVE; } catch (Exception ex) { // Couldn't find form, ignore exception SharePointHelper.HandleException(ex, "", "Employee.Deactivate"); } }
public override void MapFromList(ListItem item, bool includeChildren = false) { base.MapFromList(item); this.SharePointList = SharePointHelper.ToStringNullSafe(item["SharePointList"]); this.ViewName = SharePointHelper.ToStringNullSafe(item["ViewName"]); this.RecipientType = SharePointHelper.ToStringNullSafe(item["RecipientType"]); this.RecipientColumn = SharePointHelper.ToStringNullSafe(item["RecipientColumn"]); this.Subject = SharePointHelper.ToStringNullSafe(item["Subject"]); this.Frequency = SharePointHelper.ToStringNullSafe(item["Frequency"]); this.Body = SharePointHelper.ToStringNullSafe(item["Body"]); this.NextRunDate = Convert.ToDateTime(item["NextRunDateTime"]); this.LastRunDate = Convert.ToDateTime(item["LastRunDateTime"]); this.LastRunStatus = SharePointHelper.ToStringNullSafe(item["LastRunStatus"]); this.IncludeCc = Convert.ToBoolean(item["IncludeCC"]); this.Enabled = Convert.ToBoolean(item["Enabled"]); this.Application = SharePointHelper.ToStringNullSafe(item["Application"]); var dict = new Dictionary <string, string>(); dict = Settings.GetAppEmailFieldsDef(dict); if (Title == NotificationTypes.EXTENSION_DECISION || Title == NotificationTypes.EXTENSION_RECEIVED || Title == NotificationTypes.EXTENSION_REQUEST) { dict = ExtensionRequest.GetEmailFieldsDef(dict); } else { dict = OGEForm450.GetEmailFieldsDef(dict); } this.TemplateFields = dict; }
public void Deactivate() { try { // Set Current Form to Canceled if (this.CurrentFormId > 0) { var form = OGEForm450.Get(this.CurrentFormId); form.FormStatus = Constants.FormStatus.CANCELED; form.Save(); } } catch (Exception ex) { // Couldn't find form, ignore exception } // Set Pending Extensions to Canceled var extensions = ExtensionRequest.GetPendingExtensions(this.CurrentFormId); foreach (ExtensionRequest ext in extensions) { ext.Status = Constants.ExtensionStatus.CANCELED; ext.Save(); } this.InactiveDate = DateTime.Now; }
public static void FormCertified(OGEForm450 form) { var emp = Employee.Get(form.Filer); emp.Last450Date = form.DateOfReviewerSignature; emp.ReportingStatus = Constants.ReportingStatus.ANNUAL; emp.Save(); }
public string RunBusinessRules(UserInfo user, ExtensionRequest oldItem) { var form = OGEForm450.Get(this.OGEForm450Id); var filer = UserInfo.GetUser(form.Filer); _pendingEmails = new List <Notifications>(); if (Id == 0 && !(form.FormStatus == Constants.FormStatus.NOT_STARTED || form.FormStatus == Constants.FormStatus.DRAFT || form.FormStatus == Constants.FormStatus.MISSING_INFORMATION)) { return("Cannot make a request for a form that has been submitted or certified or cancelled"); } // ensure 90 day rule if (form.DaysExtended + this.DaysRequested > 90) { return("Cannot make a request for more than 90 days"); } if (oldItem != null && !user.IsReviewer) { return("Unauthorised: Cannot update record, you must be a reviewer to approve or deny an extension."); } if (this.DaysRequested == 0) { return("Must request at least one day"); } if (this.Reason == "") { return("Must provide a reason for extension."); } var data = this.GetEmailData(user); if (oldItem == null) { this.Status = Constants.ExtensionStatus.PENDING; _pendingEmails.Add(EmailHelper.GetEmail(NotificationTemplates.NotificationTypes.EXTENSION_RECEIVED, filer, data)); _pendingEmails.Add(EmailHelper.GetEmail(NotificationTemplates.NotificationTypes.EXTENSION_REQUEST, filer, data)); } else if (user.IsReviewer) { if (oldItem.Status == Constants.ExtensionStatus.PENDING && this.Status != Constants.ExtensionStatus.CANCELED && this.Status != Constants.ExtensionStatus.PENDING) { _pendingEmails.Add(EmailHelper.GetEmail(NotificationTemplates.NotificationTypes.EXTENSION_DECISION, filer, data)); } } // made it to the end, return empty string as success return(""); }
private static UserInfo MapToModel(User u) { var info = new UserInfo(); info.Id = u.Id; info.Upn = u.LoginName; OGEForm450 form = null; form = GetUserForm(u.LoginName); if (form != null) { info.CurrentFormId = form.Id; info.CurrentFormStatus = form.FormStatus; } else { info.CurrentFormId = 0; info.CurrentFormStatus = "Not Available"; } var profile = UserProfileHelper.GetUserProfile(u.LoginName); if (profile != null) { info.DisplayName = profile.IsPropertyAvailable("DisplayName") ? profile.DisplayName : u.LoginName; info.UserProfileUrl = profile.IsPropertyAvailable("UserUrl") ? profile.UserUrl : ""; info.Email = profile.IsPropertyAvailable("Email") ? profile.Email : ""; //info.Manager = (profile.IsPropertyAvailable("UserProfileProperties") && profile.UserProfileProperties.ContainsKey("Manager")) ? profile.UserProfileProperties["Manager"] : string.Empty; info.PhoneNumber = (profile.IsPropertyAvailable("UserProfileProperties") && profile.UserProfileProperties.ContainsKey("WorkPhone")) ? profile.UserProfileProperties["WorkPhone"] : string.Empty; info.Branch = (profile.IsPropertyAvailable("UserProfileProperties") && profile.UserProfileProperties.ContainsKey("Office")) ? profile.UserProfileProperties["Office"] : string.Empty; } try { info.Groups = u.Groups.Select(x => x.Title).ToList(); info.IsReviewer = info.IsInGroup(SharePointHelper.ReviewerGroup); info.IsAdmin = info.IsInGroup(SharePointHelper.AdminGroup); info.IsRestrictedAdmin = info.IsInGroup(SharePointHelper.RestrictedAdmin); } catch (Exception ex) { // ignore } info.InMaintMode = Settings.IN_MAINTENANCE_MODE; return(info); }
public static void FixStatusFromVersionHistory() { var employees = GetAll().Where(x => x.FilerType == ""); var settings = Settings.GetAll().FirstOrDefault(); var forms = OGEForm450.GetAll(); foreach (Employee emp in employees) { // Determine if has a Form 450 var empForms = forms.Where(x => x.Filer.ToLower() == emp.AccountName.ToLower() && x.FormStatus != Constants.FormStatus.CANCELED).ToList(); // If Exists Set FilerType = 450 Filer if (empForms.Count > 0) { emp.FilerType = Constants.FilerType._450_FILER; // get most recent non-canceled form var f = empForms.Where(x => x.FormStatus == Constants.FormStatus.CERTIFIED).OrderByDescending(x => x.DateOfReviewerSignature).FirstOrDefault(); if (f != null) { // If has a certified form Set ReportingStatus to Annual // Set Last File Date emp.ReportingStatus = Constants.ReportingStatus.ANNUAL; emp.Last450Date = f.DateOfReviewerSignature; } else { // Else Set to New Entrant emp.ReportingStatus = Constants.ReportingStatus.NEW_ENTRANT; } } else { // Else Set FilerType = Not Available if (emp.Inactive == false) { emp.FilerType = Constants.FilerType.NOT_ASSIGNED; } } emp.Save(); } }
public static List <Employee> GetUsers(string filter = "") { var list = Employee.GetAll(); var settings = Settings.GetAll().FirstOrDefault(); var forms = OGEForm450.GetAllBy("Year", settings.CurrentFilingYear); foreach (Employee emp in list) { var f = forms.Where(x => x.Filer.ToLower() == emp.AccountName.ToLower() && x.FormStatus != Constants.FormStatus.CANCELED).FirstOrDefault(); emp.GenerateForm = false; emp.CurrentFormId = f != null ? f.Id : 0; emp.CurrentFormStatus = f != null ? f.FormStatus : "Not Available"; } return(list); }
public static void UpdateNotStartedFormsAddProfileData() { var list = OGEForm450.GetAll().Where(x => x.FormStatus == Constants.FormStatus.NOT_STARTED).ToList(); foreach (OGEForm450 form in list) { var emp = Get(form.Filer); GetEmployeeUserProfileInfo(emp); form.Agency = emp.Agency; form.BranchUnitAndAddress = emp.Branch; form.EmailAddress = emp.EmailAddress; form.PositionTitle = emp.Position; form.WorkPhone = emp.WorkPhone; form.Save(); } }
public static OGEForm450 GetUserForm(string loginName) { var form = OGEForm450.GetCurrentFormByUser(loginName); return(form); }
private DateTime GetExtensionDate() { var form = OGEForm450.Get(OGEForm450Id); return(form.DueDate.AddDays(DaysRequested)); }