SharePoint2010QuickFlow安装及使用


一:QuickFlow的安装

1,从http://quickflow.codeplex.com/下载解决方案包以及设计器。

2,将QuickFlow.dll以及QuickFlow.UI.dll添加到程序集引用。

3,将QuickFlow2010.wsp部署到站点上并激活。

4,创建一个任务列表,用来存储工作流运行后的历史。

二:QuickFlow的使用

1,发布工作流;

选择File—Publish to SharePoint—

2,创建变量;

3,给变量赋值;

在开始节点的AfterRule里面给该变量赋值

4,搜集了一些工作流中常用到的代码。

//获取列表项的Id
string itemId =this.GetVariable("ListitemID").ToString();
//获取列表
SPList cfgList = this.Web.Lists["项目备案信息"];
//获取一条数据
var cfgItem = cfgList.GetItemById(Convert.ToInt32(itemId));
//给申请人变量赋值                                  
SPFieldUserValue ProjectUser= cfgItem.Fields.GetField("ProjectUser").GetFieldValue(cfgItem["ProjectUser"].ToString()) as SPFieldUserValue;
//this.SetVariable("人员", ProjectUser.User.LoginName);
//给项目区域赋值
SPFieldLookupValue proprovince=cfgItem.Fields.GetField("ProjectProvince").GetFieldValue(cfgItem["ProjectProvince"].ToString()) as SPFieldLookupValue ;
this.SetVariable("项目区域",proprovince.LookupValue);
//给项目大区赋值
SPFieldLookupValue probigZone=cfgItem.Fields.GetField("BigZone").GetFieldValue(cfgItem["BigZone"].ToString()) as SPFieldLookupValue ;
this.SetVariable("项目大区",probigZone.LookupValue);
//给项目战区赋值
SPFieldLookupValue proWarZone=cfgItem.Fields.GetField("WarZone").GetFieldValue(cfgItem["WarZone"].ToString()) as SPFieldLookupValue ;
this.SetVariable("项目战区",proWarZone.LookupValue);

//到员工信息表中查询总经理
QueryField qfloginname=new QueryField("LoginName");
QueryField headManager=new QueryField("Role");

SPList cfgListEmploy = this.Web.Lists["员工信息"];
//获取一条数据
SPListItemCollection cfgItemhead=ListQuery.From(cfgListEmploy).Where(headManager=="总经理").GetItems();

if(cfgItemhead.Count>0)
{
this.SetVariable("总经理",cfgItemhead[0]["LoginName"]);
}


//获取一条数据
var cfgItemEmploy = ListQuery.From(cfgListEmploy).Where(qfloginname==ProjectUser.User.LoginName).GetItems()[0];
if(cfgItemEmploy!=null)
{


this.SetVariable("人员",cfgItemEmploy["Title"]);


//给人员区域赋值
SPFieldLookupValue provinceEmploy=cfgItemEmploy.Fields.GetField("Province").GetFieldValue(cfgItemEmploy["Province"].ToString()) as SPFieldLookupValue;
this.SetVariable("人员区域",provinceEmploy.LookupValue);


//给人员大区赋值
SPFieldLookupValue BigZoneEmploy=cfgItemEmploy.Fields.GetField("BigZone").GetFieldValue(cfgItemEmploy["BigZone"].ToString()) as SPFieldLookupValue;
this.SetVariable("人员大区",BigZoneEmploy.LookupValue);

//给人员战区赋值
SPFieldLookupValue WarZoneEmploy=cfgItemEmploy.Fields.GetField("WarZone").GetFieldValue(cfgItemEmploy["WarZone"].ToString()) as SPFieldLookupValue;
this.SetVariable("人员战区",WarZoneEmploy.LookupValue);
//给申请人上级经理赋值
SPFieldUserValue TopManager= cfgItemEmploy.Fields.GetField("Manager").GetFieldValue(cfgItemEmploy["Manager"].ToString()) as SPFieldUserValue;
this.SetVariable("申请人上级经理", TopManager.User.LoginName);

//到大区表中查询数据
SPList cfgListBigZone = this.Web.Lists["大区"];
//获取一条数据

var cfgItemUserBigZone = cfgListBigZone.GetItemById(BigZoneEmploy.LookupId);
var cfgItemProBigZone = cfgListBigZone.GetItemById(probigZone.LookupId);
//给申请人大区经理赋值
if(cfgItemUserBigZone!=null)
{
SPFieldUserValue UserBigZoneManager= cfgItemUserBigZone.Fields.GetField("Manager").GetFieldValue(cfgItemUserBigZone["Manager"].ToString()) as SPFieldUserValue;
this.SetVariable("申请人大区经理",UserBigZoneManager.User.LoginName);


}
//给项目大区经理赋值
if(cfgItemProBigZone!=null)
{
SPFieldUserValue ProBigZoneManager= cfgItemProBigZone.Fields.GetField("Manager").GetFieldValue(cfgItemProBigZone["Manager"].ToString()) as SPFieldUserValue;
this.SetVariable("项目大区经理", ProBigZoneManager.User.LoginName);


}
//到战区表中查询数据
SPList cfgListwarZone = this.Web.Lists["战区"];

//获取一条数据
var cfgItemUserWarZone=cfgListwarZone.GetItemById(WarZoneEmploy.LookupId);
var cfgItemProWarZone=cfgListwarZone.GetItemById(proWarZone.LookupId);

if(cfgItemUserWarZone!=null)
{
//给申请人战区经理赋值
SPFieldUserValue UserWarZoneManager= cfgItemUserWarZone.Fields.GetField("Manager").GetFieldValue(cfgItemUserWarZone["Manager"].ToString()) as SPFieldUserValue;
this.SetVariable("申请人战区经理", UserWarZoneManager.User.LoginName);
}
if(cfgItemProWarZone!=null)
{
//给项目战区经理赋值
SPFieldUserValue ProWarZoneManager= cfgItemProWarZone.Fields.GetField("Manager").GetFieldValue(cfgItemProWarZone["Manager"].ToString()) as SPFieldUserValue;
this.SetVariable("项目战区经理", ProWarZoneManager.User.LoginName);
}

}


 

posted @ 2014-03-27 14:08  美酒与歌  阅读(333)  评论(0编辑  收藏  举报