Beispiel #1
0
        /// <summary>
        /// Method compares the downloaded data file to the existing data
        /// file to check if the update is required. This will prevent file
        /// switching if the data file was downloaded but is not newer than
        /// the existing data file.
        /// </summary>
        /// <remarks>
        /// The following conditions must be met for the data file to be
        /// considered newer than the current master data file:
        /// 1. Current master data file does not exist.
        /// 2. If the published dates are not the same.
        /// 3. If the number of properties is not the same.
        /// </remarks>
        /// <param name="binaryFile">
        /// Current file to compare against.
        /// </param>
        /// <param name="decompressedTempFile">
        /// Path to the decompressed downloaded file.
        /// </param>
        /// <returns>The current state of the update process.</returns>
        private static AutoUpdateStatus ValidateDownloadedFile(
            FileInfo binaryFile, FileInfo decompressedTempFile)
        {
            AutoUpdateStatus status = AutoUpdateStatus.AUTO_UPDATE_IN_PROGRESS;

            if (decompressedTempFile.Exists)
            {
                // This will throw an exception if the downloaded data file
                // can't be used to get the required attributes. The exception
                // is a key part of the validation process.
                DataSetAttributes tempAttrs = new DataSetAttributes(
                    decompressedTempFile);

                // If the current binary file exists then compare the two for
                // the same published date and same properties. If either value
                // is different then the data file should be accepted. If
                // they're the same then the update is not needed.
                if (binaryFile.Exists)
                {
                    DataSetAttributes binaryAttrs = new DataSetAttributes(
                        binaryFile);
                    if (binaryAttrs.Published != tempAttrs.Published ||
                        binaryAttrs.PropertyCount != tempAttrs.PropertyCount)
                    {
                        status = AutoUpdateStatus.AUTO_UPDATE_IN_PROGRESS;
                    }
                    else
                    {
                        status = AutoUpdateStatus.AUTO_UPDATE_NOT_NEEDED;
                    }
                }
            }
            return(status);
        }
        /// <summary>
        /// Method compares the downloaded data file to the existing data 
        /// file to check if the update is required. This will prevent file 
        /// switching if the data file was downloaded but is not newer than 
        /// the existing data file.
        /// </summary>
        /// <remarks>
        /// The following conditions must be met for the data file to be 
        /// considered newer than the current master data file:
        /// 1. Current master data file does not exist.
        /// 2. If the published dates are not the same.
        /// 3. If the number of properties is not the same.
        /// </remarks>
        /// <param name="binaryFile">
        /// Current file to compare against.
        /// </param>
        /// <param name="decompressedTempFile">
        /// Path to the decompressed downloaded file.
        /// </param>
        /// <returns>The current state of the update process.</returns>
        private static AutoUpdateStatus ValidateDownloadedFile(
            FileInfo binaryFile, FileInfo decompressedTempFile)
        {
            AutoUpdateStatus status = AutoUpdateStatus.AUTO_UPDATE_IN_PROGRESS;
            if (decompressedTempFile.Exists)
            {

                // This will throw an exception if the downloaded data file
                // can't be used to get the required attributes. The exception
                // is a key part of the validation process.
                DataSetAttributes tempAttrs = new DataSetAttributes(
                        decompressedTempFile);

                // If the current binary file exists then compare the two for
                // the same published date and same properties. If either value
                // is different then the data file should be accepted. If
                // they're the same then the update is not needed.
                if (binaryFile.Exists)
                {
                    DataSetAttributes binaryAttrs = new DataSetAttributes(
                        binaryFile);
                    if (binaryAttrs.Published != tempAttrs.Published ||
                        binaryAttrs.PropertyCount != tempAttrs.PropertyCount)
                    {
                        status = AutoUpdateStatus.AUTO_UPDATE_IN_PROGRESS;
                    }
                    else
                    {
                        status = AutoUpdateStatus.AUTO_UPDATE_NOT_NEEDED;
                    }
                }
            }
            return status;
        }