Example #1
0
        /// <summary>
        /// افراد تحت مدیریت را براساس کلمه جستجوشده برمیگرداند
        /// </summary>
        /// <param name="searchKey"></param>
        /// <param name="searchType"></param>
        /// <param name="pageIndex"></param>
        /// <param name="pageSize"></param>
        /// <param name="orderField"></param>
        /// <param name="orderType"></param>
        /// <returns></returns>
        public IList <UnderManagementPerson> GetUnderManagmentBySearch(int month, string searchKey, GridSearchFields searchType, int pageIndex, int pageSize, GridOrderFields orderField, GridOrderFieldType orderType)
        {
            try
            {
                if (InitManager())
                {
                    if (orderField == GridOrderFields.NONE)
                    {
                        orderField = GridOrderFields.gridFields_BarCode;
                    }
                    IList <UnderManagementPerson> Result = new List <UnderManagementPerson>();
                    if (searchType == GridSearchFields.PersonName)
                    {
                        Result = managerRepository.GetUnderManagmentByDepartment(GridSearchFields.PersonName, BUser.CurrentUser.Person.ID, 0, searchKey, "", month, month > 0 ? 0 : Utility.ToDateRangeIndex(DateTime.Now, sysLanguageResource), DateTime.Now.ToString("yyyy/MM/dd"), orderField, orderType, pageIndex, pageSize);
                    }
                    else if (searchType == GridSearchFields.PersonCode)
                    {
                        Result = managerRepository.GetUnderManagmentByDepartment(GridSearchFields.PersonCode, BUser.CurrentUser.Person.ID, 0, "", searchKey, month, month > 0 ? 0 : Utility.ToDateRangeIndex(DateTime.Now, sysLanguageResource), DateTime.Now.ToString("yyyy/MM/dd"), orderField, orderType, pageIndex, pageSize);
                    }
                    else
                    {
                        Result = managerRepository.GetUnderManagmentByDepartment(GridSearchFields.PersonName, BUser.CurrentUser.Person.ID, 0, searchKey, "", month, month > 0 ? 0 : Utility.ToDateRangeIndex(DateTime.Now, sysLanguageResource), DateTime.Now.ToString("yyyy/MM/dd"), orderField, orderType, pageIndex, pageSize);
                        if (Result == null || Result.Count == 0)
                        {
                            Result = managerRepository.GetUnderManagmentByDepartment(GridSearchFields.PersonCode, BUser.CurrentUser.Person.ID, 0, "", searchKey, month, month > 0 ? 0 : Utility.ToDateRangeIndex(DateTime.Now, sysLanguageResource), DateTime.Now.ToString("yyyy/MM/dd"), orderField, orderType, pageIndex, pageSize);
                        }
                    }
                    foreach (UnderManagementPerson under in Result)
                    {
                        #region LoadBasicTraffic
                        GTS.Clock.Business.BaseInformation.BTraffic trafficBus = new BaseInformation.BTraffic();
                        IList <BasicTrafficProxy> trafficList = trafficBus.GetDayTraffics(under.PersonId, Utility.ToString(DateTime.Now));
                        int counter = 1;
                        foreach (BasicTrafficProxy trafic in trafficList)
                        {
                            switch (counter)
                            {
                            case 1:
                                under.FirstEntrance = trafic.TheTime;
                                break;

                            case 2:
                                under.FirstExit = trafic.TheTime;
                                break;

                            case 3:
                                under.SecondEntrance = trafic.TheTime;
                                break;

                            case 4:
                                under.SecondExit = trafic.TheTime;
                                break;

                            case 5:
                                under.ThirdEntrance = trafic.TheTime;
                                break;

                            case 6:
                                under.ThirdExit = trafic.TheTime;
                                break;

                            case 7:
                                under.FourthEntrance = trafic.TheTime;
                                break;

                            case 8:
                                under.FourthExit = trafic.TheTime;
                                break;

                            case 9:
                                under.FifthEntrance = trafic.TheTime;
                                break;

                            case 10:
                                under.FifthExit = trafic.TheTime;
                                break;
                            }
                            counter++;
                        }
                        under.LastExit = trafficList.LastOrDefault() != null?trafficList.LastOrDefault().TheTime : "";

                        #endregion
                    }
                    return(Result);
                }
                else if (InitOperator())
                {
                    decimal oprPrsId = BUser.CurrentUser.Person.ID;
                    if (orderField == GridOrderFields.NONE)
                    {
                        orderField = GridOrderFields.gridFields_BarCode;
                    }
                    IList <UnderManagementPerson> Result = new List <UnderManagementPerson>();
                    if (searchType == GridSearchFields.PersonName)
                    {
                        Result = managerRepository.GetUnderManagmentOperatorByDepartment(GridSearchFields.PersonName, oprPrsId, 0, searchKey, "", month, month > 0 ? 0 : Utility.ToDateRangeIndex(DateTime.Now, sysLanguageResource), DateTime.Now.ToString("yyyy/MM/dd"), orderField, orderType, pageIndex, pageSize);
                    }
                    else if (searchType == GridSearchFields.PersonCode)
                    {
                        Result = managerRepository.GetUnderManagmentOperatorByDepartment(GridSearchFields.PersonCode, oprPrsId, 0, "", searchKey, month, month > 0 ? 0 : Utility.ToDateRangeIndex(DateTime.Now, sysLanguageResource), DateTime.Now.ToString("yyyy/MM/dd"), orderField, orderType, pageIndex, pageSize);
                    }
                    else
                    {
                        Result = managerRepository.GetUnderManagmentOperatorByDepartment(GridSearchFields.PersonName, oprPrsId, 0, searchKey, "", month, month > 0 ? 0 : Utility.ToDateRangeIndex(DateTime.Now, sysLanguageResource), DateTime.Now.ToString("yyyy/MM/dd"), orderField, orderType, pageIndex, pageSize);
                        if (Result == null || Result.Count == 0)
                        {
                            Result = managerRepository.GetUnderManagmentOperatorByDepartment(GridSearchFields.PersonCode, oprPrsId, 0, "", searchKey, month, month > 0 ? 0 : Utility.ToDateRangeIndex(DateTime.Now, sysLanguageResource), DateTime.Now.ToString("yyyy/MM/dd"), orderField, orderType, pageIndex, pageSize);
                        }
                    }
                    foreach (UnderManagementPerson under in Result)
                    {
                        #region LoadBasicTraffic
                        GTS.Clock.Business.BaseInformation.BTraffic trafficBus = new BaseInformation.BTraffic();
                        IList <BasicTrafficProxy> trafficList = trafficBus.GetDayTraffics(under.PersonId, Utility.ToString(DateTime.Now));
                        int counter = 1;
                        foreach (BasicTrafficProxy trafic in trafficList)
                        {
                            switch (counter)
                            {
                            case 1:
                                under.FirstEntrance = trafic.TheTime;
                                break;

                            case 2:
                                under.FirstExit = trafic.TheTime;
                                break;

                            case 3:
                                under.SecondEntrance = trafic.TheTime;
                                break;

                            case 4:
                                under.SecondExit = trafic.TheTime;
                                break;

                            case 5:
                                under.ThirdEntrance = trafic.TheTime;
                                break;

                            case 6:
                                under.ThirdExit = trafic.TheTime;
                                break;

                            case 7:
                                under.FourthEntrance = trafic.TheTime;
                                break;

                            case 8:
                                under.FourthExit = trafic.TheTime;
                                break;

                            case 9:
                                under.FifthEntrance = trafic.TheTime;
                                break;

                            case 10:
                                under.FifthExit = trafic.TheTime;
                                break;
                            }
                            counter++;
                        }
                        under.LastExit = trafficList.LastOrDefault() != null?trafficList.LastOrDefault().TheTime : "";

                        #endregion
                    }
                    return(Result);
                }
                else
                {
                    throw new IllegalServiceAccess(String.Format("این سرویس تنها توسط مدیران قابل استفاده میباشد. شناسه کاربری {0} میباشد", this.Username), ExceptionSrc);
                }
            }
            catch (Exception ex)
            {
                BaseBusiness <Entity> .LogException(ex, "BWorkedTime", "GetUnderManagmentByDepartment");

                throw ex;
            }
        }
Example #2
0
        /// <summary>
        /// با دریافت یک گره از درخت تحت مدیریت مدیر اشخاص تحت مدیریت را برمیگرداند
        /// این افراد مرتب شده بر اساس فیلد مشخص شده هستند
        /// </summary>
        /// <param name="departmentID"></param>
        /// <returns></returns>
        public IList <UnderManagementPerson> GetUnderManagmentByDepartment(int month, decimal departmentID, int pageIndex, int pageSize, GridOrderFields orderField, GridOrderFieldType orderType)
        {
            try
            {
                int year = 0;
                if (BLanguage.CurrentSystemLanguage == LanguagesName.Parsi)
                {
                    year = Utility.ToPersianDateTime(DateTime.Now).Year;
                    if (month <= 0)
                    {
                        month = Utility.ToPersianDateTime(DateTime.Now).Month;
                    }
                }
                else
                {
                    year = DateTime.Now.Year;
                    if (month <= 0)
                    {
                        month = DateTime.Now.Month;
                    }
                }

                if (orderField == GridOrderFields.NONE)
                {
                    orderField = GridOrderFields.gridFields_BarCode;
                }
                if (InitManager())
                {
                    IList <UnderManagementPerson> Result = managerRepository.GetUnderManagmentByDepartment(GridSearchFields.NONE, BUser.CurrentUser.Person.ID, departmentID, "", "", month, month > 0 ? 0 : Utility.ToDateRangeIndex(DateTime.Now, sysLanguageResource), DateTime.Now.ToString("yyyy/MM/dd"), orderField, orderType, pageIndex, pageSize);
                    foreach (UnderManagementPerson under in Result)
                    {
                        #region LoadBasicTraffic
                        GTS.Clock.Business.BaseInformation.BTraffic trafficBus = new BaseInformation.BTraffic();
                        IList <BasicTrafficProxy> trafficList = trafficBus.GetDayTraffics(under.PersonId, Utility.ToString(DateTime.Now));
                        int counter = 1;
                        foreach (BasicTrafficProxy trafic in trafficList)
                        {
                            switch (counter)
                            {
                            case 1:
                                under.FirstEntrance = trafic.TheTime;
                                break;

                            case 2:
                                under.FirstExit = trafic.TheTime;
                                break;

                            case 3:
                                under.SecondEntrance = trafic.TheTime;
                                break;

                            case 4:
                                under.SecondExit = trafic.TheTime;
                                break;

                            case 5:
                                under.ThirdEntrance = trafic.TheTime;
                                break;

                            case 6:
                                under.ThirdExit = trafic.TheTime;
                                break;

                            case 7:
                                under.FourthEntrance = trafic.TheTime;
                                break;

                            case 8:
                                under.FourthExit = trafic.TheTime;
                                break;

                            case 9:
                                under.FifthEntrance = trafic.TheTime;
                                break;

                            case 10:
                                under.FifthExit = trafic.TheTime;
                                break;
                            }
                            counter++;
                        }
                        under.LastExit = trafficList.LastOrDefault() != null?trafficList.LastOrDefault().TheTime : "";

                        #endregion

                        under.RemainLeaveToYearEnd  = this.GetReainLeaveToEndOfYear(under.PersonId, year, month);
                        under.RemainLeaveToMonthEnd = this.GetReaiLeaveToEndMonth(under.PersonId, year, month);
                    }
                    return(Result);
                }
                else if (InitOperator())
                {
                    IList <UnderManagementPerson> Result = managerRepository.GetUnderManagmentOperatorByDepartment(GridSearchFields.NONE, BUser.CurrentUser.Person.ID, departmentID, "", "", month, month > 0 ? 0 : Utility.ToDateRangeIndex(DateTime.Now, sysLanguageResource), DateTime.Now.ToString("yyyy/MM/dd"), orderField, orderType, pageIndex, pageSize);
                    foreach (UnderManagementPerson under in Result)
                    {
                        #region LoadBasicTraffic
                        GTS.Clock.Business.BaseInformation.BTraffic trafficBus = new BaseInformation.BTraffic();
                        IList <BasicTrafficProxy> trafficList = trafficBus.GetDayTraffics(under.PersonId, Utility.ToString(DateTime.Now));
                        int counter = 1;
                        foreach (BasicTrafficProxy trafic in trafficList)
                        {
                            switch (counter)
                            {
                            case 1:
                                under.FirstEntrance = trafic.TheTime;
                                break;

                            case 2:
                                under.FirstExit = trafic.TheTime;
                                break;

                            case 3:
                                under.SecondEntrance = trafic.TheTime;
                                break;

                            case 4:
                                under.SecondExit = trafic.TheTime;
                                break;

                            case 5:
                                under.ThirdEntrance = trafic.TheTime;
                                break;

                            case 6:
                                under.ThirdExit = trafic.TheTime;
                                break;

                            case 7:
                                under.FourthEntrance = trafic.TheTime;
                                break;

                            case 8:
                                under.FourthExit = trafic.TheTime;
                                break;

                            case 9:
                                under.FifthEntrance = trafic.TheTime;
                                break;

                            case 10:
                                under.FifthExit = trafic.TheTime;
                                break;
                            }
                            counter++;
                        }
                        under.LastExit = trafficList.LastOrDefault() != null?trafficList.LastOrDefault().TheTime : "";

                        #endregion

                        under.RemainLeaveToYearEnd  = this.GetReainLeaveToEndOfYear(under.PersonId, year, month);
                        under.RemainLeaveToMonthEnd = this.GetReaiLeaveToEndMonth(under.PersonId, year, month);
                    }
                    return(Result);
                }
                else
                {
                    throw new IllegalServiceAccess(String.Format("این سرویس تنها توسط مدیران قابل استفاده میباشد. شناسه کاربری {0} میباشد", this.Username), ExceptionSrc);
                }
            }
            catch (Exception ex)
            {
                BaseBusiness <Entity> .LogException(ex, "BWorkedTime", "GetUnderManagmentByDepartment");

                throw ex;
            }
        }