public ActionResult AddingTask() { if (Convert.ToBoolean(Session["loggedOn"]) == true && (Convert.ToInt32(Session["userType"]) == 3 || Convert.ToInt32(Session["userType"]) == 4 || Convert.ToInt32(Session["userType"]) == 5 || Convert.ToInt32(Session["userType"]) == 6)) { ViewBag.userTypeName = Session["UserTypeName"]; ViewBag.userEmail = Session["UserEmail"]; if (Request.Form["SubmitName"] != null) { Project_Task task = new Project_Task(); task.ProjectID = Convert.ToInt32(Request.Form["ProjectName"]); task.UserID = Convert.ToInt32(Request.Form["user"]); task.Description = Request.Form["description"]; task.DueDate = Convert.ToDateTime(Request.Form["dueDate"]); task.Priority = Request.Form["priority"]; try { tasks.Insert(task); return(RedirectToAction("Index")); } catch (Exception e) { Response.Write(e); } } } return(View("Index", "Error")); }
/* SaveTask - Insert project_task into the database. * @param task - The project_task. * @return - Autoincrement Id of the Project_Task. */ public int SaveTask(Project_Task task) { lock (locker) { if (task.name != "") { try { database.Insert(task); SQLiteCommand cmd = database.CreateCommand("SELECT last_insert_rowid()"); cmd.CommandText = "SELECT last_insert_rowid()"; Int64 LastRowID64 = cmd.ExecuteScalar <Int64>(); int LastRowID = (int)LastRowID64; return(LastRowID); } catch (Exception e) { database.Update(task); return(task.Id); } } else { return(-1); } } }
/* * SessionLive - Initialize the Content view when a session is being resume. * @param databaseAccess - The database. */ public SessionLive(Database_Controller databaseAccess) { InitializeComponent(); RefreshTime(); database = databaseAccess; current = database.GetliveSession(); selected_project = database.GetOneProject(current.project); selected_task = database.GetOneTask(current.taskId); this.Task_Name.Text = selected_task.name; this.Project_Name.Text = selected_project.name; interrupt = database.GetliveInterrupt(); if (!Resolver.IsSet) { var container = new SimpleContainer(); container.Register <IAccelerometer, Accelerometer>(); Resolver.SetResolver(container.GetResolver()); } GlobalUtilities.accelerometer = Resolver.Resolve <IAccelerometer>(); GlobalUtilities.accelerometer.Interval = AccelerometerInterval.Normal; if (interrupt is null) { Start.Text = "Pause"; getlocation = true; askLocation(); accelometeractive = true; GlobalUtilities.accelerometer.ReadingAvailable += Accelerometer_ReadingAvailable; } else { Start.Text = "Resume"; getlocation = false; askLocation(); } }
public static List <Project_Task> TablesColumnsDisplay() { List <Project_Task> PT = new List <Project_Task>(); string connection = "Data Source=(localdb)\\mssqllocaldb;Initial Catalog=ICONEXTContext-1;Integrated Security=True"; using (SqlConnection sqlconn = new SqlConnection(connection)) { using (SqlCommand sqlcomm = new SqlCommand("select project.Name, TaskProject.Tasks from project full join TaskProject on project.ProjID=TaskProject.ProjID")) { using (SqlDataAdapter SDA = new SqlDataAdapter()) { sqlcomm.Connection = sqlconn; sqlconn.Open(); SDA.SelectCommand = sqlcomm; SqlDataReader SDR = sqlcomm.ExecuteReader(); while (SDR.Read()) { Project_Task PTOBJ = new Project_Task(); PTOBJ.Name = SDR["Name"].ToString(); PTOBJ.Tasks = SDR["Tasks"].ToString(); PT.Add(PTOBJ); } } return(PT); } } }
public void Delete(int id) { Project_Task task = this.context.Project_Task.SingleOrDefault(x => x.Id == id); this.context.Project_Task.Remove(task); this.context.SaveChanges(); }
/* * OnCancelButtonClicked - Method that cancels the information displayed for a task. */ void OnCancelButtonClicked(object sender, EventArgs args) { overlay.IsVisible = false; Tasks_List.IsVisible = true; View_Sessions.IsVisible = true; Delete_Project.IsVisible = true; tapped = null; }
public void Update(Project_Task projectTask) { Project_Task task = this.context.Project_Task.SingleOrDefault(x => x.Id == projectTask.Id); task.UserID = projectTask.UserID; task.DueDate = projectTask.DueDate; this.context.SaveChanges(); }
Semaphore semaphoreObject = new Semaphore(initialCount: 1, maximumCount: 1, name: "accel"); //semaphore to allow only one reading of the accelerometer. /* * SessionLive - Initialize the Content view and its components. * @param project - The project that own the task and the session. * @param task - The task that own the session. * @param databaseAccess - The database. */ public SessionLive(Project project, Project_Task task, Database_Controller databaseAccess) { InitializeComponent(); this.Task_Name.Text = task.name; this.Project_Name.Text = project.name; selected_project = project; selected_task = task; database = databaseAccess; //Timer_Counter.Text = "Session is not live"; }
/* * OnOKButtonClicked - Add the task to the list. */ void OnOKButtonClicked(object sender, EventArgs args) { overlay.IsVisible = false; List <Session> sessions = new List <Session>(); Project_Task new_task = new Project_Task(Name.Text, Decription.Text, Double.Parse(Estimation.Text), sessions); list.Add(new_task); Tasks_List.IsVisible = true; New_Tasks.IsVisible = true; Create_Project.IsVisible = true; }
/* * OnSelection - Deleted the tapped task out of the project. */ void OnSelection(object sender, ItemTappedEventArgs e) { if (e.Item == null) { return; //ItemSelected is called on deselection, which results in SelectedItem being set to null } Project_Task temp_task = (Project_Task)e.Item; DisplayAlert("Item Selected", temp_task.name, "Ok"); list.Remove(temp_task); }
/* * OnAppearing - Get live session, calculates the engage time and estimation time for the project. */ protected override void OnAppearing() { overlay.IsVisible = false; Tasks_List.IsVisible = true; View_Sessions.IsVisible = true; Delete_Project.IsVisible = true; tapped = null; live = database.GetliveSession(); Estimation_Time.Text = "Estimation: "; Engage_Time.Text = "Time spend: "; double auxEstimation = GetEstimation(selectedProject); double auxSpend = GetEngageTime(selectedProject); Estimation_Time.Text += TimeSpan.FromMinutes(Math.Round(auxEstimation, 3)).ToString(); Engage_Time.Text += TimeSpan.FromMinutes(Math.Round(auxSpend, 3)).ToString(); if (auxEstimation < auxSpend) { Engage_Time.BackgroundColor = Color.Red; } else { Engage_Time.BackgroundColor = Color.Green; } if (live != null) { Resume_Session.IsVisible = true; LiveSession = true; interrupt = database.GetliveInterrupt(); if (interrupt is null) { getlocation = true; askLocation(); accelometeractive = true; GlobalUtilities.accelerometer.ReadingAvailable += Accelerometer_ReadingAvailable; } } else { Resume_Session.IsVisible = false; LiveSession = false; } }
/* * OnSelection - Method that display the information of the selected task. */ void OnSelection(object sender, ItemTappedEventArgs e) { if (e.Item == null) { return; } Project_Task temp_task = (Project_Task)e.Item; Name.Text = "Name: "; Decription.Text = "Description: "; Estimation.Text = "Estimation: "; temp_task.sessions = database.GetSessionsOfTask(temp_task.Id); double timeSP; if (temp_task.sessions != null) { timeSP = GetTaskEngageTime(temp_task.sessions); TimeSpendTask.Text = "Time Spend: " + TimeSpan.FromMinutes(Math.Round(timeSP, 3)).ToString(); } else { timeSP = 0; } Name.Text += temp_task.name; Decription.Text += temp_task.description; Estimation.Text += TimeSpan.FromMinutes(temp_task.estimation).ToString(); tapped = temp_task; if (temp_task.estimation < timeSP) { TimeSpendTask.BackgroundColor = Color.Red; } else { TimeSpendTask.BackgroundColor = Color.Green; } overlay.IsVisible = true; Tasks_List.IsVisible = false; View_Sessions.IsVisible = false; Delete_Project.IsVisible = false; Name.Focus(); }
public void Insert(Project_Task projectTask) { this.context.Project_Task.Add(projectTask); this.context.SaveChanges(); }
public void Update(Project_Task projectTask) { this.data.Update(projectTask); }
public void Insert(Project_Task projectTask) { this.data.Insert(projectTask); }