Esempio n. 1
0
        public virtual object GetProcessProperty(HttpContext context)
        {
            YZRequest request     = new YZRequest(context);
            string    processName = request.GetString("processName");
            Version   version     = request.GetVersion("version");

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

                return(new {
                    GlobalTableIdentitys = BPMProcess.GetProcessGlobalTableIdentitys(cn, processName, version),
                    Property = BPMProcess.GetProcessProperty(cn, processName, version),
                    MessageGroups = BPMProcess.GetMessageGroups(cn, processName, version),
                    Events = BPMProcess.GetEvents(cn, processName, version)
                });
            }
        }
Esempio n. 2
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);
        }
Esempio n. 3
0
        public virtual JObject GetHistoryTasks(HttpContext context)
        {
            YZRequest       request  = new YZRequest(context);
            HistoryTaskType taskType = request.GetEnum <HistoryTaskType>("HistoryTaskType", HistoryTaskType.AllAccessable);
            int             year     = request.GetString("byYear", "1") == "0" ? -1 : request.GetInt32("Year", DateTime.Today.Year);

            //获得数据
            JObject rv = new JObject();

            string taskTableFilter;
            string stepTableFilter;

            using (IYZDbProvider provider = YZDbProviderManager.DefaultProvider)
            {
                taskTableFilter = this.GetFilterStringHistoryTaskTaskTable(request, provider);
                stepTableFilter = this.GetFilterStringHistoryTaskStep(request, provider);
            }

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

                int rowcount;
                BPMTaskCollection tasks = cn.GetHistoryTasks(year, taskType, taskTableFilter, stepTableFilter, null, request.Start, request.Limit, out rowcount);

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

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

                    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["State"]            = YZJsonHelper.GetTaskStateJObject(cn, task.TaskState, task.TaskID);
                    item["Description"]      = task.Description;

                    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);
                    }
                }
            }

            return(rv);
        }
Esempio n. 4
0
        protected virtual void PostProcessNotifyTopic(IYZDbProvider provider, IDbConnection cn, BPMConnection bpmcn, string loginUserAccount, DataRow row, bool countUsers)
        {
            JObject jExt = new JObject();

            row["ext"] = jExt;
            YZResourceType resType = (YZResourceType)Enum.Parse(typeof(YZResourceType), Convert.ToString(row["resType"]), true);

            row["resType"] = resType.ToString();

            if (row.Table.Columns.Contains("uid"))
            {
                string uid  = Convert.ToString(row["uid"]);
                User   user = User.TryGetUser(bpmcn, uid);
                jExt["UserShortName"] = user == null ? uid : user.ShortName;
            }

            switch (resType)
            {
            case YZResourceType.Task:
                BPMTask         task     = BPMTask.Load(bpmcn, Int32.Parse(Convert.ToString(row["resId"])));
                ProcessProperty property = BPMProcess.GetProcessProperty(bpmcn, task.ProcessName, task.ProcessVersion);

                string owner = YZStringHelper.GetUserShortName(task.OwnerAccount, task.OwnerDisplayName);
                row["resName"] = String.Format(Resources.YZStrings.All_BPM_Task_Title_FMT, owner, task.ProcessName);

                jExt["ProcessName"] = task.ProcessName;
                jExt["Owner"]       = owner;
                jExt["Color"]       = property.Color;
                jExt["ShortName"]   = property.ShortName;
                if (String.IsNullOrEmpty(property.ShortName))
                {
                    jExt["ShortName"] = YZStringHelper.GetProcessDefaultShortName(task.ProcessName);
                }
                break;

            case YZResourceType.Group:
                Group.Group group = GroupManager.GetGroup(provider, cn, Int32.Parse(Convert.ToString(row["resId"])));

                row["resName"]      = group.Name;
                jExt["GroupType"]   = group.GroupType;
                jExt["ImageFileID"] = group.ImageFileID;

                if (countUsers)
                {
                    jExt["MemberCount"] = GroupManager.GetGroupMemberCount(provider, cn, group.GroupID);
                }

                break;

            case YZResourceType.SingleChat:
                P2PGroup.P2PGroup p2pGroup = P2PGroupManager.GetGroup(provider, cn, Int32.Parse(Convert.ToString(row["resId"])));

                row["resName"]         = p2pGroup.GetGroupName(bpmcn, loginUserAccount);
                jExt["P2PPeerAccount"] = p2pGroup.GetPeerAccount(loginUserAccount);
                jExt["FolderID"]       = p2pGroup.FolderID;

                break;

            case YZResourceType.TaskApproved:
                row["resName"] = Resources.YZStrings.Aspx_Message_Title_Approved;
                break;

            case YZResourceType.TaskRejected:
                row["resName"] = Resources.YZStrings.Aspx_Message_Title_Rejected;
                break;

            default:
                break;
            }
        }