Activiti模型详情获取,模型XML获取

前端之家收集整理的这篇文章主要介绍了Activiti模型详情获取,模型XML获取前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
//上传XML文件到部署中
[Ajax(Login = true)]
public JObject UpLoadDeploymentXMLFile(SyncContext syncContext)
{
syncContext.Response.ContentType = "text/html;charset=UTF-8";
HttpPostedFile file = syncContext.Request.Files["uploadFile"];
var filename = file.FileName;
var url = "http://192.168.3.20:8080/WF/openapi/deployXml.do?filename={0}";
url = string.Format(url,filename);
var request = WebRequest.Create(url) as HttpWebRequest;
//请求参数
request.Accept = "application/json";
request.Method = "POST";
request.UserAgent =
"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; SV1; .NET CLR 1.1.4322; .NET CLR 2.0.50727)";
// request.ContentType = "text/plain:charset=utf-8";
request.CookieContainer = new CookieContainer();
//获取响应对象
var response = request.GetResponse() as HttpWebResponse;
var stream = response.GetResponseStream();
var sr = new StreamReader(stream,Encoding.UTF8);
var msg = (JObject)JsonConvert.DeserializeObject(sr.ReadToEnd());
return msg;

}



//获取一个模型的详情信息
[Ajax(Login = true)]
public JObject ExistModelFile(int modelId,SyncContext syncContext)
{
var method = "repository/models/{modelId}";
var api = new WFOperator(syncContext.Context);
var result = api.Call(Method.GET,method,new Dictionary<string,object>
{
{"modelId",modelId}
});
return JObject.Parse(result.Content);
}


//获取一个模型的XML文件 [Ajax(Login = true)] public void QueryModelXml(int modelId,string name,SyncContext syncContext) { var url = "http://192.168.3.20:8080/WF/openapi/export.do?modelId={0}"; url = string.Format(url,modelId); var request = WebRequest.Create(url) as HttpWebRequest; request.Method = "GET"; request.Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8"; request.Connection = "keep=alive"; request.UserAgent = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; SV1; .NET CLR 1.1.4322; .NET CLR 2.0.50727)"; request.CookieContainer=new CookieContainer(); var response = request.GetResponse() as HttpWebResponse; var stream = response.GetResponseStream(); var sr= new StreamReader(stream,Encoding.UTF8); var msg = sr.ReadToEnd(); var buffer = Encoding.UTF8.GetBytes(msg); name = string.Format("{0}.bpmn20.xml",name); syncContext.Response.Clear(); syncContext.Response.ContentType = "application/octet-stream"; syncContext.Response.AddHeader("Content-Disposition","attachment;filename=" + HttpUtility.UrlEncode(name)); syncContext.Response.AddHeader("Content-Length",buffer.Length.ToString(CultureInfo.InvariantCulture)); syncContext.Response.BinaryWrite(buffer); syncContext.Response.Flush(); }

猜你在找的XML相关文章