//private static void AddHiddenField(IFormsRepository formsRepo, def_FormResults formResult, string fieldName, string value) //{ // int itemId = formsRepo.GetItemByIdentifier(SIS_HIDDEN).itemId; // def_ItemResults itemResult = formsRepo.GetItemResultByFormResItem(formResult.formResultId, itemId); // def_ResponseVariables relatedFormResultRV = null; // try // { // relatedFormResultRV = formsRepo.GetResponseVariablesByFormResultIdentifier(formResult.formResultId, fieldName); // } // catch (Exception ex) // { // Console.WriteLine(ex.Message); // } // def_ItemVariables itemVariableRelated = formsRepo.GetItemVariableByIdentifier(fieldName); // if (itemVariableRelated != null) // { // if (relatedFormResultRV != null) // { // relatedFormResultRV.rspValue = value; // formsRepo.ConvertValueToNativeType(itemVariableRelated, relatedFormResultRV); // } // else // { // relatedFormResultRV = new def_ResponseVariables(); // relatedFormResultRV.itemResultId = itemResult.itemResultId; // relatedFormResultRV.itemVariableId = itemVariableRelated.itemVariableId; // relatedFormResultRV.rspValue = value; // formsRepo.ConvertValueToNativeType(itemVariableRelated, relatedFormResultRV); // formsRepo.AddResponseVariableNoSave(relatedFormResultRV); // } // } // formsRepo.Save(); //} private static void CopyAssessmentData(IFormsRepository formsRepo, int oldFormResultId, def_FormResults copyFormResult) { try { IUasSql uasSql = new UasSql(); using (DbConnection connection = new SqlConnection(uasSql.GetConnectionString())) { connection.Open(); using (DbCommand command = connection.CreateCommand()) { command.CommandText = "SELECT IR.itemId, RV.itemVariableId, RV.rspValue from def_ItemResults IR JOIN def_FormResults FR on FR.formResultId = IR.formResultId JOIN def_ResponseVariables RV on RV.itemResultId = IR.itemResultId WHERE FR.formResultId = " + oldFormResultId + " ORDER BY itemId"; command.CommandType = CommandType.Text; DataTable dt = new DataTable(); dt.Load(command.ExecuteReader()); if (dt != null) { SaveAssessmentFromDataTable(formsRepo, copyFormResult, dt); } } } } catch (Exception ex) { Debug.WriteLine("* * * CreateFormResultJSON exception: " + ex.Message); } }
/// <summary> /// Used by the create application method to populate the application with data pulled from Ramsell /// this uses the ramsellId from within the formResult's responses, /// so applications that do not have a response to the RamsellId item will not be effected by this function /// </summary> /// <param name="frmRes">Form result for the application to populate</param> public static void PopulateItemsFromRamsellImport(IFormsRepository formsRepo, def_FormResults frmRes) { //get rammsellId (or terminate) string ramsellMemberId = String.Empty; def_ResponseVariables rv = formsRepo.GetResponseVariablesByFormResultIdentifier(frmRes.formResultId, "ADAP_D9_Ramsell"); if (rv != null) { ramsellMemberId = rv.rspValue; } if (String.IsNullOrWhiteSpace(ramsellMemberId)) { Debug.WriteLine("* * * AdapController.PopulateItemsFromRamsellImport: no RamsellId/MemberId present in formResult " + frmRes.formResultId + ", skipping Ramsell import..."); return; } //get oauth token // string usrId = "38222218"; // string password = @"P@ssw0rd"; 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 oauthToken = Ramsell.GetOauthToken(usrId, password); new RamsellImport(formsRepo, frmRes.formResultId).ImportApplication(oauthToken, ramsellMemberId); }
public static void LogStatusChange(IFormsRepository formsRepo, int formResultId, def_StatusDetail from, def_StatusDetail to, string note) { def_StatusLog statusChangeLog = new def_StatusLog(); statusChangeLog.formResultId = formResultId; if (from != null) { statusChangeLog.statusDetailIdFrom = from.statusDetailId; } if (to != null) { statusChangeLog.statusDetailIdTo = to.statusDetailId; } statusChangeLog.statusLogDate = DateTime.Now; statusChangeLog.UserID = SessionHelper.LoginStatus.UserID; statusChangeLog.statusNote = note; try { formsRepo.AddStatusLog(statusChangeLog); } catch (Exception ex) { Console.WriteLine("Error adding status log: " + ex.Message); } }
public static def_FormResults CopyAssessment(IFormsRepository formsRepo, int formResultId) { def_FormResults oldFormResult = formsRepo.GetFormResultById(formResultId); def_FormResults copyFormResult = new def_FormResults(); copyFormResult.archived = oldFormResult.archived; copyFormResult.assigned = oldFormResult.assigned; copyFormResult.dateUpdated = oldFormResult.dateUpdated; copyFormResult.deleted = oldFormResult.deleted; copyFormResult.EnterpriseID = oldFormResult.EnterpriseID; copyFormResult.formId = oldFormResult.formId; copyFormResult.formStatus = oldFormResult.formStatus; copyFormResult.GroupID = oldFormResult.GroupID; copyFormResult.interviewer = oldFormResult.interviewer; copyFormResult.locked = oldFormResult.locked; copyFormResult.reviewStatus = oldFormResult.reviewStatus; copyFormResult.sessionStatus = oldFormResult.sessionStatus; copyFormResult.statusChangeDate = oldFormResult.statusChangeDate; copyFormResult.subject = oldFormResult.subject; copyFormResult.training = oldFormResult.training; formsRepo.AddFormResultNoSave(copyFormResult); CopyAssessmentData(formsRepo, oldFormResult.formResultId, copyFormResult); formsRepo.Save(); ReviewStatus.ChangeStatus(formsRepo, copyFormResult, ReviewStatus.PRE_QA, "Pre-QA copy created"); AddHiddenFields(formsRepo, oldFormResult, copyFormResult); return(copyFormResult); }
public static void UpdateSisAScores(IFormsRepository formsRepo, int formResultId) { try { def_Forms frm = formsRepo.GetFormByIdentifier("SIS-A"); int standardScoreTotal = SharedScoring.UpdateSisScoresNoSave ( formsRepo, frm, formResultId, getSisASubscaleCatagories(), (int totalRawScore, double avgRawScore, SubscaleCatagory cat) => { return(GetSisASubscaleStandardScore(totalRawScore, cat)); }, (int totalRawScore, double avgRawScore, SubscaleCatagory cat) => { return(GetSisASubscalePercentile(totalRawScore, cat)); } ); //save standard scores to database int compositeIndex = GetSisASupportNeedsIndex(standardScoreTotal); int compositePercentile = GetSisASupportNeedsPercentile(standardScoreTotal); SharedScoring.UpdateScoreResponseNoSave(formsRepo, formResultId, "scr_support_needs_index", compositeIndex); SharedScoring.UpdateScoreResponseNoSave(formsRepo, formResultId, "scr_sni_percentile_rank", compositePercentile); formsRepo.Save(); } catch (Exception xcptn) { Debug.WriteLine("UpdateSisAScores exception: " + xcptn.Message); } }
public ResultsController(ILogger logger, IFormsRepository fr, IAuthentication auth) { // Initiialized by Infrastructure.Ninject formsRepo = fr; mLogger = logger; authClient = auth; }
public static int ComputeClientAgeInYears(IFormsRepository formsRepo, int formResultId) { def_ResponseVariables dobRV = formsRepo.GetResponseVariablesByFormResultIdentifier(formResultId, "sis_cl_dob_dt"); if (dobRV == null) { throw new Exception("could not find date-of-birth response variable with identifier \"sis_cl_dob_dt\" under formResultId " + formResultId); } def_ResponseVariables dintRV = formsRepo.GetResponseVariablesByFormResultIdentifier(formResultId, "sis_completed_dt"); if (dintRV == null) { throw new Exception("could not find interview-date response variable with identifier \"sis_completed_dt\" under formResultId " + formResultId); } AssertRVHasDate(dobRV); AssertRVHasDate(dintRV); //http://stackoverflow.com/a/4127396 DateTime dob = dobRV.rspDate.Value; DateTime intDate = dintRV.rspDate.Value; DateTime zeroTime = new DateTime(1, 1, 1); TimeSpan span = intDate - dob; return((zeroTime + span).AddDays(-1).Year - 1); }
public static void UpdateSisCScores(IFormsRepository formsRepo, int formResultId, int ageInYears) { def_Forms frm = formsRepo.GetFormByIdentifier("SIS-C"); SharedScoring.UpdateSisScoresNoSave ( formsRepo, frm, formResultId, getSisCSubscaleCatagories(), (int totalRawScore, double avgRawScore, SubscaleCatagory cat) => { return(GetSisCSubscaleStandardScore(avgRawScore, cat, ageInYears)); }, (int totalRawScore, double avgRawScore, SubscaleCatagory cat) => { return(GetSisCSubscalePercentile(avgRawScore, cat, ageInYears)); } ); def_ResponseVariables rv = formsRepo.GetResponseVariablesByFormResultIdentifier(formResultId, "scr_total_rating"); double totalRating = Convert.ToDouble(rv.rspValue); double meanRating = Math.Round(totalRating / 7, 2); //usd only for SIS-C reports //save standard scores to database double compositeIndex = GetSisCSupportNeedsIndex(meanRating, ageInYears); double compositePercentile = GetSisCSupportNeedsPercentile(meanRating, ageInYears); SharedScoring.UpdateScoreResponseNoSave(formsRepo, formResultId, "scr_support_needs_index", compositeIndex); SharedScoring.UpdateScoreResponseNoSave(formsRepo, formResultId, "scr_sni_percentile_rank", compositePercentile); formsRepo.Save(); }
/// <summary> /// Allows the attachment of database records or other types of information which DO NOT require saving to the file system. /// Be aware the distinct displayText class expects the RelatedId and RelatedEnumId to form a unique key. /// </summary> /// <param name="formsRepo"> IFormsRepository necessary for database access.</param> /// <param name="RelatedId">Identifier used to associate a file with a record type.</param> /// <param name="fa">FileAttachment record to be recorded.</param> /// <returns></returns> public static int CreateDataAttachment(IFormsRepository formsRepo, int RelatedId, def_FileAttachment fa) { int fileId = -1; Debug.WriteLine("FileUploads CreateDataAttachment FileName: " + fa.FileName); if (!string.IsNullOrEmpty(fa.FilePath)) { def_FileAttachment faQuery = formsRepo.GetFileAttachment(RelatedId, fa.RelatedEnumId, fa.FilePath); if (faQuery == null) { fileId = formsRepo.AddFileAttachment(fa); } else { formsRepo.UpdateFileAttachment(fa); fileId = fa.FileId; } } else { Debug.WriteLine("FileUploads CreateAttachment Error: File not saved."); } return(fileId); }
public SearchController(IFormsRepository fr) { // Initiialized by Infrastructure.Ninject formsRepo = fr; ventureMode = SessionHelper.IsVentureMode; }
/* * Constructor */ public Def3MaintController(IFormsRepository fr) { formsRepo = fr; lookupModel = new ExpandoObject(); lookupModel.baseTypes = fr.GetBaseTypes(); lookupModel.languages = formsRepo.GetAllLanguages(); }
internal static void CallWebService(IFormsRepository formsRepo, int activityId, string activityParamaters) { bool requestFailed = true; string requestServiceMsg = "Web service not yet implemented"; DateTime?dateTimeServiced = null; string sentBy = null; //InsertWebServiceActivityRecord(formsRepo, activityId, activityParamaters, requestFailed, requestServiceMsg, dateTimeServiced, sentBy); }
/// <summary> /// Adds a new record, or Updates an existing record, to the def_FileAttachment table, then saves the file in the file system. Files in the same directory with the same name /// will be overwritten without warning. Use of sub-directories can prevent this. /// </summary> /// <param name="formsRepo"> IFormsRepository necessary for database access.</param> /// <param name="fileStream">input stream containing the contents of the attachment file</param> /// <param name="originalFileName">the original filename of the attachment file</param> /// <param name="subDir">Optional superDirectory name, set to null to disable.</param> /// <param name="subDir">Optional subDirectory name, set to null to disable.</param> /// <param name="RelatedId">Identifier used to associate a file with a record type.</param> /// <param name="RelatedEnumId">Type of identifier used in RelatedId.</param> /// <param name="AttachTypeId">Indicates how the file was attached, which may represent the file itself or just a generic type.</param> /// <returns>Int value of the FileId</returns> public static int CreateAttachment(IFormsRepository formsRepo, Stream fileStream, string originalFileName, string superDir, string subDir, int RelatedId, int RelatedEnumId, int AttachTypeId) { int fileId = -1; if (fileStream != null && !String.IsNullOrEmpty(originalFileName.Trim())) { Debug.WriteLine("FileUploads CreateAttachment FileName: " + originalFileName); // Save the file to the file system. string fileName = SaveUpload(fileStream, Path.GetFileName(originalFileName), subDir, RelatedId, superDir); if (!String.IsNullOrEmpty(fileName)) { // Append the sub directory and the file name if sub directory has a value. String subFileName = (!String.IsNullOrEmpty(subDir)) ? subDir + Path.DirectorySeparatorChar + fileName.Substring(fileName.LastIndexOf(Path.DirectorySeparatorChar) + 1) : fileName.Substring(fileName.LastIndexOf(Path.DirectorySeparatorChar) + 1); def_FileAttachment fa = formsRepo.GetFileAttachment(RelatedId, RelatedEnumId, subFileName); if (fa == null) { fa = new def_FileAttachment(); fa.EnterpriseId = SessionHelper.LoginStatus.EnterpriseID; //fa.GroupId = SessionHelper.LoginStatus.GroupID; //LoginStatus was returning an invalid number for GroupId fa.UserId = SessionHelper.LoginStatus.UserID; fa.AttachTypeId = AttachTypeId; fa.RelatedId = RelatedId; fa.RelatedEnumId = RelatedEnumId; fa.displayText = fileName.Substring(fileName.LastIndexOf(Path.DirectorySeparatorChar) + 1); fa.FilePath = fileName; fa.FileName = subFileName; fa.StatusFlag = "A"; fa.CreatedDate = DateTime.Now; fa.CreatedBy = SessionHelper.LoginStatus.UserID; fileId = formsRepo.AddFileAttachment(fa); } else { fa.FilePath = fileName; fa.FileName = subFileName; fa.StatusFlag = "A"; formsRepo.UpdateFileAttachment(fa); fileId = fa.FileId; } } else { Debug.WriteLine("FileUploads CreateAttachment Error: File not saved."); } } else { Debug.WriteLine("FileUploads CreateAttachment Error: File not found."); } return(fileId); }
private void MarkAllLookupsInactive(int lookupMasterId, int enterpriseId, IFormsRepository formsRepo) { List <def_LookupDetail> lookupDetails = formsRepo.GetLookupDetailsByLookupMasterEnterprise(lookupMasterId, enterpriseId); foreach (def_LookupDetail detail in lookupDetails) { detail.StatusFlag = "I"; formsRepo.SaveLookupDetail(detail); } }
private static List <def_Sections> getTopLevelSectionsInForm(int formId, IFormsRepository formsRepo) { List <def_Sections> result = new List <def_Sections>(); foreach (def_FormParts fp in formsRepo.GetFormPartsByFormId(formId)) { result.AddRange(formsRepo.GetSectionsInPartById(fp.partId)); } return(result); }
public AdapLAStubApp(IFormsRepository fr) { formsRepo = fr; auth = new AuthenticationClient(); stubForm = formsRepo.GetFormByIdentifier(stubFormIdentifier); if (stubForm == null) { throw new Exception("Could not find LA Stub-application form with identifier \"" + stubFormIdentifier + "\""); } }
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); }
public AdapPdfReport( IFormsRepository formsRepo, int formResultId, string outputPath, bool grayscale) : base(formsRepo, formResultId, outputPath, grayscale) { setFontSize(8); setPartHeaderFontSize(12); setSectionHeaderFontSize(10); if (form.title.Equals("ADAP Application")) { setCustomSectionOrder("ADAP_demographic", "ADAP_contact", "ADAP_household", "ADAP_medical", "ADAP_health", "ADAP_income", "ADAP_cert", "ADAP_finalCert"); } else { defaultOrderSections(); } setSectionIdentifierPrefixToRemove("ADAP_"); //handlers for printing special-case sections, by section identifier //handlers should print section contents specialCaseSections = new Dictionary <string, Action <def_Sections, int, double, double, double> > { { "ADAP_C1", printC1 }, { "ADAP_C3", printC3 }, { "ADAP_D5", printD5AndD6 }, { "ADAP_D6", printD5AndD6 }, { "ADAP_D7", printD7 }, { "ADAP_D8", printD8 }, { "ADAP_M1", printM1 }, { "ADAP_H5", printH5 }, { "ADAP_F3_A", printF3 }, { "ADAP_F3_B", printF3 }, { "ADAP_F3_C", printF3 }, { "ADAP_F3_D", printF3 }, { "ADAP_I2", printI2 }, { "ADAP_I3", printI3 }, }; sectionsToSkip = new string[] { "ADAP_F3", "ADAP_reminder" }.ToList(); //many sections can potentially be printed on one line using the same function foreach (string sctName in "D2 D4 D9 H1 H2 M3 M4".Split(' ')) { specialCaseSections.Add("ADAP_" + sctName, tryPrintSingleLineResponse); } foreach (string sctName in "D3".Split(' ')) { specialCaseSections.Add("ADAP_" + sctName, tryPrintSingleLineLabel); } }
public static bool RunSingleSectionOneOffValidation(IFormsRepository formsRepo, FormCollection frmCllctn, int sectionId, out List <string> validationErrorMessages) { bool invalid = false; validationErrorMessages = new List <string>(); def_Sections sct = formsRepo.GetSectionById(sectionId); #region Sections 2,3: if the Frequency is greater than zero, then the Duration and Type of support must be greater than zero. if ("SIS-A 2A,SIS-A 2B,SIS-A 2C,SIS-A 2D,SIS-A 2E,SIS-A 2F,SIS-A 3".Split(',').ToList().Contains(sct.identifier)) { formsRepo.SortSectionItems(sct); foreach (def_SectionItems si in sct.def_SectionItems) { if (si.subSectionId == null) { def_ItemVariables ivFreq = si.def_Items.def_ItemVariables.Where(iv => iv.identifier.EndsWith("_Fqy")).FirstOrDefault(); if (ivFreq == null) { throw new Exception("could not find fequency itemVariable (with suffix \"_Fqy\") for item \"" + si.def_Items.identifier + "\""); } string rspFreq = frmCllctn[ivFreq.identifier]; //def_ResponseVariables rvFreq = formsRepo.GetResponseVariablesByFormResultItemVarId(fr.formResultId, ivFreq.itemVariableId); if (rspFreq != null && rspFreq.Trim().Length > 0 && Convert.ToInt16(rspFreq) > 0) { foreach (string suffix in new string[] { "_TOS", "_DST" }) { def_ItemVariables ivSuff = si.def_Items.def_ItemVariables.Where(iv => iv.identifier.EndsWith(suffix)).FirstOrDefault(); if (ivSuff == null) { throw new Exception("could not find itemVariable with suffix \"" + suffix + "\" for item \"" + si.def_Items.identifier + "\""); } string rspSuff = frmCllctn[ivSuff.identifier]; //def_ResponseVariables rvSuff = formsRepo.GetResponseVariablesByFormResultItemVarId(fr.formResultId, ivSuff.itemVariableId); if (rspSuff == null || rspSuff.Trim().Length == 0 || Convert.ToInt16(rspSuff) == 0) { invalid = true; validationErrorMessages.Add(si.def_Sections.title + ", " + si.def_Items.label + ": you entered a Frequency greater than zero, so Daily Support Time and Type of Support must also be greater than zero."); } } } } } } #endregion return(invalid); }
public static XmlDocument BuildRamsellXmlDocForFormResult(int formResultId, IFormsRepository formsRepo) { string xsdFilePath = HttpContext.Current.Server.MapPath(xsdPath); XmlSchemaSet schemaSet = Utilities.GetXsdSchemaSet(xsdFilePath); // Extract the schema sets from the XSD (microsoft actually does it this way) // https://msdn.microsoft.com/en-us/library/ms255932(v=vs.110).aspx XmlSchema schema = null; foreach (XmlSchema xs in schemaSet.Schemas()) { schema = xs; } // convert schema heirarchy into custom types. See "SchemaElement" and subclasses below. // (the ResponseElement subclass will be used to link "leaf" nodes with item variables) List <RamsellExport.DefSchemaElement> defElements = RamsellExport.ParseSchemaElements(schema.Elements.Values); // build response xml document based on schema XmlDocument outputXmlDoc = new XmlDocument(); // Removed schemaSet from top level tag per Ramsell // outputXmlDoc.Schemas.Add(schemaSet); //outputXmlDoc.AppendChild(outputXmlDoc.CreateComment("Responses taken from formResult " + formResultId)); foreach (RamsellExport.DefSchemaElement elem in defElements) { RamsellExport.BuildResponseXml(null, outputXmlDoc, elem, formResultId, formsRepo); } // Validate response xml based on schema // resultDoc.Validate((object sender, ValidationEventArgs args) => { throw new Exception(args.Message); } ); try { Debug.WriteLine("XSD resultDoc.Schemas.Count: " + outputXmlDoc.Schemas.Count.ToString()); /* * foreach (System.Xml.Schema.XmlSchemaSet xss in resultDoc.Schemas.Schemas()) * { * Debug.WriteLine("XSD Schemas NameTable: " + xss.NameTable.ToString()); * } */ ValidationEventHandler eventHandler = new ValidationEventHandler(ValidationEventHandler); outputXmlDoc.Validate(eventHandler); Debug.WriteLine("*** Validation is complete."); } catch (Exception xcptn) { Debug.WriteLine("Validate exception: " + xcptn.Message); } return(outputXmlDoc); }
private static string GetVersion(IFormsRepository formsRepo, def_FormResults oldFormResult) { def_ResponseVariables relatedFormResultRV = formsRepo.GetResponseVariablesByFormResultIdentifier(oldFormResult.formResultId, Updates.VERSION); if (relatedFormResultRV == null) { return("0"); } else { return(relatedFormResultRV.rspValue); } }
private static void AddHiddenFields(IFormsRepository formsRepo, def_FormResults oldFormResult, def_FormResults copyFormResult) { string version = GetVersion(formsRepo, oldFormResult); // Increment version -- may add more complex function here to do this later, right now just increment by 1 each time string newVersion = (Int32.Parse(version) + 1).ToString(); Updates.AddField(formsRepo, Updates.SIS_HIDDEN, oldFormResult, Updates.RELATED_FORM_RESULT, copyFormResult.formResultId.ToString()); Updates.AddField(formsRepo, Updates.SIS_HIDDEN, copyFormResult, Updates.RELATED_FORM_RESULT, oldFormResult.formResultId.ToString()); Updates.AddField(formsRepo, Updates.SIS_HIDDEN, oldFormResult, Updates.VERSION, newVersion); Updates.AddField(formsRepo, Updates.SIS_HIDDEN, copyFormResult, Updates.VERSION, version); }
public static Dictionary <int, string> RetrieveFileDisplayTextsByRelatedId(IFormsRepository formsRepo, int RelatedId, int RelatedEnumId, string StatusFlag = null, int?AttachTypeId = null) { Dictionary <int, string> displayText = new Dictionary <int, string>(); try { Debug.WriteLine("FileUploads RetrieveFileDisplayTextsByRelatedId RelatedId: " + RelatedId); displayText = formsRepo.GetFileAttachmentDisplayText(RelatedId, RelatedEnumId, StatusFlag, AttachTypeId); } catch (Exception excptn) { Debug.WriteLine("FileUploads RetrieveFileDisplayTextsByRelatedId error: " + excptn.Message); } return(displayText); }
/// <summary> /// Perform generic validation: /// /// For the given formResultId (assigned in SharedValidation constructor), /// Make sure there is some non-null, non-whitespace response value for each of the /// def_ItemVariables corresponding to a def_SectionItems entry (or def_SectionItemsEnt entry) /// where the "display" "validation" and "requiredForm" flags are all marked 1/true. /// /// Only def_SectionItems for the current def_Forms (parameter "frm") are considered. /// /// Only def_SectionItemsEnt for the current def_Forms and form enterprise /// </summary> /// <param name="amt"></param> /// <param name="frm"></param> /// <param name="ItemVariableSuffixesToSkip"></param> /// <returns></returns> public bool DoGenericValidation( IFormsRepository formsRepo, TemplateItems amt, def_Forms frm, string[] ItemVariableSuffixesToSkip = null) { //pick an enterprise ID to use for validation purposes int entId = SessionHelper.LoginStatus.EnterpriseID; bool invalid = false; amt.missingItemVariablesBySectionByPart = new Dictionary <int, Dictionary <int, List <string> > >(); //get a list of identifiers for all the required item variables //typically this list will be pulled from a single EntAppConfig record for this enterprise/form //if such a record is not available, the meta-data structure will be traversed to find the required itemvariables //and an EntAppDonfig record will be added to speed the next validation for this enterprise/form List <ItemVariableIdentifierWithPartSection> requiredIvs = GetRequiredItemVarsWithPartsSections(formsRepo, frm, entId); //iterate through all the required item variable identifiers foreach (ItemVariableIdentifierWithPartSection ivps in requiredIvs) { //if this identifier ends with one of the "skippable" suffixes, skip it if (ItemVariableSuffixesToSkip != null) { bool skip = false; foreach (string suffixtoSkip in ItemVariableSuffixesToSkip) { if (ivps.itemVariableIdentifier.EndsWith(suffixtoSkip)) { skip = true; break; } } if (skip) { continue; } } //check if we have a valid response for this required item variable ValuePair vp = allResponses.FirstOrDefault(vpt => vpt.identifier == ivps.itemVariableIdentifier); if (vp == null || vp.rspValue == null || vp.rspValue.Trim().Length == 0) { invalid = true; AddMissingItemtoModel(ivps, amt); } } return(invalid); }
public static void InsertAccessLogRecord(IFormsRepository formsRepo, int formResultId, int accessLogFunctionId, string description) { def_AccessLogging accessLogging = new def_AccessLogging() { formResultId = formResultId, accessLogFunctionId = accessLogFunctionId, accessDescription = description, datetimeAccessed = DateTime.Now, EnterpriseID = SessionHelper.LoginStatus.EnterpriseID, UserID = SessionHelper.LoginStatus.UserID }; formsRepo.AddAccessLogging(accessLogging); }
public static void updateSection1ScoresNoSave( IFormsRepository formsRepo, def_Forms frm, int formResultId) { def_FormResults fr = formsRepo.GetFormResultById(formResultId); int entId = fr.EnterpriseID.HasValue ? fr.EnterpriseID.Value : 0; string sectionIdentifierPrefix = frm.identifier; //"SIS-A" or "SIS-C" foreach (string shortSectionName in new string[] { "1A", "1B" }) { string sectionIdentifier = sectionIdentifierPrefix + " " + shortSectionName; // e.g. "SIS-A 1A" def_Sections sct = formsRepo.GetSectionByIdentifier(sectionIdentifier); if (sct == null) { throw new Exception("Could not find section with identifier \"" + sectionIdentifier + "\""); } int rawTotal = 0; foreach (def_SectionItems si in formsRepo.GetSectionItemsBySectionIdEnt(sct.sectionId, entId)) { def_ItemVariables rawScoreIv = formsRepo.GetItemVariablesByItemId(si.itemId) .Where(iv => iv.identifier.EndsWith("Support")).SingleOrDefault(); //e.g. "Q1A1_ExMedSupport" if (rawScoreIv != null) { def_ResponseVariables rv = formsRepo.GetResponseVariablesByFormResultItemVarId(formResultId, rawScoreIv.itemVariableId); if (rv != null && !String.IsNullOrWhiteSpace(rv.rspValue)) { int rawScore; if (Int32.TryParse(rv.rspValue, out rawScore)) { rawTotal += rawScore; } else { Debug.WriteLine("* * * Skipping item on updating section 1 scores: " + "Could not parse integer from response value \"{0}\" for itemVariable \"{1}\". (formResultID {2})", rv.rspValue, rawScoreIv.identifier, formResultId); } } } } UpdateScoreResponseNoSave(formsRepo, formResultId, "scr_" + shortSectionName + "_raw_total", rawTotal); } }
public TemplateAssmntNavMenu(IFormsRepository formsRepo) { if (SessionHelper.LoginStatus.appGroupPermissions[0].groupPermissionSets.Count() > 0) { create = UAS_Business_Functions.hasPermission(SessionHelper.LoginStatus.appGroupPermissions[0].groupPermissionSets[0].PermissionSet, UAS.Business.PermissionConstants.CREATE, UAS.Business.PermissionConstants.ASSMNTS); unlock = UAS_Business_Functions.hasPermission(SessionHelper.LoginStatus.appGroupPermissions[0].groupPermissionSets[0].PermissionSet, UAS.Business.PermissionConstants.UNLOCK, UAS.Business.PermissionConstants.ASSMNTS); delete = UAS_Business_Functions.hasPermission(SessionHelper.LoginStatus.appGroupPermissions[0].groupPermissionSets[0].PermissionSet, UAS.Business.PermissionConstants.DELETE, UAS.Business.PermissionConstants.ASSMNTS); archive = UAS_Business_Functions.hasPermission(SessionHelper.LoginStatus.appGroupPermissions[0].groupPermissionSets[0].PermissionSet, UAS.Business.PermissionConstants.ARCHIVE, UAS.Business.PermissionConstants.ASSMNTS); undelete = UAS_Business_Functions.hasPermission(SessionHelper.LoginStatus.appGroupPermissions[0].groupPermissionSets[0].PermissionSet, UAS.Business.PermissionConstants.UNDELETE, UAS.Business.PermissionConstants.ASSMNTS); } ventureMode = SessionHelper.IsVentureMode; forms = Business.Forms.GetFormsDictionary(formsRepo); }
///// <summary> ///// Gets the review status based on the status code provided (the sort order) ///// </summary> ///// <param name="statusCode">Codes determined by the def_StatusDetail table</param> ///// <returns>A string for display with the appropriate status info</returns> //public static string GetReviewStatus(int statusCode, IFormsRepository formsRepo) //{ // def_StatusText statusText = formsRepo.GetStatusTextByDetailSortOrder(STATUS_MASTER_ID, statusCode); // if (statusText != null) // { // return statusText.displayText; // } // return String.Empty; //} public static Dictionary <int?, string> GetReviewStatuses(IFormsRepository formsRepo) { Dictionary <int?, string> reviewStatuses = null; try { reviewStatuses = formsRepo.GetStatusDisplayTextsByStatusMasterId(STATUS_MASTER_ID); } catch (Exception ex) { Debug.WriteLine(ex.Message); return(null); } return(reviewStatuses); }
/// <summary> /// Adds a new record, or Updates an existing record, to the def_FileAttachment table, then saves the file in the file system. Files in the same directory with the same name /// will be overwritten without warning. Use of sub-directories can prevent this. /// </summary> /// <param name="formsRepo"> IFormsRepository necessary for database access.</param> /// <param name="file">File being uploaded.</param> /// <param name="subDir">Optional superDirectory name, set to null to disable.</param> /// <param name="subDir">Optional subDirectory name, set to null to disable.</param> /// <param name="RelatedId">Identifier used to associate a file with a record type.</param> /// <param name="RelatedEnumId">Type of identifier used in RelatedId.</param> /// <param name="AttachTypeId">Indicates how the file was attached, which may represent the file itself or just a generic type.</param> /// <returns>Int value of the FileId</returns> public static int CreateAttachment(IFormsRepository formsRepo, System.Web.HttpPostedFileWrapper file, string superDir, string subDir, int RelatedId, int RelatedEnumId, int AttachTypeId) { int fileId = -1; if (file != null && !String.IsNullOrEmpty(file.FileName.Trim())) { fileId = CreateAttachment(formsRepo, file.InputStream, file.FileName, superDir, subDir, RelatedId, RelatedEnumId, AttachTypeId); } else { Debug.WriteLine("FileUploads CreateAttachment Error: File not found."); } return(fileId); }
public static Dictionary <int, string> GetFormsDictionary(IFormsRepository formsRepo) { Dictionary <int, string> forms = null; try { forms = GetFormsDictionaryThrow(formsRepo); } catch (Exception ex) { forms = new Dictionary <int, string>(); } return(forms); }