internal static CellSetData Deserialize(XmlReader reader) { if (reader != null) { try { if (!(reader.NodeType == XmlNodeType.Element && reader.Name == XML_CellSetData)) { reader.ReadToFollowing(XML_CellSetData); } CellSetData target = new CellSetData(); // Начало - CellSetData reader.ReadStartElement(XML_CellSetData); var data = Jayrock.Json.Conversion.JsonConvert.Import(reader.Value) as JsonArray; // Имя куба target.CubeName = data[0] != null ? data[0].ToString() : String.Empty; // Соединение var connection = data.GetArray(1); target.Connection.ConnectionID = connection[0].ToString(); target.Connection.ConnectionString = connection[1].ToString(); reader.Read(); // Оси reader.ReadStartElement("Axes"); var axes = Jayrock.Json.Conversion.JsonConvert.Import(reader.Value) as JsonArray; for (int a = 0; a < axes.Count; a++) { var axis_data = axes.GetArray(a); AxisData axis = new AxisData(); axis.AxisNum = a; // Название оси axis.Name = axis_data[0].ToString(); // Позиции var positions = axis_data.GetArray(1); for (int p = 0; p < positions.Count; p++) { var position_data = positions.GetArray(p); PositionData pos = new PositionData(); for (int m = 0; m < position_data.Count; m++) { var member_data = position_data.GetArray(m); PositionMemberData member = new PositionMemberData(Convert.ToInt32(member_data[0])); member.DrilledDown = Convert.ToBoolean(member_data[1]); pos.Members.Add(member); } axis.Positions.Add(pos); } // Названаия свойств var PropertiesNames = axis_data.GetArray(2); // Названаия пользовательских свойств var MemberPropertiesNames = axis_data.GetArray(3); // Элементы оси var members = axis_data.GetArray(4); // Варианты стиля var equalsMemberProps = axis_data.GetArray(5); // Описание стиля var equalsMemberPropertiesNames = axis_data.GetArray(6); for (int m = 0; m < members.Count; m++) { var member_data = members.GetArray(m); var Settings = member_data.GetArray(0); var PropertiesValues = member_data.GetArray(1); var MemberPropertiesValues = member_data.GetArray(2); int MemberPropertiesStyleId = Convert.ToInt32(member_data[3]); MemberData member = new MemberData(); int x = 0; member.Caption = Settings[x++].ToString(); member.Description = Settings[x++].ToString(); member.Name = Settings[x++].ToString(); member.UniqueName = Settings[x++].ToString(); member.ChildCount = Convert.ToInt32(Settings[x++].ToString()); member.DrilledDown = Convert.ToBoolean(Settings[x++].ToString()); member.LevelDepth = Convert.ToInt32(Settings[x++].ToString()); member.LevelName = Settings[x++].ToString(); member.HierarchyUniqueName = Settings[x++].ToString(); member.ParentSameAsPrevious = Convert.ToBoolean(Settings[x++].ToString()); for (int j = 0; j < PropertiesValues.Length; j++) { member.Properties.Add(new PropertyData(PropertiesNames[j].ToString(), ConvertFromJson(PropertiesValues[j]))); } for (int j = 0; j < MemberPropertiesValues.Length; j++) { member.MemberProperties.Add(new PropertyData(MemberPropertiesNames[j].ToString(), ConvertFromJson(MemberPropertiesValues[j]))); } var member_equalsPropsValues = equalsMemberProps.GetArray(MemberPropertiesStyleId); for (int k = 0; k < equalsMemberPropertiesNames.Length; k++) { var propName = equalsMemberPropertiesNames[k].ToString(); member.MemberProperties.Add(new PropertyData(propName, ConvertFromJson(member_equalsPropsValues[k]))); } axis.Members.Add(axis.Members.Count, member); } target.Axes.Add(axis); } reader.Read(); if (reader.NodeType == XmlNodeType.EndElement && reader.Name == "Axes") { reader.ReadEndElement(); } // Ячейки reader.ReadStartElement("Cells"); var strData = reader.Value; target.DeserializeData(strData); reader.Read(); if (reader.NodeType == XmlNodeType.EndElement && reader.Name == "Cells") { reader.ReadEndElement(); } // Конец - CellSetData if (reader.NodeType == XmlNodeType.EndElement && reader.Name == XML_CellSetData) { reader.ReadEndElement(); } return(target); } catch (XmlException) { throw; } } return(null); }
internal static CellSetData Deserialize(XmlReader reader) { if (reader != null) { try { if (!(reader.NodeType == XmlNodeType.Element && reader.Name == XML_CellSetData)) { reader.ReadToFollowing(XML_CellSetData); } CellSetData target = new CellSetData(); // Начало - CellSetData reader.ReadStartElement(XML_CellSetData); var data = Jayrock.Json.Conversion.JsonConvert.Import(reader.Value) as JsonArray; // Имя куба target.CubeName = data[0] != null ? data[0].ToString() : String.Empty; // Соединение var connection = data.GetArray(1); target.Connection.ConnectionID = connection[0].ToString(); target.Connection.ConnectionString = connection[1].ToString(); reader.Read(); // Оси reader.ReadStartElement("Axes"); var axes = Jayrock.Json.Conversion.JsonConvert.Import(reader.Value) as JsonArray; for (int a = 0; a < axes.Count; a++) { var axis_data = axes.GetArray(a); AxisData axis = new AxisData(); axis.AxisNum = a; // Название оси axis.Name = axis_data[0].ToString(); // Позиции var positions = axis_data.GetArray(1); for (int p = 0; p < positions.Count; p++) { var position_data = positions.GetArray(p); PositionData pos = new PositionData(); for (int m = 0; m < position_data.Count; m++) { var member_data = position_data.GetArray(m); PositionMemberData member = new PositionMemberData(Convert.ToInt32(member_data[0])); member.DrilledDown = Convert.ToBoolean(member_data[1]); pos.Members.Add(member); } axis.Positions.Add(pos); } // Названаия свойств var PropertiesNames = axis_data.GetArray(2); // Названаия пользовательских свойств var MemberPropertiesNames = axis_data.GetArray(3); // Элементы оси var members = axis_data.GetArray(4); // Варианты стиля var equalsMemberProps = axis_data.GetArray(5); // Описание стиля var equalsMemberPropertiesNames = axis_data.GetArray(6); for (int m = 0; m < members.Count; m++) { var member_data = members.GetArray(m); var Settings = member_data.GetArray(0); var PropertiesValues = member_data.GetArray(1); var MemberPropertiesValues = member_data.GetArray(2); int MemberPropertiesStyleId = Convert.ToInt32(member_data[3]); MemberData member = new MemberData(); int x = 0; member.Caption = Settings[x++].ToString(); member.Description = Settings[x++].ToString(); member.Name = Settings[x++].ToString(); member.UniqueName = Settings[x++].ToString(); member.ChildCount = Convert.ToInt32(Settings[x++].ToString()); member.DrilledDown = Convert.ToBoolean(Settings[x++].ToString()); member.LevelDepth = Convert.ToInt32(Settings[x++].ToString()); member.LevelName = Settings[x++].ToString(); member.HierarchyUniqueName = Settings[x++].ToString(); member.ParentSameAsPrevious = Convert.ToBoolean(Settings[x++].ToString()); for (int j = 0; j < PropertiesValues.Length; j++) { member.Properties.Add(new PropertyData(PropertiesNames[j].ToString(), ConvertFromJson(PropertiesValues[j]))); } for (int j = 0; j < MemberPropertiesValues.Length; j++) { member.MemberProperties.Add(new PropertyData(MemberPropertiesNames[j].ToString(), ConvertFromJson(MemberPropertiesValues[j]))); } var member_equalsPropsValues = equalsMemberProps.GetArray(MemberPropertiesStyleId); for (int k = 0; k < equalsMemberPropertiesNames.Length; k++) { var propName = equalsMemberPropertiesNames[k].ToString(); member.MemberProperties.Add(new PropertyData(propName, ConvertFromJson(member_equalsPropsValues[k]))); } axis.Members.Add(axis.Members.Count, member); } target.Axes.Add(axis); } reader.Read(); if (reader.NodeType == XmlNodeType.EndElement && reader.Name == "Axes") { reader.ReadEndElement(); } // Ячейки reader.ReadStartElement("Cells"); var strData = reader.Value; target.DeserializeData(strData); reader.Read(); if (reader.NodeType == XmlNodeType.EndElement && reader.Name == "Cells") { reader.ReadEndElement(); } // Конец - CellSetData if (reader.NodeType == XmlNodeType.EndElement && reader.Name == XML_CellSetData) { reader.ReadEndElement(); } return target; } catch (XmlException) { throw; } } return null; }