public Dictionary <long, string> GetNumberingObjectPrefixes() { var nop = new Dictionary <long, string>(); using (DbManagerProxy manager = DbManagerFactory.Factory.Create(ModelUserContext.Instance)) { try { DataTable dt = manager.SetSpCommand("dbo.spGetNextNumberPrefixes").ExecuteDataTable(); //ToDictionary(kv => Convert.ToInt64(kv.Key), kv => Utils.Str(kv.Value)) if ((dt != null) && (dt.Rows.Count > 0)) { nop = dt.AsEnumerable().ToDictionary <DataRow, long, string>(row => Convert.ToInt64(row["idfsNumberName"]), row => Utils.Str(row["strPrefix"])); } foreach (var num in NumberingObjectEnum.GetValues(typeof(NumberingObjectEnum))) { if (!nop.ContainsKey((long)num)) { nop.Add((long)num, string.Empty); } } return(nop); } catch (DataException e) { throw DbModelException.Create(null, e); } } }
/// Gets readable identifier consisting of object prefix, server-specific prefix (i.e. WEB00), last two digits of current year, /// extra specific character taken from config settings (if needed in accordance with config settings), /// and long number converted into alphanumeric string. /// <param name="obj">Numbering Object to identify prefix</param> /// <param name="id">Numeric system unique identifier of the object instance</param> /// <param name="digitsCount">Minumum number of characters of alphanumeric part of the readable identifier</param> /// <returns>Returns string value with readable identifier based on input parameters. If numeric id is less or equal to 0, returns empty string</returns> public static string GetReadableIdentifier(NumberingObjectEnum obj, long id, int digitsCount = 4) { var objPrefix = string.Empty; if (EidssSiteContext.Instance.NumberingObjectPrefixes.ContainsKey((long)obj)) { objPrefix = EidssSiteContext.Instance.NumberingObjectPrefixes[(long)obj]; } return(GetReadableIdentifier(objPrefix, id, digitsCount)); }