示例#1
0
        /// <summary>
        /// Imports mappingValues
        /// </summary>
        /// <param name="fileNameWPath"></param>
        /// <param name="importDefaultValues"></param>
        /// <param name="importRowsMapping"></param>
        /// <param name="importColsMapping"></param>
        public void ImportFrmFile(string fileNameWPath, bool importDefaultValues, bool importRowsMapping, bool importColsMapping, int startingTableIndex)
        {
            XmlSerializer         SerializedObject;
            StreamReader          Reader;
            CrossTabInputFileInfo SrcInputFileInfo = null;

            try
            {
                if (File.Exists(fileNameWPath))
                {
                    SerializedObject = new XmlSerializer(typeof(CrossTabInputFileInfo));
                    Reader           = new StreamReader(fileNameWPath);
                    SrcInputFileInfo = (CrossTabInputFileInfo)SerializedObject.Deserialize(Reader);
                    Reader.Close();

                    if (SrcInputFileInfo != null)
                    {
                        this.ImportMappingValues(SrcInputFileInfo, importDefaultValues, importRowsMapping, importColsMapping, startingTableIndex);
                    }
                }
            }
            catch (Exception)
            {
                SrcInputFileInfo = DXSFileConveter.GetInputFileInfo(fileNameWPath);
                if (SrcInputFileInfo != null)
                {
                    this.ImportMappingValues(SrcInputFileInfo, importDefaultValues, importRowsMapping, importColsMapping, startingTableIndex);
                }
            }
        }
示例#2
0
        public static CrossTabInputFileInfo GetInputFileInfo(string filenameWPath)
        {
            CrossTabInputFileInfo RetVal;
            DataSet DXMDataSet;

            try
            {
                DXMDataSet = new DataSet();
                DXMDataSet.ReadXml(filenameWPath, XmlReadMode.ReadSchema);
                RetVal = new CrossTabInputFileInfo();
                if (DXMDataSet.Tables.Count > 0 && DXMDataSet.Tables.Count % 9 == 0)
                {
                    for (int TableIndex = 0; TableIndex < ((DXMDataSet.Tables.Count) / 9); TableIndex++)
                    {
                        RetVal.Tables.Add(DXSFileConveter.GetCrossTabTableInfo(TableIndex, DXMDataSet));

                        DXSFileConveter.AddDefaultMappingInfo(DXMDataSet, RetVal.Tables[TableIndex], TableIndex);
                        DXSFileConveter.AddColumnsMappingInfo(DXMDataSet, RetVal.Tables[TableIndex], TableIndex);

                        DXSFileConveter.AddRowsMappingInfo(DXMDataSet, RetVal.Tables[TableIndex], TableIndex);
                    }
                }
            }
            catch (Exception ex)
            {
                throw new ApplicationException(ex.ToString());
            }

            return(RetVal);
        }
示例#3
0
        private static void AddRowsMappingInfo(DataSet dts, CrossTabTableInfo srcTableTableInfo, int tableIndex)
        {
            DataTable MappedTable;
            DataTable MapTypeTable;

            string MappedValueString = string.Empty;
            string MappedTypeString  = string.Empty;
            string Value             = string.Empty;
            string GID = string.Empty;

            string[] MappedValues;
            string[] MappedTypes;
            string[] ElementValue;
            Mapping  RowMapping;

            try
            {
                if (srcTableTableInfo != null)
                {
                    // only if mappedRow and maptype table exists
                    if (dts.Tables.Contains(TablesName.MAPPEDROW_TBLNAME + tableIndex) && dts.Tables.Contains(TablesName.MAPTYPEROW_TBLNAME + tableIndex))
                    {
                        MapTypeTable = dts.Tables[TablesName.MAPTYPEROW_TBLNAME + tableIndex];
                        MappedTable  = dts.Tables[TablesName.MAPPEDROW_TBLNAME + tableIndex];

                        if (MapTypeTable.Rows.Count == MappedTable.Rows.Count)
                        {
                            for (int Index = 0; Index < MapTypeTable.Rows.Count; Index++)
                            {
                                MappedTypeString  = Convert.ToString(MapTypeTable.Rows[Index][0]);
                                MappedValueString = Convert.ToString(MappedTable.Rows[Index][0]);

                                RowMapping = srcTableTableInfo.RowsMapping[Index].Mappings.CellMap;

                                //import mapping
                                DXSFileConveter.ImportMapping(MappedValueString, MappedTypeString, RowMapping);
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                throw new ApplicationException(ex.ToString());
            }
        }
示例#4
0
        private static void AddColumnsMappingInfo(DataSet dts, CrossTabTableInfo srcTableTableInfo, int tableIndex)
        {
            DataTable MappedTable;
            DataTable MapTypeTable;

            string MappedValueString = string.Empty;
            string MappedTypeString  = string.Empty;
            string Value             = string.Empty;
            string GID = string.Empty;

            string[] MappedValues;
            string[] MappedTypes;
            string[] ElementValue;
            Mapping  ColMapping;

            try
            {
                if (srcTableTableInfo != null)
                {
                    // only if mappedCol and maptype table exists
                    if (dts.Tables.Contains(TablesName.MAPPEDCOL_TBLNAME + tableIndex) && dts.Tables.Contains(TablesName.MAPTYPECOL_TBLNAME + tableIndex))
                    {
                        MapTypeTable = dts.Tables[TablesName.MAPTYPECOL_TBLNAME + tableIndex];
                        MappedTable  = dts.Tables[TablesName.MAPPEDCOL_TBLNAME + tableIndex];



                        if (MapTypeTable.Columns.Count == MappedTable.Columns.Count)
                        {
                            for (int Index = 0; Index < MapTypeTable.Columns.Count; Index++)
                            {
                                MappedTypeString  = Convert.ToString(MapTypeTable.Rows[0][Index]);
                                MappedValueString = Convert.ToString(MappedTable.Rows[0][Index]);
                                ColMapping        = srcTableTableInfo.ColumnsMapping[Index].Mappings.CellMap;

                                //import mapping
                                DXSFileConveter.ImportMapping(MappedValueString, MappedTypeString, ColMapping);
                            }
                        }

                        //////        if (!string.IsNullOrEmpty(MappedValueString) && !string.IsNullOrEmpty(MappedTypeString))
                        //////        {
                        //////            MappedTypes = DICommon.SplitString(MappedTypeString, "\r\n");
                        //////            MappedValues = DICommon.SplitString(MappedValueString, "\r\n");

                        //////            for (int i = 0; i < MappedTypes.Length; i++)
                        //////            {
                        //////                // only if value exists
                        //////                if (!string.IsNullOrEmpty(MappedTypes[i]) && !string.IsNullOrEmpty(MappedValues[Index]))
                        //////                {
                        //////                    ColMapping = srcTableTableInfo.ColumnsMapping[Index].Mappings.CellMap;
                        //////                    ElementValue = DICommon.SplitString(MappedValues[i], "||");

                        //////                    // only if element value have value and GID
                        //////                    if (ElementValue.Length == 2)
                        //////                    {
                        //////                        Value = Convert.ToString(ElementValue[0]);
                        //////                        GID= Convert.ToString(ElementValue[1]);

                        //////                        switch (MappedTypes[i].ToUpper())
                        //////                        {
                        //////                            case "INDICATOR":
                        //////                                ColMapping.IndicatorName = Value;
                        //////                                ColMapping.IndicatorGID = GID;
                        //////                                break;

                        //////                            case "UNIT":
                        //////                                ColMapping.UnitName = Value;
                        //////                                ColMapping.UnitGID = GID;
                        //////                                break;

                        //////                            case "SUBGROUP":
                        //////                                ColMapping.SubgroupVal = Value;
                        //////                                ColMapping.SubgroupValGID = GID;
                        //////                                break;
                        //////                            case "AREA":
                        //////                                ColMapping.Area = Value;
                        //////                                ColMapping.AreaID = GID;
                        //////                                break;

                        //////                            case "SOURCE":
                        //////                                ColMapping.Source = Value;
                        //////                                break;

                        //////                            case "TIMEPERIOD":
                        //////                                ColMapping.Timeperiod = Value;
                        //////                                break;

                        //////                            case "AGE":
                        //////                            case "SEX":
                        //////                            case "LOCATION":
                        //////                            case "OTHERS":
                        //////                                if(ColMapping.Subgroups.ContainsKey(GID)==false)
                        //////                                {
                        //////                                    DevInfo.Lib.DI_LibBAL.DA.DML.DI6SubgroupInfo SG =new DevInfo.Lib.DI_LibBAL.DA.DML.DI6SubgroupInfo();
                        //////                                    SG.Name=Value;
                        //////                                    SG.GID=GID;
                        //////                                    ColMapping.Subgroups.Add(GID, SG);
                        //////                                }

                        //////                                break;
                        //////                            default:
                        //////                                break;
                        //////                        }
                        //////                    }
                        //////                }
                        //////            }

                        //////        }
                        //////    }

                        //////}
                    }
                }
            }
            catch (Exception ex)
            {
                throw new ApplicationException(ex.ToString());
            }
        }