Example #1
0
        public static void NewNote(string listId, string taskSeriesId, string taskId, string note)
        {
            string[] parts = null;
            string   note_title;
            string   note_body;
            bool     has_separator = (0 < note.IndexOf("|") && note.IndexOf("|") < note.Length);
            bool     has_newline   = (0 < note.IndexOf("\n") && note.IndexOf("\n") < note.Length);
            bool     newline_first = note.IndexOf("\n") < note.IndexOf("|");

            if ((has_newline && has_separator && newline_first) || (has_newline && !has_separator))
            {
                parts = note.Split(new char[] { '\n' }, 2);
            }
            else if (has_separator)
            {
                parts = note.Split(new char[] { '|' }, 2);
            }

            if (string.IsNullOrEmpty(note) || ((has_separator || has_newline) && parts != null && parts.Length < 2))
            {
                Log <RTM> .Debug("Entered text cannot be used as a note.");

                return;
            }
            else
            {
                note_title = (has_separator || has_newline) ? parts[0].Trim() : "Untitled Note";
                note_body  = (has_separator || has_newline) ? parts[1].Trim() : note;
            }

            try {
                rtm.NotesAdd(timeline, listId, taskSeriesId, taskId, note_title, note_body);
            } catch (RtmException e) {
                Log <RTM> .Debug(e.Message);

                return;
            }

            FinalizeAction(AddinManager.CurrentLocalizer.GetString("Note Added"),
                           AddinManager.CurrentLocalizer.GetString("A note has been added to the selected task"));
        }
Example #2
0
        public RtmNote CreateNote(RtmTask rtmTask, string text)
        {
            RtmNet.Note note    = null;
            RtmNote     rtmNote = null;

            if (rtm != null)
            {
                try {
                    note    = rtm.NotesAdd(timeline, rtmTask.ListID, rtmTask.SeriesTaskID, rtmTask.TaskTaskID, String.Empty, text);
                    rtmNote = new RtmNote(note);
                } catch (Exception e) {
                    Logger.Debug("RtmBackend.CreateNote: Unable to create a new note");
                    Logger.Debug(e.ToString());
                }
            }
            else
            {
                throw new Exception("Unable to communicate with Remember The Milk");
            }

            return(rtmNote);
        }