Exemplo n.º 1
0
        public void ProcessRequest(HttpContext context)
        {
            try
            {
                string           key    = context.Request.Params["key"] ?? string.Empty;
                PrimaryKeyEntity entity = null;
                if (string.IsNullOrWhiteSpace(key))
                {
                    entity      = new PrimaryKeyEntity();
                    entity.Type = 1;
                }
                else
                {
                    key    = CryptHelper.DESDecode(key);
                    entity = JsonHelper.Deserialize <PrimaryKeyEntity>(key);
                }

                string id = string.Empty;

                lock (client)
                {
                    PrimaryKeyProvider provider = (PrimaryKeyProvider)client.Get("PrimaryKeyProvider");
                    id = provider.Get(entity);
                }

                context.Response.Write(id);
            }
            catch (Exception ex)
            {
                LogHelper.Log4Net.Error(ex.Message);
                context.Response.Write(string.Empty);
            }
        }
        public string Get(PrimaryKeyEntity entity)
        {
            if (provider.ContainsKey(entity.Type))
            {
                return(provider[entity.Type].Get(entity));
            }

            return(string.Empty);
        }
Exemplo n.º 3
0
        public override string Get(PrimaryKeyEntity entity)
        {
            MemcachedClient client = new MemcachedClient();

            if (client.KeyExists(entity.Prefix))
            {
                long id = client.Increment(entity.Prefix, 1);
                return(string.Format("{0}{1}",
                                     entity.IsMustPrefix ? entity.Prefix : string.Empty,
                                     entity.IsMustFillWithChar ? id.ToString().PadLeft(entity.NumberLength, entity.FillChar) : id.ToString()));
            }
            else
            {
                return(string.Empty);
            }
        }
Exemplo n.º 4
0
        internal void Apply()
        {
            PrimaryKeyEntity.AddDependentRelationship(
                new EntityRelationship(
                    Name,
                    OnDeleteCascade,
                    OnDeleteSetNull,
                    ForeignKeyEntity,
                    References.Select(r => new EntityReference(r.PrimaryKeyProperty, r.ForeignKeyProperty))));

            ForeignKeyEntity.AddPrincipalRelationship(
                new EntityRelationship(
                    Name,
                    OnDeleteCascade,
                    OnDeleteSetNull,
                    PrimaryKeyEntity,
                    References.Select(r => new EntityReference(r.ForeignKeyProperty, r.PrimaryKeyProperty))));
        }
Exemplo n.º 5
0
        public override string Get(PrimaryKeyEntity entity)
        {
            if (string.IsNullOrWhiteSpace(entity.Prefix))
            {
                return(string.Empty);
            }
            long            i      = 0;
            MemcachedClient client = new MemcachedClient();

            if (client.KeyExists(entity.Prefix))
            {
                i = (long)client.Get(entity.Prefix);
            }

            i = client.Increment(entity.Prefix, 1);

            string id = string.Format("{0}{1}{2}",
                                      entity.IsMustPrefix ? entity.Prefix : string.Empty,
                                      DateTime.Now.ToString("yyyyMMdd"),
                                      entity.IsMustFillWithChar ? i.ToString().PadLeft(entity.NumberLength, entity.FillChar) : i.ToString());

            return(id);
        }
Exemplo n.º 6
0
 public override string Get(PrimaryKeyEntity entity)
 {
     return(string.Format("{0}{1}",
                          entity.IsMustPrefix ? entity.Prefix : string.Empty,
                          DateTime.Now.ToString("yyyyMMddHHmmssfff")));
 }
Exemplo n.º 7
0
 public override string Get(PrimaryKeyEntity entity)
 {
     return(string.Format("{0}{1}",
                          entity.IsMustPrefix ? entity.Prefix : string.Empty,
                          Guid.NewGuid().ToString()));
 }
Exemplo n.º 8
0
 public virtual string Get(PrimaryKeyEntity entity)
 {
     return(string.Empty);
 }