コード例 #1
0
        //private int ImportIndicator(DataRow row)
        //{
        //    int RetVal = -1;

        //    IndicatorInfo IndicatorRecord;
        //    IndicatorBuilder IndicatorBuilderObj;

        //    IndicatorRecord = this.GetIndicatorInfo(row);
        //    IndicatorBuilderObj = new IndicatorBuilder(this._TargetDBConnection, this._TargetDBQueries);
        //    RetVal = IndicatorBuilderObj.ImportIndicator(IndicatorRecord, IndicatorRecord.Nid, this.SourceDBQueries, this.SourceDBConnection);

        //    return RetVal;
        //}

        //private int ImportUnit(DataRow row)
        //{
        //    int RetVal = -1;

        //    UnitInfo UnitRecord;
        //    UnitBuilder UnitBuilderObj;

        //    UnitRecord = this.GetUnitInfo(row);

        //    UnitBuilderObj = new UnitBuilder(this._TargetDBConnection, this._TargetDBQueries);
        //    RetVal = UnitBuilderObj.ImportUnit(UnitRecord, UnitRecord.Nid, this.SourceDBQueries, this.SourceDBConnection);

        //    return RetVal;
        //}

        //private int ImportSubgroupVal(DataRow row)
        //{
        //    int RetVal = -1;

        //    DI6SubgroupValBuilder SubgroupValBuilderObj = new DI6SubgroupValBuilder(this._TargetDBConnection, this._TargetDBQueries);

        //    //import into target database
        //    RetVal = SubgroupValBuilderObj.ImportSubgroupVal(Convert.ToInt32(row[SubgroupVals.SubgroupValNId]), this.SourceDBQueries, this.SourceDBConnection);

        //    return RetVal;
        //}

        //private void ImportIUS(List<string> selectedNids, bool allSelected)
        //{
        //    int ProgressBarValue = 1;
        //    int IndicatorNId = -1;
        //    int UnitNId = -1;
        //    int SGValNId = -1;
        //    int MinValue=0;
        //    int MaxValue=0;

        //    DataRow[] Rows;
        //    DataTable TempTable;

        //    List<string> ImportedIndicatorNIDs = new List<string>();
        //    List<string> ImportedUnitNIDs = new List<string>();
        //    List<string> ImportedSGNIDs = new List<string>();

        //    IUSBuilder IusBuilderObj ;

        //    if (this.ShowIUS)
        //    {
        //        // Get selected rows
        //        if (allSelected)
        //        {
        //            Rows = this.SourceTable.Select("1=1");
        //        }
        //        else
        //        {
        //            Rows = this.SourceTable.Select(this.TagValueColumnName + " IN ( " + string.Join(",", selectedNids.ToArray()) + ")");
        //        }

        //        foreach (DataRow Row in Rows)
        //        {
        //            try
        //            {
        //                //import Indicator
        //                IndicatorNId = Convert.ToInt32(Row[Indicator.IndicatorNId]);
        //                if (!ImportedIndicatorNIDs.Contains(IndicatorNId.ToString()))
        //                {
        //                    ImportedIndicatorNIDs.Add(IndicatorNId.ToString());
        //                    IndicatorNId = this.ImportIndicator(Row);
        //                }


        //                    // import unit
        //                UnitNId = Convert.ToInt32(Row[Unit.UnitNId]);
        //                if (!ImportedIndicatorNIDs.Contains(UnitNId.ToString()))
        //                {
        //                   ImportedUnitNIDs.Add(UnitNId.ToString());
        //                    UnitNId =  this.ImportUnit(Row);
        //                }

        //                // import subgroupval
        //                SGValNId=Convert.ToInt32(Row[SubgroupVals.SubgroupValNId]);
        //                if (!ImportedSGNIDs.Contains(SGValNId.ToString()))
        //                {
        //                    ImportedSGNIDs.Add(SGValNId.ToString());
        //                    SGValNId = this.ImportSubgroupVal(Row);
        //                }

        //                //import IUS
        //                if (IndicatorNId > 0 && UnitNId > 0 && SGValNId > 0)
        //                {
        //                    //if(Convert.ToString(Row[Indicator_Unit_Subgroup.MaxValue]).Length>0)
        //                    //{
        //                    //MaxValue=   Convert.ToInt32(Row[Indicator_Unit_Subgroup.MaxValue]);
        //                    //}
        //                    //else
        //                    //{
        //                    //    MaxValue=0;
        //                    //}

        //                    //if(Convert.ToString(Row[Indicator_Unit_Subgroup.MinValue]).Length>0)
        //                    //{
        //                    //    MinValue= Convert.ToInt32(Row[Indicator_Unit_Subgroup.MinValue]);
        //                    //}
        //                    //else
        //                    //{
        //                    //    MinValue=0;
        //                    //}


        //                    IusBuilderObj = new IUSBuilder( this._TargetDBConnection, this._TargetDBQueries);

        //                    IusBuilderObj.ImportIUS(IndicatorNId, UnitNId, SGValNId,                                                    MinValue, MaxValue , this.SourceDBQueries, this.SourceDBConnection);

        //                }

        //                if (this.ShowSector)
        //                {
        //                    this.ImportSector(Row);
        //                }
        //            }
        //            catch (Exception)
        //            {

        //                throw;
        //            }
        //            this.RaiseIncrementProgessBarEvent(ProgressBarValue);
        //            ProgressBarValue++;
        //        }
        //    }
        //}

        /// <summary>
        /// Imports records from source database to target database/template
        /// </summary>
        /// <param name="selectedNids"></param>
        /// <param name="allSelected">Set true to import all records</param>
        public override void ImportValues(List <string> selectedNids, bool allSelected)
        {
            DataRow                    Row;
            IndicatorInfo              IndicatorRecord            = null;
            IndicatorBuilder           IndicatorBuilderObj        = null;
            DI7MetadataCategoryBuilder MetadataCategoryBuilderObj = null;
            int ProgressBarValue = 1;

            // import indicator metadata categories
            MetadataCategoryBuilderObj = new DI7MetadataCategoryBuilder(this._TargetDBConnection, this._TargetDBQueries);
            MetadataCategoryBuilderObj.ImportAllMetadataCategories(this.SourceDBConnection, this.SourceDBQueries, MetadataElementType.Indicator);

            // import IUS or indicator
            foreach (string Nid in selectedNids)
            {
                try
                {
                    Row = this.SourceTable.Select(this.TagValueColumnName + "=" + Nid)[0];

                    if (this._ShowIUS)
                    {
                        this.ImportForIUS(Row);
                    }
                    else
                    {
                        //import indicator
                        IndicatorRecord     = this.GetIndicatorInfo(Row);
                        IndicatorBuilderObj = new IndicatorBuilder(this._TargetDBConnection, this._TargetDBQueries);
                        IndicatorBuilderObj.ImportIndicator(IndicatorRecord, Convert.ToInt32(Nid), this.SourceDBQueries, this.SourceDBConnection);

                        if (this._ShowSector)
                        {
                            this.ImportSector(Row);
                        }
                    }
                }
                catch (Exception)
                {
                    throw;
                }
                this.RaiseIncrementProgessBarEvent(ProgressBarValue);
                ProgressBarValue++;
            }


            if (this._ShowIUS && this._ShowSector)
            {
                this.ImportSectors(selectedNids, allSelected);
            }
        }
コード例 #2
0
        public override void Import(string selectedGIds)
        {
            int       ProgressCounter = 0;
            DataTable Table           = null;
            string    selectedNids    = string.Empty;

            selectedNids = selectedGIds;

            // Initialize progress bar
            this.RaiseProgressBarInitialize(selectedGIds.Split(',').GetUpperBound(0) + 1);

            IndicatorBuilder             TrgIndicatorBuilderObj = null;
            IndicatorBuilder             SourceIndicatorBuilder = null;
            IndicatorInfo                IndicatorInfoObj       = null;
            Dictionary <string, DataRow> FileWithNids           = new Dictionary <string, DataRow>();

            DIConnection SourceDBConnection = null;
            DIQueries    SourceDBQueries    = null;

            //-- Step 1: Get TempTable with Sorted SourceFileName
            Table = this._TargetDBConnection.ExecuteDataTable(this.ImportQueries.GetImportIndicator(selectedNids));

            //-- Step 2:Initialise Indicator Builder with Target DBConnection
            TrgIndicatorBuilderObj = new IndicatorBuilder(this.TargetDBConnection, this.TargetDBQueries);

            //-- Step 3: Import Nids for each SourceFile
            foreach (DataRow Row in Table.Copy().Rows)
            {
                try
                {
                    string SourceFileWPath = Convert.ToString(Row[MergetTemplateConstants.Columns.COLUMN_SOURCEFILENAME]);

                    SourceDBConnection = new DIConnection(DIServerType.MsAccess, String.Empty, String.Empty, SourceFileWPath, String.Empty, MergetTemplateConstants.DBPassword);
                    SourceDBQueries    = DataExchange.GetDBQueries(SourceDBConnection);

                    // Get Source Indicator Info
                    SourceIndicatorBuilder = new IndicatorBuilder(SourceDBConnection, SourceDBQueries);
                    IndicatorInfoObj       = SourceIndicatorBuilder.GetIndicatorInfo(FilterFieldType.NId, Convert.ToString(Row[MergetTemplateConstants.Columns.COLUMN_SRCNID]), FieldSelection.Light);

                    // Import INdicator By Nid
                    TrgIndicatorBuilderObj.ImportIndicator(IndicatorInfoObj, Convert.ToInt32(Row[MergetTemplateConstants.Columns.COLUMN_SRCNID]), SourceDBQueries, SourceDBConnection);
                    ProgressCounter += 1;
                    this.RaiseProgressBarIncrement(ProgressCounter);
                }
                catch (Exception ex) { ExceptionFacade.ThrowException(ex); }
                finally
                {
                    if (SourceDBConnection != null)
                    {
                        SourceDBConnection.Dispose();
                    }
                    if (SourceDBQueries != null)
                    {
                        SourceDBQueries.Dispose();
                    }
                }
            }
            this._AvailableTable = this.GetAvailableTable();
            this._UnmatchedTable = this.GetUnmatchedTable();
            // Close ProgressBar
            this.RaiseProgressBarClose();
        }