예제 #1
0
 public static async Task GetFullBackupDataDirectory(PathSetting path, string databaseName, int requestTimeoutInMs, bool getNodesInfo, ServerStore serverStore, Stream responseStream)
 {
     var isBackup   = string.IsNullOrEmpty(databaseName) == false;
     var pathResult = GetActualFullPath(serverStore, path.FullPath);
     var info       = new DataDirectoryInfo(serverStore, pathResult.FolderPath, databaseName, isBackup, getNodesInfo, requestTimeoutInMs, responseStream);
     await info.UpdateDirectoryResult(databaseName : databaseName, error : pathResult.Error);
 }
예제 #2
0
        /// <summary>
        /// The load routine for the static data file collection
        /// </summary>
        /// <param name="PopulateNodeTrees"></param>
        /// <returns></returns>
        public new bool Load(int PopulateNodeTreeDepth = 0)
        {
            // Loads the static data and builds the trees representing the data files
            if (!DataDirectoryInfo.Exists)
            {
                return(false);
            }
            else
            {
                foreach (FileInfo dataFile in DataDirectoryInfo.GetFiles(targetFileExtension)) // .Reverse())
                {
                    Debug.Print("File evaluated {0}", dataFile.Name);

                    // Create a new HEStationonBlueprintFile and populate the path.
                    StationBlueprint_File tempBlueprintFile = new StationBlueprint_File(this, dataFile);
                    // Add the file to the Data Dictionary
                    DataDictionary.Add(dataFile.Name, tempBlueprintFile);

                    if (tempBlueprintFile.IsLoaded && !LoadError)
                    {
                        // if (PopulateNodeTreeDepth > 0) tempBlueprintFile.DataViewRootNode.CreateChildNodesFromjData(PopulateNodeTreeDepth);

                        if (tempBlueprintFile.RootNode == null)
                        {
                            throw new NullReferenceException();
                        }
                        else
                        {
                            RootNode.Nodes.Insert(0, tempBlueprintFile.RootNode);
                        }
                    }
                }
                return(true);
            }
        }
        /// <summary>
        /// The load routine for the static data file collection
        /// </summary>
        /// <param name="PopulateNodeTrees"></param>
        /// <returns></returns>
        public bool Load(int populateDepth = 0)
        {
            // Loads the static data and builds the trees representing the data files
            if (!DataDirectoryInfo.Exists)
            {
                return(false);
            }
            else
            {
                foreach (FileInfo dataFile in DataDirectoryInfo.GetFiles(targetFileExtension))
                {
                    // Create a new Json_File_UI and populate the path.
                    Json_File_UI tempJsonFile = new Json_File_UI(this, dataFile, populateDepth);
                    // Add the file to the Data Dictionary
                    DataDictionary.Add(dataFile.Name, tempJsonFile);

                    //if (tempJsonFile.IsLoaded) // && !LoadError)
                    {
                        if (tempJsonFile.RootNode == null)
                        {
                            throw new NullReferenceException
                                      ("Json_FileCollection.Load: tempJsonFile.RootNode was null.");
                        }
                        else
                        {
                            RootNode.Nodes.Insert(0, tempJsonFile.RootNode);
                        }
                    }
                }
                return(true);
            }
        }
예제 #4
0
        public static void AssertBackupConfiguration(PeriodicBackupConfiguration configuration)
        {
            if (VerifyBackupFrequency(configuration.FullBackupFrequency) == null &&
                VerifyBackupFrequency(configuration.IncrementalBackupFrequency) == null)
            {
                throw new ArgumentException("Couldn't parse the cron expressions for both full and incremental backups. " +
                                            $"full backup cron expression: {configuration.FullBackupFrequency}, " +
                                            $"incremental backup cron expression: {configuration.IncrementalBackupFrequency}");
            }

            var localSettings = configuration.LocalSettings;

            if (localSettings != null && localSettings.Disabled == false)
            {
                if (localSettings.HasSettings() == false)
                {
                    throw new ArgumentException(
                              $"{nameof(localSettings.FolderPath)} and {nameof(localSettings.GetBackupConfigurationScript)} cannot be both null or empty");
                }

                if (string.IsNullOrEmpty(localSettings.FolderPath) == false)
                {
                    if (DataDirectoryInfo.CanAccessPath(localSettings.FolderPath, out var error) == false)
                    {
                        throw new ArgumentException(error);
                    }
                }
            }

            var retentionPolicy = configuration.RetentionPolicy;

            if (retentionPolicy != null && retentionPolicy.Disabled == false)
            {
                if (retentionPolicy.MinimumBackupAgeToKeep != null)
                {
                    if (retentionPolicy.MinimumBackupAgeToKeep.Value.Ticks <= 0)
                    {
                        throw new ArgumentException($"{nameof(RetentionPolicy.MinimumBackupAgeToKeep)} must be positive");
                    }

                    if (SkipMinimumBackupAgeToKeepValidation == false && retentionPolicy.MinimumBackupAgeToKeep.Value < TimeSpan.FromDays(1))
                    {
                        throw new ArgumentException($"{nameof(RetentionPolicy.MinimumBackupAgeToKeep)} must be bigger than one day");
                    }
                }
            }

            CrontabSchedule VerifyBackupFrequency(string backupFrequency)
            {
                return(string.IsNullOrWhiteSpace(backupFrequency) ? null : CrontabSchedule.Parse(backupFrequency));
            }
        }
예제 #5
0
        public static void AssertBackupConfigurationInternal(BackupConfiguration configuration)
        {
            var localSettings = configuration.LocalSettings;

            if (localSettings != null && localSettings.Disabled == false)
            {
                if (localSettings.HasSettings() == false)
                {
                    throw new ArgumentException(
                              $"{nameof(localSettings.FolderPath)} and {nameof(localSettings.GetBackupConfigurationScript)} cannot be both null or empty");
                }

                if (string.IsNullOrEmpty(localSettings.FolderPath) == false)
                {
                    if (DataDirectoryInfo.CanAccessPath(localSettings.FolderPath, out var error) == false)
                    {
                        throw new ArgumentException(error);
                    }
                }
            }
        }
예제 #6
0
 public static async Task GetFullBackupDataDirectory(string path, int requestTimeoutInMs, bool getNodesInfo, ServerStore serverStore, Stream responseStream)
 {
     var pathResult = GetActualFullPath(serverStore, path);
     var info       = new DataDirectoryInfo(serverStore, pathResult.FolderPath, null, isBackup: true, getNodesInfo, requestTimeoutInMs, responseStream);
     await info.UpdateDirectoryResult(databaseName : null, error : pathResult.Error);
 }