示例#1
0
        public void AddTaskStatuses(Task[] tasks, int checkSheetId)
        {
            List <TaskStatus> statuses = new List <TaskStatus>();

            foreach (Task task in tasks)
            {
                var status = new TaskStatus
                {
                    CheckSheetId   = checkSheetId,
                    TaskId         = task.TaskId,
                    AssignedUserId = null,
                    Comment        = "",
                    State          = State.None
                };

                statuses.Add(status);
            }

            taskStatusRepo.AddMany(statuses.ToArray());
            taskStatusRepo.SaveChanges();
        }
示例#2
0
        public Task[] ImportTasks(string filePath, int checkSheetTypeId)
        {
            using var streamReader = new StreamReader(filePath, Encoding.GetEncoding(1250));
            using var csv          = new CsvReader(streamReader, CultureInfo.InvariantCulture)
                  {
                      Configuration =
                      {
                          Encoding         = Encoding.GetEncoding(1250),
                          ShouldSkipRecord = (record) => record.All(field => string.IsNullOrEmpty(field)),
                          TrimOptions      = CsvHelper.Configuration.TrimOptions.Trim
                      }
                  };

            csv.Configuration.RegisterClassMap <CheckSheetRowMap>();

            var csvRecords = csv.GetRecords <CheckSheetRow>().ToList();
            var tasks      = MapCsvToTasks(csvRecords, checkSheetTypeId);

            taskRepo.AddMany(tasks);
            taskRepo.SaveChanges();

            return(tasks);
        }