/// <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;
            FootnoteInfo FootnoteRecord = null;
            FootnoteBuilder FootnoteBuilderObj = null;
            int ProgressBarValue = 0;

            try
            {
                //import selected footnotes
                foreach (string Nid in SelectedNids)
                {
                    try
                    {
                        Row = this.SourceTable.Select(this.TagValueColumnName + "=" + Nid)[0];

                        //import footnote
                        FootnoteRecord = new FootnoteInfo();
                        FootnoteRecord.Name = Convert.ToString(Row[FootNotes.FootNote]);
                        FootnoteRecord.Nid = Convert.ToInt32(Row[FootNotes.FootNoteNId]);
                        FootnoteRecord.GID = Convert.ToString(Row[FootNotes.FootNoteGId]);

                        FootnoteBuilderObj = new FootnoteBuilder(this._TargetDBConnection, this._TargetDBQueries);
                        FootnoteBuilderObj.CheckNCreateFoonote(FootnoteRecord);

                        //FootnoteBuilderObj.ImportFootnote(FootnoteRecord, Convert.ToInt32(Nid), this.SourceDBQueries, this.SourceDBConnection);
                    }
                    catch (Exception ex)
                    {
                        throw new ApplicationException(ex.ToString());
                    }

                    this.RaiseIncrementProgessBarEvent(ProgressBarValue);
                    ProgressBarValue++;
                }
            }
            catch (Exception ex)
            {
                ExceptionHandler.ExceptionFacade.ThrowException(ex);
            }
        }
Beispiel #2
0
        /// <summary>
        /// To open or create DevInfo database
        /// </summary>
        /// <param name="fileNameWPath"></param>
        /// <param name="datasetPrefix"></param>        
        /// <param name="langaugeCode"></param>
        public void OpenDatabase(string fileNameWPath, string datasetPrefix, string langaugeCode)
        {
            DBConverterDecorator DBConverter;

            //check file exists or not. If not exists then create it.
            if (!File.Exists(fileNameWPath))
            {
                DIDatabase.CreateDevInfoDBFile(fileNameWPath);

                // update the db schema
                DBConverter = new DBConverterDecorator(fileNameWPath);
                DBConverter.DoConversion(false);
                DBConverter.Dispose();
            }

            this.SetDatabaseObjects(fileNameWPath, datasetPrefix, langaugeCode);

            this.DIArea = new AreaBuilder(this.DBConnection, this.DBQueries);
            this.DIIUS = new IUSBuilder(this.DBConnection, this.DBQueries);
            this.DITimeperiod = new TimeperiodBuilder(this.DBConnection, this.DBQueries);
            this.DISource = new SourceBuilder(this.DBConnection, this.DBQueries);
            this.DIFootnote = new FootnoteBuilder(this.DBConnection, this.DBQueries);
        }
Beispiel #3
0
 /// <summary>
 /// Returns instance of DIDatabase.
 /// </summary>
 /// <param name="connection">Instance of DIConnection which is already opened</param>
 /// <param name="queries">Instance of DIQueries which is already opened</param>
 public DIDatabase(DIConnection connection, DIQueries queries)
 {
     this.DBConnection = connection;
     this.DBQueries = queries;
     this.DIArea = new AreaBuilder(this.DBConnection, this.DBQueries);
     this.DIIUS = new IUSBuilder(this.DBConnection, this.DBQueries);
     this.DITimeperiod = new TimeperiodBuilder(this.DBConnection, this.DBQueries);
     this.DISource = new SourceBuilder(this.DBConnection, this.DBQueries);
     this.DIFootnote = new FootnoteBuilder(this.DBConnection, this.DBQueries);
 }
Beispiel #4
0
        /// <summary>
        /// Convets Database into template
        /// </summary>
        public void ConvertDatabaseToTemplate()
        {
            SourceBuilder SrcBuilder;
            FootnoteBuilder FoonotesBuilder;
            IndicatorClassificationBuilder ICBuilder;
            RecommendedSourcesBuilder RecommendedSrcBuilder;
            DataTable ICTable;
            string ICNIds = string.Empty;

            try
            {
                // STEP 1: Remove records from DATA table
                this.DBConnection.ExecuteNonQuery(this.DBQueries.Delete.Data.DeleteRecords(string.Empty));

                // STEP 2: Remove records from TIME table
                this.DBConnection.ExecuteNonQuery(this.DBQueries.Delete.Timeperiod.DeleteRecords(string.Empty));

                // STEP 3: Remove records from SOURCE table
                SrcBuilder = new SourceBuilder(this.DBConnection, this.DBQueries);
                SrcBuilder.DeleteSources(string.Empty);

                // STEP 4: Remove source records from Indicator_classification tables
                ICBuilder = new IndicatorClassificationBuilder(this.DBConnection, this.DBQueries);

                ICTable = this.DBConnection.ExecuteDataTable(this.DBQueries.IndicatorClassification.GetIC(FilterFieldType.Type, "'SR'", FieldSelection.NId));
                if (ICTable != null && ICTable.Rows.Count > 0)
                {
                    ICNIds = DIConnection.GetDelimitedValuesFromDataTable(ICTable, IndicatorClassifications.ICNId);
                }
                ICBuilder.DeleteClassification(ICNIds);

                // STEP 5: Remove records from Footnotes table
                FoonotesBuilder = new FootnoteBuilder(this.DBConnection, this.DBQueries);
                FoonotesBuilder.DeleteFootnote(string.Empty);

                // STEP 6: Creates DevInfoSP2 tables if missing.
                DICommon.CheckNCreateDevInfoSP2Database(this.DBConnection, this.DBQueries, false);

                // STEP 7: remove records from notes table
                this.ClearNotesTables();

                // STEP 8: remove records from RecommendedSources table
                RecommendedSrcBuilder = new RecommendedSourcesBuilder(this.DBConnection, this.DBQueries);
                RecommendedSrcBuilder.DeleteRecommendedSources(string.Empty);

                // STEP 9:Remove Source metadata reports
                new DI7MetaDataBuilder(this.DBConnection, this.DBQueries).DeleteMetadataReports(MetadataElementType.Source);

            }
            catch (Exception ex)
            {
                throw new ApplicationException(ex.ToString());
            }
        }
Beispiel #5
0
        private void InsertNewFootNotes()
        {
            String SqlQuery = string.Empty;
            DataTable NewFootnotes;
            DataTable TempFootnotesTable;
            FootnoteBuilder DIFootNote;
            FootnoteInfo DIFootNoteInfo;
            int NewNid;
            Dictionary<string, int> InsertedFootnotes = new Dictionary<string, int>();
            string FootnoteText = string.Empty;
            try
            {
                // 1. Update special quotes in FootNotes

                // as replace function does not work with ADO.net so first get the special foonote with quotes and then update footnote text one by one.
                if (this.DBConnection.ConnectionStringParameters.ServerType == DIServerType.MsAccess)
                {
                    TempFootnotesTable = this.DBConnection.ExecuteDataTable(this.DAQuery.GetFootnoteTextWSpecialQuotesFrmTempDataTbl());

                    //update footnote text
                    foreach (DataRow Row in TempFootnotesTable.Rows)
                    {
                        this.DBConnection.ExecuteNonQuery(this.DAQuery.UpdateSpecialInFootnoteText(Convert.ToString(Row[FootNotes.FootNote]), Convert.ToString(Row[Data.DataNId])));
                    }
                }
                //this.DBConnection.ExecuteNonQuery(this.DAQuery.UpdateFootNoteNid());

                // 2. Get new FootNotes from Temp_Data table which are not in UT_FootNotes Table.
                //NewFootnotes = this.DBConnection.ExecuteDataTable(this.DAQuery.GetNewFootNotes());
                NewFootnotes = this.DBConnection.ExecuteDataTable(this.DAQuery.GetFootNotesFrmTempDataTable()).DefaultView.ToTable(true, DAImportCommon.Constants.FootNoteColumnName);

                // 3. Insert FootNotes from TempData Table into UT_FootNote
                DIFootNote = new FootnoteBuilder(this.DBConnection, this.DBQueries);
                foreach (DataRow SourceRow in NewFootnotes.Rows)
                {
                    FootnoteText = Lib.DI_LibBAL.Utility.DICommon.RemoveQuotes(Convert.ToString(SourceRow[DAImportCommon.Constants.FootNoteColumnName]));

                    if (!InsertedFootnotes.ContainsKey(FootnoteText) && !string.IsNullOrEmpty(FootnoteText))
                    {
                        DIFootNoteInfo = new FootnoteInfo();
                        DIFootNoteInfo.Name = FootnoteText;
                        NewNid = DIFootNote.CheckNCreateFoonote(DIFootNoteInfo);

                        if (NewNid > 0)
                        {
                            InsertedFootnotes.Add(FootnoteText, NewNid);

                            // 4. Update FootNotes Nid in Temp_Data.
                            this.DBConnection.ExecuteNonQuery(this.DAQuery.UpdateFootNoteNid(NewNid, FootnoteText));
                        }
                    }
                }

                //////// 4. Update FootNotes Nid in Temp_Data.
                //////this.DBConnection.ExecuteNonQuery(this.DAQuery.UpdateFootNoteNid());

                // 5. Update FootNote Nid = -1 where FootNote is blank.
                this.DBConnection.ExecuteNonQuery(this.DAQuery.UpdateNidForEmptyFootNote());
            }
            catch (Exception ex)
            {

                ExceptionHandler.ExceptionFacade.ThrowException(ex);
            }
        }