Esempio n. 1
0
        public virtual JObject GetTestingTemplates(HttpContext context)
        {
            string    loginAccount = YZAuthHelper.LoginUserAccount;
            YZRequest request      = new YZRequest(context);
            string    processName  = request.GetString("ProcessName", null);

            IYZDbProvider provider = YZDbProviderManager.DefaultProvider;

            //System.Threading.Thread.Sleep(2000);
            //获得数据
            BPMDraftCollection drafts = new BPMDraftCollection();
            int     rowcount          = 0;
            JObject rv = new JObject();

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

                if (!String.IsNullOrEmpty(processName))
                {
                    drafts = cn.GetTestingTemplates(processName, null, null, request.GetSortString("CreateDate DESC"), 0, Int32.MaxValue, out rowcount);
                }

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

                JArray children = new JArray();
                rv[YZJsonProperty.children] = children;

                foreach (BPMDraft draft in drafts)
                {
                    JObject item = new JObject();
                    children.Add(item);

                    item["DraftID"]      = draft.DraftGuid.ToString();
                    item["ProcessName"]  = draft.ProcessName;
                    item["CreateDate"]   = draft.CreateDate;
                    item["ModifyDate"]   = draft.ModifyDate;
                    item["Account"]      = draft.Account;
                    item["OwnerAccount"] = draft.OwnerAccount;
                    item["Comments"]     = draft.Comments;
                    item["Description"]  = draft.Description;
                    if (!NameCompare.EquName(draft.OwnerAccount, loginAccount))
                    {
                        item["Owner"] = PositionManager.MemberFullNameFromID(cn, draft.OwnerPositionID);
                    }
                }
            }

            return(rv);
        }
Esempio n. 2
0
        public virtual JObject GetDrafts(HttpContext context)
        {
            YZRequest    request      = new YZRequest(context);
            string       loginAccount = YZAuthHelper.LoginUserAccount;
            GridPageInfo gridPageInfo = new GridPageInfo(context);

            //System.Threading.Thread.Sleep(2000);
            //获得数据
            BPMDraftCollection drafts = new BPMDraftCollection();
            int     rowcount;
            JObject rv = new JObject();

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

                drafts = cn.GetMyDrafts(DraftType.Draft, null, request.GetSortString("CreateDate DESC"), gridPageInfo.Start, gridPageInfo.Limit, out rowcount);

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

                JArray children = new JArray();
                rv[YZJsonProperty.children] = children;

                foreach (BPMDraft draft in drafts)
                {
                    JObject item = new JObject();
                    children.Add(item);

                    item["DraftID"]      = draft.DraftGuid.ToString();
                    item["ProcessName"]  = draft.ProcessName;
                    item["CreateDate"]   = draft.CreateDate;
                    item["ModifyDate"]   = draft.ModifyDate;
                    item["Account"]      = draft.Account;
                    item["OwnerAccount"] = draft.OwnerAccount;
                    item["Comments"]     = draft.Comments;
                    item["Description"]  = draft.Description;
                    if (!NameCompare.EquName(draft.OwnerAccount, loginAccount))
                    {
                        item["Owner"] = PositionManager.MemberFullNameFromID(cn, draft.OwnerPositionID);
                    }
                }
            }

            //输出数据
            return(rv);
        }
Esempio n. 3
0
File: Form.cs Progetto: radtek/EMIP
        public virtual JObject GetPostInfo(HttpContext context)
        {
            YZRequest request       = new YZRequest(context);
            string    processName   = request.GetString("pn", null);
            int       restartTaskID = request.GetInt32("restartTaskID", -1);
            string    owner         = request.GetString("owner", null);
            string    permisions    = request.GetString("Permisions", null);
            string    did           = request.GetString("did", null);

            Version          processVersion = null;
            PostInfo         postInfo;
            JObject          perm;
            BPMDraft         draft        = null;
            JObject          jDraftHeader = null;
            bool             delagation;
            string           selectPosition;
            MemberCollection positions;
            JObject          rv = new JObject();
            PostSubModel     subModel;

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

                if (!String.IsNullOrEmpty(did))
                {
                    draft = new BPMDraft();
                    draft.Open(cn, new Guid(did));
                    processName = draft.ProcessName;

                    if (!String.IsNullOrEmpty(draft.Header))
                    {
                        jDraftHeader = JObject.Parse(draft.Header);
                    }
                }

                if (draft != null)
                {
                    subModel = (PostSubModel)Enum.Parse(typeof(PostSubModel), draft.Type.ToString());
                }
                else
                {
                    subModel = PostSubModel.Post;
                }

                if (restartTaskID == -1)
                {
                    processVersion = cn.GetGlobalObjectLastVersion(StoreZoneType.Process, processName);
                }

                postInfo = BPMProcess.GetPostInfo(cn, processName, processVersion, owner, restartTaskID);
                perm     = this.CheckPermision(postInfo, permisions);

                //获得delagation/selectPosition
                if (draft != null)
                {
                    selectPosition = PositionManager.MemberFullNameFromID(cn, draft.OwnerPositionID);
                    delagation     = !YZStringHelper.EquName(draft.OwnerAccount, cn.UID);
                }
                else
                {
                    if (postInfo.IsPostByAgent)
                    {
                        delagation     = true;
                        selectPosition = owner;
                    }
                    else
                    {
                        delagation     = false;
                        selectPosition = owner;
                    }
                }

                //获得positions
                if (!delagation)
                {
                    positions = OrgSvr.GetUserPositions(cn, cn.UID);
                    if (String.IsNullOrEmpty(selectPosition) && positions.Count != 0)
                    {
                        selectPosition = positions[0].FullName;
                    }
                }
                else
                {
                    Member mb = new Member();
                    mb.Open(cn, selectPosition);
                    positions      = OrgSvr.GetUserPositions(cn, mb.UserAccount);
                    selectPosition = mb.FullName;
                }

                if (String.IsNullOrEmpty(postInfo.FormFile))
                {
                    throw new Exception(Resources.YZStrings.Aspx_Post_MissForm);
                }

                //返回
                rv[YZJsonProperty.success] = true;
                rv["subModel"]             = subModel.ToString();

                //基本信息
                rv["pn"]             = postInfo.ProcessName;
                rv["version"]        = postInfo.ProcessVersion.ToString(2);
                rv["restartTaskID"]  = restartTaskID;
                rv["url"]            = YZUtility.GetFormRedirectUrl(postInfo.FormFile).ToString();
                rv["perm"]           = perm;
                rv["PersistParams"]  = postInfo.PersistParams;
                rv["NodePermisions"] = this.Serialize(postInfo.NodePermision);

                rv["Comments"]    = draft != null ? draft.Comments : null;
                rv["DraftHeader"] = jDraftHeader;

                //处理按钮
                JArray links = new JArray();
                rv["links"] = links;
                foreach (Link link in postInfo.Links)
                {
                    links.Add(this.Serialize(link, "normal"));
                }

                //提交职位
                rv["delagation"]     = delagation;
                rv["selectPosition"] = selectPosition;
                JArray jPoss = new JArray();
                rv["positions"] = jPoss;
                foreach (Member position in positions)
                {
                    JObject jPos = new JObject();
                    jPoss.Add(jPos);

                    string name = position.GetParentOU(cn).Name + "\\" + position.UserAccount;

                    if (position.IsLeader)
                    {
                        name += "(" + position.LeaderTitle + ")";
                    }

                    jPos["name"]  = name;
                    jPos["value"] = position.FullName;
                }

                //自由流
                rv["ParticipantDeclares"] = JArray.FromObject(postInfo.ParticipantDeclares);
            }
            return(rv);
        }
Esempio n. 4
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);
        }