Пример #1
0
        static string GenerateMasterID(string ConfigKey, int Length)
        {
            KeyValuePair <string, string> kvp = ConfigTemplateModel.Configurations.FirstOrDefault(m => m.Key == ConfigKey);
            int           value = string.IsNullOrEmpty(kvp.Key) || string.IsNullOrEmpty(kvp.Value) ? 1 : int.Parse(kvp.Value) + 1;
            StringBuilder sb    = new StringBuilder();

            for (int i = 0; i < Length; i++)
            {
                sb.Append("0");
            }
            sb.Append(value.ToString());
            string s = sb.ToString().Substring(sb.Length - Length, Length);

            ConfigTemplateModel.AppendConfig(ConfigKey, value.ToString());
            return(s);
        }