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; }
//获取一个模型的详情信息
//获取一个模型的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(); } (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |