简体   繁体   中英

Avaya Supervisor CMS extract data from Report and load it into MySQL

IMPORTANT. This is not a correct way of doing this. It's just a quick hack I need to implement. Connecting directly to Avaya DB would be much better. Windows Task Scheduler is to slow. This will only run on local network.

My plan for this quick hack is to:

  1. Login to Avaya CMS Supervisor Version 19.0
  2. Run ".acsauto"
  3. Extract data into.txt

which will look like this:

Some Nice Service Desk
2,Martin Scorsese,8869711,5543711,,AVAIL,0,47,
5,Alfred Hitchcock,8869712,5543732,Default,AUX,0,785,
5,Stanley Kubrick,8869714,5543722,Default,AUXOUT,173,85,
2,Francis Ford Coppola,8869715,5543733,,AVAIL,0,1252,
5,John Huston,8869713,5543743,Default,AUXOUT,173,186,
  1. Finally load it into MySQL 8.0.19 Table:
CREATE TABLE `avaya_live_report` (
    `icon_number` TINYINT unsigned NOT NULL,
    `agent_name` TINYTEXT CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
    `agent_number` INT unsigned NOT NULL,
    `extension` INT unsigned NOT NULL,
    `state_type` TINYTEXT CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
    `state` TINYTEXT NOT NULL,
    `zero` TINYINT unsigned NOT NULL,
    `time` SMALLINT unsigned NOT NULL,
    `empty` TINYTEXT NOT NULL);

As it is impossible to schedule Load Data as a scheduled reacquiring event on MySQL:

LOAD DATA INFILE 'C:\\ProgramData\\MySQL\\MySQL Server 8.0\\Uploads\\live_report.txt' 
INTO TABLE avaya_live_report
FIELDS TERMINATED BY ',' 
LINES TERMINATED BY '\n'
IGNORE 1 LINES;

I need to connect to MySQL directly from.acsauto script:

'LANGUAGE=ENU
'SERVERNAME=SOME_NICE_IP_ADDRESS
Public Sub Main()

'## begin
'## ID = 1000
'## Description = "Report: Real-Time: Agent: Agent Group Report: Export Data"
'## Parameters.Add "Report: Real-Time: Agent: Agent Group Report: Export Data","_Desc"
'## Parameters.Add "Reports","_Catalog"
'## Parameters.Add "2","_Action"
'## Parameters.Add "1","_Quit"
'## Parameters.Add "Real-Time\Agent\Agent Group Report","_Report"
'## Parameters.Add "1","_ACD"
'## Parameters.Add "1335","_Top"
'## Parameters.Add "2580","_Left"
'## Parameters.Add "6930","_Width"
'## Parameters.Add "4575","_Height"
'## Parameters.Add "default","_TimeZone"
'## Parameters.Add "The report Real-Time\Agent\Agent Group Report was not found on ACD 1.","_ReportNotFound"
'## Parameters.Add "*","_BeginProperties"
'## Parameters.Add "Nice Service Desk","Agent Group"
'## Parameters.Add "*","_EndProperties"
'## Parameters.Add "*","_BeginViews"
'## Parameters.Add "*","_EndViews"
'## Parameters.Add "C:\Scripts\live.txt","_Output"
'## Parameters.Add "9","_FldSep"
'## Parameters.Add "0","_TextDelim"
'## Parameters.Add "False","_NullToZero"
'## Parameters.Add "False","_Labels"
'## Parameters.Add "True","_DurSecs"

   On Error Resume Next

   cvsSrv.Reports.ACD = 1
   Set Info = cvsSrv.Reports.Reports("Real-Time\Agent\Agent Group Report")

   If Info Is Nothing Then
      If cvsSrv.Interactive Then
          MsgBox "The report Real-Time\Agent\Agent Group Report was not found on ACD 1.", vbCritical Or vbOKOnly, "Avaya CMS Supervisor"
      Else
          Set Log = CreateObject("ACSERR.cvsLog") 
          Log.AutoLogWrite "The report Real-Time\Agent\Agent Group Report was not found on ACD 1."
          Set Log = Nothing
      End If
   Else

       b = cvsSrv.Reports.CreateReport(Info,Rep)
       If b Then

          Rep.Window.Top = 1335
          Rep.Window.Left = 2580
          Rep.Window.Width = 6930
          Rep.Window.Height = 4575        


                        Rep.TimeZone = "default"



          Rep.SetProperty "Agent Group","Nice Service Desk"

          ' StackOverflow PLEASE START READING HERE
          ' This loop lets me action something and then wait for 30 seconds in a loop
          For i=1 To 10
          ' This line creates this nice comma separated txt file (Using TXT file is a lot faster then CSV)
            b = Rep.ExportData("C:\ProgramData\MySQL\MySQL Server 8.0\Uploads\live_report.txt", 44, 0, True, False, True)

            Dim dteWait
            '30 sek
            dteWait = DateAdd("s", 30, Now())
            Do Until (Now() > dteWait)
            Loop
            Next




          Rep.Quit



              If Not cvsSrv.Interactive Then cvsSrv.ActiveTasks.Remove Rep.TaskID
          Set Rep = Nothing
       End If

   End If
   Set Info = Nothing
'## cvs_cmd_end

End Sub

And I need to integrate this connection to MySQL into above script. Obviously the script below is just VBA Excel script so it makes it quite tricky.

Connect

conMySQL.ConnectionString = "DRIVER={MySQL ODBC 5.1 Driver};" & "SERVER=" & server & ";" & " DATABASE=" & database & ";" & "UID=" & login_user & ";PWD=" & password & "; OPTION=3; PORT=" & port & ";Connect Timeout=20;"

conMySQL.Open

Query

strSQL = "SELECT x FROM some_table"
MySQL.Query (strSQL)

With rsTemporary
      Do Until .EOF
          recordCount = recordCount + 1
          some_variable = ![supcode]
          rsTemporary.MoveNext
      Loop
End With
        MySQL.closeCon

I've installed ODBC driver already but other then this I just have my Avaya CMS Supervisor Version 19.0 + MySQL 8.0.19 on my dev environment.

MY QUESTION: Did anyone try to integrate this MySQL connection into.acsauto Avaya Script?

Thank you in advance. KK

So, many years ago I had played around with SQL and was able to figure out how to create a table, drop a table, and insert records into a table. Below is inserting records into a Sql table

'LANGUAGE=ENU
'SERVERNAME=xxx.xxx.xxx.xxx
Public Sub Main()

   On Error Resume Next

StrConnect = "Driver={SQL Server};Server=xxx.xxx.xxx.xxx\QLIS,2026;Database=OADB;UID=xxxxxxx;PWD=xxxxxxx"
Set cnt = CreateObject("ADODB.Connection")
cnt.Open StrConnect

set recordSet = CreateObject("ADODB.Recordset")
SQLStr = "Select * from tmpCMSData2 "
recordSet.Open SQLStr, cnt, 1, 1

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile("C:\Inetpub\wwwroot\Telecom\COOL_TEXT.txt", 1)

If (objFSO.FileExists("C:\Inetpub\wwwroot\Telecom\COOL_TEXT.txt")) Then

Do Until objFile.AtEndOfStream

  strCharacter = objFile.Read(1)
  strLine = objFile.ReadLine

  For z = Ubound(strLine) to LBound(strLine) Step -1
    arrProcessLines = Split(strLine,",")
    '##msgbox(arrProcessLines(3))
    cnt.Execute "INSERT INTO tmpCMSData2 (Extension, Workmode, Direction)VALUES(" & arrProcessLines(0) & "," & arrProcessLines(1) & "," & arrProcessLines(2) & ")"
  Next

Loop

else
  strFileExists = Msgbox("no")
End If

End Sub

Creating a table is:

cnt.Execute "CREATE TABLE tmpCMSData2 (Extension int,Workmode int,Direction int, Duration int, Split int, OnHold int, ACD int, AuxReason int, LogID int, CID varchar(25))"

An example of the data I was importing in the COOL_TEXT.txt file is:

Extn,State,Direction,Time,Split/Skill,ONHOLD,ACD,AUX Reason,Login ID
21281,AUX,0,327,10,0,1,General,42554
17334,AUX,0,1049,10,0,1,General,47322
68909,AUX,IN,71,10,0,1,General,45466
16425,AUX,0,11856,10,0,1,General,48103
16322,AUX,0,2773,10,0,1,General,45955
21394,AVAIL,0,278,10,0,1,,47633
17501,AUX,0,10463,10,0,1,General,48513
16360,AUX,0,3811,10,0,1,General,45996
21305,AUX,0,10229,10,0,1,General,44873

Hope this helps!

Dave M.

I do the same as Dave M. I write the data to a file then loop the file to insert data into the database. For historical data, I use informix to pull the data.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM