List <TaskSchedule> CreateActualDeliveryTask(List <TaskSchedule> tasks) { List <TaskSchedule> returnList = new List <TaskSchedule>(); //Create temp delivery between locations for (int i = 0; i < tasks.Count; i++) { returnList.Add(tasks[i]); if (i != tasks.Count - 1) { if (tasks[i].ToLocation != tasks[i + 1].FromLocation) { TaskSchedule temp = new TaskSchedule(); temp.ScheduleID = i.ToString() + "_V"; temp.TaskName = "Virtual"; temp.TaskType = "Virtual"; temp.PickTime = 0.0; temp.Duration = 0.0; temp.ConsTime = 0.0; temp.FromLocation = tasks[i].ToLocation; temp.ToLocation = tasks[i + 1].FromLocation; returnList.Add(temp); } } } return(returnList); }
public List <TaskSchedule> GenerateSchedules(List <StandardTask> standardTasks, List <int> numofeachtask, int timelength) { List <TaskSchedule> returnList = new List <TaskSchedule>(); for (int i = 0; i < standardTasks.Count; i++) { for (int j = 0; j < numofeachtask[i]; j++) { TaskSchedule taskSchedule = new TaskSchedule(); taskSchedule.TaskName = standardTasks[i].TaskName; taskSchedule.TaskType = standardTasks[i].TaskType; taskSchedule.PickTime = Math.Round(rand.NextDouble() * timelength); taskSchedule.ConsTime = Math.Round(NormalDistribution.Random(standardTasks[i].DeliveryTime, standardTasks[i].Deviation)) + taskSchedule.PickTime; taskSchedule.FromLocation = standardTasks[i].FromLocation; taskSchedule.ToLocation = standardTasks[i].ToLocation; while (taskSchedule.ConsTime > timelength) { taskSchedule.PickTime = Math.Round(rand.NextDouble() * timelength); taskSchedule.ConsTime = Math.Round(NormalDistribution.Random(standardTasks[i].DeliveryTime, standardTasks[i].Deviation)) + taskSchedule.PickTime; } taskSchedule.Duration = taskSchedule.ConsTime - taskSchedule.PickTime; returnList.Add(taskSchedule); } } return(returnList); }
private void BtnReadCSV_Click(object sender, RoutedEventArgs e) { //Read CSV file OpenFileDialog openFileDialog = new OpenFileDialog(); string tempString = ""; if (openFileDialog.ShowDialog() == true) { string[] lines = File.ReadAllLines(System.IO.Path.ChangeExtension(openFileDialog.FileName, ".csv")); for (int i = 0; i < lines.Length; i++) { string[] data = lines[i].Split(','); TaskSchedule tempTask = new TaskSchedule(); tempTask.ScheduleID = data[0]; tempTask.TaskName = data[1]; tempTask.TaskType = data[2]; //unit = second tempTask.PickTime = ConvertMMSStoSecond(data[3]); tempTask.Duration = ConvertMMSStoSecond(data[4]); tempTask.ConsTime = ConvertMMSStoSecond(data[5]); tempTask.FromLocation = data[6]; tempTask.ToLocation = data[7]; tempString = tempString + tempTask.ScheduleID + "," + tempTask.TaskName + "," + tempTask.TaskType + "," + tempTask.PickTime + "," + tempTask.Duration + "," + tempTask.ConsTime + "," + tempTask.FromLocation + "," + tempTask.ToLocation + "\r\n"; inputTaskList.Add(tempTask); } } txtTaskListInput.Text = tempString; MessageBox.Show("Task list is imported"); }