Example #1
0
        public static bool ValidatePaths(FileBrowserValidateEventArgs args, out string errorMessage)
        {
            errorMessage = string.Empty;
            bool          result     = true;
            SqlConnection connection = null;

            if (args != null)
            {
                ConnectionInfo connInfo;
                ConnectionService.Instance.TryFindConnection(args.OwnerUri, out connInfo);
                if (connInfo != null)
                {
                    DbConnection dbConnection = null;
                    connInfo.TryGetConnection(Connection.ConnectionType.Default, out dbConnection);
                    if (dbConnection != null)
                    {
                        connection = ReliableConnectionHelper.GetAsSqlConnection(dbConnection);
                    }
                }
            }

            if (connection != null)
            {
                foreach (string filePath in args.FilePaths)
                {
                    bool isFolder;
                    bool existing = IsPathExisting(connection, filePath, out isFolder);

                    if (existing)
                    {
                        if (isFolder)
                        {
                            errorMessage = SR.BackupPathIsFolderError;
                        }
                    }
                    else
                    {
                        if (args.ServiceType == FileValidationServiceConstants.Backup)
                        {
                            errorMessage = IsFolderPathExisting(connection, filePath);
                        }
                        else if (args.ServiceType == FileValidationServiceConstants.Restore)
                        {
                            errorMessage = SR.InvalidBackupPathError;
                        }
                    }

                    if (!string.IsNullOrEmpty(errorMessage))
                    {
                        result = false;
                        break;
                    }
                }
            }

            return(result);
        }
Example #2
0
 private static bool ValidatePaths(FileBrowserValidateEventArgs eventArgs, out string message)
 {
     message = string.Empty;
     return(false);
 }