Exemple #1
0
        protected virtual SequenceItem[] GetSequences(ISession session)
        {
            ICriteria            query = session.CreateCriteria(typeof(SequenceItem));
            IList <SequenceItem> items = query.List <SequenceItem>();

            SequenceItem[] result = new SequenceItem[items.Count];
            items.CopyTo(result, 0);
            return(result);
        }
Exemple #2
0
        protected virtual bool RemoveSequence(ISession session, string sequenceId)
        {
            SequenceItem item = session.Get <SequenceItem>(sequenceId);

            if (item != null)
            {
                session.Delete(item);
            }
            return(item != null);
        }
Exemple #3
0
        protected virtual void SetSequence(ISession session, string sequenceId, int value, string rule)
        {
            SequenceItem item = session.Get <SequenceItem>(sequenceId);

            if (item == null)
            {
                item            = new SequenceItem();
                item.SequenceId = sequenceId;
                item.Value      = value;
                item.Rule       = rule;
                item.LastChange = DateTime.Now;
                session.Save(item);
            }
            else
            {
                item.Value      = value;
                item.Rule       = rule;
                item.LastChange = DateTime.Now;
                session.Update(item);
            }
        }
Exemple #4
0
        protected virtual int?GetNext(ISession session, string sequenceId)
        {
            SequenceItem item = session.Get <SequenceItem>(sequenceId);

            if (item == null)
            {
                return(null);
            }

            int result = item.Value;

            ISequenceRule rule;

            if (item.Rule == null || !rules.TryGetValue(item.Rule, out rule))
            {
                rule = standardRule;
            }
            item.Value      = rule.GetNext(result);
            item.LastChange = DateTime.Now;

            session.Update(item);

            return(result);
        }
Exemple #5
0
        protected virtual SequenceItem GetSequence(ISession session, string sequenceId)
        {
            SequenceItem item = session.Get <SequenceItem>(sequenceId);

            return(item);
        }