/// <summary> /// Constructor. Builds the data for the CSV file /// </summary> /// <param name="projects"></param> /// <param name="dataSources"></param> /// <param name="workbooks"></param> /// <param name="users"></param> /// <param name="groups"></param> /// <param name="statusLogger"></param> public CustomerSiteInventory( IEnumerable <SiteProject> projects, IEnumerable <SiteDatasource> dataSources, IEnumerable <SiteWorkbook> workbooks, IEnumerable <SiteUser> users, IEnumerable <SiteGroup> groups, TaskStatusLogs statusLogger) { //Somewhere to store status logs if (statusLogger == null) { statusLogger = new TaskStatusLogs(); } StatusLog = statusLogger; //If we have a user-set, put it into a lookup class so we can quickly look up user names when we write out other data //that has user ids var siteUsers = users as IList <SiteUser> ?? users.ToList(); if (users != null) { _siteUserMapping = new KeyedLookup <SiteUser>(siteUsers); } AddProjectsData(projects); AddDatasourcesData(dataSources); AddWorkbooksData(workbooks); AddUsersData(siteUsers); AddGroupsData(groups); }
/// <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="workbook">Workbook record.</param> /// <param name="statusLog">Logging object.</param> /// <returns></returns> public static string EnsureProjectBasedPath(string basePath, SiteWorkbook workbook, TaskStatusLogs statusLog) { //If we have no project list to do lookups in then just return the base path if (workbook == null) { return(basePath); } //Turn the project name into a directory name var safeDirectoryName = GenerateWindowsSafeFilename(workbook.Name); var pathWithProject = Path.Combine(basePath, safeDirectoryName); //If needed, create the directory if (!Directory.Exists(pathWithProject)) { Directory.CreateDirectory(pathWithProject); } return(pathWithProject); }
/// <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); }