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);
        }
Exemple #2
0
        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;
            }
        }