echi-converter 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,29 @@
1
+ History.txt
2
+ License.txt
3
+ Manifest.txt
4
+ README.txt
5
+ Rakefile
6
+ echi-converter
7
+ lib/main.rb
8
+ lib/echi-converter/version.rb
9
+ lib/database.rb
10
+ lib/main.rb
11
+ lib/echi-converter.rb
12
+ scripts/txt2html
13
+ setup.rb
14
+ test/test_echi-converter.rb
15
+ test/test_helper.rb
16
+ website/index.html
17
+ website/index.txt
18
+ website/javascripts/rounded_corners_lite.inc.js
19
+ website/stylesheets/screen.css
20
+ website/template.rhtml
21
+ config/application.yml
22
+ config/database.yml
23
+ config/extended_version12.yml
24
+ db/migrate/001_create_echi_records.rb
25
+ db/migrate/002_create_echi_logs.rb
26
+ bin/echi-converter-create
27
+ examples/extended_version12/chr0003
28
+ examples/extended_version12/chr0003.txt
29
+
@@ -0,0 +1,33 @@
1
+ README for echi_converter
2
+ ==========================
3
+ ECHI Converter - The Binary to ASCII converter for Avaya CMS External Call History files
4
+
5
+ --- background ---
6
+
7
+ See more info on the Avaya ECHI format here (note, these overviews are version specific):
8
+
9
+ http://support.avaya.com/elmodocs2/cms/R12/ECHI.pdf
10
+
11
+ --- command ---
12
+
13
+ Usage: ruby echi-converter-daemon.rb <command> <options> -- <application options>
14
+
15
+ * where <command> is one of:
16
+ start start an instance of the application
17
+ stop stop all instances of the application
18
+ restart stop all instances and restart them afterwards
19
+ run start the application and stay on top
20
+ zap set the application to a stopped state
21
+
22
+ * and where <options> may contain several of the following:
23
+
24
+ -t, --ontop Stay on top (does not daemonize)
25
+ -f, --force Force operation
26
+
27
+ Common options:
28
+ -h, --help Show this message
29
+ --version Show version
30
+
31
+ --- overview ---
32
+
33
+ Blah, blah here
@@ -0,0 +1,143 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+ require 'rake/clean'
4
+ require 'rake/testtask'
5
+ require 'rake/packagetask'
6
+ require 'rake/gempackagetask'
7
+ require 'rake/rdoctask'
8
+ require 'rake/contrib/rubyforgepublisher'
9
+ require 'fileutils'
10
+ require 'hoe'
11
+ require 'active_record'
12
+ require 'yaml'
13
+
14
+ include FileUtils
15
+ require File.join(File.dirname(__FILE__), 'lib', 'echi-converter', 'version')
16
+
17
+ AUTHOR = 'Jason Goecke' # can also be an array of Authors
18
+ EMAIL = "jason [at] goecke.net"
19
+ DESCRIPTION = "ECHI Conversion Utility - Provides a utility to fetch Avaya CMS / ECHI binary files, convert them and insert into a database table via ActiveRecord"
20
+ GEM_NAME = 'echi-converter' # what ppl will type to install your gem
21
+
22
+ @config_file = "~/.rubyforge/user-config.yml"
23
+ @config = nil
24
+ def rubyforge_username
25
+ unless @config
26
+ begin
27
+ @config = YAML.load(File.read(File.expand_path(@config_file)))
28
+ rescue
29
+ puts <<-EOS
30
+ ERROR: No rubyforge config file found: #{@config_file}"
31
+ Run 'rubyforge setup' to prepare your env for access to Rubyforge
32
+ - See http://newgem.rubyforge.org/rubyforge.html for more details
33
+ EOS
34
+ exit
35
+ end
36
+ end
37
+ @rubyforge_username ||= @config["username"]
38
+ end
39
+
40
+ RUBYFORGE_PROJECT = 'echi-converter' # The unix name for your project
41
+ HOMEPATH = "http://#{RUBYFORGE_PROJECT}.rubyforge.org"
42
+ DOWNLOAD_PATH = "http://rubyforge.org/projects/#{RUBYFORGE_PROJECT}"
43
+
44
+ NAME = "echi-converter"
45
+ REV = nil
46
+ # UNCOMMENT IF REQUIRED:
47
+ # REV = `svn info`.each {|line| if line =~ /^Revision:/ then k,v = line.split(': '); break v.chomp; else next; end} rescue nil
48
+ VERS = EchiConverter::VERSION::STRING + (REV ? ".#{REV}" : "")
49
+ CLEAN.include ['**/.*.sw?', '*.gem', '.config', '**/.DS_Store']
50
+ RDOC_OPTS = ['--quiet', '--title', 'echi-converter documentation',
51
+ "--opname", "index.html",
52
+ "--line-numbers",
53
+ "--main", "README",
54
+ "--inline-source"]
55
+
56
+ class Hoe
57
+ def extra_deps
58
+ @extra_deps.reject { |x| Array(x).first == 'hoe' }
59
+ end
60
+ end
61
+
62
+ # Generate all the Rake tasks
63
+ # Run 'rake -T' to see list of generated tasks (from gem root directory)
64
+ hoe = Hoe.new(GEM_NAME, VERS) do |p|
65
+ p.author = AUTHOR
66
+ p.description = DESCRIPTION
67
+ p.email = EMAIL
68
+ p.summary = DESCRIPTION
69
+ p.url = HOMEPATH
70
+ p.rubyforge_name = RUBYFORGE_PROJECT if RUBYFORGE_PROJECT
71
+ p.test_globs = ["test/**/test_*.rb"]
72
+ p.clean_globs |= CLEAN #An array of file patterns to delete on clean.
73
+
74
+ # == Optional
75
+ p.changes = p.paragraphs_of("History.txt", 0..1).join("\n\n")
76
+ #p.extra_deps = [] # An array of rubygem dependencies [name, version], e.g. [ ['active_support', '>= 1.3.1'] ]
77
+ #p.spec_extras = {} # A hash of extra values to set in the gemspec.
78
+ end
79
+
80
+ CHANGES = hoe.paragraphs_of('History.txt', 0..1).join("\n\n")
81
+ PATH = (RUBYFORGE_PROJECT == GEM_NAME) ? RUBYFORGE_PROJECT : "#{RUBYFORGE_PROJECT}/#{GEM_NAME}"
82
+ hoe.remote_rdoc_dir = File.join(PATH.gsub(/^#{RUBYFORGE_PROJECT}\/?/,''), 'rdoc')
83
+
84
+ desc 'Generate website files'
85
+ task :website_generate do
86
+ Dir['website/**/*.txt'].each do |txt|
87
+ sh %{ ruby scripts/txt2html #{txt} > #{txt.gsub(/txt$/,'html')} }
88
+ end
89
+ end
90
+
91
+ desc 'Upload website files to rubyforge'
92
+ task :website_upload do
93
+ host = "#{rubyforge_username}@rubyforge.org"
94
+ remote_dir = "/var/www/gforge-projects/#{PATH}/"
95
+ local_dir = 'website'
96
+ sh %{rsync -aCv #{local_dir}/ #{host}:#{remote_dir}}
97
+ end
98
+
99
+ desc 'Generate and upload website files'
100
+ task :website => [:website_generate, :website_upload, :publish_docs]
101
+
102
+ desc 'Release the website and new gem version'
103
+ task :deploy => [:check_version, :website, :release] do
104
+ puts "Remember to create SVN tag:"
105
+ puts "svn copy svn+ssh://#{rubyforge_username}@rubyforge.org/var/svn/#{PATH}/trunk " +
106
+ "svn+ssh://#{rubyforge_username}@rubyforge.org/var/svn/#{PATH}/tags/REL-#{VERS} "
107
+ puts "Suggested comment:"
108
+ puts "Tagging release #{CHANGES}"
109
+ end
110
+
111
+ desc 'Runs tasks website_generate and install_gem as a local deployment of the gem'
112
+ task :local_deploy => [:website_generate, :install_gem]
113
+
114
+ task :check_version do
115
+ unless ENV['VERSION']
116
+ puts 'Must pass a VERSION=x.y.z release version'
117
+ exit
118
+ end
119
+ unless ENV['VERSION'] == VERS
120
+ puts "Please update your version.rb to match the release version, currently #{VERS}"
121
+ exit
122
+ end
123
+ end
124
+
125
+ ##Add the ability to use ActiveRecord Migrations to create the database
126
+ desc "Migrate the database through scripts in db/migrate. Target specific version with VERSION=x"
127
+ task :migrate => :environment do
128
+ #Load the working directoy and configuration file
129
+ workingdirectory = File.expand_path(File.dirname(__FILE__))
130
+ configfile = workingdirectory + '/config/application.yml'
131
+ config = YAML::load(File.open(configfile))
132
+
133
+ #Load the configured schema
134
+ schemafile = workingdirectory + "/config/" + config["echi_schema"]
135
+ @@echi_schema = YAML::load(File.open(schemafile))
136
+
137
+ ActiveRecord::Migrator.migrate('db/migrate', ENV["VERSION"] ? ENV["VERSION"].to_i : nil )
138
+ end
139
+
140
+ task :environment do
141
+ ActiveRecord::Base.establish_connection(YAML::load(File.open('config/database.yml')))
142
+ ActiveRecord::Base.logger = Logger.new(File.open('log/database.log', 'a'))
143
+ end
@@ -0,0 +1,76 @@
1
+ #!/usr/bin/env ruby
2
+ require 'rubygems'
3
+ require 'yaml'
4
+ require 'fileutils'
5
+ include FileUtils
6
+
7
+ usage = "Usage: echi-converter-create /path/to/directory"
8
+
9
+ if ARGV[0] == nil
10
+ puts usage
11
+ puts "You must specify a directory name"
12
+ exit
13
+ end
14
+
15
+ dest_dir_relative = ARGV[0] || Dir.pwd
16
+ dest_dir = File.expand_path dest_dir_relative
17
+ base_dir = File.expand_path File.dirname(__FILE__)
18
+
19
+ if RUBY_PLATFORM =~ /mswin32/
20
+ slash = "\ ".rstrip!
21
+ puts 'Windows'
22
+ else
23
+ puts 'Linux/OSX'
24
+ slash = "/"
25
+ end
26
+
27
+ #Obtain the details of which Gem is installed
28
+ gem_details = base_dir.split(slash)
29
+ location = gem_details.length - 2
30
+ puts 'Creating new ' + gem_details[location] + ' directory tree in ' + dest_dir
31
+ puts ' '
32
+
33
+ #Now, create the directory, must be a new 'fresh' one
34
+ begin
35
+ result = FileUtils.mkdir dest_dir_relative
36
+ puts 'Created diretory "' + result.to_s + '"'
37
+ rescue => err
38
+ puts 'ERROR: ' + err
39
+ puts 'Failed, exiting...'
40
+ exit
41
+ end
42
+
43
+ #Now create various directories
44
+ logdir = dest_dir + slash +'log'
45
+ filesdir = dest_dir + slash + 'files'
46
+ csvdir = filesdir + slash + 'csv'
47
+ processeddir = filesdir + slash + 'processed'
48
+ toprocessdir = filesdir + slash + 'to_process'
49
+ begin
50
+ FileUtils.mkdir logdir
51
+ FileUtils.mkdir filesdir
52
+ FileUtils.mkdir csvdir
53
+ FileUtils.mkdir processeddir
54
+ FileUtils.mkdir toprocessdir
55
+ rescue => err
56
+ puts 'ERROR: ' + err
57
+ puts 'Failed, exiting...'
58
+ exit
59
+ end
60
+
61
+ #Now, start copying project files files
62
+ substitute = slash + '.'
63
+ base_dir = base_dir.sub('/bin', substitute)
64
+ new_dest_dir = dest_dir + slash + '.'
65
+ exe_file = dest_dir + slash + 'echi-converter'
66
+ begin
67
+ FileUtils.cp_r base_dir, new_dest_dir
68
+ FileUtils.chmod 0755, exe_file
69
+ rescue => err
70
+ puts 'ERROR: ' + err
71
+ puts 'Failed, exiting...'
72
+ exit
73
+ end
74
+
75
+ puts ' '
76
+ puts 'ECHI Conveter directory created! Now ready for use.'
@@ -0,0 +1,33 @@
1
+ #Configuration details for the application
2
+
3
+ #Connection details for the Avaya CMS/ECHI host
4
+ echi_host: localhost
5
+ echi_port: 22
6
+ echi_username: jsgoecke
7
+ echi_password: sanfran2007!
8
+ echi_connect_type: ftp #only ftp supported now, possible for ssh in the future
9
+ echi_ftp_directory: /Users/ftp/anonymous
10
+ echi_ftp_retry: 3
11
+ echi_schema: extended_version12.yml
12
+
13
+ #Currently only ftp supported, but may want to add UUCP/Serial later
14
+ echi_xfer_type: ftp
15
+
16
+ #How frequently to fetch records off of the Avaya CMS ftp server
17
+ fetch_interval: 60 #in seconds
18
+
19
+ #Whether or not to insert into a database, into a csv file or both
20
+ export_type: database
21
+
22
+ #Options are:
23
+ #FATAL: an unhandleable error that results in a program crash
24
+ #ERROR: a handleable error condition
25
+ #WARN: a warning
26
+ #INFO: generic (useful) information about system operation
27
+ #DEBUG: low-level information for developers
28
+ #NONE: turn off logging
29
+ log_level: DEBUG
30
+ #How many log files to create and the length before cycling through
31
+ log_number: 10
32
+ #The size of each individual log file
33
+ log_length: 10240000
@@ -0,0 +1,6 @@
1
+ #Database connection configuration, uses Active Record from Ruby on Rails
2
+ adapter: mysql
3
+ database: echi_records
4
+ username: root
5
+ password:
6
+ host: localhost
@@ -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