Blog      Products      DotNetWiki      Support      Contact  
     Blog Categories
 - All
 - .NET
 - 4 Word Book Reviews
 - AllPodcasts
 - Business Thoughts
 - Clueless Idiocy
 - Norn Iron
 - Personal
 - Podcasting
 - PowerPack
 - Weird Interweb Stuff
 
     Geoff on Twitter
 
     Local Blogs
 
  ASP.NET PowerPack
The ASP.NET PowerPack contains 28 rich, cross-browser controls including:
 - RichTextBox
 - ComboBox
 - DatePicker
 - No-Repost validator

Try the ASP.NET PowerPack free today!
 - More Info
 - Download
 - Price List
 - Licensing
 - Buy Now!

 
     Web Tools
 - The DotNetWiki
 - OPML Viewer
 - RSS Viewer
 - ASP.NET Colors
 - Base64 Encode
 - Base64 Decode
 - HTML Encode
 - HTML Decode
 - URL Encode
 - URL Decode
 - Crazy IPs
 - Whois

 
     Windows Tools

ADO.NET ConnTest
A simple, free Windows program to test ADO.NET connection strings.

Lines of C#
Ever wanted to know how many lines of C# code are in a file or folder hierarchy?  This free Windows program will tell you.

XmlTools
Free tools to process XML files from the command line.

 
Exporting from Chandler into Evernote

I had a lot of notes in Chandler, but I’ve started using Evernote for that kind of thing so I wanted to move them all so I only had to look in one place.

Nice as they both are, getting data into and out of them is quite a pain. In the end I exported from Chandler to an ICS file (the only portable format it can export to, as far as I can tell).

Then I converted that to RDF using ical2Rdf. Then I patched up the XML by hand to include the last edit date for the task (the closest I could get to the creation date).

Then I wrote a program to add each ICS entry to Evernote using ENScript. It’s great that they provide that tool, but it fails silently if you give it an empty text file for the description field. (It fails not so silently if you give it a text file without the .txt extension, but as long as it gives an error I can deal with it.)

So, here’s the source code for the program. It’s a nasty hack of a program, but I only had to get one successful run out of it so I’m not overly bothered. It might help someone else in the same boat.

No, you can’t ask me for support for this. I’ve already spent too long at this and I never want to see it again. You’re on your own, take backups, and don’t come crying to me if this deletes anything or everything.

Good luck!

 

Code Snippet
  1. namespace EvernoteIcalImport
  2. {
  3.     using System;
  4.     using System.Collections.Generic;
  5.     using System.Diagnostics;
  6.     using System.Linq;
  7.     using System.Xml.Linq;
  8.  
  9.     class Program
  10.     {
  11.         private static readonly XNamespace IcalNamespace = "http://www.w3.org/2002/12/cal/ical#";
  12.  
  13.         private static int _counter = 0;
  14.  
  15.         static void Main ()
  16.         {
  17.             XDocument toImport = XDocument.Load (@"..\..\ToImport.xml");
  18.             var document = toImport.Document;
  19.             var events = document.Descendants (IcalNamespace + "Vevent");
  20.             ProcessItem (events);
  21.  
  22.             var todo = document.Descendants (IcalNamespace + "Vtodo");
  23.             ProcessItem (todo);
  24.  
  25.             Console.In.ReadLine ();
  26.  
  27.             return;
  28.         }
  29.  
  30.         private static void ProcessItem (IEnumerable<XElement> items)
  31.         {
  32.             foreach (var element in items)
  33.             {
  34.                 string summaryText = "";
  35.                 var summary = element.Element (IcalNamespace + "summary");
  36.                 if (summary != null)
  37.                 {
  38.                     summaryText = summary.Value;
  39.                 }
  40.  
  41.                 string descriptionText = "";
  42.                 var description = element.Element (IcalNamespace + "description");
  43.                 if (description != null)
  44.                 {
  45.                     descriptionText = description.Value;
  46.                 }
  47.  
  48.                 string statusText = "";
  49.                 var status = element.Element (IcalNamespace + "status");
  50.                 if (status != null)
  51.                 {
  52.                     statusText = status.Value;
  53.                 }
  54.  
  55.                 var createdElement = element.Descendants (IcalNamespace + "date").First ();
  56.                 DateTimeOffset created = DateTimeOffset.Parse (createdElement.Value);
  57.  
  58.                 Import (summaryText, descriptionText, created, statusText);
  59.             }
  60.         }
  61.  
  62.         private static void Import (string title, string description, DateTimeOffset created, string tag)
  63.         {
  64.             string arguments = string.Format ("createNote /n \"Chandler Import\" /t \"{0}\" /c \"{1}\" /i \"{2}\"", tag, created.ToString ("yyyy/MM/dd hh:mm:ss"), title);
  65.             _counter++;
  66.             Console.Out.WriteLine ("Arguments[{0}]: {1}", _counter, arguments);
  67.  
  68.             var startInfo = new ProcessStartInfo (@"C:\Program Files (x86)\Evernote\ENScript.exe", arguments)
  69.                                 {
  70.                                     UseShellExecute = false,
  71.                                     RedirectStandardInput = true,
  72.                                     RedirectStandardOutput = true,
  73.                                     RedirectStandardError = true,
  74.                                     CreateNoWindow = true
  75.                                 };
  76.  
  77.             var process = Process.Start (startInfo);
  78.  
  79.             if (string.IsNullOrEmpty (description))
  80.             {
  81.                 description = "Empty import";
  82.             }
  83.  
  84.             process.StandardInput.Write (description);
  85.             process.StandardInput.Flush ();
  86.             process.StandardInput.Close ();
  87.  
  88.             process.WaitForExit ();
  89.  
  90.             string output = process.StandardOutput.ReadToEnd ();
  91.             Console.Out.WriteLine ("Output:");
  92.             Console.Out.WriteLine (output);
  93.  
  94.             string error = process.StandardError.ReadToEnd ();
  95.             Console.Out.WriteLine ("Errors:");
  96.             Console.Out.WriteLine (error);
  97.             if (!string.IsNullOrEmpty (error))
  98.             {
  99.                 Console.In.ReadLine ();
  100.             }
  101.  
  102.             return;
  103.         }
  104.     }
  105. }


Categories: .NET
Permalink #.Posted by 'geoff' on Wednesday, 30 December 2009 at 4:42PM


Comments, Trackbacks and Pingbacks

There are no comments to display.

Post A Comment

Your Name:
Your URL (optional):
Comment Title:


View my Technorati Profile.
RSS 2.0 Subscribe to the RSS 2.0 feed for Geoff's Blog.