using System;
using System.Collections.Generic;
using System.Collections;
using System.Data;
using System.Web;
namespace CCFlow.SDKFlowDemo
{
///
/// WindowsFormsApplicationDemo1 的摘要说明
///
public class WindowsFormsApplicationDemo1 : IHttpHandler
{
#region 变量.
public HttpContext context = null;
public string DoType
{
get
{
return context.Request.QueryString["DoType"];
}
}
public string FK_Flow
{
get
{
return context.Request.QueryString["FK_Flow"];
}
}
public Int64 WorkID
{
get
{
return Int64.Parse( context.Request.QueryString["WorkID"]);
}
}
public int FK_Node
{
get
{
return int.Parse(context.Request.QueryString["FK_Node"]);
}
}
public string ToEmps
{
get
{
return context.Request.QueryString["ToEmps"];
}
}
public int ToNodeID
{
get
{
return int.Parse(context.Request.QueryString["ToNodeID"]);
}
}
///
/// 当前节点ID
///
public int CurrentNodeID
{
get
{
return int.Parse(context.Request.QueryString["CurrentNodeID"]);
}
}
public string Msg
{
get
{
return context.Request.QueryString["Msg"];
}
}
public string UserNo
{
get
{
return context.Request.QueryString["UserNo"];
}
}
#endregion 变量.
public void ProcessRequest(HttpContext con)
{
context = con;
if (BP.Web.WebUser.No != UserNo)
BP.WF.Dev2Interface.Port_Login(UserNo);
try
{
string info = "";
switch (this.DoType)
{
case "StartFlows": //获得发起列表. 形成菜单内容.
info = StartFlows(this.UserNo);
break;
case "Todolist": //代办列表. 形成菜单内容.
info = Todolist(this.UserNo);
break;
case "Runing": //在途列表. 形成菜单内容.
info = Runing(this.UserNo);
break;
case "CreateBlankWork": //创建工作ID.
info = CreateBlankWork(this.FK_Flow, this.UserNo).ToString();
break;
case "SendWork": //执行发送ID.
info = SendWork(this.FK_Flow, this.WorkID, this.ToNodeID, this.ToEmps, null).ToString();
break;
case "GenerWorkNode": //获得WorkNode. 用于初始化工作处理器信息.
info = GenerWorkNode();
break;
case "GenerWillReturnNodes": //获得可以退回的节点.
info = GenerWillReturnNodes();
break;
case "ReturnWork": //执行退回.
info = ReturnWork(this.UserNo, this.WorkID, this.CurrentNodeID,
this.ToNodeID, this.Msg, false).ToString();
break;
default:
info = "err@" + this.DoType;
break;
}
context.Response.ContentType = "text/plain";
context.Response.Write(info);
// BP.Tools.Json.ToDataTable(
}
catch (Exception ex)
{
context.Response.ContentType = "text/plain";
context.Response.Write("err@" + ex.Message);
}
}
#region 工作处理.
///
/// 创建workid.
///
/// 流程编号
/// 人员编号
/// 该流程的一个空白的workid.
public Int64 CreateBlankWork(string flowNo, string userNo)
{
if (BP.Web.WebUser.No != userNo)
BP.WF.Dev2Interface.Port_Login(userNo);
return BP.WF.Dev2Interface.Node_CreateBlankWork(flowNo);
}
///
/// 工作发送
///
/// 流程编号
/// 工作ID
/// 到达的节点,可以为0
/// 到达的人员,可以为null
/// 相关参数,可以为null
/// 发送结果
public string SendWork(string flowNo, Int64 workid, int toNodeID, string toEmps, Hashtable ht)
{
return BP.WF.Dev2Interface.Node_SendWork(flowNo, workid, ht, toNodeID, toEmps).ToMsgOfText();
}
///
/// 获得一个工作节点.
///
///
public string GenerWorkNode()
{
// BP.WF.HttpHandler.WF_MyFlow myflow = new BP.WF.HttpHandler.WF_MyFlow( HttpContext.context);
//return myflow.GenerWorkNode();
return null;
}
#endregion 工作处理.
#region 退回窗口。
///
/// 退回
///
/// 用户
/// 流程编号
/// 工作ID
/// 当前节点ID
/// 退回到
/// 退回消息
/// 是否原路返回
/// 执行结果
public string ReturnWork(string flowNo, Int64 workid, int currentNodeID, int returnToNodeID,
string msg, bool isBackToThisNode = false)
{
return BP.WF.Dev2Interface.Node_ReturnWork(flowNo, workid, 0, currentNodeID, returnToNodeID, msg, isBackToThisNode);
}
///
/// 获得可以退回的节点
///
///
public string GenerWillReturnNodes()
{
DataTable dt= BP.WF.Dev2Interface.DB_GenerWillReturnNodes(this.FK_Node,this.WorkID,0);
return BP.Tools.Json.ToJson(dt);
}
#endregion 退回窗口。
#region 三大菜单.
///
/// 获得发起列表.
///
///
///
public string StartFlows(string userNo)
{
DataTable dt= BP.WF.Dev2Interface.DB_StarFlows(userNo);
return BP.Tools.Json.ToJson(dt);
}
///
/// 获得待办
///
///
///
public string Todolist(string userNo)
{
DataTable dt = BP.WF.Dev2Interface.DB_Todolist(userNo);
return BP.Tools.Json.ToJson(dt);
}
///
/// 在途
///
///
///
public string Runing(string userNo)
{
DataTable dt = BP.WF.Dev2Interface.DB_GenerRuning(userNo);
return BP.Tools.Json.ToJson(dt);
}
#endregion 三大菜单.
public bool IsReusable
{
get
{
return false;
}
}
}
}