echi-converter 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,6 +1,6 @@
1
1
  == 0.0.1 2007-07-22
2
2
 
3
- * 1 major enhancement:
3
+ * 1 major enhancement(s):
4
4
  * Initial release
5
5
  * Alpha phase
6
6
 
@@ -12,6 +12,17 @@
12
12
  * Changed BOOLEAN fields to char(1) with Y/N possible values (FR#12741)
13
13
  * Added the ability to toggle deleting or leaving the FTP files (FR#12702)
14
14
  * Removed some extraneous debug info
15
- * 1 bug fix:
16
- * Bug # 12528 - Handle segstart/segstop dates properly
17
- * Bug #12746 - Properly parse Bytearray for Boolean fields
15
+ * 1 Bug fix(es):
16
+ * Bug #12528 - Handle segstart/segstop dates properly
17
+ * Bug #12746 - Properly parse Bytearray for Boolean fields
18
+
19
+ == 0.0.3 2007-08-10
20
+
21
+ * Major enhancement(s):
22
+ * Added support for import of ASCII CSV files (FR#12997)
23
+ * Minor enhancement(s):
24
+ * Added support of processing 'chr' files only (FR#12996)
25
+ * Added a configuration element to turn logging of file processing to a table on/off
26
+ * Removed the net/ssh library include, as not using sftp for now
27
+ * Bug fix(es):
28
+ * Added proper error handling when ftp user does not have delete rights
@@ -21,6 +21,7 @@ website/template.rhtml
21
21
  config/application.yml
22
22
  config/database.yml
23
23
  config/extended_version12.yml
24
+ config/extended_version13.yml
24
25
  db/migrate/001_create_echi_records.rb
25
26
  db/migrate/002_create_echi_logs.rb
26
27
  bin/echi-converter-create
@@ -8,8 +8,10 @@ echi_password: sanfran2007!
8
8
  echi_connect_type: ftp #only ftp supported now, possible for ssh in the future
9
9
  echi_ftp_directory: /Users/ftp/anonymous
10
10
  echi_ftp_retry: 3
11
- echi_ftp_delete: Y #to not delete the files off of the FTP server set to N
11
+ echi_ftp_delete: N #to not delete the files off of the FTP server set to N
12
12
  echi_schema: extended_version13.yml
13
+ echi_format: ASCII #valid settings are ASCII or BINARY
14
+ echi_process_log: N #valid is Y/N to turn it on or off
13
15
 
14
16
  #Currently only ftp supported, but may want to add UUCP/Serial later
15
17
  echi_xfer_type: ftp
@@ -0,0 +1,234 @@
1
+ #ECH File construct, order is important, as the application sequentially reads the file
2
+ #Version 12 - Extended Schema
3
+ fields:
4
+ - name: callid
5
+ type: int
6
+ length: 4
7
+ - name: acwtime
8
+ type: int
9
+ length: 4
10
+ - name: onholdtime
11
+ type: int
12
+ length: 4
13
+ - name: consulttime
14
+ type: int
15
+ length: 4
16
+ - name: disptime
17
+ type: int
18
+ length: 4
19
+ - name: duration
20
+ type: int
21
+ length: 4
22
+ - name: segstart
23
+ type: datetime
24
+ length: 4
25
+ - name: segstop
26
+ type: datetime
27
+ length: 4
28
+ - name: talktime
29
+ type: int
30
+ length: 4
31
+ - name: netintime
32
+ type: int
33
+ length: 4
34
+ - name: origholdtime
35
+ type: int
36
+ length: 4
37
+ - name: queuetime
38
+ type: int
39
+ length: 4
40
+ - name: ringtime
41
+ type: int
42
+ length: 4
43
+ - name: dispivector
44
+ type: int
45
+ length: 2
46
+ - name: dispsplit
47
+ type: int
48
+ length: 2
49
+ - name: firstivector
50
+ type: int
51
+ length: 2
52
+ - name: split1
53
+ type: int
54
+ length: 2
55
+ - name: split2
56
+ type: int
57
+ length: 2
58
+ - name: split3
59
+ type: int
60
+ length: 2
61
+ - name: trunkgroup
62
+ type: int
63
+ length: 2
64
+ - name: tk_locid
65
+ type: int
66
+ length: 2
67
+ - name: orig_locid
68
+ type: int
69
+ length: 2
70
+ - name: answer_locid
71
+ type: int
72
+ length: 2
73
+ - name: obs_locid
74
+ type: int
75
+ length: 2
76
+ - name: uui_len
77
+ type: int
78
+ length: 2
79
+ - name: assist
80
+ type: bool
81
+ length: 1
82
+ - name: audio_difficulty
83
+ type: bool
84
+ length: 1
85
+ - name: conference
86
+ type: bool
87
+ length: 1
88
+ - name: da_queued
89
+ type: bool
90
+ length: 1
91
+ - name: hold_abn
92
+ type: bool
93
+ length: 1
94
+ - name: malicious
95
+ type: bool
96
+ length: 1
97
+ - name: observing_call
98
+ type: bool
99
+ length: 1
100
+ - name: transferred
101
+ type: bool
102
+ length: 1
103
+ - name: agent_released
104
+ type: bool_int
105
+ length: 1
106
+ - name: acdnum
107
+ type: int
108
+ length: 1
109
+ - name: call_disp
110
+ type: int
111
+ length: 1
112
+ - name: disppriority
113
+ type: int
114
+ length: 1
115
+ - name: holds
116
+ type: int
117
+ length: 1
118
+ - name: segment
119
+ type: int
120
+ length: 1
121
+ - name: ansreason
122
+ type: int
123
+ length: 1
124
+ - name: origreason
125
+ type: int
126
+ length: 1
127
+ - name: dispsklevel
128
+ type: int
129
+ length: 1
130
+ - name: events0
131
+ type: int
132
+ length: 1
133
+ - name: events1
134
+ type: int
135
+ length: 1
136
+ - name: events2
137
+ type: int
138
+ length: 1
139
+ - name: events3
140
+ type: int
141
+ length: 1
142
+ - name: events4
143
+ type: int
144
+ length: 1
145
+ - name: events5
146
+ type: int
147
+ length: 1
148
+ - name: events6
149
+ type: int
150
+ length: 1
151
+ - name: events7
152
+ type: int
153
+ length: 1
154
+ - name: events8
155
+ type: int
156
+ length: 1
157
+ - name: ucid
158
+ type: str
159
+ length: 21
160
+ - name: dispvdn
161
+ type: str
162
+ length: 8
163
+ - name: eqloc
164
+ type: str
165
+ length: 10
166
+ - name: firstvdn
167
+ type: str
168
+ length: 8
169
+ - name: orig_logid
170
+ type: str
171
+ length: 10
172
+ - name: ans_logid
173
+ type: str
174
+ length: 10
175
+ - name: last_observer
176
+ type: str
177
+ length: 10
178
+ - name: dialed_number
179
+ type: str
180
+ length: 25
181
+ - name: calling_party
182
+ type: str
183
+ length: 13
184
+ - name: collect_digits
185
+ type: str
186
+ length: 17
187
+ - name: cwc_digits
188
+ type: str
189
+ length: 17
190
+ - name: calling_II
191
+ type: str
192
+ length: 3
193
+ - name: cwcs0
194
+ type: str
195
+ length: 17
196
+ - name: cwcs1
197
+ type: str
198
+ length: 17
199
+ - name: cwcs2
200
+ type: str
201
+ length: 17
202
+ - name: cwcs3
203
+ type: str
204
+ length: 17
205
+ - name: cwcs4
206
+ type: str
207
+ length: 17
208
+ - name: vdn2
209
+ type: str
210
+ length: 8
211
+ - name: vdn3
212
+ type: str
213
+ length: 8
214
+ - name: vdn4
215
+ type: str
216
+ length: 8
217
+ - name: vdn5
218
+ type: str
219
+ length: 8
220
+ - name: vdn6
221
+ type: str
222
+ length: 8
223
+ - name: vdn7
224
+ type: str
225
+ length: 8
226
+ - name: vdn8
227
+ type: str
228
+ length: 8
229
+ - name: vdn9
230
+ type: str
231
+ length: 8
232
+ - name: asaiuui
233
+ type: str
234
+ length: 96
@@ -2,7 +2,7 @@ require 'rubygems'
2
2
  require 'active_record'
3
3
  require 'faster_csv'
4
4
  require 'net/ftp'
5
- require 'net/ssh'
5
+ #require 'net/ssh'
6
6
  #require 'net/sftp'
7
7
  require 'fileutils'
8
8
 
@@ -110,11 +110,13 @@ module EchiConverter
110
110
  fileversion = dump_binary 'int', 4
111
111
  @log.debug "Version " + fileversion.to_s
112
112
 
113
- #Log the file
114
- echi_log = EchiLog.new
115
- echi_log.filename = filename
116
- echi_log.filenumber = filenumber
117
- echi_log.version = fileversion
113
+ if @config["echi_process_log"] == "Yes"
114
+ #Log the file
115
+ echi_log = EchiLog.new
116
+ echi_log.filename = filename
117
+ echi_log.filenumber = filenumber
118
+ echi_log.version = fileversion
119
+ end
118
120
 
119
121
  bool_cnt = 0
120
122
  record_cnt = 0
@@ -158,10 +160,12 @@ module EchiConverter
158
160
  destination_directory = @workingdirectory + '/../files/processed/'
159
161
  FileUtils.mv(echi_file, destination_directory)
160
162
 
161
- #Finish logging the details on the file
162
- echi_log.records = record_cnt
163
- echi_log.processed_at = Time.now
164
- echi_log.save
163
+ if @config["echi_process_log"] == "Yes"
164
+ #Finish logging the details on the file
165
+ echi_log.records = record_cnt
166
+ echi_log.processed_at = Time.now
167
+ echi_log.save
168
+ end
165
169
 
166
170
  return record_cnt
167
171
  end
@@ -214,7 +218,11 @@ module EchiConverter
214
218
  ftp_session.getbinaryfile(remote_filename, local_filename)
215
219
  files_to_process[file_cnt] = remote_filename
216
220
  if @config["echi_ftp_delete"] == 'Y'
217
- ftp_session.delete(remote_filename)
221
+ begin
222
+ ftp_session.delete(remote_filename)
223
+ rescue => err
224
+ @log.fatal err
225
+ end
218
226
  end
219
227
  file_cnt += 1
220
228
  end
@@ -227,4 +235,54 @@ module EchiConverter
227
235
  end
228
236
  end
229
237
 
238
+ def process_ascii filename
239
+ echi_file = @workingdirectory + "/../files/to_process/" + filename
240
+
241
+ if @config["echi_process_log"] == "Yes"
242
+ #Log the file
243
+ echi_log = EchiLog.new
244
+ echi_log.filename = filename
245
+ echi_log.filenumber = filenumber
246
+ echi_log.version = fileversion
247
+ end
248
+
249
+ record_cnt = 0
250
+ FasterCSV.foreach(echi_file) do |row|
251
+ if row != nil
252
+ @log.debug '<====================START RECORD====================>'
253
+ echi_record = EchiRecord.new
254
+ cnt = 0
255
+ @echi_schema["fields"].each do | field |
256
+ if field["type"] == "bool" || field["type"] == "bool_int"
257
+ case row[cnt]
258
+ when "0"
259
+ echi_record[field["name"]] = "N"
260
+ when "1"
261
+ echi_record[field["name"]] = "Y"
262
+ end
263
+ @log.debug field["name"] + ' == ' + row[cnt]
264
+ else
265
+ echi_record[field["name"]] = row[cnt]
266
+ if row[cnt] != nil
267
+ @log.debug field["name"] + ' == ' + row[cnt]
268
+ end
269
+ end
270
+ cnt += 1
271
+ end
272
+ echi_record.save
273
+ @log.debug '<====================STOP RECORD====================>'
274
+ record_cnt += 1
275
+ end
276
+ end
277
+
278
+ if @config["echi_process_log"] == "Yes"
279
+ #Finish logging the details on the file
280
+ echi_log.records = record_cnt
281
+ echi_log.processed_at = Time.now
282
+ echi_log.save
283
+ end
284
+
285
+ return record_cnt
286
+ end
287
+
230
288
  require @workingdirectory + '/echi-converter/version.rb'
@@ -2,7 +2,7 @@ module EchiConverter #:nodoc:
2
2
  module VERSION #:nodoc:
3
3
  MAJOR = 0
4
4
  MINOR = 0
5
- TINY = 2
5
+ TINY = 3
6
6
 
7
7
  STRING = [MAJOR, MINOR, TINY].join('.')
8
8
  end
@@ -32,7 +32,11 @@ loop do
32
32
  #Process the files
33
33
  files = fetch_ftp_files
34
34
  files.each do | file |
35
- record_cnt = convert_binary_file file
35
+ if @config["echi_format"] == 'BINARY'
36
+ record_cnt = convert_binary_file file
37
+ elsif @config["echi_format"] == 'ASCII'
38
+ record_cnt = process_ascii file
39
+ end
36
40
  @log.info "Processed file #{file} with #{record_cnt.to_s} records"
37
41
  end
38
42
 
@@ -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.0.2</a>
36
+ <a href="http://rubyforge.org/projects/echi-converter" class="numbers">0.0.3</a>
37
37
  </div>
38
38
  <h1>&#x2192; &#8216;echi-converter&#8217;</h1>
39
39
 
@@ -59,7 +59,7 @@
59
59
  <ol>
60
60
  <li>Support of ActiveRecord (means you may use Oracle, MySQL, MS-SQL, Postgres, <span class="caps">DB2</span>, etc)</li>
61
61
  <li>Generate your schema via ActiveRecord Migrations</li>
62
- <li>Fetch Binary files from the Avaya <span class="caps">CMS</span> platform via <span class="caps">FTP</span></li>
62
+ <li>Fetch Binary or <span class="caps">ASCII CSV</span> files from the Avaya <span class="caps">CMS</span> platform via <span class="caps">FTP</span></li>
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</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>
@@ -176,6 +176,7 @@
176
176
 
177
177
  <ol>
178
178
  <li>&#8216;echi-converter-create&#8217; works fine with <span class="caps">OSX</span>/Linux, need to test validate with a Win32 platform</li>
179
+ <li>Determine what to do with the files on the <span class="caps">FTP</span> server of the Avaya <span class="caps">CMS</span>, delete them or leave them and add methods to ensure no duplication</li>
179
180
  </ol>
180
181
 
181
182
 
@@ -205,7 +206,7 @@
205
206
 
206
207
  <p>Comments are welcome. Send an email to <a href="mailto:jason@goecke.net">jason [at] goecke.net</a>.</p>
207
208
  <p class="coda">
208
- <a href="mailto:drnicwilliams@gmail.com">Dr Nic</a>, 2nd August 2007<br>
209
+ <a href="mailto:drnicwilliams@gmail.com">Dr Nic</a>, 11th August 2007<br>
209
210
  Theme extended from <a href="http://rb2js.rubyforge.org/">Paul Battley</a>
210
211
  </p>
211
212
  </div>
@@ -18,7 +18,7 @@ The utility provides the following capabilities:
18
18
 
19
19
  # Support of ActiveRecord (means you may use Oracle, MySQL, MS-SQL, Postgres, DB2, etc)
20
20
  # Generate your schema via ActiveRecord Migrations
21
- # Fetch Binary files from the Avaya CMS platform via FTP
21
+ # Fetch Binary or ASCII CSV files from the Avaya CMS platform via FTP
22
22
  # Convert from the defined Binary format to ASCII
23
23
  # Insert the records into the defined database table
24
24
  # Change schema structure via YML configuration file to accommodate various releases of the ECHI format
@@ -95,6 +95,7 @@ h2. ToDo
95
95
  Items to be done to move this out of alpha stage:
96
96
 
97
97
  # 'echi-converter-create' works fine with OSX/Linux, need to test validate with a Win32 platform
98
+ # Determine what to do with the files on the FTP server of the Avaya CMS, delete them or leave them and add methods to ensure no duplication
98
99
 
99
100
 
100
101
  h2. Forum
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.0.2
7
- date: 2007-08-02 00:00:00 -07:00
6
+ version: 0.0.3
7
+ date: 2007-08-11 00:00:00 -07: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
@@ -51,6 +51,7 @@ files:
51
51
  - config/application.yml
52
52
  - config/database.yml
53
53
  - config/extended_version12.yml
54
+ - config/extended_version13.yml
54
55
  - db/migrate/001_create_echi_records.rb
55
56
  - db/migrate/002_create_echi_logs.rb
56
57
  - bin/echi-converter-create