Beispiel #1
0
        /// <summary>
        /// Constructor that is created from an RTM Task Series
        /// </summary>
        /// <param name="taskSeries">
        /// A <see cref="TaskSeries"/>
        /// </param>
        public RtmTask(TaskSeries taskSeries, RtmBackend be, string listID)
        {
            this.taskSeries = taskSeries;
            this.rtmBackend = be;
            this.category   = be.GetCategory(listID);

            if (CompletionDate == DateTime.MinValue)
            {
                state = TaskState.Active;
            }
            else
            {
                state = TaskState.Completed;
            }
            notes = new List <INote>();

            if (taskSeries.Notes.NoteCollection != null)
            {
                foreach (Note note in taskSeries.Notes.NoteCollection)
                {
                    RtmNote rtmNote = new RtmNote(note);
                    notes.Add(rtmNote);
                }
            }
        }
Beispiel #2
0
        private void OnAuthButtonClicked(object sender, EventArgs args)
        {
            RtmBackend rtmBackend = Application.Backend as RtmBackend;

            if (rtmBackend != null)
            {
                if (!isAuthorized && !authRequested)
                {
                    string url = string.Empty;
                    try {
                        url = rtmBackend.GetAuthUrl();
                    } catch (Exception) {
                        Logger.Debug("Failed to get auth URL from Remember the Milk. Try again later.");
                        authButton.Label = Catalog.GetString("Remember the Milk not responding. Try again later.");
                        return;
                    }
                    Logger.Debug("Launching browser to authorize with Remember the Milk");
                    try {
                        Application.Instance.NativeApplication.OpenUrl(url);
                        authRequested    = true;
                        authButton.Label = Catalog.GetString("Click Here After Authorizing");
                    } catch (Exception ex) {
                        Logger.Error("Exception opening URL: {0}", ex.Message);
                        authButton.Label = Catalog.GetString("Set the default browser and try again");
                    }
                }
                else if (!isAuthorized && authRequested)
                {
                    authButton.Label = Catalog.GetString("Processing...");
                    try {
                        rtmBackend.FinishedAuth();
                        Logger.Debug("Successfully authorized with Remember the Milk");
                        isAuthorized  = true;
                        authRequested = false;
                    } catch (RtmNet.RtmApiException) {
                        Logger.Debug("Failed to authorize with Remember the Milk");
                        isAuthorized     = false;
                        authRequested    = true;
                        authButton.Label = Catalog.GetString("Failed, Try Again");
                    }
                }
                if (isAuthorized)
                {
                    authButton.Label     = Catalog.GetString("Thank You");
                    authButton.Sensitive = false;
                    statusLabel.Text     = "\n\n" +
                                           Catalog.GetString("You are currently connected");
                    string userName =
                        Application.Preferences.Get(Preferences.UserNameKey);
                    if (userName != null && userName.Trim() != string.Empty)
                    {
                        statusLabel.Text = "\n\n" +
                                           Catalog.GetString("You are currently connected as") +
                                           "\n" + userName.Trim();
                    }
                }
            }
        }
Beispiel #3
0
        /// <summary>
        /// Constructor that is created from an RTM Task Series
        /// </summary>
        /// <param name="taskSeries">
        /// A <see cref="TaskSeries"/>
        /// </param>
        public RtmTask(TaskSeries taskSeries, RtmBackend be, string listID)
        {
            this.taskSeries = taskSeries;
            this.rtmBackend = be;
            this.category = be.GetCategory(listID);

            if(CompletionDate == DateTime.MinValue )
                state = TaskState.Active;
            else
                state = TaskState.Completed;
            notes = new List<INote>();

            if (taskSeries.Notes.NoteCollection != null) {
                foreach(Note note in taskSeries.Notes.NoteCollection) {
                    RtmNote rtmNote = new RtmNote(note);
                    notes.Add(rtmNote);
                }
            }
        }
Beispiel #4
0
        /// <summary>
        /// Constructor that is created from an RTM Task Series
        /// </summary>
        /// <param name="taskSeries">
        /// A <see cref="TaskSeries"/>
        /// </param>
        public RtmTask(TaskSeries taskSeries, RtmBackend be, string listId)
            : base(taskSeries.Name, TaskNoteSupport.Multiple)
        {
            ListID = listId;
            this.taskSeries = taskSeries;
            rtmBackend = be;
            DueDate = taskSeries.Task.Due;
            CompletionDate = taskSeries.Task.Completed;

            var priority = TaskPriority.None;
            switch (taskSeries.Task.Priority) {
            case "N":
                priority = TaskPriority.None;
                break;
            case "1":
                priority = TaskPriority.High;
                break;
            case "2":
                priority = TaskPriority.Medium;
                break;
            case "3":
                priority = TaskPriority.Low;
                break;
            }
            Priority = priority;

            if (taskSeries.Task.Completed == DateTime.MinValue)
                State = TaskState.Active;
            else
                State = TaskState.Completed;

            if (taskSeries.Notes.NoteCollection != null) {
                foreach (var note in taskSeries.Notes.NoteCollection) {
                    var rtmNote = new RtmNote (note);
                    AddNote (rtmNote);
                }
            }
        }