Example #1
0
        }                                            // ID

        public virtual void AddChild(AExperianLtdDataRow oKid)
        {
            if (oKid != null)
            {
                Children.Add(oKid);
            }
        }         // AddChild
Example #2
0
        }         // SetDecimal

        private static void SetDate(PropertyInfo pi, AExperianLtdDataRow oCurTable, string sValue)
        {
            DateTime n;

            if (DateTime.TryParseExact(sValue, "yyyyMMdd", ms_oCulture, DateTimeStyles.AssumeUniversal, out n))
            {
                pi.SetValue(oCurTable, n);
            }
            else
            {
                pi.SetValue(oCurTable, null);
            }
        }         // SetDate
Example #3
0
        }         // SetInt

        private static void SetDecimal(PropertyInfo pi, AExperianLtdDataRow oCurTable, string sValue)
        {
            decimal n;

            if (decimal.TryParse(sValue, out n))
            {
                pi.SetValue(oCurTable, n);
            }
            else
            {
                pi.SetValue(oCurTable, null);
            }
        }         // SetDecimal
Example #4
0
        }         // SetValue

        private static void SetInt(PropertyInfo pi, AExperianLtdDataRow oCurTable, string sValue)
        {
            int n;

            if (int.TryParse(sValue, out n))
            {
                pi.SetValue(oCurTable, n);
            }
            else
            {
                pi.SetValue(oCurTable, null);
            }
        }         // SetInt
Example #5
0
        }         // SelfSave

        protected virtual void LoadOneChildFromXml(XmlNode oRoot, Type oTableType, ASrcAttribute oGroupSrcAttr)
        {
            oGroupSrcAttr = oGroupSrcAttr ?? oTableType.GetCustomAttribute <ASrcAttribute>();

            Log.Debug("Parsing Experian company data into {0}...", oTableType.Name);

            ConstructorInfo ci = oTableType.GetConstructors().FirstOrDefault();

            if (ci == null)
            {
                Log.Alert("Parsing Experian company data into {0} failed: no constructor found.", oTableType.Name);
                return;
            }             // if

            XmlNodeList oGroupNodes = oRoot.SelectNodes(oGroupSrcAttr.GroupPath);

            if (oGroupNodes == null)
            {
                Log.Debug("Parsing Experian company data into {0}: no XML nodes found.", oTableType.Name);
                return;
            }             // if

            Log.Debug(
                "Parsing Experian company data into {0}: {1} XML node{2} found.",
                oTableType.Name,
                oGroupNodes.Count,
                oGroupNodes.Count == 1 ? "" : "s"
                );

            foreach (XmlNode oGroup in oGroupNodes)
            {
                AExperianLtdDataRow oRow = (AExperianLtdDataRow)ci.Invoke(new object[] { Log });

                oRow.LoadFromXml(oGroup);

                if (oRow.ShouldBeSaved())
                {
                    Children.Add(oRow);
                }
            }             // for each matching XML node

            Log.Debug("Parsing Experian company data into {0} complete.", oTableType.Name);
        }         // LoadOneChildFromXml
Example #6
0
        }         // LoadOneChildFromXml

        private static void SetValue(AExperianLtdDataRow oCurTable, PropertyInfo pi, XmlNode oNode)
        {
            if (pi.PropertyType == typeof(string))
            {
                pi.SetValue(oCurTable, oNode.InnerText);
            }
            else if (pi.PropertyType == typeof(int?))
            {
                SetInt(pi, oCurTable, oNode.InnerText);
            }
            else if (pi.PropertyType == typeof(decimal?))
            {
                SetDecimal(pi, oCurTable, oNode.InnerText);
            }
            else if (pi.PropertyType == typeof(DateTime?))
            {
                if (oNode.Name.EndsWith("-YYYY"))
                {
                    string sPrefix = oNode.Name.Substring(0, oNode.Name.Length - 5);

                    // ReSharper disable PossibleNullReferenceException
                    XmlNode oMonthNode = oNode.ParentNode.SelectSingleNode(sPrefix + "-MM");

                    XmlNode oDayNode = oMonthNode == null ? null : oNode.ParentNode.SelectSingleNode(sPrefix + "-DD");
                    // ReSharper restore PossibleNullReferenceException

                    if (oDayNode != null)
                    {
                        SetDate(pi, oCurTable, oNode.InnerText + MD(oMonthNode) + MD(oDayNode));
                    }
                }
                else
                {
                    SetDate(pi, oCurTable, oNode.InnerText);
                }
            }     // if
        }         // SetValue
Example #7
0
        }         // Load

        private static ExperianLtd Load(IEnumerable <SafeReader> lst, ASafeLog oLog)
        {
            var oResult = new ExperianLtd();

            var oKidMap = new SortedTable <string, long, AExperianLtdDataRow>();

            foreach (SafeReader sr in lst)
            {
                string sType = sr["DatumType"];

                if (sType == "Metadata")
                {
                    oResult.ReceivedTime = sr["InsertDate"];
                    continue;
                }                 // if

                Type oType = typeof(ExperianLtd).Assembly.GetType(typeof(ExperianLtd).Namespace + "." + sType);

                if (oType == null)
                {
                    oLog.Alert("Could not find type '{0}'.", sType);
                    continue;
                }                 // if

                AExperianLtdDataRow oRow;

                if (oType == typeof(ExperianLtd))
                {
                    oRow = oResult;
                }
                else
                {
                    ConstructorInfo ci = oType.GetConstructors().FirstOrDefault();

                    if (ci == null)
                    {
                        oLog.Alert("Parsing Experian company data into {0} failed: no constructor found.", oType.Name);
                        continue;
                    }                     // if

                    oRow = (AExperianLtdDataRow)ci.Invoke(new object[] { oLog });
                }                 // if

                sr.Fill(oRow);

                oRow.ID       = sr["ID"];
                oRow.ParentID = sr["ParentID"];

                oKidMap[sType, oRow.ID] = oRow;

                string sParentType = sr["ParentType"];

                if (string.IsNullOrWhiteSpace(sParentType))
                {
                    // oLog.Debug("No parent row. This row: id {0} of type {1}.", oRow.ID, sType);
                    continue;
                }                 // if

                AExperianLtdDataRow oParent = oKidMap[sParentType, oRow.ParentID];

                if (oParent == null)
                {
                    oLog.Alert(
                        "No parent row found.\n\tThis row: id {0} of type {1}.\n\tParent row: id {2} of type {3}.",
                        oRow.ID, sType, oRow.ParentID, sParentType
                        );
                }
                else
                {
                    oParent.AddChild(oRow);
                    // Log.Debug("\n\tThis row: id {0} of type {1}.\n\tParent row: id {2} of type {3}.", oRow.ID, sType, oRow.ParentID, sParentType);
                }         // if
            }             // for each row

            return(oResult);
        }         // Load