Exemple #1
0
        public virtual object Process(HttpContext context)
        {
            YZRequest request = new YZRequest(context);
            int       stepid  = request.GetInt32("StepID");
            string    uid     = request.GetString("uid", YZAuthHelper.LoginUserAccount); //共享任务uid为空,会导致重定向到登录页面,产生异常

            using (BPMConnection cn = new BPMConnection())
            {
                string orguid = YZAuthHelper.LoginUserAccount;
                YZAuthHelper.SetAuthCookie(uid);
                try
                {
                    cn.WebOpen();
                }
                finally
                {
                    YZAuthHelper.SetAuthCookie(orguid);
                }

                ProcessInfo processInfo = BPMProcess.GetProcessInfo(cn, stepid);
                if (processInfo.Links.Count == 0)
                {
                    throw new BPMException(BPMExceptionType.MissOutLink, processInfo.NodeName);
                }

                string postXml = @"{0}
                    <XForm>
                        <Header>
                            <Method>Process</Method>
                            <PID>{1}</PID>
                            <Action>{2}</Action>
                            <Comment></Comment>
                        </Header>
                        <FormData>
                        </FormData>
                    </XForm>";

                postXml = String.Format(postXml,
                                        "<?xml version=\"1.0\"?>",
                                        stepid,
                                        YZUtility.EncodeXMLInnerText(processInfo.Links[0].DisplayString));

                using (MemoryStream postStream = new MemoryStream(Encoding.UTF8.GetBytes(postXml)))
                {
                    PostResult postResult = BPMProcess.Post(cn, postStream);

                    return(new
                    {
                        success = true,
                        result = (postResult.PostResultType == PostResultType.TaskFinishedApproved || postResult.PostResultType == PostResultType.TaskFinishedRejected) ? "finished" : "running"
                    });
                }
            }
        }
Exemple #2
0
        public virtual JObject GetProcessInfo(HttpContext context)
        {
            YZRequest request    = new YZRequest(context);
            int       stepid     = request.GetInt32("pid");
            string    permisions = request.GetString("Permisions", null);

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

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

                //检查处理权
                if (!step.Share || !String.IsNullOrEmpty(step.OwnerAccount)) //常规任务及已获取的共享任务
                {
                    if (!NameCompare.EquName(step.OwnerAccount, cn.UID) &&
                        !NameCompare.EquName(step.AgentAccount, cn.UID))
                    {
                        throw new BPMException(BPMExceptionType.ProcessErrPermDenied);
                    }
                }

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

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

                JObject rv = new JObject();
                rv[YZJsonProperty.success] = true;
                rv["uid"]      = cn.UID;
                rv["subModel"] = subModel.ToString();

                rv["sn"]             = task.SerialNum;
                rv["taskid"]         = task.TaskID;
                rv["urlParams"]      = task.UrlParams;
                rv["url"]            = YZUtility.GetFormRedirectUrl(processInfo.FormFile).ToString();
                rv["NodePermisions"] = this.Serialize(processInfo.NodePermision);
                rv["Comments"]       = step.Comments;
                rv["perm"]           = perm;

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

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

                    rv["directsend"] = this.GetDirectSendInfo(cn, step, processInfo.SystemLinks);

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

                return(rv);
            }
        }
Exemple #3
0
        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);
        }
Exemple #4
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!YZAuthHelper.IsAuthenticated)
        {
            string token = this.Request.QueryString["Token"];
            if (!String.IsNullOrEmpty(token))
            {
                using (SqlConnection cn = new SqlConnection())
                {
                    cn.ConnectionString = System.Web.Configuration.WebConfigurationManager.ConnectionStrings["BPMDB"].ConnectionString;
                    cn.Open();

                    using (SqlCommand cmd = new SqlCommand())
                    {
                        cmd.Connection  = cn;
                        cmd.CommandText = "SELECT StepID,Account,hash FROM BPMInstProcessToken WHERE Token=@Token";
                        cmd.Parameters.Add("@Token", SqlDbType.NVarChar).Value = token;

                        using (DBReader reader = new DBReader(cmd.ExecuteReader()))
                        {
                            if (reader.Read())
                            {
                                int    stepid      = Int32.Parse(this.Request.QueryString["pid"]);
                                int    stepidSaved = reader.ReadInt32(0);
                                string account     = reader.ReadString(1);
                                string hash        = reader.ReadString(2);

                                if (stepid == stepidSaved)
                                {
                                    List <string> values = new List <string>();
                                    values.Add(token);
                                    values.Add(stepid.ToString());
                                    values.Add(account);

                                    if (YZSecurityHelper.CheckHash(values, hash, YZSecurityHelper.SecurityKey))
                                    {
                                        YZAuthHelper.SetAuthCookie(account);
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }

        if (!YZAuthHelper.IsAuthenticated)
        {
            FormsAuthentication.RedirectToLoginPage();
            return;
        }

        int pid = Int32.Parse(this.Request["pid"]);

        BPM.Client.ProcessInfo processInfo;

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

            //如果是共享任务,表单打开时直接获取共享任务
            //BPMProcStep step = BPMProcStep.Load(cn,pid);
            //if (step.Share)
            //    BPMProcStep.PickupShareStep(cn, pid);

            processInfo = BPMProcess.GetProcessInfo(cn, pid);
        }

        if (String.IsNullOrEmpty(processInfo.FormFile))
        {
            throw new Exception(Resources.YZStrings.Aspx_Process_MissForm);
        }
        else
        {
            YZUrlBuilder urlBuilder = YZUtility.GetFormRedirectUrl(this.Page, processInfo.FormFile);
            this.Response.Redirect(urlBuilder.ToString(), true);
        }
    }