Exemplo n.º 1
0
        /// <summary>
        /// Update BAUSTEIN.DBF (only timestamp, attribs buildup not known)
        /// This is needed for the compare function to detect the difference.
        /// </summary>
        /// <param name="NonRetain"></param>
        /// <param name="newTime"></param>
        private void updateBlocksListItemsAttr(
            DbItemsCollection dbItemsCollection,
            bool NonRetain,
            string newTime = null)
        {
            DbfFile dbf = new DbfFile(encoding);

            dbf.Open(blocksListPath, FileMode.Open, FileAccess.ReadWrite, FileShare.ReadWrite);
            DbfRecord record = new DbfRecord(dbf.Header);

            while (dbf.ReadNext(record))
            {
                if (record.IsDeleted)
                {
                    continue;
                }
                try
                {
                    DbItem dbItem = new DbItem(record, DatabaseType.NormalBlocksList);

                    //Only one record with each ID
                    if (dbItemsCollection.getDbItems().ContainsKey(dbItem.DatabaseId) &&
                        dbItemsCollection.getDbItems()
                        [dbItem.DatabaseId][DbType10].currentNonRetain != NonRetain)
                    {
                        //Update attribute with new timestamp1
                        dbItem.updateDbItemAttribs(record, newTime);
                        dbf.Update(record);
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.ToString());
                }
            }
            dbf.Close();
        }