/// <summary>生成数字编码</summary>
        /// <param name="name">规则名称</param>
        /// <returns>数字编码</returns>
        public string Generate(string name)
        {
            string result = null;

            lock (lockObject)
            {
                DigitalNumberInfo param = FindOne(name);

                if (param == null)
                {
                    throw new Exception(string.Format("未找到相关配置信息,请联系管理员配置相关编号【{0}】参数信息。", name));
                }
                else
                {
                    int seed = param.Seed;

                    result = DigitalNumberScript.RunScript(param.Expression, param.ModifiedDate, ref seed);

                    param.Seed = seed;

                    // 忽略不需要自增的编号和更新时间的编号
                    if (!(DigitalNumberConfigurationView.Instance.IgnoreIncrementSeed.IndexOf(param.Name) > -1 || param.Seed == -1))
                    {
                        Save(param);
                    }

                    return(result);
                }
            }
        }
Beispiel #2
0
        private IDigitalNumberService service = DigitalNumberContext.Instance.DigitalNumberService; // 数据提供器

        // -------------------------------------------------------
        // 保存 删除
        // -------------------------------------------------------

        #region 函数:Save(XmlDocument doc)
        /// <summary>保存记录</summary>
        /// <param name="doc">Xml 文档对象</param>
        /// <returns>返回操作结果</returns>
        public string Save(XmlDocument doc)
        {
            DigitalNumberInfo param = new DigitalNumberInfo();

            param = AjaxUtil.Deserialize <DigitalNumberInfo>(param, doc);

            this.service.Save(param);

            return("{\"message\":{\"returnCode\":0,\"value\":\"查询成功。\"}}");
        }
Beispiel #3
0
        public void TestSave()
        {
            DigitalNumberInfo param = new DigitalNumberInfo();

            param.Name       = "test_" + DateHelper.GetTimestamp();
            param.Expression = "{guid}";
            param.Seed       = 0;

            DigitalNumberContext.Instance.DigitalNumberService.Save(param);
        }
Beispiel #4
0
        // -------------------------------------------------------
        // 保存 添加 修改 删除
        // -------------------------------------------------------

        #region 函数:Save(DigitalNumberInfo param)
        /// <summary>保存记录</summary>
        /// <param name="param"><see cref="DigitalNumberInfo"/> 实例详细信息</param>
        /// <returns><see cref="DigitalNumberInfo"/> 实例详细信息</returns>
        public DigitalNumberInfo Save(DigitalNumberInfo param)
        {
            if (!IsExistName(param.Name))
            {
                Insert(param);
            }
            else
            {
                Update(param);
            }

            return(param);
        }
Beispiel #5
0
        // -------------------------------------------------------
        // 查询
        // -------------------------------------------------------

        #region 函数:FindOne(XmlDocument doc)
        /// <summary>获取分页内容 / get paging.</summary>
        /// <param name="doc">Xml 文档对象</param>
        /// <returns>返回一个相关的实例列表.</returns>
        public string FindOne(XmlDocument doc)
        {
            StringBuilder outString = new StringBuilder();

            string name = XmlHelper.Fetch("name", doc);

            DigitalNumberInfo param = this.service.FindOne(name);

            outString.Append("{\"data\":" + AjaxUtil.Parse <DigitalNumberInfo>(param) + ",");

            outString.Append(MessageObject.Stringify("0", I18n.Strings["msg_query_success"], true) + "}");

            return(outString.ToString());
        }
Beispiel #6
0
        /// <summary>创建新的对象</summary>
        /// <param name="doc">Xml 文档对象</param>
        /// <returns>返回操作结果</returns>
        public string CreateNewObject(XmlDocument doc)
        {
            StringBuilder outString = new StringBuilder();

            DigitalNumberInfo param = new DigitalNumberInfo();

            param.Name = string.Empty;

            param.CreatedDate = param.ModifiedDate = DateTime.Now;

            outString.Append("{\"data\":" + AjaxUtil.Parse <DigitalNumberInfo>(param) + ",");

            outString.Append(MessageObject.Stringify("0", I18n.Strings["msg_create_success"], true) + "}");

            return(outString.ToString());
        }
Beispiel #7
0
 /// <summary>修改记录</summary>
 /// <param name="param"><see cref="DigitalNumberInfo"/> 实例的详细信息</param>
 public void Update(DigitalNumberInfo param)
 {
     this.ibatisMapper.Update(StringHelper.ToProcedurePrefix(string.Format("{0}_Update", tableName)), param);
 }
Beispiel #8
0
        /// <summary>添加记录</summary>
        /// <param name="param"><see cref="DigitalNumberInfo"/> 实例的详细信息</param>
        public void Insert(DigitalNumberInfo param)
        {
            Dictionary <string, object> args = new Dictionary <string, object>();

            this.ibatisMapper.Insert(StringHelper.ToProcedurePrefix(string.Format("{0}_Insert", tableName)), param);
        }
        // -------------------------------------------------------
        // 保存 删除
        // -------------------------------------------------------

        #region 函数:Save(DigitalNumberInfo param)
        /// <summary>保存记录</summary>
        /// <param name="param"><see cref="DigitalNumberInfo"/> 实例详细信息</param>
        /// <returns><see cref="DigitalNumberInfo"/> 实例详细信息</returns>
        public DigitalNumberInfo Save(DigitalNumberInfo param)
        {
            return(this.provider.Save(param));
        }