internal bool ExportMDB(string destinationDBNameWPath, string tempFolderPath, bool createNewDatabase) { bool RetVal = false; int ProgressCount = 0; try { if (createNewDatabase) { this.ExportMDB(destinationDBNameWPath, tempFolderPath); } else { DIExport.RaiseExportProgressBarInitialize(100); //- Establish Connection with Destination Database in temp folder this.DestDBConnection = new DIConnection(DIServerType.MsAccess, string.Empty, string.Empty, destinationDBNameWPath, string.Empty, string.Empty); this.DestDBQueries = new DIQueries(DestDBConnection.DIDataSetDefault(), DestDBConnection.DILanguageCodeDefault(DestDBConnection.DIDataSetDefault())); this.DBTableNames = new DITables(DestDBConnection.DIDataSetDefault(), DestDBConnection.DILanguageCodeDefault(DestDBConnection.DIDataSetDefault())); this.SourceTableNames = this.SourceDBQueries.TablesName; // if database/tempalte already in DI6 format then convert it into latest format DBConverterDecorator DBConverter = new DBConverterDecorator(this.DestDBConnection, this.DestDBQueries); DBConverter.DoConversion(false); //-- Get LanguageTable this.LanguageTable = this.DestDBConnection.DILanguages(this.DestDBConnection.DIDataSetDefault()); DIExport.RaiseExportProgressBarIncrement(1); //- Export Indicator, Unit, Subgroupval, IUS this.ProcessIndicators(); DIExport.RaiseExportProgressBarIncrement(10); // Export linked IC information this.ProcessIndicatorClassifications(); DIExport.RaiseExportProgressBarIncrement(20); //- Export Area this.ProcessAreas(); DIExport.RaiseExportProgressBarIncrement(30); //- Export TimePeriod this.ProcessTimePeriods(); DIExport.RaiseExportProgressBarIncrement(40); //- Export Data this.ExportData(); DIExport.RaiseExportProgressBarIncrement(80); this.ProcessOtherTables(); DIExport.RaiseExportProgressBarIncrement(90); DIExport.RaiseExportProgressBarIncrement(ProgressCount++); this.DeleteTable(TEMP_TABLE_Data, this.DestDBConnection); DIExport.RaiseExportProgressBarIncrement(100); } } catch { throw; } return RetVal; }
/// <summary> /// Returns true if template or database is in current DevInfo 6.0 format /// </summary> /// <param name="fileNameWPath"></param> /// <returns></returns> /// <remarks>For MsAccess</remarks> public static bool ISDevInfoLatestDatabase(string fileNameWPath, ref string dbFilePostFix) { bool RetVal = false; DIConnection DBConnection = null; DIQueries DBQueries = null; DBConverterDecorator DBConverterObject; DI7_0_0_0DBConverter DI7_DatabaseConvertor; try { DBConnection = new DIConnection(DIServerType.MsAccess, string.Empty, string.Empty, fileNameWPath, string.Empty, string.Empty); DBQueries = new DIQueries(DBConnection.DIDataSetDefault(), DBConnection.DILanguageCodeDefault(DBConnection.DIDataSetDefault())); DI7_DatabaseConvertor = new DI7_0_0_0DBConverter(DBConnection, DBQueries); RetVal = DI7_DatabaseConvertor.IsValidDB(false); dbFilePostFix = DI7_DatabaseConvertor.DBFilePostfix; if (RetVal) { // if database/tempalte already in DI7 format then convert it into latest format DBConverterObject = new DBConverterDecorator(DBConnection, DBQueries); DBConverterObject.DoConversion(false); } } catch (Exception) { RetVal = false; // Do NOT throw any exception. } finally { if (DBConnection != null) { DBConnection.Dispose(); } } return RetVal; }
/// <summary> /// Updates database schema into latest format /// </summary> /// <returns></returns> public static bool UpdateDBSchemaToLatestDI6(string fileNameWPath) { bool RetVal = false; DBConverterDecorator DBConverter = null; try { DBConverter = new DBConverterDecorator(fileNameWPath); RetVal = DBConverter.DoConversion(false); } catch (Exception ex) { RetVal = false; throw new ApplicationException(ex.ToString()); } finally { if (DBConverter != null) { DBConverter.Dispose(); } } return RetVal; }
/// <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); }