Ejemplo n.º 1
0
        private void WriteUnmatchedElementsIntoLogFile(CrossTabLogFile logFile, UnMatchedElementInfo unmatchedElement)
        {
            //Write unmatched elements into log
            if (unmatchedElement != null)
            {
                //area
                foreach (string Key in unmatchedElement.Areas.Keys)
                {
                    logFile.AddUnmatchedArea(this._Caption, Key, unmatchedElement.Areas[Key]);
                }

                // indicator
                foreach (string IndicatorKey in unmatchedElement.Indicators.Keys)
                {
                    logFile.AddUnmatchedIndicator(this._Caption, unmatchedElement.Indicators[IndicatorKey], IndicatorKey);
                }

                // unit
                foreach (string UnitKey in unmatchedElement.Units.Keys)
                {
                    logFile.AddUnmatchedUnit(this._Caption, unmatchedElement.Units[UnitKey], UnitKey);
                }

                // Subgroup
                foreach (string SGKey in unmatchedElement.Subgroups.Keys)
                {
                    logFile.AddUnmatchedSubgroup(this._Caption, unmatchedElement.Subgroups[SGKey], SGKey);
                }
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Imports mapped data values into database
        /// </summary>
        public void ImportTableValuesIntoDB(Database dbDatabase, CrossTabLogFile logFile)
        {
            Mapping MappedValues = null;
            string DataValue = String.Empty;
            string DenominatorValue = string.Empty;
            UnMatchedElementInfo UnmatchedElement;

            try
            {

                // import datavalues into target database
                for (int RowIndex = 0; RowIndex < this._DataValueTable.Rows.Count; RowIndex++)
                {
                    for (int ColIndex = 0; ColIndex < this._DataValueTable.Columns.Count; ColIndex++)
                    {
                        // dont insert denominator column values
                        if (this.DenominatorTable.Select(DenominatorColumns.DenominatorColumn + "='" + ColIndex +"'").Length == 0)
                        {
                            MappedValues = this.GetCellMapping(RowIndex, ColIndex, dbDatabase);
                            DataValue = Convert.ToString(this._DataValueTable.Rows[RowIndex][ColIndex]);

                            if (!string.IsNullOrEmpty(DataValue) && MappedValues != null && MappedValues.IsVaildMappedValues())
                            {

                                // dont import missingvaluecharacter into data table
                                if (!string.IsNullOrEmpty(this._MissingValueCharacter) && DataValue == this._MissingValueCharacter)
                                {
                                    // dont import missingvaluecharacter into data table
                                }
                                else
                                {
                                    // replace datavalue to zero if datavalue is equal to zero mask value
                                    if (!string.IsNullOrEmpty(this._ZeroMaskValue))
                                    {
                                        if (DataValue == this._ZeroMaskValue)
                                        {
                                            DataValue = "0";
                                        }
                                    }

                                    // round numeric datavalue
                                    if (DataValue != "-" && DataValue != "." && Microsoft.VisualBasic.Information.IsNumeric(DataValue))
                                    {
                                        DataValue = Convert.ToString(Math.Round(Convert.ToDecimal(DataValue), this._DecimalValue));
                                    }

                                    // get denominator value
                                    DenominatorValue = this.GetDenominatorValue(RowIndex, ColIndex);
                                    UnmatchedElement = MappedValues.ImportMappedValuesIntoDB(dbDatabase.DBConnection, dbDatabase.DBQueries, DataValue, DenominatorValue);

                                    this.WriteUnmatchedElementsIntoLogFile(logFile, UnmatchedElement);
                                }

                            }
                            else
                            {
                                // WRITE unmapped information into log file
                                this.WriteUnmappedInfoIntoLogFile(logFile, MappedValues, Convert.ToString(DataValue));
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                throw new ApplicationException(ex.ToString());
            }
        }
Ejemplo n.º 3
0
 private void WriteUnmappedInfoIntoLogFile(CrossTabLogFile logFile, Mapping mappedValues, string cellValue)
 {
     if (!string.IsNullOrEmpty(cellValue))
     {
         logFile.AddUnMappedCells(this._Caption, cellValue,
             string.IsNullOrEmpty(mappedValues.IndicatorGID),
     string.IsNullOrEmpty(mappedValues.UnitGID),
     string.IsNullOrEmpty(mappedValues.SubgroupValGID),
     string.IsNullOrEmpty(mappedValues.AreaID),
     string.IsNullOrEmpty(mappedValues.Timeperiod),
     string.IsNullOrEmpty(mappedValues.Source));
     }
 }
Ejemplo n.º 4
0
        /// <summary>
        /// Imports input files into database and returns log file name with path
        /// </summary>
        /// 
        public string ImportFilesIntoDB(Database dbDatabase)
        {
            string RetVal = string.Empty;

            CrossTabLogFile LogFile = new CrossTabLogFile();
            List<string> InputFileNames = new List<string>();
            int TableIndex = 1;
            try
            {
                RetVal = DICommon.DefaultFolder.DefaultSpreadSheetsFolder + LogFile.GenerateLogFileName(this._DXApplicationName);

                // Get fileNames
                foreach (CrossTabInputFileInfo InputFile1 in this._InputFiles)
                {
                    if (string.IsNullOrEmpty(InputFile1.ActucalFileNameWPath))
                    {
                        InputFileNames.Add(InputFile1.FileNameWPath);
                    }
                    else
                    {
                        InputFileNames.Add(InputFile1.ActucalFileNameWPath);
                    }
                }

                // Start log file
                LogFile.Start(RetVal, this._DXApplicationName, InputFileNames, this._OutputFileNameForLogFile, dbDatabase.DBConnection, dbDatabase.DBQueries);

                foreach (CrossTabInputFileInfo InputFileInfo in this._InputFiles)
                {
                    TableIndex = 1;

                    // Write file name in log file
                    LogFile.StartInputFileLog(InputFileInfo.ActucalFileNameWithoutExtension);

                    foreach (CrossTabTableInfo TableInfo in InputFileInfo.Tables)
                    {

                        if (string.IsNullOrEmpty(TableInfo.Caption))
                        {
                            TableInfo.Caption = TableIndex.ToString();
                        }

                        TableInfo.ZeroMaskValue = this._ZeroMaskValue;
                        TableInfo.MissingValueCharacter = this._MissingValueCharacter;
                        TableInfo.ImportTableValuesIntoDB(dbDatabase, LogFile);

                        TableIndex++;
                    }

                    //end input file log
                    LogFile.EndInputFileLog();
                }

                // close log file
                LogFile.Close();

                //update I,U & S NIDs in data table
                try
                {
                    dbDatabase.DBConnection.ExecuteNonQuery(DI_LibDAL.Queries.Data.Update.UpdateIndicatorUnitSubgroupVAlNids(dbDatabase.DBQueries.TablesName));
                }
                catch (Exception ex)
                {
                    throw new ApplicationException(ex.ToString());
                }
            }
            catch (Exception ex)
            {
                throw new ApplicationException(ex.ToString());
            }
            return RetVal;
        }