Thursday, 24 July 2014

Asp.Net with K2 Black Pearl Start New Process

using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
// Add DLL from this path: C:\WINDOWS\assembly\GAC_32\SourceCode.Workflow.Client\4.0.0.0__16a2c5aaaa1b130d\SourceCode.Workflow.Client.dll
using SourceCode.Workflow.Client;
namespace WebApplication2.AllCommon
{
public partial class WebForm1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
Label1.Text = Request.ServerVariables["LOGON_USER"].ToString();
}
protected void btn_Click(object sender, EventArgs e)
{
Connection k2Conn = new Connection();
try
{
k2Conn.Open("DLX");
ProcessInstance pi = k2Conn.CreateProcessInstance("SAPIDRequestSystem\\SAPID");
#region Bind Data Fields from Form Data
pi.DataFields["SAPStatus"].Value = Label1.Text;
pi.Folio = "SQLStar" + System.DateTime.Now;
#endregion
k2Conn.StartProcessInstance(pi);
Label1.Text = "Success";
}
catch (Exception exception)
{
Response.Write("Error: " + exception.Message);
}
finally
{
k2Conn.Close();
}
}
}
}
view raw gistfile1.cs hosted with ❤ by GitHub