public void CalcRemainingTimeMinutesTest2() { var a = new TaskInfo(); a.end = new DateTime(2013, 03, 14, 9, 0, 0); var now = new DateTime(2013, 03, 10, 14, 0, 0); var period = a.calcRemainingTimeMinutes(now); Assert.AreEqual(period, 4 * 12 * 60 - 1 - 5 * 60); }
private void btnOk_Click(object sender, EventArgs e) { if (!File.Exists(txtXmlFilePath.Text)) { MessageBox.Show("Файл не найден."); txtXmlFilePath.Focus(); return; } if (DateTime.Now >= datetimeEnd.Value.AddMinutes(10)) { MessageBox.Show("Дата выполнения должна быть в будущем"); datetimeEnd.Focus(); return; } TaskType type; if (radioApartmentAdd.Checked) type = TaskType.ApartmentAdding; else if (radioApartmentDelete.Checked) type = TaskType.ApartmentDeleting; else if (radioOther.Checked) type = TaskType.Other; else { MessageBox.Show("Тип не указан."); return; } Directory.CreateDirectory(TASKS_FOLDER_NAME); string id = getRandomFileName(); string xmlFileName = Path.Combine(TASKS_FOLDER_NAME, id + ".xml"); string infoFileName = Path.Combine(TASKS_FOLDER_NAME, id + ".info.data"); File.Copy(txtXmlFilePath.Text, xmlFileName); var taskInfo = new TaskInfo(); taskInfo.id = id; taskInfo.type = type; taskInfo.creation = DateTime.Now; taskInfo.end = datetimeEnd.Value; taskInfo.count = getXMLCountOfRows(xmlFileName); taskInfo.Serialize(infoFileName); this.ResultTaskInfo = taskInfo; this.DialogResult = System.Windows.Forms.DialogResult.OK; this.Close(); }
public Task(string id) { info = TaskInfo.Unserialize(Path.Combine("tasks", id + ".info.data")); state = TaskState.Unserialize(Path.Combine("tasks", id + ".state.data")); }