private void RMA_WarehouseRC_AutoPickupAndApprove()
{
GlobalFunction gf = new GlobalFunction();
//Sql - Get the BPM Request list
string strsql = "SELECT *";
strsql += " FROM dbo.BPMInstProcSteps";
strsql += " where ProcessName = N'RMA' and NodeName = N'Warehouse RC' and FinishAt is null";
//Share Task
strsql += " and Share=1";
//Not Picked up
strsql += " and OwnerAccount is Null";
strsql += " Order by TaskID Asc";
//Search the BPMDB
SqlConnection connBPMDB = new SqlConnection(ConfigurationManager.ConnectionStrings["BPMDBConnectionString"].ConnectionString);
SqlCommand mycmd = new SqlCommand(strsql, connBPMDB);
mycmd.CommandType = CommandType.Text;
connBPMDB.Open();
//SqlDataReader drtemp = mycmd.ExecuteReader();
SqlDataAdapter da = new SqlDataAdapter();
DataSet ds = new DataSet();
da.SelectCommand = mycmd;
da.Fill(ds);
DataTable dt = new DataTable();
dt = ds.Tables[0];
connBPMDB.Close();
for (int i = 0; i < dt.Rows.Count; i++)
{
//Get the Warehouse Receivied Status from ERP LN
//This update using MSSQL job to update the data
//Database: WAIBPM
//Table: FormRMA
//Data field: WarehouseReceived
//Pickup and approve
if (gf.testread("Select ID from FormRMA where WarehouseReceived = N'Yes' and TaskID= " + Convert.ToInt32(dt.Rows[i]["TaskID"]) + ""))
{
PickupShareTaskandApprove(Convert.ToInt32(dt.Rows[i]["StepID"]));
}
//Pickup only
else
{
PickupShareTask(Convert.ToInt32(dt.Rows[i]["StepID"]));
}
}
}
第一个要分享的是获取当前的申请状态以及当前的处理人,虽然我们很容易通过BPMInstProcSteps这张表找到FinishAt is Null的记录,但是如果直接用2表的关联查询会有并行流程的问题,另外当你把自己的申请数据独立开来,做跨数据的关联就有些不直观,索性写一个函数GetBPMCurrentStep(@TaskID),使用方法很简单,直接在自己的视图里面使用就行。
USE [WAIWorkflow]
GO
/****** Object: UserDefinedFunction [dbo].[GetBPMCurrentStep] Script Date: 05/24/2011 14:34:50 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE FUNCTION [dbo].[GetBPMCurrentStep](@TaskID nvarchar(50))
RETURNS nvarchar(Max)
AS
BEGIN
DECLARE @r nvarchar(Max)
SET @r = ''
SELECT @r = @r + ',' + NodeName + '('+ OwnerAccount+')'
FROM [BPMDB].[dbo].[BPMInstProcSteps]
WHERE TaskID=@TaskID
AND [FinishAt] is null
RETURN STUFF(@r, 1, 1, '')
END
1、AD集成方面一定要注意IIS里面的Directory Security的验证方式要选择“Integrated Windows Authentication”。同时,Flowportal安装目录下的Server.config要修改如下:如果要取消网页认证的话,把WebLoginEnable修改成False即可。