public TaskClass getTask() { TaskClass task = new TaskClass(); task.serviceVisitID = this.serviceVisitID; task.lastService = this.lastService; task.thisResult = (TaskResultStatus)Enum.Parse(typeof(TaskResultStatus), this.thisResult); task.lastResult = (TaskResultStatus)Enum.Parse(typeof(TaskResultStatus), this.lastResult); task.taskType = this.taskType; task.serviceVisitItemNumber = this.serviceVisitItemNumber; task.taskName = this.taskName; task.siteEquipmentLineNumber = this.siteEquipmentLineNumber; task.siteID = this.siteID; TaskInformation taskInfo = new TaskInformation(); taskInfo.contractor = this.contractor; taskInfo.taskTypeDescription = this.taskTypeDescription; taskInfo.location = this.location; taskInfo.barcode = this.barcode; taskInfo.opNumber = this.opNumber; taskInfo.isMoving2012Standard = this.isMoving2012Standard; taskInfo.maintainedStandard = this.maintainedStandard; taskInfo.lastServicedBy = this.lastServicedBy; task.taskInformation = taskInfo; return(task); }
/// <summary> /// Remove Task from the database /// </summary> /// <param name="TaskId">TaskId</param> /// <returns>Status of the Operation</returns> public string RemoveTask(int TaskId) { try { using (CapsuleEntities PE = new CapsuleEntities()) { PE.Configuration.ProxyCreationEnabled = false; TaskInformation I = PE.TaskInformations.Where(x => x.TaskId == TaskId).FirstOrDefault(); if (I == null) { return("Task with Id " + TaskId + " Not found"); } else { PE.Entry(I).State = System.Data.Entity.EntityState.Deleted; PE.SaveChanges(); return("Success"); } } } catch (Exception ex) { return("Failed : " + ex.Message); } }
public void PosTaskTest() { //Arrange TaskCrud taskcrud = new TaskCrud(); //Act TaskInformation task = new TaskInformation(); task.IsTaskCompleted = 0; task.Priority = 4; task.ProjectId = 1; task.TaskId = 0; task.TaskDescription = "Test Child"; task.UserId = 1; task.StartDate = DateTime.Parse("02/01/2018"); task.EndDate = DateTime.Parse("02/01/2018"); TaskInformation value = taskcrud.AddTask(task); //Assert if (value != null) { Assert.AreEqual(value.TaskDescription, task.TaskDescription); } else { Assert.IsNotNull(value);//Arrange } }
private void RefreshRead(TaskInformation task) { GUILayout.BeginVertical(); { GUILayout.BeginHorizontal(); { GUILayout.Button("名称:", GUILayout.Width(WIDTH)); GUILayout.Label(task.name, GUILayout.Width(150)); GUILayout.Button("进度:", GUILayout.Width(WIDTH)); GUILayout.Label(string.Format("{0}%", task.progress)); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); { GUILayout.Button("描述:", GUILayout.Width(WIDTH)); GUILayout.Label(task.description, GUILayout.ExpandHeight(true)); } GUILayout.EndHorizontal(); } GUILayout.EndVertical(); }
public IHttpActionResult Put(int TaskId, TaskInformation t) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (TaskId != t.TaskId) { return(BadRequest()); } try { TaskDetailsGetter.UpdateTask(t); } catch (DbUpdateConcurrencyException) { if (!TaskDetailsGetter.IsTaskExist(TaskId)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public static void PopulateTaskInformation(TaskInformation information) { if (information.Status == TaskStatus.Completed) { return; } else { TaskConfigData taskData = ConfigInterface.Instance.TaskConfigHelper.GetTaskData(information.TaskID); foreach (KeyValuePair <int, TaskConditionConfigData> condition in taskData.Conditions) { if (information.ConditionProgresses == null) { information.ConditionProgresses = new Dictionary <int, TaskProgressInformation>(); } if (!information.ConditionProgresses.ContainsKey(condition.Key)) { information.ConditionProgresses.Add(condition.Key, new TaskProgressInformation() { StartValue = 0, CurrentValue = GetCurrentValueFromConfig(condition.Value) }); } else { information.ConditionProgresses[condition.Key].CurrentValue = GetCurrentValueFromConfig(condition.Value); } } } }
void GetANewTask() { System.Random Random = new System.Random(); int NewTaskInt = Random.Next(0, Tasks.Length); if (TaskInt != NewTaskInt) { TaskInt = NewTaskInt; CurrentTask = Tasks[TaskInt]; } else { while (TaskInt == NewTaskInt) { NewTaskInt = Random.Next(0, Tasks.Length); if (TaskInt != NewTaskInt) { TaskInt = NewTaskInt; CurrentTask = Tasks[TaskInt]; Config.Clear(); break; } } } }
private void RefreshWrite(TaskInformation task) { GUILayout.BeginVertical(); { GUILayout.BeginHorizontal(); { GUILayout.Button("名称:", GUILayout.Width(WIDTH)); task.name = GUILayout.TextField(task.name); switch (task.status) { case Status.Editor: { GUILayout.Button("进度:", GUILayout.Width(WIDTH)); GUILayout.Label(string.Format("{0}%", task.progress), GUILayout.Width(100)); task.progress = GUILayout.HorizontalSlider(task.progress, 0, 100, GUILayout.Width(150)); } break; } } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); { GUILayout.Button("描述:", GUILayout.Width(WIDTH)); task.description = GUILayout.TextField(task.description, GUILayout.ExpandHeight(true)); } GUILayout.EndHorizontal(); } GUILayout.EndVertical(); }
public static async Task <BackgroundTaskRegistration> RegisterBackgroundTask(TaskInformation info) { if (info.background) { await BackgroundExecutionManager.RequestAccessAsync(); } var builder = new BackgroundTaskBuilder(); builder.Name = info.name; builder.TaskEntryPoint = info.taskEntryPoint; builder.SetTrigger(info.trigger); if (info.condition != null) { builder.AddCondition(info.condition); builder.CancelOnConditionLoss = true; } BackgroundTaskRegistration task = builder.Register(); /*if (info.callback != null) * { * task.Completed += * }*/ return(task); }
public void OpenChildrenTask() { foreach (int childID in this.TaskConfigData.Children) { TaskInformation info = new TaskInformation(); info.Status = TaskStatus.Opened; info.TaskID = childID; info.ConditionProgresses = new Dictionary <int, TaskProgressInformation>(); TaskConfigData configData = ConfigInterface.Instance.TaskConfigHelper.GetTaskData(childID); if (configData.ValidSeconds > 0) { info.RemainingSeconds = configData.ValidSeconds; } foreach (KeyValuePair <int, TaskConditionConfigData> condition in configData.Conditions) { if (!condition.Value.IsGlobal) { info.ConditionProgresses.Add(condition.Key, new TaskProgressInformation() { StartValue = TaskProgressFactory.GetCurrentValueFromConfig(condition.Value) }); } } TaskProgressFactory.PopulateTaskInformation(info); Task childTask = new Task(info, this.m_Manager); LogicController.Instance.TaskManager.AddTask(childTask); } }
/// <summary> /// Getting the specific Task from the database /// </summary> /// <param name="TaskId">TaskId</param> /// <returns>TaskInformation</returns> public TaskInformation GetTask(int TaskId) { using (CapsuleEntities PE = new CapsuleEntities()) { PE.Configuration.ProxyCreationEnabled = false; TaskInformation i = PE.TaskInformations.Where(x => x.TaskId == TaskId).FirstOrDefault(); return(i); } }
public IHttpActionResult Post(TaskInformation t) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } TaskDetailsGetter.AddTask(t); return(CreatedAtRoute("DefaultApi", new { id = t.TaskId }, t)); }
public ActionResult DeleteTaskInfo(string id) { TaskInformationDBContext db = new TaskInformationDBContext(); int ID = Convert.ToInt32(id); TaskInformation taskinformation = db.taskInformations.Find(ID); db.taskInformations.Remove(taskinformation); db.SaveChanges(); return(RedirectToAction("TaskListInfo")); }
public ActionResult EditTaskInfo([Bind(Include = "taskId,taskName,taskStartTime,taskEndTime,taskMaxSubmitTime,taskPercent,taskRequire,taskSubmitter,courseId")] TaskInformation task) { if (ModelState.IsValid) { TaskInformationDBContext db = new TaskInformationDBContext(); db.Entry(task).State = EntityState.Modified; db.SaveChanges(); } return(RedirectToAction("TaskListInfo")); }
public IHttpActionResult Delete(int TaskId) { TaskInformation task = TaskDetailsGetter.GetTask(TaskId); if (task == null) { return(NotFound()); } TaskDetailsGetter.RemoveTask(TaskId); return(Ok(task)); }
private void RefreshTask(TaskInformation task) { switch (task.status) { case Status.Create: { RefreshWrite(task); if (GUILayout.Button("新加", GUILayout.Width(100), GUILayout.ExpandHeight(true))) { task.status = Status.None; this.task.Add(task); Save(); create = new TaskInformation() { status = Status.Create, }; } } break; case Status.Editor: { RefreshWrite(task); GUILayout.BeginVertical(GUILayout.Width(100)); { if (GUILayout.Button("保存")) { task.status = Status.None; Save(); } if (GUILayout.Button("删除")) { this.task.Remove(task.name); Save(); } } GUILayout.EndVertical(); } break; case Status.None: { RefreshRead(task); if (GUILayout.Button("修改")) { task.status = Status.Editor; } } break; } }
public IHttpActionResult Get(int TaskId) { TaskInformation i = TaskDetailsGetter.GetTask(TaskId); if (i != null) { return(Ok(i)); } else { return(NotFound()); } }
public void UpdateTask(TaskInformation _task) { var AllTasks = QuestManager.Instance.TaskContainer.GetComponentsInChildren <Tasks> (); foreach (var taskGameObject in AllTasks) { if (_task == taskGameObject.task) { taskGameObject.DoneImageSprite.SetActive(_task.TaskCompleted); taskGameObject.GoButton.SetActive(!_task.TaskCompleted); } } }
public HttpResponseMessage Get(int TaskId) { TaskInformation i = TaskDetailsGetter.GetTask(TaskId); if (i != null) { return(Request.CreateResponse(HttpStatusCode.OK, i)); } else { return(Request.CreateErrorResponse(HttpStatusCode.NotFound, "Task Id : " + TaskId + " Not Found")); } }
public Boolean AddTaskInformation(TaskInformation tinfo) { try { _context.TaskInformations.Add(tinfo); _context.SaveChanges(); return(true); } catch { return(false); } }
protected void OnButton1Clicked(object sender, EventArgs e) { // start a new task with Task.Factory // this is a very common method to work on something in the background // use TaskInformation to observe this new task CancellationTokenSource cancelTokenSource = new CancellationTokenSource(); lock (cancelTokenList) cancelTokenList.Add(cancelTokenSource); Task.Factory.StartNew(() => { myTaskId++; String name = String.Format("{0}:{1}", myThreadHeader, myTaskId); String description = "Example how to use a Task"; Message(String.Format("Task {0} started", name)); Gtk.Application.Invoke(delegate { labelTaskCount.Text = String.Format("Running count: {0}", ++countTasks); }); TaskInformation ti = TaskInformation.Create(cancelTokenSource, name, description); int duration = rnd.Next() % 5000 + 5000; int steps = 100; int onesleep = duration / steps; int proceeded = 0; while (proceeded < duration) { proceeded += onesleep; Thread.Sleep(onesleep); ti.Progress = proceeded * 100 / duration; if (cancelTokenSource.IsCancellationRequested) { break; } } Message(String.Format("Task {0} {1}", name, cancelTokenSource.IsCancellationRequested ? "cancelled" : "finished")); ti.Destroy(); Gtk.Application.Invoke(delegate { labelTaskCount.Text = String.Format("Running count: {0}", --countTasks); }); lock (cancelTokenList) cancelTokenList.Remove(cancelTokenSource); }, cancelTokenSource.Token); }
public async Task Register(TaskInformation info) { bool found = false; foreach (var task in BackgroundTaskRegistration.AllTasks) { if (task.Value.Name == info.name) found = true; } if (!found) { var reg = await RegisterBackgroundTask(info); } }
public void GetTaskTest() { //Arrange TaskCrud taskcrud = new TaskCrud(); //Act TaskInformation task = taskcrud.GetTask(1); //Assert if (task != null) { Assert.AreEqual(1, task.TaskId); } else { Assert.IsNotNull(task); } }
public ActionResult CreateTaskInfo([Bind(Include = "taskName,taskStartTime,taskEndTime,taskMaxSubmitTime,taskRequire")] TaskInformation task) { DBHelper dbHelper = DBHelper.getMyHelper(); if (ModelState.IsValid) { //1.获取Cookie,从中提取课程id HttpCookie cookie = Request.Cookies["course"]; string courseId = null; if (cookie != null) { courseId = cookie["courseid"]; } if (courseId == null) { return(RedirectToAction("CourseInfo")); } //2.赋值给task task.courseId = courseId; //3.获取cookie,提取用户id,获得用户姓名 cookie = Request.Cookies["Account"]; string userId = null; if (cookie != null) { userId = cookie["userName"]; } if (userId == null) { return(RedirectToAction("Index", "SecurityController")); } List <User> users = dbHelper.getUsers(); foreach (User u in users) { if (u.userId == userId) { task.taskSubmitter = u.userName; break; } } TaskInformationDBContext db = new TaskInformationDBContext(); db.taskInformations.Add(task); db.SaveChanges(); db = null; } return(RedirectToAction("TaskListInfo")); }
public ActionResult TaskInfoDetails(string id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } TaskInformationDBContext db = new TaskInformationDBContext(); int ID = Convert.ToInt32(id); TaskInformation taskinformation = db.taskInformations.Find(ID); if (taskinformation == null) { return(HttpNotFound()); } return(View(taskinformation)); }
public TaskDetailsViewModel(TaskViewModel targetTast) { TargetTask = targetTast; //DuplicateTaskInfo = new TaskInformation DuplicateTaskInfo = new TaskInformation() { Contractor = _taskViewModel.TaskInfo.Contractor, TaskTypeDescription = _taskViewModel.TaskInfo.TaskTypeDescription, Barcode = _taskViewModel.TaskInfo.Barcode, IsMoving2012Standard = _taskViewModel.TaskInfo.IsMoving2012Standard, LastServicedBy = _taskViewModel.TaskInfo.LastServicedBy, Location = _taskViewModel.TaskInfo.Location, MaintainedStandard = _taskViewModel.TaskInfo.MaintainedStandard, OPNumber = _taskViewModel.TaskInfo.OPNumber }; SaveTaskInfoCommand = new Command(async() => await SaveTaskInfoCommandAct()); }
protected override void Init() { string content = UnityEngine.PlayerPrefs.GetString(KEY); if (string.IsNullOrEmpty(content)) { task = new TaskData(); } else { task = JsonUtility.FromJson <TaskData>(content); } create = new TaskInformation() { status = Status.Create, }; }
/// <summary> /// Add a particular task to database /// </summary> /// <param name="i">TaskInformation</param> /// <returns>Status of the Operation</returns> public TaskInformation AddTask(TaskInformation i) { try { using (CapsuleEntities PE = new CapsuleEntities()) { PE.Configuration.ProxyCreationEnabled = false; PE.TaskInformations.Add(i); PE.SaveChanges(); return(i); } } catch (Exception) { throw; } }
/// <summary> /// Add a particular task to database /// </summary> /// <param name="i">TaskInformation</param> /// <returns>Status of the Operation</returns> public string AddTask(TaskInformation i) { try { using (CapsuleEntities PE = new CapsuleEntities()) { PE.Configuration.ProxyCreationEnabled = false; PE.TaskInformations.Add(i); PE.SaveChanges(); return("Success"); } } catch (Exception ex) { return("Failed" + ex.Message); } }
/// <summary> /// Remove Task from the database /// </summary> /// <param name="TaskId">TaskId</param> /// <returns>Status of the Operation</returns> public TaskInformation RemoveTask(int TaskId) { try { using (CapsuleEntities PE = new CapsuleEntities()) { PE.Configuration.ProxyCreationEnabled = false; TaskInformation I = PE.TaskInformations.Where(x => x.TaskId == TaskId).FirstOrDefault(); PE.Entry(I).State = System.Data.Entity.EntityState.Deleted; PE.SaveChanges(); return(I); } } catch (Exception) { throw; } }
public async Task Register(TaskInformation info) { bool found = false; foreach (var task in BackgroundTaskRegistration.AllTasks) { if (task.Value.Name == info.name) { found = true; } } if (!found) { var reg = await RegisterBackgroundTask(info); } }
public static async Task<BackgroundTaskRegistration> RegisterBackgroundTask(TaskInformation info) { if (info.background) { await BackgroundExecutionManager.RequestAccessAsync(); } var builder = new BackgroundTaskBuilder(); builder.Name = info.name; builder.TaskEntryPoint = info.taskEntryPoint; builder.SetTrigger(info.trigger); if (info.condition != null) { builder.AddCondition(info.condition); builder.CancelOnConditionLoss = true; } BackgroundTaskRegistration task = builder.Register(); /*if (info.callback != null) { task.Completed += }*/ return task; }