-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclass_tms.prg
316 lines (254 loc) · 11.1 KB
/
class_tms.prg
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
#include <hmg.ch>
#include "hbclass.ch"
#define true .T.
#define false .F.
CREATE CLASS HostConect
VAR Name INIT ''
VAR User INIT ''
VAR DataBase INIT ''
VAR Password INIT ''
VAR Conectado INIT false
END CLASS
CREATE CLASS InfoEmpresa
VAR Empresa INIT {}
VAR nPos INIT 0
VAR id INIT 0
VAR Ambiente INIT 0
VAR Nome INIT ''
VAR Fantasia INIT ''
VAR sigla_cia INIT ''
VAR CNPJ INIT ''
VAR Fone INIT ''
VAR email_contabil INIT ''
VAR email_comercial INIT ''
VAR Portal INIT ''
VAR gmail1_login INIT ''
VAR gmail1_senha INIT ''
VAR gmail2_login INIT ''
VAR gmail2_senha INIT ''
VAR smtp_servidor INIT ''
VAR smtp_pass INIT ''
VAR smtp_email INIT ''
VAR smtp_login INIT ''
VAR smtp_senha INIT ''
VAR smtp_porta INIT 0
VAR smtp_autentica INIT 0
VAR email_CCO INIT ''
VAR pathShared INIT ''
VAR cte_path INIT ''
METHOD Adds()
METHOD Clean()
METHOD QtdeEmpresas()
METHOD SetFolders(n) SETGET
METHOD SetEmpresa() SETGET
METHOD SetByID() SETGET
END CLASS
METHOD Adds( oBjetoEmp ) CLASS InfoEmpresa
AADD( ::Empresa, oBjetoEmp )
::nPos := HMG_LEN(::Empresa)
RETURN SELF
METHOD Clean() CLASS InfoEmpresa
::Empresa := {}
::nPos := 0
::id := 0
::Ambiente := 0
::Nome := ''
::Fantasia := ''
::sigla_cia := ''
::CNPJ := ''
::Fone := ''
::email_contabil := ''
::email_comercial := ''
::Portal := ''
::gmail1_login := ''
::gmail1_senha := ''
::gmail2_login := ''
::gmail2_senha := ''
::smtp_servidor := ''
::smtp_pass := ''
::smtp_email := ''
::smtp_login := ''
::smtp_senha := ''
::smtp_porta := 0
::smtp_autentica := 0
::email_CCO := ''
::pathShared := ''
::cte_path := ''
RETURN SELF
METHOD QtdeEmpresas() CLASS InfoEmpresa
RETURN HMG_LEN( ::Empresa )
METHOD SetFolders(n) CLASS InfoEmpresa
Local nLen := HMG_LEN(::Empresa)
if !( ValType(n) == 'N' ) .OR. ( n < 1 ) .OR. ( n > nLen )
n := 1
end
if ( nLen == 0 )
::nPos := 0
::id := 0
::Ambiente := 0
::Nome := ''
::Fantasia := ''
::sigla_cia := ''
::CNPJ := ''
::Fone := ''
::email_contabil := ''
::email_comercial := ''
::Portal := ''
::gmail1_login := ''
::gmail1_senha := ''
::gmail2_login := ''
::gmail2_senha := ''
::smtp_servidor := ''
::smtp_pass := ''
::smtp_email := ''
::smtp_login := ''
::smtp_senha := ''
::smtp_porta := 0
::smtp_autentica := 0
::email_CCO := ''
::pathShared := ''
::cte_path := ''
else
::nPos := n
::id := ::Empresa[n]:FieldGet('emp_id')
::Ambiente := ::Empresa[n]:FieldGet('emp_ambiente_sefaz')
::Nome := AllTrim( ::Empresa[n]:FieldGet('empresa') )
::Fantasia := AllTrim( ::Empresa[n]:FieldGet('emp_nome_fantasia') )
::sigla_cia := AllTrim( ::Empresa[n]:FieldGet('emp_sigla_cia') )
::CNPJ := ::Empresa[n]:FieldGet('emp_cnpj')
::Fone := AllTrim( ::Empresa[n]:FieldGet('emp_fone1') )
::email_contabil := AllTrim( ::Empresa[n]:FieldGet('emp_email_contabil') )
::email_comercial := AllTrim( ::Empresa[n]:FieldGet('emp_email_comercial') )
::Portal := AllTrim( ::Empresa[n]:FieldGet('emp_portal') )
::gmail1_login := AllTrim( ::Empresa[n]:FieldGet('emp_gmail1_login') )
::gmail1_senha := AllTrim( ::Empresa[n]:FieldGet('emp_gmail1_senha') )
::gmail2_login := AllTrim( ::Empresa[n]:FieldGet('emp_gmail2_login') )
::gmail2_senha := AllTrim( ::Empresa[n]:FieldGet('emp_gmail2_senha') )
::smtp_servidor := AllTrim( ::Empresa[n]:FieldGet('emp_smtp_servidor') )
::smtp_pass := AllTrim( ::Empresa[n]:FieldGet('emp_smtp_pass') )
::smtp_email := AllTrim( ::Empresa[n]:FieldGet('emp_smtp_email') )
::smtp_login := AllTrim( ::Empresa[n]:FieldGet('emp_smtp_login') )
::smtp_senha := AllTrim( ::Empresa[n]:FieldGet('emp_smtp_senha') )
if Empty(::smtp_pass)
::smtp_pass := ::smtp_senha
endif
::smtp_porta := ::Empresa[n]:FieldGet('emp_smtp_porta')
::smtp_autentica := ::Empresa[n]:FieldGet('emp_smtp_autentica')
::email_CCO := ::Empresa[n]:FieldGet('emp_email_CCO')
::pathShared := RegistryRead('HKEY_CURRENT_USER\SOFTWARE\Sistrom\DFeMonitor\InstallPath\dfePath')
::cte_path := ::pathShared + ::Empresa[::nPos]:FieldGet('emp_cnpj') + "\CTe\"
if !hb_DirExists( ::cte_path )
hb_DirBuild( ::cte_path )
end
end
RETURN SELF
METHOD SetEmpresa( n ) CLASS InfoEmpresa
Local nLen := HMG_LEN(::Empresa)
if !( ValType(n) == 'N' ) .OR. ( n < 1 ) .OR. ( n > nLen )
n := 1
end
if ( nLen == 0 )
::nPos := 0
::id := 0
::Ambiente := 0
::Nome := ''
::Fantasia := ''
::sigla_cia := ''
::CNPJ := ''
::Fone := ''
::email_contabil := ''
::email_comercial := ''
::Portal := ''
::gmail1_login := ''
::gmail1_senha := ''
::gmail2_login := ''
::gmail2_senha := ''
::smtp_servidor := ''
::smtp_pass := ''
::smtp_email := ''
::smtp_login := ''
::smtp_senha := ''
::smtp_porta := 0
::smtp_autentica := 0
::email_CCO := ''
::cte_path := ''
else
::nPos := n
::id := ::Empresa[n]:FieldGet('emp_id')
::Ambiente := ::Empresa[n]:FieldGet('emp_ambiente_sefaz')
::Nome := AllTrim( ::Empresa[n]:FieldGet('empresa') )
::Fantasia := AllTrim( ::Empresa[n]:FieldGet('emp_nome_fantasia') )
::sigla_cia := AllTrim( ::Empresa[n]:FieldGet('emp_sigla_cia') )
::CNPJ := ::Empresa[n]:FieldGet('emp_cnpj')
::Fone := AllTrim( ::Empresa[n]:FieldGet('emp_fone1') )
::email_contabil := AllTrim( ::Empresa[n]:FieldGet('emp_email_contabil') )
::email_comercial := AllTrim( ::Empresa[n]:FieldGet('emp_email_comercial') )
::Portal := AllTrim( ::Empresa[n]:FieldGet('emp_portal') )
::gmail1_login := AllTrim( ::Empresa[n]:FieldGet('emp_gmail1_login') )
::gmail1_senha := AllTrim( ::Empresa[n]:FieldGet('emp_gmail1_senha') )
::gmail2_login := AllTrim( ::Empresa[n]:FieldGet('emp_gmail2_login') )
::gmail2_senha := AllTrim( ::Empresa[n]:FieldGet('emp_gmail2_senha') )
::smtp_servidor := AllTrim( ::Empresa[n]:FieldGet('emp_smtp_servidor') )
::smtp_pass := AllTrim( ::Empresa[n]:FieldGet('emp_smtp_pass') )
::smtp_email := AllTrim( ::Empresa[n]:FieldGet('emp_smtp_email') )
::smtp_login := AllTrim( ::Empresa[n]:FieldGet('emp_smtp_login') )
::smtp_senha := AllTrim( ::Empresa[n]:FieldGet('emp_smtp_senha') )
::smtp_porta := ::Empresa[n]:FieldGet('emp_smtp_porta')
::smtp_autentica := ::Empresa[n]:FieldGet('emp_smtp_autentica')
::email_CCO := ::Empresa[n]:FieldGet('emp_email_CCO')
::cte_path := ::pathShared + ::Empresa[n]:FieldGet('emp_cnpj') + "\CTe\"
end
RETURN SELF
METHOD SetByID( nId ) CLASS InfoEmpresa
::nPos := hb_Ascan( ::Empresa, {|oVal| oVal:FieldGet('emp_id') == nId} )
if ( ::nPos == 0 )
::id := 0
::Ambiente := 0
::Nome := ''
::Fantasia := ''
::sigla_cia := ''
::CNPJ := ''
::Fone := ''
::email_contabil := ''
::email_comercial := ''
::Portal := ''
::gmail1_login := ''
::gmail1_senha := ''
::gmail2_login := ''
::gmail2_senha := ''
::smtp_servidor := ''
::smtp_pass := ''
::smtp_email := ''
::smtp_login := ''
::smtp_senha := ''
::smtp_porta := 0
::smtp_autentica := 0
::email_CCO := ''
::pathShared := ''
::cte_path := ''
else
::id := ::Empresa[::nPos]:FieldGet('emp_id')
::Ambiente := ::Empresa[::nPos]:FieldGet('emp_ambiente_sefaz')
::Nome := AllTrim( ::Empresa[::nPos]:FieldGet('empresa') )
::Fantasia := AllTrim( ::Empresa[::nPos]:FieldGet('emp_nome_fantasia') )
::sigla_cia := AllTrim( ::Empresa[::nPos]:FieldGet('emp_sigla_cia') )
::CNPJ := ::Empresa[::nPos]:FieldGet('emp_cnpj')
::Fone := AllTrim( ::Empresa[::nPos]:FieldGet('emp_fone1') )
::email_contabil := AllTrim( ::Empresa[::nPos]:FieldGet('emp_email_contabil') )
::email_comercial := AllTrim( ::Empresa[::nPos]:FieldGet('emp_email_comercial') )
::Portal := AllTrim( ::Empresa[::nPos]:FieldGet('emp_portal') )
::gmail1_login := AllTrim( ::Empresa[::nPos]:FieldGet('emp_gmail1_login') )
::gmail1_senha := AllTrim( ::Empresa[::nPos]:FieldGet('emp_gmail1_senha') )
::gmail2_login := AllTrim( ::Empresa[::nPos]:FieldGet('emp_gmail2_login') )
::gmail2_senha := AllTrim( ::Empresa[::nPos]:FieldGet('emp_gmail2_senha') )
::smtp_servidor := AllTrim( ::Empresa[::nPos]:FieldGet('emp_smtp_servidor') )
::smtp_pass := AllTrim( ::Empresa[::nPos]:FieldGet('emp_smtp_pass') )
::smtp_email := AllTrim( ::Empresa[::nPos]:FieldGet('emp_smtp_email') )
::smtp_login := AllTrim( ::Empresa[::nPos]:FieldGet('emp_smtp_login') )
::smtp_senha := AllTrim( ::Empresa[::nPos]:FieldGet('emp_smtp_senha') )
::smtp_porta := ::Empresa[::nPos]:FieldGet('emp_smtp_porta')
::smtp_autentica := ::Empresa[::nPos]:FieldGet('emp_smtp_autentica')
::email_CCO := ::Empresa[::nPos]:FieldGet('emp_email_CCO')
::cte_path := ::pathShared + ::Empresa[::nPos]:FieldGet('emp_cnpj') + "\CTe\"
end
RETURN SELF