More DBWrite and DBRead keys and values

New features you'd like see on SIP Sorcery
Post Reply
jvwelzen
Posts: 716
Joined: Thu Sep 11, 2008 1:56 pm

More DBWrite and DBRead keys and values

Post by jvwelzen » Wed Sep 09, 2009 4:35 pm

Hi

I would like to have more DBWrite and DBRead keys and values to read and write from dialplan

DBWrite(string key, string key1, string value, string value1, string value2)

DBRead(string key, string key1, string value, string value1, string value2)

Is it easy to change the source for myself if so do we only have to change DialPlanScriptHelper.cs or are there more files that we have to change

Thanks in advance

MikeTelis
Posts: 1582
Joined: Wed Jul 30, 2008 6:48 am

Post by MikeTelis » Wed Sep 09, 2009 7:12 pm

Why don't you use a separator and split saved string into as many "value" variables as you need? Check out the "split" method.

jvwelzen
Posts: 716
Joined: Thu Sep 11, 2008 1:56 pm

Post by jvwelzen » Wed Sep 09, 2009 7:41 pm

Please Explain ?

or do you mean this

Code: Select all

case req.URI.User.to_s      
  when /^\*(..)(..*)$/     
    parms = $2.split('*') 
    case $1
For now I am playing with

Code: Select all

res = sys.DBExecuteScalar("MySQL", "Database=sipsorcery;Data Source=127.0.0.1;User Id=username;Password=password", "select * from sipadres where customer = #{sys.Username}")

jack9901
Posts: 277
Joined: Tue Jan 29, 2008 7:30 pm

Post by jack9901 » Wed Sep 09, 2009 11:53 pm

I think Mike meant something like this,

Code: Select all

#Write
sys.DBWrite(name, [value1, value2, ...].join("|||"))  # "|||" or any appropriate separator

#Read
value = sys.DBRead(name).to_s.split("|||")
value1 = value[0]
value2 = value[1]
...
Or with some additions that can facilitate your indexing.

Aaron
Site Admin
Posts: 4652
Joined: Thu Jul 12, 2007 12:13 am

Re: More DBWrite and DBRead keys and values

Post by Aaron » Thu Sep 10, 2009 12:13 am

jvwelzen wrote:Hi

I would like to have more DBWrite and DBRead keys and values to read and write from dialplan

DBWrite(string key, string key1, string value, string value1, string value2)

DBRead(string key, string key1, string value, string value1, string value2)

Is it easy to change the source for myself if so do we only have to change DialPlanScriptHelper.cs or are there more files that we have to change

Thanks in advance
Yes DialPlanScriptHelper.cs is the only class file you would need to modify for that. 99% the dialplan logic and 100% of the dialplan application logic is in the SIPSorcery.AppServer.DialPlan assembly. If you or anyone else want to add or fix existing applications that's the only code you need to understand.

If you do come up with a patch that you want to contribute feel free to submit it http://sipsorcery.codeplex.com/SourceCo ... hList.aspx.

Regards,

Aaron

MikeTelis
Posts: 1582
Joined: Wed Jul 30, 2008 6:48 am

Post by MikeTelis » Thu Sep 10, 2009 1:43 am

Thank you, jack9901, that's exactly what I wanted to say :)

Post Reply