Exemple #1
0
        /// <summary>
        /// Exports a project meta-data and model systems to the given path as a zip file.
        /// </summary>
        /// <param name="user">The user issuing the command.</param>
        /// <param name="exportPath">The file that the project will be saved as.</param>
        /// <param name="error">An error message if the operation fails.</param>
        /// <returns>True if the operation succeeds, false otherwise with an error message.</returns>
        public bool ExportProject(User user, string exportPath, out CommandError?error)
        {
            if (user is null)
            {
                throw new ArgumentNullException(nameof(user));
            }

            if (string.IsNullOrWhiteSpace(exportPath))
            {
                throw new ArgumentException("message", nameof(exportPath));
            }

            lock (_sessionLock)
            {
                if (!Project.CanAccess(user))
                {
                    error = new CommandError("The user does not have access to the project.", true);
                    return(false);
                }
                if (_activeSessions.Count > 0)
                {
                    error = new CommandError("The project is currently being edited and can not be exported.");
                    return(false);
                }
                return(ProjectFile.ExportProject(this, user, exportPath, out error));
            }
        }