/// <summary> /// تعداد کل نتایج جستجو را برمیگرداند /// </summary> /// <returns></returns> public int GetAllPaeronsCount(Business.Proxy.PersonAdvanceSearchProxy proxy) { ISearchPerson bperson = new BPerson(); int count = bperson.GetPersonInAdvanceSearchCount(proxy); return(count); }
/// <summary> /// تعداد مدیران جستجو شده /// اگر کاربر فعلی اپراتور فقط در بین مدیران زیر دست اپراتور جست و جو میکنیم /// ولی اگر مدیر باشد نتایج جست و جو تهی میباشد /// اگر هم مدیر باشد و هم اپراتور آنگاه خود شخص به علاوه مدیران تحت مدیریت برمیگردد /// </summary> /// <param name="proxy"></param> /// <returns></returns> public int GetAllManagerCount(PersonAdvanceSearchProxy proxy) { //if (!IsOperator()) { return 0; } ISearchPerson searchTools = new BPerson(); int count = searchTools.GetPersonInAdvanceSearchCount(proxy, PersonCategory.Manager); return(count); }
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); }
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; } }
/// <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; } }
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); }
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; } }
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); }
/// <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; } }
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; } } }
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; } } }