Allow normal user to access (read only) tblParameter programatically?

Hi all,

I store data on tblParameter (in config database) because this data need to be accessed from multiple companies. the problem is, only admin user can access this tblParameter. How can I allow normal user to access (read only) to this tblParameter?

  • 0

    i would have thought that using the Sage200Configuration database was not a supported thing to do.

    If it was me, i would create a seperate database, and store what i want in there, or in an XML/ini file in the Sage share.

  • 0 in reply to Toby

    I have created a separate database, and I store the credential in tblParameters because this table can be accessed by multiple companies.

    If I store it in XML/ini file, what is the default Sage share folder path looks like?

  • 0 in reply to murni

    or how do I get the Sage share folder programmatically?

  • 0 in reply to murni

    if i recall its something like sage.accounting.application.rootpath.

    but i'm away from the office and can't check exactly

  • 0 in reply to Toby

    Out of interest, how are you reading tblParameters - I wasn't aware it was possible to access the configuration database directly.

  • 0 in reply to Geoff Turner

    this is how I read tblParameters

    if (SrvcAcc.ParametersGetList(null, out parametersList))
    {
        return;
    }
    
    this.parameters = new Dictionary<string, ParameterItem>();
    if (parametersList.tblParameters != null && parametersList.tblParameters.Rows.Count > 0)
    {
        foreach (ParametersList.tblParametersRow tblParameter in parametersList.tblParameters)
        {
            ParameterItem parameterItem = new ParameterItem()
            {
                ParameterName = tblParameter.ParameterName,
                ParameterValue = tblParameter.ParameterValue
            };
            this.parameters.Add(tblParameter.ParameterName, parameterItem);
        }
    }

    This is how I write to tblParameters

    ParametersList.tblParametersRow parameterName = parametersList.tblParameters.NewtblParametersRow();
    parameterName.ParameterName = value.ParameterName;
    parameterName.ParameterValue = value.ParameterValue;
    parametersList.tblParameters.AddtblParametersRow(parameterName);
    SrvcAcc.ParametersUpdate(null, parametersList);

  • 0 in reply to murni

    I guess SvrcAcc is a direct SQL connection to the configuration database, not a Sage object of any kind then?

  • 0 in reply to Geoff Turner

    SvrAcc is a Sage object, is coming from Sage.MMSAdmin.Kernel

  • 0 in reply to Geoff Turner

    Maybe I should add the whole class here so you can see where the object coming from. I use mainly Sage.MMSAdmin objects for this

    using Sage.MMSAdmin.DBSchema.Others;
    using Sage.MMSAdmin.Kernel;
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    
    namespace CustomApp.Business
    {
        public class TblParametersBusiness
        {
            public Dictionary<string, ParameterItem> parameters;
    
            public TblParametersBusiness() { }
    
            public void Reload()
            {
                ParametersList parametersList = null;
                try
                {
                    if (SrvcAcc.ParametersGetList(null, out parametersList))
                    {
                        return;
                    }
                    
                    this.parameters = new Dictionary<string, ParameterItem>();
                    if (parametersList.tblParameters != null && parametersList.tblParameters.Rows.Count > 0)
                    {
                        foreach (ParametersList.tblParametersRow tblParameter in parametersList.tblParameters)
                        {
                            ParameterItem parameterItem = new ParameterItem()
                            {
                                ParameterName = tblParameter.ParameterName,
                                ParameterValue = tblParameter.ParameterValue
                            };
                            this.parameters.Add(tblParameter.ParameterName, parameterItem);
                        }
                    }
                }
                catch(Exception ex)
                {
                    //print ex
                }
                
            }
    
            public void Save()
            {
                ParametersList parametersList = new ParametersList();
                foreach (ParameterItem value in this.parameters.Values)
                {
                    if (!value.Modified)
                    {
                        continue;
                    }
                    ParametersList.tblParametersRow parameterName = parametersList.tblParameters.NewtblParametersRow();
                    parameterName.ParameterName = value.ParameterName;
                    parameterName.ParameterValue = value.ParameterValue;
                    parametersList.tblParameters.AddtblParametersRow(parameterName);
                }
                if (parametersList.tblParameters.Rows.Count > 0)
                {
                    SrvcAcc.ParametersUpdate(null, parametersList);
                }
            }
    
        }
        public class ParameterItem
        {
            private string _strParameterName;
    
            private string _strParameterValue;
    
            private bool _bModified;
    
            public bool Modified
            {
                get
                {
                    return this._bModified;
                }
                set
                {
                    this._bModified = value;
                }
            }
    
            public string ParameterName
            {
                get
                {
                    return this._strParameterName;
                }
                set
                {
                    this._strParameterName = value;
                }
            }
    
            public string ParameterValue
            {
                get
                {
                    return this._strParameterValue;
                }
                set
                {
                    this._strParameterValue = value;
                }
            }
    
            public ParameterItem()
            {
            }
            public ParameterItem(string parametername, string valuepassed, Boolean modified)
            {
                this._strParameterName = parametername;
                this._strParameterValue = valuepassed;
                this._bModified = true;
            }
        }
    }
    

  • 0 in reply to Toby

    thank you., it is correct. use Sage.Accounting.Application.RootPath to access the Sage share folder