<br/><br/>SELECT * <br/>FROM [dbo].[BPMInstTasks]<br/>WHERE ProcessName='ICN'<br/>AND State='Deleted'<br/><br/>declare @TaskID INT <br/>SET @TaskID=12361<br/><br/>--SELECT StepID FROM [dbo].[BPMInstProcSteps] WHERE TaskID = @TaskID<br/><br/>--Snapshot<br/>DELETE FROM [dbo].[BPMSysSnapshot] WHERE TaskID = @TaskID<br/>--Security<br/>DELETE FROM [dbo].[BPMSecurityTACL] WHERE TaskID = @TaskID<br/>--TaskStepLinks<br/>DELETE FROM [dbo].[BPMInstTaskStepLinks] WHERE TaskID = @TaskID<br/>--Tasks<br/>DELETE FROM [dbo].[BPMInstTasks] WHERE TaskID = @TaskID<br/>--Share Tasks<br/>DELETE FROM [dbo].[BPMInstShare] WHERE StepID IN (SELECT StepID FROM [dbo].[BPMInstProcSteps] WHERE TaskID = @TaskID)<br/>--Task Steps<br/>DELETE FROM [dbo].[BPMInstProcSteps] WHERE TaskID = @TaskID<br/>--Routing<br/>DELETE FROM [dbo].[BPMInstRouting] WHERE TaskID = @TaskID<br/>--Links in Email<br/>DELETE FROM [dbo].[BPMInstClickToProcessQuery] WHERE TaskID = @TaskID<br/>
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"]));
}
}
}
今天在测试开发的一个流程时,当走到一步叫做“Patent Director of Engineering Approval”的步骤,死活报错:“String or binary data would be truncated”,按照这个错误提示,通常来讲这个错误是数据库的表字段长度太短,而添加到此字段的字符长度超过本身定义的长度而造成的。经过不停的调试修改当前步骤涉及到的字段,始终不得解决,反而还造成了流程进入到一个“空白区”,卡在了2个步骤中间,后来只能通过后台修改表BPMInstProcSteps的FinishAt为Null,为避免此问题再次发生,在咨询官方技术人员后,还修改了服务器上的server.config中DTC的设定,开启了事务支持。
附上手工修正的SQL语句:
Update [BPMDB].[dbo].[BPMInstProcSteps] Set FinishAt=Null Where StepID=26403
第一个要分享的是获取当前的申请状态以及当前的处理人,虽然我们很容易通过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即可。