Ejemplo n.º 1
0
        private string CreateNoteChangesJsonString(IList <NoteInfo> noteUpdates, int?expectedNewRevision)
        {
            Hyena.Json.JsonObject noteChangesObj =
                new Hyena.Json.JsonObject();
            Hyena.Json.JsonArray noteChangesArray =
                new Hyena.Json.JsonArray();
            foreach (NoteInfo note in noteUpdates)
            {
                noteChangesArray.Add(note.ToUpdateObject());
            }
            noteChangesObj [NoteChangesElementName] = noteChangesArray;
            if (expectedNewRevision != null)
            {
                noteChangesObj [LatestSyncRevisionElementName] = expectedNewRevision;
            }

            // TODO: Handle errors
            Hyena.Json.Serializer serializer =
                new Hyena.Json.Serializer(noteChangesObj);
            // TODO: Log this for debugging?
            return(serializer.Serialize());
        }
Ejemplo n.º 2
0
        public Hyena.Json.JsonObject ToUpdateObject()
        {
            Hyena.Json.JsonObject noteUpdateObj =
                new Hyena.Json.JsonObject();

            if (string.IsNullOrEmpty(Guid))
            {
                throw new InvalidOperationException("Cannot create a valid JSON representation without a Guid");
            }

            noteUpdateObj [GuidElementName] = Guid;

            if (!string.IsNullOrEmpty(Command))
            {
                noteUpdateObj [CommandElementName] = Command;
                return(noteUpdateObj);
            }

            if (Title != null)
            {
                noteUpdateObj [TitleElementName] = Title;
            }
            if (NoteContent != null)
            {
                noteUpdateObj [NoteContentElementName] = NoteContent;
            }
            if (NoteContentVersion.HasValue)
            {
                noteUpdateObj [NoteContentVersionElementName] = NoteContentVersion.Value;
            }

            if (LastChangeDate.HasValue)
            {
                noteUpdateObj [LastChangeDateElementName] =
                    LastChangeDate.Value.ToString(NoteArchiver.DATE_TIME_FORMAT);
            }
            if (LastMetadataChangeDate.HasValue)
            {
                noteUpdateObj [LastMetadataChangeDateElementName] =
                    LastMetadataChangeDate.Value.ToString(NoteArchiver.DATE_TIME_FORMAT);
            }
            if (CreateDate.HasValue)
            {
                noteUpdateObj [CreateDateElementName] =
                    CreateDate.Value.ToString(NoteArchiver.DATE_TIME_FORMAT);
            }

            // TODO: Figure out what we do on client side for this
//			if (LastSyncRevision.HasValue)
//				noteUpdateObj [LastSyncRevisionElementName] = LastSyncRevision;
            if (OpenOnStartup.HasValue)
            {
                noteUpdateObj [OpenOnStartupElementName] = OpenOnStartup.Value;
            }
            if (Pinned.HasValue)
            {
                noteUpdateObj [PinnedElementName] = Pinned.Value;
            }

            if (Tags != null)
            {
                Hyena.Json.JsonArray tagArray =
                    new Hyena.Json.JsonArray();
                foreach (string tag in Tags)
                {
                    tagArray.Add(tag);
                }
                noteUpdateObj [TagsElementName] = tagArray;
            }

            return(noteUpdateObj);
        }
Ejemplo n.º 3
0
		private string CreateNoteChangesJsonString (IList<NoteInfo> noteUpdates, int? expectedNewRevision)
		{
			Hyena.Json.JsonObject noteChangesObj =
				new Hyena.Json.JsonObject ();
			Hyena.Json.JsonArray noteChangesArray =
				new Hyena.Json.JsonArray ();
			foreach (NoteInfo note in noteUpdates)
				noteChangesArray.Add (note.ToUpdateObject ());
			noteChangesObj [NoteChangesElementName] = noteChangesArray;
			if (expectedNewRevision != null)
				noteChangesObj [LatestSyncRevisionElementName] = expectedNewRevision;

			// TODO: Handle errors
			Hyena.Json.Serializer serializer =
				new Hyena.Json.Serializer (noteChangesObj);
			// TODO: Log this for debugging?
			return serializer.Serialize ();
		}
Ejemplo n.º 4
0
		public Hyena.Json.JsonObject ToUpdateObject ()
		{
			Hyena.Json.JsonObject noteUpdateObj =
				new Hyena.Json.JsonObject ();

			if (string.IsNullOrEmpty (Guid))
				throw new InvalidOperationException ("Cannot create a valid JSON representation without a Guid");
			
			noteUpdateObj [GuidElementName] = Guid;
			
			if (!string.IsNullOrEmpty (Command)) {
				noteUpdateObj [CommandElementName] = Command;
				return noteUpdateObj;
			}

			if (Title != null)
				noteUpdateObj [TitleElementName] = Title;
			if (NoteContent != null)
				noteUpdateObj [NoteContentElementName] = NoteContent;
			if (NoteContentVersion.HasValue)
				noteUpdateObj [NoteContentVersionElementName] = NoteContentVersion.Value;

			if (LastChangeDate.HasValue)
				noteUpdateObj [LastChangeDateElementName] =
					LastChangeDate.Value.ToString (NoteArchiver.DATE_TIME_FORMAT);
			if (LastMetadataChangeDate.HasValue)
				noteUpdateObj [LastMetadataChangeDateElementName] =
					LastMetadataChangeDate.Value.ToString (NoteArchiver.DATE_TIME_FORMAT);
			if (CreateDate.HasValue)
				noteUpdateObj [CreateDateElementName] =
					CreateDate.Value.ToString (NoteArchiver.DATE_TIME_FORMAT);

			// TODO: Figure out what we do on client side for this
//			if (LastSyncRevision.HasValue)
//				noteUpdateObj [LastSyncRevisionElementName] = LastSyncRevision;
			if (OpenOnStartup.HasValue)
				noteUpdateObj [OpenOnStartupElementName] = OpenOnStartup.Value;
			if (Pinned.HasValue)
				noteUpdateObj [PinnedElementName] = Pinned.Value;

			if (Tags != null) {
				Hyena.Json.JsonArray tagArray =
					new Hyena.Json.JsonArray ();
				foreach (string tag in Tags)
					tagArray.Add (tag);
				noteUpdateObj [TagsElementName] = tagArray;
			}

			return noteUpdateObj;
		}