UOF2 EIP BPM 取得某使用者代理人(並轉UserSet) | 一等一科技 | 程式碼

by | 4 月 28, 2026 | 一等一UOF系統, 程式 | 0 comments

Views: 1

某個簽核透過程式起單,起單過程中需要取得使用者代理人,並且將代理人加入簽核,這段程式碼我將取得代理人包成一個Method

取得代理人(程式碼)

using Ede.Uof.EIP.Organization.Util;

namespace EIP_Extention
{
    public static class EbUserHelper
    {
        /// <summary>
        /// 取得代理人員的UserSet
        /// </summary>
        /// <param name="userGuid">使用者的GUID</param>
        /// <returns>代理人員的UserSet</returns>
        public static UserSet GetUserAgent(string userGuid)
        {
            UserUCO userUCO = new UserUCO();
            EBUser user = userUCO.GetEBUser(userGuid);
            return GetUserAgent(user);
        }
        /// <summary>
        /// 取得代理人員的UserSet
        /// </summary>
        /// <param name="user"></param>
        /// <returns></returns>
        public static UserSet GetUserAgent(EBUser user)
        {
            var agentUserSet = new UserSet();
            bool hasAgent = false;
            EBUser eBUserMajor = user.GetEmployeeAgent(AgentOfUser.Major);
            EBUser eBUserMinor1 = user.GetEmployeeAgent(AgentOfUser.Minor1);
            EBUser eBUserMinor2 = user.GetEmployeeAgent(AgentOfUser.Minor2);
            if (eBUserMajor != null)
            {
                var userSetB = new UserSet();
                userSetB.SetXML("<UserSet><Element type='user'><userId>" + eBUserMajor.UserGUID + "</userId></Element></UserSet>");
                UserSet.MergeToA(ref agentUserSet, userSetB);
                hasAgent = true;
            }
            if (eBUserMinor1 != null)
            {
                var userSetB = new UserSet();
                userSetB.SetXML("<UserSet><Element type='user'><userId>" + eBUserMinor1.UserGUID + "</userId></Element></UserSet>");
                UserSet.MergeToA(ref agentUserSet, userSetB);
                hasAgent = true;
            }
            if (eBUserMinor2 != null)
            {
                var userSetB = new UserSet();
                userSetB.SetXML("<UserSet><Element type='user'><userId>" + eBUserMinor2.UserGUID + "</userId></Element></UserSet>");
                UserSet.MergeToA(ref agentUserSet, userSetB);
                hasAgent = true;
            }

            if (hasAgent)
            {
                return agentUserSet;
            }
            return null;
        }
    }
}

使用方法

//某個人的guid
string guid = "..."; 

//取得代理人
var agentUserSet = EIP_Extention.EbUserHelper.GetUserAgent(guid);

//轉成userSet
string agentUserSetString = agentUserSet.GetXML();

0 Comments

Submit a Comment

發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *