/// <summary> /// If we have Project Mapping information, generate a project based path for the download /// </summary> /// <param name="basePath">File system location which will be the root of project paths.</param> /// <param name="projectList">Collection of projects which this method will ensure paths exist.</param> /// <param name="project">Project record.</param> /// <param name="statusLog">Logging object.</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); }
/// <summary> /// Attempt to look up the name of a user /// </summary> /// <param name="userId"></param> /// <returns></returns> private string helper_AttemptUserNameLookup(string userId) { try { return(helper_AttemptUserNameLookup_inner(userId)); } catch (Exception ex) { StatusLog.AddError("Error looking up user id, " + ex.Message); return("** Error in user lookup **"); //Continue onward } }