Ejemplo n.º 1
0
        /// <summary>
        /// 新增序号管理
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        public int Init()
        {
            DataTable table = this.Sequence.GetTables();

            if (table != null && table.Rows.Count > 0)
            {
                foreach (DataRow row in table.Rows)
                {
                    string TabName = row["name"] != null ? row["name"].ToString() : string.Empty;
                    if (!TabName.IsEmpty())
                    {
                        SequenceEntity entity = new SequenceEntity();
                        entity.Where(a => a.TabName == TabName);
                        if (this.Sequence.GetCount(entity) == 0)
                        {
                            entity             = new SequenceEntity();
                            entity.SN          = TNumProivder.CreateGUID();
                            entity.TabName     = TabName;
                            entity.FirstType   = (int)ESequence.Sequence;
                            entity.FirstRule   = "";
                            entity.FirstLength = 6;
                            entity.JoinChar    = "";
                            entity.IncludeAll();
                            this.Sequence.Add(entity);
                        }
                    }
                }
            }
            return(0);
        }
Ejemplo n.º 2
0
        public ActionResult Sequence()
        {
            string       TabName   = WebUtil.GetFormValue <string>("TabName", string.Empty);
            string       Day       = WebUtil.GetFormValue <string>("Day", "");
            int          PageIndex = WebUtil.GetFormValue <int>("PageIndex", 1);
            int          PageSize  = WebUtil.GetFormValue <int>("PageSize", 10);
            TNumProivder provider  = new TNumProivder();
            TNumEntity   entity    = new TNumEntity();

            if (!TabName.IsEmpty())
            {
                entity.Where("TabName", ECondition.Like, "%" + TabName + "%");
            }
            if (!Day.IsEmpty())
            {
                entity.Where(a => a.Day == Day);
            }
            PageInfo pageInfo = new PageInfo()
            {
                PageIndex = PageIndex, PageSize = PageSize
            };
            List <TNumEntity> listResult = provider.GetList(entity, ref pageInfo);

            listResult = listResult.IsNull() ? new List <TNumEntity>() : listResult;
            string json = JsonConvert.SerializeObject(listResult);

            this.ReturnJson.AddProperty("Data", json);
            this.ReturnJson.AddProperty("RowCount", pageInfo.RowCount);
            return(Content(this.ReturnJson.ToString()));
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 获得表的序列号
        /// </summary>
        /// <returns></returns>
        public static string GetSequence(Type type)
        {
            Func<int, string, int, string> Func = (int SequenceType, string SequenceRule, int SequenceLength) =>
            {
                string value = string.Empty;
                if (SequenceType > 0)
                {
                    if (SequenceType == (int)ESequence.Constant)
                    {
                        value = SequenceRule;
                    }
                    else if (SequenceType == (int)ESequence.Guid)
                    {
                        value = TNumProivder.CreateGUID();
                    }
                    else if (SequenceType == (int)ESequence.CustomerTime)
                    {
                        value = DateTime.Now.ToString(SequenceRule);
                    }
                    else if (SequenceType == (int)ESequence.Sequence)
                    {
                        if (SequenceLength == 0)
                        {
                            value = new TNumProivder().GetSwiftNum(type);
                        }
                        else
                        {
                            value = new TNumProivder().GetSwiftNum(type, SequenceLength);
                        }
                    }
                    else if (SequenceType == (int)ESequence.SequenceOfDay)
                    {
                        if (SequenceLength == 0)
                        {
                            value = new TNumProivder().GetSwiftNumByDay(type);
                        }
                        else
                        {
                            value = new TNumProivder().GetSwiftNumByDay(type, SequenceLength);
                        }
                    }
                }
                return value;
            };

            TableInfo tableInfo = EntityTypeCache.Get(type);
            string TabName = tableInfo.Table.Name;
            SequenceProvider provider = new SequenceProvider();
            SequenceEntity entity = provider.GetSingle(TabName);

            string result = string.Empty;
            if (entity != null)
            {
                List<string> list = new List<string>();
                if (entity.FirstType > 0)
                {
                    list.Add(Func(entity.FirstType, entity.FirstRule, entity.FirstLength));
                }
                if (entity.SecondType > 0)
                {
                    list.Add(Func(entity.SecondType, entity.SecondRule, entity.SecondLength));
                }
                if (entity.ThirdType > 0)
                {
                    list.Add(Func(entity.ThirdType, entity.ThirdRule, entity.ThirdLength));
                }
                if (entity.FourType > 0)
                {
                    list.Add(Func(entity.FourType, entity.FourRule, entity.FourLength));
                }
                result = string.Join(entity.JoinChar, list.ToArray());
            }
            else
            {
                result = TNumProivder.CreateGUID();
            }
            return result;
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 获得表的序列号
        /// </summary>
        /// <returns></returns>
        public static string GetSequence(Type type)
        {
            Func <int, string, int, string> Func = (int SequenceType, string SequenceRule, int SequenceLength) =>
            {
                string value = string.Empty;
                if (SequenceType > 0)
                {
                    if (SequenceType == (int)ESequence.Constant)
                    {
                        value = SequenceRule;
                    }
                    else if (SequenceType == (int)ESequence.Guid)
                    {
                        value = TNumProivder.CreateGUID();
                    }
                    else if (SequenceType == (int)ESequence.CustomerTime)
                    {
                        value = DateTime.Now.ToString(SequenceRule);
                    }
                    else if (SequenceType == (int)ESequence.Sequence)
                    {
                        if (SequenceLength == 0)
                        {
                            value = new TNumProivder().GetSwiftNum(type);
                        }
                        else
                        {
                            value = new TNumProivder().GetSwiftNum(type, SequenceLength);
                        }
                    }
                    else if (SequenceType == (int)ESequence.SequenceOfDay)
                    {
                        if (SequenceLength == 0)
                        {
                            value = new TNumProivder().GetSwiftNumByDay(type);
                        }
                        else
                        {
                            value = new TNumProivder().GetSwiftNumByDay(type, SequenceLength);
                        }
                    }
                }
                return(value);
            };

            TableInfo        tableInfo = EntityTypeCache.Get(type);
            string           TabName   = tableInfo.Table.Name;
            SequenceProvider provider  = new SequenceProvider();
            SequenceEntity   entity    = provider.GetSingle(TabName);

            string result = string.Empty;

            if (entity != null)
            {
                List <string> list = new List <string>();
                if (entity.FirstType > 0)
                {
                    list.Add(Func(entity.FirstType, entity.FirstRule, entity.FirstLength));
                }
                if (entity.SecondType > 0)
                {
                    list.Add(Func(entity.SecondType, entity.SecondRule, entity.SecondLength));
                }
                if (entity.ThirdType > 0)
                {
                    list.Add(Func(entity.ThirdType, entity.ThirdRule, entity.ThirdLength));
                }
                if (entity.FourType > 0)
                {
                    list.Add(Func(entity.FourType, entity.FourRule, entity.FourLength));
                }
                result = string.Join(entity.JoinChar, list.ToArray());
            }
            else
            {
                result = TNumProivder.CreateGUID();
            }
            return(result);
        }