示例#1
0
        public void SendVoiceMessageCollection_RestClientReturnsNull_ReturnsNull()
        {
            // Arrange
            VoiceMessage           message  = new VoiceMessage("recipients", "body", "accountReference");
            VoiceMessageCollection messages = new VoiceMessageCollection(message);

            string serialisedMessage = "serialisedMessage";

            RestResource resource = new MessageDispatcherResource(serialisedMessage, false);

            RestResponse response = null;

            mockSerialiser
            .Setup(s => s.Serialise(messages))
            .Returns(serialisedMessage);

            mockRestClient
            .Setup(rc => rc.Post(resource))
            .Returns(response);

            // Act
            MessagingResult actualResult = service.SendMessages(messages);

            // Assert
            Assert.IsNull(actualResult);
        }
示例#2
0
            public static MessagingResult SendPushMessage(string serverKey, string token, Object pushData, string senderId)
            {
                MessagingResult result = new MessagingResult {
                    Successful = true, Error = null
                };

                try
                {
                    WebRequest webRequest = WebRequest.Create(Config.requestUri);
                    webRequest.Method = "POST";
                    webRequest.Headers.Add(string.Format("Authorization: key={0}", serverKey));
                    webRequest.Headers.Add(string.Format("Sender: id={0}", senderId));
                    webRequest.ContentType = "application/json";

                    var modelName = Dynamic.GetPropValue(pushData, "ModelName").ToString();
                    var path      = Dynamic.GetFullyQualifiedPath(modelName);


                    var fcmdata = new
                    {
                        to       = token,
                        priority = "high",
                        data     = pushData
                    };

                    var    serializer = new JavaScriptSerializer();
                    var    json       = serializer.Serialize(fcmdata);
                    Byte[] byteArray  = Encoding.UTF8.GetBytes(json);
                    webRequest.ContentLength = byteArray.Length;
                    using (Stream dataStream = webRequest.GetRequestStream())
                    {
                        dataStream.Write(byteArray, 0, byteArray.Length);
                        using (WebResponse webResponse = webRequest.GetResponse())
                        {
                            using (Stream dataStreamResponse = webResponse.GetResponseStream())
                            {
                                using (StreamReader tReader = new StreamReader(dataStreamResponse))
                                {
                                    String sResponseFromServer = tReader.ReadToEnd();
                                    result.Response = sResponseFromServer;

                                    //var dynamicModel = Dynamic.GetInstance("BDCO.Domain.Aggregates.Push.PushData");
                                    var dynamicModel = Dynamic.GetInstance(path);
                                    Tools.CopyClass(dynamicModel, pushData);
                                    UnitOfWork unitOfWork = new UnitOfWork();
                                    Dynamic.DynamicRepo(dynamicModel, unitOfWork.context, DBOperations.INSERT);
                                    unitOfWork.SaveChange();
                                }
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    result.Successful = false;
                    result.Response   = null;
                    result.Error      = ex;
                }
                return(result);
            }
示例#3
0
 private void OnCompleteSendDelete(MessagingResult result)
 {
     if (result.Status == Status.Success)
     {
         this.Dispatcher.BeginInvoke(
             delegate
         {
             foreach (MyTask searchTask in ((MyProject)((ObservableCollection <MyProject>)settings["ProjectList"])[selectedProject]).tasks)
             {
                 try
                 {
                     ScheduledActionService.Remove(searchTask.taskKey);
                 }
                 catch (InvalidOperationException) { }
             }
             ((ObservableCollection <MyProject>)settings["ProjectList"]).RemoveAt(selectedProject);
             NavigationService.GoBack();
         });
     }
     else
     {
         this.Dispatcher.BeginInvoke(
             delegate
         {
             ((ApplicationBarIconButton)ApplicationBar.Buttons[0]).IsEnabled = true;
             ((ApplicationBarIconButton)ApplicationBar.Buttons[1]).IsEnabled = true;
             ((ApplicationBarIconButton)ApplicationBar.Buttons[2]).IsEnabled = true;
             ProgressBar.IsVisible = false;
         });
         this.DisplayMessage("Operation failed. Check your wifi/cellular connection.", "Error");
     }
 }
示例#4
0
 private void OnCompleteSendIncomplete(MessagingResult result)
 {
     if (result.Status == Status.Success)
     {
         this.Dispatcher.BeginInvoke(
             delegate
         {
             ((MyProject)((ObservableCollection <MyProject>)settings["DoneProjectList"])[selectedProject]).isComplete = false;
             ((MyProject)((ObservableCollection <MyProject>)settings["DoneProjectList"])[selectedProject]).status     = "Incomplete";
             foreach (MyTask searchTask in ((MyProject)((ObservableCollection <MyProject>)settings["DoneProjectList"])[selectedProject]).tasks)
             {
                 if (searchTask.remindDate != DateTime.MinValue && searchTask.remindDate > DateTime.Now)
                 {
                     try
                     {
                         ScheduledActionService.Remove(searchTask.taskKey);
                     }
                     catch (InvalidOperationException) { }
                     Reminder reminder = new Reminder(searchTask.taskKey);
                     Uri navUri        = new Uri("/TaskView.xaml?TaskKey=" + searchTask.taskKey + "&ProjectKey=" +
                                                 ((MyProject)((ObservableCollection <MyProject>)settings["DoneProjectList"])[selectedProject]).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;
                 }
             }
             ((ObservableCollection <MyProject>)settings["ProjectList"]).Add(((MyProject)((ObservableCollection <MyProject>)settings["DoneProjectList"])[selectedProject]));
             settings["ProjectList"] = ProjectSort(((ObservableCollection <MyProject>)settings["ProjectList"]));
             ((ObservableCollection <MyProject>)settings["DoneProjectList"]).Remove(((MyProject)((ObservableCollection <MyProject>)settings["DoneProjectList"])[selectedProject]));
             NavigationService.GoBack();
         });
     }
     else
     {
         this.Dispatcher.BeginInvoke(
             delegate
         {
             ((ApplicationBarIconButton)ApplicationBar.Buttons[0]).IsEnabled = true;
             ((ApplicationBarIconButton)ApplicationBar.Buttons[1]).IsEnabled = true;
             ((ApplicationBarIconButton)ApplicationBar.Buttons[2]).IsEnabled = true;
             ProgressBar.IsVisible = false;
         });
         this.DisplayMessage("Operation failed. Check your wifi/cellular connection.", "Error");
     }
 }
示例#5
0
 private void OnCompleteSendTask(MessagingResult result)
 {
     if (result.Status == Status.Success)
     {
     }
     else
     {
         this.Dispatcher.BeginInvoke(
             delegate
         {
             ProgressBar.IsVisible = false;
             UnlockUI();
         });
         this.DisplayMessage("Task was unable to be assigned. Check your wifi/cellular connection.", "Error");
     }
 }
示例#6
0
        public void SendScheduledMessages_WithVoiceMessage_ReturnsBatchIdResult()
        {
            // Arrange
            DateTime timestamp = DateTime.UtcNow;

            VoiceMessage           message  = new VoiceMessage("recipients", "body", "accountReference");
            VoiceMessageCollection messages = new VoiceMessageCollection(message)
            {
                SendAt = timestamp
            };

            string serialisedMessage = "serialisedMessage";

            RestResource resource = new MessageDispatcherResource(serialisedMessage, false);

            RestResponse response = new RestResponse()
            {
                StatusCode = HttpStatusCode.OK,
                Content    = "serialisedResponse"
            };

            MessagingResult expectedResult = new MessagingResult()
            {
                BatchId    = Guid.NewGuid(),
                MessageIds = new List <ResourceLink>()
            };

            mockSerialiser
            .Setup(s => s.Serialise(messages))
            .Returns(serialisedMessage);

            mockRestClient
            .Setup(rc => rc.Post(resource))
            .Returns(response);

            mockSerialiser
            .Setup(s => s.Deserialise <MessagingResult>(response.Content))
            .Returns(expectedResult);

            // Act
            MessagingResult actualResult = service.SendScheduledMessages(messages, timestamp);

            // Assert
            Assert.IsNotNull(actualResult);
            Assert.AreEqual(expectedResult.BatchId, actualResult.BatchId);
            Assert.AreEqual(0, actualResult.MessageIds.Count());
        }
示例#7
0
 private void OnCompleteSendProject(MessagingResult result)
 {
     if (result.Status == Status.Success)
     {
         this.Dispatcher.BeginInvoke(
             delegate
         {
             (((MyProject)((ObservableCollection <MyProject>)settings["ProjectList"])[selectedProject]).tasks).Add(sendTask);
             ((MyProject)((ObservableCollection <MyProject>)settings["ProjectList"])[selectedProject]).tasks = TaskSort(
                 ((MyProject)((ObservableCollection <MyProject>)settings["ProjectList"])[selectedProject]).tasks);
             foreach (MyTask send in (((MyProject)((ObservableCollection <MyProject>)settings["ProjectList"])[selectedProject])).tasks)
             {
                 byte[] message = send.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.OnCompleteSendTask);
             }
             foreach (MyTask send in (((MyProject)((ObservableCollection <MyProject>)settings["ProjectList"])[selectedProject])).doneTasks)
             {
                 byte[] message = send.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.OnCompleteSendTask);
             }
             NavigationService.GoBack();
         });
         //this.DisplayMessage("Sending message to group(s) succeeded.", "Info");
     }
     else
     {
         this.Dispatcher.BeginInvoke(
             delegate
         {
             ProgressBar.IsVisible = false;
             UnlockUI();
         });
         this.DisplayMessage("Task was unable to be assigned. Check your wifi/cellular connection.", "Error");
     }
 }
示例#8
0
 private void SendProject(Endpoint from, string recipients)
 {
     if (!String.IsNullOrEmpty(recipients))
     {
         byte[] message = editProj.Serialize();
         RelayService.SendMessageAsync(
             HawaiiClient.HawaiiApplicationId,
             from,
             recipients,
             message,
             this.OnCompleteSendMessage);
     }
     else
     {
         MessagingResult ret = new MessagingResult();
         ret.Status = Status.Success;
         OnCompleteSendMessage(ret);
     }
 }
示例#9
0
        private void OnCompleteSendMessage(MessagingResult result)
        {
            if (result.Status == Status.Success)
            {
                //this.DisplayMessage("Update succeeded.", "Info");
                this.Dispatcher.BeginInvoke(
                    delegate
                {
                    ((ObservableCollection <MyProject>)settings["ProjectList"])[selectedProject].name        = NameTextBox.Text;
                    ((ObservableCollection <MyProject>)settings["ProjectList"])[selectedProject].description = DescTextBox.Text;
                    if ((bool)DueSwitch.IsChecked)     //changing due date
                    {
                        var dueDate = (DateTime)DueDatePicker.Value;
                        var dueTime = (DateTime)DueTimePicker.Value;
                        ((ObservableCollection <MyProject>)settings["ProjectList"])[selectedProject].dueDate = (new DateTime(dueDate.Year, dueDate.Month, dueDate.Day, dueTime.Hour, dueTime.Minute, dueTime.Second));
                    }
                    else     //else get rid of the due date
                    {
                        ((ObservableCollection <MyProject>)settings["ProjectList"])[selectedProject].dueDate = DateTime.MinValue;
                    }

                    settings["ProjectList"] = ProjectSort((ObservableCollection <MyProject>)settings["ProjectList"]);

                    NavigationService.GoBack();
                });
            }
            else
            {
                this.Dispatcher.BeginInvoke(
                    delegate
                {
                    ((ApplicationBarIconButton)ApplicationBar.Buttons[0]).IsEnabled = true;
                    ProgressBar.IsVisible   = false;
                    NameTextBox.IsEnabled   = true;
                    DescTextBox.IsEnabled   = true;
                    DueSwitch.IsEnabled     = true;
                    DueDatePicker.IsEnabled = true;
                    DueTimePicker.IsEnabled = true;
                });
                this.DisplayMessage("Project edit failed. Check your wifi/cellular connection.", "Error");
            }
        }
示例#10
0
        private void OnCompleteSendAccept(MessagingResult result)
        {
            Debug.Assert(result != null, "result is null");

            if (result.Status == Status.Success)
            {
                //this.DisplayMessage("Contact request succeeded.", "Info");
                this.Dispatcher.BeginInvoke(
                    delegate
                {
                    ((ObservableCollection <Person>)settings["ContactsList"]).Add(new Person {
                        name = NameBox.Text, username = UsernameBox.Text, hawaiiID = acceptIDString, reqSent = true, accepted = true
                    });
                    ((ObservableCollection <Person>)settings["ContactsList"]).RemoveAt(0);
                    settings["ContactsList"] = ContactSort(((ObservableCollection <Person>)settings["ContactsList"]));
                    ((ObservableCollection <Person>)settings["ContactsList"]).Insert(0,
                                                                                     new Person {
                        name = "Me", username = (string)settings["MyUsername"], hawaiiID = this.RelayContext.Endpoint.RegistrationId, accepted = true, reqSent = true
                    });

                    Person reqPerson = ((ObservableCollection <Person>)settings["RequestList"]).Where(X => X.hawaiiID == acceptIDString).FirstOrDefault();
                    if (reqPerson != null)
                    {
                        System.Diagnostics.Debug.WriteLine("Removing " + reqPerson.username + " from request list.");
                        ((ObservableCollection <Person>)settings["RequestList"]).Remove(reqPerson);
                    }
                    NavigationService.GoBack();
                });
            }
            else
            {
                this.Dispatcher.BeginInvoke(
                    delegate
                {
                    ((ApplicationBarIconButton)ApplicationBar.Buttons[0]).IsEnabled = true;
                    ProgressBar.IsVisible = false;
                    NameBox.IsEnabled     = true;
                    UsernameBox.IsEnabled = true;
                });
                this.DisplayMessage("Accept failed. Check your wifi/cellular connection.", "Error");
            }
        }
示例#11
0
        public void SendMessage_WithSmsMessage_ReturnsBatchIdResult()
        {
            // Arrange
            var message  = new SmsMessage("recipients", "body", "accountReference");
            var messages = new SmsMessageCollection(message);

            var serialisedMessage = "serialisedMessage";

            RestResource resource = new MessageDispatcherResource(serialisedMessage, false);

            var response = new RestResponse
            {
                StatusCode = HttpStatusCode.OK,
                Content    = "serialisedResponse"
            };

            var expectedResult = new MessagingResult
            {
                BatchId    = Guid.NewGuid(),
                MessageIds = new List <ResourceLink>()
            };

            mockSerialiser
            .Setup(s => s.Serialise(messages))
            .Returns(serialisedMessage);

            mockRestClient
            .Setup(rc => rc.Post(resource))
            .Returns(response);

            mockSerialiser
            .Setup(s => s.Deserialise <MessagingResult>(response.Content))
            .Returns(expectedResult);

            // Act
            var actualResult = service.SendMessage(message);

            // Assert
            Assert.IsNotNull(actualResult);
            Assert.AreEqual(expectedResult.BatchId, actualResult.BatchId);
            Assert.AreEqual(0, actualResult.MessageIds.Count());
        }
示例#12
0
 private void OnCompleteSendMessage(MessagingResult result)
 {
     if (result.Status == Status.Success)
     {
         this.Dispatcher.BeginInvoke(
             delegate
         {
             foreach (MyProject search in ((ObservableCollection <MyProject>)settings["ProjectList"]))
             {
                 if (search.creator.hawaiiID.Equals(((Person)((ObservableCollection <Person>)settings["ContactsList"])[selectedContact]).hawaiiID))
                 {
                     foreach (MyTask searchTask in search.tasks)
                     {
                         try
                         {
                             ScheduledActionService.Remove(searchTask.taskKey);
                         }
                         catch (InvalidOperationException) { }
                     }
                     ((ObservableCollection <MyProject>)settings["ProjectList"]).Remove(search);
                 }
             }
             Person remove = ((ObservableCollection <Person>)settings["ContactsList"]).Where(X => X.hawaiiID == ((Person)((ObservableCollection <Person>)settings["ContactsList"])[selectedContact]).hawaiiID).FirstOrDefault();
             if (remove == null)
             {
                 System.Diagnostics.Debug.WriteLine("Remove was 0.");
             }
             ((ObservableCollection <Person>)settings["ContactsList"]).Remove(remove);
             NavigationService.GoBack();
         });
     }
     else
     {
         this.Dispatcher.BeginInvoke(
             delegate
         {
             ((ApplicationBarIconButton)ApplicationBar.Buttons[0]).IsEnabled = true;
             ((ApplicationBarIconButton)ApplicationBar.Buttons[1]).IsEnabled = true;
             ProgressBar.IsVisible = false;
         });
     }
 }
示例#13
0
        private static void SendMessageExample()
        {
            SmsMessage message = new SmsMessage("07000000000", "This is a test...", accountReference);

            MessagingService messagingService = new MessagingService(true, Credentials);

            try
            {
                MessagingResult messageResult = messagingService.SendMessage(message);

                Console.WriteLine("Message Batch Id: {0}", messageResult.BatchId);

                foreach (ResourceLink messageId in messageResult.MessageIds)
                {
                    Console.WriteLine("Message Uri: {0}", messageId.Uri);
                }
            }
            catch (WebException ex)
            {
                Console.Write(ex.Message);
            }
        }
示例#14
0
        private void OnCompleteSendMessage(MessagingResult result)
        {
            Debug.Assert(result != null, "result is null");

            if (result.Status == Status.Success)
            {
                //this.DisplayMessage("Contact request succeeded.", "Info");
                this.AddContact();
            }
            else
            {
                this.Dispatcher.BeginInvoke(
                    delegate
                {
                    ((ApplicationBarIconButton)ApplicationBar.Buttons[0]).IsEnabled = true;
                    ProgressBar.IsVisible = false;
                    NameBox.IsEnabled     = true;
                    UsernameBox.IsEnabled = true;
                });
                this.DisplayMessage("Contact request failed. Check your wifi/cellular connection.", "Error");
            }
        }
示例#15
0
        public static Dictionary <object, object> Send(Dictionary <object, object> requestParams)
        {
            // TODO: get credentials from config settings
            EsendexCredentials credentials = new EsendexCredentials("*****@*****.**", "XAvHA7Tdf433");

            // TODO: get accountReference EX0111208 from config settings
            SmsMessage message = new SmsMessage((string)requestParams["Phone"], (string)requestParams["Text"], "EX0111208");

            MessagingService messagingService = new MessagingService(true, credentials);

            try
            {
                MessagingResult result = messagingService.SendMessage(message);

                /*Console.WriteLine("Sent Message Batch Id: {0}", result.BatchId);
                 *
                 * foreach (ResourceLink messageId in result.MessageIds)
                 * {
                 *  Console.WriteLine("Message Uri: {0}", messageId.Uri);
                 * }*/

                return(new Dictionary <object, object>()
                {
                    { "RESULT", ESMSGatewayResult.OK },
                    { "ERROR", string.Empty },
                    { "ERRORMESSAGE", string.Empty }
                });
            }
            catch (WebException ex)
            {
                return(new Dictionary <object, object>()
                {
                    { "RESULT", ESMSGatewayResult.ERROR },
                    { "ERROR", "ERROR" },
                    { "ERRORMESSAGE", ex.Message }
                });
            }
        }
示例#16
0
        private void OnCompleteSendEditTask(MessagingResult result)
        {
            if (result.Status == Status.Success)
            {
                this.Dispatcher.BeginInvoke(
                    delegate
                {
                    (((MyProject)((ObservableCollection <MyProject>)settings["ProjectList"])[selectedProject]).tasks[selectedKey]).name        = NameTextBox.Text;
                    (((MyProject)((ObservableCollection <MyProject>)settings["ProjectList"])[selectedProject]).tasks[selectedKey]).description = DescTextBox.Text;

                    if ((bool)DueSwitch.IsChecked)     //change duedate
                    {
                        var dueDate = (DateTime)DueDatePicker.Value;
                        var dueTime = (DateTime)DueTimePicker.Value;
                        (((MyProject)((ObservableCollection <MyProject>)settings["ProjectList"])[selectedProject]).tasks[selectedKey]).dueDate = new DateTime(dueDate.Year, dueDate.Month, dueDate.Day, dueDate.Hour, dueDate.Minute, dueDate.Second);
                    }
                    else
                    {
                        (((MyProject)((ObservableCollection <MyProject>)settings["ProjectList"])[selectedProject]).tasks[selectedKey]).dueDate = DateTime.MinValue;
                    }

                    if ((bool)RemindSwitch.IsChecked)     //change remind date and update reminder in system
                    {
                        var remindDate = (DateTime)ReminderDatePicker.Value;
                        var remindTime = (DateTime)ReminderTimePicker.Value;
                        (((MyProject)((ObservableCollection <MyProject>)settings["ProjectList"])[selectedProject]).tasks[selectedKey]).remindDate = new DateTime(remindDate.Year, remindDate.Month, remindDate.Day, remindTime.Hour, remindTime.Minute, remindTime.Second);
                        if (editTask.assignedTo.hawaiiID == this.RelayContext.Endpoint.RegistrationId)
                        {
                            try
                            {
                                ScheduledActionService.Remove((((MyProject)((ObservableCollection <MyProject>)settings["ProjectList"])[selectedProject]).tasks[selectedKey]).taskKey);
                            }
                            catch (InvalidOperationException) { }
                            Reminder reminder       = new Reminder((((MyProject)((ObservableCollection <MyProject>)settings["ProjectList"])[selectedProject]).tasks[selectedKey]).taskKey);
                            Uri navUri              = new Uri("/TaskView.xaml?TaskKey=" + selectedKey + "&ProjectKey=" + selectedProject, UriKind.RelativeOrAbsolute);
                            reminder.Title          = (((MyProject)((ObservableCollection <MyProject>)settings["ProjectList"])[selectedProject]).tasks[selectedKey]).name;
                            reminder.Content        = (((MyProject)((ObservableCollection <MyProject>)settings["ProjectList"])[selectedProject]).tasks[selectedKey]).description;
                            reminder.BeginTime      = (((MyProject)((ObservableCollection <MyProject>)settings["ProjectList"])[selectedProject]).tasks[selectedKey]).remindDate;
                            reminder.ExpirationTime = (((MyProject)((ObservableCollection <MyProject>)settings["ProjectList"])[selectedProject]).tasks[selectedKey]).remindDate;
                            reminder.NavigationUri  = navUri;
                            ScheduledActionService.Add(reminder);
                        }
                    }
                    else
                    {
                        (((MyProject)((ObservableCollection <MyProject>)settings["ProjectList"])[selectedProject]).tasks[selectedKey]).remindDate = DateTime.MinValue;
                    }

                    ((MyProject)((ObservableCollection <MyProject>)settings["ProjectList"])[selectedProject]).tasks = TaskSort(
                        ((MyProject)((ObservableCollection <MyProject>)settings["ProjectList"])[selectedProject]).tasks);

                    NavigationService.GoBack();
                });
            }
            else
            {
                ProgressBar.IsVisible = false;
                UnlockUI();
                this.DisplayMessage("Task was unable to be edited. Check your wifi/cellular connection.", "Error");
            }
        }
示例#17
0
 /// <summary>
 ///     Constructor.
 /// </summary>
 public MessagingResultBuilder()
 {
     _messagingResult = new MessagingResult {
         ApplicationMessageIds = new List <string>()
     };
 }
示例#18
0
        private void OnCompleteSendMessage(MessagingResult result)
        {
            if (result.Status == Status.Success)
            {
                this.Dispatcher.BeginInvoke(
                    delegate
                {
                    if (compdelete == 0)
                    {
                        try
                        {
                            ScheduledActionService.Remove(((MyProject)((ObservableCollection <MyProject>)settings["ProjectList"])[selectedProject]).tasks[selectedKey].taskKey);    //remove reminder if it exists
                        }
                        catch (InvalidOperationException) { }

                        ((MyTask)((MyProject)((ObservableCollection <MyProject>)settings["ProjectList"])[selectedProject]).tasks[selectedKey]).isComplete = true;       //mark as complete
                        ((MyTask)((MyProject)((ObservableCollection <MyProject>)settings["ProjectList"])[selectedProject]).tasks[selectedKey]).status     = "Complete"; //mark as complete
                        ((MyProject)((ObservableCollection <MyProject>)settings["ProjectList"])[selectedProject]).doneTasks.Add(currentTask);
                        ((MyProject)((ObservableCollection <MyProject>)settings["ProjectList"])[selectedProject]).doneTasks = TaskSort(
                            ((MyProject)((ObservableCollection <MyProject>)settings["ProjectList"])[selectedProject]).doneTasks);
                        ((MyProject)((ObservableCollection <MyProject>)settings["ProjectList"])[selectedProject]).tasks.Remove(currentTask);
                    }
                    else if (compdelete == 1)
                    {
                        try
                        {
                            ScheduledActionService.Remove(((MyProject)((ObservableCollection <MyProject>)settings["ProjectList"])[selectedProject]).tasks[selectedKey].taskKey);    //remove reminder if it exists
                        }
                        catch (InvalidOperationException) { }

                        ((MyProject)((ObservableCollection <MyProject>)settings["ProjectList"])[selectedProject]).tasks.RemoveAt(selectedKey);    //remove task
                    }
                    else if (compdelete == 2)
                    {
                        currentTask.isComplete = false;
                        currentTask.status     = "Incomplete";

                        if (currentTask.remindDate > DateTime.Now)
                        {
                            try
                            {
                                ScheduledActionService.Remove(currentTask.taskKey);
                            }
                            catch (InvalidOperationException) { }
                            Reminder reminder       = new Reminder(currentTask.taskKey);
                            Uri navUri              = new Uri("/TaskView.xaml?TaskKey=" + selectedKey + "&ProjectKey=" + selectedProject, UriKind.RelativeOrAbsolute);
                            reminder.Title          = currentTask.name;
                            reminder.Content        = currentTask.description;
                            reminder.BeginTime      = currentTask.remindDate;
                            reminder.ExpirationTime = currentTask.remindDate;
                            reminder.NavigationUri  = navUri;
                            ScheduledActionService.Add(reminder);
                        }
                        else
                        {
                            currentTask.remindDate = DateTime.MinValue;
                        }

                        currentProject.tasks.Add(currentTask);
                        currentProject.tasks = TaskSort(currentProject.tasks);
                        currentProject.doneTasks.Remove(currentTask);
                    }
                    NavigationService.GoBack();
                    //this.DisplayMessage("Accept succeeded.", "Info");
                });
            }
            else
            {
                this.Dispatcher.BeginInvoke(
                    delegate
                {
                    ((ApplicationBarIconButton)ApplicationBar.Buttons[0]).IsEnabled = true;
                    ((ApplicationBarIconButton)ApplicationBar.Buttons[1]).IsEnabled = true;
                    ((ApplicationBarIconButton)ApplicationBar.Buttons[2]).IsEnabled = true;
                    ProgressBar.IsVisible = false;
                });
                this.DisplayMessage("Operation failed. Check your wifi/cellular connection.", "Error");
            }
        }