using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using DTK.MIS.Common;
using DTK.MIS.Entities;
using System.IO;
using Newtonsoft.Json;
using DTK.MIS.BLL;
namespace DTKMIS.Api
{
/// <summary>
/// WorkflowCallbackHandler 在办事项收回
/// </summary>
public class WorkflowCallbackHandler : IHttpHandler
{
public void ProcessRequest(HttpContext context)
{
context.Response.ContentType = "application/json";
ResultEntity entity = null;
WorkFlowSqEntity workflow = new WorkFlowSqEntity();
context.Response.Cache.SetCacheability(HttpCacheability.NoCache);
using (var reader = new StreamReader(context.Request.InputStream))
{
String postJson = reader.ReadToEnd();
entity = (ResultEntity)JsonConvert.DeserializeObject(postJson, typeof(ResultEntity));
}
//办理人编号
int UserId = 0;
//工作流编号
int SqId = 0;
// 工作节点顺序编号
int OrderId = 0;
if (context.Request.RequestType.ToLower() == "post")
{
if (entity == null)
{
return;
}
UserId = entity.UserId;
SqId = entity.SqId;
OrderId = entity.OrderID;
}
SetParameter para = new SetParameter();
para.state = 0;
para.msg = "操作失败";
//已处理的节点顺序
int AreadyOrder = OrderId + 1;
if (SqNodeBLL.DeleteBySqlIDAndOrderID(AreadyOrder, SqId))
{
if (SqNodeBLL.UpdateWhere(" NodeStatus=0", "SqID=" + SqId + " and OrderID=" + OrderId + ""))
{
if (SqNodeBLL.UpdateWhere(" Status=2,SpDate='" + DateTime.Now + "'", "SqID=" + SqId + " and OrderID=" + OrderId + " and BlPerson=" + UserId + ""))
{
para.state = 1;
para.msg = "操作成功";
}
else
{
para.state = 0;
para.msg = "操作失败";
}
}
}
string strJson = JsonConvert.SerializeObject(para);
context.Response.Write(strJson);
}
/// <summary>
/// POST请求参数
/// </summary>
public class ResultEntity
{
/// <summary>
/// 办理人
/// </summary>
public int UserId { get; set; }
/// <summary>
/// 工作流编号
/// </summary>
public int SqId { get; set; }
/// <summary>
/// 流程节点顺序
/// </summary>
public int OrderID { get; set; }
}
public class SetParameter
{
public int state;
public string msg;
}
public bool IsReusable
{
get
{
return false;
}
}
}
using System.Collections.Generic;
using System.Linq;
using System.Web;
using DTK.MIS.Common;
using DTK.MIS.Entities;
using System.IO;
using Newtonsoft.Json;
using DTK.MIS.BLL;
namespace DTKMIS.Api
{
/// <summary>
/// WorkflowCallbackHandler 在办事项收回
/// </summary>
public class WorkflowCallbackHandler : IHttpHandler
{
public void ProcessRequest(HttpContext context)
{
context.Response.ContentType = "application/json";
ResultEntity entity = null;
WorkFlowSqEntity workflow = new WorkFlowSqEntity();
context.Response.Cache.SetCacheability(HttpCacheability.NoCache);
using (var reader = new StreamReader(context.Request.InputStream))
{
String postJson = reader.ReadToEnd();
entity = (ResultEntity)JsonConvert.DeserializeObject(postJson, typeof(ResultEntity));
}
//办理人编号
int UserId = 0;
//工作流编号
int SqId = 0;
// 工作节点顺序编号
int OrderId = 0;
if (context.Request.RequestType.ToLower() == "post")
{
if (entity == null)
{
return;
}
UserId = entity.UserId;
SqId = entity.SqId;
OrderId = entity.OrderID;
}
SetParameter para = new SetParameter();
para.state = 0;
para.msg = "操作失败";
//已处理的节点顺序
int AreadyOrder = OrderId + 1;
if (SqNodeBLL.DeleteBySqlIDAndOrderID(AreadyOrder, SqId))
{
if (SqNodeBLL.UpdateWhere(" NodeStatus=0", "SqID=" + SqId + " and OrderID=" + OrderId + ""))
{
if (SqNodeBLL.UpdateWhere(" Status=2,SpDate='" + DateTime.Now + "'", "SqID=" + SqId + " and OrderID=" + OrderId + " and BlPerson=" + UserId + ""))
{
para.state = 1;
para.msg = "操作成功";
}
else
{
para.state = 0;
para.msg = "操作失败";
}
}
}
string strJson = JsonConvert.SerializeObject(para);
context.Response.Write(strJson);
}
/// <summary>
/// POST请求参数
/// </summary>
public class ResultEntity
{
/// <summary>
/// 办理人
/// </summary>
public int UserId { get; set; }
/// <summary>
/// 工作流编号
/// </summary>
public int SqId { get; set; }
/// <summary>
/// 流程节点顺序
/// </summary>
public int OrderID { get; set; }
}
public class SetParameter
{
public int state;
public string msg;
}
public bool IsReusable
{
get
{
return false;
}
}
}
}