public int GetSequenceValue(string sysSettingName) { var sequenceMap = new SequenceMap(UserConnection); var sequence = sequenceMap.GetByNameOrDefault(sysSettingName); return(sequence.GetCurrentValue()); }
public string GetIncrementValueVsMask(string sysSettingName, string sysSettingMaskName) { string sysSettingsCodeMask = (string)CoreSysSettings.GetValue(UserConnection, sysSettingMaskName); string result = string.Empty; if (GlobalAppSettings.UseDBSequence) { var sequenceMap = new SequenceMap(UserConnection); var sequence = sequenceMap.GetByNameOrDefault(sysSettingName); result = string.Format(sysSettingsCodeMask, sequence.GetNextValue()); return(result); } var coreSysSettings = new CoreSysSettings(UserConnection); if (coreSysSettings.FetchFromDB("Code", sysSettingName)) { int sysSettingsLastNumber = Convert.ToInt32(CoreSysSettings.GetDefValue(UserConnection, sysSettingName)); ++sysSettingsLastNumber; CoreSysSettings.SetDefValue(UserConnection, sysSettingName, sysSettingsLastNumber); result = string.Format(sysSettingsCodeMask, sysSettingsLastNumber); } return(result); }
/// <summary> /// Returns sequence number. /// </summary> /// <param name="entitySchema">Entity schema.</param> /// <param name="connection">User connection.</param> /// <returns>String that represents a generated sequence number.</returns> public virtual string GenerateSequenseNumber(EntitySchema entitySchema, UserConnection connection) { string entitySchemaName = entitySchema.Name; string codeMaskSettingName = entitySchemaName + "CodeMask"; string lastNumberSettingName = entitySchemaName + "LastNumber"; string sysSettingsCodeMask = string.Empty; var sysSettingsMaskItem = new CoreSysSettings(connection) { UseAdminRights = false, Code = codeMaskSettingName }; if (!sysSettingsMaskItem.FetchFromDB("Code", codeMaskSettingName)) { throw new ItemNotFoundException(codeMaskSettingName); } if (sysSettingsMaskItem.IsPersonal) { sysSettingsCodeMask = (string)CoreSysSettings.GetValue(connection, codeMaskSettingName); } else { sysSettingsCodeMask = (string)CoreSysSettings.GetDefValue(connection, codeMaskSettingName); } if (GlobalAppSettings.UseDBSequence) { var sequenceMap = new SequenceMap(connection); var sequence = sequenceMap.GetByNameOrDefault(lastNumberSettingName); return(string.Format(sysSettingsCodeMask, sequence.GetNextValue())); } int sysSettingsLastNumber = Convert.ToInt32(CoreSysSettings.GetDefValue(connection, lastNumberSettingName)); ++sysSettingsLastNumber; CoreSysSettings.SetDefValue(connection, lastNumberSettingName, sysSettingsLastNumber); return(string.Format(sysSettingsCodeMask, sysSettingsLastNumber)); }