예제 #1
0
        public string Series(SequenceContext data)
        {
            var result = Handle(data);

            result = result ?? string.Empty;
            if (PaddingSide == PaddingSide.Left && PaddingWidth > 0)
            {
                if (PaddingChar == char.MinValue)
                {
                    throw new Exception(string.Format("取得Sequence[{0}]处理中未设置填充的字符", data.SequenceName));
                }

                result = result.PadLeft(PaddingWidth, PaddingChar);
            }
            else if (PaddingSide == PaddingSide.Right && PaddingWidth > 0)
            {
                if (PaddingChar == char.MinValue)
                {
                    throw new Exception(string.Format("取得Sequence[{0}]处理中未设置填充的字符", data.SequenceName));
                }

                result = result.PadRight(PaddingWidth, PaddingChar);
            }

            return(result);
        }
예제 #2
0
        public string Dependency(SequenceContext context)
        {
            var result = DateTime.Now.ToString("yyyyMMdd HH:mm");

            if (result != context.CurrentReset)
            {
                //重置规则
                context.CurrentNo = 0;
            }
            context.CurrentReset = result;
            return(result);
        }
예제 #3
0
        public string Handle(SequenceContext data)
        {
            if (!data.row.ContainsKey("ArtNo"))
                throw new Exception("缺少参数ArtNo");

            if (!data.row.ContainsKey("Color"))
                throw new Exception("缺少参数Color");

            if (!data.row.ContainsKey("Size"))
                throw new Exception("缺少参数Size");

            var list = new List<string>();
            list.Add(data.row["ArtNo"].ToString());
            list.Add(data.row["Color"].ToString());
            list.Add(data.row["Size"].ToString());

            return string.Join("-", list);
        }
예제 #4
0
        protected override string Handle(SequenceContext data)
        {
            if (handler == null)
            {
                var type = Type.GetType(RuleValue);
                if (type == null)
                {
                    throw new Exception(string.Format("取得Sequence[{0}]函数处理规则中类名设置不正确", data.SequenceName));
                }

                if (type.GetInterface("IClassSequenceHandler") == null)
                {
                    throw new Exception(string.Format("取得Sequence[{0}]函数处理{0}未实现接口IClassSequenceHandler", type.Name));
                }

                handler = (IClassSequenceHandler)Activator.CreateInstance(type);
            }

            return(handler.Handle(data));
        }
예제 #5
0
 /// <summary>
 /// 具体的规则处理
 /// </summary>
 /// <param name="data"></param>
 /// <returns></returns>
 protected abstract string Handle(SequenceContext data);
예제 #6
0
        protected override string Handle(SequenceContext data)
        {
            var result = DateTime.Now.ToString(RuleValue);

            return(result);
        }
예제 #7
0
 public Sequence(string name)
 {
     _context              = new SequenceContext();
     _context.TenantID     = "";
     _context.SequenceName = name;
 }
예제 #8
0
 protected override string Handle(SequenceContext data)
 {
     return(Guid.NewGuid().ToString(RuleValue));
 }