public List<DeveloperModel> GetDevelopersFromExcel(IFormFile file) { ExcelUpload<DeveloperModel> excel = new ExcelUpload<DeveloperModel>(); string folderName = "Upload"; string webRootPath = environment.WebRootPath; string newPath = Path.Combine(webRootPath, folderName); string[] allowedColumns = { "name", "skills", "keywords", "previousworks", "profilelink", "previouswork", "product", "component", "hardware" }; return excel.ImportFromExcel(file, newPath, allowedColumns, (string colName, string colValue, DeveloperModel developer) => { if (colName == "name") { developer.DeveloperName = colValue; } if (colName == "product") { developer.ProductName = colValue; } if (colName == "component") { developer.ComponentName = colValue; } if (colName == "hardware") { developer.HardwareName = colValue; } if (colName == "previousworks" || colName == "previouswork" || colName == "profilelink") { developer.PreviousWorks = colValue; } if (colName == "keywords" || colName == "skills") { string[] skills = colValue.Split(','); string processedSkill = ""; foreach (var skill in skills) { var keyword = TextFormaterTool.DataPreprocess(skill); if (keyword == null || keyword == "") continue; processedSkill += keyword + ","; } developer.Skills = processedSkill.TrimEnd(','); } }); }
public List<BugModel> GetBugsFromExcel(IFormFile file) { ExcelUpload<BugModel> excel = new ExcelUpload<BugModel>(); string folderName = "Upload"; string webRootPath = environment.WebRootPath; string newPath = Path.Combine(webRootPath, folderName); string[] allowedColumns = { "product", "component", "severity", "priority", "summary", "description", "hardware", "assignee", "status", "resolution", "id", "changed" }; return excel.ImportFromExcel(file, newPath ,allowedColumns,(string coulumnName, string columnValue,BugModel bug) => { if (coulumnName == "assignee") { bug.AssigneeName = columnValue; } if ( coulumnName == "product") { bug.ProductName = columnValue; } if ( coulumnName == "component") { bug.ComponentName = columnValue; } if (coulumnName == "hardware") { bug.HardwareName = columnValue; } if (coulumnName == "severity") { string severityFromExcel = columnValue.Trim().ToLower(); bug.SeverityTitle = severityFromExcel; } if (coulumnName == "priority") { string priorityFromExcel =columnValue.Trim().ToLower(); bug.PriorityTitle = priorityFromExcel; } if (coulumnName == "summary" ||coulumnName == "description") { string colValue = columnValue.Replace("\'", String.Empty) .Replace("{", string.Empty) .Replace("}", string.Empty) .Replace("\"", String.Empty); var keyword = TextFormaterTool.DataPreprocess(colValue); bug.KeyWords = bug.KeyWords + keyword; } }); }