public void Insert_RulesGrouping_Test() { validationGroup_testObject.Name = "TestGroup01"; validationGroup_testObject.GroupingList = new List <UIValidationGrouping>(); UIValidationGrouping groupting = new UIValidationGrouping() { RuleID = ADORule1.ID }; validationGroup_testObject.GroupingList.Add(groupting); groupting = new UIValidationGrouping() { RuleID = ADORule2.ID }; validationGroup_testObject.GroupingList.Add(groupting); busValidationGroup.SaveChanges(validationGroup_testObject, UIActionType.ADD); ClearSession(); UIValidationGroup group = busValidationGroup.GetByID(validationGroup_testObject.ID); Assert.IsNotNull(group.GroupingList); Assert.AreEqual(2, group.GroupingList.Count); }
public void TestSetup() { validationGroup_testObject = new UIValidationGroup(); busValidationGroup = new BUIValidationGroup(); ruleTA.InsertQuery(111000111, "TestRule1", "000-001", true); ruleTA.InsertQuery(111000112, "TestRule2", "000-002", true); DatabaseGateway.TA_UIValidationRuleDataTable ruleTable = ruleTA.GetDataByCode("000-001"); ADORule1.ID = (ruleTable.Rows[0] as DatabaseGateway.TA_UIValidationRuleRow).UIRle_ID; ruleTable = ruleTA.GetDataByCode("000-002"); ADORule2.ID = (ruleTable.Rows[0] as DatabaseGateway.TA_UIValidationRuleRow).UIRle_ID; paramTmpTA.Insert(0, "Rule TMP Param Test 1", ADORule1.ID); paramTmpTA.Insert(1, "Rule TMP Param Test 2", ADORule1.ID); paramTmpTA.Insert(2, "Rule TMP Param Test 3", ADORule1.ID); validationGroupTA.InsertQuery("TestGroup00"); DatabaseGateway.TA_UIValidationGroupDataTable groupTable = validationGroupTA.GetDataByName("TestGroup00"); ADOGroup1.ID = (groupTable.Rows[0] as DatabaseGateway.TA_UIValidationGroupRow).UIValGrp_ID; validationGroupTA.InsertQuery("TestGroup01"); groupTable = validationGroupTA.GetDataByName("TestGroup01"); ADOGroup2.ID = (groupTable.Rows[0] as DatabaseGateway.TA_UIValidationGroupRow).UIValGrp_ID; groupingTA.Insert(ADORule1.ID, ADOGroup1.ID, false, true); personTA.UpdateValidationGroup(ADOGroup1.ID, ADOPerson1.ID); }
public IList <UIValidationGrouping> GetByGroupId(decimal groupId) { UIValidationGrouping grouping = null; UIValidationGroup group = null; IList <UIValidationGrouping> list = NHibernateSession.QueryOver <UIValidationGrouping>(() => grouping) .Where(() => grouping.GroupID == groupId) .List(); IList <UIValidationGrouping> result = list != null && list.Count > 0 ? list : new List <UIValidationGrouping>(); return(result); }
public IList <UIValidationGrouping> GetByPersonId(decimal personId) { UIValidationGrouping grouping = null; UIValidationGroup group = null; PersonTASpec person = null; IList <UIValidationGrouping> list = base.NHibernateSession.QueryOver <UIValidationGrouping>(() => grouping) .JoinAlias(() => grouping.ValidationGroup, () => group) .JoinAlias(() => group.PersonTAList, () => person) .Where(() => person.ID == personId) .And(() => group.SubSystemId == (int)SubSystemIdentifier.TimeAtendance) .List <UIValidationGrouping>(); IList <UIValidationGrouping> result = list != null && list.Count > 0 ? list : new List <UIValidationGrouping>(); return(result); }
public void Update_Test() { try { validationGroup_testObject.ID = ADOGroup1.ID; validationGroup_testObject.Name = "TestGroup03"; busValidationGroup.SaveChanges(validationGroup_testObject, UIActionType.EDIT); ClearSession(); validationGroup_testObject = new UIValidationGroup(); validationGroup_testObject = busValidationGroup.GetByID(ADOGroup1.ID); Assert.AreEqual("TestGroup03", validationGroup_testObject.Name); busValidationGroup.SaveChanges(validationGroup_testObject, UIActionType.DELETE); } catch (Exception ex) { Assert.Fail(ex.Message); } }
public decimal GetByPersonIdAndRuleCode(decimal personId, int ruleCode) { IList <decimal> kk = new List <decimal>(); UIValidationGrouping grouping = null; UIValidationGroup group = null; UIValidationRule rule = null; PersonTASpec person = null; IList <UIValidationGrouping> list = base.NHibernateSession.QueryOver <UIValidationGrouping>(() => grouping) .JoinAlias(() => grouping.ValidationGroup, () => group) .JoinAlias(() => group.PersonTAList, () => person) .JoinAlias(() => grouping.ValidationRule, () => rule) .Where(() => person.ID == personId) .And(() => rule.CustomCode == ruleCode.ToString()) .And(() => group.SubSystemId == (int)SubSystemIdentifier.TimeAtendance) .List <UIValidationGrouping>(); decimal result = list != null && list.Count > 0 ? list.First().ID : 0; return(result); }
public void GetById_Test() { validationGroup_testObject = busValidationGroup.GetByID(ADOGroup1.ID); Assert.AreEqual("TestGroup00", validationGroup_testObject.Name); }
public string[] UpdateUiValidation_UiValidationPage(string state, string SelectedUiValidationID, string UiValidationCode, string UiValidationName, string strRulesList) { this.InitializeCulture(); string[] retMessage = new string[4]; try { AttackDefender.CSRFDefender(this.Page); decimal uiValidationID = 0; decimal selectedUiValidationID = decimal.Parse(this.StringBuilder.CreateString(SelectedUiValidationID), CultureInfo.InvariantCulture); UiValidationCode = this.StringBuilder.CreateString(UiValidationCode); UiValidationName = this.StringBuilder.CreateString(UiValidationName); UIActionType uam = (UIActionType)Enum.Parse(typeof(UIActionType), this.StringBuilder.CreateString(state).ToUpper()); strRulesList = this.StringBuilder.CreateString(strRulesList); UIValidationGroup uiValidation = new UIValidationGroup(); uiValidation.ID = selectedUiValidationID; if (uam != UIActionType.DELETE) { uiValidation.CustomCode = UiValidationCode; uiValidation.Name = UiValidationName; } switch (uam) { case UIActionType.ADD: uiValidationID = this.UiValidationBusiness.InsertUIValidationGroup(uiValidation, uam); break; case UIActionType.EDIT: if (selectedUiValidationID == 0) { retMessage = this.exceptionHandler.HandleException(this.Page, ExceptionTypes.UIValidationExceptions, new Exception(GetLocalResourceObject("NoUiValidationSelectedforEdit").ToString()), retMessage); return(retMessage); } IList <UiValidationRuleGroupProxy> UiValidtionRuleGroupProxyList = this.CreateUiValidationGroupingList(strRulesList); // this.UiValidationBusiness.UpdateRulesList(UiValidtionRuleGroupProxyList); uiValidationID = this.UiValidationBusiness.UpdateUIValidationGroup(uiValidation, UiValidtionRuleGroupProxyList, uam); break; case UIActionType.DELETE: if (selectedUiValidationID == 0) { retMessage = this.exceptionHandler.HandleException(this.Page, ExceptionTypes.UIValidationExceptions, new Exception(GetLocalResourceObject("NoUiValidationSelectedforDelete").ToString()), retMessage); return(retMessage); } uiValidationID = this.UiValidationBusiness.DeleteUIValidationGroup(uiValidation, uam); break; } retMessage[0] = GetLocalResourceObject("RetSuccessType").ToString(); string SuccessMessageBody = string.Empty; switch (uam) { 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] = uiValidationID.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); } }
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; } }
public void InsertRequestSubstitute(Request request) { try { RequestSubstitute requestSubstitute = null; Person person = null; Precard precardAlias = null; UIValidationGroup uiValidationGroupAlias = null; UIValidationRule uiValidationRuleAlias = null; UIValidationRuleGroup uiValidationRuleGroupAlias = null; UIValidationRuleGroupPrecard uiValidationRuleGroupPrecardAlias = null; const string requestSubstituteUIValidationRuleCode = "33"; BPerson bPerson = new BPerson(); BUIValidationGroup bUIValidationGroup = new BUIValidationGroup(); UIValidationRuleGroup RuleGroup = new UIValidationRuleGroup(); JavaScriptSerializer JsSerializer = new JavaScriptSerializer(); NHibernate.IQueryOver <UIValidationRuleGroup, UIValidationRuleGroup> uiValidationRuleGroup = null; if (request != null && request.Person != null && request.Person.ID != 0) { person = NHSession.QueryOver <Person>() .Where(x => x.ID == request.Person.ID) .SingleOrDefault(); if (person != null && person.PersonTASpec != null && person.PersonTASpec.UIValidationGroup != null) { uiValidationRuleGroup = this.NHSession.QueryOver <UIValidationRuleGroup>(() => uiValidationRuleGroupAlias) .JoinAlias(() => uiValidationRuleGroupAlias.ValidationGroup, () => uiValidationGroupAlias) .JoinAlias(() => uiValidationRuleGroupAlias.ValidationRule, () => uiValidationRuleAlias) .JoinAlias(() => uiValidationRuleGroupAlias.PrecardList, () => uiValidationRuleGroupPrecardAlias) .JoinAlias(() => uiValidationRuleGroupPrecardAlias.Precard, () => precardAlias) .Where(() => uiValidationGroupAlias.ID == person.PersonTASpec.UIValidationGroup.ID && uiValidationRuleGroupAlias.Active && uiValidationRuleAlias.ExistTag && uiValidationRuleAlias.CustomCode == requestSubstituteUIValidationRuleCode && uiValidationRuleGroupPrecardAlias.Active && precardAlias.ID == request.Precard.ID ); if (request.Person.ID != request.User.Person.ID) { RuleGroup = uiValidationRuleGroup.Where(x => uiValidationRuleGroupPrecardAlias.Operator).SingleOrDefault(); } else { RuleGroup = uiValidationRuleGroup.SingleOrDefault(); } if (RuleGroup != null && RuleGroup.Tag != null && RuleGroup.Tag != string.Empty) { R33_UiValidationRuleTagValueProxy r33_UiValidationRuleTagValueProxy = JsSerializer.Deserialize <R33_UiValidationRuleTagValueProxy>(RuleGroup.Tag); if (r33_UiValidationRuleTagValueProxy.IsForceConfirmByRequestSubstitute) { requestSubstitute = new RequestSubstitute(); requestSubstitute.Request = request; requestSubstitute.SubstitutePerson = request.SubstitutePerson; requestSubstitute.OperationDate = DateTime.Now; this.SaveChanges(requestSubstitute, UIActionType.ADD); } } } NHSession.Evict(person); } } catch (Exception ex) { BaseBusiness <RequestSubstitute> .LogException(ex, "BRequestSubstitute", "InsertRequestSubstitute"); throw ex; } }