Beispiel #1
0
        /// <summary>
        /// ############# ######## ## ######### ######### #########.
        /// </summary>
        /// <param name="code">### ######### #########.</param>
        /// <param name="value">######## ######### #########.</param>
        private void SetSysSettingsDefValue(string code, object value)
        {
            var sysSettings = new Terrasoft.Core.Configuration.SysSettings(CurrentUserConnection);

            if (sysSettings.FetchFromDB("Code", code))
            {
                Terrasoft.Core.Configuration.SysSettings.SetDefValue(CurrentUserConnection, code, value);
            }
        }
Beispiel #2
0
        public int GetIncrementValue(string sysSettingName)
        {
            var coreSysSettings = new CoreSysSettings(UserConnection);
            int resultValue     = 0;

            if (coreSysSettings.FetchFromDB("Code", sysSettingName))
            {
                int sysSettingsLastNumber = Convert.ToInt32(CoreSysSettings.GetDefValue(UserConnection, sysSettingName));
                ++sysSettingsLastNumber;
                CoreSysSettings.SetDefValue(UserConnection, sysSettingName, sysSettingsLastNumber);
            }
            return(resultValue);
        }
Beispiel #3
0
        public string GetIncrementValueVsMask(string sysSettingName, string sysSettingMaskName)
        {
            string sysSettingsCodeMask = (string)CoreSysSettings.GetValue(UserConnection, sysSettingMaskName);
            var    coreSysSettings     = new CoreSysSettings(UserConnection);
            string result = string.Empty;

            if (GlobalAppSettings.UseDBSequence)
            {
                var sequence = new CaseSequence(UserConnection, sysSettingName);
                result = string.Format(sysSettingsCodeMask, sequence.NextValue());
                return(result);
            }
            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));
        }