Dismiss Notice
We would like to remind you that we’re updating our login process for all 3CX forums whereby you will be able to login with the same credentials you use for the Partner or Customer Portal. Click here to read more.

Write to File / SQL / Shell Scripts

Discussion in 'Call Flow Designer' started by Josh Dinsdale, Oct 24, 2017.

Thread Status:
Not open for further replies.
  1. Josh Dinsdale

    Joined:
    Oct 11, 2017
    Messages:
    11
    Likes Received:
    0
    Hi Guys

    Firstly, I am using 3CX debian version.

    In preparation for our move away from Askozia to 3CX i am currently trying to rewrite a custom app i wrote in Askozias Call Flow Editor in 3CX's CFD.

    The old system uses a txt file to store a variable, the call flow overwrites that file when it is accessed, which updates the contents to the new variable.

    My plan was to replicated this with the Read / Write file function. I dont want to append the file, but overwrite it each time and am trying to do this by changing the 'Open Mode' to 'CreateNew'. However this seems to write the file once (if it doesnt already exist), but then doesnt seem to over write it after that.
    I have permissions correctly setup (i've actually set them to 777 for testing).

    Any ideas on that?

    My next approach was to think oh hell, lets rewrite this properly using SQL, but then i discovered that MySQL isnt supported, only PostGres or MSSQL. We have a MySQL infrastructure setup that i would like to have used, but I guess it looks like that idea is out of the window?

    Also, are you planning to build in any functionality to run shell scripts on debian installs? I probably could have uses this as another mechanism to make it work..?

    Thanks :)
     
  2. edossantos

    edossantos Support Team
    Staff Member 3CX Support

    Joined:
    Jun 27, 2007
    Messages:
    1,600
    Likes Received:
    125
    Hello @Josh Dinsdale,

    In first place, please take a look at the following article explaining how to troubleshoot CFD apps issues:
    https://www.3cx.com/docs/manual/cfd-troubleshooting/

    Regarding the file override issue, I think that the problem is that you're using the "CreateNew" mode, which will only create the file if it doesn't exist, otherwise an IOException is thrown, as explained here:
    https://msdn.microsoft.com/en-us/library/system.io.filemode(v=vs.110).aspx

    For sure the 3CXQueueManager.log file will have the exception described above.

    What you need to use is the mode "Create", as explained in the same article above.


    RE MySQL, unfortunately it is not supported. However, you can use a Launch External Script component to run your own C# .NET Core code, and from there you can connect to MySQL and run your query. But in this case you will not be using the Database Access component.

    And regarding running shell scripts, that's also something that you can do using the Launch External Script component. You just need to call "Process.Start", for example as explained here:
    https://loune.net/2017/06/running-shell-bash-commands-in-net-core/

    Hope the information helps.

    Kind regards.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
    Josh Dinsdale likes this.
  3. Josh Dinsdale

    Joined:
    Oct 11, 2017
    Messages:
    11
    Likes Received:
    0
    Thanks edossantos, changing to 'create' did the trick! :)
     
Thread Status:
Not open for further replies.