Module: AssMaintainer::InfoBase::ServerIb::EnterpriseServers::WpConnection Private

Includes:
Support::InfoBaseFind, Support::OleRuntime, Support::Reconnect
Defined in:
lib/ass_maintainer/info_base/server_ib/enterprise_servers/wp_connection.rb

Overview

This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.

Object for comunication with 1C Working process.

Examples:

wp_connection = WpConnection.new(wp_info).connect(infobase_wrapper)

Constant Summary collapse

DROP_MODES =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

Drop infobase modes defines what should do with infobase's database.

  • 0 - databse willn't be deleted
  • 1 - databse will be deleted
  • 2 - database willn't be deleted but will be cleared
{alive_db: 0, destroy_db: 1, clear_db: 2}.freeze

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Support::InfoBaseFind

#infobase_find, #infobase_include?

Methods included from Support::OleRuntime

#_connect, #connected?, #disconnect, runtime_new

Instance Attribute Details

#infobase_wrapperObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



29
30
31
# File 'lib/ass_maintainer/info_base/server_ib/enterprise_servers/wp_connection.rb', line 29

def infobase_wrapper
  @infobase_wrapper
end

#wp_infoObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



31
32
33
# File 'lib/ass_maintainer/info_base/server_ib/enterprise_servers/wp_connection.rb', line 31

def wp_info
  @wp_info
end

Class Method Details

.new(wp_info) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Make new object of anonymous class which included this module.

Parameters:



23
24
25
26
27
# File 'lib/ass_maintainer/info_base/server_ib/enterprise_servers/wp_connection.rb', line 23

def self.new(wp_info)
  Class.new do
    include WpConnection
  end.new wp_info
end

Instance Method Details

#_reconnect_required?Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)


180
181
182
# File 'lib/ass_maintainer/info_base/server_ib/enterprise_servers/wp_connection.rb', line 180

def _reconnect_required?
  getInfoBases.empty?
end

#authenticateObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



76
77
78
79
# File 'lib/ass_maintainer/info_base/server_ib/enterprise_servers/wp_connection.rb', line 76

def authenticate
  AuthenticateAdmin(cluster.user.to_s, cluster.password.to_s)
  authenticate_infobase_admin
end

#authenticate?Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)


93
94
95
# File 'lib/ass_maintainer/info_base/server_ib/enterprise_servers/wp_connection.rb', line 93

def authenticate?
  false
end

#authenticate_infobase_adminObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



81
82
83
84
85
# File 'lib/ass_maintainer/info_base/server_ib/enterprise_servers/wp_connection.rb', line 81

def authenticate_infobase_admin
  AddAuthentication(user, pass)
  ole_connector.GetInfoBaseConnections(ib_info_create)
  true
end

#clusterObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



46
47
48
# File 'lib/ass_maintainer/info_base/server_ib/enterprise_servers/wp_connection.rb', line 46

def cluster
  wp_info.cluster
end

#connect(infobase_wrapper) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Parameters:



67
68
69
70
# File 'lib/ass_maintainer/info_base/server_ib/enterprise_servers/wp_connection.rb', line 67

def connect(infobase_wrapper)
  @infobase_wrapper = infobase_wrapper
  _connect host_port, sagent.platform_require
end

#connectionsObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



118
119
120
# File 'lib/ass_maintainer/info_base/server_ib/enterprise_servers/wp_connection.rb', line 118

def connections
  GetInfoBaseConnections(infobase_info)
end

#drop_connectionsObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



140
141
142
143
144
# File 'lib/ass_maintainer/info_base/server_ib/enterprise_servers/wp_connection.rb', line 140

def drop_connections
  connections.each do |conn|
    Disconnect(conn)
  end
end

#drop_infobase!(mode) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



101
102
103
104
105
# File 'lib/ass_maintainer/info_base/server_ib/enterprise_servers/wp_connection.rb', line 101

def drop_infobase!(mode)
  fail ArgumentError, "Invalid mode #{mode}" unless DROP_MODES[mode]
  lock_infobase!(nil, nil, "BEFORE DROP INFOBASE", '')
  DropInfoBase(infobase_info, DROP_MODES[mode])
end

#drop_sessionsObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



134
135
136
137
138
# File 'lib/ass_maintainer/info_base/server_ib/enterprise_servers/wp_connection.rb', line 134

def drop_sessions
  infobase_wrapper.sessions.each do |sess|
    sess.terminate
  end
end

#host_portObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



50
51
52
# File 'lib/ass_maintainer/info_base/server_ib/enterprise_servers/wp_connection.rb', line 50

def host_port
  "#{wp_info.HostName}:#{wp_info.MainPort}"
end

#ib_info_createObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



87
88
89
90
91
# File 'lib/ass_maintainer/info_base/server_ib/enterprise_servers/wp_connection.rb', line 87

def ib_info_create
  ii = createInfoBaseInfo
  ii.Name = ib_ref
  ii
end

#ib_refObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



72
73
74
# File 'lib/ass_maintainer/info_base/server_ib/enterprise_servers/wp_connection.rb', line 72

def ib_ref
  infobase_wrapper.ib_ref
end

#infobase_exists?Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)


97
98
99
# File 'lib/ass_maintainer/info_base/server_ib/enterprise_servers/wp_connection.rb', line 97

def infobase_exists?
  infobase_include? ib_ref
end

#infobase_infoObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



107
108
109
110
111
# File 'lib/ass_maintainer/info_base/server_ib/enterprise_servers/wp_connection.rb', line 107

def infobase_info
  fail 'Infobase not exists' unless infobase_exists?
  authenticate_infobase_admin
  infobase_find ib_ref
end

#infobasesObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



175
176
177
178
# File 'lib/ass_maintainer/info_base/server_ib/enterprise_servers/wp_connection.rb', line 175

def infobases
  reconnect
  getInfoBases
end

#initialize(wp_info) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Parameters:



34
35
36
# File 'lib/ass_maintainer/info_base/server_ib/enterprise_servers/wp_connection.rb', line 34

def initialize(wp_info)
  @wp_info = wp_info
end

#lock_infobase!(from, to, code, mess) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



146
147
148
149
150
151
# File 'lib/ass_maintainer/info_base/server_ib/enterprise_servers/wp_connection.rb', line 146

def lock_infobase!(from, to, code, mess)
  lock_sessions!(from, to, code, mess)
  lock_schjobs!
  drop_sessions
  drop_connections
end

#lock_schjobs!Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



163
164
165
166
167
# File 'lib/ass_maintainer/info_base/server_ib/enterprise_servers/wp_connection.rb', line 163

def lock_schjobs!
  ii = infobase_info
  ii.ScheduledJobsDenied = true
  UpdateInfoBase(ii)
end

#lock_sessions!(from, to, code, mess) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



122
123
124
125
126
127
128
129
130
131
132
# File 'lib/ass_maintainer/info_base/server_ib/enterprise_servers/wp_connection.rb', line 122

def lock_sessions!(from, to, code, mess)
  fail ArgumentError, 'Permission code won\'t be empty' if\
    code.to_s.empty?
  ii = infobase_info
  ii.DeniedFrom = (from.nil? ? Date.parse('1973.09.07') : from).to_time
  ii.DeniedTo   = (to.nil? ? Date.parse('2073.09.07') : to).to_time
  ii.DeniedMessage = mess.to_s
  ii.SessionsDenied = true
  ii.PermissionCode = code
  UpdateInfoBase(ii)
end

#locked?Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)


113
114
115
116
# File 'lib/ass_maintainer/info_base/server_ib/enterprise_servers/wp_connection.rb', line 113

def locked?
  ii = infobase_info
  ii.SessionsDenied
end

#passObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



58
59
60
# File 'lib/ass_maintainer/info_base/server_ib/enterprise_servers/wp_connection.rb', line 58

def pass
  infobase_wrapper.ib.pwd.to_s
end

#ping?Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)


62
63
64
# File 'lib/ass_maintainer/info_base/server_ib/enterprise_servers/wp_connection.rb', line 62

def ping?
  wp_info.ping?
end

#raise_unless_unlock_possable(err, unlock_code) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



185
186
187
188
189
190
191
192
193
# File 'lib/ass_maintainer/info_base/server_ib/enterprise_servers/wp_connection.rb', line 185

def raise_unless_unlock_possable(err, unlock_code)
  ii = infobase_info
  return if !ii.SessionsDenied
  return if ii.PermissionCode.to_s.empty?
  return if unlock_code.to_s.downcase == ii.PermissionCode
    .to_s.downcase
  fail err, "Infobase is locked and PermissionCode:"\
    " `#{ii.PermissionCode}' not match unlock_code: `#{unlock_code}'"
end

#runtime_typeObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



38
39
40
# File 'lib/ass_maintainer/info_base/server_ib/enterprise_servers/wp_connection.rb', line 38

def runtime_type
  :wp
end

#sagentObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



42
43
44
# File 'lib/ass_maintainer/info_base/server_ib/enterprise_servers/wp_connection.rb', line 42

def sagent
  wp_info.sagent
end

#unlock_schjobs!Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



169
170
171
172
173
# File 'lib/ass_maintainer/info_base/server_ib/enterprise_servers/wp_connection.rb', line 169

def unlock_schjobs!
  ii = infobase_info
  ii.ScheduledJobsDenied = false
  UpdateInfoBase(ii)
end

#unlock_sessions!Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



153
154
155
156
157
158
159
160
161
# File 'lib/ass_maintainer/info_base/server_ib/enterprise_servers/wp_connection.rb', line 153

def unlock_sessions!
  ii = infobase_info
  ii.DeniedFrom          = Date.parse('1973.09.07').to_time
  ii.DeniedTo            = Date.parse('1973.09.07').to_time
  ii.DeniedMessage       = ''
  ii.SessionsDenied      = false
  ii.PermissionCode      = ''
  UpdateInfoBase(ii)
end

#userObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



54
55
56
# File 'lib/ass_maintainer/info_base/server_ib/enterprise_servers/wp_connection.rb', line 54

def user
  infobase_wrapper.ib.usr.to_s
end