コード例 #1
0
        public void SaveSMSSetting(SMSSettings setting, PersonAdvanceSearchProxy proxy)
        {
            try
            {
                ISearchPerson  searchTool = new BPerson();
                IList <Person> list;

                //don't select count
                if (proxy.PersonId > 0)
                {
                    list = searchTool.GetPersonInAdvanceSearch(proxy, 0, 1, PersonCategory.Public);
                }
                else
                {
                    list = searchTool.GetPersonInAdvanceSearch(proxy);
                }
                var l = from o in list
                        select o;
                list = l.ToList <Person>();

                foreach (Person prs in list)
                {
                    this.SaveSMSSetting(setting, prs.User);
                }
            }
            catch (Exception ex)
            {
                LogException(ex, "BUserSettings", "SaveSMSSettingsAdvanceSearch");
                throw ex;
            }
        }
コード例 #2
0
        /// <summary>
        /// لیست نتایج جستجو را برمیگرداند
        /// </summary>
        /// <param name="proxy"></param>
        /// <param name="pageIndex"></param>
        /// <param name="PageSize"></param>
        /// <returns></returns>
        public IList <Person> GetAllPersons(Business.Proxy.PersonAdvanceSearchProxy proxy, int pageIndex, int PageSize)
        {
            ISearchPerson  bperson = new BPerson();
            IList <Person> list    = bperson.GetPersonInAdvanceSearch(proxy, pageIndex, PageSize);

            return(list);
        }
コード例 #3
0
ファイル: MainPage.aspx.cs プロジェクト: ImanRezaeipour/GTS
        protected void Button34_Click(object sender, EventArgs e)
        {
            ISearchPerson            search = new BPerson();
            PersonAdvanceSearchProxy proxy  = new PersonAdvanceSearchProxy();

            proxy.RuleGroupId       = 41467;
            proxy.RuleGroupFromDate = "2012/12/15";
            proxy.RuleGroupToDate   = "2012/12/20";
            int            count = search.GetPersonInAdvanceSearchCount(proxy);
            IList <Person> list  = search.GetPersonInAdvanceSearch(proxy, 0, 10);
        }
コード例 #4
0
ファイル: BPersonParams.cs プロジェクト: ImanRezaeipour/atlas
        public IList <PersonParamValue> GetAll(decimal paramFieldId, PersonAdvanceSearchProxy proxy)
        {
            try
            {
                ISearchPerson            searchTool   = new BPerson();
                int                      count        = searchTool.GetPersonInAdvanceSearchCount(proxy);
                IList <Person>           personList   = searchTool.GetPersonInAdvanceSearch(proxy, 0, count);
                List <decimal>           personIDList = personList.Select(r => r.ID).ToList <decimal>();
                IList <PersonParamValue> list         = paramValueRepository.Find(x => personIDList.Contains(x.Person.ID) && x.ParamField.ID == paramFieldId).ToList();
                List <PersonParamValue>  listParams   = new List <PersonParamValue>();

                foreach (PersonParamValue item in list)
                {
                    bool result = true;
                    foreach (decimal personID in personIDList)
                    {
                        if (list.Count(p => p.Person.ID == personID && p.FromDate == item.FromDate && p.ToDate == item.ToDate && p.Value == item.Value) == 0)
                        {
                            result = false;
                        }
                    }
                    if (result == true)
                    {
                        if (listParams.Count(c => c.FromDate == item.FromDate && c.ToDate == item.ToDate && c.Value == item.Value) == 0)
                        {
                            listParams.Add(item);
                        }
                    }
                }

                foreach (PersonParamValue value in listParams)
                {
                    if (BLanguage.CurrentSystemLanguage == LanguagesName.Parsi)
                    {
                        value.TheFromDate = Utility.ToPersianDate(value.FromDate);
                        value.TheToDate   = Utility.ToPersianDate(value.ToDate);
                    }
                    else
                    {
                        value.TheFromDate = Utility.ToString(value.FromDate);
                        value.TheToDate   = Utility.ToString(value.ToDate);
                    }
                }
                return(listParams);
            }
            catch (Exception ex)
            {
                LogException(ex);
                throw ex;
            }
        }
コード例 #5
0
ファイル: BRemainLeave.cs プロジェクト: ImanRezaeipour/GTS
        /// <summary>
        /// مانده مرخصی را برای سالها و افراد جستجو شده  برمیگرداند
        /// حد اکثر 1000 رکورد بر میگرداند
        /// </summary>
        /// <param name="proxy"></param>
        /// <param name="fromDate"></param>
        /// <param name="toDate"></param>
        /// <returns></returns>
        public IList <RemainLeaveProxy> GetRemainLeave(PersonAdvanceSearchProxy proxy, int fromYear, int toYear, int pageIndex, int pageSize)
        {
            try
            {
                IList <decimal> underManagmentList = new List <decimal>();
                ISearchPerson   searchTool         = new BPerson();
                int             count = 1000;//searchTool.GetPersonInAdvanceSearchCount(proxy);
                IList <Person>  list  = searchTool.GetPersonInAdvanceSearch(proxy, 0, count);
                var             l     = from p in list
                                        select p.ID;
                underManagmentList = l.ToList <decimal>();

                /*
                 * IList<LeaveYearRemain> result = new List<LeaveYearRemain>();
                 * if (underManagmentList != null && underManagmentList.Count > 0)
                 * {
                 *  DateTime fromDate, toDate;
                 *  if (BLanguage.CurrentSystemLanguage == LanguagesName.Parsi)
                 *  {
                 *      fromDate = Utility.ToMildiDate(String.Format("{0}/01/01", fromYear));
                 *      toDate = Utility.ToMildiDate(String.Format("{0}/01/01", toYear));
                 *  }
                 *  else
                 *  {
                 *     fromDate = new DateTime(fromYear, 1, 1);
                 *      toDate = new DateTime(toYear, 1, 1);
                 *  }
                 *  result = objectRep.GetByCriteriaByPage(pageIndex, pageSize,
                 *                                                  new CriteriaStruct(Utility.GetPropertyName(() => new LeaveYearRemain().Date), fromDate, CriteriaOperation.GreaterEqThan),
                 *                                                  new CriteriaStruct(Utility.GetPropertyName(() => new LeaveYearRemain().Date), toDate, CriteriaOperation.LessEqThan),
                 *                                                  new CriteriaStruct(Utility.GetPropertyName(() => new LeaveYearRemain().PersonId), underManagmentList.ToArray<decimal>(), CriteriaOperation.IN));
                 * }
                 * if (result != null && result.Count > 0)
                 * {
                 *  result = result.OrderBy(x => x.Person.LastName).ThenBy(x => x.Date.Year).ToList();
                 *
                 * }
                 * return this.ConvertToProxy(result);
                 * */

                return(this.GetRemainLeave(underManagmentList, fromYear, toYear, pageIndex, pageSize));
            }
            catch (Exception ex)
            {
                LogException(ex, "BRemainLeave", "GetRemainLeave");
                throw ex;
            }
        }
コード例 #6
0
        /// <summary>
        /// لیست مدیران جستجو شده
        /// اگر کاربر فعلی اپراتور فقط در بین مدیران زیر دست اپراتور جست و جو میکنیم
        /// ولی اگر مدیر باشد نتایج جست و جو تهی میباشد
        /// اگر هم مدیر باشد و هم اپراتور آنگاه خود شخص به علاوه مدیران تحت مدیریت برمیگردد
        /// </summary>
        /// <param name="proxy"></param>
        /// <param name="pageIndex"></param>
        /// <param name="pageSize"></param>
        /// <returns></returns>
        public IList <Person> GetAllManager(PersonAdvanceSearchProxy proxy, int pageIndex, int pageSize)
        {
            IList <Person> result = new List <Person>();
            //if (!IsOperator()) { return result; }
            //PersonRepository prsRep = new PersonRepository();
            //var ids = from mng in this.GetAllManager(0, this.GetAllManagerCount())
            //          select mng.ID;
            //IList<decimal> list = ids.ToList<decimal>();
            //proxy.SearchInCategory = PersonCategory.Manager;
            //result = prsRep.GetPersonInAdvanceSearch(proxy, list, pageIndex, pageSize);

            ISearchPerson searchTool = new BPerson();

            result = searchTool.GetPersonInAdvanceSearch(proxy, pageIndex, pageSize, PersonCategory.Manager);
            return(result);
        }
コード例 #7
0
        public IList <ArchiveCalcValuesProxy> GetArchiveValues(int year, int month, PersonAdvanceSearchProxy proxy, int pageIndex, int pageSize)
        {
            //int count = searchTool.GetPersonInAdvanceSearchCount(proxy);
            //IList<Person> list = searchTool.GetPersonInAdvanceSearch(proxy, 0, count);
            int            rangeOrder = month;
            ISearchPerson  searchTool = new BPerson();
            IList <Person> personList = searchTool.GetPersonInAdvanceSearch(proxy);
            var            ids        = from o in personList
                                        select o.ID;
            IList <decimal> existsPersonArchiveList = archiveRep.GetExsitsArchivePersons(ids.ToList(), year, rangeOrder);

            personList = personList.Where(x => existsPersonArchiveList.Any(y => y == x.ID))
                         .Skip(pageIndex * pageSize)
                         .Take(pageSize)
                         .ToList();

            return(this.GetArchiveValues(year, month, personList));
        }
コード例 #8
0
ファイル: BRemainLeave.cs プロジェクト: ImanRezaeipour/GTS
        /// <summary>
        ///  اتقال مرخصی به سال بعد
        /// </summary>
        /// <param name="proxy"></param>
        /// <param name="fromYear"></param>
        /// <param name="toYear"></param>
        public int TransferToNextYear(PersonAdvanceSearchProxy proxy, int fromYear, int toYear)
        {
            try
            {
                DateTime fromDate, toDate;
                if (BLanguage.CurrentSystemLanguage == LanguagesName.Parsi)
                {
                    fromDate = Utility.ToMildiDate(String.Format("{0}/01/01", fromYear));
                    toDate   = Utility.ToMildiDate(String.Format("{0}/01/01", toYear));
                }
                else
                {
                    fromDate = new DateTime(fromYear, 1, 1);
                    toDate   = new DateTime(toYear, 1, 1);
                }

                IList <decimal> underManagmentList = new List <decimal>();
                ISearchPerson   searchTool         = new BPerson();
                int             count = searchTool.GetPersonInAdvanceSearchCount(proxy);
                IList <Person>  list  = searchTool.GetPersonInAdvanceSearch(proxy, 0, count);
                var             l     = from p in list
                                        select p.ID;
                underManagmentList = l.ToList <decimal>();
                int counter = 0;
                foreach (decimal personId in underManagmentList)
                {
                    try
                    {
                        this.TransferToNextYear(personId, fromDate, toDate, fromYear, toYear);
                        counter++;
                    }
                    catch (UIValidationExceptions ex)
                    {
                        LogException(ex);
                    }
                }
                return(counter);
            }
            catch (Exception ex)
            {
                LogException(ex, "BRemainLeave", "TransferToNextYear");
                throw ex;
            }
        }
コード例 #9
0
        public int GetSearchCount(PersonAdvanceSearchProxy proxy, int year, int month)
        {
            try
            {
                int            rangeOrder = month;
                ISearchPerson  searchTool = new BPerson();
                IList <Person> personList = searchTool.GetPersonInAdvanceSearch(proxy);
                var            ids        = from o in personList
                                            select o.ID;
                IList <decimal> personIds = archiveRep.GetExsitsArchivePersons(ids.ToList(), year, rangeOrder);
                return(personIds.Count);
            }
            catch (Exception ex)
            {
                BaseBusiness <Entity> .LogException(ex);

                throw ex;
            }
        }
コード例 #10
0
ファイル: BRemainLeave.cs プロジェクト: ImanRezaeipour/GTS
        /// <summary>
        /// مانده مرخصی را برای سالها و افراد جستجو شده  برمیگرداند
        /// حد اکثر 1000 برمیگردد
        /// </summary>
        /// <param name="proxy"></param>
        /// <param name="fromDate"></param>
        /// <param name="toDate"></param>
        /// <returns></returns>
        public int GetRemainLeaveCount(PersonAdvanceSearchProxy proxy, int fromYear, int toYear)
        {
            try
            {
                IList <decimal> underManagmentList = new List <decimal>();
                ISearchPerson   searchTool         = new BPerson();
                int             count = 1000;//searchTool.GetPersonInAdvanceSearchCount(proxy);
                IList <Person>  list  = searchTool.GetPersonInAdvanceSearch(proxy, 0, count);
                var             l     = from p in list
                                        select p.ID;
                underManagmentList = l.ToList <decimal>();

                /*
                 * if (underManagmentList != null && underManagmentList.Count > 0)
                 * {
                 *  DateTime fromDate, toDate;
                 *  if (BLanguage.CurrentSystemLanguage == LanguagesName.Parsi)
                 *  {
                 *      fromDate = Utility.ToMildiDate(String.Format("{0}/01/01", fromYear));
                 *      toDate = Utility.ToMildiDate(String.Format("{0}/01/01", toYear));
                 *  }
                 *  else
                 *  {
                 *      fromDate = new DateTime(fromYear, 1, 1);
                 *      toDate = new DateTime(toYear, 1, 1);
                 *  }
                 *  count = objectRep.GetCountByCriteria(new CriteriaStruct(Utility.GetPropertyName(() => new LeaveYearRemain().Date), fromDate, CriteriaOperation.GreaterEqThan),
                 *                                       new CriteriaStruct(Utility.GetPropertyName(() => new LeaveYearRemain().Date), toDate, CriteriaOperation.LessEqThan),
                 *                                       new CriteriaStruct(Utility.GetPropertyName(() => new LeaveYearRemain().PersonId), underManagmentList.ToArray<decimal>(), CriteriaOperation.IN));
                 *
                 * }
                 * return count;*/

                return(this.GetRemainLeaveCount(underManagmentList, fromYear, toYear));
            }
            catch (Exception ex)
            {
                LogException(ex, "BRemainLeave", "GetRemainLeaveCount");
                throw ex;
            }
        }
コード例 #11
0
ファイル: BPersonParams.cs プロジェクト: ImanRezaeipour/atlas
        public decimal DeletePersonsParamValue_onPersonnelUpdate(PersonParamValue filedValue, UIActionType UAT, PersonAdvanceSearchProxy proxy)
        {
            ISearchPerson    searchTool     = new BPerson();
            int              count          = searchTool.GetPersonInAdvanceSearchCount(proxy);
            IList <Person>   list           = searchTool.GetPersonInAdvanceSearch(proxy, 0, count);
            PersonParamValue personParamOld = GetAll().SingleOrDefault(p => p.ID == filedValue.ID);

            string   value    = personParamOld.Value;
            DateTime fromDate = personParamOld.FromDate;
            DateTime toDate   = personParamOld.ToDate;

            foreach (Person prs in list)
            {
                PersonParamValue personParamObj = new PersonParamValue();
                personParamObj = GetAll().SingleOrDefault(f => f.Person.ID == prs.ID && f.FromDate == fromDate && f.ToDate == toDate && f.Value == value);


                this.SaveChanges(personParamObj, UAT);
            }

            return(list.Count);
        }
コード例 #12
0
        public bool Calculate(PersonAdvanceSearchProxy proxy, string fromDate, string toDate, bool forceCalculate)
        {
            try
            {
                ISearchPerson  searchTool = new BPerson();
                int            count      = searchTool.GetPersonInAdvanceSearchCount(proxy);
                IList <Person> personList = searchTool.GetPersonInAdvanceSearch(proxy, 0, count)
                                            .Where(x => x.Active).ToList();
                var ids = from o in personList
                          select o.ID;

                DateTime from, to;
                if (BLanguage.CurrentSystemLanguage == LanguagesName.Parsi)
                {
                    from = Utility.ToMildiDate(fromDate);
                    to   = Utility.ToMildiDate(toDate);
                }
                else
                {
                    from = Utility.ToMildiDateTime(fromDate);
                    to   = Utility.ToMildiDateTime(toDate);
                }
                if (forceCalculate)
                {
                    BusinessEntity entity = new BusinessEntity();
                    entity.UpdateCFP(personList, from, true);
                }
                gtsEngineWS.GTS_ExecutePersonsByToDate(BUser.CurrentUser.UserName, ids.ToArray <decimal>(), to);
                BaseBusiness <Entity> .LogUserAction(String.Format("CalculateAll -> Count: {0} -->Calculate(AdvanceSearch,toDate)", personList.Count));

                return(true);
            }
            catch (Exception ex)
            {
                BaseBusiness <Entity> .LogException(ex, "BEngineCalculator", "Calculate(AdvanceSearch,toDate)");

                throw ex;
            }
        }
コード例 #13
0
ファイル: BPersonParams.cs プロジェクト: ImanRezaeipour/atlas
        public decimal InsertPersonsParamValue_onPersonnelUpdate(PersonParamValue filedValue, UIActionType UAT, PersonAdvanceSearchProxy proxy)
        {
            ISearchPerson    searchTool     = new BPerson();
            int              count          = searchTool.GetPersonInAdvanceSearchCount(proxy);
            IList <Person>   list           = searchTool.GetPersonInAdvanceSearch(proxy, 0, count);
            PersonParamValue personParamObj = new PersonParamValue();

            foreach (Person prs in list)
            {
                personParamObj             = new PersonParamValue();
                personParamObj.ID          = filedValue.ID;
                personParamObj.FromDate    = filedValue.FromDate;
                personParamObj.ParamField  = filedValue.ParamField;
                personParamObj.Person      = prs;
                personParamObj.TheFromDate = filedValue.TheFromDate;
                personParamObj.TheToDate   = filedValue.TheToDate;
                personParamObj.ToDate      = filedValue.ToDate;
                personParamObj.Value       = filedValue.Value;

                this.SaveChanges(personParamObj, UAT);
            }
            return(list.Count);
        }
コード例 #14
0
        public StiReport GetReport(decimal reportFileId, PersonAdvanceSearchProxy proxy, IList <ReportUIParameter> parmeters)
        {
            try
            {
                if (parmeters.Where(x => Utility.IsEmpty(x.ActionId)).Count() > 0)
                {
                    exception.Add(new ValidationException(ExceptionResourceKeys.ReportParameterActionIdIsEmpty, "شناسه عملیات مشخص نشده است", ExceptionSrc));
                    throw exception;
                }
                ISearchPerson   searchTool = new BPerson();
                IList <decimal> personIdList;
                IList <Person>  persons;
                if (Utility.IsEmpty(parmeters))
                {
                    //مثلا برای گزارش شیفتها چه نیازی به لیست پرسنل است
                    persons = new List <Person>();// searchTool.QuickSearch("", PersonCategory.Public);
                }
                else
                {
                    if (proxy.PersonIdList == null || proxy.PersonIdList.Count == 0)
                    {
                        persons = searchTool.GetPersonInAdvanceSearch(proxy);
                    }
                    else
                    {
                        persons = searchTool.GetPersonByPersonIdList(proxy.PersonIdList);
                    }
                }
                //کلیه پرسنل مدیر , جانشین و اپراتور
                if (persons.Count == 0 && !Utility.IsEmpty(parmeters))
                {
                    persons = searchTool.QuickSearchByPage(0, 1000, "");
                }

                if (persons.Count == 0 && !Utility.IsEmpty(parmeters))
                {
                    exception.Add(new ValidationException(ExceptionResourceKeys.ReportParameterPersonIsEmpty, "مجموعه انتخابی شامل هیچ پرسنلی نمیباشد", ExceptionSrc));
                    throw exception;
                }
                var ids = from o in persons
                          select o.ID;
                personIdList = ids.ToList <decimal>();

                IDictionary <string, object> ParamValues = new Dictionary <string, object>();
                foreach (ReportUIParameter param in parmeters)
                {
                    if (Utility.IsEmpty(param.Value))
                    {
                        exception.Add(new ValidationException(ExceptionResourceKeys.ReportParametersIsEmpty, "مقدار پارامترها مشخص نشده است", ExceptionSrc));
                        throw exception;
                    }

                    string value = param.Value;
                    IDictionary <string, object> result;
                    if (BusinessFactory.Exists(param.ActionId))
                    {
                        result = BusinessFactory.GetBusiness <IBControlParameter>(param.ActionId).ParsParameter(value, param.ActionId);
                    }
                    else
                    {
                        result = BaseControlParameter.ParsParameter(value);
                    }
                    if (result != null)
                    {
                        foreach (var item in result)
                        {
                            ParamValues.Add(item);
                        }
                    }
                }

                ReportFile   file         = this.GetReportFile(reportFileId);
                ReportHelper reportHelper = ReportHelper.Instance("شرکت طرح و پردازش غدیر", BUser.CurrentUser.ID, BUser.CurrentUser.Person.Name, personIdList);
                StiReport    report       = reportHelper.GetReport(@file.File);
                reportHelper.InitAssemblyReport(report);
                reportHelper.InitReportParameter(report, ParamValues);
                reportHelper.InitReportConnection(report, ReportParamRep.GetConnectionString());


                return(report);
            }
            catch (Exception ex)
            {
                BaseBusiness <Report> .LogException(ex, "BReportParameter", "GetReport");

                throw ex;
            }
        }
コード例 #15
0
        public void ExchangeDayByWorkGroup(decimal workGroupId, string firstDay, string secondDay)
        {
            UIValidationExceptions exception = new UIValidationExceptions();

            if (workGroupId == 0)
            {
                exception.Add(ExceptionResourceKeys.ExceptionShiftWorkGroupIdRequierd, "شناسه گروه کاری مشخص نشده است", ExceptionSrc);
            }

            if (exception.Count > 0)
            {
                throw exception;
            }
            using (NHibernateSessionManager.Instance.BeginTransactionOn())
            {
                try
                {
                    DateTime firstDate, secondDate;
                    if (BLanguage.CurrentSystemLanguage == LanguagesName.Parsi)
                    {
                        firstDate  = Utility.ToMildiDate(firstDay);
                        secondDate = Utility.ToMildiDate(secondDay);
                    }
                    else
                    {
                        firstDate  = Utility.ToMildiDateTime(firstDay);
                        secondDate = Utility.ToMildiDateTime(secondDay);
                    }

                    ISearchPerson            searchTool = new BPerson();
                    PersonAdvanceSearchProxy proxy      = new PersonAdvanceSearchProxy();
                    proxy.WorkGroupId       = workGroupId;
                    proxy.WorkGroupFromDate = Utility.ToString(firstDate);
                    int            count   = searchTool.GetPersonInAdvanceSearchCount(proxy);
                    IList <Person> persons = searchTool.GetPersonInAdvanceSearch(proxy, 0, count);
                    foreach (Person prs in persons)
                    {
                        decimal personId = prs.ID;
                        objectRep.DeleteExceptionShift(personId, firstDate, firstDate);
                        objectRep.DeleteExceptionShift(personId, secondDate, secondDate);

                        ShiftRepository shiftRep = new ShiftRepository();
                        decimal?        shift1   = shiftRep.GetShiftIdByPersonId(personId, firstDate);
                        decimal?        shift2   = shiftRep.GetShiftIdByPersonId(personId, secondDate);

                        ShiftException exShift = new ShiftException();
                        exShift.RegistrationDate = DateTime.Now.Date;
                        exShift.Date             = secondDate;
                        exShift.Person           = new Person()
                        {
                            ID = personId
                        };
                        exShift.UserID = BUser.CurrentUser.ID;
                        if (shift1 != null && shift1 > 0)
                        {
                            exShift.Shift = new Shift()
                            {
                                ID = (decimal)shift1
                            };
                        }
                        else
                        {
                            exShift.Shift = null;
                        }
                        base.SaveChanges(exShift, UIActionType.ADD);

                        exShift = new ShiftException();
                        exShift.RegistrationDate = DateTime.Now.Date;
                        exShift.Date             = firstDate;
                        exShift.Person           = new Person()
                        {
                            ID = personId
                        };
                        exShift.UserID = BUser.CurrentUser.ID;
                        if (shift2 != null && shift2 > 0)
                        {
                            exShift.Shift = new Shift()
                            {
                                ID = (decimal)shift2
                            };
                        }
                        else
                        {
                            exShift.Shift = null;
                        }
                        base.SaveChanges(exShift, UIActionType.ADD);
                    }

                    NHibernateSessionManager.Instance.CommitTransactionOn();
                }
                catch (Exception ex)
                {
                    NHibernateSessionManager.Instance.RollbackTransactionOn();
                    LogException(ex, "BExceptionShift", "ExchangeDayByWorkGroup");
                    throw ex;
                }
            }
        }
コード例 #16
0
        public void ExchangeWorkGroup(decimal workGroup1, decimal workGroup2, string date1, string date2)
        {
            UIValidationExceptions exception = new UIValidationExceptions();

            if (workGroup1 == 0 || workGroup2 == 0)
            {
                exception.Add(ExceptionResourceKeys.ExceptionShiftWorkGroupIdRequierd, "شناسه گروه کاری مشخص نشده است", ExceptionSrc);
            }

            if (exception.Count > 0)
            {
                throw exception;
            }
            using (NHibernateSessionManager.Instance.BeginTransactionOn())
            {
                try
                {
                    DateTime dayDate1, dayDate2;
                    if (BLanguage.CurrentSystemLanguage == LanguagesName.Parsi)
                    {
                        dayDate1 = Utility.ToMildiDate(date1);
                        dayDate2 = Utility.ToMildiDate(date2);
                    }
                    else
                    {
                        dayDate1 = Utility.ToMildiDateTime(date1);
                        dayDate2 = Utility.ToMildiDateTime(date2);
                    }

                    ISearchPerson            searchTool = new BPerson();
                    PersonAdvanceSearchProxy proxy      = new PersonAdvanceSearchProxy();
                    proxy.WorkGroupId       = workGroup1;
                    proxy.WorkGroupFromDate = Utility.ToString(dayDate1);
                    int            count    = searchTool.GetPersonInAdvanceSearchCount(proxy);
                    IList <Person> persons1 = searchTool.GetPersonInAdvanceSearch(proxy, 0, count);

                    proxy                   = new PersonAdvanceSearchProxy();
                    proxy.WorkGroupId       = workGroup2;
                    proxy.WorkGroupFromDate = Utility.ToString(dayDate2);
                    count                   = searchTool.GetPersonInAdvanceSearchCount(proxy);
                    IList <Person> persons2 = searchTool.GetPersonInAdvanceSearch(proxy, 0, count);

                    ShiftRepository shiftRep = new ShiftRepository(false);
                    decimal?        shift1   = shiftRep.GetShiftIdByWorkGroupId(workGroup1, dayDate1);
                    decimal?        shift2   = shiftRep.GetShiftIdByWorkGroupId(workGroup2, dayDate2);

                    foreach (Person prs in persons2)
                    {
                        decimal personId2 = prs.ID;
                        objectRep.DeleteExceptionShift(personId2, dayDate2, dayDate2);
                        objectRep.DeleteExceptionShift(personId2, dayDate1, dayDate1);

                        ShiftException exShift = new ShiftException();
                        exShift.Date   = dayDate1;
                        exShift.Person = new Person()
                        {
                            ID = personId2
                        };
                        exShift.RegistrationDate = DateTime.Now;
                        if (shift1 != null && shift1 > 0)
                        {
                            exShift.Shift = new Shift()
                            {
                                ID = (decimal)shift1
                            };
                        }
                        else
                        {
                            exShift.Shift = null;
                        }
                        base.SaveChanges(exShift, UIActionType.ADD);
                    }

                    foreach (Person prs in persons1)
                    {
                        decimal personId1 = prs.ID;
                        objectRep.DeleteExceptionShift(personId1, dayDate2, dayDate2);
                        objectRep.DeleteExceptionShift(personId1, dayDate1, dayDate1);

                        ShiftException exShift = new ShiftException();
                        exShift.Date   = dayDate2;
                        exShift.Person = new Person()
                        {
                            ID = personId1
                        };
                        exShift.RegistrationDate = DateTime.Now;
                        if (shift2 != null && shift2 > 0)
                        {
                            exShift.Shift = new Shift()
                            {
                                ID = (decimal)shift2
                            };
                        }
                        else
                        {
                            exShift.Shift = null;
                        }
                        base.SaveChanges(exShift, UIActionType.ADD);
                    }
                    NHibernateSessionManager.Instance.CommitTransactionOn();
                }
                catch (Exception ex)
                {
                    NHibernateSessionManager.Instance.RollbackTransactionOn();
                    LogException(ex, "BExceptionShift", "ExchangeWorkGroup");
                    throw ex;
                }
            }
        }
コード例 #17
0
        /// <summary>
        /// انجام محاسبات پرسنل جستجو شده در بازه زمانی مشخص
        /// </summary>
        /// <param name="proxy">پروکسی جستجوی پیشرفته پرسنل</param>
        /// <param name="fromDate">تاریخ شروع</param>
        /// <param name="toDate">تاریخ پایان</param>
        /// <param name="forceCalculate">محاسبات اجباری</param>
        /// <returns>انجام شد یا نشد</returns>
        public bool Calculate(PersonAdvanceSearchProxy proxy, string fromDate, string toDate, bool forceCalculate)
        {
            try
            {
                bool   IsCalculationDependOnLockDate    = true;
                string IsCalculationDependOnLockDateStr = System.Configuration.ConfigurationManager.AppSettings["IsCalculationDependOnLockDate"];

                bool resultGetAppSetting = Boolean.TryParse(IsCalculationDependOnLockDateStr, out IsCalculationDependOnLockDate);
                if (!resultGetAppSetting)
                {
                    IsCalculationDependOnLockDate = true;
                }
                UIValidationExceptions exception  = new UIValidationExceptions();
                ISearchPerson          searchTool = new BPerson();
                int            count      = searchTool.GetPersonInAdvanceSearchCount(proxy);
                IList <Person> personList = searchTool.GetPersonInAdvanceSearch(proxy, 0, count)
                                            .Where(x => x.Active).ToList();
                var ids = from o in personList
                          select o.ID;
                IList <decimal> PersonIdCalculateList = new List <decimal>();
                DateTime        from, to;
                if (BLanguage.CurrentSystemLanguage == LanguagesName.Parsi)
                {
                    from = Utility.ToMildiDate(fromDate);
                    to   = Utility.ToMildiDate(toDate);
                }
                else
                {
                    from = Utility.ToMildiDateTime(fromDate);
                    to   = Utility.ToMildiDateTime(toDate);
                }
                if (to != Utility.GTSMinStandardDateTime && from > to)
                {
                    exception.Add(new ValidationException(ExceptionResourceKeys.CalculationStartDateIsGreaterThanCalculationEndDate, "تاریخ ابتدا از تاریخ انتها بزرگتر است", ExceptionSrc));
                }
                if (exception.Count > 0)
                {
                    throw exception;
                }

                if (forceCalculate)
                {
                    BusinessEntity entity = new BusinessEntity();


                    Dictionary <decimal, decimal>  UiValidationGroupIdPersonList = uivalidationGroupingRepository.GetUivalidationPersonIdList(ids.ToList <decimal>());
                    Dictionary <decimal, DateTime> uivalidationGroupIdDic        = new Dictionary <decimal, DateTime>();
                    foreach (KeyValuePair <decimal, decimal> uiValidateionGrpId in UiValidationGroupIdPersonList)
                    {
                        if (!uivalidationGroupIdDic.ContainsKey(uiValidateionGrpId.Value))
                        {
                            DateTime calculationLockDate = entity.UIValidator.GetCalculationLockDateByGroup(uiValidateionGrpId.Value);
                            uivalidationGroupIdDic.Add(uiValidateionGrpId.Value, calculationLockDate);
                        }
                    }
                    int personFailedToCalculateCount = 0;
                    if (IsCalculationDependOnLockDate)
                    {
                        foreach (decimal item in ids)
                        {
                            UIValidationExceptions exceptionLockDate = new UIValidationExceptions();
                            if (UiValidationGroupIdPersonList.Keys.Contains(item))
                            {
                                decimal  groupId = UiValidationGroupIdPersonList.FirstOrDefault(u => u.Key == item).Value;
                                DateTime calculationPersonLockDate = uivalidationGroupIdDic.FirstOrDefault(u => u.Key == groupId).Value;
                                if (calculationPersonLockDate >= from)
                                {
                                    personFailedToCalculateCount++;

                                    exceptionLockDate.Add(new ValidationException(ExceptionResourceKeys.UIValidation_R3_LockCalculationFromDate, String.Format("خطا در انجام محاسبات - محاسبات برای پرسنل ({0}) بسته شده است", personList.FirstOrDefault(p => p.ID == item).BarCode + "-" + personList.FirstOrDefault(p => p.ID == item).Name), ExceptionSrc));
                                    BaseBusiness <Entity> .LogException(exceptionLockDate, "BEngineCalculator", "Calculate");
                                }
                                else
                                {
                                    PersonIdCalculateList.Add(item);
                                }
                            }
                            else
                            {
                                exceptionLockDate.Add(new ValidationException(ExceptionResourceKeys.UIValidation_R3_LockCalculationFromDate, String.Format("خطا در انجام محاسبات - تاریخ بستن محاسبات برای پرسنل {0} یافت نشد", personList.FirstOrDefault(p => p.ID == item).BarCode + "-" + personList.FirstOrDefault(p => p.ID == item).Name), ExceptionSrc));
                                BaseBusiness <Entity> .LogException(exceptionLockDate, "BEngineCalculator", "Calculate");
                            }
                        }
                    }
                    else
                    {
                        PersonIdCalculateList = ids.ToList();
                    }

                    IList <CFP> cfpPersonList = new List <CFP>();
                    if (PersonIdCalculateList.Count > 0)
                    {
                        cfpPersonList = entity.GetCFPPersons(PersonIdCalculateList.Select(a => a).ToList <decimal>());
                    }
                    IList <decimal> cfpPersonIdInsertList = new List <decimal>();
                    entity.UpdateCfpByPersonList(PersonIdCalculateList, from);
                    cfpPersonIdInsertList = PersonIdCalculateList.Where(p => cfpPersonList != null && !cfpPersonList.Select(c => c.PrsId).ToList().Contains(p)).Select(p => p).Distinct().ToList <decimal>();
                    if (cfpPersonIdInsertList.Count > 0)
                    {
                        entity.InsertCfpByPersonList(cfpPersonIdInsertList, from);
                    }
                    SessionHelper.SaveSessionValue(SessionHelper.PersonIsFailedForCalculate, personFailedToCalculateCount);
                }
                else
                {
                    PersonIdCalculateList = ids.ToList();
                }

                BTemp  bTemp = new BTemp();
                string operationGUID = bTemp.InsertTempList(PersonIdCalculateList);
                gtsEngineWS.GTS_ExecutePersonsByToDateGUID(BUser.CurrentUser.UserName, operationGUID, to);
                bTemp.DeleteTempList(operationGUID);
                BaseBusiness <Entity> .LogUserAction(String.Format("CalculateAll -> Count: {0} -->Calculate(AdvanceSearch,toDate)", PersonIdCalculateList.Count));

                return(true);
            }
            catch (Exception ex)
            {
                BaseBusiness <Entity> .LogException(ex, "BEngineCalculator", "Calculate(AdvanceSearch,toDate)");

                throw ex;
            }
        }