/// <summary> /// یک آیتم از کومبو حذف میکند /// </summary> /// <param name="reservedFieldId"></param> /// <param name="comboItem"></param> public void DeleteComboItem(decimal reservedFieldId, decimal comboItem) { try { PersonReserveField field = base.GetByID(reservedFieldId); if (field.ControlType == PersonReservedFieldsType.ComboValue) { if (field.ComboItems == null) { field.ComboItems = new List <PersonReserveFieldComboValue>(); } PersonReserveFieldComboValue item = field.ComboItems.Where(x => x.ID == comboItem).FirstOrDefault(); if (item != null) { EntityRepository <PersonDetail> dtlRep = new EntityRepository <PersonDetail>(false); bool flag = false; switch (field.OrginalName) { case "R16": if (dtlRep.GetCountByCriteria(new CriteriaStruct(Utility.GetPropertyName(() => new PersonTASpec().R16), item.ID)) > 0) { flag = true; } break; case "R17": if (dtlRep.GetCountByCriteria(new CriteriaStruct(Utility.GetPropertyName(() => new PersonTASpec().R17), item.ID)) > 0) { flag = true; } break; case "R18": if (dtlRep.GetCountByCriteria(new CriteriaStruct(Utility.GetPropertyName(() => new PersonTASpec().R18), item.ID)) > 0) { flag = true; } break; case "R19": if (dtlRep.GetCountByCriteria(new CriteriaStruct(Utility.GetPropertyName(() => new PersonTASpec().R19), item.ID)) > 0) { flag = true; } break; case "R20": if (dtlRep.GetCountByCriteria(new CriteriaStruct(Utility.GetPropertyName(() => new PersonTASpec().R20), item.ID)) > 0) { flag = true; } break; } if (flag) { UIValidationExceptions exception = new UIValidationExceptions(); exception.Add(new ValidationException(ExceptionResourceKeys.PrsRsvFldComboValueUsedByPerson, "آیتم انتخابیی جهت حذف ، در پرسنل قبلا استفاده شده است", ExceptionSrc)); throw exception; } field.ComboItems.Remove(item); this.SaveChanges(field, UIActionType.EDIT); } } else { throw new IllegalServiceAccess("تنها برای فیلدهایی از نوع انتخابی ، گزینه موجود است", ExceptionSrc); } } catch (Exception ex) { LogException(ex); throw ex; } }
public IList <ImperativeUndermanagementInfoProxy> GetAdvancedSearchPersonByImperativeRequest(PersonAdvanceSearchProxy proxy, ImperativeRequestLoadState IRLS, ImperativeRequest imperativeRequest, PersonCategory searchInCategory, int pageIndex, int pageSize) { try { UIValidationExceptions exception = new UIValidationExceptions(); if (imperativeRequest.Precard == null || imperativeRequest.Precard.ID == 0) { exception.Add(new ValidationException(ExceptionResourceKeys.RequestPrecardIsEmpty, "پیشکارت نباید خالی باشد", ExceptionSrc)); } if (imperativeRequest.Year == null || imperativeRequest.Year == 0) { exception.Add(new ValidationException(ExceptionResourceKeys.RequestYearIsEmpty, "سال نباید خالی باشد", ExceptionSrc)); } if (imperativeRequest.Month == null || imperativeRequest.Month == 0) { exception.Add(new ValidationException(ExceptionResourceKeys.RequestMonthIsEmpty, "ماه نباید خالی باشد", ExceptionSrc)); } if (exception.Count == 0) { BApplicationSettings.CheckGTSLicense(); #region Date Convert if (!Utility.IsEmpty(proxy.FromBirthDate) && BLanguage.CurrentSystemLanguage == LanguagesName.Parsi) { proxy.FromBirthDate = Utility.ToMildiDateString(proxy.FromBirthDate); } if (!Utility.IsEmpty(proxy.ToBirthDate) && BLanguage.CurrentSystemLanguage == LanguagesName.Parsi) { proxy.ToBirthDate = Utility.ToMildiDateString(proxy.ToBirthDate); } if (!Utility.IsEmpty(proxy.FromEmploymentDate) && BLanguage.CurrentSystemLanguage == LanguagesName.Parsi) { proxy.FromEmploymentDate = Utility.ToMildiDateString(proxy.FromEmploymentDate); } if (!Utility.IsEmpty(proxy.ToEmploymentDate) && BLanguage.CurrentSystemLanguage == LanguagesName.Parsi) { proxy.ToEmploymentDate = Utility.ToMildiDateString(proxy.ToEmploymentDate); } if (!Utility.IsEmpty(proxy.WorkGroupFromDate) && BLanguage.CurrentSystemLanguage == LanguagesName.Parsi) { proxy.WorkGroupFromDate = Utility.ToMildiDateString(proxy.WorkGroupFromDate); } if (!Utility.IsEmpty(proxy.RuleGroupFromDate) && BLanguage.CurrentSystemLanguage == LanguagesName.Parsi) { proxy.RuleGroupFromDate = Utility.ToMildiDateString(proxy.RuleGroupFromDate); } if (!Utility.IsEmpty(proxy.RuleGroupToDate) && BLanguage.CurrentSystemLanguage == LanguagesName.Parsi) { proxy.RuleGroupToDate = Utility.ToMildiDateString(proxy.RuleGroupToDate); } if (!Utility.IsEmpty(proxy.CalculationFromDate) && BLanguage.CurrentSystemLanguage == LanguagesName.Parsi) { proxy.CalculationFromDate = Utility.ToMildiDateString(proxy.CalculationFromDate); } #endregion IList <Person> list; if (!Utility.IsEmpty(proxy.PersonId)) { list = new List <Person>(); Person prs = this.personBusiness.GetByID((decimal)proxy.PersonId); list.Add(prs); } else { decimal managerId = personBusiness.GetCurentManagerId(ref searchInCategory); list = this.imperativeRequestRepository.GetAdvancedSearchPersonByImperativeRequest(proxy, IRLS, imperativeRequest, BUser.CurrentUser.ID, managerId, searchInCategory, pageIndex, pageSize); } return(this.ConvertToImperativeUndermanagementInfoProxy(list, imperativeRequest, pageSize, pageIndex)); } else { throw exception; } } catch (Exception ex) { LogException(ex, "BImperativeRequest", "GetAdvancedSearchPersonByImperativeRequest"); throw ex; } }
public decimal InsertDateRange(CalculationRangeGroup calcDateRangeGroup, IList <CalculationDateRange> defaultDateRanges, IList <CalculationDateRange> dateRanges, IList <decimal> conceptTmpIds) { try { #region validation UIValidationExceptions exception = new UIValidationExceptions(); if (dateRanges == null || dateRanges.Count != 12) { exception.Add(new ValidationException(ExceptionResourceKeys.DateRangesCountNotEqualToTwelve, "تعداد ماههای ارسالی برای ذخیره دوره محاسبات باید برابر 12 باشد", ExceptionSrc)); } if (Utility.IsEmpty(conceptTmpIds)) { exception.Add(new ValidationException(ExceptionResourceKeys.DateRangesMustHaveConcept, "بمنظور بروزرسانی حتما باید یک یا چند مفهوم انتخاب شود", ExceptionSrc)); } if (exception.Count > 0) { throw exception; } #endregion LanguagesName sysLanguage = BLanguage.CurrentSystemLanguage; if (sysLanguage != null) { calcDateRangeGroup.Culture = sysLanguage; } calcDateRangeGroup.DateRangeList = new List <CalculationDateRange>(); foreach (decimal conceptID in conceptTmpIds) { IList <CalculationDateRange> rangeList = dateRanges.Clone <CalculationDateRange>(); for (int i = 0; i < rangeList.Count; i++) { rangeList[i].Concept = new SecondaryConcept() { ID = conceptID }; rangeList[i].RangeGroup = calcDateRangeGroup; SetDateRangeIndex(rangeList[i]); } ((List <CalculationDateRange>)calcDateRangeGroup.DateRangeList).AddRange(rangeList); } //درج دورهای پیشفرض IList <SecondaryConcept> orginConcepts = this.GetAllRanglyConcepts(); foreach (SecondaryConcept cnp in orginConcepts) { if (conceptTmpIds.Where(x => x == cnp.ID).Count() == 0) { IList <CalculationDateRange> rangeList = defaultDateRanges.Clone <CalculationDateRange>(); for (int i = 0; i < rangeList.Count; i++) { rangeList[i].Concept = new SecondaryConcept() { ID = cnp.ID }; rangeList[i].RangeGroup = calcDateRangeGroup; SetDateRangeIndex(rangeList[i]); } ((List <CalculationDateRange>)calcDateRangeGroup.DateRangeList).AddRange(rangeList); } } base.SaveChanges(calcDateRangeGroup, UIActionType.ADD); return(calcDateRangeGroup.ID); } catch (Exception ex) { LogException(ex, "BDateRange", "InsertDateRange"); throw ex; } }
/// <summary> /// «اعتبارسنجی /// «نام شیفت خالی نباشد /// «نام شیفت تکراری نباشد /// «رنگ شیفت نباید خالی باشد /// «رنگ شیفت نباید تکراری باشد /// « کد تعریف شده نباید تکراری باشد /// </summary> /// <param name="shift"></param> protected override void UpdateValidate(Shift shift) { UIValidationExceptions exception = new UIValidationExceptions(); if (Utility.IsEmpty(shift.Name)) { exception.Add(ExceptionResourceKeys.ShiftNameRequierd, "بروزرسانی - نام شیفت نباید خالی باشد", ExceptionSrc); } else { if (shiftRepository.GetCountByCriteria(new CriteriaStruct(Utility.GetPropertyName(() => shift.Name), shift.Name), new CriteriaStruct(Utility.GetPropertyName(() => shift.ID), shift.ID, CriteriaOperation.NotEqual)) > 0) { exception.Add(ExceptionResourceKeys.ShiftNameRepeated, "بروزرسانی - نام شیفت نباید تکراری باشد", ExceptionSrc); } } if (Utility.IsEmpty(shift.Color)) { exception.Add(ExceptionResourceKeys.ShiftColorRequierd, "بروزرسانی - رنگ شیفت نباید خالی باشد", ExceptionSrc); } //else //{ // if (shiftRepository.GetCountByCriteria(new CriteriaStruct(Utility.GetPropertyName(() => shift.Color), shift.Color), // new CriteriaStruct(Utility.GetPropertyName(() => shift.ID), shift.ID, CriteriaOperation.NotEqual)) > 0) // { // exception.Add(ExceptionResourceKeys.ShiftColorRepeated, "بروزرسانی - رنگ شیفت نباید تکراری باشد", ExceptionSrc); // } //} if (shift.ShiftType == null) { exception.Add(ExceptionResourceKeys.ShiftTypeRequierd, "بروزرسانی - نوع شیفت نباید خالی باشد", ExceptionSrc); } else if (shift.ShiftType != ShiftTypesEnum.COMPENSATION_OVERTIME && shift.ShiftType != ShiftTypesEnum.OVERTIME && shift.ShiftType != ShiftTypesEnum.WORK) { exception.Add(ExceptionResourceKeys.ShiftTypeRequierd, "بروزرسانی - نوع شیفت نامعتبر میباشد", ExceptionSrc); } if (!Utility.IsEmpty(shift.CustomCode)) { if (shiftRepository.GetCountByCriteria(new CriteriaStruct(Utility.GetPropertyName(() => shift.CustomCode), shift.CustomCode), new CriteriaStruct(Utility.GetPropertyName(() => shift.ID), shift.ID, CriteriaOperation.NotEqual)) > 0) { exception.Add(new ValidationException(ExceptionResourceKeys.ShiftCustomCodeRepeated, "بروزرسانی - کد گروه کاری نباید تکراری باشد7", ExceptionSrc)); } } if (!Utility.IsEmpty(shift.ShortcutsKey)) { if (shiftRepository.GetCountByCriteria(new CriteriaStruct(Utility.GetPropertyName(() => shift.ShortcutsKey), shift.ShortcutsKey), new CriteriaStruct(Utility.GetPropertyName(() => shift.ID), shift.ID, CriteriaOperation.NotEqual)) > 0) { exception.Add(new ValidationException(ExceptionResourceKeys.ShiftShortsKeyRepeated, "کلید میانبر نباید تکراری باشد", ExceptionSrc)); } } if (exception.Count > 0) { throw exception; } }
protected override void UpdateValidate(PersonContractAssignment personContractAssignment) { UIValidationExceptions exception = new UIValidationExceptions(); EntityRepository <Contract> contractRep = new EntityRepository <Contract>(false); PersonRepository personRep = new PersonRepository(false); PersonContractAssignment PersonContractAssignmentAlias = null; Person PersonAlias = null; this.CheckUserInterfaceRuleGroup(personContractAssignment.Person); if (personContractAssignment.Person == null || personRep.GetCountByCriteria(new CriteriaStruct(Utility.GetPropertyName(() => new Person().ID), personContractAssignment.Person.ID)) == 0) { exception.Add(new ValidationException(ExceptionResourceKeys.PersonContractAssignmentPersonIdNotExsits, "پرسنلی با این مشخصات یافت نشد", ExceptionSrc)); } if (personContractAssignment.Contract == null || contractRep.GetCountByCriteria(new CriteriaStruct(Utility.GetPropertyName(() => new Contract().ID), personContractAssignment.Contract.ID)) == 0) { exception.Add(new ValidationException(ExceptionResourceKeys.PersonContractAssignmentContractIdNotExsits, "قرارداد با این مشخصات یافت نشد", ExceptionSrc)); } if (personContractAssignment.FromDate < Utility.GTSMinStandardDateTime || personContractAssignment.ToDate < Utility.GTSMinStandardDateTime) { exception.Add(new ValidationException(ExceptionResourceKeys.PersonContractAssignmentDateSmallerThanStandardValue, "مقدار تاریخ انتساب قرارداد از حد مجاز کمتر میباشد", ExceptionSrc)); } if (personContractAssignment.ToDate != Utility.GTSMinStandardDateTime && personContractAssignment.FromDate > personContractAssignment.ToDate) { exception.Add(new ValidationException(ExceptionResourceKeys.PersonContractAssignmentFromDateGreaterThanToDate, "تاریخ انتساب ابتدای قرارداد از انتها بزرگتر است", ExceptionSrc)); } if (exception.Count == 0) { IList <PersonContractAssignment> personContractAssignmentList = NHSession.QueryOver <PersonContractAssignment>(() => PersonContractAssignmentAlias) .JoinAlias(() => PersonContractAssignmentAlias.Person, () => PersonAlias) .Where(() => !PersonContractAssignmentAlias.IsDeleted && PersonAlias.ID == personContractAssignment.Person.ID && PersonContractAssignmentAlias.ID != personContractAssignment.ID ) .List <PersonContractAssignment>(); if (personContractAssignmentList != null && personContractAssignmentList.Count > 0) { personContractAssignmentList.ToList() .ForEach(x => { if (x.ToDate == Utility.GTSMinStandardDateTime) { x.ToDate = DateTime.MaxValue.Date; } } ); } if (personContractAssignment.ToDate == Utility.GTSMinStandardDateTime) { personContractAssignment.ToDate = DateTime.MaxValue.Date; } if (this.CheckPersonContractAssignmentConfilct(personContractAssignmentList.ToList(), personContractAssignment)) { exception.Add(new ValidationException(ExceptionResourceKeys.PersonContractAssignmentDateHasConfilict, "تاریخ انتساب قرارداد با تاریخ های قبلی همپوشانی دارد", ExceptionSrc)); } if (personContractAssignment.ToDate == DateTime.MaxValue.Date) { personContractAssignment.ToDate = Utility.GTSMinStandardDateTime; } } if (exception.Count == 0 && personContractAssignment.Person != null && personContractAssignment.Person.ID != 0) { BPerson bPerson = new BPerson(); Person person = bPerson.GetByID(personContractAssignment.Person.ID); if (person != null && person.ID != 0 && personContractAssignment.FromDate < person.EmploymentDate) { exception.Add(new ValidationException(ExceptionResourceKeys.personContractAssignmentFromDateMustNotLessThanEmploymentDate, "تاریخ انتساب ابتدای قرارداد نباید از تاریخ استخدام کوچکتر باشد", ExceptionSrc)); } if (person.PersonContractAssignmentList != null && person.PersonContractAssignmentList.Count > 0) { person.PersonContractAssignmentList.ToList().ForEach(x => { this.NHSession.Evict(x); }); } this.NHSession.Evict(person); } if (exception.Count > 0) { throw exception; } }
/// <summary> /// بروزرسانی مدیرهای یک جریان خاص /// </summary> /// <param name="flowId">کد جریان</param> /// <param name="activeFlow">وضعیت فعال بودن</param> /// <param name="mngrFlows">مدیران جریان کاری</param> public void UpdateManagerFlows(decimal flowId, bool activeFlow, bool mainFlow, IList <ManagerProxy> mngrFlows) { ManagerRepository managerRep = new ManagerRepository(false); using (NHibernateSessionManager.Instance.BeginTransactionOn()) { try { if (Utility.IsEmpty(mngrFlows)) { UIValidationExceptions exception = new UIValidationExceptions(); exception.Add(new ValidationException(ExceptionResourceKeys.FlowMustHaveOneManagerFlow, "جریان کاری باید حداقل دارای یک مدیر در خود باشد", ExceptionSrc)); throw exception; } BManager bManager = new BManager(); Flow flow = base.GetByID(flowId); flow.ActiveFlow = activeFlow; flow.MainFlow = mainFlow; flow.ManagerFlowList = new List <ManagerFlow>(); flowRep.DeleteManagerFlows(flowId); foreach (ManagerProxy mp in mngrFlows) { ManagerFlow managerFlow = new ManagerFlow(); Manager mng; if (mp.OwnerID == 0) { UIValidationExceptions exception = new UIValidationExceptions(); exception.Add(new ValidationException(ExceptionResourceKeys.FlowPersonOrOrganizationMustSpecified, "یا شخص یا پست سازمانی باید مقداردهی شود", ExceptionSrc)); throw exception; } if (mp.ManagerType == ManagerType.Person) { mng = managerRep.GetManagerByPersonID(mp.OwnerID); if (mng == null || mng.ID == 0) { Manager manager = new Manager(); manager.Person = new Person() { ID = mp.OwnerID }; manager.Active = true; bManager.SaveChanges(manager, UIActionType.ADD); mng = manager; } } else { mng = managerRep.GetManagerByOrganID(mp.OwnerID); if (mng == null || mng.ID == 0) { Manager manager = new Manager(); manager.OrganizationUnit = new OrganizationUnit() { ID = mp.OwnerID }; manager.Active = true; bManager.SaveChanges(manager, UIActionType.ADD); mng = manager; } } managerFlow.Active = true; managerFlow.Manager = mng; managerFlow.Flow = flow; managerFlow.Level = mp.Level; flow.ManagerFlowList.Add(managerFlow); } SaveChanges(flow, UIActionType.EDIT); managerRep.SetManagerActivation(); LogUserAction(flow, "Change Manager Flow Levels"); NHibernateSessionManager.Instance.CommitTransactionOn(); } catch (Exception ex) { NHibernateSessionManager.Instance.RollbackTransactionOn(); LogException(ex); throw ex; } } }
private void SaveSMSSetting(SMSSettings setting, User user) { try { /*if (user == null || user.ID == 0) * { * throw new InvalidDatabaseStateException(UIFatalExceptionIdentifiers.CurrentUserIsNotValid, "کاربر جاری نا معتبر است", ExceptionSrc); * }*/ if (user.UserSetting == null || user.UserSetting.ID == 0) { user.UserSetting = this.GetUserSettings(user); } if (user.UserSetting.SMSSettings == null) { user.UserSetting.SMSSettings = this.GetSMSSettings(user.UserSetting); } if (user.UserSetting.EmailSettings == null) { user.UserSetting.EmailSettings = this.GetEmailSettings(user.UserSetting); } UserSettings userSetting = base.GetByID(user.UserSetting.ID); userSetting.SMSSettings.Active = setting.Active; userSetting.SMSSettings.DayHour = Utility.RealTimeToIntTime(setting.TheDayHour); userSetting.SMSSettings.DayCount = setting.DayCount; userSetting.SMSSettings.Hour = Utility.RealTimeToIntTime(setting.TheHour); userSetting.SMSSettings.SendByDay = setting.SendByDay; #region validation UIValidationExceptions exceptions = new UIValidationExceptions(); if (setting.Active) { if (setting.SendByDay) { if (userSetting.SMSSettings.DayHour == 0) { exceptions.Add(new ValidationException(ExceptionResourceKeys.UserSet_SMSTimeIsNotValid, "زمان ارسال ایمیل نا معتبر است", ExceptionSrc)); } } else { if (userSetting.SMSSettings.Hour == 0) { exceptions.Add(new ValidationException(ExceptionResourceKeys.UserSet_SMSTimeIsNotValid, "زمان ارسال ایمیل نا معتبر است", ExceptionSrc)); } else if (userSetting.SMSSettings.Hour < 5) { exceptions.Add(new ValidationException(ExceptionResourceKeys.UserSet_SMSTimeLessThanMin, "تکرار زمان ارسال ایمیل حداقل 5 دقیقه میباشد", ExceptionSrc)); } } } if (exceptions.Count > 0) { throw exceptions; } #endregion this.SaveChanges(userSetting, UIActionType.EDIT); } catch (Exception ex) { LogException(ex, "BUserSettings", "SaveSMSSettings"); throw ex; } }
private decimal TransferToNextYear(decimal personId, DateTime fromDate, DateTime toDate, int fromYear, int toYear) { try { UIValidationExceptions exception = new UIValidationExceptions(); if (toYear - fromYear != 1) { exception.Add(new ValidationException(ExceptionResourceKeys.RemainTransferFromToYearDiffrenceMoreThanOne, "اختلاف سال شروع و پایان برای انتقال مانده مرخصی به سال بعد باید یک باشد", ExceptionSrc)); } int fromYearCount = this.GetRemainLeaveCount(personId, fromYear, fromYear); LeaveYearRemain toLeaveYear = objectRep.GetByCriteria(new CriteriaStruct(Utility.GetPropertyName(() => new LeaveYearRemain().Date), fromDate), new CriteriaStruct(Utility.GetPropertyName(() => new LeaveYearRemain().Date), toDate), new CriteriaStruct(Utility.GetPropertyName(() => new LeaveYearRemain().PersonId), personId)).FirstOrDefault(); if (toLeaveYear == null) { toLeaveYear = new LeaveYearRemain(); } if (fromYearCount == 0) { exception.Add(new ValidationException(ExceptionResourceKeys.RemainTransferFromYearIsNotExists, "طلب سالانه مرخصی برای سال شروع مشخص شده موجود نمیباشد ", ExceptionSrc)); } if (exception.Count > 0) { throw exception; } GTSEngineWS.TotalWebServiceClient gtsEngineWS = new GTS.Clock.Business.GTSEngineWS.TotalWebServiceClient(); gtsEngineWS.GTS_ExecuteByPersonID(BUser.CurrentUser.UserName, personId); int realDay, realMinute; this.GetRemainLeaveToEndOfYear(personId, fromYear, 12, out realDay, out realMinute); toLeaveYear.Date = toDate; toLeaveYear.Person = new Person() { ID = personId }; toLeaveYear.DayRemainReal = realDay; toLeaveYear.MinuteRemainReal = realMinute; toLeaveYear.DayRemainOK = realDay; toLeaveYear.MinuteRemainOK = realMinute; decimal leaveRemainID = 0; if (toLeaveYear.ID != 0) { leaveRemainID = this.SaveChanges(toLeaveYear, UIActionType.EDIT); } else { leaveRemainID = this.SaveChanges(toLeaveYear, UIActionType.ADD); } this.ExtraLeaveYearRemainsExistanceValidate(leaveRemainID, toDate, personId); return(toLeaveYear.ID); } catch (Exception ex) { LogException(ex, "BRemainLeave", "TransferToNextYear"); throw ex; } }
public void ExchangePerson(decimal personId1, decimal personId2, string date1, string date2) { UIValidationExceptions exception = new UIValidationExceptions(); if (personId1 == 0 || personId2 == 0) { exception.Add(ExceptionResourceKeys.ExceptionShiftPersonIdRequierd, "شناسه پرسنل مشخص نشده است", 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); } objectRep.DeleteExceptionShift(personId1, dayDate1, dayDate1); objectRep.DeleteExceptionShift(personId1, dayDate2, dayDate2); objectRep.DeleteExceptionShift(personId2, dayDate2, dayDate2); objectRep.DeleteExceptionShift(personId2, dayDate1, dayDate1); ShiftRepository shiftRep = new ShiftRepository(); decimal? shift1 = shiftRep.GetShiftIdByPersonId(personId1, dayDate1); decimal? shift2 = shiftRep.GetShiftIdByPersonId(personId2, dayDate2); ShiftException exShift = new ShiftException(); exShift.RegistrationDate = DateTime.Now.Date; exShift.Date = dayDate1; exShift.Person = new Person() { ID = personId2 }; 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 = dayDate2; exShift.Person = new Person() { ID = personId1 }; 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", "ExchangePerson"); 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; } } }
public static void LogException(UIValidationExceptions ex, string className, string methodName) { new EntityBusiness().LogException(ex, className, methodName, BUser.CurrentUser.UserName, IsBusinessLogEnable); }
/// <summary> /// ارتباطات مفهوم ثانوی با بقیه مدل ها را دیتابیس ایجاد و بروزرسانی می کند /// </summary> /// <param name="secondaryConcept">مفهوم ثانوی</param> private void AddUpdateRelatedExpression(SecondaryConcept secondaryConcept) { try { var bCnpExpression = new BConceptExpression(); var cnpExpressionRoot = bCnpExpression.GetRoot(); if (cnpExpressionRoot == null) { try { cnpExpressionRoot = new ConceptExpression { AddOnParentCreation = false, CanAddToFinal = false, CanEditInFinal = false, CustomeCategoryCode = 0, Parent_ID = null, ScriptBeginEn = string.Empty, ScriptEndEn = string.Empty, ScriptBeginFa = "...", ScriptEndFa = string.Empty, SortOrder = 0, Visible = true }; bCnpExpression.InsertConceptExpression(cnpExpressionRoot); } catch (Exception) { var uiException = new UIValidationExceptions(); uiException.Add(ExceptionResourceKeys.BSecondaryConceptCustomeCategoryParentExpressionRequierd, "مولفه ریشه (...) ساخته نشد", ExceptionSrc); throw uiException; } } #region اجزاي كاربردي var expressionParent1 = bCnpExpression.GetByParentId(cnpExpressionRoot.ID) .FirstOrDefault(x => x.ScriptBeginFa.Contains("اجزاي كاربردي")); if (expressionParent1 == null) { try { expressionParent1 = new ConceptExpression { AddOnParentCreation = false, CanAddToFinal = false, CanEditInFinal = false, CustomeCategoryCode = int.Parse(secondaryConcept.CustomCategoryCode), Parent_ID = cnpExpressionRoot.ID, ScriptBeginEn = string.Empty, ScriptEndEn = string.Empty, ScriptBeginFa = "اجزاي كاربردي", ScriptEndFa = string.Empty, SortOrder = 0, Visible = true }; bCnpExpression.InsertConceptExpression(expressionParent1); } catch (Exception) { var uiException = new UIValidationExceptions(); uiException.Add(ExceptionResourceKeys.BSecondaryConceptCustomeCategoryParentExpressionRequierd, "مولفه اجزاي كاربردي ساخته نشد", ExceptionSrc); throw uiException; } } #endregion #region مفهوم var expressionParent2 = bCnpExpression.GetByParentId(expressionParent1.ID) .FirstOrDefault(x => x.ScriptBeginFa.Contains("مفهوم")); if (expressionParent2 == null) { try { expressionParent2 = new ConceptExpression { AddOnParentCreation = false, CanAddToFinal = false, CanEditInFinal = false, CustomeCategoryCode = int.Parse(secondaryConcept.CustomCategoryCode), Parent_ID = expressionParent1.ID, ScriptBeginEn = string.Empty, ScriptEndEn = string.Empty, ScriptBeginFa = "مفهوم", ScriptEndFa = string.Empty, SortOrder = 1, Visible = true }; bCnpExpression.InsertConceptExpression(expressionParent2); } catch (Exception) { var uiException = new UIValidationExceptions(); uiException.Add(ExceptionResourceKeys.BSecondaryConceptCustomeCategoryParentExpressionRequierd, "مولفه مفهوم ساخته نشد", ExceptionSrc); throw uiException; } } #endregion #region بازه ای مقداری عملگر string periodicTypeTitle; switch (secondaryConcept.Type) { case ScndCnpPairableType.PSC: periodicTypeTitle = "بازه ای"; break; case ScndCnpPairableType.NPSC: periodicTypeTitle = "مقداری"; break; default: periodicTypeTitle = "عملگر"; break; } var expressionParent3 = bCnpExpression.GetByParentId(expressionParent2.ID) .FirstOrDefault(x => x.ScriptBeginFa.Contains(periodicTypeTitle)); if (expressionParent3 == null) { try { expressionParent3 = new ConceptExpression { AddOnParentCreation = false, CanAddToFinal = false, CanEditInFinal = false, CustomeCategoryCode = int.Parse(secondaryConcept.CustomCategoryCode), Parent_ID = expressionParent2.ID, ScriptBeginEn = string.Empty, ScriptEndEn = string.Empty, ScriptBeginFa = periodicTypeTitle, ScriptEndFa = string.Empty, SortOrder = 1, Visible = true }; bCnpExpression.InsertConceptExpression(expressionParent3); } catch (Exception) { var uiException = new UIValidationExceptions(); uiException.Add(ExceptionResourceKeys.BSecondaryConceptCustomeCategoryParentExpressionRequierd, "مولفه" + periodicTypeTitle + "موجود نیست", ExceptionSrc); throw uiException; } } #endregion #region کاری مرخصی ماموریت غیبت اضافه کار var expressionParent4 = bCnpExpression.GetByParentId(expressionParent3.ID) .FirstOrDefault(x => x.CustomeCategoryCode == int.Parse(secondaryConcept.CustomCategoryCode)); if (expressionParent4 == null) { var customCategoryTitle = string.Empty; try { switch (int.Parse(secondaryConcept.CustomCategoryCode)) { case 1: { customCategoryTitle = "کاری"; break; } case 2: { customCategoryTitle = "مرخصی"; break; } case 3: { customCategoryTitle = "ماموریت"; break; } case 4: { customCategoryTitle = "غیبت"; break; } case 5: { customCategoryTitle = "اضافه کار"; break; } default: { customCategoryTitle = "کاری"; break; } } expressionParent4 = new ConceptExpression { AddOnParentCreation = false, CanAddToFinal = false, CanEditInFinal = false, CustomeCategoryCode = int.Parse(secondaryConcept.CustomCategoryCode), Parent_ID = expressionParent3.ID, ScriptBeginEn = string.Empty, ScriptEndEn = string.Empty, ScriptBeginFa = customCategoryTitle, ScriptEndFa = string.Empty, SortOrder = 1, Visible = true }; bCnpExpression.InsertConceptExpression(expressionParent4); } catch (Exception) { var uiException = new UIValidationExceptions(); uiException.Add(ExceptionResourceKeys.BSecondaryConceptCustomeCategoryParentExpressionRequierd, "مولفه" + customCategoryTitle + "موجود نیست", ExceptionSrc); throw uiException; } } #endregion var conceptExpressionObj = new ConceptExpression { AddOnParentCreation = false, CanAddToFinal = true, CanEditInFinal = false, CustomeCategoryCode = int.Parse(secondaryConcept.CustomCategoryCode), Parent_ID = expressionParent4.ID, ScriptBeginEn = string.Format("this.DoConcept({0}).Value", secondaryConcept.IdentifierCode), ScriptEndEn = string.Empty, ScriptBeginFa = secondaryConcept.Name, ScriptEndFa = string.Empty, SortOrder = (int)secondaryConcept.ID, Visible = true }; bCnpExpression.InsertConceptExpression(conceptExpressionObj); } catch (Exception ex) { var uiException = new UIValidationExceptions(); uiException.Add(ExceptionResourceKeys.BSecondaryConceptCustomeCategoryParentExpressionRequierd, ex.Message, ExceptionSrc); throw uiException; } }
public int SaveChanges(IList <CalendarCellInfo> cellInfoList, decimal workGroupId, int year) { try { WorkGroupRepository workGroupRep = new WorkGroupRepository(false); DateTime minDate = new DateTime(); DateTime maxDate = new DateTime(); if (sysLangruage == SysLanguageResource.Parsi) { minDate = Utility.ToMildiDate(String.Format("{0}/01/01", year)); maxDate = Utility.ToMildiDate(String.Format("{0}/01/01", year + 1)); } else if (sysLangruage == SysLanguageResource.English) { minDate = new DateTime(year, 1, 1); maxDate = new DateTime(year + 1, 1, 1); } int count = cellInfoList.GroupBy(x => x.Key) .Where(g => g.Count() > 1).Count(); if (count > 0) { UIValidationExceptions exception = new UIValidationExceptions(); exception.Add(ExceptionResourceKeys.WorkGroupCalendarDublicateDate, "برای روز دوبار شیفت انتساب داده شده است", ExceptionSrc); throw exception; } workGroupRep.DeleteWorkGroupDetail(workGroupId, minDate, maxDate.AddDays(-1)); IList <WorkGroupDetail> detailList = new List <WorkGroupDetail>(); foreach (CalendarCellInfo cellInfo in cellInfoList) { if (cellInfo.ShiftID != 0) { WorkGroupDetail detail = new WorkGroupDetail(); DateTime date = new DateTime(); if (sysLangruage == SysLanguageResource.Parsi) { date = Utility.ToMildiDate(String.Format("{0}/{1}/{2}", year, cellInfo.Month, cellInfo.Day)); } else if (sysLangruage == SysLanguageResource.English) { date = new DateTime(year, cellInfo.Month, cellInfo.Day); } detail.WorkGroup = new WorkGroup() { ID = workGroupId }; detail.Date = date; detail.Shift = new Shift() { ID = cellInfo.ShiftID }; base.SaveChanges(detail, UIActionType.ADD); } } this.UpdateCFPByWorkGroupId(workGroupId, minDate); return(cellInfoList.Count); } catch (Exception ex) { LogException(ex, "BWorkGroupCalendar", "SaveChanges"); throw ex; } }
public string[] UpdateRule_RulesPage( string ID, string IdentifierCode, string Name, string CustomCategoryCode, string TypeId, string UserDefined, string Script, string CSharpCode, string JsonObject, string PageState) { this.InitializeCulture(); UIValidationExceptions uiValidationExceptions = new UIValidationExceptions(); string[] retMessage = new string[4]; decimal iID = 0; RuleTemplate RuleRecived = new RuleTemplate(); RuleRecived.ID = Convert.ToDecimal(StringBuilder.CreateString(ID)); PageState = StringBuilder.CreateString(PageState); if (PageState != "Delete") { RuleRecived.IdentifierCode = Convert.ToDecimal(StringBuilder.CreateString(IdentifierCode)); RuleRecived.Name = StringBuilder.CreateString(Name); RuleRecived.CustomCategoryCode = StringBuilder.CreateString(CustomCategoryCode); RuleRecived.TypeId = Convert.ToDecimal(StringBuilder.CreateString(TypeId)); RuleRecived.UserDefined = bool.Parse(StringBuilder.CreateString(UserDefined)); RuleRecived.Script = StringBuilder.CreateString(Script); RuleRecived.CSharpCode = StringBuilder.CreateString(CSharpCode); if (!string.IsNullOrEmpty(JsonObject)) { RuleRecived.JsonObject = JsonObject.Substring(1, JsonObject.Length - 2); } } #region Effect on DB try { #region Set UIActionType Enum UIActionType uiActionType = UIActionType.ADD; switch (PageState.ToUpper()) { #region Add case "ADD": uiActionType = UIActionType.ADD; iID = RuleBusiness.InsertRule(RuleRecived); break; #endregion #region Edit case "EDIT": uiActionType = UIActionType.EDIT; if (RuleRecived.ID == 0) { retMessage = this.ExceptionHandler.HandleException(this.Page, ExceptionTypes.Exception, new Exception(GetLocalResourceObject("NoRuleSelectedforEdit").ToString()), retMessage); return(retMessage); } var concept = RuleBusiness.GetByID(RuleRecived.ID); RuleBusiness.Copy(RuleRecived, ref concept); iID = RuleBusiness.UpdateRule(concept); break; #endregion #region Delete case "DELETE": uiActionType = UIActionType.DELETE; if (RuleRecived.ID == 0) { retMessage = this.ExceptionHandler.HandleException(this.Page, ExceptionTypes.Exception, new Exception(GetLocalResourceObject("NoRuleSelectedforDelete").ToString()), retMessage); return(retMessage); } iID = RuleBusiness.DeleteRule(RuleRecived); break; #endregion default: break; } #endregion retMessage[0] = GetLocalResourceObject("RetSuccessType").ToString(); string SuccessMessageBody = string.Empty; switch (uiActionType) { case UIActionType.ADD: SuccessMessageBody = GetLocalResourceObject("AddComplete").ToString(); break; case UIActionType.EDIT: SuccessMessageBody = GetLocalResourceObject("EditComplete").ToString(); break; case UIActionType.DELETE: SuccessMessageBody = GetLocalResourceObject("DeleteComplete").ToString(); break; default: break; } retMessage[1] = SuccessMessageBody; retMessage[2] = "success"; retMessage[3] = iID.ToString(); return(retMessage); } catch (UIValidationExceptions ex) { retMessage = this.ExceptionHandler.HandleException(this.Page, ExceptionTypes.UIValidationExceptions, ex, retMessage); return(retMessage); } catch (UIBaseException ex) { retMessage = this.ExceptionHandler.HandleException(this.Page, ExceptionTypes.UIBaseException, ex, retMessage); return(retMessage); } catch (Exception ex) { retMessage = this.ExceptionHandler.HandleException(this.Page, ExceptionTypes.Exception, ex, retMessage); return(retMessage); } #endregion }
/// <summary> /// تکرار دوره /// </summary> /// <param name="year"></param> /// <param name="startMonth"></param> /// <param name="startDay"></param> /// <param name="endMonth"></param> /// <param name="endDay"></param> /// <param name="holidayTypes"></param> /// <param name="cellInfoList"></param> public IList <CalendarCellInfo> RepetitionPeriod(int year, int startMonth, int startDay, int endMonth, int endDay, IList <decimal> holidayTypes, IList <CalendarCellInfo> cellInfoList) { try { DateTime startDate, endDate, endOfYear; if (sysLangruage == SysLanguageResource.Parsi) { startDate = Utility.ToMildiDate(String.Format("{0}/{1}/{2}", year, startMonth, startDay)); endDate = Utility.ToMildiDate(String.Format("{0}/{1}/{2}", year, endMonth, endDay)); endOfYear = Utility.ToMildiDate(String.Format("{0}/{1}/{2}", year, 12, Utility.GetEndOfPersianMonth(year, 12))); } else { startDate = new DateTime(year, startMonth, startDay); endDate = new DateTime(year, endMonth, endDay); endOfYear = new DateTime(year, 12, DateTime.DaysInMonth(year, 12)); } if (startDate > endDate) { UIValidationExceptions exception = new UIValidationExceptions(); exception.Add(ExceptionResourceKeys.WorkGroupCalendarPriodDateIsNotValid, "تاریخ ابتدا از انتها بزرگتر است", ExceptionSrc); throw exception; } IList <CalendarCellInfo> list = new List <CalendarCellInfo>(); IList <CalendarCellInfo> cells = new List <CalendarCellInfo>(); IList <CalendarCellInfo> result = new List <CalendarCellInfo>(); IList <Shift> shiftList = new BShift().GetAll(); //looking for item in parameter list by date for (DateTime date = startDate; date <= endDate; date = date.AddDays(1)) { int day = 0, month = 0; if (sysLangruage == SysLanguageResource.Parsi) { day = new PersianDateTime(date).Day; month = new PersianDateTime(date).Month; } else { day = date.Day; month = date.Month; } CalendarCellInfo info = cellInfoList.Where(x => x.Day == day && x.Month == month).FirstOrDefault(); if (info != null) { list.Add(info); } else { list.Add(null); } } if (list.Count == 0 || list.Where(x => x != null).Count() == 0) { UIValidationExceptions exception = new UIValidationExceptions(); exception.Add(ExceptionResourceKeys.WorkGroupCalendarPriodIsEmpty, "در بازه زمانی مشخص شده شیفتی انتساب دهده نشده است", ExceptionSrc); throw exception; } for (DateTime index = startDate; index <= endOfYear; index = index.AddDays(list.Count)) { for (int i = 0; i < list.Count && index.AddDays(i) <= endOfYear; i++) { if (list[i] != null) { CalendarCellInfo info = new CalendarCellInfo(); info.ShiftID = list[i].ShiftID; Shift shift = shiftList.Where(x => x.ID == list[i].ShiftID).FirstOrDefault(); info.Color = shift != null ? shift.Color : ""; info.Title = list[i].Title; if (sysLangruage == SysLanguageResource.Parsi) { info.Day = new PersianDateTime(index.AddDays(i)).Day; info.Month = new PersianDateTime(index.AddDays(i)).Month; } else { info.Day = index.AddDays(i).Day; info.Month = index.AddDays(i).Month; } cells.Add(info); } } } //apply holidays List <CalendarCellInfo> holidays = new List <CalendarCellInfo>(); if (holidayTypes != null) { foreach (decimal id in holidayTypes) { holidays.AddRange(new BCalendarType().GetCalendarList(year, id)); } } foreach (CalendarCellInfo cell in cells) { if (holidays.Where(x => x.Day == cell.Day && x.Month == cell.Month).Count() == 0) { result.Add(cell); } } return(result); } catch (Exception ex) { LogException(ex, "BWorkGroupCalendar", "RepetitionPeriod"); throw ex; } }
protected void CallBackSaveRules_Rules_OnCallBack(object sender, CallBackEventArgs e) { //UpdateRule_RulesPage( // e.Parameters[0], // e.Parameters[1], // e.Parameters[2], // e.Parameters[3], // e.Parameters[4], // e.Parameters[5], // e.Parameters[6], // e.Parameters[7], // e.Parameters[8], // e.Parameters[9] // ); string ID = e.Parameters[0]; string IdentifierCode = e.Parameters[1]; string Name = e.Parameters[2]; string CustomCategoryCode = e.Parameters[3]; string TypeId = e.Parameters[4]; string UserDefined = e.Parameters[5]; string Script = e.Parameters[6]; string CSharpCode = e.Parameters[7]; string JsonObject = e.Parameters[8]; string PageState = e.Parameters[9]; this.InitializeCulture(); UIValidationExceptions uiValidationExceptions = new UIValidationExceptions(); string[] retMessage = new string[4]; decimal iID = 0; RuleTemplate RuleRecived = new RuleTemplate(); RuleRecived.ID = Convert.ToDecimal(StringBuilder.CreateString(ID)); PageState = StringBuilder.CreateString(PageState); if (PageState != "Delete") { RuleRecived.IdentifierCode = Convert.ToDecimal(StringBuilder.CreateString(IdentifierCode)); RuleRecived.Name = StringBuilder.CreateString(Name); RuleRecived.CustomCategoryCode = StringBuilder.CreateString(CustomCategoryCode); RuleRecived.TypeId = Convert.ToDecimal(StringBuilder.CreateString(TypeId)); RuleRecived.UserDefined = bool.Parse(StringBuilder.CreateString(UserDefined)); RuleRecived.Script = StringBuilder.CreateString(Script); RuleRecived.CSharpCode = StringBuilder.CreateString(CSharpCode); RuleRecived.JsonObject = JsonObject; } #region Effect on DB try { #region Set UIActionType Enum UIActionType uiActionType = UIActionType.ADD; switch (PageState.ToUpper()) { #region Add case "ADD": uiActionType = UIActionType.ADD; iID = RuleBusiness.InsertRule(RuleRecived); break; #endregion #region Edit case "EDIT": uiActionType = UIActionType.EDIT; if (RuleRecived.ID == 0) { retMessage = this.ExceptionHandler.HandleException(this.Page, ExceptionTypes.Exception, new Exception(GetLocalResourceObject("NoRuleSelectedforEdit").ToString()), retMessage); hfCallBackDataSaveRules_Rules.Value = Newtonsoft.Json.JsonConvert.SerializeObject(retMessage); this.hfCallBackDataSaveRules_Rules.RenderControl(e.Output); } var concept = RuleBusiness.GetByID(RuleRecived.ID); RuleBusiness.Copy(RuleRecived, ref concept); iID = RuleBusiness.UpdateRule(concept); break; #endregion #region Delete case "DELETE": uiActionType = UIActionType.DELETE; if (RuleRecived.ID == 0) { retMessage = this.ExceptionHandler.HandleException(this.Page, ExceptionTypes.Exception, new Exception(GetLocalResourceObject("NoRuleSelectedforDelete").ToString()), retMessage); hfCallBackDataSaveRules_Rules.Value = Newtonsoft.Json.JsonConvert.SerializeObject(retMessage); this.hfCallBackDataSaveRules_Rules.RenderControl(e.Output); } iID = RuleBusiness.DeleteRule(RuleRecived); break; #endregion default: break; } #endregion retMessage[0] = GetLocalResourceObject("RetSuccessType").ToString(); string SuccessMessageBody = string.Empty; switch (uiActionType) { case UIActionType.ADD: SuccessMessageBody = GetLocalResourceObject("AddComplete").ToString(); break; case UIActionType.EDIT: SuccessMessageBody = GetLocalResourceObject("EditComplete").ToString(); break; case UIActionType.DELETE: SuccessMessageBody = GetLocalResourceObject("DeleteComplete").ToString(); break; default: break; } retMessage[1] = SuccessMessageBody; retMessage[2] = "success"; retMessage[3] = iID.ToString(CultureInfo.InvariantCulture); hfCallBackDataSaveRules_Rules.Value = Newtonsoft.Json.JsonConvert.SerializeObject(retMessage); this.hfCallBackDataSaveRules_Rules.RenderControl(e.Output); } catch (UIValidationExceptions ex) { retMessage = this.ExceptionHandler.HandleException(this.Page, ExceptionTypes.UIValidationExceptions, ex, retMessage); hfCallBackDataSaveRules_Rules.Value = Newtonsoft.Json.JsonConvert.SerializeObject(retMessage); this.hfCallBackDataSaveRules_Rules.RenderControl(e.Output); } catch (UIBaseException ex) { retMessage = this.ExceptionHandler.HandleException(this.Page, ExceptionTypes.UIBaseException, ex, retMessage); hfCallBackDataSaveRules_Rules.Value = Newtonsoft.Json.JsonConvert.SerializeObject(retMessage); this.hfCallBackDataSaveRules_Rules.RenderControl(e.Output); } catch (Exception ex) { retMessage = this.ExceptionHandler.HandleException(this.Page, ExceptionTypes.Exception, ex, retMessage); hfCallBackDataSaveRules_Rules.Value = Newtonsoft.Json.JsonConvert.SerializeObject(retMessage); this.hfCallBackDataSaveRules_Rules.RenderControl(e.Output); } #endregion }
//END OF DNN NOte /// <summary> /// یک سال را دریافت میکند و 12 ماه را همراه با شروع و پایان آن برمیگرداند /// </summary> /// <param name="year">سال</param> /// <returns>لیست پروکسی بازه های زمانی در یک سال</returns> public IList <DateRangeOrderProxy> GetDateRangeOrder(int year) { using (NHibernateSessionManager.Instance.BeginTransactionOn()) { try { if (IsValidPeson()) { IList <DateRangeOrderProxy> list = new List <DateRangeOrderProxy>(); for (int i = 1; i <= 12; i++) { DateRangeOrderProxy proxy = new DateRangeOrderProxy(); DateTime date = new DateTime(year, i, DateTime.DaysInMonth(year, i)); if (sysLanguageResource == LanguagesName.Parsi) { int endOfMonth = new PersianCalendar().GetDaysInMonth(year, i); date = Utility.ToMildiDate(String.Format("{0}/{1}/{2}", year, i, endOfMonth)); } PersonalMonthlyReport report = personRepository.GetPersonalMonthlyReport(this.workingPersonId, date, i); if (report.DataRangeIsValid) { proxy.Order = i; proxy.Selected = false; if (sysLanguageResource == LanguagesName.Parsi) { proxy.FromDate = Utility.ToPersianDate(report.FromDate); proxy.ToDate = Utility.ToPersianDate(report.ToDate); } else { proxy.FromDate = report.FromDate; proxy.ToDate = report.ToDate; } if (report.MinDate.Date <= DateTime.Now && DateTime.Now.Date <= report.MaxDate) { proxy.Selected = true; } list.Add(proxy); } } if (list.Count == 0) { UIValidationExceptions exeptions = new UIValidationExceptions(); exeptions.Add(new ValidationException(ExceptionResourceKeys.PersonnelCalculationDateRangeIsNotValuedForSelectedYear, "در سال انتخاب شده محدوده محاسبات به پرسنل تخصیص داده نشده است", ExceptionSrc)); throw exeptions; } list = list.OrderBy(x => x.Order).ToList(); if (list.Where(x => x.Selected).Count() == 0) { if (Utility.ToPersianDateTime(DateTime.Now).Year == year + 1)//سال قبل { list[list.Count - 1].Selected = true; } else { list[0].Selected = true; } } NHibernateSessionManager.Instance.CommitTransactionOn(); return(list); } else { throw new IllegalServiceAccess(String.Format("این سرویس بعللت اعتبارسنجی قابل دسترسی نمیباشد. شناسه کاربری {0} میباشد", this.Username), ExceptionSrc); } } catch (Exception ex) { NHibernateSessionManager.Instance.RollbackTransactionOn(); BaseBusiness <Entity> .LogException(ex, "BPersonMonthlyWorkedTime", "GetDateRangeOrder"); throw ex; } } }
public ArchiveCalcValuesProxy SetArchiveValues(int year, int month, decimal personId, ArchiveCalcValuesProxy proxy) { IList <ArchiveCalcValuesProxy> resultList = new List <ArchiveCalcValuesProxy>(); int rangeOrder = month; try { UIValidate(personId); proxy = ValidateKaheshiKosuratBankSepah(proxy, year, month, personId); } catch (Exception) { } IList <ArchiveConceptValue> archiveValues = archiveRep.LoadArchiveValueList(new List <decimal>() { personId }, year, rangeOrder); IList <ArchiveFieldMap> fildsMapList = mapRep.GetAll(); if (archiveValues.Any(x => x.PersonId == personId)) { ArchiveFieldMap map = null; MemberInfo[] members = proxy.GetType().GetMembers(); #region Data Type Validatin UIValidationExceptions exceptions = new UIValidationExceptions(); foreach (MemberInfo member in members.Where(a => a.MemberType == MemberTypes.Property && !a.Name.ToLower().Contains("person"))) { PropertyInfo prop = typeof(ArchiveCalcValuesProxy).GetProperty(member.Name); map = fildsMapList.Where(x => x.PId.ToLower().Equals(member.Name.ToLower())).FirstOrDefault(); if (map != null && map.Visible) { ArchiveConceptValue cnpValue = archiveValues.Where(x => x.PersonId == personId && x.Concept.KeyColumnName.ToLower().Equals(map.ConceptKeyColumn.ToLower())).FirstOrDefault(); if (cnpValue != null) { bool isValid = false; string pValue = Utility.ToString(prop.GetValue(proxy, null)).Trim(); if (Utility.IsEmpty(pValue)) { pValue = "0"; } int value = 0; string cnpName = ""; if (BLanguage.CurrentLocalLanguage == LanguagesName.Parsi) { cnpName = map.FnTitle; } else { cnpName = map.EnTitle; } switch (cnpValue.Concept.DataType) { case ConceptDataType.Int: if (!Utility.IsIntiger(pValue)) { ValidationException exception = new ValidationException(ExceptionResourceKeys.ArchiveDataTypeIsNotValid, cnpName, ExceptionSrc); exception.Data.Add("Info", cnpName); exceptions.Add(exception); } break; case ConceptDataType.Hour: if (!Utility.IsTime(pValue) && !Utility.IsIntiger(pValue)) { ValidationException exception = new ValidationException(ExceptionResourceKeys.ArchiveDataTypeIsNotValid, cnpName, ExceptionSrc); exception.Data.Add("Info", cnpName); exceptions.Add(exception); } break; } if (isValid) { cnpValue.ChangedValue = value; archiveRep.SaveOrUpdate(cnpValue); } } } } if (exceptions.Count > 0) { throw exceptions; } #endregion #region Set Value foreach (MemberInfo member in members.Where(a => a.MemberType == MemberTypes.Property && !a.Name.ToLower().Contains("person"))) { PropertyInfo prop = typeof(ArchiveCalcValuesProxy).GetProperty(member.Name); map = fildsMapList.Where(x => x.PId.ToLower().Equals(member.Name.ToLower())).FirstOrDefault(); if (map != null && map.Visible) { ArchiveConceptValue cnpValue = archiveValues.Where(x => x.PersonId == personId && x.Concept.KeyColumnName.ToLower().Equals(map.ConceptKeyColumn.ToLower())).FirstOrDefault(); if (cnpValue != null) { bool isValid = false; string pValue = Utility.ToString(prop.GetValue(proxy, null)).Trim(); if (Utility.IsEmpty(pValue)) { pValue = "0"; } int value = 0; switch (cnpValue.Concept.DataType) { case ConceptDataType.Int: if (Utility.IsIntiger(pValue)) { value = Utility.ToInteger(pValue); isValid = true; } break; case ConceptDataType.Hour: if (Utility.IsIntiger(pValue)) { pValue = pValue += ":00"; } if (Utility.IsTime(pValue)) { value = Utility.RealTimeToIntTime(pValue); isValid = true; } break; } if (isValid) { cnpValue.ModifiedDate = DateTime.Now; cnpValue.ModifiedPersonId = BUser.CurrentUser.Person.ID; cnpValue.ChangedValue = value; archiveRep.SaveOrUpdate(cnpValue); BArchiveCalculator.LogUserAction(cnpValue, string.Format("Change Archive for person {0} , Date: {2}/{1}", cnpValue.PersonId.ToString(), month, year)); } } } } #endregion } return(proxy); }
public string[] UpdateExpression_ExpressionsPage( string ID, string Parent_ID, string ScriptBeginFa, string ScriptEndFa, string ScriptBeginEn, string ScriptEndEn, string AddOnParentCreation, string CanAddToFinal, string CanEditInFinal, string Visible, string SortOrder, string PageState ) { this.InitializeCulture(); UIValidationExceptions uiValidationExceptions = new UIValidationExceptions(); string[] retMessage = new string[4]; decimal iID = 0; ConceptExpression ConceptExpressionRecived = new ConceptExpression(); ConceptExpressionRecived.ID = Convert.ToDecimal(StringBuilder.CreateString(ID)); PageState = StringBuilder.CreateString(PageState); if (PageState != "Delete") { uiValidationExceptions = BExpression.Validation(ScriptBeginFa); if (uiValidationExceptions.ExceptionList.Count > 0) { retMessage = this.ExceptionHandler.HandleException( this.Page, ExceptionTypes.UIValidationExceptions, uiValidationExceptions, retMessage); return(retMessage); } if (!string.IsNullOrEmpty(StringBuilder.CreateString(Parent_ID))) { ConceptExpressionRecived.Parent_ID = Convert.ToDecimal(StringBuilder.CreateString(Parent_ID)); } /* * ID, Parent_ID, ScriptBeginFa, ScriptEndFa, ScriptBeginEn, * ScriptEndEn, AddOnParentCreation, CanAddToFinal, CanEditInFinal, * Visible, SortOrder, PageState */ ConceptExpressionRecived.ScriptBeginFa = StringBuilder.CreateString(ScriptBeginFa); ConceptExpressionRecived.ScriptEndFa = StringBuilder.CreateString(ScriptEndFa); ConceptExpressionRecived.ScriptBeginEn = StringBuilder.CreateString(ScriptBeginEn); ConceptExpressionRecived.ScriptEndEn = StringBuilder.CreateString(ScriptEndEn); ConceptExpressionRecived.SortOrder = int.Parse(StringBuilder.CreateString(SortOrder)); ConceptExpressionRecived.AddOnParentCreation = bool.Parse(StringBuilder.CreateString(AddOnParentCreation)); ConceptExpressionRecived.CanAddToFinal = bool.Parse(StringBuilder.CreateString(CanAddToFinal)); ConceptExpressionRecived.CanEditInFinal = bool.Parse(StringBuilder.CreateString(CanEditInFinal)); ConceptExpressionRecived.Visible = bool.Parse(StringBuilder.CreateString(Visible)); } #region Effect on DB try { #region Set UIActionType Enum UIActionType uiActionType = UIActionType.ADD; switch (PageState.ToUpper()) { #region Add case "ADD": uiActionType = UIActionType.ADD; iID = BExpression.InsertConceptExpression(ConceptExpressionRecived); break; #endregion #region Edit case "EDIT": uiActionType = UIActionType.EDIT; if (ConceptExpressionRecived.ID == 0) { retMessage = this.ExceptionHandler.HandleException(this.Page, ExceptionTypes.Exception, new Exception(GetLocalResourceObject("NoConceptExpressionSelectedforEdit").ToString()), retMessage); return(retMessage); } var conceptFromDb = BExpression.GetByID(ConceptExpressionRecived.ID); BExpression.Copy(ConceptExpressionRecived, ref conceptFromDb); iID = BExpression.UpdateConceptExpression(conceptFromDb); break; #endregion #region Delete case "DELETE": uiActionType = UIActionType.DELETE; if (ConceptExpressionRecived.ID == 0) { retMessage = this.ExceptionHandler.HandleException(this.Page, ExceptionTypes.Exception, new Exception(GetLocalResourceObject("NoConceptExpressionSelectedforDelete").ToString()), retMessage); return(retMessage); } iID = BExpression.DeleteConceptExpression(ConceptExpressionRecived); break; #endregion default: break; } #endregion retMessage[0] = GetLocalResourceObject("RetSuccessType").ToString(); string SuccessMessageBody = string.Empty; switch (uiActionType) { case UIActionType.ADD: SuccessMessageBody = GetLocalResourceObject("AddComplete").ToString(); break; case UIActionType.EDIT: SuccessMessageBody = GetLocalResourceObject("EditComplete").ToString(); break; case UIActionType.DELETE: SuccessMessageBody = GetLocalResourceObject("DeleteComplete").ToString(); break; default: break; } retMessage[1] = SuccessMessageBody; retMessage[2] = "success"; retMessage[3] = iID.ToString(); return(retMessage); } catch (UIValidationExceptions ex) { retMessage = this.ExceptionHandler.HandleException(this.Page, ExceptionTypes.UIValidationExceptions, ex, retMessage); return(retMessage); } catch (UIBaseException ex) { retMessage = this.ExceptionHandler.HandleException(this.Page, ExceptionTypes.UIBaseException, ex, retMessage); return(retMessage); } catch (Exception ex) { retMessage = this.ExceptionHandler.HandleException(this.Page, ExceptionTypes.Exception, ex, retMessage); return(retMessage); } #endregion }
/// <summary> /// انجام محاسبات پرسنل جستجو شده در بازه زمانی مشخص /// </summary> /// <param name="searchKey">عبارت جستجو</param> /// <param name="fromDate">تاریخ شروع</param> /// <param name="toDate">تاریخ پایان</param> /// <param name="forceCalculate">محاسبات اجباری</param> /// <returns>انجام شد یا نشد</returns> public bool Calculate(string searchKey, 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(); IList <Person> personList = searchTool.QuickSearch(searchKey, PersonCategory.Public) .Where(x => x.Active).ToList(); IList <decimal> PersonIdCalculateList = new List <decimal>(); 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 (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 -> searchKey: {0} And Count: {1} -->Calculate(searchKey, toDate)", searchKey, PersonIdCalculateList.Count)); return(true); } catch (Exception ex) { BaseBusiness <Entity> .LogException(ex, "BEngineCalculator", "Calculate(searchKey, toDate)"); throw ex; } }
public decimal UpdateDateRange(CalculationRangeGroup calcDateRangeGroup, IList <CalculationDateRange> dateRanges, IList <decimal> conceptTmpIds) { try { #region validation UIValidationExceptions exception = new UIValidationExceptions(); if (dateRanges == null || dateRanges.Count != 12) { exception.Add(new ValidationException(ExceptionResourceKeys.DateRangesCountNotEqualToTwelve, "تعداد ماههای ارسالی برای ذخیره دوره محاسبات باید برابر 12 باشد", ExceptionSrc)); } if (Utility.IsEmpty(conceptTmpIds)) { exception.Add(new ValidationException(ExceptionResourceKeys.DateRangesMustHaveConcept, "بمنظور بروزرسانی حتما باید یک یا چند مفهوم انتخاب شود", ExceptionSrc)); } if (exception.Count > 0) { throw exception; } #endregion ApplicationLanguageSettings sysLanguage = new BLanguage().CurrentApplicationSetting; if (sysLanguage != null) { calcDateRangeGroup.Culture = sysLanguage.Language.Name; } //بارگذاری دوره مجاسبات ثبت شده در دیتابیس var result = from o in conceptTmpIds select new SecondaryConcept() { ID = o }; IList <SecondaryConcept> conceptsList = result.ToList <SecondaryConcept>(); IList <CalculationDateRange> dateRangeListInDatabase = dateRangeRepository.GetCalculationDateRanges(calcDateRangeGroup, conceptsList); //استخراج مفاهیمی که در حال حاضر در دیتابیس دوره محاسبات ندارند IList <SecondaryConcept> extraCnps = conceptsList.Where(x => dateRangeListInDatabase.Select(y => y.Concept.ID).Contains(x.ID) == false).ToList(); IList <CalculationDateRange> newOrderList = new List <CalculationDateRange>(); List <CalculationDateRange> resultDateRangeList = new List <CalculationDateRange>(); foreach (CalculationDateRange dateRange in dateRanges.OrderBy(x => x.Order).ToList()) { //بروزرساتی دورهای محاسباتی IList <CalculationDateRange> sameOrderList = dateRangeListInDatabase.Where(x => x.Order == dateRange.Order).ToList(); for (int i = 0; i < sameOrderList.Count; i++) { sameOrderList[i].FromDay = dateRange.FromDay; sameOrderList[i].FromMonth = dateRange.FromMonth; sameOrderList[i].ToDay = dateRange.ToDay; sameOrderList[i].ToMonth = dateRange.ToMonth; SetDateRangeIndex(sameOrderList[i]); } //درج دوره محاسبات برای مفاهیم جدید foreach (SecondaryConcept cnp in extraCnps) { CalculationDateRange dr = new CalculationDateRange(); dr.Concept = cnp; dr.FromDay = dateRange.FromDay; dr.FromMonth = dateRange.FromMonth; dr.ToDay = dateRange.ToDay; dr.ToMonth = dateRange.ToMonth; dr.Order = dateRange.Order; dr.RangeGroup = calcDateRangeGroup; SetDateRangeIndex(dr); newOrderList.Add(dr); } } resultDateRangeList.AddRange(dateRangeListInDatabase); resultDateRangeList.AddRange(newOrderList); calcDateRangeGroup.DateRangeList = resultDateRangeList; base.SaveChanges(calcDateRangeGroup, UIActionType.EDIT); return(calcDateRangeGroup.ID); } catch (Exception ex) { LogException(ex, "BDateRange", "UpdateDateRange"); throw ex; } }
/// <summary> /// انجام محاسبات یک پرسنل در بازه زمانی مشخص /// </summary> /// <param name="personId">کلید اصلی پرسنل</param> /// <param name="fromDate">تاریخ شروع</param> /// <param name="toDate">تاریخ پایان</param> /// <param name="forceCalculate">محاسبات اجباری</param> /// <returns>انجام شد یا نشد</returns> public bool Calculate(decimal personId, string fromDate, string toDate, bool forceCalculate) { try { DateTime from, to; object obj = new object(); UIValidationExceptions exception = new UIValidationExceptions(); 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 (personId == 0) { exception.Add(new ValidationException(ExceptionResourceKeys.CalculationPersonNotSelected, "پرسنلی انتخاب نشده است.", ExceptionSrc)); } if (exception.Count > 0) { throw exception; } decimal[] ids = new decimal[1]; ids[0] = personId; PersonID = ids[0]; FromDate = from; ToDate = to; if (forceCalculate) { BusinessEntity entity = new BusinessEntity(); entity.UpdateCFP(new List <Person>() { new Person() { ID = personId } }, from, true); } BTemp bTemp = new BTemp(); string operationGUID = bTemp.InsertTempList(ids.ToList()); CallUIValidator(this); gtsEngineWS.GTS_ExecutePersonsByToDateGUID(BUser.CurrentUser.UserName, operationGUID, to); bTemp.DeleteTempList(operationGUID); BaseBusiness <Entity> .LogUserAction(String.Format("CalculateAll -> personId: {0} -->Calculate(personId,toDate)", personId)); return(true); } catch (Exception ex) { BaseBusiness <Entity> .LogException(ex, "BEngineCalculator", "Calculate(personId,toDate)"); throw ex; } }
public string[] UpdateConcept_ConceptsPage( string ID, string IdentifierCode, string Name, //string Description, string Color, string KeyColumnName, string CSharpCode, string Script, string UserDefined, string PeriodicType, string Type, string CalcSituationType, string PersistSituationType, string CustomeCategoryCode, string JsonObject, string PageState ) { this.InitializeCulture(); UIValidationExceptions uiValidationExceptions = new UIValidationExceptions(); string[] retMessage = new string[4]; decimal iID = 0; SecondaryConcept ConceptRecived = new SecondaryConcept(); ConceptRecived.ID = Convert.ToDecimal(StringBuilder.CreateString(ID)); PageState = StringBuilder.CreateString(PageState); if (PageState != "Delete") { uiValidationExceptions = BSecondaryConceptUserDefined.SecondaryConceptEnumJsonObjectsValidation( StringBuilder.CreateString(PeriodicType), StringBuilder.CreateString(Type), StringBuilder.CreateString(CalcSituationType), StringBuilder.CreateString(PersistSituationType) ); if (uiValidationExceptions.ExceptionList.Count > 0) { retMessage = this.ExceptionHandler.HandleException( this.Page, ExceptionTypes.UIValidationExceptions, uiValidationExceptions, retMessage); return(retMessage); } ConceptRecived.IdentifierCode = Convert.ToDecimal(StringBuilder.CreateString(IdentifierCode)); ConceptRecived.Name = StringBuilder.CreateString(Name); ConceptRecived.Color = StringBuilder.CreateString(Color); ConceptRecived.KeyColumnName = StringBuilder.CreateString(KeyColumnName); ConceptRecived.CSharpCode = StringBuilder.CreateString(CSharpCode); ConceptRecived.Script = StringBuilder.CreateString(Script); ConceptRecived.UserDefined = bool.Parse(StringBuilder.CreateString(UserDefined)); ConceptRecived.PeriodicType = (ScndCnpPeriodicType)Enum.Parse(typeof(ScndCnpPeriodicType), StringBuilder.CreateString(PeriodicType)); ConceptRecived.Type = (ScndCnpPairableType)Enum.Parse(typeof(ScndCnpPairableType), StringBuilder.CreateString(Type)); ConceptRecived.CalcSituationType = (ScndCnpCalcSituationType)Enum.Parse(typeof(ScndCnpCalcSituationType), StringBuilder.CreateString(CalcSituationType)); ConceptRecived.PersistSituationType = (ScndCnpPersistSituationType)Enum.Parse(typeof(ScndCnpPersistSituationType), StringBuilder.CreateString(PersistSituationType)); ConceptRecived.CustomCategoryCode = ((ScndCnpCustomeCategoryCode)Enum.Parse(typeof(ScndCnpCustomeCategoryCode), StringBuilder.CreateString(CustomeCategoryCode))).ToString("D"); ConceptRecived.JsonObject = StringBuilder.CreateString(JsonObject); } #region Effect on DB try { #region Set UIActionType Enum UIActionType uiActionType = UIActionType.ADD; switch (PageState.ToUpper()) { #region Add case "ADD": uiActionType = UIActionType.ADD; iID = BSecondaryConceptUserDefined.InsertConcept(ConceptRecived); break; #endregion #region Edit case "EDIT": uiActionType = UIActionType.EDIT; if (ConceptRecived.ID == 0) { retMessage = this.ExceptionHandler.HandleException(this.Page, ExceptionTypes.Exception, new Exception(GetLocalResourceObject("NoConceptSelectedforEdit").ToString()), retMessage); return(retMessage); } var concept = BSecondaryConceptUserDefined.GetByID(ConceptRecived.ID); BSecondaryConceptUserDefined.Copy(ConceptRecived, ref concept); iID = BSecondaryConceptUserDefined.UpdateConcept(concept); break; #endregion #region Delete case "DELETE": uiActionType = UIActionType.DELETE; if (ConceptRecived.ID == 0) { retMessage = this.ExceptionHandler.HandleException(this.Page, ExceptionTypes.Exception, new Exception(GetLocalResourceObject("NoConceptSelectedforDelete").ToString()), retMessage); return(retMessage); } iID = BSecondaryConceptUserDefined.DeleteConcept(ConceptRecived); break; #endregion } #endregion retMessage[0] = GetLocalResourceObject("RetSuccessType").ToString(); string SuccessMessageBody = string.Empty; switch (uiActionType) { case UIActionType.ADD: SuccessMessageBody = GetLocalResourceObject("AddComplete").ToString(); break; case UIActionType.EDIT: SuccessMessageBody = GetLocalResourceObject("EditComplete").ToString(); break; case UIActionType.DELETE: SuccessMessageBody = GetLocalResourceObject("DeleteComplete").ToString(); break; } retMessage[1] = SuccessMessageBody; retMessage[2] = "success"; retMessage[3] = iID.ToString(CultureInfo.InvariantCulture); return(retMessage); } catch (UIValidationExceptions ex) { retMessage = this.ExceptionHandler.HandleException(this.Page, ExceptionTypes.UIValidationExceptions, ex, retMessage); return(retMessage); } catch (UIBaseException ex) { retMessage = this.ExceptionHandler.HandleException(this.Page, ExceptionTypes.UIBaseException, ex, retMessage); return(retMessage); } catch (Exception ex) { retMessage = this.ExceptionHandler.HandleException(this.Page, ExceptionTypes.Exception, ex, retMessage); return(retMessage); } #endregion }
/// <summary> /// پیشکارتهای یک جانشین را ثبت میکند /// اگر پارانتر آخر تهی باشد بدین معنی است که جریان حذف شود یعنی تمام پیشکارتهایش خالی شود /// </summary> /// <param name="substituteId"></param> /// <param name="flowId"></param> /// <param name="accessGroupList"></param> /// <returns></returns> public bool UpdateByProxy(decimal substituteId, decimal flowId, IList <AccessGroupProxy> accessGroupList) { try { if (substituteId == 0 || flowId == 0) { UIValidationExceptions exception = new UIValidationExceptions(); exception.Add(new ValidationException(ExceptionResourceKeys.SubstituteUpdateFlowAndSubstituteIdRequeiered, "کد جریان و جانشین نامشخص است", ExceptionSrc)); } bool substituteContainsFlow = false; //تیک جریان کاری در گرید مربوطه BFlow flow = new BFlow(); PrecardAccessGroup precardAccessGroup = flow.GetByID(flowId).AccessGroup; EntityRepository <PrecardGroups> groupRep = new EntityRepository <PrecardGroups>(false); IList <Precard> removeList = new List <Precard>(); Substitute substitute = this.GetByID(substituteId); substitute.PrecardAccessIsSet = true; substitute.TheFromDate = Utility.ToPersianDate(substitute.FromDate); substitute.TheToDate = Utility.ToPersianDate(substitute.ToDate); //ابتدا همگی حذف و سپس ایجاد میگردد substitute.PrecardList = new List <Precard>(); if (accessGroupList != null) { foreach (AccessGroupProxy proxy in accessGroupList) { if (proxy.IsParent) { PrecardGroups group = groupRep.GetById(proxy.ID, false); foreach (Precard p in group.PrecardList) { substituteContainsFlow = true; substitute.PrecardList.Add(p); } } else if (proxy.Checked) { substituteContainsFlow = true; substitute.PrecardList.Add(new Precard() { ID = proxy.ID }); } else { removeList.Add(new Precard() { ID = proxy.ID }); } } foreach (Precard p in removeList) { substitute.PrecardList.Remove(p); } } SaveChanges(substitute, UIActionType.EDIT); return(substituteContainsFlow); } catch (Exception ex) { LogException(ex, "BSubstitute", "UpdateByProxy"); throw ex; } }
private UIValidationExceptions R30_ValidateRuleParametersValue(string keyName, string parameterValue, UIValidationExceptions exception) { switch (keyName) { case "LockCalculationtMonth": int LockCalculationtMonth = Utility.ToInteger(parameterValue); if (LockCalculationtMonth < 1 || LockCalculationtMonth > 12) { exception = AddException(ExceptionResourceKeys.LockCalculationtMonthNotValid, " مقدار پارامتر دوره محاسباتی باید عددی بین 1 تا 12 باشد", exception); } break; case "LockCalculationDay": int LockCalculationDay = Utility.ToInteger(parameterValue); if (LockCalculationDay < 1 || LockCalculationDay > 31) { exception = AddException(ExceptionResourceKeys.LockCalculationDayNotValid, "مقدارپارامتر روز باید عددی بین 1 تا 31 باشد", exception); } break; } return(exception); }
public void SetArchiveValues(int year, int month, decimal personId, ArchiveCalcValuesProxy proxy) { IList <ArchiveCalcValuesProxy> resultList = new List <ArchiveCalcValuesProxy>(); int rangeOrder = month; IList <ArchiveConceptValue> archiveValues = archiveRep.LoadArchiveValueList(new List <decimal>() { personId }, year, rangeOrder); IList <ArchiveFieldMap> fildsMapList = mapRep.GetAll(); if (archiveValues.Any(x => x.PersonId == personId)) { ArchiveFieldMap map = null; MemberInfo[] members = proxy.GetType().GetMembers(); #region Data Type Validatin UIValidationExceptions exceptions = new UIValidationExceptions(); foreach (MemberInfo member in members.Where(a => a.MemberType == MemberTypes.Property && !a.Name.ToLower().Contains("person"))) { PropertyInfo prop = typeof(ArchiveCalcValuesProxy).GetProperty(member.Name); map = fildsMapList.Where(x => x.PId.ToLower().Equals(member.Name.ToLower())).FirstOrDefault(); if (map != null) { ArchiveConceptValue cnpValue = archiveValues.Where(x => x.PersonId == personId && x.Concept.KeyColumnName.ToLower().Equals(map.ConceptKeyColumn.ToLower())).FirstOrDefault(); if (cnpValue != null) { bool isValid = false; string pValue = Utility.ToString(prop.GetValue(proxy, null)); int value = 0; string cnpName = ""; if (BLanguage.CurrentLocalLanguage == LanguagesName.Parsi) { cnpName = map.FnTitle; } else { cnpName = map.EnTitle; } switch (cnpValue.Concept.DataType) { case ConceptDataType.Int: if (!Utility.IsNumber(pValue)) { exceptions.Add(new ValidationException(ExceptionResourceKeys.ArchiveDataTypeIsNotValid, cnpName, ExceptionSrc)); } break; case ConceptDataType.Hour: if (!Utility.IsTime(pValue)) { exceptions.Add(new ValidationException(ExceptionResourceKeys.ArchiveDataTypeIsNotValid, cnpName, ExceptionSrc)); } break; } if (isValid) { cnpValue.ChangedValue = value; archiveRep.SaveOrUpdate(cnpValue); } } } } if (exceptions.Count > 0) { throw exceptions; } #endregion #region Set Value foreach (MemberInfo member in members.Where(a => a.MemberType == MemberTypes.Property && !a.Name.ToLower().Contains("person"))) { PropertyInfo prop = typeof(ArchiveCalcValuesProxy).GetProperty(member.Name); map = fildsMapList.Where(x => x.PId.ToLower().Equals(member.Name.ToLower())).FirstOrDefault(); if (map != null) { ArchiveConceptValue cnpValue = archiveValues.Where(x => x.PersonId == personId && x.Concept.KeyColumnName.ToLower().Equals(map.ConceptKeyColumn.ToLower())).FirstOrDefault(); if (cnpValue != null) { bool isValid = false; string pValue = Utility.ToString(prop.GetValue(proxy, null)); int value = 0; switch (cnpValue.Concept.DataType) { case ConceptDataType.Int: if (Utility.IsNumber(pValue)) { value = Utility.ToInteger(pValue); isValid = true; } break; case ConceptDataType.Hour: if (Utility.IsTime(pValue)) { value = Utility.RealTimeToIntTime(pValue); isValid = true; } break; } if (isValid) { cnpValue.ChangedValue = value; archiveRep.SaveOrUpdate(cnpValue); } } } } #endregion } }