2008年12月 のアーカイブ

SharePointワークフロー起動オプションの問題

SharePointワークフロー起動オプションの問題をはてなブックマークに追加 SharePointワークフロー起動オプションの問題をdel.icio.usに追加 Yahoo!ブックマークに登録 SharePointワークフロー起動オプションの問題をGoogle Bookmarksに追加

2008年12月30日 火曜日
今年最後のネタはSharePointネタです。SharePointでワークフローをライブラリに適用する際に、
自分でワークフローを起動する。
アイテムが新規投稿されたときに起動する。
アイテムが編集されたときに起動する。
という起動オプションがあるのですが、3番目の「アイテムが編集されたときに起動する」というオプションはユーザに気付かせずにワークフローを裏で動かすために便利なのですが、なかなか扱いづらいものでして、

アイテムが編集される。
ワークフローが起動される。
ワークフローにてアイテムに編集をかける。
アイテムが編集されたのでさらにワークフローが起動される。(延々とループ)
・・・・
というかなり斬新な仕様になってます。で、いろいろ困って検索していましたら、こんな対応方法がありましたので紹介してみます。
動かしてみたら、確かにワークフローインスタンスがパカパカつくられた形跡はなく、うまく動くようでした。

using System;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.Collections;
using System.Drawing;
using System.Workflow.ComponentModel.Compiler;
using System.Workflow.ComponentModel.Serialization;
using System.Workflow.ComponentModel;
using System.Workflow.ComponentModel.Design;
using System.Workflow.Runtime;
using System.Workflow.Activities;
using System.Workflow.Activities.Rules;
using System.Xml.Serialization;
using System.Xml;
using Microsoft.SharePoint;
using Microsoft.SharePoint.WorkflowActions;
using System.Collections.Generic;
using System.Text;
using System.Reflection;
/// provides access to the internal Microsoft.SharePoint.SPEventManager class by using reflection
/// sample usage:
/// SPEventManagerWrapper.DisableEventFiring();
/// SPList myList = SPContext.Current.Web.Lists["Shared Documents"];
/// myList.Items[0].Update();
/// SPEventManagerWrapper.EnableEventFiring();
namespace setDraftWorkflow
{
public static class SPEventManagerWrapper
{
private static readonly string _className = "Microsoft.SharePoint.SPEventManager";
private static readonly string _eventFiringSwitchName = "EventFiringDisabled";
private static Type _eventManagerType;
/// gets the status of event firing on the current thread
public static bool EventFiringDisabled
{
get { return GetEventFiringSwitchValue(); }
}
private static Type EventManagerType
{
get
{
if (_eventManagerType == null)
GetEventManagerType();
return _eventManagerType;
}
}
/// enables event firing on the current thread
public static void EnableEventFiring()
{
SetEventFiringSwitch(false);
}
/// disables sharepoint event firing on the current thread
public static void DisableEventFiring()
{
SetEventFiringSwitch(true);
}
/// sets the event firing switch on Microsoft.SharePoint.SPEventManager class using reflection
private static void SetEventFiringSwitch(bool value)
{
PropertyInfo pi = EventManagerType.GetProperty(_eventFiringSwitchName, System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.NonPublic);
pi.SetValue(null, value, null);
}
private static bool GetEventFiringSwitchValue()
{
PropertyInfo pi = EventManagerType.GetProperty(_eventFiringSwitchName, System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.NonPublic);
object val = pi.GetValue(null, null);
return (bool)val;
}
private static Type GetEventManagerType()
{
_eventManagerType = typeof(SPList).Assembly.GetType(_className, true);
return _eventManagerType;
}
}
public sealed partial class Workflow1: SequentialWorkflowActivity
{
public Workflow1()
{
InitializeComponent();
}
public Guid workflowId = default(System.Guid);
public Microsoft.SharePoint.Workflow.SPWorkflowActivationProperties workflowProperties = new Microsoft.SharePoint.Workflow.SPWorkflowActivationProperties();
private void onWorkflowActivated1_Invoked(object sender, ExternalDataEventArgs e)
{
SPListItem activator = workflowProperties.Item;
// なんか自アイテムを編集する。
SPEventManagerWrapper.DisableEventFiring();
activator.Update();
SPEventManagerWrapper.EnableEventFiring();
}
}
}

アボカドのディップつくった

アボカドのディップつくったをはてなブックマークに追加 アボカドのディップつくったをdel.icio.usに追加 Yahoo!ブックマークに登録 アボカドのディップつくったをGoogle Bookmarksに追加

2008年12月25日 木曜日
DSCF3188.JPG
海老名のショッパーズプラザでおつとめ品アボカドが3個で100円で売ってたのでディップにしてサラダにしました。水菜をぎゅっとまとめてトマトで縁取りしてサーモンを盛ってみました。ディップはちゃんとした作り方知らないんですけど、牛乳とパルメザンチーズに塩をまぜて味を付けてみました。意外とうまく出来た。アボカドって熟してからすぐ食べないと色も悪いわ味も落ちるわだけどディップにすればごまかせるね

428を12:00まで進めた

428を12:00まで進めたをはてなブックマークに追加 428を12:00まで進めたをdel.icio.usに追加 Yahoo!ブックマークに登録 428を12:00まで進めたをGoogle Bookmarksに追加

2008年12月25日 木曜日
428を12:00まで進めた。

・亜智とひとみが逃げて回って
・タマが着ぐるみ脱げなくなって弁当食われる
・加納が婚約者のオヤジと犯人グループに翻弄されて
・御法川がなんか出版社のしゃっちょさんを自殺直前で助けて
・大沢賢治はひとみのオヤジでウィルス研究者だってわかったくらい

物語自体はあまり進んでない。ウィルス学者が出てきてるからこれからウィルスパニックとかになるのかな?なんかそんな感じに話が進んでないんだけど。
で、進行具合はいいとして、田中要次がタクシーの運転手で出てきた。田中要次といえばドラマHEROの「あるよ」の人である。すごいな。あとは、なすびがタマの雇い主として出てきた。キモ懐かしい。なんだキモ懐かしいって。あと、御法川が始めユースケサンタマリアかと思ったら違った。なんか似てる。キャラクターとして似てるのかもしれない。加納慎也は和泉元彌かと思った。わない。今日はこんくらいにして寝る。メリークリスマス(明日枕元に3億円くらい置いてありますように☆)