예제 #1
0
        /// <summary>
        /// Recursive method that builds the XML output structure
        /// </summary>
        /// <param name="appendTo"></param>
        /// <param name="doc"></param>
        /// <param name="schemaElem"></param>
        /// <param name="formResultId"></param>
        /// <param name="formsRepo"></param>
        public static void BuildResponseXml(
            XmlNode appendTo,
            XmlDocument doc,
            RamsellExport.DefSchemaElement schemaElem,
            int formResultId,
            IFormsRepository formsRepo)
        {
            RamsellExport.DefStructureElement structElem = schemaElem as RamsellExport.DefStructureElement;
            RamsellExport.DefResponseElement  rspElem    = schemaElem as RamsellExport.DefResponseElement;

            //if this is a structural element...
            if (structElem != null)
            {
                if (structElem.tagName == "Income_Item")
                {
                    //special case for "Income_Item" structure, with multiple occurences
                    AppendIncomeStructs(appendTo, doc, structElem, formResultId, formsRepo);
                }
                else
                {
                    //normal logic for structural elements: insert a single structural node and recurse for each child element
                    XmlElement outputElem = doc.CreateElement(schemaElem.tagName, Utilities.xmlNamespaceURI);
                    foreach (RamsellExport.DefSchemaElement child in structElem.children)
                    {
                        BuildResponseXml(outputElem, doc, child, formResultId, formsRepo);
                    }

                    if (appendTo == null)
                    {
                        doc.AppendChild(outputElem);
                    }
                    else
                    {
                        appendTo.AppendChild(outputElem);
                    }
                }
            }

            //if this is a response element...
            else if (rspElem != null)
            {
                TransformAndAppendResponseNodesToXML(appendTo, doc, rspElem, formResultId, formsRepo);
            }
            else
            {
                throw new Exception("Unrecognized SchemaElement subclass \"" + schemaElem.GetType().Name + "\"");
            }
        }
예제 #2
0
        public static void AppendIncomeStructs(
            XmlNode appendTo,
            XmlDocument doc,
            RamsellExport.DefStructureElement incomeStructElem,
            int formResultId,
            IFormsRepository formsRepo)
        {
            int totalMonthlyAmtNum = 0;

            //iterate though each of the subsections "ADAP_F3_[A-D]"
            foreach (string subsectionLetter in new string[] { "A", "B", "C", "D" })
            {
                string subsectionName = "ADAP_F3_" + subsectionLetter;

                def_ResponseVariables incomeEarnerNameRV = formsRepo.GetResponseVariablesByFormResultIdentifier(formResultId, subsectionName + "_Recipient");

                def_ResponseVariables monthlyAmtRV = formsRepo.GetResponseVariablesByFormResultIdentifier(formResultId, subsectionName + "_IncomeAmt");
                string monthlyAmtVal = null;
                if (monthlyAmtRV != null && !String.IsNullOrWhiteSpace(monthlyAmtRV.rspValue))
                {
                    monthlyAmtVal = monthlyAmtRV.rspValue;
                }

                int monthlyAmtNum = 0;
                Int32.TryParse(monthlyAmtVal, out monthlyAmtNum);
                totalMonthlyAmtNum += monthlyAmtNum;

                //ADAP_F3_[A-D]_IncomeTypeDrop options

                //0 = Employment
                //1 = Unemployment benefits
                //2 = Short-/Long-term disability
                //3 = SSI (supplemental Security Income)
                //4 = Worker's compensation
                //5 = SSDI (Supplemental Security Disability Insurance)
                //6 = AND (Aid to the Needy Disabled)
                //7 = TANF (Temporary Aid to Needy Families)
                //8 = Interest/Investment Income
                //9 = Veterans benefits
                //10 = Retirement/Pension
                //11 = Taxable trust income
                //12 = Alimony paid to you
                //13 = Other (please describe below)

                def_ResponseVariables incomeTypeRV = formsRepo.GetResponseVariablesByFormResultIdentifier(formResultId, subsectionName + "_IncomeTypeDrop");
                string incomeTypeVal = "";
                if (incomeTypeRV != null && !String.IsNullOrWhiteSpace(incomeTypeRV.rspValue))
                {
                    incomeTypeVal = incomeTypeRV.rspValue;
                }

                //create income_item structure and add children
                XmlElement incomeStruct = doc.CreateElement(incomeStructElem.tagName, Utilities.xmlNamespaceURI);
                foreach (RamsellExport.DefSchemaElement child in incomeStructElem.children)
                {
                    if (child.tagName == "Income_Earner_Name")
                    {
                        if (incomeEarnerNameRV != null && !String.IsNullOrWhiteSpace(incomeEarnerNameRV.rspValue))
                        {
                            AppendContentNodeToXML(incomeStruct, doc, child.tagName, incomeEarnerNameRV.rspValue);
                        }
                    }

                    else if (child.tagName == "Salary_Wages" && incomeTypeVal == "0" && monthlyAmtVal != null)
                    {
                        AppendContentNodeToXML(incomeStruct, doc, child.tagName, monthlyAmtVal);
                    }

                    else if (child.tagName == "Investments_Trust" && incomeTypeVal == "8" && monthlyAmtVal != null)
                    {
                        AppendContentNodeToXML(incomeStruct, doc, child.tagName, monthlyAmtVal);
                    }

                    else if (child.tagName == "SSDI" && incomeTypeVal == "5" && monthlyAmtVal != null)
                    {
                        AppendContentNodeToXML(incomeStruct, doc, child.tagName, monthlyAmtVal);
                    }

                    else if (child.tagName == "SSI" && incomeTypeVal == "3" && monthlyAmtVal != null)
                    {
                        AppendContentNodeToXML(incomeStruct, doc, child.tagName, monthlyAmtVal);
                    }

                    else if (child.tagName == "AND" && incomeTypeVal == "6" && monthlyAmtVal != null)
                    {
                        AppendContentNodeToXML(incomeStruct, doc, child.tagName, monthlyAmtVal);
                    }

                    else if (child.tagName == "Workers_Comp" && incomeTypeVal == "4" && monthlyAmtVal != null)
                    {
                        AppendContentNodeToXML(incomeStruct, doc, child.tagName, monthlyAmtVal);
                    }

                    else if (child.tagName == "Child_Support_Alimony" && incomeTypeVal == "12" && monthlyAmtVal != null)
                    {
                        AppendContentNodeToXML(incomeStruct, doc, child.tagName, monthlyAmtVal);
                    }

                    else if (child.tagName == "Retirement" && incomeTypeVal == "10" && monthlyAmtVal != null)
                    {
                        AppendContentNodeToXML(incomeStruct, doc, child.tagName, monthlyAmtVal);
                    }

                    else if (child.tagName == "VA_Income" && incomeTypeVal == "9" && monthlyAmtVal != null)
                    {
                        AppendContentNodeToXML(incomeStruct, doc, child.tagName, monthlyAmtVal);
                    }

                    else if (child.tagName == "Unemployment" && incomeTypeVal == "1" && monthlyAmtVal != null)
                    {
                        AppendContentNodeToXML(incomeStruct, doc, child.tagName, monthlyAmtVal);
                    }

                    else if (child.tagName == "Other" && incomeTypeVal == "13" && monthlyAmtVal != null)
                    {
                        AppendContentNodeToXML(incomeStruct, doc, child.tagName, monthlyAmtVal);
                    }

                    else if (child.tagName == "Other_Description" && incomeTypeVal == "13")
                    {
                        def_ResponseVariables descRV = formsRepo.GetResponseVariablesByFormResultIdentifier(formResultId, subsectionName + "_IncomeTypeOther");
                        if (descRV != null && !String.IsNullOrWhiteSpace(descRV.rspValue))
                        {
                            AppendContentNodeToXML(incomeStruct, doc, child.tagName, descRV.rspValue);
                        }
                    }

                    else
                    {
                        Debug.WriteLine("* * * ramsellExport.AppendIncomeStructs() - found unrecognized Income_Item child tag \"" + child.tagName + "\", skipping...");
                    }
                }


                //if the income_item node contains any info, add it to xml
                if (incomeStruct.ChildNodes.Count > 0)
                {
                    if (appendTo == null)
                    {
                        doc.AppendChild(incomeStruct);
                    }
                    else
                    {
                        appendTo.AppendChild(incomeStruct);
                    }
                }
            }

            AppendContentNodeToXML(appendTo, doc, "Total_Income", (totalMonthlyAmtNum * 12).ToString());
        }