当前位置: 首页>>代码示例>>C#>>正文


C# DIConnection.InsertNewDBFileName方法代码示例

本文整理汇总了C#中DevInfo.Lib.DI_LibDAL.Connection.DIConnection.InsertNewDBFileName方法的典型用法代码示例。如果您正苦于以下问题:C# DIConnection.InsertNewDBFileName方法的具体用法?C# DIConnection.InsertNewDBFileName怎么用?C# DIConnection.InsertNewDBFileName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DevInfo.Lib.DI_LibDAL.Connection.DIConnection的用法示例。


在下文中一共展示了DIConnection.InsertNewDBFileName方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CompactDataBase

        /// <summary>
        /// Compact the database mainly Access database(.mdb) and save as specified destination file.
        /// </summary>
        ///<param name="sourceDBConnection"> Source database connection</param>
        /// <param name="destFilePath">destination file name with path.</param>
        /// <param name="disposeConnection"> Set true when calling this methods for finish process otherwise false.For only saving the database, pass False and for finish , pass true.  </param>
        /// <returns>true, if success.</returns>
        /// <remarks>Before calling this function,dont dispose source database connection </remarks>
        public static bool CompactDataBase(ref DIConnection sourceDBConnection, DIQueries dbQueries, string destFilePath, bool disposeConnection)
        {
            bool RetVal = false;
            bool IsFileOpen = false;
            DIConnectionDetails SourceDBConnectionDetails;
            DBMetadataTableBuilder DBMetadataTable;
            DIDatabase DBDatabase;
            string SourceDBNameWPath;
            JRO.JetEngine je;
            string DataPrefix = string.Empty;
            DI7MetadataCategoryBuilder DI7MetadataCategory;

            // -- NOTE: USE sDestFile only when sDestFile <> sSourceDB
            try
            {
                if (sourceDBConnection != null && !string.IsNullOrEmpty(destFilePath))
                {
                    //Drop index for ut_data table for IUSNID, areanid column
                    DIDatabase.DropDefaultIndex(sourceDBConnection);

                    // update counts in DBMetadata table( only if database/template is in DI6 format)
                    if (dbQueries == null)
                    {
                        DataPrefix = sourceDBConnection.DIDataSetDefault();

                        dbQueries = new DIQueries(DataPrefix, sourceDBConnection.DILanguageCodeDefault(DataPrefix));
                    }

                    DBMetadataTable = new DBMetadataTableBuilder(sourceDBConnection, dbQueries);
                    if (DBMetadataTable.IsDBMetadataTableExists())
                    {
                        DBMetadataTable.GetNUpdateCounts();
                    }
                    //Updating XSLT from Resourse File into database.
                    DI7MetadataCategory = new DI7MetadataCategoryBuilder(sourceDBConnection, dbQueries);
                    DI7MetadataCategory.UpdateXSLT(dbQueries.DataPrefix);

                    // update database name in DB_Available table
                    sourceDBConnection.InsertNewDBFileName(dbQueries.DataPrefix, DICommon.RemoveQuotes(System.IO.Path.GetFileName(destFilePath)));

                    if (DIDatabase.SeperateDataValueColumn)
                    {
                        // Check orgTextual_Data_value exists or not. If column exists then move textual & numeric values into their respective column.
                        DIDataValueHelper.SeparateTextualandNemericData(sourceDBConnection, dbQueries);
                    }

                    // update indicator unit and subgroup nids in Data table
                    DBDatabase = new DIDatabase(sourceDBConnection, dbQueries);
                    DBDatabase.UpdateIndicatorUnitSubgroupNIDsInData();

                    // remove FootnoteNId inconsistency. (replace 0 or null FootnoteNId by -1 in UT_data table).
                    DBDatabase.RemoveFootnoteNIdsInconsistencyInData();

                    // Update auto calculated columns ( IC table - Publisher, Year & title ,Indicator table- Data_Exists, area table - data_exist, IUS table - subgroup_nids & data_exist) into the database/template
                    DBDatabase.UpdateAutoCalculatedFieldsInTables();

                    // Update auto calculated column of DI7
                    DBDatabase.UpdateAutoCalculatedDI7FieldsInTables();

                    //Update those subgroupVals which is not associated with any subgroup type.Then insert association with others for those subgroup
                    DBDatabase.UpdateSubgroupValsInOthersSGDimensionInTables();

                    //Create index for ut_data table for IUSNID, areanid column
                    DIDatabase.CreateDefaultIndex(sourceDBConnection);

                    // dispose source database connection
                    SourceDBConnectionDetails = sourceDBConnection.ConnectionStringParameters;
                    SourceDBNameWPath = SourceDBConnectionDetails.DbName;
                    sourceDBConnection.Dispose();
                    System.Threading.Thread.Sleep(10);
                    try
                    {
                        if (File.Exists(destFilePath))
                        {
                            File.SetAttributes(destFilePath, FileAttributes.Normal);
                            File.Delete(destFilePath);
                        }
                    }
                    catch { }

                    //-- Copy SourceFile to temp file so that any existing connection on database shall not stop compact database process.
                    //string TempFile = DICommon.GetValidFileName(DateTime.Now.ToString()) + Path.GetExtension(SourceDBNameWPath);
                    //File.Copy(SourceDBNameWPath, TempFile, true);

                    try
                    {
                        // compacting the database
                        je = new JRO.JetEngine();
                        je.CompactDatabase("Data Source=\"" + SourceDBNameWPath + "\";Jet OLEDB:Database Password=" + SourceDBConnectionDetails.Password, "Data Source=\"" + destFilePath + "\";Jet OLEDB:Database Password=" + SourceDBConnectionDetails.Password);
                        je = null;

                    }
//.........这里部分代码省略.........
开发者ID:SDRC-India,项目名称:sdrcdevinfo,代码行数:101,代码来源:DIDatabase.cs


注:本文中的DevInfo.Lib.DI_LibDAL.Connection.DIConnection.InsertNewDBFileName方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。