示例#1
0
        public virtual object GetTaskLastSteps(HttpContext context)
        {
            YZRequest request    = new YZRequest(context);
            int       taskid     = request.GetInt32("TaskID");
            int       lastStepId = request.GetInt32("LastStepID");

            BPMStepCollection steps;

            //获得数据
            using (BPMConnection cn = new BPMConnection())
            {
                cn.WebOpen();
                steps = BPMTask.GetAllSteps(cn, taskid);
            }

            BPMStepCollection newSteps = new BPMStepCollection();

            foreach (BPMProcStep step in steps)
            {
                if (step.StepID > lastStepId)
                {
                    newSteps.Add(step);
                }
            }

            return(new
            {
                Steps = this.SerializeSteps(newSteps)
            });
        }
示例#2
0
        public virtual object GetTaskTraceInfo(HttpContext context)
        {
            YZRequest request = new YZRequest(context);
            int       taskid  = request.GetInt32("TaskID");

            BPMTask            task;
            NodeItemCollection nodes = new NodeItemCollection();
            LinkItemCollection links = new LinkItemCollection();
            BPMStepCollection  steps = new BPMStepCollection();

            //获得数据
            using (BPMConnection cn = new BPMConnection())
            {
                cn.WebOpen();

                task = BPMTask.Load(cn, taskid);
                BPMProcess.GetTaskTraceInfo(cn, task.ProcessName, task.ProcessVersion, out nodes, out links);
                steps = BPMTask.GetAllSteps(cn, taskid);
            }

            return(new
            {
                Task = this.SerializeTask(task),
                Process = new
                {
                    Nodes = nodes,
                    Links = links
                },
                Steps = this.SerializeSteps(steps)
            });
        }
示例#3
0
        public virtual JObject GetReActiveSteps(HttpContext context)
        {
            YZRequest request = new YZRequest(context);
            int       taskid  = request.GetInt32("TaskID");

            JArray children = new JArray();

            //获得数据
            BPMStepCollection steps = null;

            using (BPMConnection cn = new BPMConnection())
            {
                cn.WebOpen();
                steps = BPMTask.GetAllSteps(cn, taskid);

                BPMObjectNameCollection stepNames = new BPMObjectNameCollection();
                for (int i = steps.Count - 1; i >= 0; i--)
                {
                    BPMProcStep step = steps[i];

                    if (!step.IsHumanStep)
                    {
                        continue;
                    }

                    if (step.IsTaskOptStep || step.IsIndicateStep || step.IsInformStep || step.IsConsignStep)
                    {
                        continue;
                    }

                    if (stepNames.Contains(step.NodeName))
                    {
                        continue;
                    }

                    stepNames.Add(step.NodeName);
                    children.Add(Serialize(cn, step));
                }
            }

            //输出数据
            JObject rv = new JObject();

            rv[YZJsonProperty.success]  = true;
            rv[YZJsonProperty.total]    = children.Count;
            rv[YZJsonProperty.children] = children;
            return(rv);
        }
示例#4
0
        /// <summary>
        /// 判断任务是否是当前待办
        /// </summary>
        /// <param name="UserAccount">帐号</param>
        /// <param name="StepID">步骤id</param>
        /// <returns></returns>
        private bool IsCurrentStep(BPMConnection cn, string UserAccount, int StepID, int TaskID)
        {
            BPMStepCollection _steps = BPMTask.GetAllSteps(cn, TaskID);

            foreach (BPMProcStep item in _steps)
            {
                if (item.IsHumanStep)
                {
                    if (item.StepID == StepID && item.RecipientAccount.Equals(UserAccount, StringComparison.OrdinalIgnoreCase))
                    {
                        return(true);
                    }
                }
            }
            return(false);
        }
示例#5
0
        private JObject GetApprovalLog(BPMConnection cn, int TaskID)
        {
            JObject result = new JObject();

            BPMTask task = BPMTask.Load(cn, TaskID);

            result["success"] = true;
            result["TaskID"]  = TaskID;
            result["SN"]      = task.SerialNum;
            result["State"]   = task.TaskState.ToString();

            JArray StepItems = new JArray();

            result["StepItems"] = StepItems;

            BPMStepCollection steps = BPMTask.GetAllSteps(cn, TaskID);

            foreach (BPMProcStep step in steps)
            {
                if (step.IsHumanStep)
                {
                    JObject item = new JObject();
                    StepItems.Add(item);
                    item["StepID"]           = step.StepID;
                    item["NodeName"]         = step.NodeName;
                    item["ReceiveAt"]        = YZStringHelper.DateToStringL(step.ReceiveAt);
                    item["FinishAt"]         = step.FinishAt == DateTime.MinValue ? "" : YZStringHelper.DateToStringL(step.FinishAt);
                    item["OwnerAccount"]     = step.OwnerAccount;
                    item["OwnerName"]        = step.OwnerFullName;
                    item["RecipientAccount"] = step.RecipientAccount == null ? "" : step.RecipientAccount;
                    item["RecipientName"]    = step.RecipientFullName == null ? "" : step.RecipientFullName;
                    item["HandlerAccount"]   = step.HandlerAccount == null ? "" : step.HandlerAccount;
                    item["HandlerName"]      = step.HandlerFullName == null ? "" : step.HandlerFullName;
                    item["AgentAccount"]     = step.AgentAccount == null ? "" : step.AgentAccount;
                    item["AgentName"]        = step.AgentFullName == null ? "" : step.AgentFullName;
                    item["SelAction"]        = step.SelAction == null ? "" : step.SelAction;
                    item["Comments"]         = step.Comments == null ? "" : step.Comments;
                }
            }

            return(result);
        }
示例#6
0
        public virtual JObject GetTaskProcessedSteps(HttpContext context)
        {
            YZRequest request = new YZRequest(context);
            int       taskid  = request.GetInt32("TaskID");
            JObject   rv      = new JObject();

            //获得数据
            BPMStepCollection steps = null;

            using (BPMConnection cn = new BPMConnection())
            {
                cn.WebOpen();
                steps = BPMTask.GetAllSteps(cn, taskid);

                //将数据转化为Json集合
                JArray children = new JArray();
                rv[YZJsonProperty.children] = children;

                foreach (BPMProcStep step in steps)
                {
                    if (!step.IsHumanStep)
                    {
                        continue;
                    }

                    if (!step.Finished)
                    {
                        continue;
                    }

                    children.Add(Serialize(cn, step));
                }

                rv[YZJsonProperty.total] = children.Count;
            }

            //输出数据
            rv[YZJsonProperty.success] = true;
            return(rv);
        }
示例#7
0
        public void ProcessRequest(HttpContext context)
        {
            YZAuthHelper.OAuth();

            //YZAuthHelper.AshxAuthCheck();

            try
            {
                UIStrings rs     = new UIStrings();
                int       taskid = Int32.Parse(context.Request.Params["tid"]);

                JsonItem rv = new JsonItem();
                using (BPMConnection cn = new BPMConnection())
                {
                    cn.WebOpen();

                    BPMStepCollection steps = BPMTask.GetAllSteps(cn, taskid);
                    BPMTask           task  = BPMTask.Load(cn, taskid);

                    rv.Attributes.Add("sn", task.SerialNum);
                    rv.Attributes.Add("pn", task.ProcessName);

                    //将数据转化为Json集合
                    JsonItemCollection children = new JsonItemCollection();
                    rv.Attributes.Add("children", children);

                    foreach (BPMProcStep step in steps)
                    {
                        //不是有效的步骤
                        if (!step.IsHumanStep)
                        {
                            continue;
                        }

                        //跳过 - 无处理人的非共享任务
                        if (String.IsNullOrEmpty(step.OwnerAccount) && !step.Share)
                        {
                            continue;
                        }

                        JsonItem item = new JsonItem();
                        children.Add(item);

                        item.Attributes.Add("StepDisplayName", step.StepDisplayName);

                        string recpAccount;
                        string recpDisplayName;
                        if (step.Finished)
                        {
                            recpAccount     = step.HandlerAccount;
                            recpDisplayName = YZStringHelper.GetUserShortName(step.HandlerAccount, step.HandlerFullName);
                        }
                        else
                        {
                            recpAccount     = step.RecipientAccount;
                            recpDisplayName = YZStringHelper.GetUserShortName(step.RecipientAccount, step.RecipientFullName);
                        }

                        if (!step.IsConsignStep && recpAccount != step.OwnerAccount)
                        {
                            recpDisplayName = String.Format(rs["XFormDesigner.XSignTrace.OwnerFmt"], recpDisplayName, YZStringHelper.GetUserShortName(step.OwnerAccount, step.OwnerDisplayName));
                        }
                        item.Attributes.Add("Recipient", recpDisplayName);

                        item.Attributes.Add("OwnerAccount", step.OwnerAccount);
                        item.Attributes.Add("OwnerFullName", step.OwnerFullName);
                        item.Attributes.Add("OwnerDisplayName", step.OwnerDisplayName);

                        item.Attributes.Add("Finished", step.Finished);
                        item.Attributes.Add("FinishAt", YZStringHelper.DateToStringM(step.FinishAt, ""));
                        item.Attributes.Add("ReceiveAt", YZStringHelper.DateToStringM(step.ReceiveAt, ""));

                        item.Attributes.Add("SelActionDisplayString", step.SelActionDisplayString);
                        item.Attributes.Add("Comments", HttpUtility.HtmlEncode(step.Comments));
                    }
                }

                //System.Threading.Thread.Sleep(500);
                //输出数据
                context.Response.Write(rv.ToString());
            }
            catch (Exception e)
            {
                JsonItem rv = new JsonItem();
                rv.Attributes.Add("success", false);
                rv.Attributes.Add("errorMessage", e.Message);
                context.Response.Write(rv.ToString());
            }


            context.Response.AppendHeader("Access-Control-Allow-Origin", "*");      // 响应类型
            context.Response.AppendHeader("Access-Control-Allow-Methods", "POST");  // 响应头设置
            context.Response.AppendHeader("Access-Control-Allow-Headers", "x-requested-with,content-type");

            context.Response.Charset         = "gb2312"; //设置字符集类型
            context.Response.ContentEncoding = System.Text.Encoding.GetEncoding("gb2312");
            context.Response.ContentType     = "application/json;charset=gb2312";
        }
示例#8
0
        //FormData格式如下
        //<FormData>
        //    <Purchase>
        //        <SN></SN>
        //        <Amount>26000.00</Amount>
        //        <Reason>dddd</Reason>
        //        <Attachments></Attachments>
        //    </Purchase>
        //    <PurchaseDetail>
        //        <RelationRowGuid>1</RelationRowGuid>
        //        <RowPrimaryKeys></RowPrimaryKeys>
        //        <ItemCode>001</ItemCode>
        //        <Price>10000.00</Price>
        //        <Qty>1</Qty>
        //        <SubTotal>10000.00</SubTotal>
        //    </PurchaseDetail>
        //    <PurchaseDetail>
        //        <RelationRowGuid>2</RelationRowGuid>
        //        <RowPrimaryKeys></RowPrimaryKeys>
        //        <ItemCode>002</ItemCode>
        //        <Price>8000.00</Price>
        //        <Qty>2</Qty>
        //        <SubTotal>16000.00</SubTotal>
        //    </PurchaseDetail>
        //</FormData>
        //RelationRowGuid是在这个文件里自增的字段,不管几个子表不管几行数据,永远自增1。
        private JObject PostTask(BPMConnection cn, string ProcessName, string UserAccount, string Action, string Comment, bool Draft, int ExistTaskID, string FormData)
        {
            JObject result = new JObject();

            //处理ExistTask参数
            StringBuilder sb = new StringBuilder();

            if (ExistTaskID != -1)
            {
                BPMProcStep startStep = null;
                try
                {
                    startStep = BPMTask.PickBackRestart(cn, ExistTaskID, "");
                }
                catch (BPMException e)
                {
                    if (e.ExceptionType == BPMExceptionType.TaskPickBackErrNeedNot)
                    {
                        BPMStepCollection temp = BPMTask.GetAllSteps(cn, ExistTaskID);
                        startStep = temp.Find(delegate(BPMProcStep item) { return(item.IsHumanStep == true && item.Finished == false); });
                        if (startStep == null)
                        {
                            throw new Exception("当前任务没有待审批步骤");
                        }
                    }
                    else
                    {
                        throw e;
                    }
                }

                if (startStep == null)
                {
                    throw new Exception("获取当前审批步骤失败");
                }

                sb.Append(String.Format("<?xml version=\"1.0\"?>"));
                sb.Append(String.Format("<XForm>"));
                sb.Append(String.Format(@"
                            <Header>
                                <Method>Process</Method>
                                <PID>{0}</PID>
                                <Action>{1}</Action>
                                <Comment>{2}</Comment>
                            </Header>", startStep.StepID, Action, Comment));
                sb.Append(FormData);
                sb.Append(String.Format("</XForm>"));
            }
            else
            {
                sb.Append(String.Format("<?xml version=\"1.0\"?>"));
                sb.Append(String.Format("<XForm>"));
                sb.Append(String.Format(@"
                            <Header>
                                <Method>{0}</Method>
                                <ProcessName>{1}</ProcessName>
                                <OwnerMemberFullName>{2}</OwnerMemberFullName>
                                <Action>{3}</Action>
                                <Comment>{4}</Comment>
                            </Header>", Draft ? "SaveAsDraft" : "Post", ProcessName, GetMember(cn, UserAccount).FullName, Action, Comment));
                sb.Append(FormData);
                sb.Append(String.Format("</XForm>"));
            }

            MemoryStream xmlStream  = new MemoryStream(Encoding.UTF8.GetBytes(sb.ToString()));
            PostResult   postResult = BPMProcess.Post(cn, xmlStream);

            string requestUrl      = HttpContext.Current.Request.Url.ToString();
            string RedirectURLBase = requestUrl.Substring(0, requestUrl.IndexOf("YZSoft", StringComparison.OrdinalIgnoreCase)) + "YZSoft/Forms/";
            string openUrl         = String.Empty;

            if (Draft)
            {
                openUrl = String.Format(RedirectURLBase + "Post.aspx?pn={0}&did={1}", ProcessName, postResult.SN);
            }
            else
            {
                openUrl = String.Format(RedirectURLBase + "Read.aspx?tid={0}", postResult.TaskID);
            }

            result["success"] = true;
            result["TaskID"]  = postResult.TaskID;
            result["SN"]      = postResult.SN;
            result["OpenUrl"] = openUrl;

            return(result);
        }
示例#9
0
文件: Form.cs 项目: radtek/EMIP
        public virtual JObject GetTaskReadInfo(HttpContext context)
        {
            YZRequest request    = new YZRequest(context);
            int       taskid     = request.GetInt32("tid");
            string    permisions = request.GetString("Permisions", null);
            string    uid        = YZAuthHelper.LoginUserAccount;

            BPMTask task;
            CommentItemCollection comments;
            FlowDataSet           formdataset;
            BPMStepCollection     steps;
            JObject perm = null;
            string  readForm;
            string  mobileReadForm;

            using (BPMConnection cn = new BPMConnection())
            {
                cn.WebOpen();

                task     = BPMTask.Load(cn, taskid);
                comments = BPMTask.GetComments(cn, task.TaskID);
                readForm = BPMProcess.GetTaskReadForm(cn, taskid);

                formdataset    = BPMProcess.GetFormDataForRead(cn, taskid);
                steps          = BPMTask.GetAllSteps(cn, task.TaskID);
                mobileReadForm = BPMProcess.GetTaskReadFormMobile(cn, task.TaskID);

                perm = this.CheckPermision(cn, taskid, -1, permisions);
            }

            int total;
            int newMessageCount;

            using (IYZDbProvider provider = YZDbProviderManager.DefaultProvider)
            {
                using (IDbConnection cn = provider.OpenConnection())
                {
                    total           = YZSoft.Web.Social.SocialManager.GetMessageCount(provider, cn, YZResourceType.Task, task.TaskID.ToString());
                    newMessageCount = YZSoft.Web.Social.SocialManager.GetNewMessageCount(provider, cn, YZResourceType.Task, task.TaskID.ToString(), uid);
                }
            }

            //准备返回值
            JObject result = new JObject();

            JObject jForm = new JObject();

            if (String.IsNullOrEmpty(mobileReadForm))
            {
                //jForm["xclass"] = "YZSoft.form.Form5";
                //jForm["config"] = new JObject();

                jForm["xclass"] = "YZSoft.form.aspx.Form";

                if (String.IsNullOrEmpty(readForm))
                {
                    throw new Exception(Resources.YZStrings.Aspx_Read_MissForm);
                }

                jForm["config"] = JObject.FromObject(new
                {
                    aspxform = readForm
                });
            }
            else
            {
                string  xclass;
                JObject config;
                this.ParseMobileForm(mobileReadForm, out xclass, out config);
                jForm["xclass"] = xclass;
                jForm["config"] = config;
            }
            result["form"]         = jForm;
            result["subModel"]     = "Read";
            result["task"]         = this.Serialize(task);
            result["perm"]         = perm;
            result["socialInfo"]   = this.SerializeSocialInfo(total, newMessageCount);
            result["steps"]        = this.SerializeForTrace(steps);
            result["signcomments"] = JArray.FromObject(comments);
            result["formdataset"]  = this.ToResult(formdataset, true);

            return(result);
        }
示例#10
0
文件: Form.cs 项目: radtek/EMIP
        public virtual JObject GetProcessInfo(HttpContext context)
        {
            YZRequest request    = new YZRequest(context);
            int       stepid     = request.GetInt32("pid");
            string    permisions = request.GetString("Permisions", null);
            string    uid        = YZAuthHelper.LoginUserAccount;

            BPMProcStep step;
            BPMTask     task;

            global::BPM.Client.ProcessInfo processInfo;
            CommentItemCollection          comments;
            FlowDataSet       formdataset;
            BPMStepCollection steps;
            ProcessSubModel   subModel;
            JObject           perm           = null;
            JObject           directSendInfo = null;

            using (BPMConnection cn = new BPMConnection())
            {
                cn.WebOpen();

                step        = BPMProcStep.Load(cn, stepid);
                task        = BPMTask.Load(cn, step.TaskID);
                processInfo = BPMProcess.GetProcessInfo(cn, stepid);

                comments    = BPMTask.GetComments(cn, task.TaskID);
                formdataset = BPMProcess.GetFormData(cn, stepid);
                steps       = BPMTask.GetAllSteps(cn, task.TaskID);

                //获得ProcessSubModel
                if (step.Share && String.IsNullOrEmpty(step.OwnerAccount))
                {
                    subModel = ProcessSubModel.Share;
                }
                else
                {
                    if (processInfo.StepProcessPermision == StepProcessPermision.Inform)
                    {
                        subModel = ProcessSubModel.Inform;
                    }
                    else if (processInfo.StepProcessPermision == StepProcessPermision.Indicate)
                    {
                        subModel = ProcessSubModel.Indicate;
                    }
                    else
                    {
                        subModel = ProcessSubModel.Process;
                    }
                }

                //ProcessSubModel.Process - 则获得任务操作权限
                if (subModel == ProcessSubModel.Process ||
                    subModel == ProcessSubModel.Inform ||
                    subModel == ProcessSubModel.Indicate)
                {
                    perm = this.CheckPermision(cn, step.TaskID, stepid, permisions);
                }
                else
                {
                    perm = new JObject();
                }

                directSendInfo = this.GetDirectSendInfo(cn, step, processInfo.SystemLinks);
            }

            int total;
            int newMessageCount;

            using (IYZDbProvider provider = YZDbProviderManager.DefaultProvider)
            {
                using (IDbConnection cn = provider.OpenConnection())
                {
                    total           = YZSoft.Web.Social.SocialManager.GetMessageCount(provider, cn, YZResourceType.Task, task.TaskID.ToString());
                    newMessageCount = YZSoft.Web.Social.SocialManager.GetNewMessageCount(provider, cn, YZResourceType.Task, task.TaskID.ToString(), uid);
                }
            }

            //准备返回值
            JObject result = new JObject();

            JObject jForm = new JObject();

            if (String.IsNullOrEmpty(processInfo.MobileForm))
            {
                //jForm["xclass"] = "YZSoft.form.Form5";
                //jForm["config"] = new JObject();

                jForm["xclass"] = "YZSoft.form.aspx.Form";

                if (String.IsNullOrEmpty(processInfo.FormFile))
                {
                    throw new Exception(String.Format(Resources.YZStrings.Aspx_Process_MissForm, step.NodeName));
                }

                jForm["config"] = JObject.FromObject(new
                {
                    aspxform = processInfo.FormFile
                });
            }
            else
            {
                string  xclass;
                JObject config;
                this.ParseMobileForm(processInfo.MobileForm, out xclass, out config);
                jForm["xclass"] = xclass;
                jForm["config"] = config;
            }
            result["form"] = jForm;

            result["subModel"]       = subModel.ToString();
            result["task"]           = this.Serialize(task);
            result["step"]           = this.Serialize(step);
            result["NodePermisions"] = this.Serialize(processInfo.NodePermision);
            result["Comments"]       = step.Comments;
            result["perm"]           = perm;
            result["socialInfo"]     = this.SerializeSocialInfo(total, newMessageCount);
            result["steps"]          = this.SerializeForTrace(steps);
            result["signcomments"]   = JArray.FromObject(comments);
            result["formdataset"]    = this.ToResult(formdataset, true);

            if (subModel == ProcessSubModel.Process)
            {
                result["shareTask"] = step.Share;
                result["IsConsign"] = step.IsConsignStep;

                JArray links = new JArray();
                result["links"] = links;
                foreach (Link link in processInfo.Links)
                {
                    links.Add(this.Serialize(link, "normal"));
                }

                result["directsend"] = directSendInfo;

                //自由流
                if (!step.IsConsignStep) //加签不显示自由流
                {
                    result["ParticipantDeclares"] = JArray.FromObject(processInfo.ParticipantDeclares);
                    result["Routing"]             = processInfo.Routing;
                }
            }

            return(result);
        }