Example #1
0
        public virtual void PutbackShareTask(HttpContext context)
        {
            YZRequest request = new YZRequest(context);

            this.ApproveCheck(context);

            int stepid = request.GetInt32("StepID");

            using (BPMConnection cn = new BPMConnection())
            {
                cn.WebOpen();
                BPMProcStep.PutbackShareStep(cn, stepid);
            }
        }
Example #2
0
        public virtual JArray GetRemindTarget(HttpContext context)
        {
            YZRequest request = new YZRequest(context);
            int       taskid  = request.GetInt32("TaskID");
            JArray    rv      = new JArray();

            //获得数据
            BPMStepCollection steps = null;

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

                foreach (BPMProcStep step in steps)
                {
                    if (step.Share && String.IsNullOrEmpty(step.OwnerAccount))
                    {
                        UserCollection users = BPMProcStep.GetShareUsers(cn, step.StepID);
                        foreach (User user in users)
                        {
                            JObject jStep = new JObject();
                            rv.Add(jStep);

                            jStep["StepID"]          = step.StepID;
                            jStep["Share"]           = true;
                            jStep["NodeDisplayName"] = step.StepDisplayName;
                            jStep["Account"]         = user.Account;
                            jStep["ShortName"]       = user.ShortName;
                            jStep["ElapsedMinutes"]  = (DateTime.Now - step.ReceiveAt).TotalMinutes;
                        }
                    }
                    else
                    {
                        JObject jStep = new JObject();
                        rv.Add(jStep);

                        jStep["StepID"]          = step.StepID;
                        jStep["Share"]           = false;
                        jStep["NodeDisplayName"] = step.StepDisplayName;
                        jStep["Account"]         = step.RecipientAccount;
                        jStep["ShortName"]       = step.RecipientDisplayName;
                        jStep["ElapsedMinutes"]  = (DateTime.Now - step.ReceiveAt).TotalMinutes;
                    }
                }
            }

            return(rv);
        }
Example #3
0
        public virtual object PickupShareStep(HttpContext context)
        {
            YZRequest request = new YZRequest(context);
            int       stepid  = request.GetInt32("StepID");

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

                return(new
                {
                    stepid = BPMProcStep.PickupShareStep(cn, stepid)
                });
            }
        }
Example #4
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);
        }
Example #5
0
        public virtual DataTable GetProcessAnalysisByNode(HttpContext context)
        {
            YZRequest request     = new YZRequest(context);
            string    type        = request.GetString("Type", "year");
            int       year        = request.GetInt32("year", DateTime.Today.Year);
            int       month       = request.GetInt32("month", -1);
            string    processName = request.GetString("ProcessName");
            string    orderby     = request.GetString("OrderBy");

            if (String.Compare(type, "year", true) == 0)
            {
                month = -1;
            }

            DataTable table;

            using (IYZDbProvider provider = YZDbProviderManager.DefaultProvider)
            {
                using (IDbConnection cn = provider.OpenConnection())
                {
                    using (YZReader reader = new YZReader(provider.GetProcessAnalysisByNode(cn, year, month, processName, orderby)))
                    {
                        table = reader.LoadTable();
                        PageResult.RegularColumnsName(table, new string[] {
                            "NodeName",
                            "Counts",
                            "SumMinutes",
                            "AvgMinutes",
                            "MaxMinutes",
                            "TotalMinutes",
                            "Per"
                        });
                    }
                }
            }

            //补齐信息
            table.Columns.Add("NodeDisplayName", typeof(string));
            foreach (DataRow row in table.Rows)
            {
                string nodeName = Convert.ToString(row["NodeName"]);
                row["NodeDisplayName"] = BPMProcStep.GetStepDisplayName(nodeName);
            }

            return(table);
        }
Example #6
0
        public virtual JObject HandoverSteps(HttpContext context)
        {
            JArray processedItems = new JArray();

            try
            {
                YZRequest request        = new YZRequest(context);
                string    leavingUid     = request.GetString("uid");
                string    memberFullName = request.GetString("MemberFullName");
                JObject   jPost          = request.GetPostData <JObject>();
                string    comments       = (string)jPost["comments"];
                JArray    items          = jPost["items"] as JArray;

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

                    foreach (JObject item in items)
                    {
                        int stepid = (int)item["StepID"];
                        int id     = (int)item["ID"];

                        BPMProcStep.HandOverStep(cn, stepid, leavingUid, memberFullName, comments);

                        JObject processedItem = new JObject();
                        processedItem["ID"] = id;
                        processedItems.Add(processedItem);
                    }

                    JObject rv = new JObject();
                    rv[YZJsonProperty.success]        = true;
                    rv[YZJsonProperty.processedItems] = processedItems;

                    return(rv);
                }
            }
            catch (Exception exp)
            {
                JObject rv = new JObject();
                rv[YZJsonProperty.success]        = false;
                rv[YZJsonProperty.errorMessage]   = exp.Message;
                rv[YZJsonProperty.processedItems] = processedItems;

                return(rv);
            }
        }
Example #7
0
        public virtual JArray GetRecedeBackSteps(HttpContext context)
        {
            YZRequest request = new YZRequest(context);
            int       stepid  = request.GetInt32("StepID");
            JObject   rv      = new JObject();

            //获得数据
            BPMStepCollection steps = null;

            using (BPMConnection cn = new BPMConnection())
            {
                cn.WebOpen();
                steps = BPMProcStep.GetRecedableToSteps(cn, stepid);
            }

            return(this.Serialize(steps));
        }
Example #8
0
        public virtual JObject Pickback(HttpContext context)
        {
            YZRequest request  = new YZRequest(context);
            int       taskid   = request.GetInt32("TaskID");
            int       stepid   = request.GetInt32("StepID");
            string    comments = request.GetString("Comments", null);

            using (BPMConnection cn = new BPMConnection())
            {
                cn.WebOpen();
                BPMProcStep step = BPMTask.PickBack(cn, taskid, stepid, comments);

                JObject rv = new JObject();
                rv["StepName"]         = step.NodeName;
                rv["UserFriendlyName"] = YZStringHelper.GetUserFriendlyName(step.RecipientAccount, step.RecipientFullName);
                return(rv);
            }
        }
Example #9
0
        public virtual JObject BatchApprove(HttpContext context)
        {
            JArray processedItems = new JArray();

            try
            {
                YZRequest request = new YZRequest(context);
                JObject   jPost   = request.GetPostData <JObject>();
                JArray    items   = (JArray)jPost["items"];

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

                    foreach (JObject item in items)
                    {
                        int        id     = (int)item["ID"];
                        int        stepid = (int)item["StepID"];
                        PostResult result = BPMProcStep.Approve(cn, stepid);

                        JObject processedItem = new JObject();
                        processedItem["ID"]        = id;
                        processedItem["SerialNum"] = result.SN;
                        processedItem["Result"]    = YZStringHelper.GetPostResultDisplayStringShort(result);
                        processedItems.Add(processedItem);
                    }

                    JObject rv = new JObject();
                    rv[YZJsonProperty.success]        = true;
                    rv[YZJsonProperty.processedItems] = processedItems;

                    return(rv);
                }
            }
            catch (Exception exp)
            {
                JObject rv = new JObject();
                rv[YZJsonProperty.success]        = false;
                rv[YZJsonProperty.errorMessage]   = exp.Message;
                rv[YZJsonProperty.processedItems] = processedItems;

                return(rv);
            }
        }
Example #10
0
        protected virtual BPMProcStep GetSimulateStep(BPMTask task, User user)
        {
            BPMProcStep step = new BPMProcStep();

            step.StepID                 = 13009;
            step.TaskID                 = 12001;
            step.ProcessName            = task.ProcessName;
            step.ProcessVersion         = task.ProcessVersion;
            step.NodeName               = "经理审批";
            step.OwnerAccount           = user.Account;
            step.OwnerPositionID        = 1006;
            step.OwnerFullName          = user.DisplayName;
            step.AgentAccount           = null;
            step.AgentFullName          = null;
            step.ReceiveAt              = DateTime.Now.AddHours(-2);
            step.FinishAt               = DateTime.MinValue;
            step.SelAction              = null;
            step.Share                  = false;
            step.Memo                   = null;
            step.IsHumanStep            = true;
            step.HandlerAccount         = null;
            step.HandlerFullName        = null;
            step.SubNodeName            = null;
            step.AutoProcess            = false;
            step.Comments               = null;
            step.UsedMinutes            = -1;
            step.UsedMinutesWork        = -1;
            step.RecedeFromStep         = -1;
            step.TimeoutNotifyCount     = 0;
            step.RisedConsignID         = -1;
            step.BelongConsignID        = -1;
            step.ConsignOwnerAccount    = null;
            step.TimeoutFirstNotifyDate = DateTime.Now.AddDays(1);
            step.TimeoutDeadline        = DateTime.Now.AddDays(2);
            step.StandardMinutesWork    = 24 * 60;
            step.BatchApprove           = false;
            step.Posted                 = false;
            step.FormSaved              = false;
            step.ParentStepID           = 01;
            step.NodePath               = null;

            return(step);
        }
Example #11
0
        public virtual JObject RecedeBack(HttpContext context)
        {
            YZRequest request = new YZRequest(context);

            this.ApproveCheck(context);

            int        stepid    = request.GetInt32("StepID");
            JObject    jPost     = request.GetPostData <JObject>();
            string     comments  = (string)jPost["comments"];
            string     formdata  = (string)jPost["formdata"];
            List <int> toStepIDs = jPost["toStepIDs"].ToObject <List <int> >();

            BPMTask     task;
            BPMProcStep srcStep;

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

                //移动审批不保存表单数据
                if (!String.IsNullOrEmpty(formdata))
                {
                    BPMProcess.Post(cn, formdata);
                }

                srcStep = BPMProcStep.Load(cn, stepid);
                task    = BPMTask.Load(cn, srcStep.TaskID);

                BPMStepCollection newSteps = BPMProcStep.RecedeBack(cn, stepid, toStepIDs.ToArray(), comments);
                List <string>     to       = new List <string>();
                foreach (BPMProcStep step in newSteps)
                {
                    to.Add(String.Format("{0}[{1}]", step.NodeName, YZStringHelper.GetUserFriendlyName(step.RecipientAccount, step.RecipientFullName)));
                }

                JObject rv = new JObject();
                rv[YZJsonProperty.success] = true;
                rv["sn"]      = task.SerialNum;
                rv["tosteps"] = String.Join(";", to.ToArray());

                return(rv);
            }
        }
Example #12
0
        public virtual JObject PutbackShareTaskExt(HttpContext context)
        {
            JArray processedItems = new JArray();

            try
            {
                YZRequest request = new YZRequest(context);
                JObject   jPost   = request.GetPostData <JObject>();
                JArray    items   = (JArray)jPost["items"];

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

                    foreach (JObject item in items)
                    {
                        int id     = (int)item["ID"];
                        int stepid = (int)item["StepID"];
                        BPMProcStep.PutbackShareStep(cn, stepid);

                        JObject processedItem = new JObject();
                        processedItem["ID"] = id;
                        processedItems.Add(processedItem);
                    }

                    JObject rv = new JObject();
                    rv[YZJsonProperty.success]        = true;
                    rv[YZJsonProperty.processedItems] = processedItems;

                    return(rv);
                }
            }
            catch (Exception exp)
            {
                JObject rv = new JObject();
                rv[YZJsonProperty.success]        = false;
                rv[YZJsonProperty.errorMessage]   = exp.Message;
                rv[YZJsonProperty.processedItems] = processedItems;

                return(rv);
            }
        }
Example #13
0
        internal static JObject Serialize(BPMConnection cn, BPMProcStep step)
        {
            JObject item = new JObject();

            string stepMemo = null;

            if ((step.IsIndicateStep || step.IsInformStep) && String.IsNullOrEmpty(step.Memo))
            {
                BPMStepCollection prevSteps = step.LoadPrevSteps(cn);
                if (prevSteps.Count != 0)
                {
                    BPMProcStep prevStep = prevSteps[0];
                    stepMemo = "<span class='yz-stepraiser'>" + String.Format(Resources.YZStrings.Aspx_StepRaiser, YZStringHelper.GetUserShortName(prevStep.HandlerAccount, prevStep.HandlerFullName)) + "</span>";
                }
            }

            item["TaskID"]               = step.TaskID;
            item["StepID"]               = step.StepID;
            item["ProcessName"]          = step.ProcessName;
            item["ProcessVersion"]       = step.ProcessVersion.ToString(2);
            item["NodeNameOrg"]          = step.NodeName;
            item["NodeName"]             = HttpUtility.HtmlEncode(step.StepDisplayName) + stepMemo;
            item["SelAction"]            = step.SelActionDisplayString;
            item["OwnerAccount"]         = step.OwnerAccount;
            item["OwnerDisplayName"]     = step.OwnerFullName;
            item["AgentAccount"]         = step.AgentAccount;
            item["AgentDisplayName"]     = step.AgentFullName;
            item["FinishAt"]             = step.FinishAt;
            item["ReceiveAt"]            = step.ReceiveAt;
            item["IsConsignStep"]        = step.IsConsignStep;
            item["RecipientAccount"]     = step.RecipientAccount;
            item["RecipientDisplayName"] = step.RecipientFullName;
            item["HandlerAccount"]       = step.HandlerAccount;
            item["HandlerDisplayName"]   = step.HandlerFullName;
            item["Comments"]             = step.Comments;
            item["Share"]       = step.Share;
            item["Memo"]        = step.Memo;
            item["AutoProcess"] = step.AutoProcess;

            return(item);
        }
Example #14
0
File: Form.cs Project: radtek/EMIP
        protected virtual JObject GetDirectSendInfo(BPMConnection cn, BPMProcStep step, SystemLinkCollection systemLinks)
        {
            if (step.RecedeFromStep == -1)
            {
                return(null);
            }

            int        idx            = systemLinks.Find(SystemLinkType.DirectSend);
            SystemLink directSendLink = idx == -1 ? null:systemLinks[idx];

            if (directSendLink != null && !directSendLink.Enabled)
            {
                return(null);
            }

            BPMStepCollection toSteps = null;

            toSteps = BPMProcStep.GetDirectSendTargetSteps(cn, step.StepID);

            if (toSteps == null || toSteps.Count == 0)
            {
                return(null);
            }

            JObject rv       = new JObject();
            JArray  jtoSteps = new JArray();

            rv["toSteps"]         = jtoSteps;
            rv["validationGroup"] = directSendLink.ValidationGroup;

            foreach (BPMProcStep toStep in toSteps)
            {
                JObject jtoStep = new JObject();
                jtoSteps.Add(jtoStep);

                jtoStep["NodeName"] = toStep.NodeName;
                jtoStep["User"]     = YZStringHelper.GetUserShortName(toStep.RecipientAccount, toStep.RecipientFullName);
            }

            return(rv);
        }
Example #15
0
        public virtual object GetStepOverviewInfo(HttpContext context)
        {
            YZRequest request = new YZRequest(context);
            int       stepid  = request.GetInt32("stepid");

            string      fileid;
            string      spriteid;
            BPMProcStep step;

            using (BPMConnection cn = new BPMConnection())
            {
                cn.WebOpen();
                BPMProcStep.GetRelatedSprite(cn, stepid, out fileid, out spriteid);
                step = BPMProcStep.Load(cn, stepid);
            }

            using (IYZDbProvider provider = YZDbProviderManager.DefaultProvider)
            {
                using (IDbConnection cn = provider.OpenConnection())
                {
                    File file = File.Load(provider, cn, fileid);

                    Sprite sprite = file.Sprites[spriteid];
                    sprite.AllReferences.RefreshName(provider, cn);

                    SpriteCollection usedby = sprite.GetUsedBySprites(provider, cn);

                    return(new
                    {
                        sprite = sprite,
                        usedby = usedby.Identities,
                        usedbyFiles = usedby.Files.Identities,
                        parentProcess = new {
                            ProcessName = step.ProcessName,
                            Version = step.ProcessVersion.ToString(2)
                        }
                    });
                }
            }
        }
Example #16
0
File: Form.cs Project: radtek/EMIP
        public virtual JObject SubmitAuth(HttpContext context)
        {
            YZRequest request = new YZRequest(context);
            int       stepid  = request.GetInt32("StepID", -1);
            string    pwd     = request.GetString("Password", null);

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

                string uid = null;
                if (stepid != -1)
                {
                    BPMProcStep step = BPMProcStep.Load(cn, stepid);
                    uid = step.RecipientAccount;
                }
                else
                {
                    uid = cn.UID;
                }

                JObject rv = new JObject();
                rv[YZJsonProperty.success] = true;

                string token;
                if (BPMConnection.Authenticate(YZAuthHelper.BPMServerName, YZAuthHelper.BPMServerPort, uid, pwd, out uid, out token))
                {
                    rv["pass"] = true;
                }
                else
                {
                    rv["pass"] = false;
                }

                return(rv);
            }
        }
Example #17
0
        protected virtual BPMStepCollection GetSimulateSteps(BPMTask task, BPMProcStep step, User user)
        {
            BPMStepCollection steps = new BPMStepCollection();

            steps.Add(step);

            BPMProcStep step1;

            step1                 = new BPMProcStep();
            step1.StepID          = 13002;
            step1.TaskID          = 12001;
            step1.NodeName        = "部长审批";
            step1.FinishAt        = DateTime.Now.AddDays(-2);
            step1.OwnerAccount    = "44144";
            step1.OwnerFullName   = "李四";
            step1.HandlerAccount  = "44144";
            step1.HandlerFullName = "李四";
            step1.SelAction       = "同意";
            step1.Comments        = "很棒!";
            steps.Add(step1);

            step1                 = new BPMProcStep();
            step1.StepID          = 13001;
            step1.TaskID          = 12001;
            step1.NodeName        = "开始";
            step1.FinishAt        = DateTime.Now.AddDays(-2);
            step1.OwnerAccount    = "33133";
            step1.OwnerFullName   = "张三";
            step1.HandlerAccount  = "33133";
            step1.HandlerFullName = "张三";
            step1.SelAction       = "提交";
            step1.Comments        = "";
            steps.Add(step1);

            return(steps);
        }
Example #18
0
        protected virtual JObject Serialize(BPMConnection cn, BPMTaskListCollection tasks, int rowcount)
        {
            JObject rv = new JObject();

            //将数据转化为Json集合
            rv[YZJsonProperty.total] = rowcount;

            JArray children = new JArray();

            rv[YZJsonProperty.children] = children;

            foreach (BPMTaskListItem task in tasks)
            {
                JObject item = new JObject();
                children.Add(item);

                string stepDisplayName = BPMProcStep.GetStepDisplayName(task.StepName);

                item["StepID"]                 = task.StepID;
                item["TaskID"]                 = task.TaskID;
                item["SerialNum"]              = task.SerialNum;
                item["ProcessName"]            = task.ProcessName;
                item["ProcessVersion"]         = task.ProcessVersion.ToString(2);
                item["OwnerAccount"]           = task.OwnerAccount;
                item["OwnerDisplayName"]       = task.OwnerDisplayName;
                item["AgentAccount"]           = task.AgentAccount;
                item["AgentDisplayName"]       = task.AgentDisplayName;
                item["CreateAt"]               = task.CreateAt;
                item["NodeName"]               = stepDisplayName;
                item["ReceiveAt"]              = task.ReceiveAt;
                item["Share"]                  = task.Share;
                item["TimeoutFirstNotifyDate"] = task.TimeoutFirstNotifyDate;
                item["TimeoutDeadline"]        = task.TimeoutDeadline;
                item["TimeoutNotifyCount"]     = task.TimeoutNotifyCount;
                item["Description"]            = task.Description;

                if (task.Progress != -1)
                {
                    item["Progress"] = task.Progress;
                }

                try
                {
                    string memberFullName = PositionManager.MemberFullNameFromID(cn, task.OwnerPositionID);
                    OU     ou             = Member.GetParentOU(cn, memberFullName, null);

                    item["Owner"] = String.Format("{0}/{1}", task.OwnerDisplayName, ou.Name);
                }
                catch (Exception)
                {
                    item["Owner"] = task.OwnerDisplayName;
                }

                try
                {
                    ProcessProperty property = BPMProcess.GetProcessProperty(cn, task.ProcessName, task.ProcessVersion);
                    item["ShortName"] = property.ShortName;
                    item["Color"]     = property.Color;

                    if (String.IsNullOrEmpty(property.ShortName))
                    {
                        item["ShortName"] = YZStringHelper.GetProcessDefaultShortName(task.ProcessName);
                    }
                }
                catch (Exception)
                {
                    item["Color"]     = this._deletedProcessColor;
                    item["ShortName"] = YZStringHelper.GetProcessDefaultShortName(task.ProcessName);
                }

                JObject perm = new JObject();
                item["perm"]  = perm;
                perm["Share"] = task.Share;
            }

            return(rv);
        }
Example #19
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);
        }
Example #20
0
    public static string GetSelActionDisplayString(BPMProcStep step)
    {
        if (!step.Finished)
            return Resources.YZStrings.All_Running;

        if (YZStringHelper.EquName(step.SelAction, SystemAction.Abort))
            return Resources.YZStrings.Aspx_SysAct_Abort;

        if (YZStringHelper.EquName(step.SelAction, SystemAction.RecedeBack))
            return Resources.YZStrings.Aspx_SysAct_RecedeBack;

        if (YZStringHelper.EquName(step.SelAction, SystemAction.AssignOwner))
            return Resources.YZStrings.Aspx_SysAct_AssignOwner;

        if (YZStringHelper.EquName(step.SelAction, SystemAction.Continue))
            return Resources.YZStrings.Aspx_SysAct_Continue;

        if (YZStringHelper.EquName(step.SelAction, SystemAction.Delete))
            return Resources.YZStrings.Aspx_SysAct_Delete;

        if (YZStringHelper.EquName(step.SelAction, SystemAction.Jump))
            return Resources.YZStrings.Aspx_SysAct_Jump + "(" + step.Memo + ")";

        if (YZStringHelper.EquName(step.SelAction, SystemAction.TimeoutJump))
            return Resources.YZStrings.Aspx_SysAct_TimeoutJump + "(" + step.Memo + ")";

        if (YZStringHelper.EquName(step.SelAction, SystemAction.PickBackRestart))
            return Resources.YZStrings.Aspx_SysAct_PickbackRestart;

        if (YZStringHelper.EquName(step.SelAction, SystemAction.PickBack))
            return Resources.YZStrings.Aspx_SysAct_Pickback;

        if (YZStringHelper.EquName(step.SelAction, SystemAction.RecedeRestart))
            return Resources.YZStrings.Aspx_SysAct_RecedeRestart;

        if (YZStringHelper.EquName(step.SelAction, SystemAction.Reject))
            return Resources.YZStrings.Aspx_SysAct_Reject;

        if (YZStringHelper.EquName(step.SelAction, SystemAction.Transfer))
            return Resources.YZStrings.Aspx_SysAct_Agent;

        if (YZStringHelper.EquName(step.SelAction, SystemAction.DirectSend))
            return Resources.YZStrings.Aspx_SysAct_DirectSend;

        if (YZStringHelper.EquName(step.SelAction, SystemAction.InviteIndicate))
            return Resources.YZStrings.Aspx_SysAct_InviteIndicate;

        if (!step.AutoProcess)
            return step.SelAction;
        else
            return step.SelAction + "(" + Resources.YZStrings.Aspx_Auto + ")";
    }
Example #21
0
        public virtual void AddTestingFields(JObject form, JArray formitems, JObject fieldset, JArray items, BPMTask task, BPMProcStep step, FlowDataSet formdataset, CommentItemCollection comments)
        {
            JObject field;

            fieldset = new JObject();
            formitems.Add(fieldset);
            items             = new JArray();
            fieldset["items"] = items;

            field = new JObject();
            items.Add(field);
            field["xclass"] = "Ext.field.Text";
            field["label"]  = "Text";
            field["value"]  = task.ProcessName;

            field = new JObject();
            items.Add(field);
            field["xclass"] = "Ext.field.Number";
            field["label"]  = "Number";
            field["value"]  = 123;

            field = new JObject();
            items.Add(field);
            field["xclass"] = "Ext.field.TextArea";
            field["label"]  = "TextArea";
            field["value"]  = task.ProcessName;

            field = new JObject();
            items.Add(field);
            field["xclass"] = "Ext.field.DatePicker";
            field["label"]  = "DatePicker";
            field["value"]  = DateTime.Today;

            field = new JObject();
            items.Add(field);
            field["xclass"] = "Ext.field.Email";
            field["label"]  = "Email";
            field["value"]  = task.ProcessName;

            field = new JObject();
            items.Add(field);
            field["xclass"] = "Ext.field.Password";
            field["label"]  = "Password";
            field["value"]  = "123";

            field = new JObject();
            items.Add(field);
            field["xclass"] = "Ext.field.Checkbox";
            field["label"]  = "Checkbox";
            field["value"]  = true;

            field = new JObject();
            items.Add(field);
            field["xclass"] = "Ext.field.Radio";
            field["label"]  = "Radio";
            field["value"]  = true;

            //field = new JObject();
            //items.Add(field);
            //field["xclass"] = "Ext.field.Select";
            //field["label"] = "Select";
            //field["value"] = "SH";

            //field = new JObject();
            //items.Add(field);
            //field["xclass"] = "YZSoft$ux.field.Attachment";
            //field["label"] = "Attachment";
            //field["value"] = task.ProcessName;
        }
Example #22
0
        //应用移动表单设定字段 - 可重复表
        protected virtual void ApplyDetailFields(Model model, JObject form, JArray formitems, BPMTask task, BPMProcStep step, MobileFormSetting formSetting, FlowDataSet formdataset)
        {
            foreach (FlowDataTable table in formSetting.ControlDataSet.Tables)
            {
                FlowDataTable srcTable = formdataset.Tables.TryGetTable(table.TableName);
                if (srcTable == null)
                {
                    continue;
                }

                if (!srcTable.IsRepeatableTable)
                {
                    continue;
                }

                JArray citems = this.GenFieldItems(model, srcTable, table);
                foreach (JObject citem in citems)
                {
                    formitems.Add(citem);
                }
            }
        }
Example #23
0
File: Form.cs Project: radtek/EMIP
        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);
            }
        }
Example #24
0
        //根据流程名调用相应的函数,一个流程一个文件,参考“我的流程1、我的流程2”
        protected virtual void ApplyCustomFields(Model model, JObject form, JArray formitems, BPMTask task, BPMProcStep step, FlowDataSet formdataset, CommentItemCollection comments)
        {
            string processName = "";
            //string processName = "我的流程1";  //表单定制演示
            string functionName = "Form_" + processName;

            MethodInfo method = this.GetType().GetMethod(functionName, BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public);

            if (method != null)
            {
                method.Invoke(this, new object[] { model, form, formitems, task, step, formdataset, comments });
            }

            this.Default(model, form, formitems, task, step, formdataset, comments);
        }
Example #25
0
File: Form.cs Project: 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);
        }
Example #26
0
 protected virtual void Default(Model model, JObject form, JArray formitems, BPMTask task, BPMProcStep step, FlowDataSet formdataset, CommentItemCollection comments)
 {
 }
Example #27
0
        private void Form_我的流程2(Model model, JObject form, JArray formitems, BPMTask task, BPMProcStep step, FlowDataSet formdataset, CommentItemCollection comments)
        {
            JObject fieldset;
            JArray  items;
            JObject field;
            int     index;

            //在头部加入一行
            fieldset = this.TryGetFieldSet(form, "Header");
            items    = fieldset["items"] as JArray;

            field = new JObject();
            items.Add(field);
            field["xclass"] = "Ext.field.Field";
            field["label"]  = "AAA";
            field["html"]   = "AAAValue";

            //在表Purchase中加入一行
            fieldset = this.TryGetFieldSet(form, "Purchase");
            items    = fieldset["items"] as JArray;

            field = new JObject();
            items.Add(field);
            field["xclass"] = "Ext.field.Field";
            field["label"]  = "BBB";
            field["html"]   = "BBBValue";

            //在表Purchase前加入一个fieldset
            fieldset = this.TryGetFieldSet(form, "Purchase");
            index    = formitems.IndexOf(fieldset);

            fieldset = new JObject();
            formitems.Insert(index, fieldset);
            fieldset["xtype"] = "fieldset";

            items             = new JArray();
            fieldset["items"] = items;

            field = new JObject();
            items.Add(field);
            field["xclass"] = "Ext.field.Field";
            field["label"]  = "CCC";
            field["html"]   = "CCCValue";

            //在末尾加入一行
            fieldset = new JObject();
            formitems.Add(fieldset);
            fieldset["xtype"] = "fieldset";

            items             = new JArray();
            fieldset["items"] = items;

            field = new JObject();
            items.Add(field);
            field["xclass"] = "Ext.field.Field";
            field["label"]  = "DDD";
            field["html"]   = "DDDValue";

            field = new JObject();
            items.Add(field);
            field["xclass"] = "Ext.field.Field";
            field["label"]  = "EEE";
            field["html"]   = "EEEValue";
        }
Example #28
0
        public void GetTaskLst(String UserAccount)
        {
            IDictionary<String, Dictionary<String, String>> DictLst = new Dictionary<String, Dictionary<String, String>>();

            // SecurityToken token = null;
            // YZAuthHelper.AuthCheck();

            // string LoginUserAccount = YZAuthHelper.LoginUserAccount;

            YZAuthHelper.OAuth();

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

                int taskCount = cn.GetMyTaskCount();
                //int ShareTaskCount = cn.GetShareTaskCount();

                int ProcessNameCounts = 0;
                var TaskList = cn.GetMyTaskList();

                foreach (BPM.Client.BPMTaskListItem BPMTaskList in TaskList)
                {

                    int TaskID = BPMTaskList.TaskID;
                    String TaskState = BPMTaskList.TaskState.ToString();
                    String SerialNum = BPMTaskList.SerialNum;
                    String ProcessName = BPMTaskList.ProcessName;
                    String OwnerDisplayName = BPMTaskList.OwnerDisplayName;
                    String StepName = BPMTaskList.StepID + "-" + BPMTaskList.StepName;


                    if (!DictLst.ContainsKey(ProcessName))
                    {

                        ProcessName = String.Format("ProcessName=N'{0}'", ProcessName);

                        TaskList = cn.GetMyTaskList(ProcessName, "StepID DESC", 0, 100, out ProcessNameCounts);
                        Dictionary<String, String> iDict = new Dictionary<String, String>();
                        foreach (BPM.Client.BPMTaskListItem thisTaskList in TaskList)
                        {
                            string stepDisplayName = BPMProcStep.GetStepDisplayName(thisTaskList.StepName);

                            TaskID = thisTaskList.TaskID;
                            TaskState = thisTaskList.TaskState.ToString();
                            SerialNum = thisTaskList.SerialNum;
                            ProcessName = thisTaskList.ProcessName;
                            OwnerDisplayName = thisTaskList.OwnerDisplayName;
                            StepName = thisTaskList.StepID + "-" + stepDisplayName;

                            String Keys = SerialNum + "|" + StepName + "|" + OwnerDisplayName;
                            iDict.Add(Keys, ProcessName);
                        }

                        ProcessName = ProcessName + "|" + ProcessNameCounts;

                        if (!DictLst.ContainsKey(ProcessName))
                            DictLst.Add(ProcessName, iDict);
                    }

                }
            }

            // return DictLst;

        }
Example #29
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);
        }
Example #30
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);
        }
Example #31
0
    public static string GetSelActionDisplayString(BPMProcStep step)
    {
        if (!step.Finished)
        {
            return(Resources.YZStrings.All_Running);
        }

        if (YZStringHelper.EquName(step.SelAction, SystemAction.Abort))
        {
            return(Resources.YZStrings.Aspx_SysAct_Abort);
        }

        if (YZStringHelper.EquName(step.SelAction, SystemAction.RecedeBack))
        {
            return(Resources.YZStrings.Aspx_SysAct_RecedeBack);
        }

        if (YZStringHelper.EquName(step.SelAction, SystemAction.AssignOwner))
        {
            return(Resources.YZStrings.Aspx_SysAct_AssignOwner);
        }

        if (YZStringHelper.EquName(step.SelAction, SystemAction.Continue))
        {
            return(Resources.YZStrings.Aspx_SysAct_Continue);
        }

        if (YZStringHelper.EquName(step.SelAction, SystemAction.Delete))
        {
            return(Resources.YZStrings.Aspx_SysAct_Delete);
        }

        if (YZStringHelper.EquName(step.SelAction, SystemAction.Jump))
        {
            return(Resources.YZStrings.Aspx_SysAct_Jump + "(" + step.Memo + ")");
        }

        if (YZStringHelper.EquName(step.SelAction, SystemAction.TimeoutJump))
        {
            return(Resources.YZStrings.Aspx_SysAct_TimeoutJump + "(" + step.Memo + ")");
        }

        if (YZStringHelper.EquName(step.SelAction, SystemAction.PickBackRestart))
        {
            return("重新取回");// Resources.YZStrings.Aspx_SysAct_PickbackRestart;
        }
        if (YZStringHelper.EquName(step.SelAction, SystemAction.PickBack))
        {
            return("取回");// Resources.YZStrings.Aspx_SysAct_Pickback;
        }
        if (YZStringHelper.EquName(step.SelAction, SystemAction.RecedeRestart))
        {
            return(Resources.YZStrings.Aspx_SysAct_RecedeRestart);
        }

        if (YZStringHelper.EquName(step.SelAction, SystemAction.Reject))
        {
            return(Resources.YZStrings.Aspx_SysAct_Reject);
        }

        if (YZStringHelper.EquName(step.SelAction, SystemAction.Transfer))
        {
            return(Resources.YZStrings.Aspx_SysAct_Agent);
        }

        if (YZStringHelper.EquName(step.SelAction, SystemAction.DirectSend))
        {
            return(Resources.YZStrings.Aspx_SysAct_DirectSend);
        }

        if (YZStringHelper.EquName(step.SelAction, SystemAction.InviteIndicate))
        {
            return(Resources.YZStrings.Aspx_SysAct_InviteIndicate);
        }

        if (!step.AutoProcess)
        {
            return(step.SelAction);
        }
        else
        {
            return(step.SelAction + "(" + Resources.YZStrings.Aspx_Auto + ")");
        }
    }