コード例 #1
0
        public void PopulateTemplate()
        {
            //To-Do: Write in other property too
            TemplateModel t = Constants.currentTemplate;

            systemName       = t.SystemName;
            tenderName       = t.TenderName;
            location         = t.Location;
            templateCode     = t.TemplateCode;
            templateRemark   = t.Remark;
            templateSaveName = t.TemplateSaveName;
            CurrentDate      = t.DateCreated;
            discount         = t.Discount;
            double afterDiscount = (double)(100 - discount) / 100;

            foreach (ItemModel item in t.SystemItems)
            {
                TemplateItems.Add(item);
                totalCost += item.Price * item.Quantity;
                if (item.ItemDiscount == 0)
                {
                    discountedCost += (item.Price * item.Quantity * afterDiscount);
                }
                else
                {
                    double itemDiscount = (double)(100 - item.ItemDiscount) / 100;
                    discountedCost += (item.Price * item.Quantity * itemDiscount);
                }
            }
            Constants.currentTemplate = null;
        }
コード例 #2
0
        private void SaveTemplate()
        {
            //Once save button is clicked, use a variable that stores the information
            TemplateModel templateToSave = new TemplateModel
            {
                SystemName       = systemName,
                TemplateCode     = templateCode,
                TenderName       = tenderName,
                DateModified     = DateTime.Now,
                Location         = location,
                Remark           = templateRemark,
                SystemItems      = TemplateItems.ToList(),
                Discount         = discount,
                TemplateSaveName = templateSaveName
            };

            //If template is newly created, generate it a name
            if (templateToSave.TemplateSaveName == null)
            {
                templateToSave.TemplateSaveName = TemplateSaveAndLoad.generateTemplateSaveFilePath(systemName);
                templateToSave.DateCreated      = DateTime.Now;
                //Create a new data entry for the template
                Constants.AddTemplate(templateToSave);
            }

            Console.WriteLine("The test file name is " + templateToSave.TemplateSaveName);


            //Save the entire template
            TemplateSaveAndLoad.save(templateToSave);

            //This method should only be called after the aplication exits
            TemplateSaveAndLoad.saveTemplateData();
        }
コード例 #3
0
 private void RemoveItemFromTemplate()
 {
     if (selectedTemplateItem != null)
     {
         TemplateItems.Remove(selectedTemplateItem);
     }
 }
コード例 #4
0
 public override void EnterRule_template_value_bool(CfgGramParser.Rule_template_value_boolContext context)
 {
     TemplateItems.Add(new TemplateItem <bool>()
     {
         Value = context.GetText() == "true",
         Type  = TemplateValueType.Bool
     });
 }
コード例 #5
0
 public override void EnterRule_template_value_integer(CfgGramParser.Rule_template_value_integerContext context)
 {
     TemplateItems.Add(new TemplateItem <int>()
     {
         Value = int.Parse(context.GetText()),
         Type  = TemplateValueType.Integer
     });
 }
コード例 #6
0
 public string Substitute(User user)
 {
     if (user == null)
     {
         throw new ArgumentNullException(nameof(user));
     }
     return(string.Concat(TemplateItems.Select(itemFunc => itemFunc(user))));
 }
コード例 #7
0
 public override void EnterRule_template_value_float(CfgGramParser.Rule_template_value_floatContext context)
 {
     TemplateItems.Add(new TemplateItem <float>()
     {
         Value = float.Parse(context.GetText()),
         Type  = TemplateValueType.Float
     });
 }
コード例 #8
0
 private void AddItemToTemplate()
 {
     if (!TemplateItems.Contains(selectedItem))
     {
         selectedItem.Quantity = 0;
         TemplateItems.Add(selectedItem);
     }
     selectedItem = null;
 }
コード例 #9
0
        public override void EnterRule_template_value_string(CfgGramParser.Rule_template_value_stringContext context)
        {
            var text = context.GetText();

            TemplateItems.Add(new TemplateItem <string>()
            {
                Value = text.Substring(1, text.Length - 2),
                Type  = TemplateValueType.String
            });
        }
コード例 #10
0
        public ActionResult SaveThenRedirect(FormCollection frmCllctn = null, TemplateItems itm = null)
        {
            Save(frmCllctn, itm);

            if (!frmCllctn.AllKeys.Contains("redirectUrl"))
            {
                throw new Exception("Expected key \"redirectUrl\" to appear in form collection");
            }

            return(Redirect(frmCllctn["redirectUrl"]));
        }
コード例 #11
0
        /// <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);
        }
コード例 #12
0
        public ActionResult SaveStubApplication(FormCollection frmCllctn, TemplateItems itm)
        {
            //run normal save (update/add response variables based on form collection)
            ResultsController rc = new ResultsController(formsRepo);

            rc.ControllerContext = ControllerContext;
            ActionResult ar = rc.Save(frmCllctn, itm);

            //update or add UAS_User based on responses
            int formResultId = SessionHelper.SessionForm.formResultId;

            new AdapLAStubApp(formsRepo).UpdateUASFromStubApp(formResultId);

            return(ar);
        }
コード例 #13
0
 public void ResetFields()
 {
     selectedItem         = null;
     selectedSupplier     = null;
     selectedTemplateItem = null;
     SupplierItems.Clear();
     TemplateItems.Clear();
     systemName     = "";
     tenderName     = "";
     location       = "";
     templateCode   = "";
     templateRemark = "";
     discount       = 0;
     discountedCost = 0;
     totalCost      = 0;
 }
コード例 #14
0
        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));
            }
        }
コード例 #15
0
        public override void ExitRule_template_member_value(CfgGramParser.Rule_template_member_valueContext context)
        {
            TemplateItemBase item;

            if (TemplateItems.Count == 1)
            {
                item      = TemplateItems.First();
                item.Name = TemplateItemKey;
            }
            else
            {
                item = new TemplateItem <TemplateItemBase[]>(TemplateItemKey,
                                                             TemplateItems.ToArray(),
                                                             TemplateValueType.List);
            }
            Template.AddItem(item);
        }
コード例 #16
0
        public bool FinalSubmit(FormCollection frmCllctn, TemplateItems itm)
        {
            int formResultId = SessionHelper.SessionForm.formResultId;

            //run save (update/add response variables based on form collection)
            ResultsController rc = new ResultsController(formsRepo);

            rc.ControllerContext = ControllerContext;
            rc.Save(frmCllctn, itm);

            //run status update
            int status = Convert.ToInt32(formsRepo.GetStatusDetailByMasterIdentifier(1, "NEEDS_REVIEW").sortOrder);

            AdapController ac = new AdapController(formsRepo);

            ac.ControllerContext = ControllerContext;
            ac.StatusUpdated("", formResultId, status, false);

            //return Redirect("~/ADAP");
            return(true);
        }
コード例 #17
0
        /// <summary>
        /// Used by ResultsController.ValidateFormResult()
        ///
        /// Runs the hard-coded validation rules, which can't be encoded into meta-data, for SIS-A and SIS-C forms.
        ///
        /// adds to the model's validation messages for any validation errors or warnings.
        /// </summary>
        /// <param name="sv"></param>
        /// <param name="model"></param>
        /// <returns>true if any validation ERRORS where found, false if nothin (or only wanrings) found</returns>
        public static bool RunOneOffValidation(IFormsRepository formsRepo, def_Forms frm, int entId, List <ValuePair> allResponses, TemplateItems model)
        {
            bool invalid          = false;
            bool isSisCAssessment = frm.identifier.Equals("SIS-C");

            #region if any section 1 "other" text fields are populated, make sure they have a positive numerical response. (and vice-versa)
            string itemsToCheck = isSisCAssessment ?
                                  "A19,A20,A21,B14,B15,B16" // <- check these section 1 items if SIS-C
                : "A19,B13";                                // <- check these if SIS-A
            foreach (string shortIdentifier in itemsToCheck.Split(','))
            {
                string textIdentifier;
                string numIdentifier;

                if (isSisCAssessment)
                {
                    textIdentifier = "SIS-C_Q1" + shortIdentifier + "_Other";
                    numIdentifier  = "SIS-C_Q1" + shortIdentifier + "_Ex" + (shortIdentifier.StartsWith("A") ? "Med" : "Beh") + "Support";
                }
                else // Assumes that if it isn't SIS-C,it must be a SIS-A assessment
                {
                    textIdentifier = "Q1" + shortIdentifier + "_Other";
                    numIdentifier  = "Q1" + shortIdentifier + "_Ex" + (shortIdentifier.StartsWith("A") ? "Med" : "Beh") + "Support";
                }

                ValuePair textVp = allResponses.SingleOrDefault(vpt => vpt.identifier == textIdentifier); //formsRepo.GetResponseVariablesByFormResultIdentifier(fr.formResultId, textIdentifier);
                ValuePair numVp  = allResponses.SingleOrDefault(vpt => vpt.identifier == numIdentifier);  //def_ResponseVariables numRv = formsRepo.GetResponseVariablesByFormResultIdentifier(fr.formResultId, numIdentifier);

                bool textBlank = textVp == null || String.IsNullOrWhiteSpace(textVp.rspValue);            //isNullEmptyOrBlank(textRv);
                bool numBlank  = numVp == null || String.IsNullOrWhiteSpace(numVp.rspValue);              //isNullEmptyOrBlank(numRv);

                if (numBlank)
                {
                    invalid = true;
                    model.validationMessages.Add("Section 1: \"other\" item " + shortIdentifier + " has no numerical response");
                }
                else if ((Int32.Parse(numVp.rspValue) > 0) && textBlank)
                {
                    invalid = true;
                    model.validationMessages.Add("Section 1: \"other\" item " + shortIdentifier + " has positive numerical response, but no text explaination");
                }
            }
            #endregion

            #region check interviewee age / interview date
            ValuePair vpBirthDate = allResponses.SingleOrDefault(vpt => vpt.identifier == "sis_cl_dob_dt");
            ValuePair vpIntDate   = allResponses.SingleOrDefault(vpt => vpt.identifier == "sis_completed_dt");
            DateTime  dtDob;
            DateTime  dtInt;
            //def_ResponseVariables rvBirthDate = formsRepo.GetResponseVariablesByFormResultIdentifier(fr.formResultId, "sis_cl_dob_dt");
            //def_ResponseVariables rvIntDate = formsRepo.GetResponseVariablesByFormResultIdentifier(fr.formResultId, "sis_completed_dt");
            if (vpBirthDate != null && DateTime.TryParse(vpBirthDate.rspValue, out dtDob) &&
                vpIntDate != null && DateTime.TryParse(vpIntDate.rspValue, out dtInt))
            {
                int age = dtInt.Year - dtDob.Year;
                if (dtInt.Month < dtDob.Month)
                {
                    age--;
                }
                if ((dtInt.Month == dtDob.Month) && (dtInt.Day < dtDob.Day))
                {
                    age--;
                }

                //for SIS-C assessments, age must fall between 5 and 16 inclusive, and interview date must be 2009 at earliest
                if (isSisCAssessment)
                {
                    if (age < 5)
                    {
                        invalid = true;
                        model.validationMessages.Add("Profile: interviewee age is " + age + " years, should be at least 5 years");
                    }
                    if (age > 16)
                    {
                        invalid = true;
                        model.validationMessages.Add("Profile: interviewee age is " + age + " years, should be at most 16 years");
                    }
                    if (dtInt.Year < 2009)
                    {
                        invalid = true;
                        model.validationMessages.Add("Profile: interview date is in the year " + dtInt.Year + ", should be 2009 at the earliest");
                    }
                }

                //for SIS-A assessments, age must be at least 15, and interview date must be 2004 at earliest
                else
                {
                    if (dtInt.Year < 2004)
                    {
                        invalid = true;
                        model.validationMessages.Add("Profile: interview date is in the year " + dtInt.Year + ", should be 2004 at the earliest");
                    }
                    if (age < 15)
                    {
                        invalid = true;
                        model.validationMessages.Add("Profile: interviewee age is " + age + " years, should be at least 15 years");
                    }
                }
            }
            #endregion

            #region if "SEVERE MEDICAL RISK" under supplementl questions is marked "yes"...

            ValuePair vpSup = allResponses.SingleOrDefault(vpt => vpt.identifier == "Q4A1v1");
            //def_ResponseVariables rvSup = formsRepo.GetResponseVariablesByFormResultIdentifier(fr.formResultId, "Q4A1v1");
            if (vpSup != null && vpSup.rspValue != null && (vpSup.rspValue.Equals("1") || vpSup.rspValue.ToLower().Equals("true")))
            {
                int rspInt;

                //make sure at least one of the items under section 1A has a rsponse value "2"
                bool      anyTwosInOtherItems = false;
                ValuePair vp;

                for (int i = 1; i <= 21; i++)
                {
                    if (isSisCAssessment) // Accomodating for different identifiers (SIS-A vs SIS-C)
                    {
                        vp = allResponses.SingleOrDefault(vpt => vpt.identifier == "SIS-C_Q1A" + i + "_ExMedSupport");
                    }
                    else
                    {
                        vp = allResponses.SingleOrDefault(vpt => vpt.identifier == "Q1A" + i + "_ExMedSupport");
                    }
                    //def_ResponseVariables rv = formsRepo.GetResponseVariablesByFormResultIdentifier(fr.formResultId, "Q1A" + i + "_ExMedSupport");
                    if ((vp != null) && Int32.TryParse(vp.rspValue, out rspInt) && (rspInt == 2))
                    {
                        anyTwosInOtherItems = true;
                        break;
                    }
                }

                ValuePair vpExMedSup = allResponses.SingleOrDefault(vpt => vpt.identifier == "Q1A_ed_ExMedSupport");
                //def_ResponseVariables edRv = formsRepo.GetResponseVariablesByFormResultIdentifier(fr.formResultId, "Q1A_ed_ExMedSupport");

                if ((vpExMedSup != null) && Int32.TryParse(vpExMedSup.rspValue, out rspInt) && (rspInt == 2))
                {
                    anyTwosInOtherItems = true;
                }

                if (!anyTwosInOtherItems)
                {
                    invalid = true;
                    model.validationMessages.Add("Marked \"yes\" under SEVERE MEDICAL RISK in supplemental questions, but no scores of 2 in section 1A");
                }
            }
            #endregion

            #region Custom validation for supplemental questions 2-4, depending on section 1B responses
            Dictionary <string, string[]> specs;
            if (isSisCAssessment)
            {
                specs = new Dictionary <string, string[]>
                {
                    { "Q4A2v1", new string[] {
                          //if Q4A2v1 has response "yes", at least one
                          //of these item variables must have response "2"
                          "SIS-C_Q1B2", //question 2 in SIS-C
                          "SIS-C_Q1B3", //question 3 in SIS-C
                          "SIS-C_Q1B8", //question 8 in SIS-C
                      } },
                    { "Q4A3v1", new string[] {
                          "SIS-C_Q1B2", //question 2 in SIS-C
                          "SIS-C_Q1B3", //question 3 in SIS-C
                          "SIS-C_Q1B8", //question 8 in SIS-C
                      } },
                    { "Q4A4v1", new string[] {
                          "SIS-C_Q1B5", //question 5 in SIS-C
                          "SIS-C_Q1B6", //question 6 in SIS-C
                          "SIS-C_Q1B7", //question 7 in SIS-C
                      } },
                };
            }
            else
            {
                specs = new Dictionary <string, string[]>
                {
                    { "Q4A2v1", new string[] {
                          //if Q4A2v1 has response "yes", at least one
                          //of these item variables must have response "2"
                          "Q1B2", //question 2 in SIS-C
                          "Q1B3", //question 3 in SIS-C
                          "Q1B9", //question 8 in SIS-C
                      } },
                    { "Q4A3v1", new string[] {
                          "Q1B2", //question 2 in SIS-C
                          "Q1B3", //question 3 in SIS-C
                          "Q1B9", //question 8 in SIS-C
                      } },
                    { "Q4A4v1", new string[] {
                          "Q1B5", //question 5 in SIS-C
                          "Q1B6", //question 6 in SIS-C
                          "Q1B7", //question 7 in SIS-C
                      } },
                };
            }
            foreach (string supIvIdent in specs.Keys)
            {
                def_ItemVariables supIv = formsRepo.GetItemVariableByIdentifier(supIvIdent);
                if (supIv == null)
                {
                    throw new Exception("Could not find item variable with identifier \"" + supIvIdent + "\"");
                }
                def_Items supItm   = formsRepo.GetItemById(supIv.itemId);
                string    supIndex = supIvIdent.Substring(3, 1);

                //rvSup = formsRepo.GetResponseVariablesByFormResultItemVarId(fr.formResultId, supIv.itemVariableId);
                vpSup = allResponses.SingleOrDefault(vpt => vpt.identifier == supIv.identifier);

                if (vpSup != null && vpSup.rspValue != null && (vpSup.rspValue.Equals("1") || vpSup.rspValue.ToLower().Equals("true")))
                {
                    List <string> checkedItemLabels   = new List <string>();
                    bool          anyTwosInOtherItems = false;
                    foreach (string ivPrefix in specs[supIvIdent])
                    {
                        def_ItemVariables iv  = formsRepo.GetItemVariableByIdentifier(ivPrefix + "_ExBehSupport");
                        def_Items         itm = formsRepo.GetItemById(iv.itemId);
                        checkedItemLabels.Add("\"" + itm.label + "\"");

                        ValuePair vp = allResponses.SingleOrDefault(vpt => vpt.identifier == iv.identifier);
                        //def_ResponseVariables rv = formsRepo.GetResponseVariablesByFormResultItemVarId(fr.formResultId, iv.itemVariableId);
                        if ((vp != null) && (vp.rspValue != null) && (vp.rspValue == "2"))
                        {
                            anyTwosInOtherItems = true;
                            break;
                        }
                    }

                    if (!anyTwosInOtherItems)
                    {
                        invalid = true;
                        model.validationMessages.Add("Marked \"yes\" under supplemental question " + supIndex + ", but no scores of 2 in any of these section 1B items: "
                                                     + String.Join(", ", checkedItemLabels));
                    }
                }
            }
            #endregion

            #region Require notes for Section 1A or 1B where the item is flagged as Important For/To
            foreach (def_FormParts fp in frm.def_FormParts)
            {
                //This is currently hardcodoed for Enterprise 44: Virginia.  This should probably be added to a lookup Table so the feature can be switched on/off for any enterprise.
                //if (fr.EnterpriseID == 44)
                //{
                if (fp.def_Parts.identifier.StartsWith("Section 1"))
                {
                    foreach (def_PartSections ps in fp.def_Parts.def_PartSections)
                    {
                        foreach (def_SectionItems si in ps.def_Sections.def_SectionItems)
                        {
                            // Configured in def_SectionItemsEnt, some Enterprises require validation on these sections.  Currently checks for a 1 for Enterprise 44.
                            // Empty lists should return false.
                            if (si.def_SectionItemsEnt.Any(r => r.validation == 1 && r.EnterpriseID == entId) && si.subSectionId != null)
                            {
                                foreach (def_SectionItems subsi in si.def_SubSections.def_Sections.def_SectionItems)
                                {
                                    List <def_ItemVariables> ivImportant = subsi.def_Items.def_ItemVariables.Where(iv => iv.identifier.EndsWith("_ImportantFor") || iv.identifier.EndsWith("_ImportantTo")).ToList();
                                    if (ivImportant.Count() == 0)
                                    {
                                        Debug.WriteLine("ResultsController:ValidateFormResult method  * * * Could not find Important For/To itemVariable for item \"" + subsi.def_Items.identifier + "\"");
                                    }
                                    else
                                    {
                                        List <bool> rvImpBools = new List <bool>();
                                        foreach (def_ItemVariables iv in ivImportant)
                                        {
                                            ValuePair vp = allResponses.SingleOrDefault(vpt => vpt.identifier == iv.identifier);
                                            //def_ResponseVariables rv = formsRepo.GetResponseVariablesByFormResultItemVarId(fr.formResultId, iv.itemVariableId);
                                            rvImpBools.Add((vp != null && vp.rspValue != null && vp.rspValue.Equals("1")));
                                        }
                                        // Test true if any value is true.  Empty lists should return false.
                                        if (rvImpBools.Any(r => r))
                                        {
                                            List <def_ItemVariables> ivNote = subsi.def_Items.def_ItemVariables.Where(iv => iv.identifier.EndsWith("_Notes")).ToList();
                                            foreach (def_ItemVariables iv in ivNote)
                                            {
                                                ValuePair vp = allResponses.SingleOrDefault(vpt => vpt.identifier == iv.identifier);
                                                //def_ResponseVariables rv = formsRepo.GetResponseVariablesByFormResultItemVarId(fr.formResultId, iv.itemVariableId);
                                                if (vp == null || String.IsNullOrEmpty(vp.rspValue))
                                                {
                                                    invalid = true;
                                                    model.validationMessages.Add(subsi.def_Sections.title + ", " + subsi.def_Items.label +
                                                                                 ": Notes are required for items flagged as Important.");
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
                //}
            }
            #endregion

            #region For all supplemental questions, require sub-questions if top-level response is "Yes" (Bug 13132, #2 in description)

            //iterate through all the sub-sections in the Supplemental Questions section
            def_Sections sqSection = formsRepo.GetSectionByIdentifier("SQ");
            formsRepo.SortSectionItems(sqSection);
            foreach (def_SectionItems si in sqSection.def_SectionItems.Where(si => si.subSectionId != null))
            {
                bool         validationRequired = false;
                def_Sections subSct             = formsRepo.GetSubSectionById(si.subSectionId);

                //exclude "S4aPageNotes" subsection
                if (subSct.identifier == "S4aPageNotes")
                {
                    continue;
                }

                //iterate through all the sectionitems in this subsection, in order
                formsRepo.SortSectionItems(subSct);
                foreach (def_SectionItems subSi in subSct.def_SectionItems)
                {
                    //if the sectionitem points to an item, that item must represent a top-level yes.no Supplemental Question
                    //and it should have exactly one itemVariable, with basetype 1
                    if (subSi.itemId > 1)
                    {
                        def_ItemVariables ivTopQuestion = subSi.def_Items.def_ItemVariables.FirstOrDefault();

                        ValuePair vpTopQuestion = allResponses.SingleOrDefault(vpt => vpt.identifier == ivTopQuestion.identifier);
                        //def_ResponseVariables rvTopQuestion = formsRepo.GetResponseVariablesByFormResultItemVarId(fr.formResultId, ivTopQuestion.itemVariableId);

                        //check if the response is "yes" for this top-level yes/no
                        if (vpTopQuestion != null && !String.IsNullOrWhiteSpace(vpTopQuestion.rspValue) && vpTopQuestion.rspValue == "1")
                        {
                            validationRequired = true;
                        }
                    }

                    //if the sectionitem points to a sub-subsection, that sub-subsection contains lower-level items
                    //that should be checked only if the previous top-level question was answered "yes"
                    else if (subSi.subSectionId.HasValue && validationRequired)
                    {
                        def_Sections subSubSct = formsRepo.GetSubSectionById(subSi.subSectionId);

                        //iterate through the item variables in this sub-subsection and require responses for some of them,
                        //if their identifier ends with a, b, c, d, or d2
                        formsRepo.SortSectionItems(subSubSct);
                        foreach (def_SectionItems subSubSi in subSubSct.def_SectionItems.Where(subSubSi => subSubSi.subSectionId == null))
                        {
                            foreach (def_ItemVariables bottomLevelIv in subSubSi.def_Items.def_ItemVariables)
                            {
                                if ("a,b,c,d,d2".Split(',').Where(suffix => bottomLevelIv.identifier.EndsWith(suffix)).Any())
                                {
                                    ValuePair vp = allResponses.SingleOrDefault(vpt => vpt.identifier == bottomLevelIv.identifier);
                                    //def_ResponseVariables rv = formsRepo.GetResponseVariablesByFormResultItemVarId(fr.formResultId, bottomLevelIv.itemVariableId);
                                    if (vp == null || String.IsNullOrWhiteSpace(vp.rspValue) ||
                                        (bottomLevelIv.baseTypeId == 1 && vp.rspValue.ToLower() == "unanswered"))
                                    //^ ^ ^ OT 3-24-16 consider "unanswered" the same as blank for yes/nos ("unanswered" responses may exist in DB as a result of a bug: Bug 13132, #1 in description)
                                    {
                                        invalid = true;
                                        model.validationMessages.Add(sqSection.title + ": since you marked \"yes\" under \"" + subSct.title + "\", you must provide a response for \"" + subSubSi.def_Items.label + "\"");
                                    }
                                }
                            }
                        }

                        //reset the flag so the following subsection is not validated unless we hit another top-level "yes"
                        validationRequired = false;
                    }
                }
            }

            #endregion

            return(invalid);
        }
コード例 #18
0
        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);
        }
コード例 #19
0
ファイル: SquidScene.cs プロジェクト: retNull/SquidEngine-XNA
 /// <summary>
 /// Adds a template sceneitem to the templates collection
 /// </summary>
 /// <param name="sceneItem">The scene item to add</param>
 public void AddTemplate(SceneItem sceneItem)
 {
     sceneItem.IsTemplate = true;
     TemplateItems.Add(sceneItem);
 }
コード例 #20
0
 public ActionResult CloseApplication(FormCollection frmCllctn, TemplateItems itm)
 {
     return(Redirect("~/ADAP"));
 }
コード例 #21
0
 private void AddMissingItemtoModel(ItemVariableIdentifierWithPartSection ivps, TemplateItems amt)
 {
     if (!amt.missingItemVariablesBySectionByPart.ContainsKey(ivps.partId))
     {
         amt.missingItemVariablesBySectionByPart.Add(ivps.partId, new Dictionary <int, List <string> >());
     }
     if (!amt.missingItemVariablesBySectionByPart[ivps.partId].ContainsKey(ivps.sectionId))
     {
         amt.missingItemVariablesBySectionByPart[ivps.partId].Add(ivps.sectionId, new List <string>());
     }
     if (!amt.missingItemVariablesBySectionByPart[ivps.partId][ivps.sectionId].Contains(ivps.itemVariableIdentifier))
     {
         amt.missingItemVariablesBySectionByPart[ivps.partId][ivps.sectionId].Add(ivps.itemVariableIdentifier);
     }
 }
コード例 #22
0
        public ActionResult Validate(FormCollection frmCllctn, TemplateItems ti)
        {
            //save response from formCollection into the DB
            ResultsController rc = new ResultsController(formsRepo);

            rc.ControllerContext = ControllerContext;
            rc.Save(frmCllctn, ti);

            int formResultId = SessionHelper.SessionForm.formResultId;

            SessionHelper.SessionForm.sectionId = -1;

            //Run generic validation
            AdapValidationErrorsModel model = new AdapValidationErrorsModel();

            model.navMenuModel       = AJBoggs.Adap.Templates.TemplateMenus.getAdapNavMenuModel(SessionHelper.SessionForm, formsRepo);
            model.validationMessages = new List <string>();
            model.missingItemVariablesBySectionByPart = new Dictionary <int, Dictionary <int, List <string> > >();
            def_Forms        frm          = formsRepo.GetFormById(SessionHelper.SessionForm.formId);
            List <ValuePair> allResponses = CommonExport.GetDataByFormResultId(formResultId);
            SharedValidation sv           = new SharedValidation(allResponses);
            bool             invalid      = sv.DoGenericValidation(formsRepo, model, frm);

            //transfer generic validation results to an ADAP-specific model
            model.titlesOfMissingSubsectionsBySectionByPart = new Dictionary <int, Dictionary <int, List <string> > >();
            foreach (int prtId in model.missingItemVariablesBySectionByPart.Keys)
            {
                model.titlesOfMissingSubsectionsBySectionByPart.Add(prtId, new Dictionary <int, List <string> >());
                foreach (int sctId in model.missingItemVariablesBySectionByPart[prtId].Keys)
                {
                    def_Sections sct = formsRepo.GetSectionById(sctId);
                    formsRepo.SortSectionItems(sct);
                    List <int> ssSectionIds = new List <int>();
                    foreach (def_SectionItems si in sct.def_SectionItems.Where(si => si.subSectionId.HasValue))
                    {
                        ssSectionIds.Add(formsRepo.GetSubSectionById(si.subSectionId.Value).sectionId);
                    }

                    model.titlesOfMissingSubsectionsBySectionByPart[prtId].Add(sctId, new List <string>());
                    foreach (string itemVariableIdent in model.missingItemVariablesBySectionByPart[prtId][sctId])
                    {
                        //for each item variable identifier returned by generic validation,
                        //lookup the corresponding subsection's title for display on the ADAP "validation errors" screen
                        def_ItemVariables iv  = formsRepo.GetItemVariableByIdentifier(itemVariableIdent);
                        def_Items         itm = iv == null ? null : iv.def_Items;
                        def_SectionItems  si  = itm == null ? null : formsRepo.getSectionItemsForItem(itm).Where(sit => ssSectionIds.Contains(sit.sectionId)).FirstOrDefault();
                        def_Sections      sub = si == null ? null : si.def_Sections;
                        if (sub != null && !model.titlesOfMissingSubsectionsBySectionByPart[prtId][sctId].Contains(sub.title))
                        {
                            model.titlesOfMissingSubsectionsBySectionByPart[prtId][sctId].Add(sub.title);
                        }
                    }
                }
            }

            //run CO-ADAP one-off validation
            if (AdapCOOneOffValidation.RunOneOffValidation(sv, model))
            {
                invalid = true;
            }

            //return the validation errors screen if any errors were found
            //model.validationMessages could have some warnings even if no errors were found, in which case "invalid" would be false here
            if (invalid)
            {
                return(View("~/Views/COADAP/ValidationErrors.cshtml", model));
            }

            //if no problems were found, or if warnings were found but no errors, return the next section in the application
            if (model.validationMessages.Count == 0)
            {
                model.validationMessages.Add("No errors were found");
            }
            int sectionId = Convert.ToInt16(frmCllctn["navSectionId"]);

            return(rc.Template(sectionId, model.validationMessages));
        }
コード例 #23
0
        /*  This method validates the SIS templates in Views/Templates/SIS
         *
         *
         */
        private bool ValidateFormResult(def_FormResults fr, TemplateItems amt = null)
        {
            // * * * OT 3-15-16 completed form results need to be validated on every save (Bug 13110)
            //// * * * OT 1-4-16   form results that are already marked as completed get to skip validation
            //if (fr.formStatus == (byte)FormResults_formStatus.COMPLETED)
            //    return true;

            if (amt == null)
            {
                amt = new GeneralForm();
            }

            //retrieve all responses for this formResult, by def_ItemVariable identifier
            List <ValuePair> allResponses = CommonExport.GetDataByFormResultId(fr.formResultId);

            //pass the response data through generic validation (meta-data driven validation)
            def_Forms frm = formsRepo.GetFormById(fr.formId);

            string[]         ItemVariableSuffixesToSkip = { "Notes", "portantTo", "portantFor", "cl_age", "int_id" };
            SharedValidation sv      = new SharedValidation(allResponses);
            bool             invalid = sv.DoGenericValidation(formsRepo, amt, frm, ItemVariableSuffixesToSkip);

            //pass the response data through one-off validation (rules that can't be encoded into meta-data)
            //populate amt.valdiationMessages in the process
            amt.validationMessages = new List <string>();
            if (SisOneOffValidation.RunOneOffValidation(formsRepo, frm, fr.EnterpriseID.Value, allResponses, amt))
            {
                invalid = true;
            }

            if (invalid)
            {
                return(false);
            }

            //  Mark the FormResult as Complete
            new Assessments(formsRepo).AssessmentComplete(fr);// formsRepo.FormResultComplete(fr);

            // Insert status log indicating assessment has been marked complete
            if (SessionHelper.IsVentureMode == false)
            {
                ReviewStatus.AssessmentIsCompleted(formsRepo, fr);

                if (WebServiceActivity.IsWebServiceEnabled())
                {
                    WebServiceActivity.CallWebService(formsRepo, (int)WebServiceActivity.webServiceActivityFunctions.COMPLETE, "formResultId=" + fr.formResultId.ToString());
                }
            }

            // Populate the hidden Venture Version field upon validation

            if (SessionHelper.IsVentureMode == true)
            {
                string ventureVersion = SessionHelper.Read <string>("venture_version");

                if (ventureVersion != null)
                {
                    Updates.AddField(formsRepo, Updates.SIS_HIDDEN, fr, Updates.VENTURE_VERSION, ventureVersion);
                }
            }

            return(true);
        }