echi-converter 0.3.1 → 0.3.2
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +14 -2
- data/Manifest.txt +3 -1
- data/Rakefile +3 -2
- data/bin/echi-converter +6 -2
- data/config/application.yml +7 -5
- data/config/install_files.yml +6 -0
- data/db/migrate/003_create_echi_agents.rb +15 -0
- data/db/migrate/004_change_log_name_size.rb +9 -0
- data/examples/ascii_csv/chr5500.123 +18 -0
- data/lib/database.rb +4 -0
- data/lib/echi-converter.rb +121 -47
- data/lib/echi-converter/version.rb +1 -1
- data/lib/main.rb +5 -0
- data/lib/main_win32.rb +6 -1
- data/website/index.html +19 -5
- data/website/index.txt +9 -3
- metadata +14 -2
data/History.txt
CHANGED
@@ -104,7 +104,7 @@
|
|
104
104
|
* Bug fix(es):
|
105
105
|
* Fixed bug so that the log file properly reports when a file is processed
|
106
106
|
|
107
|
-
== 0.3.1 2007-11-
|
107
|
+
== 0.3.1 2007-11-04
|
108
108
|
|
109
109
|
* Major enhancement(s):
|
110
110
|
* Minor enhancement(s):
|
@@ -112,4 +112,16 @@
|
|
112
112
|
* Modified the return status when creating or manipulating a Windows service
|
113
113
|
* Add the 'echi-converter status' command to check the status of a Windows service
|
114
114
|
* Bug fix(es):
|
115
|
-
* Fixed bug #15293, the service now exists cleanly
|
115
|
+
* Fixed bug #15293, the service now exists cleanly
|
116
|
+
|
117
|
+
== 0.3.2 2007-11-05
|
118
|
+
|
119
|
+
* Major enhancement(s):
|
120
|
+
* Minor enhancement(s):
|
121
|
+
* FR#15361 - Added the ability to create echi_agents and then insert data from agname.dat
|
122
|
+
* Added better error handling by giving a proper error when no project name is provided on a create command
|
123
|
+
* Added requirement for 'uuidtools' gem for creating unique filenames for the agname.dat files since the Avaya outputs them the same
|
124
|
+
* Capture and report the error when echi-converter create command fails
|
125
|
+
* Provided an example ASCII CSV file in examples/ascii_csv for testing
|
126
|
+
* Bug fix(es):
|
127
|
+
* Bug ##15367 - Added to documentation that when using a Windows FTP server you must specify 'UNIX directory listing format'
|
data/Manifest.txt
CHANGED
@@ -28,8 +28,10 @@ config/standard_version13.yml
|
|
28
28
|
config/install_files.yml
|
29
29
|
db/migrate/001_create_echi_records.rb
|
30
30
|
db/migrate/002_create_echi_logs.rb
|
31
|
+
db/migrate/003_create_echi_agents.rb
|
32
|
+
db/migrate/004_change_log_name_size.rb
|
31
33
|
bin/echi-converter
|
32
34
|
examples/extended_version12/chr0003
|
33
35
|
examples/extended_version12/chr0003.txt
|
34
36
|
examples/schemas/oracle_echi.sql
|
35
|
-
|
37
|
+
examples/ascii_csv/chr5500.123
|
data/Rakefile
CHANGED
@@ -79,8 +79,9 @@ hoe = Hoe.new(GEM_NAME, VERS) do |p|
|
|
79
79
|
['activesupport', '>=1.4.2'],
|
80
80
|
['daemons', '>=1.0.7'],
|
81
81
|
['fastercsv', '>=1.2.0'],
|
82
|
-
['hoe', '>=1.
|
83
|
-
['rake', '>=0.7.3']
|
82
|
+
['hoe', '>=1.3.0'],
|
83
|
+
['rake', '>=0.7.3'],
|
84
|
+
['uuidtools', '>=1.0.1']
|
84
85
|
]
|
85
86
|
#p.spec_extras = {} # A hash of extra values to set in the gemspec.
|
86
87
|
end
|
data/bin/echi-converter
CHANGED
@@ -72,7 +72,7 @@ def create_project dir_name
|
|
72
72
|
end
|
73
73
|
rescue => err
|
74
74
|
puts err
|
75
|
-
puts 'Fatal...exiting...'
|
75
|
+
puts 'Fatal...exiting... - ' + err
|
76
76
|
exit
|
77
77
|
end
|
78
78
|
puts ''
|
@@ -185,7 +185,11 @@ puts ''
|
|
185
185
|
|
186
186
|
#Evaluate the selection and execute
|
187
187
|
if ARGV[0] == 'create'
|
188
|
-
|
188
|
+
if ARGV[1] != nil
|
189
|
+
create_project ARGV[1]
|
190
|
+
else
|
191
|
+
puts "ECHI-converter - You must enter a project name when creating a project"
|
192
|
+
end
|
189
193
|
elsif ARGV[0] == 'upgrade'
|
190
194
|
upgrade_project ARGV[1]
|
191
195
|
elsif RUBY_PLATFORM["-mswin32"]
|
data/config/application.yml
CHANGED
@@ -7,13 +7,15 @@ echi_username: anonymous
|
|
7
7
|
echi_password:
|
8
8
|
echi_connect_type: ftp #only ftp supported now, possible for ssh in the future
|
9
9
|
echi_ftp_directory: #/Users/ftp/anonymous #If blank/nil, the system will not do a CD at the start
|
10
|
-
echi_ftp_retry:
|
10
|
+
echi_ftp_retry: 10
|
11
11
|
echi_ftp_delete: Y #to not delete the files off of the FTP server set to N, Y to delete the files
|
12
12
|
echi_schema: extended_version13.yml
|
13
13
|
echi_format: BINARY #valid settings are ASCII or BINARY
|
14
14
|
echi_process_log: Y #valid is Y/N to turn it on or off
|
15
|
+
echi_update_agent_data: N #Insert data in the 'echi_agents' table with the 'agname.dat' file, and update regularly (not available when 'pco_process' set to 'Y')
|
16
|
+
echi_update_agent_data_freq: 24 #Number of hours to wait before updating the 'echi_agents' table
|
15
17
|
|
16
|
-
#Currently only ftp supported, but may want to add
|
18
|
+
#Currently only ftp supported, but may want to add SSH/SFTP later
|
17
19
|
echi_xfer_type: ftp
|
18
20
|
|
19
21
|
#How frequently to fetch records off of the Avaya CMS ftp server
|
@@ -37,9 +39,9 @@ log_length: 10240000
|
|
37
39
|
|
38
40
|
#Email address to send alerts to, specifically failures to connect to the DB or FTP servers
|
39
41
|
#currently does not support an SMTP server that requires authentication
|
40
|
-
alert_email_address:
|
41
|
-
smtp_server:
|
42
|
+
alert_email_address: youremail@yourdomain.com
|
43
|
+
smtp_server: smtp.yourdomain.com
|
42
44
|
smtp_port: 25
|
43
45
|
|
44
46
|
#Special settings for a specific application database
|
45
|
-
pco_process: N #Set to yes or no if running with a PCO database
|
47
|
+
pco_process: N #Set to yes (Y) or no (N) if running with a PCO database
|
data/config/install_files.yml
CHANGED
@@ -12,6 +12,7 @@ dirs_to_create:
|
|
12
12
|
- name: examples
|
13
13
|
- name: examples/extended_version12
|
14
14
|
- name: examples/schemas
|
15
|
+
- name: examples/ascii_csv
|
15
16
|
- name: lib
|
16
17
|
- name: lib/echi-converter
|
17
18
|
|
@@ -31,8 +32,11 @@ files_to_copy:
|
|
31
32
|
- name: config/standard_version13.yml
|
32
33
|
- name: db/migrate/001_create_echi_records.rb
|
33
34
|
- name: db/migrate/002_create_echi_logs.rb
|
35
|
+
- name: db/migrate/003_create_echi_agents.rb
|
36
|
+
- name: db/migrate/004_change_log_name_size.rb
|
34
37
|
- name: examples/extended_version12/chr0003
|
35
38
|
- name: examples/extended_version12/chr0003.txt
|
39
|
+
- name: examples/ascii_csv/chr5500.123
|
36
40
|
- name: lib/database.rb
|
37
41
|
- name: lib/database_presence.rb
|
38
42
|
- name: lib/echi-converter.rb
|
@@ -48,3 +52,5 @@ files_to_upgrade:
|
|
48
52
|
- name: lib/main.rb
|
49
53
|
- name: lib/main_win32.rb
|
50
54
|
- name: lib/echi-converter/version.rb
|
55
|
+
- name: db/migrate/003_create_echi_agents.rb
|
56
|
+
- name: db/migrate/004_change_log_name_size.rb
|
@@ -0,0 +1,15 @@
|
|
1
|
+
class CreateEchiAgents < ActiveRecord::Migration
|
2
|
+
def self.up
|
3
|
+
create_table "echi_agents", :force => true do |t|
|
4
|
+
t.column "group_id", :string
|
5
|
+
t.column "login_id", :string
|
6
|
+
t.column "name", :string
|
7
|
+
end
|
8
|
+
add_index "echi_agents", "login_id"
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.down
|
12
|
+
remove_index "echi_agents", "login_id"
|
13
|
+
drop_table "echi_agents"
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
453862,13,0,0,36,126,2007-10-08 10:55:31,2007-10-08 10:57:50,90,0,0,0,5,16,13,15,13,-1,-1,0,0,0,3,0,0,0,0,0,0,0,0,0,0,1,1,2,4,0,1,0,0,1,0,0,0,0,0,0,0,0,0,00001023911191840931,74013,,1009,,40317,,1009,7415572532,1,,,,,,,,74013,,,,,,,,,
|
2
|
+
453869,0,0,0,163,163,2007-10-08 10:55:22,2007-10-08 10:58:05,0,0,0,138,0,3,-1,1,2,-1,-1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,4,4,0,1,0,0,0,0,0,0,0,0,0,0,0,0,00001023781191840922,74001,,1012,,,,1012,6188642689,1,,,,,,,,74001,,,,,,,,,
|
3
|
+
453870,0,0,0,0,60,2007-10-08 10:57:09,2007-10-08 10:58:09,0,0,0,0,0,911,-1,911,-1,-1,-1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,4,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,00001025341191841029,1087,,1087,,,,1087,3465496498,,,,,,,,,,,,,,,,,,
|
4
|
+
453875,6,47,0,60,656,2007-10-08 10:46:04,2007-10-08 10:58:28,227,0,0,0,4,18,14,15,14,-1,-1,0,0,0,3,0,0,0,0,1,0,0,0,0,0,1,1,2,4,1,1,0,0,1,0,0,0,0,0,0,0,0,0,00001016761191840364,74015,,1009,,40155,,1009,7809640792,4,,,,,,,,74015,,,,,,,,,
|
5
|
+
453876,6,2,0,37,247,2007-10-08 10:54:05,2007-10-08 10:58:28,37,0,0,0,4,63,57,7,57,-1,-1,0,0,0,3,0,0,0,0,0,0,0,0,0,1,1,1,2,4,1,1,0,0,3,0,0,0,0,0,0,0,0,0,00001022721191840845,74025,,1011,,40196,,1011,4339496401,1,,,,,,,,74025,,,,,,,,,
|
6
|
+
453877,11,7,0,45,552,2007-10-08 10:48:26,2007-10-08 10:58:28,220,0,0,0,4,16,13,15,13,-1,-1,0,0,0,3,0,0,0,0,0,0,0,0,0,1,1,1,2,4,1,1,0,0,1,0,0,0,0,0,0,0,0,0,00001018691191840506,74013,,1606,,40310,,1606,3133385882,2,,,,,,,,74013,,,,,,,,,
|
7
|
+
453880,0,0,0,34,743,2007-10-08 10:43:05,2007-10-08 10:58:34,0,0,0,0,0,929,-1,929,-1,-1,-1,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,00001014351191840185,,,,,,,,3404687707,,,,,,,,,,,,,,,,,,
|
8
|
+
453887,7,9,0,58,488,2007-10-08 10:50:39,2007-10-08 10:58:47,132,0,0,0,4,18,14,15,14,-1,-1,0,0,0,3,0,0,0,0,0,0,0,0,0,1,1,1,2,4,1,1,0,0,1,0,0,0,0,0,0,0,0,0,00001020131191840639,74015,,1009,,40108,,1009,5114284569,4,,,,,,,,74015,,,,,,,,,
|
9
|
+
453888,0,0,0,0,6,2007-10-08 10:58:53,2007-10-08 10:58:59,0,0,0,0,0,911,-1,911,-1,-1,-1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,4,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,00001026591191841133,1087,,1087,,,,1087,7234961461,,,,,,,,,,,,,,,,,,
|
10
|
+
453891,72,0,0,60,163,2007-10-08 10:55:11,2007-10-08 10:59:06,103,0,0,0,4,18,14,15,14,-1,-1,0,0,0,3,0,0,0,0,0,0,0,0,0,0,1,1,2,4,0,1,0,0,1,0,0,0,0,0,0,0,0,0,00001023611191840911,74015,,1009,,40111,,1009,7188493989,4,,,,,,,,74015,,,,,,,,,
|
11
|
+
453893,3,0,0,44,173,2007-10-08 10:56:15,2007-10-08 10:59:11,129,0,0,0,4,16,13,15,13,-1,-1,0,0,0,3,0,0,0,0,0,0,0,0,0,0,1,1,2,4,0,1,0,0,1,0,0,0,0,0,0,0,0,0,00001024601191840975,74013,,1009,,40311,,1009,5119780434,2,,,,,,,,74013,,,,,,,,,
|
12
|
+
453894,0,0,0,0,0,2007-10-08 10:59:12,2007-10-08 10:59:12,0,0,0,0,0,913,-1,913,-1,-1,-1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,6,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,00001026751191841152,1824,,1824,,,,1824,9959938868,,,,,,,,,,,,,,,,,,
|
13
|
+
453899,0,0,0,110,110,2007-10-08 10:57:36,2007-10-08 10:59:26,0,0,0,75,0,2,-1,1,1,-1,-1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,4,4,0,1,0,0,0,0,0,0,0,0,0,0,0,0,00001025701191841056,74004,,2012,,,,2012,9114281803,1,,,,,,,,74004,,,,,,,,,
|
14
|
+
453900,7,454,0,62,1044,2007-10-08 10:41:57,2007-10-08 10:59:28,528,0,0,0,5,8,6,7,6,-1,-1,0,0,0,3,0,0,0,0,0,0,0,0,0,0,1,1,2,4,1,1,0,0,3,0,0,0,0,0,0,0,0,0,00001013611191840117,74009,,1011,,40202,,1011,3116878459,1,,,,,,,,74009,,,,,,,,,
|
15
|
+
453901,0,0,0,162,162,2007-10-08 10:56:48,2007-10-08 10:59:30,0,0,0,139,0,3,2,1,2,-1,-1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,3,4,0,1,0,0,0,0,0,0,0,0,0,0,0,0,00001025091191841008,74001,,2013,,,,2013,3709843581,1,,,,,,,,74001,,,,,,,,,
|
16
|
+
453904,180,2,0,61,988,2007-10-08 10:41:12,2007-10-08 10:59:32,788,0,0,0,4,18,14,15,14,-1,-1,0,0,0,3,0,0,0,0,1,0,0,0,0,0,1,1,2,4,1,1,0,0,1,0,0,0,0,0,0,0,0,0,00001013161191840072,74015,,1009,,40121,,1009,4148642911,4,,,,,,,,74015,,,,,,,,,
|
17
|
+
453911,545,0,0,62,192,2007-10-08 10:47:37,2007-10-08 10:59:54,130,0,0,0,4,8,6,7,6,-1,-1,0,0,0,3,0,0,0,0,0,0,0,0,0,0,1,1,2,4,0,1,0,0,3,0,0,0,0,0,0,0,0,0,00001018111191840457,74009,,1011,,41023,,1011,9467885678,1,,,,,,,,74009,,,,,,,,,
|
18
|
+
453913,0,0,0,102,102,2007-10-08 10:58:14,2007-10-08 10:59:56,0,0,0,70,0,2,1,1,1,-1,-1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,3,4,0,1,0,0,0,0,0,0,0,0,0,0,0,0,00001026141191841094,74004,,2004,,,,2004,6186251935,4,,,,,,,,74004,,,,,,,,,
|
data/lib/database.rb
CHANGED
data/lib/echi-converter.rb
CHANGED
@@ -4,6 +4,7 @@ require 'faster_csv'
|
|
4
4
|
require 'net/ftp'
|
5
5
|
require 'net/smtp'
|
6
6
|
require 'fileutils'
|
7
|
+
require 'uuidtools'
|
7
8
|
|
8
9
|
class Logger
|
9
10
|
#Change the logging format to include a timestamp
|
@@ -13,7 +14,6 @@ class Logger
|
|
13
14
|
end
|
14
15
|
|
15
16
|
module EchiConverter
|
16
|
-
|
17
17
|
def connect_database
|
18
18
|
databaseconfig = $workingdir + '/../config/database.yml'
|
19
19
|
dblogfile = $workingdir + '/../log/database.log'
|
@@ -259,9 +259,16 @@ module EchiConverter
|
|
259
259
|
ftp_session.chdir($config["echi_ftp_directory"])
|
260
260
|
end
|
261
261
|
files = ftp_session.list('chr*')
|
262
|
+
|
263
|
+
#Also fetch the agname.dat file if it is configured to be processed
|
264
|
+
if $config["echi_update_agent_data"] == "Y"
|
265
|
+
files = files + ftp_session.list("agname.dat")
|
266
|
+
end
|
267
|
+
|
262
268
|
file_cnt = 0
|
263
269
|
files.each do | file |
|
264
270
|
file_data = file.split(' ')
|
271
|
+
|
265
272
|
local_filename = $workingdir + '/../files/to_process/' + file_data[8]
|
266
273
|
ftp_session.getbinaryfile(file_data[8], local_filename)
|
267
274
|
if $config["echi_ftp_delete"] == 'Y'
|
@@ -280,63 +287,130 @@ module EchiConverter
|
|
280
287
|
end
|
281
288
|
return
|
282
289
|
end
|
283
|
-
end
|
284
290
|
|
285
|
-
def process_ascii filename
|
286
|
-
|
291
|
+
def process_ascii filename
|
292
|
+
echi_file = $workingdir + "/../files/to_process/" + filename
|
287
293
|
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
294
|
+
if $config["echi_process_log"] == "Y"
|
295
|
+
#Log the file
|
296
|
+
echi_log = EchiLog.new
|
297
|
+
echi_log.filename = filename
|
298
|
+
#echi_log.filenumber = filenumber
|
299
|
+
#echi_log.version = fileversion
|
300
|
+
end
|
295
301
|
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
@log.debug field["name"] + ' == ' + row[cnt]
|
314
|
-
else
|
315
|
-
echi_record[field["name"]] = row[cnt]
|
316
|
-
if row[cnt] != nil
|
302
|
+
#Perform a transaction for each file, including the log table
|
303
|
+
#in order to commit as one atomic action upon success
|
304
|
+
EchiRecord.transaction do
|
305
|
+
@record_cnt = 0
|
306
|
+
FasterCSV.foreach(echi_file) do |row|
|
307
|
+
if row != nil
|
308
|
+
@log.debug '<====================START RECORD ' + @record_cnt.to_s + ' ====================>'
|
309
|
+
echi_record = EchiRecord.new
|
310
|
+
cnt = 0
|
311
|
+
@echi_schema["fields"].each do | field |
|
312
|
+
if field["type"] == "bool" || field["type"] == "bool_int"
|
313
|
+
case row[cnt]
|
314
|
+
when "0"
|
315
|
+
echi_record[field["name"]] = "N"
|
316
|
+
when "1"
|
317
|
+
echi_record[field["name"]] = "Y"
|
318
|
+
end
|
317
319
|
@log.debug field["name"] + ' == ' + row[cnt]
|
320
|
+
else
|
321
|
+
echi_record[field["name"]] = row[cnt]
|
322
|
+
if row[cnt] != nil
|
323
|
+
@log.debug field["name"] + ' == ' + row[cnt]
|
324
|
+
end
|
318
325
|
end
|
326
|
+
cnt += 1
|
319
327
|
end
|
320
|
-
|
328
|
+
echi_record.save
|
329
|
+
@log.debug '<====================STOP RECORD ' + @record_cnt.to_s + ' ====================>'
|
330
|
+
@record_cnt += 1
|
321
331
|
end
|
322
|
-
echi_record.save
|
323
|
-
@log.debug '<====================STOP RECORD ' + @record_cnt.to_s + ' ====================>'
|
324
|
-
@record_cnt += 1
|
325
332
|
end
|
326
333
|
end
|
327
|
-
end
|
328
334
|
|
329
|
-
|
330
|
-
|
335
|
+
#Move the file to the processed directory
|
336
|
+
FileUtils.mv(echi_file, @processeddirectory)
|
331
337
|
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
338
|
+
if $config["echi_process_log"] == "Y"
|
339
|
+
#Finish logging the details on the file
|
340
|
+
echi_log.records = @record_cnt
|
341
|
+
echi_log.processed_at = Time.now
|
342
|
+
echi_log.save
|
343
|
+
end
|
344
|
+
|
345
|
+
return @record_cnt
|
346
|
+
end
|
347
|
+
|
348
|
+
def insert_agent_data field
|
349
|
+
|
350
|
+
begin
|
351
|
+
echi_agent = EchiAgent.new
|
352
|
+
echi_agent.group_id = field[0]
|
353
|
+
echi_agent.login_id = field[1]
|
354
|
+
echi_agent.name = field[2]
|
355
|
+
echi_agent.save
|
356
|
+
rescue => err
|
357
|
+
@log.info "Unable to insert agent record - " + err
|
358
|
+
end
|
359
|
+
|
337
360
|
end
|
338
361
|
|
339
|
-
|
340
|
-
|
362
|
+
#Method to insert data into 'echi_agents' based on agname.dat
|
363
|
+
def process_agent_data
|
364
|
+
agent_file = $workingdir + "/../files/to_process/agname.dat"
|
365
|
+
|
366
|
+
if File.exists?(agent_file)
|
367
|
+
EchiAgent.transaction do
|
368
|
+
@record_cnt = 0
|
369
|
+
File.open(agent_file).each do |row|
|
370
|
+
if row != nil
|
371
|
+
field = row.rstrip.split('|')
|
372
|
+
@log.debug '<====================START AGENT RECORD ' + @record_cnt.to_s + ' ====================>'
|
373
|
+
agent = EchiAgent.find(:first, :conditions => [ "login_id = ? AND group_id = ?", field[1], field[0]])
|
374
|
+
if agent != nil
|
375
|
+
if agent.name != field[2]
|
376
|
+
agent.name = field[2]
|
377
|
+
agent.update
|
378
|
+
@record_cnt += 1
|
379
|
+
@log.debug "Updated record - " + field.inspect
|
380
|
+
else
|
381
|
+
@log.debug "No update required for - " + field.inspect
|
382
|
+
end
|
383
|
+
else
|
384
|
+
insert_agent_data field
|
385
|
+
@record_cnt += 1
|
386
|
+
@log.debug "Inserted new record - " + field.inspect
|
387
|
+
end
|
388
|
+
end
|
389
|
+
@log.debug '<====================STOP AGENT RECORD ' + @record_cnt.to_s + ' ====================>'
|
390
|
+
end
|
391
|
+
end
|
392
|
+
@agent_file_processed = Time.now
|
393
|
+
#Move the file to the processed directory
|
394
|
+
begin
|
395
|
+
agname_new_filename = "agname_" + UUID.timestamp_create.to_s + ".dat"
|
396
|
+
target_file = @processeddirectory + "/" + agname_new_filename
|
397
|
+
FileUtils.mv(agent_file, target_file)
|
398
|
+
rescue => err
|
399
|
+
@log.info "Issue with agname_*.dat filename - " + err
|
400
|
+
end
|
401
|
+
if $config["echi_process_log"] == "Y"
|
402
|
+
#Log the file
|
403
|
+
echi_log = EchiLog.new
|
404
|
+
echi_log.filename = agname_new_filename
|
405
|
+
#echi_log.filenumber = filenumber
|
406
|
+
#echi_log.version = fileversion
|
407
|
+
#Finish logging the details on the file
|
408
|
+
echi_log.records = @record_cnt
|
409
|
+
echi_log.processed_at = Time.now
|
410
|
+
echi_log.save
|
411
|
+
end
|
412
|
+
end
|
413
|
+
end
|
341
414
|
|
342
|
-
require $workingdir + '/echi-converter/version.rb'
|
415
|
+
require $workingdir + '/echi-converter/version.rb'
|
416
|
+
end
|
data/lib/main.rb
CHANGED
@@ -30,6 +30,7 @@ if $config["export_type"] == 'database' || $config["export_type"] == 'both'
|
|
30
30
|
connect_database
|
31
31
|
end
|
32
32
|
|
33
|
+
$init_date = Time.now
|
33
34
|
@log.info "Running..."
|
34
35
|
|
35
36
|
#Our Main loop
|
@@ -54,6 +55,10 @@ loop do
|
|
54
55
|
end
|
55
56
|
end
|
56
57
|
|
58
|
+
if $config["echi_update_agent_data"] == "Y" && $config["pco_process"] == "N"
|
59
|
+
process_agent_data
|
60
|
+
end
|
61
|
+
|
57
62
|
sleep $config["fetch_interval"]
|
58
63
|
|
59
64
|
#Make sure we did not lose our database connection while we slept
|
data/lib/main_win32.rb
CHANGED
@@ -41,6 +41,7 @@ class EchiDaemon < Daemon
|
|
41
41
|
#Open the logfile with appropriate output level
|
42
42
|
initiate_logger
|
43
43
|
@log.info "ECHI-Converter service initializing"
|
44
|
+
$init_date = Time.now
|
44
45
|
|
45
46
|
#If configured for database insertion, connect to the database
|
46
47
|
if $config["export_type"] == 'database' || $config["export_type"] == 'both'
|
@@ -71,7 +72,11 @@ class EchiDaemon < Daemon
|
|
71
72
|
@log.info "Processed file #{file} with #{record_cnt.to_s} records"
|
72
73
|
end
|
73
74
|
end
|
74
|
-
|
75
|
+
|
76
|
+
if $config["echi_update_agent_data"] == "Y" && $config["pco_process"] == "N"
|
77
|
+
process_agent_data
|
78
|
+
end
|
79
|
+
|
75
80
|
sleep $config["fetch_interval"]
|
76
81
|
|
77
82
|
#Make sure we did not lose our database connection while we slept
|
data/website/index.html
CHANGED
@@ -33,7 +33,7 @@
|
|
33
33
|
<h1>ECHI Converter</h1>
|
34
34
|
<div id="version" class="clickable" onclick='document.location = "http://rubyforge.org/projects/echi-converter"; return false'>
|
35
35
|
<p>Get Version</p>
|
36
|
-
<a href="http://rubyforge.org/projects/echi-converter" class="numbers">0.3.
|
36
|
+
<a href="http://rubyforge.org/projects/echi-converter" class="numbers">0.3.2</a>
|
37
37
|
</div>
|
38
38
|
<h1>→ ‘echi-converter’</h1>
|
39
39
|
|
@@ -63,6 +63,7 @@
|
|
63
63
|
<li>Convert from the defined Binary format to <span class="caps">ASCII</span></li>
|
64
64
|
<li>Insert the records into the defined database table using database transactions, via ActiveRecord, on a per file basis to support recovery on failure</li>
|
65
65
|
<li>Change schema structure via <span class="caps">YML</span> configuration file to accommodate various releases of the <span class="caps">ECHI</span> format</li>
|
66
|
+
<li>Supports inserting agent names from agname.dat</li>
|
66
67
|
<li>Runs as a daemon (via fork) on *NIX and a service on Windows</li>
|
67
68
|
</ol>
|
68
69
|
|
@@ -72,6 +73,7 @@
|
|
72
73
|
<ol>
|
73
74
|
<li>echi_records – stores all <span class="caps">ECHI</span> data </li>
|
74
75
|
<li>echi_logs – stores a log entry for each file processed</li>
|
76
|
+
<li>echi_agents – stores the data from the agname.dat file</li>
|
75
77
|
</ol></li>
|
76
78
|
</ol>
|
77
79
|
|
@@ -86,8 +88,9 @@
|
|
86
88
|
<li><a href="http://activesupport.rubyforge.org/">ActiveSupport v1.4.2+</a></li>
|
87
89
|
<li><a href="http://daemons.rubyforge.org/">Daemons v1.0.7+</a></li>
|
88
90
|
<li><a href="http://fastercsv.rubyforge.org/">FasterCSV v1.2.0+</a></li>
|
89
|
-
<li><a href="http://rake.rubyforge.org/">Rake v0.7.3+</a>
|
90
|
-
|
91
|
+
<li><a href="http://rake.rubyforge.org/">Rake v0.7.3+</a></li>
|
92
|
+
<li><a href="http://sporkmonger.com/projects/uuidtools/">UUIDTools v1.0.1+</a></li>
|
93
|
+
<li><a href="http://win32utils.rubyforge.org/">Win32-service v.0.5.0+</a> (Manual install for Windows only)</li>
|
91
94
|
<li><a href="http://rubyforge.org/projects/seattlerb/">Hoe v1.2.2+</a></li>
|
92
95
|
</ol>
|
93
96
|
|
@@ -136,6 +139,9 @@
|
|
136
139
|
</ol>
|
137
140
|
|
138
141
|
|
142
|
+
<p>Note: When using a Windows <span class="caps">FTP</span> server, you must configure the <span class="caps">FTP</span> server to provide a <span class="caps">UNIX</span> directory listing format</p>
|
143
|
+
|
144
|
+
|
139
145
|
<h2>Usage</h2>
|
140
146
|
|
141
147
|
|
@@ -161,7 +167,7 @@
|
|
161
167
|
|
162
168
|
|
163
169
|
<ol>
|
164
|
-
<li>echi-converter install myproject – install the service (must specify complete path such as c:\path\to\my\project – if the directory name or path has any spaces, please enclose the &#
|
170
|
+
<li>echi-converter install myproject – install the service (must specify complete path such as c:\path\to\my\project – if the directory name or path has any spaces, please enclose the “myproject” in double quotes )</li>
|
165
171
|
<li>echi-converter start – start the service</li>
|
166
172
|
<li>echi-converter stop – stop the service</li>
|
167
173
|
<li>echi-converter pause – pause the service</li>
|
@@ -172,6 +178,14 @@
|
|
172
178
|
</ol>
|
173
179
|
|
174
180
|
|
181
|
+
<ol>
|
182
|
+
<li>If you would like to run the script interactively, you may also execute this command:
|
183
|
+
<ol>
|
184
|
+
<li>ruby “c:\myproject\lib\main_win32.rb”</li>
|
185
|
+
</ol></li>
|
186
|
+
</ol>
|
187
|
+
|
188
|
+
|
175
189
|
<h2>Demonstration of usage</h2>
|
176
190
|
|
177
191
|
|
@@ -217,7 +231,7 @@
|
|
217
231
|
|
218
232
|
<p>Comments are welcome. Send an email to <a href="mailto:jason@goecke.net">jason [at] goecke.net</a>.</p>
|
219
233
|
<p class="coda">
|
220
|
-
<a href="mailto:drnicwilliams@gmail.com">Dr Nic</a>,
|
234
|
+
<a href="mailto:drnicwilliams@gmail.com">Dr Nic</a>, 5th November 2007<br>
|
221
235
|
Theme extended from <a href="http://rb2js.rubyforge.org/">Paul Battley</a>
|
222
236
|
</p>
|
223
237
|
</div>
|
data/website/index.txt
CHANGED
@@ -22,11 +22,13 @@ The utility provides the following capabilities:
|
|
22
22
|
# Convert from the defined Binary format to ASCII
|
23
23
|
# Insert the records into the defined database table using database transactions, via ActiveRecord, on a per file basis to support recovery on failure
|
24
24
|
# Change schema structure via YML configuration file to accommodate various releases of the ECHI format
|
25
|
+
# Supports inserting agent names from agname.dat
|
25
26
|
# Runs as a daemon (via fork) on *NIX and a service on Windows
|
26
27
|
|
27
28
|
# Table names:
|
28
29
|
## echi_records - stores all ECHI data
|
29
30
|
## echi_logs - stores a log entry for each file processed
|
31
|
+
## echi_agents - stores the data from the agname.dat file
|
30
32
|
|
31
33
|
|
32
34
|
h2. Requirements
|
@@ -38,7 +40,8 @@ h2. Requirements
|
|
38
40
|
# "Daemons v1.0.7+":http://daemons.rubyforge.org/
|
39
41
|
# "FasterCSV v1.2.0+":http://fastercsv.rubyforge.org/
|
40
42
|
# "Rake v0.7.3+":http://rake.rubyforge.org/
|
41
|
-
|
43
|
+
# "UUIDTools v1.0.1+":http://sporkmonger.com/projects/uuidtools/
|
44
|
+
# "Win32-service v.0.5.0+":http://win32utils.rubyforge.org/ (Manual install for Windows only)
|
42
45
|
# "Hoe v1.2.2+":http://rubyforge.org/projects/seattlerb/
|
43
46
|
|
44
47
|
|
@@ -50,7 +53,6 @@ or
|
|
50
53
|
|
51
54
|
<pre syntax="ruby">gem install echi-converter</pre>
|
52
55
|
|
53
|
-
|
54
56
|
h2. Setup
|
55
57
|
|
56
58
|
First, create the directory with all of the project files where you will run this application from:
|
@@ -70,6 +72,7 @@ Once this is complete, then simply run these commands from the project directory
|
|
70
72
|
# rake migrate (creates the tables required for the system)
|
71
73
|
# echi-converter (starts the server daemon, refer to its usage)
|
72
74
|
|
75
|
+
Note: When using a Windows FTP server, you must configure the FTP server to provide a UNIX directory listing format
|
73
76
|
|
74
77
|
h2. Usage
|
75
78
|
|
@@ -86,7 +89,7 @@ For *NIX:
|
|
86
89
|
|
87
90
|
For Windows:
|
88
91
|
|
89
|
-
# echi-converter install myproject - install the service (must specify complete path such as c:\path\to\my\project - if the directory name or path has any spaces, please enclose the
|
92
|
+
# echi-converter install myproject - install the service (must specify complete path such as c:\path\to\my\project - if the directory name or path has any spaces, please enclose the "myproject" in double quotes )
|
90
93
|
# echi-converter start - start the service
|
91
94
|
# echi-converter stop - stop the service
|
92
95
|
# echi-converter pause - pause the service
|
@@ -95,6 +98,9 @@ For Windows:
|
|
95
98
|
# echi-converter uninstall - uninstall the service
|
96
99
|
# echi-converter delete - delete the service"
|
97
100
|
|
101
|
+
# If you would like to run the script interactively, you may also execute this command:
|
102
|
+
## ruby "c:\myproject\lib\main_win32.rb"
|
103
|
+
|
98
104
|
h2. Demonstration of usage
|
99
105
|
|
100
106
|
Start the daemon/service:
|
metadata
CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.4
|
|
3
3
|
specification_version: 1
|
4
4
|
name: echi-converter
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 0.3.
|
7
|
-
date: 2007-11-
|
6
|
+
version: 0.3.2
|
7
|
+
date: 2007-11-05 00:00:00 -08:00
|
8
8
|
summary: ECHI Conversion Utility - Provides a utility to fetch Avaya CMS / ECHI binary files, convert them and insert into a database table via ActiveRecord
|
9
9
|
require_paths:
|
10
10
|
- lib
|
@@ -58,10 +58,13 @@ files:
|
|
58
58
|
- config/install_files.yml
|
59
59
|
- db/migrate/001_create_echi_records.rb
|
60
60
|
- db/migrate/002_create_echi_logs.rb
|
61
|
+
- db/migrate/003_create_echi_agents.rb
|
62
|
+
- db/migrate/004_change_log_name_size.rb
|
61
63
|
- bin/echi-converter
|
62
64
|
- examples/extended_version12/chr0003
|
63
65
|
- examples/extended_version12/chr0003.txt
|
64
66
|
- examples/schemas/oracle_echi.sql
|
67
|
+
- examples/ascii_csv/chr5500.123
|
65
68
|
test_files:
|
66
69
|
- test/test_echi-converter.rb
|
67
70
|
- test/test_helper.rb
|
@@ -127,3 +130,12 @@ dependencies:
|
|
127
130
|
- !ruby/object:Gem::Version
|
128
131
|
version: 0.7.3
|
129
132
|
version:
|
133
|
+
- !ruby/object:Gem::Dependency
|
134
|
+
name: uuidtools
|
135
|
+
version_requirement:
|
136
|
+
version_requirements: !ruby/object:Gem::Version::Requirement
|
137
|
+
requirements:
|
138
|
+
- - ">="
|
139
|
+
- !ruby/object:Gem::Version
|
140
|
+
version: 1.0.1
|
141
|
+
version:
|