Пример #1
0
 private void ParseTask(string from, string[] contents)
 {
     foreach (MyProject search in ((ObservableCollection<MyProject>)settings["ProjectList"]))
     {
         if (contents[1].Equals(search.projKey))
         {
             bool taskFound = false;
             foreach (MyTask searchTask in search.tasks)
             {
                 if (contents[4].Equals(searchTask.taskKey))
                 {
                     searchTask.name = contents[2];
                     searchTask.description = contents[3];
                     searchTask.dueDate = DateTime.Parse(contents[5]);
                     searchTask.remindDate = DateTime.Parse(contents[6]);
                     searchTask.isComplete = Convert.ToBoolean(contents[7]);
                     searchTask.status = contents[8];
                     searchTask.project = contents[9];
                     Person createP = new Person();
                     createP.name = contents[10];
                     createP.username = contents[11];
                     createP.hawaiiID = contents[12];
                     createP.reqSent = Convert.ToBoolean(contents[13]);
                     createP.accepted = Convert.ToBoolean(contents[14]);
                     searchTask.assignedTo = createP;
                     if (!searchTask.remindDate.Equals(DateTime.MinValue) && searchTask.remindDate > DateTime.Now && searchTask.assignedTo.hawaiiID == this.RelayContext.Endpoint.RegistrationId)
                     {
                         try
                         {
                             ScheduledActionService.Remove(searchTask.taskKey);
                         }
                         catch (InvalidOperationException) { }
                         Reminder reminder = new Reminder(searchTask.taskKey);
                         Uri navUri = new Uri("/TaskView.xaml?TaskKey=" + searchTask.taskKey + "&ProjectKey=" + search.projKey, UriKind.RelativeOrAbsolute);
                         reminder.Title = searchTask.name;
                         reminder.Content = searchTask.description;
                         reminder.BeginTime = searchTask.remindDate;
                         reminder.ExpirationTime = searchTask.remindDate;
                         reminder.NavigationUri = navUri;
                         ScheduledActionService.Add(reminder);
                     }
                     else if (searchTask.remindDate <= DateTime.Now)
                         searchTask.remindDate = DateTime.MinValue;
                     search.tasks = TaskSort(search.tasks);
                     taskFound = true;
                     ((ObservableCollection<TaskMeMessage>)settings["MessageList"]).Insert(0,
                         new TaskMeMessage { type = "Task Updated", content = "Task " + searchTask.name + " in Project " + search.name + " was updated.", timeStamp = DateTime.Now });
                     break;
                 }
             }
             if (!taskFound)
             {
                 MyTask create = new MyTask();
                 create.projKey = contents[1];
                 create.name = contents[2];
                 create.description = contents[3];
                 create.taskKey = contents[4];
                 create.dueDate = DateTime.Parse(contents[5]);
                 if (DateTime.Parse(contents[6]) > DateTime.Now)
                     create.remindDate = DateTime.Parse(contents[6]);
                 else
                     create.remindDate = DateTime.MinValue;
                 create.isComplete = Convert.ToBoolean(contents[7]);
                 create.status = contents[8];
                 create.project = contents[9];
                 Person createP = new Person();
                 createP.name = contents[10];
                 createP.username = contents[11];
                 createP.hawaiiID = contents[12];
                 createP.reqSent = Convert.ToBoolean(contents[13]);
                 createP.accepted = Convert.ToBoolean(contents[14]);
                 create.assignedTo = createP;
                 search.tasks.Add(create);
                 search.tasks = TaskSort(search.tasks);
                 if (!create.remindDate.Equals(DateTime.MinValue) && create.assignedTo.hawaiiID == this.RelayContext.Endpoint.RegistrationId)
                 {
                     try
                     {
                         ScheduledActionService.Remove(create.taskKey);
                     }
                     catch (InvalidOperationException) { }
                     Reminder reminder = new Reminder(create.taskKey);
                     Uri navUri = new Uri("/TaskView.xaml?TaskKey=" + create.taskKey + "&ProjectKey=" + search.projKey, UriKind.RelativeOrAbsolute);
                     reminder.Title = create.name;
                     reminder.Content = create.description;
                     reminder.BeginTime = create.remindDate;
                     reminder.ExpirationTime = create.remindDate;
                     reminder.NavigationUri = navUri;
                     ScheduledActionService.Add(reminder);
                 }
                 ((ObservableCollection<TaskMeMessage>)settings["MessageList"]).Insert(0,
                         new TaskMeMessage { type = "Task Created", content = "Task " + create.name + " in Project " + search.name + " was created.", timeStamp = DateTime.Now });
             }
             break;
         }
     }
 }
Пример #2
0
 //Called when a task in the TLB is selected
 private void TaskListBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     //System.Diagnostics.Debug.WriteLine("Hit TLBSelectionChanged: " + TaskListBox.SelectedIndex);
     if (TaskListBox.SelectedIndex == -1) //-1 is the default position
         return;
     _selectedTask = (MyTask)TaskListBox.SelectedItem;
     //System.Diagnostics.Debug.WriteLine(_selectedTask.TaskKey);
     if (TaskListBox.ItemsSource == ((ObservableCollection<MyTask>)settings["DoneTaskList"]))
     {
         NavigationService.Navigate(new Uri("/TaskView.xaml?TaskKey=" + ((ObservableCollection<MyTask>)settings["DoneTaskList"]).IndexOf(_selectedTask)
             +"&Complete=1", UriKind.RelativeOrAbsolute)); //Navigate to TaskView
     }
     else
     {
         NavigationService.Navigate(new Uri("/TaskView.xaml?TaskKey=" + ((ObservableCollection<MyTask>)settings["TaskList"]).IndexOf(_selectedTask), UriKind.RelativeOrAbsolute)); //Navigate to TaskView
     }
     TaskListBox.SelectedIndex = -1;
 }
Пример #3
0
 private void ParseDoneTask(string from, string[] contents)
 {
     foreach (MyProject search in ((ObservableCollection<MyProject>)settings["ProjectList"]))
     {
         if (contents[1].Equals(search.projKey))
         {
             MyTask create = new MyTask();
             create.projKey = contents[1];
             create.name = contents[2];
             create.description = contents[3];
             create.taskKey = contents[4];
             create.dueDate = DateTime.Parse(contents[5]);
             if (DateTime.Parse(contents[6]) > DateTime.Now)
                 create.remindDate = DateTime.Parse(contents[6]);
             else
                 create.remindDate = DateTime.MinValue;
             create.isComplete = Convert.ToBoolean(contents[7]);
             create.status = contents[8];
             create.project = contents[9];
             Person createP = new Person();
             createP.name = contents[10];
             createP.username = contents[11];
             createP.hawaiiID = contents[12];
             createP.reqSent = Convert.ToBoolean(contents[13]);
             createP.accepted = Convert.ToBoolean(contents[14]);
             create.assignedTo = createP;
             search.doneTasks.Add(create);
             search.doneTasks = TaskSort(search.doneTasks);
             ((ObservableCollection<TaskMeMessage>)settings["MessageList"]).Insert(0,
                 new TaskMeMessage { type = "Task Created", content = "Completed task " + create.name + " in Project " + search.name + " was created.", timeStamp = DateTime.Now });
             break;
         }
     }
 }
Пример #4
0
 private int TaskCmp(MyTask a, MyTask b)
 {
     if (a.dueDate.Equals(b.dueDate))
         return a.name.CompareTo(b.name);
     return a.dueDate.CompareTo(b.dueDate);
 }
Пример #5
0
        //fires whenever page is navigated to
        protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
        {
            if (NavigationContext.QueryString.TryGetValue("Edit", out selectedKeyString)) //checks for a task edit index
            {
                selectedKey = int.Parse(selectedKeyString);
                PageTitle.Text = "edit task";
            }
            if (NavigationContext.QueryString.TryGetValue("Project", out selectedProjectString)) //checks for a project index
            {
                selectedProject = int.Parse(selectedProjectString);
            }
            if (selectedKey == -1 && selectedProject == -1 && !loaded) //first load, and we're creating a new task with no project
            {
                DueCanvas.Visibility = System.Windows.Visibility.Collapsed;
                RemindCanvas.Visibility = System.Windows.Visibility.Collapsed;
                AssignPicker.Visibility = System.Windows.Visibility.Collapsed;
                AssignToSwitch.Visibility = System.Windows.Visibility.Collapsed;
                TaskPanel.Height = 404;
                loaded = true;
            }
            else if (selectedKey != -1 && selectedProject == -1) //editing a standalone task
            {
                currentTask = ((MyTask)((ObservableCollection<MyTask>)settings["TaskList"])[selectedKey]);
                DataContext = currentTask; //set the data context

                if (currentTask.dueDate == DateTime.MinValue) //hide or show the due section
                {
                    DueCanvas.Visibility = System.Windows.Visibility.Collapsed;
                }
                else
                {
                    DueSwitch.IsChecked = true;
                    TaskPanel.Height += 100;
                }

                if (currentTask.remindDate == DateTime.MinValue) //hide or show the remind section
                {
                    RemindCanvas.Visibility = System.Windows.Visibility.Collapsed;
                }
                else
                {
                    RemindSwitch.IsChecked = true;
                    TaskPanel.Height += 100;
                }
                AssignToSwitch.Visibility = System.Windows.Visibility.Collapsed;
                AssignPicker.Visibility = System.Windows.Visibility.Collapsed;
            }
            else if (selectedKey == -1 && selectedProject != -1 && !loaded) //create a new task with an associated project
            {
                DueCanvas.Visibility = System.Windows.Visibility.Collapsed;
                RemindCanvas.Visibility = System.Windows.Visibility.Collapsed;
                if (((ObservableCollection<Person>)settings["ContactsList"]).Count != 0)
                {
                    AssignToSwitch.Visibility = System.Windows.Visibility.Visible;
                    TaskPanel.Height += 111;
                    AssignPicker.Visibility = System.Windows.Visibility.Collapsed;
                    AssignPicker.ItemsSource = ((ObservableCollection<Person>)settings["ContactsList"]);
                }
                else
                {
                    AssignToSwitch.Visibility = System.Windows.Visibility.Collapsed;
                    AssignPicker.Visibility = System.Windows.Visibility.Collapsed;
                }
                loaded = true;
            }
            else if (selectedKey != -1 && selectedProject != -1) //editing a task with an associated project
            {
                currentProject = ((MyProject)((ObservableCollection<MyProject>)settings["ProjectList"])[selectedProject]);
                DataContext = currentProject.tasks[selectedKey]; //set datacontext
                if (currentProject.tasks[selectedKey].dueDate == DateTime.MinValue) //hide or show due picker
                {
                    DueCanvas.Visibility = System.Windows.Visibility.Collapsed;
                }
                else
                {
                    DueSwitch.IsChecked = true;
                    TaskPanel.Height += 100;
                }

                if (currentProject.tasks[selectedKey].remindDate == DateTime.MinValue) //hide or show remind picker
                {
                    RemindCanvas.Visibility = System.Windows.Visibility.Collapsed;
                }
                else
                {
                    RemindSwitch.IsChecked = true;
                    TaskPanel.Height += 100;
                }

                AssignToSwitch.Visibility = System.Windows.Visibility.Collapsed;
                AssignPicker.Visibility = System.Windows.Visibility.Collapsed;
            }
        }
Пример #6
0
        //standalone task
        private void SaveNewTask()
        {
            MyTask newTask = new MyTask();
            newTask.name = NameTextBox.Text;
            newTask.description = DescTextBox.Text;
            String taskKey = System.Guid.NewGuid().ToString(); //sets key to guid for ease of reminder creation
            newTask.taskKey = taskKey;

            if ((bool)DueSwitch.IsChecked) //sets due date
            {
                var dueDate = (DateTime)DueDatePicker.Value;
                var dueTime = (DateTime)DueTimePicker.Value;
                newTask.dueDate = new DateTime(dueDate.Year, dueDate.Month, dueDate.Day, dueTime.Hour, dueTime.Minute, dueTime.Second);
            }
            else
                newTask.dueDate = DateTime.MinValue;

            if ((bool)RemindSwitch.IsChecked) //sets remind date
            {
                var remindDate = (DateTime)ReminderDatePicker.Value;
                var remindTime = (DateTime)ReminderTimePicker.Value;
                newTask.remindDate = new DateTime(remindDate.Year, remindDate.Month, remindDate.Day, remindTime.Hour, remindTime.Minute, remindTime.Second);
            }
            else
                newTask.remindDate = DateTime.MinValue;

            newTask.isComplete = false;
            newTask.status = "Incomplete";
            newTask.projKey = "";
            newTask.project = "";
            ((ObservableCollection<MyTask>)settings["TaskList"]).Add(newTask);

            settings["TaskList"] = TaskSort(((ObservableCollection<MyTask>)settings["TaskList"]));

            if ((bool)RemindSwitch.IsChecked) //creates reminder in the system. Has to go after adding the new task because we need to set a navigation uri.
            {
                Reminder reminder = new Reminder(taskKey);
                Uri navUri = new Uri("/TaskView.xaml?TaskKey=" + ((ObservableCollection<MyTask>)settings["TaskList"]).IndexOf(newTask), UriKind.RelativeOrAbsolute);
                reminder.Title = newTask.name;
                reminder.Content = newTask.description;
                reminder.BeginTime = newTask.remindDate;
                reminder.ExpirationTime = newTask.remindDate;
                reminder.NavigationUri = navUri;
                ScheduledActionService.Add(reminder);
            }
            NavigationService.GoBack();
        }
Пример #7
0
        //adds a new project-associated task
        private void ProjectTask()
        {
            MyTask newTask = new MyTask();
            newTask.name = NameTextBox.Text;
            newTask.description = DescTextBox.Text;
            String taskKey = System.Guid.NewGuid().ToString();
            newTask.taskKey = taskKey;

            if ((bool)DueSwitch.IsChecked) //sets due date
            {
                var dueDate = (DateTime)DueDatePicker.Value;
                var dueTime = (DateTime)DueTimePicker.Value;
                newTask.dueDate = new DateTime(dueDate.Year, dueDate.Month, dueDate.Day, dueTime.Hour, dueTime.Minute, dueTime.Second);
            }
            else
                newTask.dueDate = DateTime.MinValue;

            if ((bool)RemindSwitch.IsChecked) //sets remind date
            {
                var remindDate = (DateTime)ReminderDatePicker.Value;
                var remindTime = (DateTime)ReminderTimePicker.Value;
                newTask.remindDate = new DateTime(remindDate.Year, remindDate.Month, remindDate.Day, remindTime.Hour, remindTime.Minute, remindTime.Second);
            }
            else
                newTask.remindDate = DateTime.MinValue;

            newTask.isComplete = false;
            newTask.status = "Incomplete";
            if ((bool)AssignToSwitch.IsChecked)
            {
                newTask.assignedTo = (Person)AssignPicker.SelectedItem;
                if (((Person)AssignPicker.SelectedItem).hawaiiID != this.RelayContext.Endpoint.RegistrationId)
                    (((MyProject)((ObservableCollection<MyProject>)settings["ProjectList"])[selectedProject])).addRecipient(((Person)AssignPicker.SelectedItem).hawaiiID);
            }
            else
                newTask.assignedTo = ((ObservableCollection<Person>)settings["ContactsList"])[0];

            newTask.projKey = ((MyProject)((ObservableCollection<MyProject>)settings["ProjectList"])[selectedProject]).projKey;
            newTask.project = ((MyProject)((ObservableCollection<MyProject>)settings["ProjectList"])[selectedProject]).name;

            if ((bool)RemindSwitch.IsChecked && newTask.assignedTo.hawaiiID == this.RelayContext.Endpoint.RegistrationId) //adds reminder in system
            {
                Reminder reminder = new Reminder(taskKey);
                Uri navUri = new Uri("/TaskView.xaml?TaskKey=" + ((ObservableCollection<MyProject>)settings["ProjectList"])[selectedProject].tasks.IndexOf(newTask) + "&ProjectKey=" + selectedProject, UriKind.RelativeOrAbsolute);
                reminder.Title = newTask.name;
                reminder.Content = newTask.description;
                reminder.BeginTime = newTask.remindDate;
                reminder.ExpirationTime = newTask.remindDate;
                reminder.NavigationUri = navUri;
                ScheduledActionService.Add(reminder);
            }

            MyProject testProj = ((MyProject)((ObservableCollection<MyProject>)settings["ProjectList"])[selectedProject]); //possibly implement this for all
            if (string.IsNullOrEmpty(testProj.recipients))
            {
                (((MyProject)((ObservableCollection<MyProject>)settings["ProjectList"])[selectedProject]).tasks).Add(newTask);
                ((MyProject)((ObservableCollection<MyProject>)settings["ProjectList"])[selectedProject]).tasks = TaskSort(
                    ((MyProject)((ObservableCollection<MyProject>)settings["ProjectList"])[selectedProject]).tasks);
                NavigationService.GoBack();
            }
            else
            {
                byte[] message = ((MyProject)((ObservableCollection<MyProject>)settings["ProjectList"])[selectedProject]).Serialize();
                //System.Diagnostics.Debug.WriteLine(((Person)AssignPicker.SelectedItem).hawaiiID + " " + ((MyProject)((ObservableCollection<MyProject>)settings["ProjectList"])[selectedProject]).recipients);

                sendTask = newTask;

                RelayService.SendMessageAsync(
                    HawaiiClient.HawaiiApplicationId,
                    this.RelayContext.Endpoint,
                    (((MyProject)((ObservableCollection<MyProject>)settings["ProjectList"])[selectedProject])).creator.hawaiiID + ","
                        + (((MyProject)((ObservableCollection<MyProject>)settings["ProjectList"])[selectedProject])).recipients,
                    message, this.OnCompleteSendProject);
            }
        }
Пример #8
0
        //edit a project-associated task
        private void EditProjectTask()
        {
            editTask = new MyTask
            {
                name = NameTextBox.Text,
                description = DescTextBox.Text,
                assignedTo = (((MyProject)((ObservableCollection<MyProject>)settings["ProjectList"])[selectedProject]).tasks[selectedKey]).assignedTo,
                isComplete = (((MyProject)((ObservableCollection<MyProject>)settings["ProjectList"])[selectedProject]).tasks[selectedKey]).isComplete,
                project = (((MyProject)((ObservableCollection<MyProject>)settings["ProjectList"])[selectedProject]).tasks[selectedKey]).project,
                projKey = (((MyProject)((ObservableCollection<MyProject>)settings["ProjectList"])[selectedProject]).tasks[selectedKey]).projKey,
                status = (((MyProject)((ObservableCollection<MyProject>)settings["ProjectList"])[selectedProject]).tasks[selectedKey]).status,
                taskKey = (((MyProject)((ObservableCollection<MyProject>)settings["ProjectList"])[selectedProject]).tasks[selectedKey]).taskKey
            };
            if ((bool)DueSwitch.IsChecked) //change duedate
            {
                var dueDate = (DateTime)DueDatePicker.Value;
                var dueTime = (DateTime)DueTimePicker.Value;
                editTask.dueDate = new DateTime(dueDate.Year, dueDate.Month, dueDate.Day, dueDate.Hour, dueDate.Minute, dueDate.Second);
            }
            else
                editTask.dueDate = DateTime.MinValue;

            if ((bool)RemindSwitch.IsChecked) //change remind date
            {
                var remindDate = (DateTime)ReminderDatePicker.Value;
                var remindTime = (DateTime)ReminderTimePicker.Value;
                editTask.remindDate = new DateTime(remindDate.Year, remindDate.Month, remindDate.Day, remindTime.Hour, remindTime.Minute, remindTime.Second);
            }
            else
                editTask.remindDate = DateTime.MinValue;

            byte[] message = editTask.Serialize();
            RelayService.SendMessageAsync(
                HawaiiClient.HawaiiApplicationId,
                this.RelayContext.Endpoint,
                (((MyProject)((ObservableCollection<MyProject>)settings["ProjectList"])[selectedProject])).creator.hawaiiID + ","
                 + (((MyProject)((ObservableCollection<MyProject>)settings["ProjectList"])[selectedProject])).recipients,
                message, this.OnCompleteSendEditTask);
        }