Ejemplo n.º 1
0
        public virtual JArray GetFormProcessData(BPMConnection cn, JObject request)
        {
            int pid = Int32.Parse((string)request["PID"]);

            FlowDataSet dataset = BPMProcess.GetFormData(cn, pid);

            return(this.ToResult(dataset, true));
        }
Ejemplo n.º 2
0
        public virtual JArray GetFormPostData(BPMConnection cn, JObject request)
        {
            string  processName    = (string)request["ProcessName"];
            Version processVersion = new Version((string)request["ProcessVersion"]);
            string  owner          = (string)request["Owner"];
            int     restartTaskID  = request.Property("restartTaskID") != null  ? (int)request["restartTaskID"]:-1;

            FlowDataSet dataset = BPMProcess.GetFormData(cn, processName, processVersion, owner, restartTaskID);

            return(this.ToResult(dataset, true));
        }
Ejemplo n.º 3
0
        private JObject GetFormInfo(BPMConnection cn, string UserAccount, int TaskID, int StepID)
        {
            FlowDataSet formData = null;
            BPMTask     task     = null;
            string      FormXml  = "";  //获取表单名称

            JObject rv = new JObject(); //最终组合的

            JArray TaskCommList = new JArray();

            rv["TaskCommList"] = TaskCommList;

            JArray FormInfo = new JArray();

            rv["FormInfo"] = FormInfo;
            JArray ButtonList = new JArray();

            rv["ButtonList"] = ButtonList;


            if (StepID < 0)
            {
                BPMStepCollection Steps = BPM.Client.BPMTask.GetAllSteps(cn, TaskID);
                foreach (BPM.Client.BPMProcStep item in Steps)
                {
                    if (item.NodeName.Equals("开始"))
                    {
                        StepID = item.StepID;
                        break;
                    }
                }
            }

            //按钮开始
            BPM.Client.ProcessInfo processInfo = BPM.Client.BPMProcess.GetProcessInfo(cn, StepID);
            BPMTask bt = BPMTask.Load(cn, TaskID);

            JObject TaskComm = new JObject();

            TaskCommList.Add(TaskComm);

            TaskComm["TaskID"]           = bt.TaskID;
            TaskComm["ParentStepID"]     = bt.ParentStepID;
            TaskComm["SerialNum"]        = bt.SerialNum;
            TaskComm["ProcessName"]      = bt.ProcessName;
            TaskComm["ApplicantAccount"] = bt.ApplicantAccount;

            TaskComm["AgentAccount"]     = bt.AgentAccount;
            TaskComm["AgentDisplayName"] = bt.AgentDisplayName;
            TaskComm["AgentDisplayName"] = bt.AgentDisplayName;

            TaskComm["OwnerAccount"]     = bt.OwnerAccount;
            TaskComm["OwnerDisplayName"] = bt.OwnerDisplayName;
            TaskComm["OwnerFullName"]    = bt.OwnerFullName;

            TaskComm["CreateAt"] = bt.CreateAt;
            TaskComm["FinishAt"] = bt.FinishAt;
            TaskComm["OptAt"]    = bt.OptAt;
            TaskComm["OptUser"]  = bt.OptUser;
            TaskComm["OptMemo"]  = bt.OptMemo;
            //TaskComm["Description"] = bt.Description;
            // TaskComm["ReturnToParent"] = bt.ReturnToParent;

            TaskComm["TaskState"] = bt.TaskState.ToString();
            TaskComm["State"]     = bt.State.ToString();


            if (IsCurrentStep(cn, UserAccount, StepID, TaskID) && bt.TaskState.ToString().Equals("Running", StringComparison.OrdinalIgnoreCase))
            {
                BPM.Client.LinkCollection links = processInfo.Links;//提交按钮
                foreach (Link link in links)
                {
                    JObject button = new JObject();
                    ButtonList.Add(button);
                    string s = link.DisplayString;
                    button["Text"]   = s;
                    button["Action"] = s;
                    button["Type"]   = "Post";
                }
                bool canReject = (processInfo.NodePermision & NodePermision.Reject) == NodePermision.Reject;//拒绝按钮
                if (canReject)
                {
                    JObject button = new JObject();
                    ButtonList.Add(button);
                    button["Text"]   = "拒绝";
                    button["Action"] = "Reject";
                    button["Type"]   = "Reject";
                }
                bool canTransfer = (processInfo.NodePermision & NodePermision.Transfer) == NodePermision.Transfer;//委托按钮
                if (canTransfer)
                {
                    JObject button = new JObject();
                    ButtonList.Add(button);
                    button["Text"]   = "委托";
                    button["Action"] = "Transfer";
                    button["Type"]   = "Transfer";
                }
                bool canConsign = (processInfo.NodePermision & NodePermision.Consign) == NodePermision.Consign;//加签按钮
                if (canConsign)
                {
                    string  s      = links[0].DisplayString;
                    JObject button = new JObject();
                    ButtonList.Add(button);
                    button["Text"]   = "加签";
                    button["Action"] = s;
                    button["Type"]   = "Consign";
                }
                bool canRecedeBack = (processInfo.NodePermision & NodePermision.RecedeBack) == NodePermision.RecedeBack;//退回重填按钮
                if (canRecedeBack)
                {
                    JObject button = new JObject();
                    ButtonList.Add(button);
                    button["Text"]   = "退回某步";
                    button["Action"] = "RecedeBack";
                    button["Type"]   = "RecedeBack";
                }
                bool recedeRestart = (processInfo.NodePermision & NodePermision.RecedeRestart) == NodePermision.RecedeRestart;//退回重填


                BPMProcStep stepLoad = BPMProcStep.Load(cn, StepID);
                int         idx      = processInfo.SystemLinks.Find(SystemLinkType.DirectSend);
                if (stepLoad.RecedeFromStep != -1 && idx != -1 && processInfo.SystemLinks[idx].Enabled)
                {
                    BPMStepCollection       directSendToSteps = BPMProcStep.LoadPrevSteps(cn, StepID);
                    BPMObjectNameCollection stepNames         = new BPMObjectNameCollection();
                    foreach (BPMProcStep step in directSendToSteps)
                    {
                        if (step.IsHumanStep)
                        {
                            stepNames.Add(step.NodeName + ":" + YZStringHelper.GetUserFriendlyName(step.RecipientAccount, step.RecipientFullName));

                            string  buttonText = "直送->" + stepNames.ToStringList(';');
                            JObject button     = new JObject();
                            ButtonList.Add(button);
                            button["Text"]   = buttonText;
                            button["Action"] = "DirectSend";
                            button["Type"]   = "DirectSend";
                        }
                    }
                }
            }

            //按钮结束
            FormXml = processInfo.FormFile;

            //获取表单数据
            formData = BPMProcess.GetFormData(cn, StepID);

            if (formData.Tables.Count == 0)
            {
                throw new Exception("获取表单数据失败");
            }

            //初始化布局文件
            task = BPMTask.Load(cn, TaskID);


            if (task == null)
            {
                throw new Exception("通过TaskID获取任务失败");
            }

            //int startIndex=FormXml.LastIndexOf(@"\");
            //int endIndex=FormXml.LastIndexOf(".aspx");
            // FormXml = FormXml.Substring(startIndex+1, endIndex - startIndex-1);
            FormXml = FormXml.Replace(".aspx", "");
            FormXml = FormXml.Replace("\\", "(");
            //throw new Exception(FormXml);
            XmlDocument layoutDoc      = new XmlDocument();
            string      layoutFilePath = HttpContext.Current.Server.MapPath(String.Format("~/FormLayout/{0}.xml", FormXml));

            string debugger = "";

            if (System.IO.File.Exists(layoutFilePath))
            {
                layoutDoc.Load(layoutFilePath);

                XmlNodeList layoutTables = layoutDoc.SelectNodes("Layout/Table");
                foreach (XmlNode layoutTable in layoutTables)
                {
                    string TableID = TryGetNodeAttribute(layoutTable, "ID");
                    //测试报文中Table是否与流程中的Table匹配
                    debugger += "[TableID]" + TableID;
                    foreach (FlowDataTable item in formData.Tables)
                    {
                        debugger += "[TableName]" + item.TableName;
                    }
                    //

                    FlowDataTable formDataTable = formData.Tables[TableID];

                    try
                    {
                        if (formDataTable != null)
                        {
                            JObject bwTable = new JObject();
                            FormInfo.Add(bwTable);
                            bwTable["TableName"]    = TableID;
                            bwTable["DisplayName"]  = TryGetNodeAttribute(layoutTable, "Name");
                            bwTable["IsRepeatable"] = formDataTable.IsRepeatableTable;

                            JArray bwRows = new JArray();
                            bwTable["Rows"] = bwRows;
                            foreach (FlowDataRow formDataRow in formDataTable.Rows)
                            {
                                JObject bwRow = new JObject();
                                bwRows.Add(bwRow);

                                XmlNodeList layoutColumns = layoutTable.ChildNodes;
                                int         i             = 0;
                                foreach (XmlNode layoutColumn in layoutColumns)
                                {
                                    //debugger += "**" + TryGetNodeAttribute(layoutColumn, "Type") + "**";
                                    if (!string.IsNullOrEmpty(TryGetNodeAttribute(layoutColumn, "Type")) && TryGetNodeAttribute(layoutColumn, "Type").Equals("Attachment", StringComparison.OrdinalIgnoreCase))
                                    {
                                        JObject bwColumn = new JObject();

                                        bwRow["Attachments_" + layoutColumn.Name] = bwColumn;
                                        bwColumn["Name"] = TryGetNodeAttribute(layoutColumn, "Name");

                                        string FileID = Convert.ToString(formDataRow[layoutColumn.Name]);

                                        //调用方法获取附件名称,附件路径
                                        JObject Attachments = GetAttachments(FileID);

                                        JArray bwAttachments = new JArray();
                                        bwColumn["Items"] = bwAttachments;
                                        foreach (JObject item in JTokenToJArray(Attachments["files"]))
                                        {
                                            JObject attachment1 = new JObject();
                                            bwAttachments.Add(attachment1);
                                            attachment1["FileName"]    = item["name"];
                                            attachment1["DownloadUrl"] = item["DownloadUrl"];
                                        }
                                        i++;
                                    }
                                    else
                                    {
                                        JObject bwColumn = new JObject();
                                        bwRow[layoutColumn.Name] = bwColumn;
                                        bwColumn["DataType"]     = TryGetNodeAttribute(layoutColumn, "DataType");
                                        bwColumn["DataFormat"]   = TryGetNodeAttribute(layoutColumn, "DataFormat");
                                        bwColumn["Order"]        = TryGetNodeAttribute(layoutColumn, "Order");

                                        bwColumn["Name"]  = TryGetNodeAttribute(layoutColumn, "Name");
                                        bwColumn["Value"] = Convert.ToString(formDataRow[layoutColumn.Name]);
                                    }
                                }
                            }
                        }
                    }
                    catch (Exception e)
                    {
                        throw new Exception(debugger + "---------" + e.Message);
                    }
                }
            }
            else
            {
                //throw new Exception(String.Format("流程[{0}]没有布局文件[{1}]", task.ProcessName, layoutFilePath));
            }


            return(rv);
        }
Ejemplo n.º 4
0
Archivo: Form.cs Proyecto: radtek/EMIP
        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);
            }
        }
Ejemplo n.º 5
0
Archivo: Form.cs Proyecto: 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);
        }
Ejemplo n.º 6
0
        public virtual JObject GetProcessForm(HttpContext context)
        {
            YZRequest request = new YZRequest(context);
            int       stepid  = request.GetInt32("pid");
            string    uid     = YZAuthHelper.LoginUserAccount;

            BPMProcStep           step;
            BPMTask               task;
            MobileFormSetting     formSetting;
            FlowDataSet           formdataset;
            CommentItemCollection comments;

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

                step        = BPMProcStep.Load(cn, stepid);
                task        = BPMTask.Load(cn, step.TaskID);
                formSetting = BPMProcess.GetMobileFormSetting(cn, task.ProcessName, task.ProcessVersion);
                formdataset = BPMProcess.GetFormData(cn, stepid);
                comments    = BPMTask.GetComments(cn, task.TaskID);
            }

            this.ParseMobileFormSetting(formSetting);

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

            //填充form域(表单信息)
            JObject fieldset;
            JArray  items;
            JObject field;

            JObject form = new JObject();

            result["form"] = form;

            JArray formitems = new JArray();

            form["items"] = formitems;

            //基本信息的fieldset填充
            fieldset = new JObject();
            formitems.Add(fieldset);
            fieldset["xtype"]     = "fieldset";
            fieldset["innerName"] = "Header";

            //fieldset["title", "基本信息");
            items             = new JArray();
            fieldset["items"] = items;

            field = new JObject();
            items.Add(field);
            field["xclass"]  = "YZSoft.form.FormHeader";
            field["padding"] = "16 10 10 16";
            field["task"]    = this.Serialize(task);

            field = new JObject();
            items.Add(field);
            field["xclass"] = "Ext.field.Field";
            field["label"]  = Resources.YZMobile.Aspx_FormData_StepName;
            field["html"]   = step.StepDisplayName;

            field = new JObject();
            items.Add(field);
            field["xclass"] = "Ext.field.Field";
            field["label"]  = Resources.YZMobile.Aspx_FormData_Date;
            field["html"]   = YZStringHelper.DateToStringM(task.CreateAt);

            field = new JObject();
            items.Add(field);
            field["xclass"] = "Ext.field.Field";
            field["label"]  = Resources.YZMobile.Aspx_FormData_Desc;
            field["html"]   = task.Description;

            //应用移动表单设定字段 - 非可重复表
            this.ApplyMasterFields(Model.Process, form, formitems, task, step, formSetting, formdataset);

            //应用移动表单设定字段 - 可重复表
            this.ApplyDetailFields(Model.Process, form, formitems, task, step, formSetting, formdataset);

            //自定义信息
            this.ApplyCustomFields(Model.Process, form, formitems, task, step, formdataset, comments);

            //控件测试
            //this.AddTestingFields(Model.Process, form, formitems, task, step, formdataset, comments);

            return(result);
        }
Ejemplo n.º 7
0
        public virtual JObject GetPostForm(HttpContext context)
        {
            YZRequest request        = new YZRequest(context);
            string    processName    = request.GetString("processName");
            Version   processVersion = request.GetVersion("processVersion");
            int       restartTaskID  = request.GetInt32("restartTaskID", -1);
            string    uid            = YZAuthHelper.LoginUserAccount;

            MobileFormSetting     formSetting;
            FlowDataSet           formdataset;
            CommentItemCollection comments = new CommentItemCollection();
            User user = new User();

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

                user.Open(cn, uid);
                formSetting = BPMProcess.GetMobileFormSetting(cn, processName, processVersion);
                formdataset = BPMProcess.GetFormData(cn, processName, processVersion, null, restartTaskID);
            }

            this.ParseMobileFormSetting(formSetting);

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

            //填充form域(表单信息)
            JObject fieldset;
            JArray  items;

            JObject form = new JObject();

            result["form"] = form;

            JArray formitems = new JArray();

            form["items"] = formitems;

            //基本信息的fieldset填充
            fieldset = new JObject();
            formitems.Add(fieldset);
            fieldset["xtype"]     = "fieldset";
            fieldset["hidden"]    = true;
            fieldset["innerName"] = "Header";

            //fieldset["title", "基本信息");
            items             = new JArray();
            fieldset["items"] = items;

            //field = new JObject();
            //items.Add(field);
            //field["xclass"] = "Ext.field.Field";
            //field["label"] = "提交人";
            //field["html"] = user.ShortName;

            //field = new JObject();
            //items.Add(field);
            //field["xclass"] = "Ext.field.Field";
            //field["label"] = Resources.YZMobile.Aspx_FormData_Date;
            //field["html"] = YZStringHelper.DateToStringM(DateTime.Today);

            //field = new JObject();
            //items.Add(field);
            //field["xclass"] = "Ext.field.Field";
            //field["label"] = "部门";
            //field["html"] = "财务部";


            //应用移动表单设定字段 - 非可重复表
            this.ApplyMasterFields(Model.Post, form, formitems, null, null, formSetting, formdataset);

            //应用移动表单设定字段 - 可重复表
            this.ApplyDetailFields(Model.Post, form, formitems, null, null, formSetting, formdataset);

            //自定义信息
            this.ApplyCustomFields(Model.Post, form, formitems, null, null, formdataset, comments);

            //控件测试
            //this.AddTestingFields(Model.Post, form, formitems, null, null, formdataset, comments);

            return(result);
        }