public void TestSetup() { assign_testObject = new AssignWorkGroup(); bussAssign = new BAssignWorkGroup(SysLanguageResource.Parsi); DatabaseGateway.TA_PersonDataTable personTable = personTA.GetDataByBarcode("00001"); ADOPerson1.ID = Convert.ToInt32(personTable.Rows[0]["prs_ID"]); ADOPerson1.BarCode = Convert.ToString(personTable.Rows[0]["prs_Barcode"]); workGroupTA.Insert("WorkGroup1", "0-0", null); DatabaseGateway.TA_WorkGroupDataTable workGroupTAble = new DatabaseGateway.TA_WorkGroupDataTable(); workGroupTA.FillByName(workGroupTAble, "WorkGroup1"); ADOworkGroup1.ID = Convert.ToDecimal(workGroupTAble.Rows[0]["WorkGroup_ID"]); ADOworkGroup1.Name = Convert.ToString(workGroupTAble.Rows[0]["WorkGroup_Name"]); ADOworkGroup1.CustomCode = Convert.ToString(workGroupTAble.Rows[0]["WorkGroup_CustomCode"]); assingTA.Insert(ADOworkGroup1.ID, ADOPerson1.ID, new DateTime(2010, 2, 14)); assingTA.Insert(ADOworkGroup1.ID, ADOPerson1.ID, new DateTime(2005, 5, 14)); assingTA.Insert(ADOworkGroup1.ID, ADOPerson1.ID, new DateTime(2007, 11, 5)); assingTA.Insert(ADOworkGroup1.ID, ADOPerson1.ID, new DateTime(2010, 9, 14)); assingTA.Insert(ADOworkGroup1.ID, ADOPerson1.ID, new DateTime(2012, 9, 14)); assingTA.Insert(ADOworkGroup1.ID, ADOPerson1.ID, new DateTime(2008, 3, 1)); DatabaseGateway.TA_AssignWorkGroupDataTable table = new DatabaseGateway.TA_AssignWorkGroupDataTable(); assingTA.FillByFilter(table, ADOworkGroup1.ID, ADOPerson1.ID); ADOAssign.ID = (decimal)table.Rows[0]["AsgWorkGroup_ID"]; ADOAssign.FromDate = (DateTime)table.Rows[0]["AsgWorkGroup_FromDate"]; }
public void Insert_ValidateSmallEnglishDateTest1() { try { bussAssign = new BAssignWorkGroup(SysLanguageResource.English); bussAssign.SaveChanges(assign_testObject, UIActionType.ADD); } catch (UIValidationExceptions ex) { Assert.AreEqual(assign_testObject.FromDate, Utility.GTSMinStandardDateTime); } }
public void Insert_ValidateSmallEnglishDateTest2() { try { bussAssign = new BAssignWorkGroup(SysLanguageResource.English); assign_testObject.UIFromDate = Utility.ToString(new DateTime(1800, 1, 1)); bussAssign.SaveChanges(assign_testObject, UIActionType.ADD); } catch (UIValidationExceptions ex) { Assert.IsTrue(ex.Exists(ExceptionResourceKeys.AssignWorkGroupSmallerThanStandardValue)); } }
public void Insert_UIFromDateEnglishTest() { BAssignWorkGroup bassign = new BAssignWorkGroup(SysLanguageResource.English); assign_testObject.UIFromDate = "2010/4/05"; assign_testObject.Person = ADOPerson1; assign_testObject.WorkGroup = ADOworkGroup1; bassign.SaveChanges(assign_testObject, UIActionType.ADD); ClearSession(); assign_testObject = bassign.GetByID(assign_testObject.ID); Assert.AreEqual(assign_testObject.FromDate.Date, new DateTime(2010, 4, 5)); }
/// <summary> /// تغییر مشخصات سازمانی /// </summary> /// <param name="personList">لیست پرسنل</param> /// <param name="infoProxy">پروکسی مشخصات سازمانی</param> /// <param name="errorList">خروجی لیست خطاها</param> /// <returns>وضعیت انجام عملیات</returns> private bool ChangeInfo(IList <Person> personList, OrganicInfoProxy infoProxy, out IList <ChangeInfoErrorProxy> errorList) { IList <PersonRuleCatAssignment> ruleAssgnList = new List <PersonRuleCatAssignment>(); IList <PersonRangeAssignment> rangeAssgnList = new List <PersonRangeAssignment>(); IList <AssignWorkGroup> workGroupAssgnList = new List <AssignWorkGroup>(); IList <PersonContractAssignment> contractAssgnList = new List <PersonContractAssignment>(); #region Validate DateTime workGroupFromDate, ruleGroupFromDate, ruleGroupToDate, DateRangeFromDate, contractFromDate, contractToDate; if (BLanguage.CurrentSystemLanguage == LanguagesName.Parsi) { workGroupFromDate = Utility.ToMildiDate(infoProxy.WorkGroupFromDate); ruleGroupFromDate = Utility.ToMildiDate(infoProxy.RuleGroupFromDate); ruleGroupToDate = Utility.ToMildiDate(infoProxy.RuleGroupToDate); DateRangeFromDate = Utility.ToMildiDate(infoProxy.DateRangeFromDate); contractFromDate = Utility.ToMildiDate(infoProxy.ContractFromDate); contractToDate = Utility.ToMildiDate(infoProxy.ContractToDate); } else { workGroupFromDate = Utility.ToMildiDateTime(infoProxy.WorkGroupFromDate); ruleGroupFromDate = Utility.ToMildiDateTime(infoProxy.RuleGroupFromDate); ruleGroupToDate = Utility.ToMildiDateTime(infoProxy.RuleGroupToDate); DateRangeFromDate = Utility.ToMildiDateTime(infoProxy.DateRangeFromDate); contractFromDate = Utility.ToMildiDateTime(infoProxy.ContractFromDate); contractToDate = Utility.ToMildiDateTime(infoProxy.ContractToDate); } errorList = new List <ChangeInfoErrorProxy>(); foreach (Person prs in personList) { string errorMessage = ""; if (infoProxy.WorkGroupID > 0) { workGroupAssgnList = new BAssignWorkGroup(BLanguage.CurrentSystemLanguage).GetAllByWorkGroupId(infoProxy.WorkGroupID); ValidateWorkGroupAssignment(prs, workGroupFromDate, ref errorMessage); } if (infoProxy.RuleGroupID > 0) { ruleAssgnList = new BAssignRule(BLanguage.CurrentSystemLanguage).GetAllByRuleGroupId(infoProxy.RuleGroupID); ValidateRuleGroupAssignment(prs, ruleGroupFromDate, ruleGroupToDate, ref errorMessage); } if (infoProxy.DateRangeID > 0) { rangeAssgnList = new BAssignDateRange(BLanguage.CurrentSystemLanguage).GetAllByRangeId(infoProxy.DateRangeID); ValidateDateRangeAssignment(prs, DateRangeFromDate, ref errorMessage); } if (infoProxy.ContractID > 0) { contractAssgnList = new BPersonContractAssignment(BLanguage.CurrentSystemLanguage).GetAllByContractId(infoProxy.ContractID); ValidateContractAssignment(prs, contractFromDate, contractToDate, ref errorMessage); } if (!Utility.IsEmpty(errorMessage)) { errorList.Add(new ChangeInfoErrorProxy() { ErrorMessage = errorMessage, PersonCode = prs.PersonCode, PersonName = prs.Name }); if (errorList.Count > 50) { break; } } } if (errorList.Count > 0) { return(false); } #endregion using (NHibernateSessionManager.Instance.BeginTransactionOn()) { try { UnderManagmentRepository underMngRep = new UnderManagmentRepository(false); List <decimal> personIdList = new List <decimal>(); IList <OrganizationFeatureProxy> organizationFeatureList = new List <OrganizationFeatureProxy>(); IList <FlowPersonsProxy> flowPersonList = new List <FlowPersonsProxy>(); List <decimal> PersonnelsDepartmentChange = new List <decimal>(); bool cfpUpdateRequierd = false; DateTime minDate = DateTime.Now; int counter = 0; foreach (Person prs in personList) { counter++; bool updatePrs = false; personIdList.Add(prs.ID); IList <OrganizationFeatureProxy> organizationFeatureExist = new List <OrganizationFeatureProxy>(); UnderManagment underMng = new UnderManagment(); #region Department if (infoProxy.DepartmentID > 0) { if (prs.Department.ID != infoProxy.DepartmentID) { PersonnelsDepartmentChange.Add(prs.ID); } if (organizationFeatureList.Count != 0) { organizationFeatureExist = organizationFeatureList.Where(x => x.DepartmentId == prs.Department.ID).ToList(); } if (organizationFeatureExist.Count == 0) { IList <decimal> FlowIds = underMngRep.GetDepartmentFlows(prs.Department.ID); foreach (decimal flowId in FlowIds) { OrganizationFeatureProxy orgFeatureProxy = new OrganizationFeatureProxy(); FlowPersonsProxy flowPerson = new FlowPersonsProxy(); orgFeatureProxy.FlowId = flowId; orgFeatureProxy.DepartmentId = prs.Department.ID; organizationFeatureList.Add(orgFeatureProxy); flowPerson.FlowId = flowId; flowPerson.PersonId = prs.ID; flowPersonList.Add(flowPerson); } } else { IList <decimal> FlowIds = organizationFeatureExist.Select(x => x.FlowId) .ToList <decimal>(); foreach (decimal flowId in FlowIds) { FlowPersonsProxy flowPerson = new FlowPersonsProxy(); flowPerson.FlowId = flowId; flowPerson.PersonId = prs.ID; flowPersonList.Add(flowPerson); } } prs.Department = new GTS.Clock.Model.Charts.Department() { ID = infoProxy.DepartmentID }; updatePrs = true; } #endregion #region Employment Type if (infoProxy.EmploymentTypeID > 0) { prs.EmploymentType = new GTS.Clock.Model.BaseInformation.EmploymentType() { ID = infoProxy.EmploymentTypeID }; updatePrs = true; } #endregion if (updatePrs) { prsRepository.WithoutTransactUpdate(prs); } #region Rule Category if (infoProxy.RuleGroupID > 0) { cfpUpdateRequierd = true; PersonRuleCatAssignment ruleAssign = new PersonRuleCatAssignment(); BAssignRule ruleAsgnBus = new BAssignRule(); ruleAssgnList = ruleAsgnBus.GetAll(prs.ID); IList <PersonRuleCatAssignment> confilictList = ruleAssgnList.Where(x => ((Utility.ToMildiDateTime(x.FromDate) <= ruleGroupToDate && Utility.ToMildiDateTime(x.ToDate) >= ruleGroupToDate)) || ((Utility.ToMildiDateTime(x.FromDate) <= ruleGroupFromDate && Utility.ToMildiDateTime(x.ToDate) >= ruleGroupFromDate)) || ((Utility.ToMildiDateTime(x.FromDate) >= ruleGroupFromDate && Utility.ToMildiDateTime(x.FromDate) <= ruleGroupToDate)) ).ToList(); if (confilictList != null && confilictList.Count > 0) { Range range = new Range() { From = ruleGroupFromDate, To = ruleGroupToDate, AditionalField = 0 }; var confilictRanges = from o in confilictList select new Range() { From = Utility.ToMildiDateTime(o.FromDate), To = Utility.ToMildiDateTime(o.ToDate), AditionalField = o.RuleCategory.ID }; IList <Range> breakedList = Utility.Differance(confilictRanges.ToList(), range); #region Delete //foreach (PersonRuleCatAssignment asgn in ruleAssgnList) //{ // ruleAsgnBus.SaveChanges(asgn, UIActionType.DELETE); //} foreach (PersonRuleCatAssignment asgn in confilictList) { ruleAsgnBus.SaveChanges(asgn, UIActionType.DELETE); } #endregion #region add first ruleAssign.FromDate = Utility.ToString(ruleGroupFromDate); ruleAssign.ToDate = Utility.ToString(ruleGroupToDate); ruleAssign.Person = prs; ruleAssign.RuleCategory = new RuleCategory() { ID = infoProxy.RuleGroupID }; busRule.InsertWithoutTransaction(ruleAssign); #endregion #region add breaked List foreach (Range r in breakedList) { if (r.From == range.To) { r.From = r.From.AddDays(1); } if (r.To == range.From) { r.To = r.To.AddDays(-1); } ruleAssign = new PersonRuleCatAssignment(); ruleAssign.FromDate = Utility.ToString(r.From); ruleAssign.ToDate = Utility.ToString(r.To); ruleAssign.Person = prs; ruleAssign.RuleCategory = new RuleCategory() { ID = r.AditionalField }; busRule.InsertWithoutTransaction(ruleAssign); } #endregion } else { ruleAssign.FromDate = Utility.ToString(ruleGroupFromDate); ruleAssign.ToDate = Utility.ToString(ruleGroupToDate); ruleAssign.Person = prs; ruleAssign.RuleCategory = new RuleCategory() { ID = infoProxy.RuleGroupID }; busRule.InsertWithoutTransaction(ruleAssign); } if (minDate > ruleGroupFromDate) { minDate = ruleGroupFromDate; } } #endregion #region Contract if (infoProxy.ContractID > 0) { cfpUpdateRequierd = true; PersonContractAssignment contractAssign = new PersonContractAssignment(); contractAssign.Person = prs; contractAssign.Contract = new Contract() { ID = infoProxy.ContractID }; contractAssign.FromDate = contractFromDate; contractAssign.ToDate = contractToDate; BPersonContractAssignment contractAsgnBus = new BPersonContractAssignment(); contractAssgnList = contractAsgnBus.GetAll(prs.ID); PersonContractAssignment PersonContractAssignmentAlias = null; Person PersonAlias = null; IList <PersonContractAssignment> personContractAssignmentList = NHSession.QueryOver <PersonContractAssignment>(() => PersonContractAssignmentAlias) .JoinAlias(() => PersonContractAssignmentAlias.Person, () => PersonAlias) .Where(() => !PersonContractAssignmentAlias.IsDeleted && PersonAlias.ID == prs.ID ) .List <PersonContractAssignment>(); if (personContractAssignmentList != null && personContractAssignmentList.Count > 0) { personContractAssignmentList.ToList() .ForEach(x => { if (x.ToDate == Utility.GTSMinStandardDateTime) { x.ToDate = DateTime.MaxValue.Date; } } ); } if (contractAssign.ToDate == Utility.GTSMinStandardDateTime) { contractAssign.ToDate = DateTime.MaxValue.Date; } if (contractAsgnBus.CheckPersonContractAssignmentConfilct(personContractAssignmentList.ToList(), contractAssign)) { errorList.Add(new ChangeInfoErrorProxy() { ErrorMessage = "تاریخ انتساب قرارداد با تاریخ های قبلی همپوشانی دارد", PersonCode = prs.PersonCode, PersonName = prs.Name }); } else { if (prs != null && prs.ID != 0 && contractAssign.FromDate < prs.EmploymentDate) { errorList.Add(new ChangeInfoErrorProxy() { ErrorMessage = "تاریخ انتساب ابتدای قرارداد نباید از تاریخ استخدام کوچکتر باشد", PersonCode = prs.PersonCode, PersonName = prs.Name }); } else { if (contractAssign.ToDate == DateTime.MaxValue.Date) { contractAssign.ToDate = Utility.GTSMinStandardDateTime; } busAssignContract.InsertWithoutTransaction(contractAssign); if (minDate > contractFromDate) { minDate = contractFromDate; } } } } #endregion #region Date Range if (infoProxy.DateRangeID > 0) { cfpUpdateRequierd = true; PersonRangeAssignment prsRangeAssignment = new PersonRangeAssignment(); rangeAssgnList = new BAssignDateRange(BLanguage.CurrentSystemLanguage).GetAll(prs.ID); prsRangeAssignment = rangeAssgnList.Where(x => x.FromDate == DateRangeFromDate).FirstOrDefault(); if (prsRangeAssignment != null) { prsRangeAssignment.FromDate = DateRangeFromDate; prsRangeAssignment.CalcDateRangeGroup = new CalculationRangeGroup() { ID = infoProxy.DateRangeID }; } else { prsRangeAssignment = new PersonRangeAssignment(); prsRangeAssignment.Person = prs; prsRangeAssignment.FromDate = DateRangeFromDate; prsRangeAssignment.CalcDateRangeGroup = new CalculationRangeGroup() { ID = infoProxy.DateRangeID }; } bussDateRange.InsertWithoutTransaction(prsRangeAssignment); if (minDate > DateRangeFromDate) { minDate = DateRangeFromDate; } } #endregion #region Work Group if (infoProxy.WorkGroupID > 0) { cfpUpdateRequierd = true; AssignWorkGroup prsWorkGroupAssignment = new AssignWorkGroup(); workGroupAssgnList = new BAssignWorkGroup(BLanguage.CurrentSystemLanguage).GetAll(prs.ID); prsWorkGroupAssignment = workGroupAssgnList.Where(x => x.FromDate == workGroupFromDate).FirstOrDefault(); if (prsWorkGroupAssignment != null) { prsWorkGroupAssignment.Person = prs; prsWorkGroupAssignment.FromDate = workGroupFromDate; prsWorkGroupAssignment.WorkGroup = new WorkGroup() { ID = infoProxy.WorkGroupID }; } else { prsWorkGroupAssignment = new AssignWorkGroup(); prsWorkGroupAssignment.Person = prs; prsWorkGroupAssignment.FromDate = workGroupFromDate; prsWorkGroupAssignment.WorkGroup = new WorkGroup() { ID = infoProxy.WorkGroupID }; } busWorkGroup.InsertWithoutTransaction(prsWorkGroupAssignment); if (minDate > workGroupFromDate) { minDate = workGroupFromDate; } } #endregion } if (infoProxy.DepartmentID > 0) { IList <decimal> FlowIDs = organizationFeatureList.Select(x => x.FlowId).Distinct().ToList <decimal>(); if (FlowIDs.Count != 0) { IList <UnderManagment> UnderManagmentList = underMngRep.GetAllPersonelparticularFlows(FlowIDs); foreach (decimal flowid in FlowIDs) { IList <decimal> PersonIds = flowPersonList.Where(x => x.FlowId == flowid && !UnderManagmentList.Where(y => y.Flow.ID == flowid).Select(y => y.Person.ID).ToList <decimal>().Contains(x.PersonId) ).Select(x => x.PersonId).ToList <decimal>(); if (PersonIds.Count != 0) { underMngRep.DeleteUnderManagmentPersonsWithOrganicInfo(flowid, PersonIds); } } } IList <decimal> NewDepertmentFlowsList = underMngRep.GetDepartmentFlows(personList[0].Department.ID); if (NewDepertmentFlowsList.Count != 0) { underMngRep.InsertUnderManagmentPersons(personIdList, NewDepertmentFlowsList); } BRequestSubstitute rSubstitute = new BRequestSubstitute(); if (PersonnelsDepartmentChange.Count != 0) { rSubstitute.UpdateRequestSubstituteOfOrganicInfo(PersonnelsDepartmentChange); } } if (cfpUpdateRequierd) { this.UpdateCFP(personList, minDate); } NHibernateSessionManager.Instance.CommitTransactionOn(); } catch (Exception ex) { BaseBusiness <Entity> .LogException(ex, "BChangeOrganicInfo", "ChangeInfo"); NHibernateSessionManager.Instance.RollbackTransactionOn(); throw ex; } } return(true); }
private bool ChangeInfo(IList <Person> personList, OrganicInfoProxy infoProxy, out IList <ChangeInfoErrorProxy> errorList) { IList <PersonRuleCatAssignment> ruleAssgnList = new List <PersonRuleCatAssignment>(); IList <PersonRangeAssignment> rangeAssgnList = new List <PersonRangeAssignment>(); IList <AssignWorkGroup> workGroupAssgnList = new List <AssignWorkGroup>(); #region Validate DateTime workGroupFromDate, ruleGroupFromDate, ruleGroupToDate, DateRangeFromDate; if (BLanguage.CurrentSystemLanguage == LanguagesName.Parsi) { workGroupFromDate = Utility.ToMildiDate(infoProxy.WorkGroupFromDate); ruleGroupFromDate = Utility.ToMildiDate(infoProxy.RuleGroupFromDate); ruleGroupToDate = Utility.ToMildiDate(infoProxy.RuleGroupToDate); DateRangeFromDate = Utility.ToMildiDate(infoProxy.DateRangeFromDate); } else { workGroupFromDate = Utility.ToMildiDateTime(infoProxy.WorkGroupFromDate); ruleGroupFromDate = Utility.ToMildiDateTime(infoProxy.RuleGroupFromDate); ruleGroupToDate = Utility.ToMildiDateTime(infoProxy.RuleGroupToDate); DateRangeFromDate = Utility.ToMildiDateTime(infoProxy.DateRangeFromDate); } errorList = new List <ChangeInfoErrorProxy>(); foreach (Person prs in personList) { string errorMessage = ""; if (infoProxy.WorkGroupID > 0) { workGroupAssgnList = new BAssignWorkGroup(BLanguage.CurrentSystemLanguage).GetAllByWorkGroupId(infoProxy.WorkGroupID); ValidateWorkGroupAssignment(prs, workGroupFromDate, ref errorMessage); } if (infoProxy.RuleGroupID > 0) { ruleAssgnList = new BAssignRule(BLanguage.CurrentSystemLanguage).GetAllByRuleGroupId(infoProxy.RuleGroupID); ValidateRuleGroupAssignment(prs, ruleGroupFromDate, ruleGroupToDate, ref errorMessage); } if (infoProxy.DateRangeID > 0) { rangeAssgnList = new BAssignDateRange(BLanguage.CurrentSystemLanguage).GetAllByRangeId(infoProxy.DateRangeID); ValidateDateRangeAssignment(prs, DateRangeFromDate, ref errorMessage); } if (!Utility.IsEmpty(errorMessage)) { errorList.Add(new ChangeInfoErrorProxy() { ErrorMessage = errorMessage, PersonCode = prs.PersonCode, PersonName = prs.Name }); if (errorList.Count > 50) { break; } } } if (errorList.Count > 0) { return(false); } #endregion using (NHibernateSessionManager.Instance.BeginTransactionOn()) { try { bool cfpUpdateRequierd = false; DateTime minDate = DateTime.Now; int counter = 0; foreach (Person prs in personList) { counter++; bool updatePrs = false; #region Department if (infoProxy.DepartmentID > 0) { prs.Department = new GTS.Clock.Model.Charts.Department() { ID = infoProxy.DepartmentID }; updatePrs = true; } #endregion #region Employment Type if (infoProxy.EmploymentTypeID > 0) { prs.EmploymentType = new GTS.Clock.Model.BaseInformation.EmploymentType() { ID = infoProxy.EmploymentTypeID }; updatePrs = true; } #endregion if (updatePrs) { prsRepository.WithoutTransactUpdate(prs); } #region Rule Category if (infoProxy.RuleGroupID > 0) { cfpUpdateRequierd = true; PersonRuleCatAssignment ruleAssign = new PersonRuleCatAssignment(); BAssignRule ruleAsgnBus = new BAssignRule(); ruleAssgnList = ruleAsgnBus.GetAll(prs.ID); IList <PersonRuleCatAssignment> confilictList = ruleAssgnList.Where(x => ((Utility.ToMildiDateTime(x.FromDate) <= ruleGroupToDate && Utility.ToMildiDateTime(x.ToDate) >= ruleGroupToDate)) || ((Utility.ToMildiDateTime(x.FromDate) <= ruleGroupFromDate && Utility.ToMildiDateTime(x.ToDate) >= ruleGroupFromDate)) || ((Utility.ToMildiDateTime(x.FromDate) >= ruleGroupFromDate && Utility.ToMildiDateTime(x.FromDate) <= ruleGroupToDate)) ).ToList(); if (confilictList != null && confilictList.Count > 0) { Range range = new Range() { From = ruleGroupFromDate, To = ruleGroupToDate, AditionalField = 0 }; var confilictRanges = from o in confilictList select new Range() { From = Utility.ToMildiDateTime(o.FromDate), To = Utility.ToMildiDateTime(o.ToDate), AditionalField = o.RuleCategory.ID }; IList <Range> breakedList = Utility.Differance(confilictRanges.ToList(), range); #region Delete foreach (PersonRuleCatAssignment asgn in ruleAssgnList) { ruleAsgnBus.SaveChanges(asgn, UIActionType.DELETE); } #endregion #region add first ruleAssign.FromDate = Utility.ToString(ruleGroupFromDate); ruleAssign.ToDate = Utility.ToString(ruleGroupToDate); ruleAssign.Person = prs; ruleAssign.RuleCategory = new RuleCategory() { ID = infoProxy.RuleGroupID }; busRule.InsertWithoutTransaction(ruleAssign); #endregion #region add breaked List foreach (Range r in breakedList) { if (r.From == range.To) { r.From = r.From.AddDays(1); } if (r.To == range.From) { r.To = r.To.AddDays(-1); } ruleAssign = new PersonRuleCatAssignment(); ruleAssign.FromDate = Utility.ToString(r.From); ruleAssign.ToDate = Utility.ToString(r.To); ruleAssign.Person = prs; ruleAssign.RuleCategory = new RuleCategory() { ID = r.AditionalField }; busRule.InsertWithoutTransaction(ruleAssign); } #endregion } else { ruleAssign.FromDate = Utility.ToString(ruleGroupFromDate); ruleAssign.ToDate = Utility.ToString(ruleGroupToDate); ruleAssign.Person = prs; ruleAssign.RuleCategory = new RuleCategory() { ID = infoProxy.RuleGroupID }; busRule.InsertWithoutTransaction(ruleAssign); } if (minDate > ruleGroupFromDate) { minDate = ruleGroupFromDate; } } #endregion #region Date Range if (infoProxy.DateRangeID > 0) { cfpUpdateRequierd = true; PersonRangeAssignment prsRangeAssignment = new PersonRangeAssignment(); rangeAssgnList = new BAssignDateRange(BLanguage.CurrentSystemLanguage).GetAll(prs.ID); prsRangeAssignment = rangeAssgnList.Where(x => x.FromDate == DateRangeFromDate).FirstOrDefault(); if (prsRangeAssignment != null) { prsRangeAssignment.FromDate = DateRangeFromDate; prsRangeAssignment.CalcDateRangeGroup = new CalculationRangeGroup() { ID = infoProxy.DateRangeID }; } else { prsRangeAssignment = new PersonRangeAssignment(); prsRangeAssignment.Person = prs; prsRangeAssignment.FromDate = DateRangeFromDate; prsRangeAssignment.CalcDateRangeGroup = new CalculationRangeGroup() { ID = infoProxy.DateRangeID }; } bussDateRange.InsertWithoutTransaction(prsRangeAssignment); if (minDate > DateRangeFromDate) { minDate = DateRangeFromDate; } } #endregion #region Work Group if (infoProxy.WorkGroupID > 0) { cfpUpdateRequierd = true; AssignWorkGroup prsWorkGroupAssignment = new AssignWorkGroup(); workGroupAssgnList = new BAssignWorkGroup(BLanguage.CurrentSystemLanguage).GetAll(prs.ID); prsWorkGroupAssignment = workGroupAssgnList.Where(x => x.FromDate == workGroupFromDate).FirstOrDefault(); if (prsWorkGroupAssignment != null) { prsWorkGroupAssignment.Person = prs; prsWorkGroupAssignment.FromDate = workGroupFromDate; prsWorkGroupAssignment.WorkGroup = new WorkGroup() { ID = infoProxy.WorkGroupID }; } else { prsWorkGroupAssignment = new AssignWorkGroup(); prsWorkGroupAssignment.Person = prs; prsWorkGroupAssignment.FromDate = workGroupFromDate; prsWorkGroupAssignment.WorkGroup = new WorkGroup() { ID = infoProxy.WorkGroupID }; } busWorkGroup.InsertWithoutTransaction(prsWorkGroupAssignment); if (minDate > workGroupFromDate) { minDate = workGroupFromDate; } } #endregion } if (cfpUpdateRequierd) { this.UpdateCFP(personList, minDate); } NHibernateSessionManager.Instance.CommitTransactionOn(); } catch (Exception ex) { BaseBusiness <Entity> .LogException(ex, "BChangeOrganicInfo", "ChangeInfo"); NHibernateSessionManager.Instance.RollbackTransactionOn(); throw ex; } } return(true); }
private Person GetReadyForUpdate(decimal personid, SysLanguageResource sys, LocalLanguageResource local) { try { busPerson = new BPerson(sys, local); if (personid == 0) { person_testObject.ID = busPerson.CreateWorkingPerson2(); ClearSession(); } else { person_testObject.ID = personid; } person_testObject.PersonDetail = new PersonDetail(); #region Assigns BAssignWorkGroup bAssginWorkGroup = new BAssignWorkGroup(SysLanguageResource.Parsi); BWorkgroup workgroup = new BWorkgroup(); decimal wID = workgroup.SaveChanges(new WorkGroup() { Name = "WorkGroupTest3", CustomCode = "0-3" }, UIActionType.ADD); AssignWorkGroup aw = new AssignWorkGroup(); aw.UIFromDate = Utility.ToPersianDate(DateTime.Now); aw.WorkGroup = new WorkGroup() { ID = wID, Name = "WorkGroupTest3" }; aw.Person = new Person() { ID = person_testObject.ID }; bAssginWorkGroup.SaveChanges(aw, UIActionType.ADD); BAssignRule bAssginRule = new BAssignRule(SysLanguageResource.Parsi); BRuleCategory bruleCat = new BRuleCategory(); bruleCat.EnableInsertValidate = false; decimal rID = bruleCat.SaveChanges(new RuleCategory() { Name = "RuleCatTest3", CustomCode = "00-00test2" }, UIActionType.ADD); PersonRuleCatAssignment pa = new PersonRuleCatAssignment(); pa.UIFromDate = Utility.ToPersianDate(new DateTime(2016, 1, 1)); pa.UIToDate = Utility.ToPersianDate(new DateTime(2017, 1, 1)); pa.RuleCategory = new RuleCategory() { ID = rID, Name = "RuleCatTest3" }; pa.Person = new Person() { ID = person_testObject.ID }; bAssginRule.SaveChanges(pa, UIActionType.ADD); BAssignDateRange bDateRange = new BAssignDateRange(SysLanguageResource.Parsi); PersonRangeAssignment rangeAssign = new PersonRangeAssignment(); BDateRange bdate = new BDateRange(); decimal rangeId = bdate.SaveChanges(new CalculationRangeGroup() { Name = "CalcGroup3" }, UIActionType.ADD); ClearSession(); rangeAssign.CalcDateRangeGroup = new CalculationRangeGroup() { ID = rangeId }; if (sys == SysLanguageResource.Parsi) { rangeAssign.UIFromDate = "1390/01/01"; } else { rangeAssign.UIFromDate = "1390/01/01"; //Utility.ToString(Utility.ToMildiDate("1390/01/01")); } rangeAssign.Person = new Person() { ID = person_testObject.ID }; bDateRange.SaveChanges(rangeAssign, UIActionType.ADD); //جهت درج //person_testObject.PersonRangeAssignList = new List<PersonRangeAssignment>(); //person_testObject.PersonRangeAssignList.Add(rangeAssign); #endregion #region Dep DatabaseGatewayTableAdapters.TA_DepartmentTableAdapter departmentTA = new GTSTestUnit.Clock.Business.DatabaseGatewayTableAdapters.TA_DepartmentTableAdapter(); decimal departmentId = Convert.ToDecimal(departmentTA.InsertQuery("Level1", "123", 1, ",1,", "")); DatabaseGatewayTableAdapters.TA_OrganizationUnitTableAdapter organTA = new GTSTestUnit.Clock.Business.DatabaseGatewayTableAdapters.TA_OrganizationUnitTableAdapter(); organTA.InsertQuery("OrganTestLevel1", "0-0Test", null, 1, String.Format(",{0},", 1)); decimal organId = Convert.ToDecimal(organTA.GetDataByCustomCode("0-0Test")[0]["organ_ID"]); DatabaseGatewayTableAdapters.TA_ControlStationTableAdapter sataionTA = new GTSTestUnit.Clock.Business.DatabaseGatewayTableAdapters.TA_ControlStationTableAdapter(); sataionTA.Insert("StationTest1", "0-0Test"); decimal stationId = Convert.ToDecimal(sataionTA.GetDataByCustomCode("0-0Test")[0]["station_ID"]); DatabaseGatewayTableAdapters.TA_EmploymentTypeTableAdapter emplTA = new GTSTestUnit.Clock.Business.DatabaseGatewayTableAdapters.TA_EmploymentTypeTableAdapter(); emplTA.Insert("EmploymentTypeTest1", "0-0Test"); decimal employeeId = Convert.ToDecimal(emplTA.GetDataByCustomCode("0-0Test")[0]["emply_ID"]); #endregion #region UIValidatinGroup DatabaseGatewayTableAdapters.TA_UIValidationGroupTableAdapter validationGroupTA = new GTSTestUnit.Clock.Business.DatabaseGatewayTableAdapters.TA_UIValidationGroupTableAdapter(); UIValidationGroup ADOUIValidationGroupEmpty = new UIValidationGroup(); validationGroupTA.InsertQuery("TestGroup00"); DatabaseGateway.TA_UIValidationGroupDataTable groupTable = validationGroupTA.GetDataByName("TestGroup00"); ADOUIValidationGroupEmpty.ID = (groupTable.Rows[0] as DatabaseGateway.TA_UIValidationGroupRow).UIValGrp_ID; person_testObject.UIValidationGroup = ADOUIValidationGroupEmpty; #endregion person_testObject.FirstName = "Iraj"; person_testObject.LastName = "Bahadori"; person_testObject.PersonDetail.FatherName = "Gholzoom"; person_testObject.PersonDetail.FatherName = "0082111098"; person_testObject.PersonDetail.BirthCertificate = "22777"; person_testObject.PersonDetail.BirthPlace = "Sorhe"; person_testObject.Education = "لیسانس"; person_testObject.PersonDetail.Status = "رو هوا"; person_testObject.PersonDetail.Tel = "23444343"; person_testObject.PersonDetail.Address = ""; person_testObject.PersonCode = "00001222"; person_testObject.CardNum = "4345554"; person_testObject.EmploymentNum = "123A342-ad"; person_testObject.Sex = PersonSex.Male; person_testObject.MaritalStatus = MaritalStatus.Motaleghe; person_testObject.PersonDetail.MilitaryStatus = MilitaryStatus.HeineKhedmat; person_testObject.Department = new global::GTS.Clock.Model.Charts.Department() { ID = departmentId }; person_testObject.OrganizationUnit = new global::GTS.Clock.Model.Charts.OrganizationUnit() { ID = organId, PersonID = person_testObject.ID, Name = "OrganTestLevel1", CustomCode = "0-0", ParentID = 1 }; person_testObject.ControlStation = new global::GTS.Clock.Model.BaseInformation.ControlStation() { ID = stationId }; person_testObject.EmploymentType = new global::GTS.Clock.Model.BaseInformation.EmploymentType() { ID = employeeId }; if (sys == SysLanguageResource.Parsi) { person_testObject.UIEmploymentDate = "1380/05/03"; person_testObject.UIEndEmploymentDate = "1390/05/03"; person_testObject.PersonDetail.UIBirthDate = "1390/05/03"; } else { person_testObject.UIEmploymentDate = Utility.ToString(Utility.ToMildiDate("1380/05/03")); person_testObject.UIEndEmploymentDate = Utility.ToString(Utility.ToMildiDate("1390/05/03")); person_testObject.PersonDetail.UIBirthDate = Utility.ToString(Utility.ToMildiDate("1390/05/03")); } ClearSession(); return(person_testObject); } catch (Exception ex) { throw ex; } }