public ActionResult Create(int id, TaskCreateForm collection) { try { if (ModelState.IsValid) { TaskService repoTask = new TaskService(); CD.Task task = new CD.Task( collection.Name, collection.Description, collection.StartDate, collection.DeadLine, id, collection.TaskTeam, (collection.MainTaskId != 0)?(int?)collection.MainTaskId:null); task = repoTask.Insert(task); return(RedirectToAction("Details", "Project", new { id = id })); } return(View(id)); } catch (Exception e) { Debug.WriteLine(e.Message); return(View(id)); } }
private void AddTaskButton_Click(object sender, EventArgs e) { TaskCreateForm form = new TaskCreateForm( Subjects[subjectComboBox.SelectedIndex].Id, Groups[groupComboBox.SelectedIndex].Id); form.TaskCreated += Form_TaskCreated; form.Show(); }
// 给模块建立任务,任务相关(需要当前的所有的项目迭代,供选择) public static Task CreateTask(ProjectModule module, Project project) { TaskCreateForm f = new TaskCreateForm(); f.Project = project; f.Module = module; f.ShowDialog(); return(f.Task); }
private void Item_TaskEdited(object sender, EventArgs e) { TaskCreateForm form = new TaskCreateForm( sender as TaskExtModel, Subjects[subjectComboBox.SelectedIndex].Id, Groups[groupComboBox.SelectedIndex].Id); form.TaskEdited += Form_TaskEdited;; form.Show(); }
public async Task <IActionResult> Create([FromBody] TaskCreateForm form) { var task = new Task { Name = form.Name, StartTime = form.StartTime, EndTime = form.EndTime, Interval = form.Interval, SubTasks = new List <SubTask>() }; var startTime = task.StartTime; var endTime = task.EndTime; while ((endTime - startTime).TotalMinutes >= 0) { var sendTime = startTime; if (sendTime <= endTime && sendTime > DateTime.UtcNow) { task.SubTasks.Add(new SubTask { Id = ObjectId.GenerateNewId(), SendTime = sendTime }); } startTime = startTime.AddMinutes(task.Interval); } await _mongoDbContext.Collection <Task>().InsertOneAsync(task); var timeFlag = task.SubTasks[0].SendTime.ToString("yyyy-MM-dd HH:mm:ssZ"); var exchange = "Task"; var queue = "Task"; var index = 0; var pendingExchange = "PendingTask"; var pendingQueue = $"PendingTask|Task:{task.Id}_{index}_{timeFlag}"; using (var channel = _rabbitConnection.CreateModel()) { channel.ExchangeDeclare(exchange, "direct", true); channel.QueueDeclare(queue, true, false, false); channel.QueueBind(queue, exchange, queue); var retryDic = new Dictionary <string, object> { { "x-dead-letter-exchange", exchange }, { "x-dead-letter-routing-key", queue } }; channel.ExchangeDeclare(pendingExchange, "direct", true); channel.QueueDeclare(pendingQueue, true, false, false, retryDic); channel.QueueBind(pendingQueue, pendingExchange, pendingQueue); var properties = channel.CreateBasicProperties(); properties.Headers = new Dictionary <string, object> { ["index"] = index, ["id"] = task.Id.ToString(), ["sendtime"] = timeFlag }; properties.Expiration = ((int)(task.SubTasks[0].SendTime - DateTime.UtcNow).TotalMilliseconds).ToString(CultureInfo.InvariantCulture); channel.BasicPublish(pendingExchange, pendingQueue, properties, Encoding.UTF8.GetBytes(string.Empty)); } return(Ok()); }