Ejemplo n.º 1
0
        static public string GenerateEntityCode(string prefix = "", int length = 8)
        {
            var service = new CoderService(36);

            string codePrefix = String.IsNullOrEmpty(prefix) ? "" : (prefix.TrimEnd('-') + "-");

            string codeDate = service.Encode(CommonService.Now.DateTime);

            string codeRandom = service.Generate(length <= 0 ? 8 : length);

            return(String.Format("{0}{1}-{2}", codePrefix, codeDate, codeRandom));
        }