For the last few years I have been keeping a daily log of events and information in a daily log using Evernote. In this article I will describe how I use a daily log in Evernote and the code I used to build a journal template.
My daily log is a place where I record notes on programming, applications, machine, and other information. Updates to applications, error reports, meeting notes, code snippets, and links to articles I would like to read later are all kept in my log.
I record events by the date which gives some order to this jumble of information. Also when tracking errors down it is good to have a date associated with their appearance.
Despite the dated entries I don’t really use it as a calendar or planner. However on occasion I will put an entry in a future date about some deadline or task to perform. But mostly it is for a record of what happened when on what project, program, or machine.
I keep one log per year. Although you can search over all your notes in Evernote I find it useful and faster to search within a note if I know the data or event was in a particular year. Also when you first bring up a note you are at January 1, so you have to page down to the current date to start a new entry for the current day.
Evernote is an online service for documents, images, web pages, and voice notes. Its greatest advantage is that your information is available via several means. The Evernote website has a sophisticated web application to view and edit your notes. There are applications available for Windows, Mac, iOS, and Android. The basic service is free and the paid service adds things like performing OCR on images and adding the words to the search index. There are also Chrome and Firefox add-ins that allow you to save a partial or entire page.
The majority of my Evernote usage is by the Windows application. The data is stored locally and synced with the website at an adjustable period. Notes are edited in a rich text editor that supports different fonts and colors, indents, bullet lists, and tables. Formatted data pasted in will retain the format of the original document.
When I started the log I kept a weekly template with horizontal rules to divide the daily entries and put a partial day/date at the top of each section. That meant every Monday morning I would have to copy this template, paste it into the end of the log, and then change seven strings like “2016.mm.dd Monday” to “2016.12.26 Monday”.
I got pretty tired of doing this and last year I started to investigate how to create a template that would suit my needs. Unfortunately paid programming work got in the way and I had to put the project aside. Also I found a 2016 calendar template on the Evernote site. I managed to edit this calendar into a usable log template. It had several drawbacks. The major one was that it was one big table so that limited how you could format things since one day was in one table cell. Also when you did an undo the document would zip back to the top, very frustrating after about April or May!
This year I was determined to revive my custom template project and have a new template in place on January 1.
My original idea was to have a program create the date text and formatting data and save it into the Windows clipboard for easy pasting into Evernote. There is an Evernote XML export / import format (.enex) but I decided not to dig into that. Besides, how hard could it be to write formatted data to the clipboard? The application source is available here in Github.
First I created the function GetClipboardInfo to list the formats in the current clipboard entry and list the formats it contains.
After listing the formats I then check to see if an HTML Format object exists. If it exists we read it with the GetData function. The Replace function is to change the new line character to a carriage return / new line so the Winforms text control will display the line breaks.
The “Version:0.9” is the beginning of the HTML Object followed by markers for the positions of the start / end of the actual HTML and the Fragment, which is what was copied. By copying parts of an Evernote note and using this tool I was able to determine what to put in the generated template.
The class GenEverLog has a single function CreateYear with a single parameter for the year to create. The HTML strings are divided between the sections before and after the date strings to be printed. The format strings are used for date formatting. These could be made variable with control settings added to the form. Also the hard coded colors in the HTML strings could likewise be made select-able.
From this point it is a simple matter to create a DateTime object, increment the day in a while loop, and build up a StringBuilder object with the HTML and the dates, months, and weeks. Note that a companion text only string is built up and will be sent to the clipboard. This text only string will be retrieved by applications that do not support HTML, such as Notepad.
To write the HTML to a new clipboard entry, I used the ClipboardHelper code from this article by Arthur Teplitzki. I had to clean up the code copied from the web page to change Word style double quotes to regular quotes and while I was at it I changed the style to use newer C# conventions. The only functional change I made was to remove the insertion of the Doctype line.
The “Write Everlog to Clipboard Function” button will call the CreateYear function and display “Added HTML to Clipboard”. If you want to see the HTML created, simply click the “Read Clipboard” button again.