/// <summary> /// Insert attribute group. /// </summary> /// <param name="state"> /// The state. /// </param> /// <param name="dsd"> /// The DSD. /// </param> /// <param name="components"> /// The components. /// </param> private static void InsertAttributeDimensions(DbTransactionState state, IDataStructureObject dsd, ItemStatusCollection components) { var parameterList = new List <DbParameter[]>(); foreach (var attributeObject in dsd.DimensionGroupAttributes) { ItemStatus attributeStatus; if (components.TryGetValue(attributeObject.Id, out attributeStatus)) { foreach (var dimensionReference in attributeObject.DimensionReferences) { ItemStatus dimensionStatus; if (components.TryGetValue(dimensionReference, out dimensionStatus)) { var parameters = new DbParameter[2]; parameters[0] = state.Database.CreateInParameter(IdParameter, DbType.Int64, attributeStatus.SysID); parameters[1] = state.Database.CreateInParameter(GroupIdParameter, DbType.Int64, dimensionStatus.SysID); parameterList.Add(parameters); } } } } state.ExecuteNonQueryFormat("insert into ATTR_DIMS (ATTR_ID, DIM_ID) VALUES ({0}, {1})", parameterList); }
/// <summary> /// Inserts the attribute attachment measures. (SDMX V2.0 only) /// </summary> /// <param name="state">The state.</param> /// <param name="dsd">The DSD.</param> /// <param name="components">The components.</param> private static void InsertAttributeAttachmentMeasures(DbTransactionState state, IDataStructureObject dsd, ItemStatusCollection components) { var cross = dsd as ICrossSectionalDataStructureObject; if (cross == null) { // it is not a SDXM v2.0 cross sectional DSD therefor there are no Measure dimensions or CrossSectional measures. return; } var parameterList = new List <DbParameter[]>(); foreach (var attributeObject in cross.Attributes) { ItemStatus attributeStatus; if (components.TryGetValue(attributeObject.Id, out attributeStatus)) { foreach (var crossSectionalMeasure in cross.GetAttachmentMeasures(attributeObject)) { ItemStatus measureStatus; if (components.TryGetValue(crossSectionalMeasure.Id, out measureStatus)) { var parameters = new DbParameter[2]; parameters[0] = state.Database.CreateInParameter(IdParameter, DbType.Int64, attributeStatus.SysID); parameters[1] = state.Database.CreateInParameter("measureId", DbType.Int64, measureStatus.SysID); parameterList.Add(parameters); } } } } state.ExecuteNonQueryFormat("insert into ATT_MEASURE (ATT_COMP_ID, MEASURE_COMP_ID) VALUES ({0}, {1})", parameterList); }
/// <summary> /// Insert dimension group. /// </summary> /// <param name="state"> /// The state. /// </param> /// <param name="dsd"> /// The DSD. /// </param> /// <param name="groups"> /// The groups. /// </param> /// <param name="components"> /// The components. /// </param> private static void InsertDimensionGroup(DbTransactionState state, IDataStructureObject dsd, ItemStatusCollection groups, ItemStatusCollection components) { var parameterList = new List <DbParameter[]>(); foreach (var dsdGroup in dsd.Groups) { ItemStatus dsdGroupStatus; if (groups.TryGetValue(dsdGroup.Id, out dsdGroupStatus)) { foreach (var dimensionRef in dsdGroup.DimensionRefs) { ItemStatus dimensionStatus; if (components.TryGetValue(dimensionRef, out dimensionStatus)) { var parameters = new DbParameter[2]; parameters[0] = state.Database.CreateInParameter(IdParameter, DbType.Int64, dimensionStatus.SysID); parameters[1] = state.Database.CreateInParameter(GroupIdParameter, DbType.Int64, dsdGroupStatus.SysID); parameterList.Add(parameters); } } } } state.ExecuteNonQueryFormat("insert into DIM_GROUP (COMP_ID, GR_ID) VALUES ({0}, {1})", parameterList); }
/// <summary> /// Insert attribute group. /// </summary> /// <param name="state"> /// The state. /// </param> /// <param name="dsd"> /// The DSD. /// </param> /// <param name="groups"> /// The groups. /// </param> /// <param name="components"> /// The components. /// </param> private static void InsertAttributeGroup(DbTransactionState state, IDataStructureObject dsd, ItemStatusCollection groups, ItemStatusCollection components) { var parameterList = new List <DbParameter[]>(); foreach (var attributeObject in dsd.GroupAttributes) { ItemStatus dsdGroupStatus; if (attributeObject.AttachmentGroup != null && groups.TryGetValue(attributeObject.AttachmentGroup, out dsdGroupStatus)) { ItemStatus attributeStatus; if (components.TryGetValue(attributeObject.Id, out attributeStatus)) { var parameters = new DbParameter[2]; parameters[0] = state.Database.CreateInParameter(IdParameter, DbType.Int64, attributeStatus.SysID); parameters[1] = state.Database.CreateInParameter(GroupIdParameter, DbType.Int64, dsdGroupStatus.SysID); parameterList.Add(parameters); } } } state.ExecuteNonQueryFormat("insert into ATT_GROUP (COMP_ID, GR_ID) VALUES ({0}, {1})", parameterList); }