Пример #1
0
        // <summary>
        /// 取得員工簽核人員
        /// </summary>
        /// <param name="userGuid"></param>
        /// <returns></returns>
        public UserSet GetUserSinger(string userGuid)
        {
            UserSet   userSet = new UserSet();
            UserUCO   userUCO = new UserUCO();
            EBUser    ebUser  = userUCO.GetEBUser(userGuid);
            BaseGroup baseGp  = ebUser.GetEmployeeDepartment(DepartmentOfUser.Major).Department;

            //找出所有簽核人員
            if (CheckIsDeptSigner(ebUser.UserGUID, baseGp.GroupId) == false)
            {
                AddSignerToUserSet(baseGp.GroupId, userSet);
            }
            else
            {
                //如果目前的簽核人員
                if (baseGp.ParnetGroup != null)
                {
                    AddSignerToUserSet(baseGp.ParnetGroup.GroupId, userSet);
                }
            }



            return(userSet);
        }
Пример #2
0
        /// <summary>
        /// 檢查是否是否是部門主管
        /// </summary>
        /// <returns></returns>
        private bool CheckIsDeptSuperior(string userGUID, string groupId)
        {
            UserUCO userUco    = new UserUCO();
            bool    IsSuperior = false;
            EBUser  ebUser     = userUco.GetEBUser(userGUID);
            EmployeeJobFunctionCollection employeeJobFunctionCollection = ebUser.GetJobFunctionsOfDepartment(groupId);

            //判斷是否是簽核者,
            for (int i = 0; i < employeeJobFunctionCollection.Count; i++)
            {
                if (employeeJobFunctionCollection[i].FunctionId == "Superior")
                {
                    IsSuperior = true;
                    break;
                }
            }

            return(IsSuperior);
        }
Пример #3
0
        public string GetExternalDllSites(string formInfo)
        {
            XmlDocument    xmlDoc     = new XmlDocument();
            XmlDocument    formXmlDoc = new XmlDocument();
            DatabaseHelper DbQueryCompanyTopAccount = new DatabaseHelper();
            DatabaseHelper DbQueryGroupName         = new DatabaseHelper();
            UserUCO        userUCO   = new UserUCO();
            DataSet        GroupName = new DataSet();


            formXmlDoc.LoadXml(formInfo);
            account  = formXmlDoc.SelectSingleNode("/ExternalFlowSite/ApplicantInfo").Attributes["account"].Value;
            userGuid = userUCO.GetGUID(account);
            EBUser ebUser = userUCO.GetEBUser(userGuid);

            DEPNAME = ebUser.GroupName;

            //找出公司內最高的主管account
            CompanyTopAccountDS = DbQueryCompanyTopAccount.ExecuteDataSet("SELECT TOP 1 CompanyTopAccount FROM [UOFTEST].[dbo].[CompanyTopAccount]");
            CompanyTopAccount   = CompanyTopAccountDS.Tables[0].Rows[0]["CompanyTopAccount"].ToString();

            GroupName = DbQueryGroupName.ExecuteDataSet("SELECT  [GroupName]   FROM [UOFTEST].[dbo].[GROUPNAMETOEF]");
            //判斷是不是指定部門,可由簽至副理就結束
            foreach (DataRow dr in GroupName.Tables[0].Rows)
            {
                if (DEPNAME.Equals(dr["GroupName"].ToString()))
                {
                    SpecialGroupName = "Y";
                    break;
                }
                else
                {
                    SpecialGroupName = "N";
                }
            }

            //找出所有簽核人員,包含主管
            FINDALLSINGER(userGuid);

            return(sites.ConvertToXML());
        }
    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            //申請者姓名
            UserUCO userUCO1 = new UserUCO();
            EBUser  eBUser   = userUCO1.GetEBUser(base.ApplicantGroupId);
            hdApplicant.Value = eBUser.Name;

            //申請部門
            GroupUCO groupUCO = new GroupUCO(GroupType.Department);
            hdDept.Value = groupUCO.QueryDepartmentName(base.ApplicantGroupId);
        }
        catch
        {
        }
        // base.ApplicantGroupId
        //這裡不用修改
        //欄位的初始化資料都到SetField Method去做
        SetField(m_versionField);
    }
Пример #5
0
        // <summary>
        /// 取得員工直屬主管
        /// </summary>
        /// <param name="userGuid"></param>
        /// <returns></returns>
        public UserSet GetUserSuperior(string userGuid)
        {
            UserSet   userSet = new UserSet();
            UserUCO   userUCO = new UserUCO();
            EBUser    ebUser  = userUCO.GetEBUser(userGuid);
            BaseGroup baseGp  = ebUser.GetEmployeeDepartment(DepartmentOfUser.Major).Department;

            //如果目前簽核人員不是部門主管,那就要找尋該人員目前部門的主管
            if (CheckIsDeptSuperior(ebUser.UserGUID, baseGp.GroupId) == false)
            {
                AddSuperiorToUserSet(baseGp.GroupId, userSet);
            }
            else
            {
                //如果目前的簽核人員是部門主管,則要找尋上一個部門的主管
                if (baseGp.ParnetGroup != null)
                {
                    AddSuperiorToUserSet(baseGp.ParnetGroup.GroupId, userSet);
                }
            }

            return(userSet);
        }
Пример #6
0
        public string GetExternalDllSites(string formInfo)
        {
            XmlDocument    formXmlDoc       = new XmlDocument();
            DatabaseHelper DbQuery          = new DatabaseHelper();
            UserUCO        userUCO          = new UserUCO();
            DataSet        GroupName        = new DataSet();
            string         SpecialGroupName = "N";

            formXmlDoc.LoadXml(formInfo);
            string account  = formXmlDoc.SelectSingleNode("/ExternalFlowSite/ApplicantInfo").Attributes["account"].Value;
            string userGuid = userUCO.GetGUID(account);
            EBUser ebUser   = userUCO.GetEBUser(userGuid);
            string DEPNAME  = ebUser.GroupName;

            GroupName = DbQuery.ExecuteDataSet("SELECT  [GroupName]   FROM [UOFTEST].[dbo].[GROUPNAMETOEF]");
            //判斷是不是指定部門,可由簽至副理就結束
            foreach (DataRow dr in GroupName.Tables[0].Rows)
            {
                if (DEPNAME.Equals(dr["GroupName"].ToString()))
                {
                    SpecialGroupName = "Y";
                    break;
                }
                else
                {
                    SpecialGroupName = "N";
                }
            }


            //找到申請者的第1層主管
            userSet1 = GetUserSuperior(userGuid);
            UserUCO userUCOsinger1 = new UserUCO();

            if (userSet1.Items.Count > 0)
            {
                EBUser ebUsersinger1 = userUCOsinger1.GetEBUser(userSet1.Items[0].Key);
                singer1 = ebUsersinger1.Account;

                //主管的職級是理級以上就停止,不是就往上找
                if (ebUsersinger1.GetEmployeeDepartment(DepartmentOfUser.Major).JobTitle.Rank <= 7)
                {
                    singer2 = null;
                }
                //如果指定部門的主管是副理以上就停止,不是就往上找
                else if (SpecialGroupName.Equals("Y") && ebUsersinger1.GetEmployeeDepartment(DepartmentOfUser.Major).JobTitle.Rank <= 9)
                {
                    singer2 = null;
                }
                else
                {
                    //找到申請者的第2層主管
                    userSet2 = GetUserSuperior(userSet1.Items[0].Key);
                    UserUCO userUCOsinger2 = new UserUCO();
                    if (userSet2.Items.Count > 0)
                    {
                        EBUser ebUsersinger2 = userUCOsinger2.GetEBUser(userSet2.Items[0].Key);
                        singer2 = ebUsersinger2.Account;

                        //主管的職級是理級以上就停止,不是就往上找
                        if (ebUsersinger2.GetEmployeeDepartment(DepartmentOfUser.Major).JobTitle.Rank <= 7)
                        {
                            singer3 = null;
                        }
                        //如果指定部門的主管是副理以上就停止,不是就往上找
                        else if (SpecialGroupName.Equals("Y") && ebUsersinger2.GetEmployeeDepartment(DepartmentOfUser.Major).JobTitle.Rank <= 9)
                        {
                            singer3 = null;
                        }
                        else
                        {
                            //找到申請者的第3層主管
                            userSet3 = GetUserSuperior(userSet2.Items[0].Key);
                            UserUCO userUCOsinger3 = new UserUCO();
                            if (userSet3.Items.Count > 0)
                            {
                                EBUser ebUsersinger3 = userUCOsinger3.GetEBUser(userSet3.Items[0].Key);
                                singer3 = ebUsersinger3.Account;
                            }
                            else
                            {
                                singer3 = null;
                            }
                        }
                    }
                    else
                    {
                        singer2 = null;
                    }
                }
            }
            else
            {
                singer1 = null;
            }



            //singer1 = "190052";
            //singer2 = "120002";
            //singer3 = "admin";

            //if (ebUser.HasJobFunction("Superior"))
            //{
            //    signer = "admin";
            //}
            //else
            //{
            //    signer = "Tony";
            //}

            XmlDocument xmlDoc = new XmlDocument();

            if (!string.IsNullOrEmpty(singer3))
            {
                //<ReturnValue></ReturnValue>
                XmlElement returnValueElement = xmlDoc.CreateElement("ReturnValue");
                //<Flow></Flow>
                XmlElement flowElement = xmlDoc.CreateElement("Flow");
                //<Site></Site> 第1層
                XmlElement siteElement = xmlDoc.CreateElement("Site");
                //<Site order='' signType='' ></Site>
                siteElement.SetAttribute("order", "0");
                siteElement.SetAttribute("signType", "0");

                //<Signers></Signers>
                XmlElement signersElement = xmlDoc.CreateElement("Signers");
                //<Signer></Signer>
                XmlElement signerElement = xmlDoc.CreateElement("Signer");
                //<Signer account='' />
                signerElement.SetAttribute("account", singer1);
                //<Signers>
                //  <Signer account='' />
                //</Signers>
                signersElement.AppendChild(signerElement);
                //<Site order='' signType='' >
                //  <Signers>
                //      <Signer account='' />
                //  </Signers>
                //</Site>
                siteElement.AppendChild(signersElement);

                flowElement.AppendChild(siteElement);

                //<Site></Site> 第2層
                siteElement = xmlDoc.CreateElement("Site");
                //<Site order='' signType='' ></Site>
                siteElement.SetAttribute("order", "1");
                siteElement.SetAttribute("signType", "0");

                //<Signers></Signers>
                signersElement = xmlDoc.CreateElement("Signers");
                //<Signer></Signer>
                signerElement = xmlDoc.CreateElement("Signer");
                //<Signer account='' />
                signerElement.SetAttribute("account", singer2);
                //<Signers>
                //  <Signer account='' />
                //</Signers>
                signersElement.AppendChild(signerElement);
                //<Site order='' signType='' >
                //  <Signers>
                //      <Signer account='' />
                //  </Signers>
                //</Site>
                siteElement.AppendChild(signersElement);

                flowElement.AppendChild(siteElement);

                //<Site></Site> 第3層
                siteElement = xmlDoc.CreateElement("Site");
                //<Site order='' signType='' ></Site>
                siteElement.SetAttribute("order", "2");
                siteElement.SetAttribute("signType", "0");

                //<Signers></Signers>
                signersElement = xmlDoc.CreateElement("Signers");
                //<Signer></Signer>
                signerElement = xmlDoc.CreateElement("Signer");
                //<Signer account='' />
                signerElement.SetAttribute("account", singer3);
                //<Signers>
                //  <Signer account='' />
                //</Signers>
                signersElement.AppendChild(signerElement);
                //<Site order='' signType='' >
                //  <Signers>
                //      <Signer account='' />
                //  </Signers>
                //</Site>
                siteElement.AppendChild(signersElement);

                flowElement.AppendChild(siteElement);



                //<ReturnValue>
                //  <Flow>
                //    <Site order="0" signType="0">
                //      <Signers>
                //        <Signer account ="Tony"/>
                //      </Signers>
                //    </Site>

                //  </Flow>
                //</ReturnValue>


                returnValueElement.AppendChild(flowElement);
                xmlDoc.AppendChild(returnValueElement);
            }
            else if (!string.IsNullOrEmpty(singer2))
            {
                //<ReturnValue></ReturnValue>
                XmlElement returnValueElement = xmlDoc.CreateElement("ReturnValue");
                //<Flow></Flow>
                XmlElement flowElement = xmlDoc.CreateElement("Flow");
                //<Site></Site> 第1層
                XmlElement siteElement = xmlDoc.CreateElement("Site");
                //<Site order='' signType='' ></Site>
                siteElement.SetAttribute("order", "0");
                siteElement.SetAttribute("signType", "0");

                //<Signers></Signers>
                XmlElement signersElement = xmlDoc.CreateElement("Signers");
                //<Signer></Signer>
                XmlElement signerElement = xmlDoc.CreateElement("Signer");
                //<Signer account='' />
                signerElement.SetAttribute("account", singer1);
                //<Signers>
                //  <Signer account='' />
                //</Signers>
                signersElement.AppendChild(signerElement);
                //<Site order='' signType='' >
                //  <Signers>
                //      <Signer account='' />
                //  </Signers>
                //</Site>
                siteElement.AppendChild(signersElement);

                flowElement.AppendChild(siteElement);

                //<Site></Site> 第2層
                siteElement = xmlDoc.CreateElement("Site");
                //<Site order='' signType='' ></Site>
                siteElement.SetAttribute("order", "1");
                siteElement.SetAttribute("signType", "0");

                //<Signers></Signers>
                signersElement = xmlDoc.CreateElement("Signers");
                //<Signer></Signer>
                signerElement = xmlDoc.CreateElement("Signer");
                //<Signer account='' />
                signerElement.SetAttribute("account", singer2);
                //<Signers>
                //  <Signer account='' />
                //</Signers>
                signersElement.AppendChild(signerElement);
                //<Site order='' signType='' >
                //  <Signers>
                //      <Signer account='' />
                //  </Signers>
                //</Site>
                siteElement.AppendChild(signersElement);

                flowElement.AppendChild(siteElement);

                returnValueElement.AppendChild(flowElement);
                xmlDoc.AppendChild(returnValueElement);
            }
            else if (!string.IsNullOrEmpty(singer1))
            {
                //<ReturnValue></ReturnValue>
                XmlElement returnValueElement = xmlDoc.CreateElement("ReturnValue");
                //<Flow></Flow>
                XmlElement flowElement = xmlDoc.CreateElement("Flow");
                //<Site></Site> 第1層
                XmlElement siteElement = xmlDoc.CreateElement("Site");
                //<Site order='' signType='' ></Site>
                siteElement.SetAttribute("order", "0");
                siteElement.SetAttribute("signType", "0");

                //<Signers></Signers>
                XmlElement signersElement = xmlDoc.CreateElement("Signers");
                //<Signer></Signer>
                XmlElement signerElement = xmlDoc.CreateElement("Signer");
                //<Signer account='' />
                signerElement.SetAttribute("account", singer1);
                //<Signers>
                //  <Signer account='' />
                //</Signers>
                signersElement.AppendChild(signerElement);
                //<Site order='' signType='' >
                //  <Signers>
                //      <Signer account='' />
                //  </Signers>
                //</Site>
                siteElement.AppendChild(signersElement);

                flowElement.AppendChild(siteElement);

                returnValueElement.AppendChild(flowElement);
                xmlDoc.AppendChild(returnValueElement);
            }

            return(xmlDoc.OuterXml);
        }
Пример #7
0
        public void FINDALLSINGER(string userGuid)
        {
            UserUCO userUCO = new UserUCO();
            EBUser  ebUser  = userUCO.GetEBUser(userGuid);
            EBUser  ebUserHasJobFunction = userUCO.GetEBUser(userGuid);

            //找到申請者的所有簽核者和主管
            while (FLAGGO == true)
            {
                BaseGroup baseGroup = new BaseGroup(ebUser.GroupID);

                //如果沒有上層的部門就停止
                if (baseGroup.ParnetGroup == null)
                {
                    FLAGGO = false;
                    //break;
                }
                else
                {
                    Lib.WKF.ExternalDllSite site1 = new Lib.WKF.ExternalDllSite();
                    site1.SignType = Lib.WKF.SignType.And;
                    Lib.WKF.ExternalDllSite site2 = new Lib.WKF.ExternalDllSite();
                    //loop start
                    userSet1 = GetUserSinger(userGuid);

                    if (userSet1.Items.Count > 0)
                    {
                        for (int i = 0; i < userSet1.Items.Count; i++)
                        {
                            ebUserHasJobFunction = userUCO.GetEBUser(userSet1.Items[i].Key);

                            if (!ebUserHasJobFunction.HasJobFunction("Superior"))
                            {
                                //申請者不用再當簽核者
                                if (!account.Equals(ebUserHasJobFunction.Account))
                                {
                                    site1.Signers.Add(ebUserHasJobFunction.Account);
                                    //add site1 singer
                                }
                            }
                            else
                            {
                                site2.Signers.Add(ebUserHasJobFunction.Account);
                                //add site2 singer

                                EBUserSuperior = ebUserHasJobFunction;
                            }
                            //loop end
                        }

                        //有找到簽核人員才新增簽核
                        if (site1.Signers.Count > 0)
                        {
                            sites.Sites.Add(site1);
                        }

                        //有找到主管新增簽核
                        if (site2.Signers.Count > 0)
                        {
                            sites.Sites.Add(site2);
                        }
                    }
                }

                //如果沒有找到最高主管就繼續找上層部門的簽核人員+主管
                if (!EBUserSuperior.Account.Equals(CompanyTopAccount))
                {
                    //FINDALLSINGER(Superior);

                    //主管的職級是理級以上就停止,不是就往上找
                    if (SpecialGroupName.Equals("N") && EBUserSuperior.GetEmployeeDepartment(DepartmentOfUser.Major).JobTitle.Rank <= 7)
                    {
                        FLAGGO = false;
                    }
                    //如果指定部門的主管是副理以上就停止,不是就往上找
                    else if (SpecialGroupName.Equals("Y") && EBUserSuperior.GetEmployeeDepartment(DepartmentOfUser.Major).JobTitle.Rank <= 9)
                    {
                        FLAGGO = false;
                    }
                    else
                    {
                        FINDALLSINGER(EBUserSuperior.UserGUID);
                    }
                }
                //如果找到最高主管就停止
                else
                {
                    FLAGGO = false;
                    //break;
                }
            }
        }