public UiValidationRulePrecardParamProxy GetRulePrcardParamValue(UIValidationRulePrecardProxy rulePrecard, IList <UIValidationRuleParameterProxy> RuleParametersList) { UiValidationRulePrecardParamProxy rulePrecardParam = new UiValidationRulePrecardParamProxy(); if (rulePrecard != null) { rulePrecardParam.ID = rulePrecard.ID; rulePrecardParam.PrecardID = rulePrecard.PrecardID; rulePrecardParam.Active = rulePrecard.Active; rulePrecardParam.Operator = rulePrecard.Operator; rulePrecardParam.ExistPrecard = rulePrecard.ExistPrecard; } else { if (rulePrecard == null && RuleParametersList.Count != 0) { UIValidationRuleGroupPrecard ruleGroupPrecard = new UIValidationRuleGroupPrecard(); ruleGroupPrecard = RuleParametersList.Select(x => x.RuleGroupPrecard).FirstOrDefault(); rulePrecardParam.ID = 0; rulePrecardParam.PrecardID = 0; rulePrecardParam.Active = true; rulePrecardParam.ExistPrecard = 0; rulePrecardParam.Operator = ruleGroupPrecard.Operator; } //else //{ // rulePrecardParam.PrecardID = -1; //} } if (RuleParametersList != null && RuleParametersList.Count != 0) { rulePrecardParam.ObjRuleParams = new List <UiValidationRuleParamProxy>(); foreach (UIValidationRuleParameterProxy ruleParameter in RuleParametersList) { if (ruleParameter.ExistParam == 1) { UiValidationRuleParamProxy ruleParam = new UiValidationRuleParamProxy(); ruleParam.ID = ruleParameter.ID; ruleParam.ParamID = ruleParameter.ParamID; ruleParam.KeyName = ruleParameter.KeyName; ruleParam.ExistParam = ruleParameter.ExistParam; ruleParam.ParameterValue = ruleParameter.ParameterValue; ruleParam.ContinueOnTomorrow = ruleParameter.ContinueOnTomorrow; ruleParam.ParamType = ruleParameter.ParamType; rulePrecardParam.ObjRuleParams.Add(ruleParam); } } } //} return(rulePrecardParam); }
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; } }