private static void AddNote(this Command command) { var c = new Command("add", "Adds a note") { new Argument <string>("description", "Description of the note") }; c.Handler = CommandHandler.Create(async(string description) => { var store = new NoteStore(); try { await store.AddAsync(new Note { Text = description }); await store.SaveChangesAsync(); } catch (UniquenessConstraintViolationException e) { ConsoleRendering.ClearLineAndWriteError(e.Message); } }); command.Add(c); }
private static void EditNote(this Command command) { var c = new Command("edit", "Edits the description for a note") { new Argument <Guid>("id", "Id for the note"), new Argument <string>("description", "New description for the note") }; c.Handler = CommandHandler.Create(async(Guid id, string description) => { var store = new NoteStore(); try { var item = await store.GetByIdAsync(id); item.Text = description; await store.UpdateAsync(item); await store.SaveChangesAsync(); } catch (ItemNotFoundException e) { ConsoleRendering.ClearLineAndWriteError(e.Message); } }); command.Add(c); }
private static void RemoveNote(this Command command) { var c = new Command("remove", "Removes a note") { new Argument <Guid>("id", "Id for the note") }; c.AddAlias("rm"); c.Handler = CommandHandler.Create(async(Guid id) => { var store = new NoteStore(); try { await store.RemoveAsync(id); await store.SaveChangesAsync(); } catch (ItemNotFoundException e) { ConsoleRendering.ClearLineAndWriteError(e.Message); } }); command.Add(c); }
public void SyncNewRecodsTOCloud() { RegisterSelfhostServer(); ConfigurationManager.AppSettings["isServer"] = "true"; ConfigurationManager.RefreshSection("AppSettings"); //Insert records to server for client1 NoteStore client1Store = new NoteStore(); List <Notes> lstNotes = new List <Notes>(); Notes client1Note = new Notes(); client1Note.NoteGuid = "b68f9b83-667c-43f3-98ca-422b31ad37a6"; client1Note.Title = "Title1"; client1Note.Body = new StringBuilder("TestBody"); client1Note.IsDeleted = false; lstNotes.Add(client1Note); client1Store.ClientId = "TestClient1"; client1Store.LstNotes = lstNotes; client1Store.LastUpDateTime = DateTime.UtcNow; var json = JsonConvert.SerializeObject(client1Store); var url = new Uri("http://localhost:9091/api/Sync/SyncData"); var result = new HttpClientUtil().PostHttpAsync(url, json).Result; if (result.Status == HttpStatusCode.OK) { List <Notes> notesFromServer = JsonConvert.DeserializeObject <List <Notes> >(result.Content); var itemServerReturned = notesFromServer.SingleOrDefault(x => x.NoteGuid == "b68f9b83-667c-43f3-98ca-422b31ad37a6"); Assert.IsNull(itemServerReturned); } }
public MainWindow() : base(Gtk.WindowType.Toplevel) { Build(); note_store = new NoteStore(basedir); preview.ModifyFont(Pango.FontDescription.FromString("Monospace 12")); Gtk.TreeViewColumn titleColumn = new Gtk.TreeViewColumn(); titleColumn.Title = "Title"; Gtk.CellRendererText titleCell = new Gtk.CellRendererText(); titleColumn.PackStart(titleCell, true); titleColumn.AddAttribute(titleCell, "text", 0); titleColumn.SortColumnId = 0; titleColumn.Expand = true; filenames.AppendColumn(titleColumn); /* * if (false) { * Gtk.TreeViewColumn filenameColumn = new Gtk.TreeViewColumn (); * filenameColumn.Title = "Filename"; * Gtk.CellRendererText filenameCell = new Gtk.CellRendererText(); * filenameColumn.PackStart(filenameCell, true); * filenameColumn.AddAttribute(filenameCell, "text", 1); * filenameColumn.SortColumnId = 1; * filenames.AppendColumn(filenameColumn); * } */ Gtk.TreeViewColumn dateColumn = new Gtk.TreeViewColumn(); dateColumn.Title = "Date added"; Gtk.CellRendererText dateCell = new Gtk.CellRendererText(); dateColumn.PackStart(dateCell, true); dateColumn.SetCellDataFunc(dateCell, this.RenderDate); dateColumn.SortColumnId = 2; filenames.AppendColumn(dateColumn); filename_list = new ListStore(typeof(String), typeof(String), typeof(DateTime), typeof(Note)); UpdateFiles(); filename_list.SetSortColumnId(0, SortType.Ascending); filter = new Gtk.TreeModelFilter(filename_list, null); filter.VisibleFunc = new TreeModelFilterVisibleFunc(FilterTree); TreeModelSort tm = new TreeModelSort(filter); tm.SetSortFunc(2, this.SortDates); filenames.Model = tm; preview.WrapMode = WrapMode.Word; preview.ModifyFont(Pango.FontDescription.FromString("Droid Sans Mono 10")); preview.Buffer.Changed += new EventHandler(this.WriteToNotefile); }
public Auth001Test(String authToken, NoteStore.Client noteStore) { mAuthToken = authToken; mNoteStore = noteStore; mConsumerKey = Properties.Settings.Default.ConsumerKey; mConsumerSecret = Properties.Settings.Default.ConsumerSecret; mEvernoteHost = Properties.Settings.Default.EvernoteHost; mUserName = Properties.Settings.Default.UserName; mPassword = Properties.Settings.Default.Password; }
// Use this for initialization void Start() { noteCount = 0; m_IF = GameObject.Find("UI/NotePage/Form/WriteNoteField").GetComponent <InputField> (); //m_IF = GameObject.FindGameObjectWithTag ("inputField").GetComponent<InputField> (); UINote = GameObject.Find("UI/NotePage"); m_IF.transform.parent.parent.gameObject.GetComponent <NoteController> ().unShow(); store = GameObject.Find("NoteStore").GetComponent <NoteStore>(); store.onNotesUpdated += notesUpdated; store.onNotePosted += noteAdded; }
// POST api/SyncData/Sync /// <summary> /// Syncs data from client to the Cloud Store and Vice Versa /// </summary> /// <param name="noteStore"></param> /// <returns></returns> public async Task <HttpResponseMessage> SyncData([FromBody] NoteStore noteStore) { try { List <Notes> notesForClient = SyncServer.Sync(noteStore); return(Request.CreateResponse(HttpStatusCode.OK, notesForClient)); } catch (Exception ex) { return(Request.CreateResponse(HttpStatusCode.BadRequest)); } }
private static List <Notes> GetDataFromServer(NoteStore noteStore) { List <Notes> notesFromStore = dbServer.GetNotesForSync(); List <Notes> noteToSync = new List <Notes>(); lastClinetSyncTimestamp = dbServer.GetLastSyncTimestamp(noteStore.ClientId); var changedListFromServer = notesFromStore.Select(n => n).Where(f => f.ModifiedDate > lastClinetSyncTimestamp); if ((changedListFromServer != null) && (changedListFromServer.Count() > 0)) { noteToSync = changedListFromServer.ToList(); } return(noteToSync); }
public static List <Notes> Sync(NoteStore noteStore) { var noteToSyncFromServer = GetDataFromServer(noteStore); var notesToSyncFromClient = noteStore.LstNotes; foreach (var note in notesToSyncFromClient) { dbServer.UpsertNotes(note); } List <Notes> returnList = GetServerDatatoSend(noteToSyncFromServer, notesToSyncFromClient); dbServer.UpdateSyncTimeStamp(noteStore); return(returnList); }
public void UpdateSyncTimeStamp(NoteStore noteStore) { InitialzeDb(); try { var com = new SQLiteCommand(sqlite_conn); com.CommandText = "Update [SyncTimeStamp] set last_synctimestamp=DATETIME('NOW'),client_id='" + noteStore.ClientId + "'"; ; // Add the first entry into our database var updated = com.ExecuteNonQuery(); // Execute the query } catch (Exception ex) { } }
private static void ListNotes(this Command command) { var c = new Command("list", "List all registered notes"); c.AddAlias("ls"); c.Handler = CommandHandler.Create(async(IConsole console) => { var store = new NoteStore(); var notes = await store.GetAllAsync(); var view = new ListView <Note>(notes); if (view.IsEmpty) { return; } console.Append(view); }); command.Add(c); }
public Find002Test(String authToken, NoteStore.Client noteStore) { mAuthToken = authToken; mNoteStore = noteStore; }
private Note GetNote(NoteStore.Client noteStore, string authToken, string noteId) { try { return noteStore.getNote(authToken, noteId, true, false, false, false); } catch (Exception ex) { throw new EverpageException( String.Format("Error occurred when getting note by id {0}: {1}", noteId, ex.Message), ex); } }
/// <summary> /// Downloads the resource attachments for every note in the list. /// </summary> public static List<Note> FetchResources( List<Note> notes, NoteStore.Client noteClient ) { log.Info( "Fetching resources for " + notes.Count + " note(s)..." ); foreach( Note note in notes ) { Resource fetched = noteClient.getResource( authentication.AuthenticationToken, note.Resources[0].Guid, true, false, false, false ); note.Resources[0] = fetched; } return notes; }
public Note001Test(String authToken, NoteStore.Client noteStore) { mAuthToken = authToken; mNoteStore = noteStore; }