Server-side

Server-side


To process server operations must be routing out in the method of requests: WorkflowInit.Runtime.DesignerAPI.

Example for ASP.NET MVC:

public ActionResult API()
{
    Stream filestream = null;
    if (Request.Files.Count > 0)
        filestream = Request.Files[0].InputStream;

    var pars = new NameValueCollection();
    pars.Add(Request.Params);
    
    if(Request.HttpMethod.Equals("POST", StringComparison.InvariantCultureIgnoreCase))
    {
        var parsKeys = pars.AllKeys;
        foreach (var key in Request.Form.AllKeys)
        {
            if (!parsKeys.Contains(key))
            {
                pars.Add(Request.Form);
            }
        }
    }

    var res = WorkflowInit.Runtime.DesignerAPI(pars, filestream, true);
    if (pars["operation"].ToLower() == "downloadscheme")
        return File(UTF8Encoding.UTF8.GetBytes(res), "text/xml", "scheme.xml");
    return Content(res);
}


Example for ASP.NET WebForms

public class WFEDesigner : IHttpHandler
{

    public void ProcessRequest(HttpContext context)
    {
        Stream filestream = null;
        if (context.Request.Files.Count > 0)
            filestream = context.Request.Files[0].InputStream;

        var pars = new NameValueCollection();
        pars.Add(context.Request.Params);

        if (context.Request.HttpMethod.Equals("POST", StringComparison.InvariantCultureIgnoreCase))
        {
            var parsKeys = pars.AllKeys;
            foreach (var key in context.Request.Form.AllKeys)
            {
                if (!parsKeys.Contains(key))
                {
                    pars.Add(key, context.Request.Form[key]);
                }
            }
        }

        var res = WorkflowInit.Runtime.DesignerAPI(pars, filestream, true);
        if (pars["operation"].ToLower() == "downloadscheme")
        {
            context.Response.ContentType = "file/xml";
            context.Response.AddHeader("Content-Disposition", "attachment; filename=schema.xml");
            context.Response.BinaryWrite(UTF8Encoding.UTF8.GetBytes(res));
            context.Response.End();
        }
        else
        {
            context.Response.Write(res);
            context.Response.End();
        }
    }

    public bool IsReusable
    {
        get
        {
            return false;
        }
    }
}

Type of server operations is defined in the parameter "operation":

  • load
  • save
  • uploadscheme
  • downloadscheme
  • exists