Taylohtio/AlertManager/SPSolutions.SharePoint.Aler.../SPSolutions.SharePoint/SPSolutions.SharePoint.Work.../WorkflowAssociationInputs.cs

106 lines
4.6 KiB
C#

using Microsoft.SharePoint.Utilities;
using System;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace SPSolutions.SharePoint.Workflow.WebControls
{
public class WorkflowAssociationInputs : WebControl
{
private SPWorkflowAssociationParameters _workflowAssociationParameters = new SPWorkflowAssociationParameters();
public SPWorkflowAssociationParameters Parameters
{
get
{
return this._workflowAssociationParameters;
}
set
{
this._workflowAssociationParameters = value;
}
}
protected override void Render(HtmlTextWriter writer)
{
this.WriteInputTag(writer, "WorkflowDefinition", this._workflowAssociationParameters.WorkflowDefinition);
this.WriteInputTag(writer, "WorkflowName", this._workflowAssociationParameters.WorkflowName);
this.WriteInputTag(writer, "AddToStatusMenu", this._workflowAssociationParameters.AddToStatusMenu);
this.WriteInputTag(writer, "AllowManual", this._workflowAssociationParameters.AllowManual);
this.WriteInputTag(writer, "RoleSelect", this._workflowAssociationParameters.RoleSelect);
this.WriteInputTag(writer, "GuidAssoc", this._workflowAssociationParameters.GuidAssociation);
this.WriteInputTag(writer, "SetDefault", this._workflowAssociationParameters.SetDefault);
this.WriteInputTag(writer, "HistoryList", this._workflowAssociationParameters.HistoryList);
this.WriteInputTag(writer, "TaskList", this._workflowAssociationParameters.TaskList);
this.WriteInputTag(writer, "UpdateLists", this._workflowAssociationParameters.UpdateLists);
this.WriteInputTag(writer, "AutoStartCreate", this._workflowAssociationParameters.AutoStartCreate);
this.WriteInputTag(writer, "AutoStartChange", this._workflowAssociationParameters.AutoStartChange);
}
private void WriteInputTag(HtmlTextWriter writer, string name, string value)
{
string value2 = SPHttpUtility.HtmlEncode(value);
writer.AddAttribute("type", "hidden");
writer.AddAttribute("name", name);
writer.AddAttribute("value", value2);
writer.RenderBeginTag("input");
writer.RenderEndTag();
writer.WriteLine();
}
private void WriteInputTag(HtmlTextWriter writer, string name, bool value)
{
this.WriteInputTag(writer, name, this.BooleanToOnOff(value));
}
public static SPWorkflowAssociationParameters CreateWorkflowAssociationParametersFromAssocRequest(HttpRequest request)
{
return new SPWorkflowAssociationParameters
{
List = request.QueryString["List"],
ContentType = request.QueryString["ctype"],
WorkflowDefinition = request.Form["WorkflowDefinition"],
WorkflowName = request.Form["WorkflowName"],
AddToStatusMenu = request.Form["AddToStatusMenu"],
AllowManual = WorkflowAssociationInputs.OnOffToBoolean(request.Form["AllowManual"]),
RoleSelect = request.Form["RoleSelect"],
GuidAssociation = request.Form["GuidAssoc"],
SetDefault = WorkflowAssociationInputs.OnOffToBoolean(request.Form["SetDefault"]),
HistoryList = request.Form["HistoryList"],
TaskList = request.Form["TaskList"],
UpdateLists = WorkflowAssociationInputs.OnOffToBoolean(request.Form["UpdateLists"]),
AutoStartCreate = WorkflowAssociationInputs.OnOffToBoolean(request.Form["AutoStartCreate"]),
AutoStartChange = WorkflowAssociationInputs.OnOffToBoolean(request.Form["AutoStartChange"])
};
}
public static SPWorkflowAssociationParameters CreateWorkflowAssociationParametersFromIntRequest(HttpRequest request)
{
return new SPWorkflowAssociationParameters
{
List = request.QueryString["List"],
ContentType = request.QueryString["ctype"],
ID = request.QueryString["ID"],
TemplateId = request.QueryString["TemplateID"],
WorkflowDefinition = request.Form["WorkflowDefinition"],
WorkflowName = request.Form["WorkflowName"],
AddToStatusMenu = request.Form["AddToStatusMenu"],
AllowManual = WorkflowAssociationInputs.OnOffToBoolean(request.Form["AllowManual"]),
RoleSelect = request.Form["RoleSelect"],
SetDefault = WorkflowAssociationInputs.OnOffToBoolean(request.Form["SetDefault"]),
HistoryList = request.Form["HistoryList"],
TaskList = request.Form["TaskList"],
UpdateLists = WorkflowAssociationInputs.OnOffToBoolean(request.Form["UpdateLists"]),
AutoStartCreate = WorkflowAssociationInputs.OnOffToBoolean(request.Form["AutoStartCreate"]),
AutoStartChange = WorkflowAssociationInputs.OnOffToBoolean(request.Form["AutoStartChange"])
};
}
private static bool OnOffToBoolean(string value)
{
return string.Compare(value, "on", true) == 0;
}
private string BooleanToOnOff(bool value)
{
if (value)
{
return "ON";
}
return "";
}
}
}