public ActionResult AddFormResults() { string paramFormId = Request["formId"] as string; mLogger.Debug("* * * ResultsController AddFormResults formId: {0}", paramFormId); Session["formId"] = paramFormId; int formId = Convert.ToInt32(paramFormId); def_FormResults frmRes = new def_FormResults() { formId = formId, formStatus = 0, sessionStatus = 0, dateUpdated = DateTime.Today }; int frmRslt = formsRepo.AddFormResult(frmRes); frmRes = formsRepo.GetFormResultById(frmRslt); def_Forms frm = formsRepo.GetFormById(formId); List <def_Parts> parts = formsRepo.GetFormParts(frm); // Setup session variables SessionForm sf = SessionHelper.SessionForm; sf.formId = frm.formId; sf.formResultId = frmRslt; return(RedirectToAction("Parts", "Results", null)); }
protected DataTable ParseFromSession(SessionForm selectedSession, StringCollection itemTypes, StringCollection genotypeStatuses, CIStringCollection items, CIStringCollection experiments) { DataTable results; //Get the genotypes from the selected session. OnStatusChange("Retrieving genotypes from session"); results = selectedSession.GetAllGenotypes(itemTypes, genotypeStatuses, items.StringCollection, experiments.StringCollection); return(results); }
public ActionResult NewBlankAssessment() { string formId = Request["formId"]; SearchModel model = new SearchModel(); if (model.create && model.edit) { /* * **** Check if User has authorization to create an Assessment for this Group. */ // *** RRB 10/27/15 - the Create Assessment should be a method used here and from the 'Action' above. def_FormResults frmRes = FormResults.CreateNewFormResultFull(formId, SessionHelper.LoginStatus.EnterpriseID.ToString(), SessionHelper.LoginStatus.appGroupPermissions[0].groupPermissionSets[0].GroupID.ToString(), "0", SessionHelper.LoginStatus.UserID.ToString()); if (ventureMode) { frmRes.assigned = SessionHelper.LoginStatus.UserID; } formsRepo.AddFormResult(frmRes); if (SessionHelper.SessionForm == null) { SessionHelper.SessionForm = new SessionForm(); } SessionForm sf = SessionHelper.SessionForm; /* * if (sf == null) * { * return RedirectToAction("Index", "Search", null); * } */ // set SessionForm params sf.formId = frmRes.formId; // TODO: How to determine which formid? sf.formResultId = frmRes.formResultId; // get the sectionId of the first section of the first part based on the formId def_Forms frm = formsRepo.GetFormById(sf.formId); def_Parts prt = formsRepo.GetFormParts(frm)[0]; sf.partId = prt.partId; Session["part"] = prt.partId; def_Sections sct = formsRepo.GetSectionsInPart(prt)[0]; return(RedirectToAction("Template", "Results", new { sectionId = sct.sectionId.ToString(), partId = sf.partId.ToString() })); } else { return(RedirectToAction("Index", "Search")); } }
public bool saveInterviewer(int?intId) { if (intId == null) { return(false); } if (SessionHelper.SessionForm == null) { SessionHelper.SessionForm = new SessionForm(); } SessionForm sessionForm = SessionHelper.SessionForm; def_FormResults frmRslt = formsRepo.GetFormResultById(sessionForm.formResultId); if (frmRslt == null) { string paramFormId = Request["formId"] as string; Session["formId"] = paramFormId; int formId = Convert.ToInt32(paramFormId); frmRslt = new def_FormResults() { formId = formId, formStatus = 0, sessionStatus = 0, dateUpdated = DateTime.Today }; int frmRsId = formsRepo.AddFormResult(frmRslt); frmRslt = formsRepo.GetFormResultById(frmRsId); } frmRslt.interviewer = intId; bool ventureMode = SessionHelper.IsVentureMode; if ((frmRslt.formStatus == (byte)FormResults_formStatus.NEW) && !ventureMode) { frmRslt.assigned = intId; } try { SaveFormResults(frmRslt); } catch { return(false); } return(true); }
public static TemplateAdapNavMenu getAdapNavMenuModel(SessionForm sf, IFormsRepository formsRepo) { TemplateAdapNavMenu result = new TemplateAdapNavMenu(); result.sctId = sf.sectionId; def_Sections currentSection = formsRepo.GetSectionById(result.sctId); if (currentSection != null) { result.currentSectionTitle = currentSection.title; } result.sectionIds = new Dictionary <string, int>(); result.sectionTitles = new Dictionary <string, string>(); foreach (Assmnts.def_Sections sct in getTopLevelSectionsInForm(sf.formId, formsRepo)) { //Assmnts.def_Sections sct = formsRepo.GetSectionByIdentifier(identifier); //if (sct == null) //{ // throw new Exception("could not find section with identifier \"" + identifier + "\""); //} result.sectionIds.Add(sct.identifier, sct.sectionId); result.sectionTitles.Add(sct.identifier, sct.title); } result.adapFormId = sf.formResultId; result.firstName = String.Empty; Assmnts.def_ResponseVariables firstNameRV = formsRepo.GetResponseVariablesByFormResultIdentifier(result.adapFormId, "ADAP_D1_FirstName"); if (firstNameRV != null) { result.firstName = firstNameRV.rspValue; } result.lastName = String.Empty; Assmnts.def_ResponseVariables lastNameRV = formsRepo.GetResponseVariablesByFormResultIdentifier(result.adapFormId, "ADAP_D1_LastName"); if (lastNameRV != null) { result.lastName = lastNameRV.rspValue; } result.ActiveUserName = SessionHelper.LoginStatus.FirstName + " " + SessionHelper.LoginStatus.LastName; result.adapPartId = sf.partId; result.access = UAS.Business.UAS_Business_Functions.hasPermission(0, "RptsExpts"); result.readOnly = sf.readOnlyMode; return(result); }
private void FileNewSessionMenuItem_Click(object sender, System.EventArgs e) { SessionForm newSession; try { //The session will live in the MDIChildren of this form. newSession = new SessionForm(this, MyConfiguration, MyPreferences, MyConnectionString); newSession.Open(SessionForm.StartMode.CreateSession, FindNextFreeName()); } catch (Exception ex) { MessageManager.ShowError(ex, "Error when starting new session.", this); } }
private void OpenSessionMenuItem_Click(object sender, System.EventArgs e) { SessionForm newSession; try { //The session will live in the MDIChildren of this form. newSession = new SessionForm(this, MyConfiguration, MyPreferences, MyConnectionString); newSession.Open(SessionForm.StartMode.LoadSession, ""); } catch (Exception ex) { MessageManager.ShowError(ex, "Error when opening session.", this); } }
private void newSessionToolStripMenuItem_Click(object sender, EventArgs e) { SessionConfigForm sessionCfgForm = new SessionConfigForm(); DialogResult dr = sessionCfgForm.ShowDialog(); if (dr != DialogResult.OK) { MessageBox.Show("Sessiongconfig Form closed without an OK!"); return; } SessionConnectionInfo newData = sessionCfgForm.Data; SessionForm newSessionForm = new SessionForm(newData); newSessionForm.Show(); }
public ActionResult RetrieveMagi(int index) { //Use the index and the current formResultId to pull the fileAttachment record to find the formResultId of the MAGI form. int fileId = -1; int RelatedEnumId = formsRepo.GetRelatedEnumIdByEnumDescription("formResultId"); int AttachTypeId = formsRepo.GetAttachTypeIdByAttachDescription("Def Form"); string attachedForm = findMagi(index, RelatedEnumId, AttachTypeId); if (String.IsNullOrEmpty(attachedForm)) { def_FormResults fr = formsRepo.GetFormResultById(SessionHelper.SessionForm.formResultId); def_FormResults magi = CreateMagiForm(fr.subject); attachedForm = magi.formResultId.ToString(); def_FileAttachment fa = new def_FileAttachment() { EnterpriseId = SessionHelper.LoginStatus.EnterpriseID, GroupId = SessionHelper.LoginStatus.GroupID, UserId = fr.subject, AttachTypeId = AttachTypeId, RelatedId = fr.formResultId, RelatedEnumId = RelatedEnumId, displayText = index + "/" + attachedForm, FilePath = index + "/" + attachedForm, FileName = attachedForm, StatusFlag = "A", CreatedDate = DateTime.Now, CreatedBy = SessionHelper.LoginStatus.UserID }; FileUploads.CreateDataAttachment(formsRepo, SessionHelper.SessionForm.formResultId, fa); } // Save the current form data as a session variable SessionForm sf = new SessionForm(); sf.formId = SessionHelper.SessionForm.formId; sf.formResultId = SessionHelper.SessionForm.formResultId; sf.partId = SessionHelper.SessionForm.partId; sf.sectionId = SessionHelper.SessionForm.sectionId; sf.itemId = SessionHelper.SessionForm.itemId; Session.Add("ParentFormData", sf); return(RedirectToAction("ToTemplate", "Adap", new { formResultId = attachedForm })); }
private TemplateNavMenu getNavMenuModel(SessionForm sf, TemplateItems parent) { switch (sf.formIdentifier) { case "ADAP": case "CA-ADAP": case "CA-ADAP-DASHBOARD": case "LA-ADAP": case "LA-ADAP-Stub": case "LA-ADAP-PreIns": case "LA-ADAP-MAGI": return(AJBoggs.Adap.Templates.TemplateMenus.getAdapNavMenuModel(sf, formsRepo)); default: return(AJBoggs.Sis.Templates.TemplateMenus.getSisNavMenuModel(sf, parent, formsRepo)); } }
public ActionResult ViewReport(int formResultId, int formid) { if (SessionHelper.SessionForm == null) { SessionHelper.SessionForm = new SessionForm(); } SessionForm sf = SessionHelper.SessionForm; sf.formId = formid; sf.formResultId = formResultId; def_Forms form = formsRepo.GetFormById(formid); sf.formIdentifier = form.identifier; Session["part"] = (int)6; return(RedirectToAction("Template", "Results", new { sectionId = 38 })); }
private void ToolsMenu_Popup(object sender, System.EventArgs e) { SessionForm activeSession; SessionForm[] sessions; bool anySessionBusy; try { //Set enabled status for menus base on the active session. activeSession = (SessionForm)this.ActiveMdiChild; if (activeSession != null) { InspectPlatesMenuItem.Enabled = !activeSession.IsBusy && !activeSession.IsAborted; RerunMenuItem.Enabled = !activeSession.IsBusy && !activeSession.IsPending && !activeSession.IsAborted; } else { InspectPlatesMenuItem.Enabled = false; RerunMenuItem.Enabled = false; } //Set the Compare menu item status based on if any of the sessions is busy. anySessionBusy = false; if (this.MdiChildren != null) { sessions = new SessionForm[this.MdiChildren.GetLength(0)]; for (int i = 0; i < this.MdiChildren.GetLength(0); i++) { sessions[i] = (SessionForm)this.MdiChildren[i]; if (sessions[i].IsBusy) { anySessionBusy = true; break; } } CompareMenuItem.Enabled = !anySessionBusy; } } catch (Exception ex) { MessageManager.ShowError(ex, "Error when showing menu.", this); } }
private SessionForm GetSession(string sessionName) { SessionForm selectedSession = null; //Get the selected session. for (int i = 0; i < MySessions.GetLength(0); i++) { if (MySessions[i].Text == sessionName) { selectedSession = MySessions[i]; break; } } if (selectedSession == null) { throw new Exception("Unable to find the selected session " + sessionName + "."); } return(selectedSession); }
protected void ScanSession(SessionForm selectedSession, out CIStringCollection usedItems, out CIStringCollection usedExperiments) { DataTable itemsDataTable, experimentsDataTable; CIStringCollection itemsCollection, experimentsCollection; //Get all items from the selected session. OnStatusChange("Retrieving items from session"); itemsDataTable = selectedSession.GetAllItems(); OnStatusChange("Storing session items in memory"); itemsCollection = new CIStringCollection(); for (int i = 0; i < itemsDataTable.Rows.Count; i++) { itemsCollection.Add(itemsDataTable.Rows[i][1].ToString()); if (i % 1000 == 0) { OnStatusChange("Storing session items in memory (" + i.ToString() + ")"); } } //Get all experiments from the selected session. OnStatusChange("Retrieving experiments from session"); experimentsDataTable = selectedSession.GetAllExperiments(); OnStatusChange("Storing session experiments in memory"); experimentsCollection = new CIStringCollection(); for (int i = 0; i < experimentsDataTable.Rows.Count; i++) { experimentsCollection.Add(experimentsDataTable.Rows[i][1].ToString()); if (i % 1000 == 0) { OnStatusChange("Storing session experiments in memory (" + i.ToString() + ")"); } } //Set out parameters. usedItems = itemsCollection; usedExperiments = experimentsCollection; }
private void IdentifyMenuItem_Click(object sender, EventArgs e) { IdentificationSettingsForm settingsForm; SessionForm[] sessions; StringCollection individualTypes, genotypeStatuses; StringCollection referenceSetNames; try { settingsForm = new IdentificationSettingsForm(MyConnectionString); //Find available sessions. if (this.MdiChildren != null) { sessions = new SessionForm[this.MdiChildren.GetLength(0)]; for (int i = 0; i < this.MdiChildren.GetLength(0); i++) { sessions[i] = (SessionForm)this.MdiChildren[i]; } individualTypes = DataServer.GetIndividualTypes(MyConnectionString, Convert.ToInt32(MyConfiguration.Get("synctimeout"))); genotypeStatuses = DataServer.GetGenotypeStatuses(MyConnectionString, Convert.ToInt32(MyConfiguration.Get("synctimeout"))); referenceSetNames = DataServer.GetReferenceSets(MyConnectionString, Convert.ToInt32(MyConfiguration.Get("synctimeout"))); settingsForm.InitSessions(sessions, individualTypes, genotypeStatuses); settingsForm.InitReferenceSets(referenceSetNames); } settingsForm.ShowDialog(this); } catch (Exception ex) { MessageManager.ShowError(ex, "Error when attempting to initialize form for identification.", this); } }
public ActionResult Template(int?sectionIdOverride = null, List <string> validationMessages = null) { mLogger.Debug("* * * ResultsController:Template method * * *"); if (!SessionHelper.IsUserLoggedIn) { return(RedirectToAction("Index", "Account", null)); } if (SessionHelper.SessionForm == null) { SessionHelper.SessionForm = new SessionForm(); } if (Session["form"] != null && !string.IsNullOrWhiteSpace(Session["form"].ToString())) { int formId = SessionHelper.SessionForm.formId; formId = int.Parse(Session["form"].ToString()); def_Forms frm = formsRepo.GetFormById(formId); SessionHelper.SessionForm.formId = formId; SessionHelper.SessionForm.formIdentifier = frm.identifier; var oldFrmResult = formsRepo.GetFormResultById(SessionHelper.SessionForm.formResultId); var newFrmResult = formsRepo.GetFormResultsByFormSubject(formId, oldFrmResult.subject).OrderByDescending(f => f.dateUpdated); if (newFrmResult.Any()) { // use most recent form result SessionHelper.SessionForm.formResultId = newFrmResult.FirstOrDefault().formResultId; } Session["form"] = null; int part = int.Parse(Session["part"].ToString()); SessionHelper.SessionForm.partId = part; } SessionForm sessionForm = SessionHelper.SessionForm; // set language ID in session based on meta-data (default to English) + other session vars CultureInfo ci = Thread.CurrentThread.CurrentUICulture; string isoName = (ci == null) ? "en" : ci.TwoLetterISOLanguageName.ToLower(); def_Languages lang = formsRepo.GetLanguageByTwoLetterISOName(isoName); if (lang == null) { throw new Exception("could not find def_Language entry for iso code \"" + isoName + "\""); } else { sessionForm.langId = lang.langId; } // This is the master or top level sectionId, there can be mulitple subSections below this section. // The subSections will be in the SectionItems string sectionId = (sectionIdOverride == null) ? Request["sectionId"] as string : sectionIdOverride.ToString(); mLogger.Debug("* * * Results Template sectionId: {0}", sectionId); Session["section"] = sectionId; def_Sections sctn = formsRepo.GetSectionById(Convert.ToInt32(sectionId)); sessionForm.sectionId = sctn.sectionId; // Create a new Assessments Model Template (AMT) that is used by the .cshtml template (Razor code) TemplateItems amt; if (sctn.href != null && (sctn.href.EndsWith("spprtNeedsScale.cshtml") || sctn.href.EndsWith("excptnlMedSpprtNeed.cshtml"))) { amt = new QuestionListForm(); } else { amt = new GeneralForm(); } amt.thisSection = sctn; amt.thisSectionId = sctn.sectionId; amt.formsRepo = formsRepo; amt.formResultId = sessionForm.formResultId; amt.currentUser = SessionHelper.LoginInfo.LoginID; //amt.items = new List<def_Items>(); amt.subSections = new List <def_Sections>(); amt.fldLabels = new Dictionary <string, string>(); amt.itmPrompts = new Dictionary <string, string>(); amt.rspValues = new Dictionary <string, string>(); mLogger.Debug("* * * ResultsController:Template sessionForm.formResultId: {0}", sessionForm.formResultId); def_FormResults fr = formsRepo.GetFormResultById(sessionForm.formResultId); mLogger.Debug("* * * ResultsController:Template fr.formResultId: {0}", fr.formResultId); if (fr != null) { if (fr.formStatus == (byte)FormResults_formStatus.IN_PROGRESS) { amt.inProgress = true; } if (fr.formStatus == (byte)FormResults_formStatus.NEW) { amt.newAssmnt = true; } } //Start: added for enhancement Bug 13663 to be refactored amt.updatedDate = fr.dateUpdated; amt.formStatus = fr.formStatus; int statusMasterId = 0; def_StatusMaster statusMaster = formsRepo.GetStatusMasterByFormId(fr.formId); if (statusMaster != null) { statusMasterId = statusMaster.statusMasterId; def_StatusDetail statusdetails = formsRepo.GetStatusDetailBySortOrder(statusMasterId, fr.formStatus); amt.formSatusText = statusdetails.def_StatusText .Where(sd => sd.EnterpriseID == 8 && sd.langId == 1) .Select(z => z.displayText) .FirstOrDefault(); } else { //This is used as currently we are showing In Progress for all items which do not have status amt.formSatusText = "In Progress"; } amt.CanUserChangeStatus = true; if (UAS_Business_Functions.hasPermission(PermissionConstants.ASSIGNED, PermissionConstants.ASSMNTS)) { amt.CanUserChangeStatus = false; } else if (amt.formSatusText.ToLower() == "needs review" || amt.formSatusText.ToLower().Contains("approved")) { if (!UAS_Business_Functions.hasPermission(PermissionConstants.APPROVE, PermissionConstants.ASSMNTS)) { amt.CanUserChangeStatus = false; } } else if (amt.formId == 18) { amt.CanUserChangeStatus = false; } var formType = formsRepo.GetResponseVariablesByFormResultIdentifier(fr.formResultId, "C1_FormType"); string formVariant = string.Empty; if (formType != null && formType.rspValue != null && formType.rspValue != String.Empty) { formVariant = formType.rspValue; amt.FormVariantTitle = formVariant; } else { formsEntities context = new Assmnts.formsEntities(); amt.FormVariantTitle = context.def_FormVariants .Where(fv => fv.formID == fr.formId) .Select(fv => fv.title) .FirstOrDefault(); } //get the subject id from form result id if (fr.subject != null) { int subject = (int)fr.subject; var elgEndDate = formsRepo.GetResponseVariablesBySubjectForm(subject, 18, "C1_ProgramEligibleEndDate"); string endDate = elgEndDate != null ? elgEndDate.rspValue : string.Empty; amt.EligibilityEnddate = endDate; amt.formResultUser = authClient.GetUserDisplay(subject); amt.clientId = authClient.GetExistingAdapIdentifier(amt.formResultUser.UserID, 8); } //End: added for enhancement Bug 13663 to be refactored amt.formId = sessionForm.formId; formsRepo.SortSectionItems(sctn); // This is both loading and sorting the SectionItems. // Get the Items in the SubSections *** NOTE: this only goes ONE level deep *** Should be made recursive for unlimited levels !!! // amt.sections = new List<def_Sections>(); foreach (def_SectionItems sctnItm in sctn.def_SectionItems.OrderBy(si => si.order)) { if (sctnItm.subSectionId.GetValueOrDefault(0) == 0 || sctnItm.display == false) { continue; } // def_Sections subSctns = sctnItm.def_SubSections.def_Sections; def_Sections subSctns = formsRepo.GetSubSectionById(sctnItm.subSectionId); //do not add notes section to the section list, (if there is a notes item, it will later be set as amt.notesItem) if (subSctns.multipleItemsPerPage == false) { continue; } formsRepo.SortSectionItems(subSctns); // Load and sort the SectionItems amt.subSections.Add(subSctns); // GetItemLabelsResponses(fr.formResultId, amt, formsRepo.GetSectionItems(sctnItm.def_SubSections.def_Sections)); } // RRB 5/28/15 *** This is only necessary for the Profile screens // *** Getting and sorting the SectionItems above is only necessary for Question forms // *** In fact, it may duplicate what is being done in the templates formsRepo.GetItemListIncludingSubSections(sctn, amt); //GetItemListIncludingSubSections(sctn, amt); // Get the Notes items formsRepo.GetItemListForNotes(sctn, amt); formsRepo.GetItemLabelsResponses(fr.formResultId, amt, amt.items); //determine whether or not this user will be shown itemvariable identifiers as tooltips //TODO this is a DEV mode only thing amt.showItemVariableIdentifiersAsTooltips = Convert.ToBoolean(ConfigurationManager.AppSettings["showItemVariableIdentifiersAsTooltips"]); // true;//new UAS.Business.UAS_Business_Functions().hasPermission(7,"assmnts"); //save response values in session variable to later determine which ones were modified ////List<string> keysToClear = new List<string>(); ////foreach (string key in Session.Keys) //// if (key.StartsWith("frmOriginal___")) //// keysToClear.Add(key); ////foreach (string key in keysToClear) //// Session.Remove(key); //DateTime oneHourFromNow = DateTime.Now.AddHours(1); //foreach (string key in amt.rspValues.Keys) //{ //Response.Cookies["frmOriginal___" + key].Value = amt.rspValues[key]; //Response.Cookies["frmOriginal___" + key].Expires = oneHourFromNow; //} mLogger.Debug("* * * AFTER GetItemLabelsResponses amt.items.Count: {0}", amt.items.Count); mLogger.Debug("* * * amt.rspValues.Count (Total): {0}", amt.rspValues.Count); //populate required and readonly dictionaries amt.fldRequired = new Dictionary <string, bool>(); amt.fldReadOnly = new Dictionary <string, bool>(); List <def_SectionItems> siList = formsRepo.GetSectionItemsBySectionIdEnt(sctn.sectionId, SessionHelper.LoginStatus.EnterpriseID); if (amt.items != null) { foreach (def_Items itm in amt.items) { if (amt.fldRequired.ContainsKey(itm.identifier)) { throw new Exception("Found duplicate item identifier \"" + itm.identifier + "\""); } def_SectionItems si = siList.FirstOrDefault(s => (!s.subSectionId.HasValue && s.itemId == itm.itemId)); amt.fldRequired.Add(itm.identifier, (si == null) ? false : si.requiredForm); amt.fldReadOnly.Add(itm.identifier, (si == null) ? false : si.readOnly); } } amt.isProfile = false; string[] uriSegments = sctn.href.Split('/'); string templateFileName = uriSegments[uriSegments.Count() - 1]; switch (templateFileName) { case "idprof1.cshtml": case "idprof2.cshtml": case "idprof2_Child.cshtml": if (mLogger.IsDebugEnabled) { mLogger.Debug("showing section item identifiers:"); foreach (def_SectionItems si in siList) { mLogger.Debug("\t{0}", si.def_Items.identifier); } } amt.notesItem = siList.Single(si => si.def_Items.identifier.EndsWith("PageNotes_item")).def_Items; sessionForm.templateType = TemplateType.StdSectionItems; amt.isProfile = true; break; default: // "SIS/section1a": Default to the item list sessionForm.templateType = TemplateType.MultipleCommonItems; break; } // Setup the Previous / Next screens amt.prevScreenTitle = amt.prevScreenHref = String.Empty; amt.nextScreenTitle = amt.nextScreenHref = String.Empty; def_Parts prt = formsRepo.GetPartById(Convert.ToInt32(Session["part"])); List <def_Sections> partSections = formsRepo.GetSectionsInPart(prt); mLogger.Debug("* * * ResultsController:Template method * * * partSections.Count: {0}", partSections.Count); //get a list of parts in the current form def_Forms form = formsRepo.GetFormById(amt.formId); List <def_Parts> partsInForm = formsRepo.GetFormParts(form); List <int> partIdsInForm = partsInForm.Select(p => p.partId).ToList(); // List<def_Parts> partsInForm = formsRepo.getFormParts(fr.def_Forms); //these variables will be assigned int he loop below int currentSectionIndex = 0; int prevSectionIndex = 0; int nextSectionIndex = 0; //start by assuming the previous and next section will be in the same part int currentPartId = (prt == null) ? sessionForm.partId : prt.partId; amt.thisPartId = currentPartId; amt.navPartId = currentPartId.ToString(); int prevPartId = currentPartId; int nextPartId = currentPartId; //in a special cases one of these will be set to true bool veryFirst = false; bool veryLast = false; bool foundSectionId = false; //iterate through possible section ids for (int idx = 0; idx < partSections.Count; idx++) { if (partSections[idx].sectionId == sessionForm.sectionId) { //found the current section id, start with some assumptions about previous and next section ids foundSectionId = true; currentSectionIndex = idx; prevSectionIndex = idx - 1; nextSectionIndex = idx + 1; //we may have to link to the last section of the previous part if (prevSectionIndex < 0) { //special case where we're on the first section of the first part if (partIdsInForm.IndexOf(prt.partId) == 0) //currentPartId == 1) { //veryFirst = true; int partIndexInForm = partsInForm.Count(); List <def_Sections> prevPartSections = formsRepo.GetSectionsInPart(partsInForm[partIndexInForm - 1]); prevPartId = partsInForm[partIndexInForm - 1].partId; prevSectionIndex = prevPartSections.Count - 1; } else { int partIndexInForm = partIdsInForm.IndexOf(prt.partId); // occasionally a part with no sections may need to be skipped, which can happen with PartSectionsEnt records. int listIndex = 0; for (int i = 1; i < partIndexInForm; i++) { if (formsRepo.GetSectionsInPart(partsInForm[partIndexInForm - i]).Count() > 0) { listIndex = partIndexInForm - i; break; } } List <def_Sections> prevPartSections = formsRepo.GetSectionsInPart(partsInForm[listIndex]); prevPartId = partsInForm[listIndex].partId; prevSectionIndex = prevPartSections.Count - 1; } } // Oliver - same here the PartSections are ordered - just use the first one in the List. // you can press F12 in Visual Studio and it will take you to the method. // Data/Concrete/FormsRepository line 200 // The defined Interfaces are in Data/Abstract/IFormsRepository.cs //we may have to link to he first section of the next part if (nextSectionIndex > (partSections.Count - 1)) { int partIndexInForm = partIdsInForm.IndexOf(prt.partId); if (partIndexInForm == (partsInForm.Count() - 1)) //formsRepo.GetPartById(nextPartId) == null) { //veryLast = true; nextPartId = partsInForm[0].partId; nextSectionIndex = 0; } else { // occasionally a part with no sections may need to be skipped, which can happen with PartSectionsEnt records. int listIndex = 0; for (int i = 1; i < partsInForm.Count() - 1 - partIndexInForm; i++) { if (formsRepo.GetSectionsInPart(partsInForm[partIndexInForm + i]).Count() > 0) { listIndex = partIndexInForm + i; break; } } nextPartId = partsInForm[listIndex].partId; nextSectionIndex = 0; } } break; } } if (!foundSectionId) { string msg = "current section id (" + sessionForm.sectionId + ") could not be found.\r\nListing candidates: (identifier / sectionId)"; foreach (def_Sections sct in partSections) { msg += (sct == null) ? "null" : ("\r\n" + sct.identifier + " / " + sct.sectionId); } throw new Exception(msg); } //print some debugging info if (mLogger.IsDebugEnabled) { mLogger.Debug("* * * ResultsController:Template method * * * " + (veryFirst ? "this is the very first part/section" : "prevPartId: " + prevPartId.ToString() + ", prevSectionIndex: " + prevSectionIndex.ToString())); mLogger.Debug("* * * ResultsController:Template method * * * " + (veryLast ? "this is the very last part/section" : "nextPartId: " + nextPartId.ToString() + ", nextSectionIndex: " + nextSectionIndex.ToString())); } if (partSections.Count > 0) { int idxPeriod = prt.identifier.IndexOf('.'); string partShortTitle = (idxPeriod < 0) ? prt.identifier : prt.identifier.Substring(0, idxPeriod); // amt.thisScreenCaption = partShortTitle + " - " + partSections[thisIdx].identifier; amt.thisScreenCaption = partShortTitle + " - " + partSections[currentSectionIndex].identifier; amt.thisScreenTitle = partSections[currentSectionIndex].title; if (!veryFirst) { List <def_Sections> prevPartSections = formsRepo.GetSectionsInPart(formsRepo.GetPartById(prevPartId)); amt.prevScreenTitle = prevPartSections[prevSectionIndex].title; amt.prevScreenPartId = prevPartId.ToString(); amt.prevScreenSectionId = prevPartSections[prevSectionIndex].sectionId.ToString(); amt.prevScreenHref = "Template?partId=" + nextPartId + "§ionId=" + amt.prevScreenSectionId; //if (prevPartId != currentPartId) // amt.previousScreenHref = "Parts?formResultId=" + formsRepo.GetPartById(prevPartId).partId.ToString() + amt.previousScreenHref; } if (!veryLast) { def_Parts tempPart = formsRepo.GetPartById(nextPartId); if (tempPart != null) { List <def_Sections> tempPartSections = formsRepo.GetSectionsInPart(tempPart); amt.nextScreenTitle = tempPartSections[nextSectionIndex].title; amt.nextScreenPartId = nextPartId.ToString(); amt.nextScreenSectionId = tempPartSections[nextSectionIndex].sectionId.ToString(); amt.nextScreenHref = "Template?partId=" + nextPartId + "§ionId=" + amt.nextScreenSectionId; } } } //pass a NavMenu model as a field in this items Model sessionForm.formIdentifier = form.identifier; amt.navMenuModel = getNavMenuModel(sessionForm, amt); //Start: added for enhancement Bug 13663 to be refactored amt.navMenuModel.formResultUser = amt.formResultUser; amt.navMenuModel.clientId = amt.clientId; amt.navMenuModel.formSatusText = amt.formSatusText; amt.navMenuModel.EligibilityEnddate = amt.EligibilityEnddate; amt.navMenuModel.FormVariantTitle = amt.FormVariantTitle; amt.navMenuModel.updatedDate = amt.updatedDate; amt.navMenuModel.CanUserChangeStatus = amt.CanUserChangeStatus; amt.navMenuModel.formResultId = amt.formResultId; //End: added for enhancement Bug 13663 to be refactored amt.ventureMode = SessionHelper.IsVentureMode; //special case for reports sections if ((sctn.identifier.EndsWith("Report") /*&& (Request["ignoreValidation"] as string) == null*/) || sctn.href.Equals("~/Views/Templates/SIS/reportErrors.cshtml") ) { if (!ValidateFormResult(fr, amt)) { return(View("~/Views/Templates/SIS/reportErrors.cshtml", amt)); } } //add messages to the mdoel if necessary amt.validationMessages = validationMessages; //validationMessages from method params, normally null //add a message to the model if necessary string message = Request["message"] as string; if (message != null) { if (amt.validationMessages == null) { amt.validationMessages = new List <string>(); } amt.validationMessages.Add(message); } // *** RRB 10/27/15 - added to fix problems with Venture and to be more efficient. if (!SessionHelper.IsVentureMode) { if (templateFileName.Equals("reportOptions.cshtml")) { amt.reportOptions = AJBoggs.Sis.Reports.SisReportOptions.BuildPdfReportOptions(fr.EnterpriseID); } } // * * * OT 3/24/16 - for SIS supplemental questions, pre-populate sis_s41f with some item prompts from section 1A // Don't do anything if there is already a response for sis_s41f // (Bug 13132, #4 in description) if (sctn.identifier == "SQ" && amt.rspValues.ContainsKey("sis_s41f") && String.IsNullOrWhiteSpace(amt.rspValues["sis_s41f"])) { amt.rspValues["sis_s41f"] = String.Empty; //iterate through all section 1A items int itmCount = 0; bool isSisCAssessment = fr.def_Forms.identifier.Equals("SIS-C"); def_Sections sct1A = formsRepo.GetSectionByIdentifier(isSisCAssessment ? "SIS-C 1A" : "SIS-A 1A"); formsRepo.SortSectionItems(sct1A); foreach (def_SectionItems si in sct1A.def_SectionItems) { def_Sections subSct = formsRepo.GetSubSectionById(si.subSectionId); formsRepo.SortSectionItems(subSct); foreach (def_SectionItems subSi in subSct.def_SectionItems) { //for items that have an itemVariable with suffix "_ExMedSupport", check if that itemVariable have a response of "2" def_Items itm = subSi.def_Items; itmCount++; def_ItemVariables exMedSupIv = itm.def_ItemVariables.Where(iv => iv.identifier.EndsWith("_ExMedSupport")).FirstOrDefault(); if (exMedSupIv != null) { def_ResponseVariables rv = formsRepo.GetResponseVariablesByFormResultItemVarId(fr.formResultId, exMedSupIv.itemVariableId); if (rv != null && !String.IsNullOrWhiteSpace(rv.rspValue) && rv.rspValue == "2") { //append the item prompt to the pre-populated response for sis_s41f amt.rspValues["sis_s41f"] += itmCount + ". " + itm.prompt + "\n"; } } } } } // *** OT 11/23/15 - added as test for Bug 12910 - Comparison: what changed from last approved application? //if we're on the ADAP form... if (form.identifier.Contains("ADAP")) { //get the previous formresult int?sortOrder = formsRepo.GetStatusDetailByMasterIdentifier(1, "CANCELLED").sortOrder; int userId = fr.subject.HasValue ? fr.subject.Value : -1; if (userId < 1) { mLogger.Warn("subject < 1 for form result having formResultId = {0}.", fr.formResultId); } // * * * OT 1-19-16 added stipulation that "prevRes" is not the current formResult "fr" def_FormResults prevRes = null; if (sortOrder.HasValue && userId > 0) { prevRes = formsRepo.GetEntities <def_FormResults>( x => x.formId == fr.formId && x.formResultId != fr.formResultId && x.subject == userId && x.formStatus != sortOrder) .OrderByDescending(x => x.dateUpdated) .FirstOrDefault(); } // * * * OT 1-19-16 in order to duplicate existing behavior and avoid crashes, // default to using the current formResult as the previous if no others are applicable if (prevRes == null) { prevRes = fr; } List <string> remainingIdentifiers = amt.rspValues.Keys.ToList(); IList <def_ItemResults> previousItemResults = formsRepo.GetItemResults(prevRes.formResultId); foreach (def_ItemResults ir in previousItemResults) { foreach (def_ResponseVariables rv in ir.def_ResponseVariables) { if (rv.def_ItemVariables == null) { continue; } remainingIdentifiers.Remove(rv.def_ItemVariables.identifier); string rspValue = HttpUtility.HtmlDecode(rv.rspValue); amt.rspValues.Add("PREVIOUS_" + rv.def_ItemVariables.identifier, rspValue); } } //populate amt with empty responses for fields Bmissing from previous formResult foreach (string ident in remainingIdentifiers) { amt.rspValues.Add("PREVIOUS_" + ident, ""); } } SessionHelper.ResponseValues = amt.rspValues; //Displays save message ViewBag.Notify = ""; ViewBag.NotifyMessage = ""; if (Session["IsPageLoad"] != null) { if (!(bool)Session["IsPageLoad"]) { if (TempData["Savemsg"] != null && TempData["SavemsgHeader"] != null) { if (TempData["Savemsg"].ToString() != "" && TempData["SavemsgHeader"].ToString() != "") { ViewBag.Notify = TempData["SavemsgHeader"].ToString(); ViewBag.NotifyMessage = TempData["Savemsg"].ToString(); } } } } TempData["SavemsgHeader"] = ""; TempData["Savemsg"] = ""; return(View(sctn.href, amt)); }
public ActionResult CreateAdapApplication() { def_Forms frm = formsRepo.GetFormByIdentifier("LA-ADAP"); //string userId = Request["userId"]; int userId = 0; try { userId = Convert.ToInt32(Request["userId"]); } catch (Exception excptn) { Debug.WriteLine("Adap Controller CreateAdapApplication exception:" + excptn.Message); } bool isCaseMgr = UAS.Business.UAS_Business_Functions.hasPermission(2, "RptsExpts"); // Case Manager permission int?intSO = formsRepo.GetStatusDetailByMasterIdentifier(1, "CANCELLED").sortOrder; def_FormResults prevRes = formsRepo.GetEntities <def_FormResults>(f => f.subject == userId && intSO != null && f.formStatus != intSO).OrderByDescending(f => f.dateUpdated).FirstOrDefault(); //def_FormResults prevRes = frm.def_FormResults.Where(f => f.subject == userId && intSO != null && f.formStatus != intSO).OrderByDescending(f => f.dateUpdated).FirstOrDefault(); if ((prevRes == null) || (prevRes.formStatus == formsRepo.GetStatusDetailByMasterIdentifier(1, "APPROVED").sortOrder)) { AuthenticationClient webclient = new AuthenticationClient(); UserDisplay ud = webclient.GetUserDisplay(userId); //Dictionary<string, string> ItemsToPopulateFromUAS = new Dictionary<string, string>(); //ItemsToPopulateFromUAS.Add( // "ADAP_D1_FirstName_item", String.IsNullOrEmpty(ud.FirstName) ? String.Empty : ud.FirstName); //ItemsToPopulateFromUAS.Add( // "ADAP_D1_LastName_item", String.IsNullOrEmpty(ud.LastName) ? String.Empty : ud.LastName); //ItemsToPopulateFromUAS.Add( // "ADAP_D2_DOB_item", ud.DOB.HasValue == false ? String.Empty : ud.DOB.Value.ToShortDateString()); //if (ud.Addresses.Any()) //{ // ItemsToPopulateFromUAS.Add( // "ADAP_C1_Address_item", String.IsNullOrEmpty(ud.Addresses[0].Address1) ? String.Empty // : ud.Addresses[0].Address1); // ItemsToPopulateFromUAS.Add( // "LA_ADAP_AddrAptNum_item", String.IsNullOrEmpty(ud.Addresses[0].Address2) ? String.Empty // : ud.Addresses[0].Address2); // ItemsToPopulateFromUAS.Add( // "ADAP_C1_City_item", String.IsNullOrEmpty(ud.Addresses[0].City) ? String.Empty // : ud.Addresses[0].City); // ItemsToPopulateFromUAS.Add( // "ADAP_C1_State_item", String.IsNullOrEmpty(ud.Addresses[0].State) ? String.Empty // : ud.Addresses[0].State); // ItemsToPopulateFromUAS.Add( // "ADAP_C1_Zip_item", String.IsNullOrEmpty(ud.Addresses[0].ZIP) ? String.Empty // : ud.Addresses[0].ZIP); //} //if (ud.Emails.Any()) //{ // ItemsToPopulateFromUAS.Add( // "LA_ADAP_Email_Adr", String.IsNullOrEmpty(ud.Emails[0].Email) ? String.Empty // : ud.Emails[0].Email); //} Dictionary <string, string> ItemsToPopulateFromUAS = new Dictionary <string, string>(); ItemsToPopulateFromUAS.Add( "ADAP_D1_FirstName_item", String.IsNullOrEmpty(ud.FirstName) ? String.Empty : ud.FirstName); ItemsToPopulateFromUAS.Add( "ADAP_D1_LastName_item", String.IsNullOrEmpty(ud.LastName) ? String.Empty : ud.LastName); ItemsToPopulateFromUAS.Add( "ADAP_D1_MiddleIntl_item", String.IsNullOrEmpty(ud.MiddleName) ? String.Empty : ud.MiddleName.Substring(0, 1)); ItemsToPopulateFromUAS.Add( "ADAP_D2_DOB_item", (ud.DOB == null) ? String.Empty : Convert.ToDateTime(ud.DOB).ToString("MM/dd/yyyy")); ItemsToPopulateFromUAS.Add( "ADAP_C1_Address_item", (ud.Addresses != null && ud.Addresses.Count() > 0) ? ud.Addresses[0].Address1 : String.Empty); ItemsToPopulateFromUAS.Add( "ADAP_C1_MayContactYN_item", (ud.Addresses != null && ud.Addresses.Count() > 0) ? ((ud.Addresses[0].MayContactAddress) ? "1" : "0") : String.Empty); ItemsToPopulateFromUAS.Add( "ADAP_C1_City_item", (ud.Addresses != null && ud.Addresses.Count() > 0) ? ud.Addresses[0].City : String.Empty); ItemsToPopulateFromUAS.Add( "ADAP_C1_State_item", (ud.Addresses != null && ud.Addresses.Count() > 0) ? ud.Addresses[0].State : String.Empty); ItemsToPopulateFromUAS.Add( "ADAP_C1_Zip_item", (ud.Addresses != null && ud.Addresses.Count() > 0) ? ud.Addresses[0].ZIP : String.Empty); ItemsToPopulateFromUAS.Add( "ADAP_C2_Address_item", (ud.Addresses != null && ud.Addresses.Count() > 1) ? ud.Addresses[1].Address1 : String.Empty); ItemsToPopulateFromUAS.Add( "ADAP_C2_MayContactYN_item", (ud.Addresses != null && ud.Addresses.Count() > 1) ? ((ud.Addresses[1].MayContactAddress) ? "1" : "0") : String.Empty); ItemsToPopulateFromUAS.Add( "ADAP_C2_City_item", (ud.Addresses != null && ud.Addresses.Count() > 1) ? ud.Addresses[1].City : String.Empty); ItemsToPopulateFromUAS.Add( "ADAP_C2_State_item", (ud.Addresses != null && ud.Addresses.Count() > 1) ? ud.Addresses[1].State : String.Empty); ItemsToPopulateFromUAS.Add( "ADAP_C2_Zip_item", (ud.Addresses != null && ud.Addresses.Count() > 1) ? ud.Addresses[1].ZIP : String.Empty); ItemsToPopulateFromUAS.Add( "ADAP_C3_Phone1_Num_item", (ud.Phones != null && ud.Phones.Count() > 0) ? ud.Phones[0].Phone : String.Empty); ItemsToPopulateFromUAS.Add( "ADAP_C3_Phone1_MayMsgYN_item", (ud.Phones != null && ud.Phones.Count() > 0) ? ((ud.Phones[0].MayContactPhone) ? "1" : "0") : String.Empty); ItemsToPopulateFromUAS.Add( "ADAP_C3_Phone2_Num_item", (ud.Phones != null && ud.Phones.Count() > 1) ? ud.Phones[1].Phone : String.Empty); ItemsToPopulateFromUAS.Add( "ADAP_C3_Phone2_MayMsgYN_item", (ud.Phones != null && ud.Phones.Count() > 1) ? ((ud.Phones[1].MayContactPhone) ? "1" : "0") : String.Empty); Applications appl = new Applications(formsRepo); def_FormResults frmRes = appl.CreateFormResultPopulatedFromUAS(SessionHelper.LoginStatus.EnterpriseID, SessionHelper.LoginStatus.GroupID, userId, frm.formId, ItemsToPopulateFromUAS); if (isCaseMgr) { frmRes.interviewer = SessionHelper.LoginStatus.UserID; } else if (ud.ManagerID != null) { frmRes.interviewer = ud.ManagerID; } frmRes.statusChangeDate = DateTime.Now; // Save the FormResult, ItemResults, and ResponseVariables int newFormResultId = 0; try { newFormResultId = formsRepo.AddFormResult(frmRes); } catch (Exception ex) { Debug.WriteLine("AddFormResult exception:" + ex.Message); } Debug.WriteLine("AddFormResult newFormResultId:" + newFormResultId.ToString()); if (SessionHelper.SessionForm == null) { SessionHelper.SessionForm = new SessionForm(); } SessionForm sf = SessionHelper.SessionForm; sf.formId = frm.formId; sf.formIdentifier = frm.identifier; sf.sectionId = formsRepo.GetSectionByIdentifier("LA_ADAP_PreScreen").sectionId; sf.partId = formsRepo.GetPartByFormAndIdentifier(frm, "LA-ADAP").partId; // *** RRB - should be deprecated - use SessionForm // *** BR - line 359 of the ResultsController calls this session variable, so it must be set to prevent an exception. // Other parts of the application may still use that variable, so changing it in the ResultsController may break something else. Session["part"] = sf.partId; // Should have the partId also - may not be required. sf.formResultId = newFormResultId; return(RedirectToAction("Template", "Results", new { sectionId = sf.sectionId.ToString() })); } else { if (isCaseMgr) { userId = SessionHelper.LoginStatus.UserID; } return(RedirectToAction("AdapPortal", "LAADAP", new { userId = userId, error = "Not Approved" })); } }
public ActionResult CreateAdapApplication() { def_Forms frm = formsRepo.GetFormByIdentifier("ADAP"); //string userId = Request["userId"]; int userId = 0; try { userId = Convert.ToInt32(Request["userId"]); } catch (Exception excptn) { Debug.WriteLine("Adap Controller CreateAdapApplication exception:" + excptn.Message); } int? intSO = formsRepo.GetStatusDetailByMasterIdentifier(1, "CANCELLED").sortOrder; def_FormResults prevRes = formsRepo.GetEntities <def_FormResults>(x => x.formId == frm.formId && x.subject == userId && x.formStatus != intSO) .OrderByDescending(x => x.dateUpdated) .FirstOrDefault(); //def_FormResults prevRes = frm.def_FormResults.Where(f => f.subject == userId && intSO != null && f.formStatus != intSO).OrderByDescending(f => f.dateUpdated).FirstOrDefault(); if ((prevRes == null) || (prevRes.formStatus == formsRepo.GetStatusDetailByMasterIdentifier(1, "APPROVED").sortOrder)) { AuthenticationClient webclient = new AuthenticationClient(); UserDisplay ud = webclient.GetUserDisplay(userId); Dictionary <string, string> ItemsToPopulateFromUAS = new Dictionary <string, string>(); ItemsToPopulateFromUAS.Add( "ADAP_D1_FirstName_item", String.IsNullOrEmpty(ud.FirstName) ? String.Empty : ud.FirstName); ItemsToPopulateFromUAS.Add( "ADAP_D1_LastName_item", String.IsNullOrEmpty(ud.LastName) ? String.Empty : ud.LastName); ItemsToPopulateFromUAS.Add( "ADAP_D1_MiddleIntl_item", String.IsNullOrEmpty(ud.MiddleName) ? String.Empty : ud.MiddleName.Substring(0, 1)); ItemsToPopulateFromUAS.Add( "ADAP_D2_DOB_item", (ud.DOB == null) ? String.Empty : Convert.ToDateTime(ud.DOB).ToString("MM/dd/yyyy")); ItemsToPopulateFromUAS.Add( "ADAP_C1_Address_item", (ud.Addresses != null && ud.Addresses.Count() > 0) ? ud.Addresses[0].Address1 : String.Empty); ItemsToPopulateFromUAS.Add( "ADAP_C1_MayContactYN_item", (ud.Addresses != null && ud.Addresses.Count() > 0) ? ((ud.Addresses[0].MayContactAddress) ? "1" : "0") : String.Empty); ItemsToPopulateFromUAS.Add( "ADAP_C1_City_item", (ud.Addresses != null && ud.Addresses.Count() > 0) ? ud.Addresses[0].City : String.Empty); ItemsToPopulateFromUAS.Add( "ADAP_C1_State_item", (ud.Addresses != null && ud.Addresses.Count() > 0) ? ud.Addresses[0].State : String.Empty); ItemsToPopulateFromUAS.Add( "ADAP_C1_Zip_item", (ud.Addresses != null && ud.Addresses.Count() > 0) ? ud.Addresses[0].ZIP : String.Empty); ItemsToPopulateFromUAS.Add( "ADAP_C2_Address_item", (ud.Addresses != null && ud.Addresses.Count() > 1) ? ud.Addresses[1].Address1 : String.Empty); ItemsToPopulateFromUAS.Add( "ADAP_C2_MayContactYN_item", (ud.Addresses != null && ud.Addresses.Count() > 1) ? ((ud.Addresses[1].MayContactAddress) ? "1" : "0") : String.Empty); ItemsToPopulateFromUAS.Add( "ADAP_C2_City_item", (ud.Addresses != null && ud.Addresses.Count() > 1) ? ud.Addresses[1].City : String.Empty); ItemsToPopulateFromUAS.Add( "ADAP_C2_State_item", (ud.Addresses != null && ud.Addresses.Count() > 1) ? ud.Addresses[1].State : String.Empty); ItemsToPopulateFromUAS.Add( "ADAP_C2_Zip_item", (ud.Addresses != null && ud.Addresses.Count() > 1) ? ud.Addresses[1].ZIP : String.Empty); ItemsToPopulateFromUAS.Add( "ADAP_C3_Phone1_Num_item", (ud.Phones != null && ud.Phones.Count() > 0) ? ud.Phones[0].Phone : String.Empty); ItemsToPopulateFromUAS.Add( "ADAP_C3_Phone1_MayMsgYN_item", (ud.Phones != null && ud.Phones.Count() > 0) ? ((ud.Phones[0].MayContactPhone) ? "1" : "0") : String.Empty); ItemsToPopulateFromUAS.Add( "ADAP_C3_Phone2_Num_item", (ud.Phones != null && ud.Phones.Count() > 1) ? ud.Phones[1].Phone : String.Empty); ItemsToPopulateFromUAS.Add( "ADAP_C3_Phone2_MayMsgYN_item", (ud.Phones != null && ud.Phones.Count() > 1) ? ((ud.Phones[1].MayContactPhone) ? "1" : "0") : String.Empty); // * * * OT 1-20-16 updated this list based on Docs/ADAP/ADAP_item_list.xslx (revision 80734) string[] ItemIdentifiersToPopulateFromPrevApplication = new string[] { #region long list of item identifiers "ADAP_D1_LastName_item", "ADAP_D1_FirstName_item", "ADAP_D1_MiddleIntl_item", "ADAP_D1_AltName_item", "ADAP_D2_DOB_item", "ADAP_D3_White_item", "ADAP_D3_Black_item", "ADAP_D3_Asian_item", "ADAP_D3_Native_item", "ADAP_D3_Indian_item", "ADAP_D4_EthnicDrop_item", "ADAP_D4_Mexican_item", "ADAP_D4_Puerto_item", "ADAP_D4_Cuban_item", "ADAP_D4_Other_item", "ADAP_D5_Indian_item", "ADAP_D5_Filipino_item", "ADAP_D5_Korean_item", "ADAP_D5_Other_item", "ADAP_D5_Chinese_item", "ADAP_D5_Japanese_item", "ADAP_D5_Vietnamese_item", "ADAP_D5_NA_item", "ADAP_D6_Native_item", "ADAP_D6_Guam_item", "ADAP_D6_Samoan_item", "ADAP_D6_Other_item", "ADAP_D6_NA_item", "ADAP_D7_LangDrop_item", "ADAP_D7_LangOther_item", "ADAP_D8_CurrGenderDrop_item", "ADAP_D8_BirthGenderDrop_item", "ADAP_D9_Ramsell_item", "ADAP_D10_SSN_item", "ADAP_C1_Address_item", "ADAP_C1_City_item", "ADAP_C1_State_item", "ADAP_C1_Zip_item", "ADAP_C1_County_item", "ADAP_C1_MayContactYN_item", "ADAP_C2_SameAsMailing_item", "ADAP_C2_Address_item", "ADAP_C2_City_item", "ADAP_C2_State_item", "ADAP_C2_Zip_item", "ADAP_C2_County_item", "ADAP_C2_MayContactYN_item", "ADAP_C3_Phone1_Num_item", "ADAP_C3_Phone1_Type_item", "ADAP_C3_Phone1_MayMsgYN_item", "ADAP_C3_Phone2_Num_item", "ADAP_C3_Phone2_Type_item", "ADAP_C3_Phone2_MayMsgYN_item", "ADAP_C4_MayCallYN_item", "ADAP_C4_Name_item", "ADAP_C4_Phone_item", "ADAP_C4_KnowHivYN_item", "ADAP_C5_HasCaseMngrYN_item", "ADAP_C5_Mngr1_Name_item", "ADAP_C5_Mngr1_Clinic_item", "ADAP_C5_Mngr2_Name_item", "ADAP_C5_Mngr2_Clinic_item", "ADAP_C5_CanReferYN_item", "ADAP_M1_Month_item", "ADAP_M1_Year_item", "ADAP_M1_DiagnosisLoc_item", "ADAP_M2_ToldAIDS_item", "ADAP_M3_ToldHepC_item", "ADAP_M4_Clinic_item", "ADAP_I1_Med_Yes_item", "ADAP_I1_Med_Denied_item", "ADAP_I1_Med_No_item", "ADAP_I1_Med_Waiting_item", "ADAP_I1_Med_DontKnow_item", "ADAP_I1_DeniedReason_item", "ADAP_I1_NotAppliedReason_item", "ADAP_I2_AffCareOpt_item", "ADAP_I2_AffCareOther_item", "ADAP_I3_MedicareYN_item", "ADAP_I3_MedNumber_item", "ADAP_I3_PartAYN_item", "ADAP_I3_PartBYN_item", "ADAP_I3_PartADate_item", "ADAP_I3_PartBDate_item", "ADAP_H1_StatusDrop_item", "ADAP_H2_RelnDrop_item", "ADAP_H2_RelnOther_item", "ADAP_H3_FileTaxYN_item", "ADAP_H3_TaxStatusOpt_item", "ADAP_H3_TaxDependants_item", "ADAP_H3_TaxNotFileOpt_item", "ADAP_H3_TaxNotFileOther_item", "ADAP_H3_Relatives_item", "ADAP_H4_ChildrenIn_item", "ADAP_H4_ChildrenOut_item", "ADAP_F1_EmployOpt_item", "ADAP_F1_EmployOther_item", "ADAP_F1_EmployerInsOpt_item", "ADAP_F1_EmployNotEnrolled_item", "ADAP_F2_EmployLast90YN_item", "ADAP_F3_A_Recipient_item", "ADAP_F3_A_IncomeTypeDrop_item", "ADAP_F3_A_Employer_item", "ADAP_F3_A_EmployStart_item", "ADAP_F3_A_TempYN_item", "ADAP_F3_A_IncomeTypeOther_item", "ADAP_F3_A_IncomeAmt_item", "ADAP_F3_A_EmployerForm_item", "ADAP_F3_B_Recipient_item", "ADAP_F3_B_IncomeTypeDrop_item", "ADAP_F3_B_Employer_item", "ADAP_F3_B_EmployStart_item", "ADAP_F3_B_TempYN_item", "ADAP_F3_B_IncomeTypeOther_item", "ADAP_F3_B_IncomeAmt_item", "ADAP_F3_B_EmployerForm_item", "ADAP_F3_C_Recipient_item", "ADAP_F3_C_IncomeTypeDrop_item", "ADAP_F3_C_Employer_item", "ADAP_F3_C_EmployStart_item", "ADAP_F3_C_TempYN_item", "ADAP_F3_C_IncomeTypeOther_item", "ADAP_F3_C_IncomeAmt_item", "ADAP_F3_C_EmployerForm_item", "ADAP_F3_D_Recipient_item", "ADAP_F3_D_IncomeTypeDrop_item", "ADAP_F3_D_Employer_item", "ADAP_F3_D_EmployStart_item", "ADAP_F3_D_TempYN_item", "ADAP_F3_D_IncomeTypeOther_item", "ADAP_F3_D_IncomeAmt_item", "ADAP_F3_D_EmployerForm_item", "ADAP_cert_NoSharing_item", "ADAP_cert_Reminders_item" #endregion }; Applications appl = new Applications(formsRepo); def_FormResults frmRes = appl.CreateFormResultPopulatedFromUAS(SessionHelper.LoginStatus.EnterpriseID, SessionHelper.LoginStatus.GroupID, userId, frm.formId, ItemsToPopulateFromUAS); appl.PopulateItemsFromPrevApplication(frmRes, ItemIdentifiersToPopulateFromPrevApplication); frmRes.statusChangeDate = DateTime.Now; // Save the FormResult, ItemResults, and ResponseVariables int newFormResultId = 0; try { newFormResultId = formsRepo.AddFormResult(frmRes); } catch (Exception ex) { Debug.WriteLine("AddFormResult exception:" + ex.Message); } Debug.WriteLine("AddFormResult newFormResultId:" + newFormResultId.ToString()); // query the ramsell system and update the formResult responses based on Ramsell response def_ResponseVariables rvMemberId = formsRepo.GetResponseVariablesByFormResultIdentifier(newFormResultId, "ADAP_D9_Ramsell"); if (rvMemberId != null && !String.IsNullOrWhiteSpace(rvMemberId.rspValue)) { string memberId = rvMemberId.rspValue; string usrId = UAS.Business.UAS_Business_Functions.GetEntAppConfigAdap("USR"); string password = UAS.Business.UAS_Business_Functions.GetEntAppConfigAdap("PWD"); Debug.WriteLine("Ramsell UseriD / Password: "******" / " + password); string token = Ramsell.GetOauthToken(usrId, password); new RamsellImport(formsRepo, frmRes.formResultId).ImportApplication(token, memberId); } //AJBoggs.Adap.Services.Api.Ramsell.PopulateItemsFromRamsellImport(formsRepo, frmRes); if (SessionHelper.SessionForm == null) { SessionHelper.SessionForm = new SessionForm(); } SessionForm sf = SessionHelper.SessionForm; sf.formId = frm.formId; sf.formIdentifier = frm.identifier; sf.sectionId = formsRepo.GetSectionByIdentifier("ADAP_demographic").sectionId; sf.partId = formsRepo.GetPartByFormAndIdentifier(frm, "ADAP").partId; // *** RRB - should be deprecated - use SessionForm // *** BR - line 359 of the ResultsController calls this session variable, so it must be set to prevent an exception. // Other parts of the application may still use that variable, so changing it in the ResultsController may break something else. Session["part"] = sf.partId; // Should have the partId also - may not be required. sf.formResultId = newFormResultId; return(RedirectToAction("Template", "Results", new { sectionId = sf.sectionId.ToString() })); } else { return(RedirectToAction("AdapPortal", "COADAP", new { userId = userId, error = "Not Approved" })); } }
/* This method Saves data from the screen when the Submit button is clicked. * The concept is that we know which Section was last displayed from the session variables. * So we cycle through the ItemVariables and update the associated ResponseValues from the FormCollection of screen values. */ public ActionResult Save(FormCollection frmCllctn, Assmnts.Models.TemplateItems ti) { mLogger.Debug(" ResultController:Save"); Dictionary <string, string> previousResponseValues = SessionHelper.ResponseValues; if (previousResponseValues != null) { //Throw out responses that haven't changed foreach (var previousResponseKvp in previousResponseValues) { if (!string.IsNullOrWhiteSpace(previousResponseKvp.Key)) { var newResponseValue = frmCllctn.GetValue(previousResponseKvp.Key); //If the value is bool and it is now false (checkbox for example) it won't be sent back in the form collection //we need to test for bool and set these values to false (if they are true) var itemVariable = formsRepo.GetItemVariableByIdentifier(previousResponseKvp.Key); //itemVariable will often be null because all the PREVIOUS_ identifiers get sent through also var impliedBooleanFalseResult = false; if (newResponseValue == null && itemVariable != null && itemVariable.baseTypeId == Assmnts.Constants.CAADAP.BASE_TYPE_BOOLEAN) { newResponseValue = new ValueProviderResult("0", "0", CultureInfo.CurrentCulture); impliedBooleanFalseResult = true; } if (newResponseValue != null) { //Compare previous with posted values //Note if they are both null or both empty we want to throw it out if (newResponseValue.AttemptedValue == null && previousResponseKvp.Value == null) { frmCllctn.Remove(previousResponseKvp.Key); } else if (newResponseValue.AttemptedValue != null && previousResponseKvp.Value != null) { var previousResponseString = previousResponseKvp.Value; var newResponseString = newResponseValue.AttemptedValue; bool previousResponseTrue = false; bool previousResponseFalse = false; //If it's a bool, try to convert 'false' to '0' and so on if (previousResponseTrue = previousResponseString.Equals("true", StringComparison.InvariantCultureIgnoreCase) || (previousResponseFalse = previousResponseString.Equals("false", StringComparison.InvariantCultureIgnoreCase))) { if (itemVariable != null && itemVariable.baseTypeId == Assmnts.Constants.CAADAP.BASE_TYPE_BOOLEAN) { if (previousResponseFalse) { previousResponseString = "0"; } else if (previousResponseTrue) { previousResponseString = "1"; } } } if (newResponseString.Equals(previousResponseString)) { frmCllctn.Remove(previousResponseKvp.Key); } else if (impliedBooleanFalseResult) { //The values are different, but the form collection doesn't contain the result frmCllctn.Add(previousResponseKvp.Key, newResponseValue.AttemptedValue); } } } } } } // If User is not logged in, there are no session variables. // This prevents saving the formResultId if (!SessionHelper.IsUserLoggedIn) { return(RedirectToAction("Index", "Account", null)); } //check if the form is unchanged //bool unchanged = true; //foreach (string key in frmCllctn.Keys) //{ // HttpCookie oldVal = Request.Cookies["frmOriginal___" + key]; // if (oldVal != null && !frmCllctn[key].Trim().Equals(oldVal.Value.Replace("%0d%0a","").Trim())) // { // //mLogger.Debug("* * * ResultsController:SaveSectionItems changed key: \"" + key + "\", original value: \"" + Session["frmOriginal___" + key] + "\", new value: \"" + frmCllctn[key] + "\"" ); // unchanged = false; // break; // } //} bool unchanged = false; SessionForm sf = SessionHelper.SessionForm; if (unchanged || sf.readOnlyMode) { mLogger.Debug("* * * ResultsController:SaveSectionItems form is unchanged, skipping update"); } else { mLogger.Debug("* * * ResultsController:Save method * * * sectionId: {0}", sf.sectionId); // save responses to database //* * * OT 03/10/16 Switched to using AJBoggs\Def\Domain\UserData.SaveFormCollection.cs UserData ud = new UserData(formsRepo); ud.SaveFormCollection(frmCllctn, sf.sectionId, sf.formResultId); ud.SaveFileUploads(sf.formResultId, Request); def_FormResults formResult = formsRepo.GetFormResultById(sf.formResultId); formResult.LastModifiedByUserId = SessionHelper.LoginStatus.UserID; formResult.dateUpdated = DateTime.Now; // Update the assigned field in the formResults based on the data in the Interviewer field on idprof1. if (sf.sectionId == 1) { def_ItemVariables interviewerVar = formsRepo.GetItemVariableByIdentifier("sis_int_id"); if (interviewerVar != null) { def_ItemResults ir = formsRepo.GetItemResultByFormResItem(formResult.formResultId, interviewerVar.itemId); if (ir != null) { def_ResponseVariables rv = formsRepo.GetResponseVariablesByItemResultItemVariable(ir.itemResultId, interviewerVar.itemVariableId); if (rv != null && !String.IsNullOrEmpty(rv.rspValue)) { int rspInt; if (Int32.TryParse(rv.rspValue, out rspInt)) { formResult.assigned = rspInt; } else { mLogger.Error("Error converting response value {0} to int.", rv.rspValue); } } } } } formsRepo.Save(); //set status to "in progress" for SIS forms //if (sf.formIdentifier.Equals("SIS-A") || sf.formIdentifier.Equals("SIS-C")) //{ //if ( (fr.reviewStatus != ReviewStatus.APPROVED) && (fr.reviewStatus != ReviewStatus.REVIEWED) && (fr.reviewStatus != ReviewStatus.PRE_QA) ) //{ // fr.formStatus = (byte)FormResults_formStatus.IN_PROGRESS; // // this will be saved to the database in one of the scoring updates below //} //} bool isSisForm = sf.formIdentifier.Equals("SIS-A") || sf.formIdentifier.Equals("SIS-C"); //run single-section validation for sis forms if (isSisForm) { List <string> validationErrorMessages; bool ssValidationFailed = SisOneOffValidation.RunSingleSectionOneOffValidation( formsRepo, frmCllctn, sf.sectionId, out validationErrorMessages); if (ssValidationFailed) { return(Template(sf.sectionId, validationErrorMessages)); } //run full-assessment validation and update scores for completed SIS forms if (formResult.formStatus == (byte)FormResults_formStatus.COMPLETED || formResult.locked) { //if validation passes, it will trigger scoring automatically if (sf.sectionId != 504 && !ValidateFormResult(formResult)) // Section 504 is interview planning { //if validation fails set the form status to in-progress formsRepo.SetFormResultStatus(formResult, (byte)FormResults_formStatus.IN_PROGRESS); } } } } // string ctrl = "Results"; // if (frmCllctn.AllKeys.Contains("UseThisControllerForTemplate")) // ctrl = frmCllctn["UseThisControllerForTemplate"]; //debug runtime //TimeSpan duration = DateTime.Now - startTime; //using (StreamWriter sw = System.IO.File.AppendText(@"C:\Users\otessmer\Desktop\log.txt")) //{ // sw.WriteLine(duration.Milliseconds); //} // if necessary, redirect to a different section now that we've saved the results string navSectionId = String.Empty; if (frmCllctn.AllKeys.Contains("navSectionId")) { navSectionId = frmCllctn["navSectionId"]; if (!String.IsNullOrEmpty(navSectionId)) { if (navSectionId == "search") { return(RedirectToAction("Index", "Search", new { })); } if (navSectionId == "logout") { return(RedirectToAction("LogoutUAS", "Account")); } if (navSectionId == "new") { return(RedirectToAction("NewBlankAssessment", "Search", new { formId = SessionHelper.Read <int>("newFormId") })); } // Redirect subforms to the original parent page. if (navSectionId == "SubForm") { SessionForm psf = (SessionForm)Session["ParentFormData"]; return(RedirectToAction("ToTemplate", "Adap", new { formResultId = psf.formResultId, formId = psf.formId, partId = psf.partId, sectionIdOverride = psf.sectionId })); } // Must be a Form Part Section //Displays successful save message Session["part"] = frmCllctn["navPartId"]; Session["form"] = frmCllctn["navFormId"]; } } else { navSectionId = sf.sectionId.ToString(); } if (Session["IsPageLoad"] != null) { } if (navSectionId == "703") { TempData["Savemsg"] = "Contact info save successful"; TempData["SavemsgHeader"] = "Saved"; } else if (navSectionId == "704") { TempData["Savemsg"] = "Demographics info save successful"; TempData["SavemsgHeader"] = "Saved"; } else if (navSectionId == "705") { TempData["Savemsg"] = "Clinical info save successful"; TempData["SavemsgHeader"] = "Saved"; } else if (navSectionId == "706") { TempData["Savemsg"] = "Health Coverage info save successful"; TempData["SavemsgHeader"] = "Saved"; } else if (navSectionId == "726") { TempData["Savemsg"] = "Income info save successful"; TempData["SavemsgHeader"] = "Saved"; } else if (navSectionId == "732") { TempData["Savemsg"] = "Insurance Assistance info save successful"; TempData["SavemsgHeader"] = "Saved"; } else if (navSectionId == "734") { TempData["Savemsg"] = "Attachment info save successful"; TempData["SavemsgHeader"] = "Saved"; } else if (navSectionId == "753") { TempData["Savemsg"] = "Medical Out of Pocket info save successful"; TempData["SavemsgHeader"] = "Saved"; } else if (navSectionId == "708") { TempData["Savemsg"] = "Consent&Submit info save successful"; TempData["SavemsgHeader"] = "Saved"; } else if (navSectionId == "756") { TempData["Savemsg"] = "Eligibility info save successful"; TempData["SavemsgHeader"] = "Saved"; } else if (navSectionId == "759") { TempData["Savemsg"] = "SVF info save successful"; TempData["SavemsgHeader"] = "Saved"; } else { TempData["Savemsg"] = ""; TempData["SavemsgHeader"] = ""; } if (sf.sectionId == 708) { def_FormResults formResult = formsRepo.GetFormResultById(sf.formResultId); IEnumerable <def_FormResults> frElgList = formsRepo.GetFormResultsByFormSubject(18, formResult.subject); var adapCaController = new AdapCaController(formsRepo); if (!frElgList.Any()) { adapCaController.CreateElgibility(sf.formResultId); } adapCaController.CopyToEligibility("C1_FormSubmitEnrollmentSiteName", "C1_MemberSelectedEnrollmentSite", formResult.formResultId, formResult.subject.Value); formsRepo.Save(); } //$$ Start of people Picker V2 Functionality PeoplePickerHelper objUtility = new PeoplePickerHelper(authClient, formsRepo); objUtility.SaveresultsForEnWrkerPicker(sf.sectionId, sf.formResultId); //$$ End of people Picker V2 Functionality var redirect = frmCllctn["navRedirect"]; if (!string.IsNullOrWhiteSpace(redirect)) { return(Redirect(redirect)); } else { return(RedirectToAction("Template", "Results", new { sectionId = navSectionId })); } }
public ActionResult Index() { Session["userId"] = "0"; Debug.WriteLine("* * * ExportController:Index method * * *"); // Initialize the session variables SessionForm sf = (SessionForm)Session["sessionForm"]; if (sf == null) { sf = new SessionForm() { formId = 0, partId = 0, sectionId = 0, formResultId = 0 }; Session["sessionForm"] = sf; } // Display the formResults (Assessments) Assmnts.Models.FormResults frmRsltsMdl = new Assmnts.Models.FormResults(); frmRsltsMdl.formResults = new List <def_FormResults>(); foreach (def_Forms frm in formsRepo.GetAllForms()) { frmRsltsMdl.formResults.AddRange(formsRepo.GetFormResultsByFormId(frm.formId)); } //frmRsltsMdl.formResults = formsRepo.GetAllFormResults(); bool noFormResults = false; if (frmRsltsMdl.formResults.Count() == 0) { Debug.WriteLine("* * * Index FormResults Count was 0. "); noFormResults = true; def_FormResults frmRslts = new def_FormResults() { formResultId = 0, formId = 0, dateUpdated = System.DateTime.Now }; frmRsltsMdl.formResults.Add(frmRslts); } else { Debug.WriteLine("* * * Index FormResults count: " + frmRsltsMdl.formResults.Count().ToString()); } frmRsltsMdl.formTitles = new List <String>(); if (noFormResults) { frmRsltsMdl.formTitles.Add("There are no Assessments in the system."); } else { foreach (def_FormResults frmRslt in frmRsltsMdl.formResults) { def_Forms frm = formsRepo.GetFormById(frmRslt.formId); if (frm != null) { frmRsltsMdl.formTitles.Add(frm.title); } } } return(View("formResults", frmRsltsMdl)); }
public ActionResult GoAction(FormCollection formCollection) { string recId = formCollection["recId"]; string paramFormResultId = formCollection["sisId"]; string paramFormId = formCollection["formId"]; string category = formCollection["CategoryID"]; SearchModel model = new SearchModel(); if (SessionHelper.SessionForm == null) { // return RedirectToAction("Index", "Search", null); SessionHelper.SessionForm = new SessionForm(); } SessionForm sf = SessionHelper.SessionForm; if (String.IsNullOrWhiteSpace(category)) { return(RedirectToAction("Index", "Search")); } else if (category.ToLower().Equals("edit") && model.edit) { // retrieve and set SessionForm params sf.formId = Convert.ToInt32(paramFormId); sf.formResultId = Convert.ToInt32(paramFormResultId); def_FormResults formResult = formsRepo.GetFormResultById(sf.formResultId); if (!formResult.locked || (formResult.locked && model.editLocked)) { // get the sectionId of the first section of the first part based on the formId def_Forms frm = formsRepo.GetFormById(sf.formId); def_Parts prt = formsRepo.GetFormParts(frm)[0]; sf.partId = prt.partId; Session["part"] = prt.partId; def_Sections sct = formsRepo.GetSectionsInPart(prt)[0]; if (ventureMode == false) { AccessLogging.InsertAccessLogRecord(formsRepo, sf.formResultId, (int)AccessLogging.accessLogFunctions.EDIT, "Initiate editing of assessment."); } return(RedirectToAction("Template", "Results", new { sectionId = sct.sectionId.ToString(), partId = sf.partId.ToString() })); } } else if (category.ToLower().Equals("review")) { // retrieve and set SessionForm params sf.formId = Convert.ToInt32(paramFormId); sf.formResultId = Convert.ToInt32(paramFormResultId); def_FormResults formResult = formsRepo.GetFormResultById(sf.formResultId); if (model.editLocked) { if (ventureMode == false) { AccessLogging.InsertAccessLogRecord(formsRepo, sf.formResultId, (int)AccessLogging.accessLogFunctions.REVIEW, "Assessment accessed for review."); } if (model.unlock == true) { formsRepo.LockFormResult(formResult.formResultId); } if (formResult.reviewStatus != (int)ReviewStatus.REVIEWED && formResult.reviewStatus != (int)ReviewStatus.APPROVED && formResult.reviewStatus != (int)ReviewStatus.PRE_QA) { def_FormResults preQAcopy = AssessmentCopy.CopyAssessment(formsRepo, formResult.formResultId); if (WebServiceActivity.IsWebServiceEnabled()) { WebServiceActivity.CallWebService(formsRepo, (int)WebServiceActivity.webServiceActivityFunctions.REVIEW, "formResultId=" + preQAcopy.formResultId.ToString()); } } ReviewStatus.ChangeStatus(formsRepo, formResult, ReviewStatus.REVIEWED, "Initiate review of assessment"); // get the sectionId of the first section of the first part based on the formId def_Forms frm = formsRepo.GetFormById(sf.formId); def_Parts prt = formsRepo.GetFormParts(frm)[0]; sf.partId = prt.partId; Session["part"] = prt.partId; def_Sections sct = formsRepo.GetSectionsInPart(prt)[0]; return(RedirectToAction("Template", "Results", new { sectionId = sct.sectionId.ToString(), partId = sf.partId.ToString() })); } } else if (category.ToLower().Equals("approve")) { // retrieve and set SessionForm params sf.formId = Convert.ToInt32(paramFormId); sf.formResultId = Convert.ToInt32(paramFormResultId); def_FormResults formResult = formsRepo.GetFormResultById(sf.formResultId); if (model.editLocked) { ReviewStatus.ChangeStatus(formsRepo, formResult, ReviewStatus.APPROVED, "Approve review of assessment"); if (WebServiceActivity.IsWebServiceEnabled()) { WebServiceActivity.CallWebService(formsRepo, (int)WebServiceActivity.webServiceActivityFunctions.APPROVE, "formResultId=" + formResult.formResultId.ToString()); } } } else if (category.ToLower().Equals("create")) { if (model.create == true) { string formId = String.IsNullOrEmpty(paramFormId) ? "1" : paramFormId; def_FormResults frmRes = FormResults.CreateNewFormResultFull(formId, SessionHelper.LoginStatus.EnterpriseID.ToString(), SessionHelper.LoginStatus.appGroupPermissions[0].groupPermissionSets[0].GroupID.ToString(), recId, SessionHelper.LoginStatus.UserID.ToString() ); string strFormResultId = String.Empty; try { int formRsltId = formsRepo.AddFormResult(frmRes); strFormResultId = formRsltId.ToString(); Debug.WriteLine("GoAction create FormResultId strFormResultId:" + strFormResultId); } catch (Exception excptn) { Debug.WriteLine("GoAction Defws.CreateNewFormResultFull formsRepo.AddFormResult exception:" + excptn.Message); Debug.WriteLine(" GoAction formId:" + formId + " entId: " + SessionHelper.LoginStatus.EnterpriseID.ToString() + " GroupId: " + SessionHelper.LoginStatus.appGroupPermissions[0].groupPermissionSets[0].GroupID.ToString() + " recId: " + recId.ToString() + " UserId: " + SessionHelper.LoginStatus.UserID.ToString() ); } if ((!String.IsNullOrEmpty(strFormResultId)) && !String.IsNullOrEmpty(recId)) { int intRecId; if (int.TryParse(recId, out intRecId)) { using (var context = DataContext.getSisDbContext()) { // Contact tempContact = new Contact(); Contact tempContact = (from c in context.Contacts where c.ContactID == intRecId select c).FirstOrDefault(); // Address tempAddress = new Address(); Address tempAddress = (from a in context.Addresses where (a.ContactID == tempContact.ContactID) && (a.AddressType == "R") select a).FirstOrDefault(); Dictionary <string, string> responsesByIdentifier = new Dictionary <string, string>(); responsesByIdentifier.Add("sis_cl_first_nm", tempContact.FirstName); responsesByIdentifier.Add("sis_cl_last_nm", tempContact.LastName); if (tempAddress != null) { responsesByIdentifier.Add("sis_cl_addr_line1", tempAddress.Address1); responsesByIdentifier.Add("sis_cl_city", tempAddress.City); responsesByIdentifier.Add("sis_cl_st", tempAddress.StateCode); responsesByIdentifier.Add("sis_cl_zip", tempAddress.Zip); } string msg = formsRepo.CreateNewResponseValues(strFormResultId, responsesByIdentifier); Debug.WriteLine("GoAction CreateNewResponseValues strFormResultId: " + strFormResultId + " msg: " + msg); } } // Retrieve and set SessionForm params sf.formId = 1; // Temporary sf.formResultId = Convert.ToInt32(strFormResultId); // Get the sectionId of the first section of the first part based on the formId def_Forms frm = formsRepo.GetFormById(sf.formId); def_Parts prt = formsRepo.GetFormParts(frm)[0]; sf.partId = prt.partId; Session["part"] = prt.partId; def_Sections sct = formsRepo.GetSectionsInPart(prt)[0]; return(RedirectToAction("Template", "Results", new { sectionId = sct.sectionId.ToString(), partId = sf.partId.ToString() })); } } } else if (category.ToLower().Equals("delete")) { if (model.delete == true) { formsRepo.FormResultDeleteLogically(Convert.ToInt32(paramFormResultId)); if (ventureMode == false) { AccessLogging.InsertAccessLogRecord(formsRepo, Convert.ToInt32(paramFormResultId), (int)AccessLogging.accessLogFunctions.DELETE, "Delete assessment."); } if (ventureMode == false && WebServiceActivity.IsWebServiceEnabled()) { WebServiceActivity.CallWebService(formsRepo, (int)WebServiceActivity.webServiceActivityFunctions.DELETE, "formResultId=" + paramFormResultId); def_FormResults preQAcopy = ReviewStatus.GetLatestPreQACopy(formsRepo, Convert.ToInt32(paramFormResultId)); if (preQAcopy != null) { formsRepo.FormResultDeleteLogically(preQAcopy.formResultId); WebServiceActivity.CallWebService(formsRepo, (int)WebServiceActivity.webServiceActivityFunctions.DELETE, "formResultId=" + preQAcopy.formResultId.ToString()); } } } } else if (category.ToLower().Equals("lock")) { if (model.unlock == true) { formsRepo.LockFormResult(Convert.ToInt32(paramFormResultId)); } } else if (category.ToLower().Equals("unlock")) { if (model.unlock == true) { formsRepo.UnlockFormResult(Convert.ToInt32(paramFormResultId)); } } else if (category.ToLower().Equals("archive")) { if (model.archive == true) { formsRepo.ArchiveFormResult(Convert.ToInt32(paramFormResultId)); if (ventureMode == false) { AccessLogging.InsertAccessLogRecord(formsRepo, Convert.ToInt32(paramFormResultId), (int)AccessLogging.accessLogFunctions.ARCHIVE, "Archive assessment."); } } } else if (category.ToLower().Equals("unarchive")) { if (model.archive == true) { formsRepo.UnarchiveFormResult(Convert.ToInt32(paramFormResultId)); if (ventureMode == false) { AccessLogging.InsertAccessLogRecord(formsRepo, Convert.ToInt32(paramFormResultId), (int)AccessLogging.accessLogFunctions.UNARCHIVE, "Unarchive assessment."); } } } else if (category.ToLower().Equals("upload")) { def_FormResults fr = formsRepo.GetFormResultById(Convert.ToInt32(paramFormResultId)); if (fr.formStatus == (byte)FormResults_formStatus.COMPLETED) { SessionHelper.Write("uploadFormResultId", Convert.ToInt32(paramFormResultId)); return(RedirectToAction("UploadSingle", "DataSync")); } } else if (category.ToLower().Equals("undelete")) { if (model.undelete == true) { formsRepo.FormResultUndelete(Convert.ToInt32(paramFormResultId)); if (ventureMode == false) { AccessLogging.InsertAccessLogRecord(formsRepo, Convert.ToInt32(paramFormResultId), (int)AccessLogging.accessLogFunctions.UNDELETE, "Undelete assessment."); } } } else if (category.ToLower().Equals("planning") && model.edit) { // retrieve and set SessionForm params sf.formId = Convert.ToInt32(paramFormId); sf.formResultId = Convert.ToInt32(paramFormResultId); def_FormResults formResult = formsRepo.GetFormResultById(sf.formResultId); if (!formResult.locked || (formResult.locked && model.editLocked)) { // get the sectionId of the first section of the first part based on the formId def_Forms frm = formsRepo.GetFormById(sf.formId); def_Parts prt = formsRepo.GetPartByFormAndIdentifier(frm, "Other"); sf.partId = prt.partId; Session["part"] = prt.partId; def_Sections sct = formsRepo.GetSectionsInPart(prt)[0]; if (ventureMode == false) { AccessLogging.InsertAccessLogRecord(formsRepo, sf.formResultId, (int)AccessLogging.accessLogFunctions.EDIT, "Initiate editing of interview planning."); } return(RedirectToAction("Template", "Results", new { sectionId = sct.sectionId.ToString(), partId = sf.partId.ToString() })); } } return(RedirectToAction("Index", "Search")); }
public void Add(SessionForm newItem) { List.Add(newItem); }
public void SetItem(int Index, SessionForm Item) { List[Index] = Item; }
public static TemplateSisNavMenu getSisNavMenuModel(SessionForm sf, TemplateItems parent, IFormsRepository formsRepo) { TemplateSisNavMenu result = new TemplateSisNavMenu(formsRepo); if (SessionHelper.LoginStatus.appGroupPermissions[0].groupPermissionSets.Count() > 0) { result.create = UAS_Business_Functions.hasPermission(SessionHelper.LoginStatus.appGroupPermissions[0].groupPermissionSets[0].PermissionSet, UAS.Business.PermissionConstants.CREATE, UAS.Business.PermissionConstants.ASSMNTS); result.unlock = UAS_Business_Functions.hasPermission(SessionHelper.LoginStatus.appGroupPermissions[0].groupPermissionSets[0].PermissionSet, UAS.Business.PermissionConstants.UNLOCK, UAS.Business.PermissionConstants.ASSMNTS); result.delete = UAS_Business_Functions.hasPermission(SessionHelper.LoginStatus.appGroupPermissions[0].groupPermissionSets[0].PermissionSet, UAS.Business.PermissionConstants.DELETE, UAS.Business.PermissionConstants.ASSMNTS); result.archive = UAS_Business_Functions.hasPermission(SessionHelper.LoginStatus.appGroupPermissions[0].groupPermissionSets[0].PermissionSet, UAS.Business.PermissionConstants.ARCHIVE, UAS.Business.PermissionConstants.ASSMNTS); result.undelete = UAS_Business_Functions.hasPermission(SessionHelper.LoginStatus.appGroupPermissions[0].groupPermissionSets[0].PermissionSet, UAS.Business.PermissionConstants.UNDELETE, UAS.Business.PermissionConstants.ASSMNTS); } result.parent = parent; result.ventureMode = SessionHelper.IsVentureMode; result.forms = Assmnts.Business.Forms.GetFormsDictionary(formsRepo); try { def_Forms frm = formsRepo.GetFormById(sf.formId); result.assmntTitle = frm.title; result.currentUser = SessionHelper.LoginInfo.LoginID; result.sectionsByPart = new Dictionary <def_Parts, List <def_Sections> >(); foreach (def_Parts prt in formsRepo.GetFormParts(frm)) { result.sectionsByPart.Add(prt, formsRepo.GetSectionsInPart(prt)); } } catch (Exception xcptn) { Debug.WriteLine("TemplateMenus getSisNavMenuModel get form, parts, sections exception: " + xcptn.Message); throw; } // LK -- 3/26/15 - #12497 Changed header tracking ID to display tracking ID instead of SIS ID // RRB - 9/8/2015 - refactored to handle empty or null sis_track_num // This is all custom SIS code and needs to be moved somewhere else. try { result.trackingNumber = String.Empty; // Default to blank def_ItemVariables trackIV = formsRepo.GetItemVariableByIdentifier("sis_track_num"); if (trackIV != null) { def_ResponseVariables trackRV = formsRepo.GetResponseVariablesByFormResultItemVarId(sf.formResultId, trackIV.itemVariableId); if (trackRV != null) { if (!String.IsNullOrEmpty(trackRV.rspValue)) { result.trackingNumber = trackRV.rspValue; } } } } catch (Exception xcptn) { Debug.WriteLine("SisTemplatesController getSisNavMenuModel trackingNumber exception: " + xcptn.Message); throw; } // BR - added to include the recipient's name on the form when applicable. try { result.recipientName = String.Empty; // Default to blank def_ItemVariables fNameIV = formsRepo.GetItemVariableByIdentifier("sis_cl_first_nm"); def_ItemVariables lNameIV = formsRepo.GetItemVariableByIdentifier("sis_cl_last_nm"); if (fNameIV != null) { def_ResponseVariables fNameRV = formsRepo.GetResponseVariablesByFormResultItemVarId(sf.formResultId, fNameIV.itemVariableId); if (fNameRV != null) { if (!String.IsNullOrEmpty(fNameRV.rspValue)) { result.recipientName = fNameRV.rspValue; } } } if (lNameIV != null) { def_ResponseVariables lNameRV = formsRepo.GetResponseVariablesByFormResultItemVarId(sf.formResultId, lNameIV.itemVariableId); if (lNameRV != null) { if (!String.IsNullOrEmpty(lNameRV.rspValue)) { if (!String.IsNullOrEmpty(result.recipientName)) { result.recipientName += " "; } result.recipientName += lNameRV.rspValue; } } } } catch (Exception xcptn) { Debug.WriteLine("TemplateMenus getSisNavMenuModel trackingNumber exception: " + xcptn.Message); throw; } return(result); }