<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Offside &#187; 技術</title>
	<atom:link href="http://htakeuchi.offtheball.jp/category/tech/feed" rel="self" type="application/rss+xml" />
	<link>http://htakeuchi.offtheball.jp</link>
	<description>Offtheball LLC 代表  竹内仁のブログ</description>
	<lastBuildDate>Sat, 17 Jul 2010 04:53:20 +0000</lastBuildDate>
	<language>ja</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>pomera2evernote Version 0.2をリリースしました</title>
		<link>http://htakeuchi.offtheball.jp/archives/3440</link>
		<comments>http://htakeuchi.offtheball.jp/archives/3440#comments</comments>
		<pubDate>Fri, 23 Apr 2010 20:14:20 +0000</pubDate>
		<dc:creator>htakeuchi</dc:creator>
				<category><![CDATA[ツール・サービス]]></category>
		<category><![CDATA[技術]]></category>
		<category><![CDATA[evernote]]></category>
		<category><![CDATA[Pomera]]></category>

		<guid isPermaLink="false">http://htakeuchi.offtheball.jp/?p=3440</guid>
		<description><![CDATA[ photo credit: yto
ノートブック名に記号（[や]など）が使われている場合、Evernoteへのアップロードに失敗する問題を修正しました。
こちらからVersion 0.2をダウンロードしてご利用ください [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.flickr.com/photos/27983255@N00/3939082915/" title="ポメラ(pomera)" target="_blank"><img src="http://farm4.static.flickr.com/3430/3939082915_37a7920d11_m.jpg" alt="ポメラ(pomera)" border="0" /></a><br /><small><a href="http://creativecommons.org/licenses/by/2.0/" title="Attribution License" target="_blank"><img src="http://htakeuchi.offtheball.jp/wp-content/plugins/photo-dropper/images/cc.png" alt="Creative Commons License" border="0" width="16" height="16" align="absmiddle" /></a> <a href="http://www.photodropper.com/photos/" target="_blank">photo</a> credit: <a href="http://www.flickr.com/photos/27983255@N00/3939082915/" title="yto" target="_blank">yto</a></small></p>
<p>ノートブック名に記号（[や]など）が使われている場合、Evernoteへのアップロードに失敗する問題を修正しました。</p>
<p><a href="http://htakeuchi.offtheball.jp/archives/3331">こちらから</a>Version 0.2をダウンロードしてご利用ください。</p>
<p>アーカイブを展開し、pomera2evernote.exeをインストール済みのものに上書きするだけでOKです。</p>
<p>なお、ノートブック名に記号を使いたい場合、config.ymlのnotebookの指定で以下のように&#8221;でくくってください。</p>
<pre class="brush: plain;">
notebook: &quot;[aNote]Pomera&quot;
</pre>
]]></content:encoded>
			<wfw:commentRss>http://htakeuchi.offtheball.jp/archives/3440/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>pomera2evernoteが窓の杜で紹介されました</title>
		<link>http://htakeuchi.offtheball.jp/archives/3425</link>
		<comments>http://htakeuchi.offtheball.jp/archives/3425#comments</comments>
		<pubDate>Thu, 15 Apr 2010 19:09:42 +0000</pubDate>
		<dc:creator>htakeuchi</dc:creator>
				<category><![CDATA[ツール・サービス]]></category>
		<category><![CDATA[技術]]></category>
		<category><![CDATA[evernote]]></category>
		<category><![CDATA[Pomera]]></category>

		<guid isPermaLink="false">http://htakeuchi.offtheball.jp/?p=3425</guid>
		<description><![CDATA[































窓の杜 &#8211; 【REVIEW】“ポメラ”内のテキストファイルを“Evernote”へ転送できる「pomera2evernote」 via kwou [...]]]></description>
			<content:encoded><![CDATA[<div class="kwout" style="text-align: center;"><img src="http://kwout.com/cutout/w/t8/46/t94_sha.jpg" alt="http://www.forest.impress.co.jp/docs/review/20100414_360941.html" title="窓の杜 - 【REVIEW】“ポメラ”内のテキストファイルを“Evernote”へ転送できる「pomera2evernote」" width="365" height="307" style="border: none;" usemap="#map_wt846t94" /><br />
<map id="map_wt846t94" name="map_wt846t94">
<area coords="7,272,60,279" href="http://www.forest.impress.co.jp/docs/review/20100415_361273.html" alt="" shape="rect" />
<area coords="7,280,61,293" href="http://www.forest.impress.co.jp/docs/review/20100415_361273.html" alt="" shape="rect" />
<area coords="7,294,42,298" href="http://www.forest.impress.co.jp/docs/review/20100415_361273.html" alt="" shape="rect" />
<area coords="7,122,53,129" href="http://www.forest.impress.co.jp/docs/news/20100415_361457.html" alt="" shape="rect" />
<area coords="7,129,31,136" href="http://www.forest.impress.co.jp/docs/news/20100415_361457.html" alt="" shape="rect" />
<area coords="7,137,44,143" href="http://www.forest.impress.co.jp/docs/news/20100415_361457.html" alt="" shape="rect" />
<area coords="7,144,58,150" href="http://www.forest.impress.co.jp/docs/news/20100415_361457.html" alt="" shape="rect" />
<area coords="7,151,37,157" href="http://www.forest.impress.co.jp/docs/news/20100415_361457.html" alt="" shape="rect" />
<area coords="263,6,353,21" href="http://www.forest.impress.co.jp/lib/inet/" alt="" shape="rect" />
<area coords="7,197,57,204" href="http://www.forest.impress.co.jp/docs/news/20100415_361391.html" alt="" shape="rect" />
<area coords="7,204,61,211" href="http://www.forest.impress.co.jp/docs/news/20100415_361391.html" alt="" shape="rect" />
<area coords="7,212,55,218" href="http://www.forest.impress.co.jp/docs/news/20100415_361391.html" alt="" shape="rect" />
<area coords="7,219,57,225" href="http://www.forest.impress.co.jp/docs/news/20100415_361391.html" alt="" shape="rect" />
<area coords="7,226,25,233" href="http://www.forest.impress.co.jp/docs/news/20100415_361391.html" alt="" shape="rect" />
<area coords="0,1,62,46" href="http://www.forest.impress.co.jp/" alt="" shape="rect" />
<area coords="7,235,61,241" href="http://www.forest.impress.co.jp/docs/news/20100415_361411.html" alt="" shape="rect" />
<area coords="7,242,58,249" href="http://www.forest.impress.co.jp/docs/news/20100415_361411.html" alt="" shape="rect" />
<area coords="7,249,43,256" href="http://www.forest.impress.co.jp/docs/news/20100415_361411.html" alt="" shape="rect" />
<area coords="7,256,56,263" href="http://www.forest.impress.co.jp/docs/news/20100415_361411.html" alt="" shape="rect" />
<area coords="7,264,31,270" href="http://www.forest.impress.co.jp/docs/news/20100415_361411.html" alt="" shape="rect" />
<area coords="7,69,61,76" href="http://www.forest.impress.co.jp/backno/inet/index_c190.html" alt="" shape="rect" />
<area coords="7,77,61,90" href="http://www.forest.impress.co.jp/backno/inet/index_c190.html" alt="" shape="rect" />
<area coords="7,91,31,97" href="http://www.forest.impress.co.jp/backno/inet/index_c190.html" alt="" shape="rect" />
<area coords="7,160,57,166" href="http://www.forest.impress.co.jp/docs/news/20100415_361421.html" alt="" shape="rect" />
<area coords="7,167,61,173" href="http://www.forest.impress.co.jp/docs/news/20100415_361421.html" alt="" shape="rect" />
<area coords="7,174,57,181" href="http://www.forest.impress.co.jp/docs/news/20100415_361421.html" alt="" shape="rect" />
<area coords="7,181,43,188" href="http://www.forest.impress.co.jp/docs/news/20100415_361421.html" alt="" shape="rect" />
<area coords="7,189,51,195" href="http://www.forest.impress.co.jp/docs/news/20100415_361421.html" alt="" shape="rect" />
<area coords="227,261,354,298" href="http://www.forest.impress.co.jp/img/wf/docs/360/941/html/image2.jpg.html" alt="" shape="rect" />
<area coords="227,149,354,241" href="http://www.forest.impress.co.jp/img/wf/docs/360/941/html/image1.jpg.html" alt="" shape="rect" /></map>
<p style="margin-top: 10px; text-align: center;"><a href="http://www.forest.impress.co.jp/docs/review/20100414_360941.html">窓の杜 &#8211; 【REVIEW】“ポメラ”内のテキストファイルを“Evernote”へ転送できる「pomera2evernote」</a> via <a href="http://kwout.com/quote/wt846t94">kwout</a></p>
</div>
<p>pomeraのテキストをEvernoteへ転送する<a href="http://htakeuchi.offtheball.jp/archives/3331">pomera2evernote</a>を窓の杜でご紹介いただきました。ありがとうございます。</p>
<p>実態はわずか80行行程度のRubyスクリプトなのでちょっと心苦しい感じですが(^^;よろしければご利用ください。</p>
<p>なお、窓の杜のレビューでは、</p>
<blockquote><p>
2回目以降は追加・更新されたテキストのみを転送できるので、テキストファイルのバージョン管理に悩むこともない。
</p></blockquote>
<p>とありますが、PomeraでEvernoteへアップロード済みのテキストファイルAを更新してA&#8217;にした場合、A&#8217;は<strong>新規に</strong>Evernoteへ転送されます。</p>
<p>つまり、Evernote上にはAとA&#8217;が存在することになりますのでご注意ください。（プログラム内部で使っているEvernoteに同梱されているEnscript.exeの仕様上、上書きが難しい）</p>
<p>EvernoteのAPIを使えばPomeraと同期するアプリも書けると思います。ぜひ、どなかた書いてください(^^)</p>
<p><a href="http://htakeuchi.offtheball.jp/archives/3390">exeUSBを使ったPomeraからEvernote自動アップロード設定例はこちら</a>です。</p>
]]></content:encoded>
			<wfw:commentRss>http://htakeuchi.offtheball.jp/archives/3425/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PomeraのテキストをEvernoteへアップロードするプログラムを作りました</title>
		<link>http://htakeuchi.offtheball.jp/archives/3331</link>
		<comments>http://htakeuchi.offtheball.jp/archives/3331#comments</comments>
		<pubDate>Fri, 12 Mar 2010 21:46:19 +0000</pubDate>
		<dc:creator>htakeuchi</dc:creator>
				<category><![CDATA[ツール・サービス]]></category>
		<category><![CDATA[技術]]></category>
		<category><![CDATA[evernote]]></category>
		<category><![CDATA[Pomera]]></category>

		<guid isPermaLink="false">http://htakeuchi.offtheball.jp/?p=3331</guid>
		<description><![CDATA[
先日、自分用にPomeraのテキストをEvernoteへアップロードするプログラム(Rubyスクリプト)を書き、使い始めました。
PomeraユーザかつEvernoteユーザが対象というニッチさから、ニーズが無いだろう [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://htakeuchi.offtheball.jp/wp-content/uploads/2010/03/evernote.png" alt="" title="evernote" width="196" height="49" class="alignnone size-full wp-image-3321" /></p>
<p>先日、自分用にPomeraのテキストをEvernoteへアップロードするプログラム(Rubyスクリプト)を書き、使い始めました。</p>
<p>PomeraユーザかつEvernoteユーザが対象というニッチさから、ニーズが無いだろうと思いつつTwitterで以下のようにつぶやいたところ、</p>
<p><a href="http://twitter.com/htakeuchi/status/10136312513"><img src="http://htakeuchi.offtheball.jp/wp-content/uploads/2010/03/tweet-300x215.jpg" alt="" title="tweet" width="300" height="215" class="alignnone size-medium wp-image-3353" /></a></p>
<p>何名かの方から反応をいただきましたので、RubyがインストールされていないPCでも使用できるよう<a href="http://sourceforge.jp/projects/exerb/">Exerb</a>でEXE形式にし、公開することにしました。</p>
<h3>機能について</h3>
<ul>
<li>USB接続したPomeraのテキストファイルをEvernoteへアップロードできる。</li>
<li>2回目以降は、前回アップロード時点より新しいファイルのみをアップロードする。</li>
<li>設定ファイルでアップロードするノートブックを指定可能。</li>
</ul>
<p>というシンプルなプログラムです。</p>
<h3>ダウンロード</h3>
<p>ダウンロードは以下のリンクからどうぞ。</p>
<ul>
<li><a href="http://www.offtheball.jp/download/free/pomera2evernote.zip">pomera2evernote Version 0.2 &#8211; ノートブック名に特殊記号が含まれている場合にアップロード失敗する問題を修正</a></li>
<li><a href="http://www.offtheball.jp/download/free/pomera2evernote01.zip">pomera2evernote Version 0.1</a></li>
</ul>
<h3>インストールの方法</h3>
<p>アーカイブを展開し任意のフォルダで解凍するだけです。以下のファイルがあることを確認してください。</p>
<ul>
<li>pomera2evernote.exe (プログラム本体)</li>
<li>config.yml (設定ファイル)</li>
<li>pomera2evernote.rb (Rubyスクリプト。通常使いません。EXEが動かない場合や改造したい場合に)</li>
</ul>
<p>次に設定ファイルの編集です。</p>
<h3>設定ファイルの編集</h3>
<p>設定ファイルconfig.ymlは初期状態では以下のようになっています。3つの設定項目がありますので、環境に応じて値を変更してください。普通のテキストファイルですのでメモ帳やテキストエディタで編集します。</p>
<pre class="brush: plain;">
path: C:\Program Files\Evernote\Evernote3.5
pomera_drive: h
notebook: &quot;Pomera&quot;
</pre>
<h4>pomera_drive</h4>
<p>pomera_driveにはPomeraをUSB接続した際に割り当てられるドライブ名を指定します(例ではHドライブを指定)。</p>
<p>事前にPomeraをUSB接続し、どのドライブからファイルをアップロードするかを決めておいてください。</p>
<h4>notebook</h4>
<p>notebookはPomeraのテキストをアップロードするEvernoteのノートブック名を指定します。(例ではPomeraを指定)</p>
<p>存在しないノートブック名を指定した場合、ノートブックを作成後にテキストをアップロードします。ただ、私が試した限りではアップロード後、Evernoteのクライアントを再起動しないと、追加したノートブックが一覧に表示されませんでした。(Evernote 3.5.2.1697)</p>
<p><strong>ノートブック名は&#8221;（ダブルクォーテーション)で囲んで指定してください。(2010/4/24追記)</strong></p>
<h4>path</h4>
<p>pathはEvernoteをインストールされているフォルダ名を指定します。(例ではC:\Program Files\Evernote\Evernote3.5を指定。そのフォルダにEnscript.exeがあります)</p>
<p>エラーメッセージ(Error: failed to execute enscript command)が表示される場合は、pathの設定が間違っている可能性が高いので良くご確認ください。</p>
<p>以上で準備完了です。</p>
<h3>PomeraからEvernoteへアップロードする方法</h3>
<p>Pomeraで作成したテキストをアップロードする方法は以下の通りです。</p>
<ol>
<li>PomeraをUSBケーブルでPCへ接続する。</li>
<li>ドライブとして認識された後、エクスプローラーなどでpomera2evernote.exeを起動。</li>
<li>前回のアップロード以降にPomeraで更新したテキストが順次アップロードされます。(初回起動時はPomeraにある全てのテキストが対象)</li>
</li>
<li>全てのアップロードが完了するとアップロードしたファイル数を表示し、プログラムが終了します。</li>
<li>ここまで終わったらPomeraを取り外してOKです。</li>
</ol>
<p>ここで紹介した手順ではPomeraを接続した後、手動でpomera2evernote.exeを起動していますが、<strong><a href="http://www.nanshiki.co.jp/software/index.html?exeusb ">exeUSB</a>というプログラムを使えば、こんなステキ環境を作れます。</strong></p>
<ol>
<li>Pomeraを接続すると自動的にpomera2evernote.exeが起動する。</li>
<li>新規、または前回から更新されているテキストだけがEvernoteへアップロードされる。</li>
<li>PomeraのUSB接続が自動的に切断される。</li>
</ul>
<p>「ドライブとして認識されるのを待ちプログラムを起動する」というちょっとした手間が継続できない要因になったりしますので、設定しておくとよいかもしれません。</p>
<p>私なんてUSB接続が面倒にならないように、プラスティックのカバーを切断してしましました。（これは、やりすぎ!?)</p>
<p><iframe src="http://rcm-jp.amazon.co.jp/e/cm?lt1=_blank&#038;bc1=000000&#038;IS2=1&#038;bg1=FFFFFF&#038;fc1=000000&#038;lc1=0000FF&#038;t=offtheball2008-22&#038;o=9&#038;p=8&#038;l=as1&#038;m=amazon&#038;f=ifr&#038;md=1X69VDGQCMF7Z30FM082&#038;asins=B002YQ2Z6A" style="width:120px;height:240px;" scrolling="no" marginwidth="0" marginheight="0" frameborder="0"></iframe></p>
<h4>制約事項</h4>
<p>現状の制約事項は以下の通りです。</p>
<ul>
<li>対象ドライブを1つしか指定できない。(私はDM20を使っており内蔵メモリを対象にしています)</li>
<li>アップロードしたテキストのフォントサイズが小さい。(Enscript.exeでノートを作成しているため。いまのところ変更方法がわかりません…)</li>
</ul>
<p>ちょっとしたプログラムですが、Pomeraユーザのお役に立てば幸いです。無料・無保証でどうぞ。</p>
]]></content:encoded>
			<wfw:commentRss>http://htakeuchi.offtheball.jp/archives/3331/feed</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>.NETからRedmineへアクセスするライブラリを試してみた</title>
		<link>http://htakeuchi.offtheball.jp/archives/2740</link>
		<comments>http://htakeuchi.offtheball.jp/archives/2740#comments</comments>
		<pubDate>Tue, 24 Nov 2009 21:09:56 +0000</pubDate>
		<dc:creator>htakeuchi</dc:creator>
				<category><![CDATA[プロジェクト管理ツール]]></category>
		<category><![CDATA[技術]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Redmine]]></category>

		<guid isPermaLink="false">http://htakeuchi.offtheball.jp/?p=2740</guid>
		<description><![CDATA[ photo credit: ahisgett
Redmine Clientというアプリケーションがあります。Windows(.NET)上で動作するRedmineのクライアントで、機能的には、

チケットに費やした時間を [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.flickr.com/photos/37804979@N00/4125499571/" title="Crab apples" target="_blank"><img src="http://farm3.static.flickr.com/2465/4125499571_b3698874ac_m.jpg" alt="Crab apples" border="0" /></a><br /><small><a href="http://creativecommons.org/licenses/by/2.0/" title="Attribution License" target="_blank"><img src="http://htakeuchi.offtheball.jp/wp-content/plugins/photo-dropper/images/cc.png" alt="Creative Commons License" border="0" width="16" height="16" align="absmiddle" /></a> <a href="http://www.photodropper.com/photos/" target="_blank">photo</a> credit: <a href="http://www.flickr.com/photos/37804979@N00/4125499571/" title="ahisgett" target="_blank">ahisgett</a></small></p>
<p><a href="http://redmineclient.sourceforge.net/">Redmine Client</a>というアプリケーションがあります。Windows(.NET)上で動作するRedmineのクライアントで、機能的には、</p>
<ul>
<li>チケットに費やした時間を計測する</li>
<li>時間をRedmineへ登録する</li>
<li>新しいチケットを登録する</li>
</ul>
<p>というシンプルなものです。C#で書かれています。</p>
<p>このアプリケーションにはRedmineへアクセスするためのライブラリ(DLL)が添付されており、<a href="http://redmineclient.sourceforge.net/apidoc/Index.html">APIの仕様</a>も公開されています。（どちらかと言うと、アプリケーションはこのライブラリのサンプル的な位置付けなのかな？）</p>
<p>Redmineは0.9でRESTfulになるらしいので、それまで待とうか…という気もしないではないのですが、このライブラリのFUTURE PLANSには“Making use of Redmine 0.9 RESTfull interface”とあり、0.9でRESTfullになったら対応する模様。</p>
<p>ということで、安心して？試してみました。</p>
<h3>インストールと設定</h3>
<ol>
<li><a href="http://sourceforge.net/projects/redmineclient/files/">ここから</a>redmineclient-0.3.0.zipをダウンロードする。</li>
<li>アーカイブを解凍しNohal.Redmine.dllをVisual Studioのプロジェクトで参照設定する。</li>
</ol>
<p>これだけです。</p>
<h3>チケット一覧を取得するための基本的な流れ</h3>
<p>以下のような流れでチケット一覧を取得できます。簡単。</p>
<ol>
<li>Redmineオブジェクトの生成</li>
<li>RedmineのURLを設定(Redmine.RedmineBaseUriプロパティ)</li>
<li>Redmineへのログイン(Redmine.LogInメソッド)</li>
<li>プロジェクト一覧の取得(Redmine.GetProjectsメソッド)</li>
<li>プロジェクトIDを指定してチケット一覧の取得（Redmine.GetIssuesメソッド)</li>
</ol>
<p>（載せるまでも無いですが）実際のコードはこんな感じ。</p>
<pre class="brush: csharp;">
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Nohal.Redmine;

namespace RedmineTest
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            Redmine redmine = new Redmine();
            redmine.RedmineBaseUri = &amp;quot;RedmineのURL&amp;quot;;
            redmine.LogIn(&amp;quot;Redmineのユーザ名&amp;quot;, &amp;quot;Redmineのパスワード&amp;quot;);

            List&amp;lt;Project&amp;gt; projects = redmine.GetProjects();
            textBox1.Text = &amp;quot;プロジェクト一覧\r\n&amp;quot;;
            foreach (Project project in projects)
                textBox1.Text += project.Id.ToString() + &amp;quot;: &amp;quot; + project.Name + &amp;quot;\r\n&amp;quot;;

            textBox1.Text += &amp;quot;チケット一覧\r\n&amp;quot;;
            // GetIssues(3)の3はプロジェクトID。本来はGetProjects()で取得したIDを指定する。
            foreach (Issue issue in redmine.GetIssues(3))
                textBox1.Text += issue.Id + &amp;quot;: &amp;quot; + issue.Subject + &amp;quot;\r\n&amp;quot;;
        }
    }
}
</pre>
<p>ざっとAPI仕様を眺めた限りでは、条件を指定してチケットを絞り込む方法が無さそうです。<br />
このため、指定したプロジェクトの全チケットがListで返却されますので、チケット数が数千～数万のオーダーになると厳しいかもしれませんが、チケットの登録はイケるでしょう。</p>
<p>C#から簡単にRedmineへアクセスできるのはいいですね。Redmineクライアントの開発をお考えての方はお試しください。</p>
]]></content:encoded>
			<wfw:commentRss>http://htakeuchi.offtheball.jp/archives/2740/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Evernote APIをラップするC#のライブラリEvernoteSharpを試してみました</title>
		<link>http://htakeuchi.offtheball.jp/archives/2620</link>
		<comments>http://htakeuchi.offtheball.jp/archives/2620#comments</comments>
		<pubDate>Sat, 07 Nov 2009 12:08:38 +0000</pubDate>
		<dc:creator>htakeuchi</dc:creator>
				<category><![CDATA[技術]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[evernote]]></category>

		<guid isPermaLink="false">http://htakeuchi.offtheball.jp/?p=2620</guid>
		<description><![CDATA[
Evernoteは開発者向けにAPIを提供しています。
C#で書こうとしているちょっとしたプログラムの調査のため、Evernote APIをラップするC#のライブラリEvernoteSharp試してみました。
Ever [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://htakeuchi.offtheball.jp/wp-content/uploads/2009/11/evernote.png" alt="evernote" title="evernote" width="196" height="49" class="alignnone size-full wp-image-2644" /></p>
<p>Evernoteは開発者向けにAPIを提供しています。</p>
<p>C#で書こうとしているちょっとしたプログラムの調査のため、Evernote APIをラップするC#のライブラリ<a href="http://evernotesharp.codeplex.com/">EvernoteSharp</a>試してみました。</p>
<p>Evernote APIを使うためには、API Keyを払い出してもらう必要があります。<a href="http://www.evernote.com/about/developer/api/">Request an API Key</a>から、必要事項を書いて申し込みます。私の場合は申し込んでから1時間半ぐらいでAPI Keyがメールで送られてきました。仕事が速いですね！</p>
<p>API Keyは開発用環境であるSandBoxのみで有効です。このため、普段使っているアカウントとは別に<a href="https://sandbox.evernote.com/Registration.action">Evernote Registration</a>からテスト専用のアカウントを登録します。</p>
<p>次に、Visual StudioでWindowsアプリケーションのプロジェクトを作成します。<a href="http://evernotesharp.codeplex.com/">EvernoteSharp</a>をダウンロードし、アーカイブを解凍してEvernoteSharp.dllをプロジェクトの参照設定へ追加します。準備はこれで完了。</p>
<p>以下のコードは、指定した画像ファイルをEvernoteのデフォルトのノートブックへ追加するものです。</p>
<pre class="brush: csharp;">
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Security.Cryptography;
using EvernoteSharp;

namespace EvernoteSample
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            StoreFactory sf = new StoreFactory(new Uri(&amp;amp;quot;http://sandbox.evernote.com/&amp;amp;quot;), &amp;amp;quot;your-api-key-here!&amp;amp;quot;, &amp;amp;quot;your-api-secret-here!&amp;amp;quot;);
            UserStoreWrapper userStore = sf.CreateUserStore();

            if (!userStore.CheckVersion())
                throw new Exception(&amp;amp;quot;Invalid API version&amp;amp;quot;);
            userStore.Authenticate(&amp;amp;quot;your-username&amp;amp;quot;, &amp;amp;quot;your-password&amp;amp;quot;);

            NoteStoreWrapper noteStore = sf.CreateNoteStore();
            Evernote.EDAM.Type.Data data = new Evernote.EDAM.Type.Data();

            FileStream fs = new FileStream(tbTitle.Text, FileMode.Open, FileAccess.Read);
            byte[] bImageFile = new byte[fs.Length];
            fs.Read(bImageFile, 0, bImageFile.Length);
            fs.Close();

            MD5CryptoServiceProvider md5 = new MD5CryptoServiceProvider();
            byte[] bs = md5.ComputeHash(bImageFile);
            string hashHex = BitConverter.ToString(bs).ToLower().Replace(&amp;amp;quot;-&amp;amp;quot;,&amp;amp;quot;&amp;amp;quot;);

            data.Size = bImageFile.Length;
            data.BodyHash = bs;
            data.Body = bImageFile;

            Evernote.EDAM.Type.Resource resource = new Evernote.EDAM.Type.Resource();
            resource.Mime= &amp;amp;quot;image/png&amp;amp;quot;;
            resource.Data = data;

            Evernote.EDAM.Type.Note note = new Evernote.EDAM.Type.Note();
            var defaultNotebook = noteStore.GetDefaultNotebook();

            note.NotebookGuid = defaultNotebook.Guid;
            note.Title = tbTitle.Text;
            note.Content = &amp;amp;quot;&amp;amp;lt;?xml version=\&amp;amp;quot;1.0\&amp;amp;quot; encoding=\&amp;amp;quot;UTF-8\&amp;amp;quot;?&amp;amp;gt;&amp;amp;quot; +
                            &amp;amp;quot;&amp;amp;lt;!DOCTYPE en-note SYSTEM \&amp;amp;quot;http://xml.evernote.com/pub/enml.dtd\&amp;amp;quot;&amp;amp;gt;&amp;amp;quot; +
                            &amp;amp;quot;&amp;amp;lt;en-note&amp;amp;gt;&amp;amp;quot; +
                            &amp;amp;quot;&amp;amp;lt;en-media type=\&amp;amp;quot;image/png\&amp;amp;quot; hash=\&amp;amp;quot;&amp;amp;quot; + hashHex + &amp;amp;quot;\&amp;amp;quot;/&amp;amp;gt;&amp;amp;quot; +
                            &amp;amp;quot;&amp;amp;lt;/en-note&amp;amp;gt;&amp;amp;quot;;

            note.Updated = note.Created;
            List&amp;amp;lt;Evernote.EDAM.Type.Resource&amp;amp;gt; resourceList = new List&amp;amp;lt;Evernote.EDAM.Type.Resource&amp;amp;gt;();
            resourceList.Add(resource);
            note.Resources = resourceList;

            noteStore.CreateNote(note);

            MessageBox.Show(tbTitle.Text + &amp;amp;quot;をEvernoteへ追加しました&amp;amp;quot;);
        }

        private void button2_Click(object sender, EventArgs e)
        {
            if (openFileDialog1.ShowDialog() == DialogResult.OK)
                tbTitle.Text = openFileDialog1.FileName;
        }
    }
}
</pre>
<p>うん、これでなんとかいけそう。</p>
<p>Evernote APIの資料はこちらです。</p>
<ul>
<li><a href="http://www.evernote.com/about/developer/api/evernote-api.htm">Evernote API Overview</a></li>
<li><a href="http://www.evernote.com/about/developer/api/ref/">Evernote API Reference</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://htakeuchi.offtheball.jp/archives/2620/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>RailsからSalesforceのDBへ簡単にアクセスできるActiveSalesforceを味見してハマったこと</title>
		<link>http://htakeuchi.offtheball.jp/archives/18</link>
		<comments>http://htakeuchi.offtheball.jp/archives/18#comments</comments>
		<pubDate>Fri, 05 Sep 2008 01:56:48 +0000</pubDate>
		<dc:creator>htakeuchi</dc:creator>
				<category><![CDATA[技術]]></category>
		<category><![CDATA[Rails]]></category>
		<category><![CDATA[Salesforce]]></category>

		<guid isPermaLink="false">http://htakeuchi.offtheball.jp/?p=18</guid>
		<description><![CDATA[ActiveSalesforceのドキュメントではパスワードだけを指定するように書かれていますが、今のSalesforceでは(ネットワークを信頼済みに指定しない限り）API経由でアクセスする際はパスワードに続けてセキュリティートークンを指定する必要があります。  

...その場合、APEX APIを使ってAjaxリクエストでデータを取得したり、バッチを開発したりして既存システムとSalesforceのデータ連係を実現する方法がありますが、ActiveSalesforce + RailsによりRailsの生産性を生かした連携開発というのもあり得るかもしれませんね。]]></description>
			<content:encoded><![CDATA[<p>
<a href="http://activesfdc.rubyforge.org/">ActiveSalesforce</a>というSalesforceのデータベースをActiveRecord経由でアクセスできるアダプタを触ってみました。ちょっとハマった部分があるのでメモしておきます。
</p>
<h3>インストールと設定</h3>
<p>
私が試した環境はRails 2.1.0です。Rails 2.xだと、</p>
<pre>
$ gem install activerecord-activesalesforce-adapter
</pre>
<p>だけでOK。Rails 1.xだとインストールと設定の手順が違いますので<a href="http://activesfdc.rubyforge.org/">こちら</a>を参照してください。
</p>
<p>
インストール後、すぐに下にあるようなコードを書いて動かしてみたのですが、<a href="http://rubyforge.org/tracker/?func=detail&#038;group_id=1201&#038;aid=19960&#038;atid=4729">RubyForge: ActiveSalesforce: トラッカー詳細: 19960 defining belongs_to with :dependent => :nullify is broken in edge rails > r8675</a>と同じ事象が発生し動作しませんでした。このチケットにあるパッチをあてたところ、うまく動くように。
</p>
<p>
次にRailsでプロジェクトを作成し、config/database.ymlを次のように書き換えます。</p>
<pre class="brush: ruby;">
development:
  adapter: activesalesforce
  url: https://www.salesforce.com/services/Soap/u/8.0
  username: Salesforceのアカウント
  password: Salesforceのパスワード|セキュリティトークン
</pre>
<p>ActiveSalesforceのドキュメントではパスワードだけを指定するように書かれていますが、今のSalesforceでは(ネットワークを信頼済みに設定しない限り）API経由でアクセスする際はパスワードに続けてセキュリティートークンを指定する必要があります。
</p>
<p>
セキュリティトークンはSalesforceにログインし、[設定] | [私の個人情報] | [セキュリティトークンのリセット] から参照できます。
</p>
<p>
尚、上記のconfig/database.ymlのサンプルでは、パスワードとセキュリティトークンの間に|がありますが、これは可読性のために入れてあります。
</p>
<p>
実際に指定するときはパスワードに続けてセキュリティトークンを指定してください。
</p>
<h3>Salesforceのデータにアクセスする</h3>
<p>
あとはRailsの世界です。ここではSalesforceの取引先(account)の一覧を出力してみます。accountのコントローラとビューを作成します。コントローラの方はこんな感じ。</p>
<pre class="brush: ruby;">
def index
  @accounts = Account.find(:all)
  respond_to do |format|
    format.html # index.html.erb
    format.xml  { render <img src='http://htakeuchi.offtheball.jp/wp-includes/images/smilies/icon_mad.gif' alt=':x' class='wp-smiley' /> ml =&gt; @accounts }
  end
end
</pre>
<p>ビュー(index.html.erb)はこんな感じ。</p>
<pre class="brush: xml;">
&lt;h1&gt;取引先一覧&lt;/h1&gt;

&lt;table&gt;
  &lt;tr&gt;
    &lt;th&gt;取引先番号&lt;/th&gt;
    &lt;th&gt;取引先名&lt;/th&gt;
    &lt;th&gt;住所(請求先)&lt;/th&gt;
    &lt;th&gt;電話&lt;/th&gt;
    &lt;th&gt;Fax&lt;/th&gt;
    &lt;th&gt;説明&lt;/th&gt;
  &lt;/tr&gt;

&lt;% for account in @accounts %&gt;
  &lt;tr&gt;
    &lt;td&gt;&lt;%=h account.account_number %&gt;&lt;/td&gt;
    &lt;td&gt;&lt;%=h account.name %&gt;&lt;/td&gt;
    &lt;td&gt;
        &lt;%=h account.billing_postal_code %&gt;
        &lt;%=h account.billing_state %&gt;
        &lt;%=h account.billing_city %&gt;
        &lt;%=h account.billing_street %&gt;
    &lt;/td&gt;
    &lt;td&gt;&lt;%=h account.phone %&gt;&lt;/td&gt;
    &lt;td&gt;&lt;%=h account.fax %&gt;&lt;/td&gt;
    &lt;td&gt;&lt;%=h account.description %&gt;&lt;/td&gt;
  &lt;/tr&gt;
&lt;% end %&gt;
&lt;/table&gt;
</pre>
<p>http://localhost:3000/accountsへアクセスしたらこんな感じに。</p>
<p>
<img src="http://htakeuchi.offtheball.jp/wp-content/uploads/2008/09/account1.jpg" width="480" height="335" alt="account.png" />
</p>
<p>
うん、普通にRailsアプリですね。とは言え、Salesforceのスキーマを知らないと何もできません。
</p>
<p>
Salesforceのスキーマは<a href="http://www.salesforce.com/us/developer/docs/api/index.htm">Force.com Web Services API Developer&#8217;s Guide</a>のReference &#8211; Standard Objectsから参照可能です。</p>
<p>なお、RailsからSalesforceのデータへアクセスする場合、メンバ名を以下のように読み替える必要がありますのでご注意。</p>
<table>
<tr>
<th>Filed Name(ドキュメントの表記)</th>
<th>Railsのメンバ名</th>
</tr>
<tr>
<td>BillingPostalCode</td>
<td>billing_postal_code</td>
</tr>
</table>
<p>
Salesforceを導入するような企業は既に基幹システムを持っているケースも多いと思います。
</p>
<p>
その場合、Force.com APIを使ってAjaxリクエストでデータを取得したり、バッチを開発したりして既存システムとSalesforceのデータ連係を実現する方法が主流だと思いますが、ActiveSalesforce + Railsという構成で、Railsの生産性の高さを生かしたSalesforce連携システム開発というのも可能性を感じます。
</p>
<p>
Salesforceに関しては標準のカスタマイズの他に、システム間連携の開発も可能です。そのような案件がありましたら、ぜひご相談ください。<a href="http://htakeuchi.offtheball.jp/?page_id=4">連絡先はこちら</a>です。</p>
]]></content:encoded>
			<wfw:commentRss>http://htakeuchi.offtheball.jp/archives/18/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
