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);
        }
Beispiel #2
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);
                }
            }
        }
        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;
        }
        private void ImportMappingValues(CrossTabInputFileInfo srcInputFileInfo, bool importDefaultValues, bool importRowsMapping, bool importColsMapping, int startingTableIndex)
        {
            int TrgTableIndex;
            try
            {
                if (this._Tables != null && this._Tables.Count > 0 && srcInputFileInfo.Tables != null && srcInputFileInfo.Tables.Count > 0)
                {
                    // import mapping information from srcInputFileInfo only if table is exists
                    TrgTableIndex = startingTableIndex;

                    for (int SrcTableIndex = 0; TrgTableIndex < this._Tables.Count; TrgTableIndex++, SrcTableIndex++)
                    {
                        // check table exists in source input file
                        if (srcInputFileInfo.Tables.Count <= SrcTableIndex)
                        {
                            break;
                        }

                        if (srcInputFileInfo.Tables[TrgTableIndex] != null)
                        {
                            // import columns mapping by checking column header
                            if (importColsMapping)
                            {
                                this._Tables[TrgTableIndex].ImportColumnsMapping(srcInputFileInfo.Tables[SrcTableIndex]);
                            }

                            // import rows mapping by checking rows header
                            if (importRowsMapping)
                            {
                                this._Tables[TrgTableIndex].ImportRowsMapping(srcInputFileInfo.Tables[SrcTableIndex]);
                            }

                            // import default mapping
                            if (importDefaultValues)
                            {
                                this._Tables[TrgTableIndex].ImportDefaultMapping(srcInputFileInfo.Tables[SrcTableIndex]);
                                this._Tables[TrgTableIndex].DecimalValue = srcInputFileInfo.Tables[SrcTableIndex].DefaultMapping.DefaultDecimalValue;
                            }

                            // import denominator table
                            // only if src table caption is same as target table caption and columns count is same
                            string TrgTableCaption=this._Tables[TrgTableIndex].Caption.ToLower();
                            string SrcTableCaption=srcInputFileInfo.Tables[SrcTableIndex].Caption.ToLower();

                            if ( TrgTableIndex == SrcTableIndex )
                            {
                                if (this._Tables[TrgTableIndex].ColumnsHeaderTable.Columns.Count ==
            srcInputFileInfo.Tables[SrcTableIndex].ColumnsHeaderTable.Columns.Count)
                                {
                                    this._Tables[TrgTableIndex].DenominatorTable = srcInputFileInfo.Tables[SrcTableIndex].DenominatorTable;
                                }

                            }

                        }

                    }
                }
            }
            catch (Exception ex)
            {
                throw new ApplicationException(ex.ToString());
            }
        }
Beispiel #5
0
        private void ImportMappingValues(CrossTabInputFileInfo srcInputFileInfo, bool importDefaultValues, bool importRowsMapping, bool importColsMapping, int startingTableIndex)
        {
            int TrgTableIndex;

            try
            {
                if (this._Tables != null && this._Tables.Count > 0 && srcInputFileInfo.Tables != null && srcInputFileInfo.Tables.Count > 0)
                {
                    // import mapping information from srcInputFileInfo only if table is exists
                    TrgTableIndex = startingTableIndex;

                    for (int SrcTableIndex = 0; TrgTableIndex < this._Tables.Count; TrgTableIndex++, SrcTableIndex++)
                    {
                        // check table exists in source input file
                        if (srcInputFileInfo.Tables.Count <= SrcTableIndex)
                        {
                            break;
                        }


                        if (srcInputFileInfo.Tables[TrgTableIndex] != null)
                        {
                            // import columns mapping by checking column header
                            if (importColsMapping)
                            {
                                this._Tables[TrgTableIndex].ImportColumnsMapping(srcInputFileInfo.Tables[SrcTableIndex]);
                            }

                            // import rows mapping by checking rows header
                            if (importRowsMapping)
                            {
                                this._Tables[TrgTableIndex].ImportRowsMapping(srcInputFileInfo.Tables[SrcTableIndex]);
                            }

                            // import default mapping
                            if (importDefaultValues)
                            {
                                this._Tables[TrgTableIndex].ImportDefaultMapping(srcInputFileInfo.Tables[SrcTableIndex]);
                                this._Tables[TrgTableIndex].DecimalValue = srcInputFileInfo.Tables[SrcTableIndex].DefaultMapping.DefaultDecimalValue;
                            }


                            // import denominator table
                            // only if src table caption is same as target table caption and columns count is same
                            string TrgTableCaption = this._Tables[TrgTableIndex].Caption.ToLower();
                            string SrcTableCaption = srcInputFileInfo.Tables[SrcTableIndex].Caption.ToLower();


                            if (TrgTableIndex == SrcTableIndex)
                            {
                                if (this._Tables[TrgTableIndex].ColumnsHeaderTable.Columns.Count ==
                                    srcInputFileInfo.Tables[SrcTableIndex].ColumnsHeaderTable.Columns.Count)
                                {
                                    this._Tables[TrgTableIndex].DenominatorTable = srcInputFileInfo.Tables[SrcTableIndex].DenominatorTable;
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                throw new ApplicationException(ex.ToString());
            }
        }