Example #1
0
    /// <summary>
    /// If we have Project Mapping information, generate a project based path for the download
    /// </summary>
    /// <param name="basePath"></param>
    /// <param name="projectList"></param>
    /// <param name="projectId"></param>
    /// <returns></returns>
    public static string EnsureProjectBasedPath(string basePath, IProjectsList projectList, IHasProjectId project, TaskStatusLogs statusLog)
    {
        //If we have no project list to do lookups in then just return the base path
        if (projectList == null) return basePath;

        //Look up the project name
        var projWithId = projectList.FindProjectWithId(project.ProjectId);
        if(projWithId == null)
        {
            statusLog.AddError("Project not found with id " + project.ProjectId);
            return basePath;
        }

        //Turn the project name into a directory name
        var safeDirectoryName = GenerateWindowsSafeFilename(projWithId.Name);

        var pathWithProject = Path.Combine(basePath, safeDirectoryName);
        //If needed, create the directory
        if(!Directory.Exists(pathWithProject))
        {
            Directory.CreateDirectory(pathWithProject);
        }

        return pathWithProject;
    }
Example #2
0
    /// <summary>
    /// If we have Project Mapping information, generate a project based path for the download
    /// </summary>
    public static string EnsureProjectBasedPath(string basePath, IProjectsList projectList, IHasProjectId project, ILogger logger)
    {
        //If we have no project list to do lookups in then just return the base path
        if (projectList == null)
        {
            return(basePath);
        }

        //Look up the project name
        var projWithId = projectList.FindProjectWithId(project.ProjectId);

        if (projWithId == null)
        {
            logger.Error("Project not found with id " + project.ProjectId);
            return(basePath);
        }

        //Turn the project name into a directory name
        var safeDirectoryName = GenerateWindowsSafeFilename(projWithId.Name);

        var pathWithProject = Path.Combine(basePath, safeDirectoryName);

        //If needed, create the directory
        if (!Directory.Exists(pathWithProject))
        {
            Directory.CreateDirectory(pathWithProject);
        }

        return(pathWithProject);
    }