Jump to content

Psypher

Member
  • Content Count

    5
  • Joined

  • Last visited

Community Reputation

0 Neutral

About Psypher

  • Rank
    Newbie
  1. Hi Tom. Now I had time to check it out and test the code more. Yes, that would be worse performance-wise and too complex compared to a constant in the script. I just wanted to avoid that, so the adaptation and setting up for the script to use in different situations would be easier (especially for other persons than me) and to avoid errors. It isn't really a requirement, but more nice-to-have, good practice and smoother. If it is just well-documented in the code, in the modules and in paper documentation, then it is all good. I can use it now and maybe later get an epiphany with a smarter solution. I am still learning, so the CDR specification and constantly inspecting the database for how it behaves in different scenarios, is a great help and suddenly inspires to new and better approaches. Thanks a lot, Tom. Best regards Kasper S.
  2. Hi Tom. Thanks for the quick response time! 🙂 Yeah, I get that the CDR is for that, but I thought that maybe there was a function, constant, etc. that could retrieve the "main telephone number", so I could filter all those calls away. It could of course be made with a hardcoded global variable in the beginning of the script - like sMainNumber = "+4580801000" and then use it in the SQL-statement, but I guess we both can agree that it is a BAD solution! I actually came to the same solution, as you wrote, like 5 minutes before leaving work, so I changed it to use ConnectDate, but only got to test it with two scenarios. I will first be back and able to try it out for real in next week, but I feel confident, that this is the right way to do it. Thanks. Kasper S.
  3. Hello again. I am trying to check, if an incoming call has been made from the same telephone number in the last 60 minutes and if it was transferred/connected successfully to a user. If so, it will be transferred to the same user who received the previous call. I therefore have to filter all the calls to the "main telephone number" away and only have the calls that was received by a user left. I have looked through a lot of the ressources since last post and have read the CDR specification and also tried to observe the behavior in the CDR database for a multiple of scenarios. I have thought 3 times, that I had the right parameters to check for, but only to realise that in certain conditions they didn't behave like I thought. I have tried something like this: "SELECT TOP 1 DestinationNumber FROM IpPbxCDR WHERE OriginationNumber = '+4520321345' AND DATEDIFF(minute, StartTime, GETDATE()) < 60 AND State = 'Connected' AND DeliveredDate IS NOT NULL ORDER BY StartTime DESC;". I have since realized that it is not right to check the State and DeliveredDate, even though it looked that way for some time and some tests. There might be something useful built-in functions that I ain't aware of or a much simpler and more logical parameter to check for, that I just can't get my head around at the moment - can anybody enlighten me? Kind Regards Kasper S. PS. the ECR manual ( http://www.swyxdownload.com/download/Swyx_ECR_english.pdf ) is wrongfully stating "SwyxWare Documentation for administrators As of: August 2018" on the first page.
  4. Hello Tom. I was away from job and have been occupied moving in private. I read your good replies the day you posted them, but was first able to reply now - sorry about that, they are much appreciated. I updated my code with all your advices (I hope) and with a little errorhandling and logging. It now look like this: Const sTimeIntervalForRecall = "60" Dim sNumberToRedirectTo Function bCallerCalledBefore() On Error Resume Next bCallerCalledBefore = False ' Define Connectionstring Dim sDsn sDsn = "Driver={SQL Server Native Client 11.0};Server=.\SQLExpress;Database=IpPbxCDR;User Id=CDR;Password=CDR;" ' Open connection to database Dim db Set db = CreateObject("ADODB.Connection") db.Open(sDsn) If Err <> 0 Then PBXScript.OutputTrace "FEJL (" & Err & "): " & Err.Description Exit Function End If Err.Clear ' Open recordset Dim sSQL sSQL = "SELECT TransferredToCallId FROM IpPbxCDR WHERE OriginationNumber = '" & CallerNumber() & "' AND DATEDIFF(minute, StartTime, GETDATE()) < " & sTimeIntervalForRecall & " ORDER BY StartTime DESC;" Dim rs Set rs = db.Execute(sSQL) If rs.BOF = False And rs.EOF = False Then bCallerCalledBefore = True sNumberToRedirectTo = rs("TransferredToCallId") PBXScript.OutputTrace "OMSTILLER TIL NUMMER: " & sNumberToRedirectTo End If rs.Close() rs = Nothing db.Close() db = Nothing End Function It still feels like a little steep learning curve and still some trial and error, but with logging and better errordescriptions I hope I am on my way. The SQL actually worked with the + instead of &, but I changed it and will try to remember that syntax. I also have to look more into all the ressources in the ECR Useful Link Collection. Thanks a lot. Kind regards Kasper S.
  5. Hello Swyx users! I am new to Swyx and have had a hard time trying to understand the basics and how everything is connected. My main focus is the GSE and writing scripts. I havn't really found a good way to view code (using Visual Studio some of the time, but I always have to adapt the code to work in GSE) and the syntax in general feels a lot like trial and error and have been taken A LOT of time. My testing at the moment is changing something and calling the number to see if it works or if the line is busy (failing) and then checking the relative sparse information in the Event Viewer and trying some new code. I am trying to make a function that checks if a caller have been calling before within X minutes and if so, it should redirect the call to the last person the caller spoke to. My code is looking like this: Const sTimeIntervalForRecall = "60" 'On Error Resume Next Function bCallerCalledBefore() bCallerCalledBefore = False ' Define Connectionstring Dim sDsn sDsn = "Driver={SQL Server Native Client 11.0};Server=.\SQLExpress;Database=IpPbxCDR;User Id=CDR;Password=CDR;" ' Open connection to database Dim db Set db = CreateObject("ADODB.Connection") db.Open(sDsn) ' Open recordset Dim sSQL sSQL = "SELECT CallId, StartTime, DATEDIFF(minute, StartTime, GETDATE()) FROM IpPbxCDR WHERE OriginationNumber = '" + CallerNumber() + "' AND DATEDIFF(minute, StartTime, GETDATE()) < " + sTimeIntervalForRecall + " ORDER BY StartTime DESC;" Dim rs 'Set rs = CreateObject("ADODB.Recordset") Set rs = db.Execute(sSQL) If rs.BOF = False And rs.EOF = False Then bCallerCalledBefore = True End If End Function The code is mostly made of syntax that was accepted and not necessarily the best practice. I also tried to add some try-catch and On Error GoTo, but without any success. I am interesting in both ressources, best practice, info, tools, work procedures, etc. that could make my problematic and slow work procedure much easier and faster. Kind Regards Kasper S.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use and have taken note of our Privacy Policy.
We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.