private void ValidateOlapReport(ReportsValidation.OlapReportsRow row)
        {
            if (row == null || row.IsReportXmlNull() || row.ReportXml == "")
            {
                return;
            }

            XmlDocument doc = new XmlDocument();

            doc.LoadXml(row.ReportXml);

            // clear stats
            row.ObjectsInvalid    = 0;
            row.ObjectsInvalidNew = 0;
            row.InvalidDiff       = 0;

            // dimensions
            foreach (XmlElement el in doc.GetElementsByTagName("D"))
            {
                string un = el.GetAttribute("UN");
                un = ValidateOlapObject(SchemaObjectType.ObjectTypeDimension, un, row);
                el.SetAttribute("UN", un);
            }

            // hierarchies
            foreach (XmlElement el in doc.GetElementsByTagName("H"))
            {
                string un = el.GetAttribute("UN");
                un = ValidateOlapObject(SchemaObjectType.ObjectTypeHierarchy, un, row);
                el.SetAttribute("UN", un);
            }

            // levels
            foreach (XmlElement el in doc.GetElementsByTagName("L"))
            {
                string un = el.GetAttribute("UN");
                un = ValidateOlapObject(SchemaObjectType.ObjectTypeLevel, un, row);
                el.SetAttribute("UN", un);
            }

            // members
            foreach (XmlElement el in doc.GetElementsByTagName("M"))
            {
                string un   = el.GetAttribute("UN");
                string calc = el.GetAttribute("C");

                if (calc != "1")
                {
                    un = ValidateOlapObject(SchemaObjectType.ObjectTypeMember, un, row);
                    el.SetAttribute("UN", un);
                }
            }

            // save back
            row.ReportXml = doc.OuterXml;
        }
        public void SaveReports()
        {
            if (_reports == null)
            {
                return;
            }

            SqlConnection reportConn = null;

            try
            {
                _reports.BeginInit();

                // open connection
                reportConn = new SqlConnection(ConfigurationManager.AppSettings["DBFINFConnection"]);
                reportConn.Open();

                // save changed and accept cahnges
                for (int i = 0; i < _reports.OlapReports.Count; i++)
                {
                    ReportsValidation.OlapReportsRow row = _reports.OlapReports[i];
                    if (row.RowState != System.Data.DataRowState.Modified)
                    {
                        continue;
                    }

                    // save xml
                    SqlCommand cmd = reportConn.CreateCommand();
                    cmd.CommandText = "update t_olap_reports set data=@data where id=@id";
                    cmd.Parameters.AddWithValue("@id", row.Id);
                    cmd.Parameters.AddWithValue("@data", row.ReportXml);
                    cmd.ExecuteNonQuery();
                    cmd.Dispose();

                    // accept
                    row.AcceptChanges();
                }
            }
            finally
            {
                if (reportConn != null)
                {
                    reportConn.Close();
                }

                if (_reports != null)
                {
                    _reports.EndInit();
                }
            }
        }
        private string ValidateOlapObject(SchemaObjectType type, string uniqueName, ReportsValidation.OlapReportsRow row)
        {
            // resolve source object
            object srcObject = (_srcUnmatched.Contains(uniqueName) ? null : SourceSchemaMap.LookupAdomdSchemaObject(_srcCube, type, uniqueName));

            if (srcObject == null)
            {
                if (!_srcUnmatched.Contains(uniqueName))
                {
                    _srcUnmatched.Add(uniqueName);
                }
                row.ObjectsInvalid++;
            }

            // try to convert manually
            string destUniqueName = null;

            if (!_destUnmatched.Contains(uniqueName))
            {
                if (uniqueName.StartsWith("[Central Chain]"))
                {
                    destUniqueName = LookupCentralChain(uniqueName);
                }
                else if (uniqueName.StartsWith("[Chain]"))
                {
                    destUniqueName = LookupChain(uniqueName);
                }
                else if (uniqueName.StartsWith("[Store].[Chain]"))
                {
                    destUniqueName = LookupStoreChain(uniqueName);
                }
                else if (uniqueName.StartsWith("[Store].[Postal Code]"))
                {
                    destUniqueName = LookupStorePostalCode(uniqueName);
                }
                else if (uniqueName.StartsWith("[Time].[Monthly]"))
                {
                    destUniqueName = LookupTimeMonthly(uniqueName);
                }
                else if (uniqueName.StartsWith("[Time].[Weekly]"))
                {
                    destUniqueName = LookupTimeWeekly(uniqueName);
                }
                else if (uniqueName.StartsWith("[Expand Compound Products]"))
                {
                    destUniqueName = LookupExpandProductGroups(uniqueName);
                }

                // convert using map
                if (destUniqueName == null)
                {
                    destUniqueName = _map.ConvertSchemaObjectUN(type, uniqueName);
                }
            }

            // lookup dest object (if matched)
            if (destUniqueName == null || SourceSchemaMap.LookupAdomdSchemaObject(_destCube, type, destUniqueName) == null)
            {
                destUniqueName = null;
                if (!_srcUnmatched.Contains(uniqueName) && !_destUnmatched.Contains(uniqueName))
                {
                    _destUnmatched.Add(uniqueName);
                }
                row.ObjectsInvalidNew++;
            }

            // diff
            row.InvalidDiff = (row.ObjectsInvalidNew - row.ObjectsInvalid);

            // return
            return(destUniqueName == null ? uniqueName : destUniqueName);
        }
Exemple #4
0
        private void ConvertOlapReport(ReportsValidation.OlapReportsRow row)
        {
            if (row == null || row.IsReportXmlNull() || row.ReportXml == "")
            {
                return;
            }

            XmlDocument doc = new XmlDocument();

            doc.LoadXml(row.ReportXml);

            // clear stats
            row.ObjectsInvalid    = 0;
            row.ObjectsInvalidNew = 0;
            row.InvalidDiff       = 0;

            // axes
            foreach (XmlElement axisEl in doc.GetElementsByTagName("A"))
            {
                int axisOrdinal = int.Parse(axisEl.GetAttribute("ORD"));

                // dimensions
                foreach (XmlElement el in axisEl.GetElementsByTagName("D"))
                {
                    string un = el.GetAttribute("UN");
                    un = ValidateOlapObject(SchemaObjectType.ObjectTypeDimension, un, row);
                    el.SetAttribute("UN", un);
                    row.ObjectsTotal++;
                }

                // hierarchies
                foreach (XmlElement el in axisEl.GetElementsByTagName("H"))
                {
                    string un = el.GetAttribute("UN");
                    un = ValidateOlapObject(SchemaObjectType.ObjectTypeHierarchy, un, row);
                    el.SetAttribute("UN", un);
                    row.ObjectsTotal++;
                }

                // levels
                foreach (XmlElement el in axisEl.GetElementsByTagName("L"))
                {
                    string un = el.GetAttribute("UN");
                    un = ValidateOlapObject(SchemaObjectType.ObjectTypeLevel, un, row);
                    el.SetAttribute("UN", un);
                    row.ObjectsTotal++;
                }

                // members
                foreach (XmlElement el in axisEl.GetElementsByTagName("M"))
                {
                    string un   = el.GetAttribute("UN");
                    string calc = el.GetAttribute("C");

                    if (calc != "1")
                    {
                        un = ValidateOlapObject(SchemaObjectType.ObjectTypeMember, un, row);
                        el.SetAttribute("UN", un);
                        row.ObjectsTotal++;
                    }
                }

                // calc members, cannot use enumerator because list of nodes is being changed inside
                XmlNodeList list = axisEl.GetElementsByTagName("M");
                for (int i = 0; i < list.Count; i++)
                {
                    XmlElement el = list[i] as XmlElement;
                    if (el == null)
                    {
                        continue;
                    }

                    // special conversion of [Time].[Monthly].[Year].&[XXXX].Children calculated member
                    bool converted = ConvertYearChildrenCalculatedMember(el);
                    if (converted)
                    {
                        row.ObjectsTotal++;
                    }
                }

                // order tuple members
                foreach (XmlElement el in axisEl.GetElementsByTagName("OTM"))
                {
                    string un = el.GetAttribute("UN");

                    un = ValidateOlapObject(SchemaObjectType.ObjectTypeMember, un, row);
                    el.SetAttribute("UN", un);
                    row.ObjectsTotal++;
                }
            }

            // save back
            row.ReportXml = doc.OuterXml;
        }