//static public string GenerateCode(string prefix = "", byte subscriptionID = 0, int length = 6) //{ // var service = new CoderService(36); // string codePrefix = String.IsNullOrEmpty(prefix) ? "" : (prefix.TrimEnd('-') + "-"); // string codeSubscr = subscriptionID <= 0 ? "" : (subscriptionID.ToString() + "-"); // if (String.IsNullOrEmpty(codePrefix) && !String.IsNullOrEmpty(codeSubscr)) // codeSubscr = "S" + codeSubscr; // string codeDate = service.Encode(CommonService.Now.DateTime); // string codeRandom = service.Generate(length <= 0 ? 6 : length); // return String.Format("{0}{1}{2}-{3}", codePrefix, codeSubscr, codeDate, codeRandom); //} public static 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); }