public virtual object Start(HttpContext context) { YZRequest request = new YZRequest(context); Guid draftid = request.GetGuid("draftid", false); string memberfullname = request.GetString("memberfullname"); string uid = request.GetString("uid"); using (BPMConnection cn = new BPMConnection()) { string orguid = YZAuthHelper.LoginUserAccount; YZAuthHelper.SetAuthCookie(uid); try { cn.WebOpen(); } finally { YZAuthHelper.SetAuthCookie(orguid); } BPMDraft draft = new BPMDraft(); draft.Open(cn, draftid); JObject jDraftHeader = null; if (!String.IsNullOrEmpty(draft.Header)) { jDraftHeader = JObject.Parse(draft.Header); } PostInfo postInfo = BPMProcess.GetPostInfo(cn, draft.ProcessName, null, memberfullname, -1); if (postInfo.Links.Count == 0) { throw new BPMException(BPMExceptionType.MissOutLink, postInfo.NodeName); } string postXml = @"{0} <XForm> <Header> <Method>Post</Method> <ProcessName>{1}</ProcessName> <OwnerMemberFullName>{2}</OwnerMemberFullName> <Action>{3}</Action> <Comment>{4}</Comment> {5} </Header> {6} </XForm>"; StringBuilder sb = new StringBuilder(); if (jDraftHeader != null) { foreach (KeyValuePair <string, JToken> jProp in jDraftHeader) { string line = String.Format("<{0}>{1}</{0}>", jProp.Key, YZUtility.EncodeXMLInnerText(jProp.Value.ToString())); sb.AppendLine(line); } } postXml = String.Format(postXml, "<?xml version=\"1.0\"?>", YZUtility.EncodeXMLInnerText(draft.ProcessName), YZUtility.EncodeXMLInnerText(memberfullname), YZUtility.EncodeXMLInnerText(postInfo.Links[0].DisplayString), YZUtility.EncodeXMLInnerText(draft.Comments), sb.ToString(), draft.xml); using (MemoryStream postStream = new MemoryStream(Encoding.UTF8.GetBytes(postXml))) { PostResult postResult = BPMProcess.Post(cn, postStream); return(new { success = true, TaskID = postResult.TaskID, SN = postResult.SN }); } } }
public virtual JObject GetPostInfo(HttpContext context) { YZRequest request = new YZRequest(context); string processName = request.GetString("pn", null); int restartTaskID = request.GetInt32("restartTaskID", -1); string owner = request.GetString("owner", null); string permisions = request.GetString("Permisions", null); string did = request.GetString("did", null); Version processVersion = null; PostInfo postInfo; JObject perm; BPMDraft draft = null; JObject jDraftHeader = null; bool delagation; string selectPosition; MemberCollection positions; JObject rv = new JObject(); PostSubModel subModel; using (BPMConnection cn = new BPMConnection()) { cn.WebOpen(); if (!String.IsNullOrEmpty(did)) { draft = new BPMDraft(); draft.Open(cn, new Guid(did)); processName = draft.ProcessName; if (!String.IsNullOrEmpty(draft.Header)) { jDraftHeader = JObject.Parse(draft.Header); } } if (draft != null) { subModel = (PostSubModel)Enum.Parse(typeof(PostSubModel), draft.Type.ToString()); } else { subModel = PostSubModel.Post; } if (restartTaskID == -1) { processVersion = cn.GetGlobalObjectLastVersion(StoreZoneType.Process, processName); } postInfo = BPMProcess.GetPostInfo(cn, processName, processVersion, owner, restartTaskID); perm = this.CheckPermision(postInfo, permisions); //获得delagation/selectPosition if (draft != null) { selectPosition = PositionManager.MemberFullNameFromID(cn, draft.OwnerPositionID); delagation = !YZStringHelper.EquName(draft.OwnerAccount, cn.UID); } else { if (postInfo.IsPostByAgent) { delagation = true; selectPosition = owner; } else { delagation = false; selectPosition = owner; } } //获得positions if (!delagation) { positions = OrgSvr.GetUserPositions(cn, cn.UID); if (String.IsNullOrEmpty(selectPosition) && positions.Count != 0) { selectPosition = positions[0].FullName; } } else { Member mb = new Member(); mb.Open(cn, selectPosition); positions = OrgSvr.GetUserPositions(cn, mb.UserAccount); selectPosition = mb.FullName; } if (String.IsNullOrEmpty(postInfo.FormFile)) { throw new Exception(Resources.YZStrings.Aspx_Post_MissForm); } //返回 rv[YZJsonProperty.success] = true; rv["subModel"] = subModel.ToString(); //基本信息 rv["pn"] = postInfo.ProcessName; rv["version"] = postInfo.ProcessVersion.ToString(2); rv["restartTaskID"] = restartTaskID; rv["url"] = YZUtility.GetFormRedirectUrl(postInfo.FormFile).ToString(); rv["perm"] = perm; rv["PersistParams"] = postInfo.PersistParams; rv["NodePermisions"] = this.Serialize(postInfo.NodePermision); rv["Comments"] = draft != null ? draft.Comments : null; rv["DraftHeader"] = jDraftHeader; //处理按钮 JArray links = new JArray(); rv["links"] = links; foreach (Link link in postInfo.Links) { links.Add(this.Serialize(link, "normal")); } //提交职位 rv["delagation"] = delagation; rv["selectPosition"] = selectPosition; JArray jPoss = new JArray(); rv["positions"] = jPoss; foreach (Member position in positions) { JObject jPos = new JObject(); jPoss.Add(jPos); string name = position.GetParentOU(cn).Name + "\\" + position.UserAccount; if (position.IsLeader) { name += "(" + position.LeaderTitle + ")"; } jPos["name"] = name; jPos["value"] = position.FullName; } //自由流 rv["ParticipantDeclares"] = JArray.FromObject(postInfo.ParticipantDeclares); } return(rv); }
public virtual JObject GetPostInfo(HttpContext context) { YZRequest request = new YZRequest(context); string processName = request.GetString("processName"); int restartTaskID = request.GetInt32("restartTaskID", -1); string permisions = request.GetString("Permisions", null); Version processVersion = null; PostInfo postInfo; JObject perm; MemberCollection positions; FlowDataSet formdataset; using (BPMConnection cn = new BPMConnection()) { cn.WebOpen(); if (restartTaskID == -1) { processVersion = cn.GetGlobalObjectLastVersion(StoreZoneType.Process, processName); } postInfo = BPMProcess.GetPostInfo(cn, processName, processVersion, null, restartTaskID); perm = this.CheckPermision(postInfo, permisions); positions = OrgSvr.GetUserPositions(cn, cn.UID); formdataset = BPMProcess.GetFormData(cn, processName, processVersion, null, restartTaskID); //准备返回值 JObject result = new JObject(); JObject jForm = new JObject(); if (String.IsNullOrEmpty(postInfo.MobileForm)) { //jForm["xclass"] = "YZSoft.form.Form5"; //jForm["config"] = new JObject(); jForm["xclass"] = "YZSoft.form.aspx.Form"; if (String.IsNullOrEmpty(postInfo.FormFile)) { throw new Exception(Resources.YZStrings.Aspx_Post_MissForm); } jForm["config"] = JObject.FromObject(new { aspxform = postInfo.FormFile }); } else { string xclass; JObject config; this.ParseMobileForm(postInfo.MobileForm, out xclass, out config); jForm["xclass"] = xclass; jForm["config"] = config; } result["form"] = jForm; result["subModel"] = "Post"; result["processName"] = postInfo.ProcessName; result["processVersion"] = postInfo.ProcessVersion.ToString(2); result["restartTaskID"] = restartTaskID; result["perm"] = perm; result["PersistParams"] = postInfo.PersistParams; result["NodePermisions"] = this.Serialize(postInfo.NodePermision); result["formdataset"] = this.ToResult(formdataset, true); //处理按钮 JArray links = new JArray(); result["links"] = links; foreach (Link link in postInfo.Links) { links.Add(this.Serialize(link, "normal")); } JArray jPoss = new JArray(); result["positions"] = jPoss; foreach (Member position in positions) { JObject jPos = new JObject(); jPoss.Add(jPos); string name = position.GetParentOU(cn).Name + "\\" + position.UserAccount; if (position.IsLeader) { name += "(" + position.LeaderTitle + ")"; } jPos["name"] = name; jPos["value"] = position.FullName; } //自由流 result["ParticipantDeclares"] = JArray.FromObject(postInfo.ParticipantDeclares); return(result); } }