Exemplo n.º 1
0
        /// <inheritdoc />
        public string Execute(IBizCodeFactoryContext context, string parameterValue)
        {
            var items = parameterValue.Split('/');

            var format   = items[1];
            var isRandom = items[0].Equals("false", StringComparison.CurrentCultureIgnoreCase);

            if (isRandom)
            {
                var newNo = RandomHelper.GetRandom();
                while (newNo == context.CurrentRuleInfo.CurrentNo)
                {
                    newNo = RandomHelper.GetRandom();
                }

                context.CurrentRuleInfo.CurrentNo = newNo;
            }
            else
            {
                if (context.CurrentRuleInfo.LastFactoryDate.HasValue)
                {
                    var lastResetDate = context.CurrentRuleInfo.LastFactoryDate.Value.ToString(context.CurrentRuleInfo.ResetDateFormat);
                    if (DateTime.UtcNow.ToString(context.CurrentRuleInfo.ResetDateFormat) != lastResetDate)
                    {
                        context.CurrentRuleInfo.CurrentNo = 0;
                    }
                }

                context.CurrentRuleInfo.CurrentNo += (context.CurrentRuleInfo.NoStep ?? 1);
            }

            var result = context.CurrentRuleInfo.CurrentNo;

            return(result.ToString(format));
        }
 public BizCodeFactory(IBizCodeFactoryContext context)
 {
     Context = context;
 }
        /// <inheritdoc />
        public string Execute(IBizCodeFactoryContext context, string parameterValue)
        {
            var result = DateTime.UtcNow.ToString(parameterValue);

            return(result);
        }
        /// <inheritdoc />
        public string Execute(IBizCodeFactoryContext context, string parameterValue)
        {
            var result = parameterValue;

            return(result);
        }
Exemplo n.º 5
0
        /// <inheritdoc />
        public string Execute(IBizCodeFactoryContext context, string parameterValue)
        {
            var result = Guid.NewGuid().ToString(parameterValue);

            return(result);
        }
        /// <inheritdoc />
        public string Execute(IBizCodeFactoryContext context, string parameterValue)
        {
            var result = context.GetVariable(parameterValue).ToString();

            return(result);
        }