-
Notifications
You must be signed in to change notification settings - Fork 0
/
frmConfig.aspx.vb
298 lines (220 loc) · 12.6 KB
/
frmConfig.aspx.vb
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
Imports Modulo
Imports System.Xml
Imports System.Globalization
Imports System.IO
Partial Class frmConfig
Inherits System.Web.UI.Page
Public ws As DIS.DIServer
Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
If Session("colorTop") <> "" Then
estilo.InnerText = "#page-wrapper { background:" & Session("colorContenido") & ";} #barratop{ background:" & Session("colorTop") & ";} .navbar-top-links {background: " & Session("colorTop") & ";} "
estilo.InnerText += ".infousu{background: " & Session("colorInfo") & ";} body { background :" & Session("colorMenu") & " } .nav{ background :inherit }"
End If
If Not Page.IsPostBack Then
Color0.Value = Session("colorTop")
Color1.Value = Session("colorInfo")
Color2.Value = Session("colorMenu")
Color3.Value = Session("colorContenido")
Dim tRow As New TableRow()
Dim tCell As New TableCell()
ws = New DIS.DIServer
ws.Url = "http://SERVERIII/SAP/DIServer.asmx"
Try
Dim Respuesta As XmlNode
Dim sqldato As String = "select top 1 U_arttype as tipo,U_artcan as cantidad ,rutaxml,rutapdf,tipodoc,[smtp],[puerto],[username], [acount],[password],[ssl] from [Ecom].[dbo].[@IL_CONFIG_E] "
Respuesta = ws.ExecuteSQL(Session("Token"), sqldato)
Session("configarttype") = ReadXML(Respuesta.InnerXml, "tipo")
Session("configartcan") = ReadXML(Respuesta.InnerXml, "cantidad")
Session("rutapdf") = ReadXML(Respuesta.InnerXml, "rutaxml")
Session("rutaxml") = ReadXML(Respuesta.InnerXml, "rutapdf")
Session("tipodocventas") = ReadXML(Respuesta.InnerXml, "tipodoc")
Session("smtp") = ReadXML(Respuesta.InnerXml, "smtp")
Session("puerto") = ReadXML(Respuesta.InnerXml, "puerto")
Session("username") = ReadXML(Respuesta.InnerXml, "username")
Session("acount") = ReadXML(Respuesta.InnerXml, "acount")
Session("password") = ReadXML(Respuesta.InnerXml, "password")
Session("ssl") = ReadXML(Respuesta.InnerXml, "ssl")
inputpdf.Value = Session("rutapdf")
inputxml.Value = Session("rutaxml")
DropDownList1.SelectedValue = Session("configarttype")
DropDownList2.SelectedValue = Session("configartcan")
DropDownList3.SelectedValue = Session("tipodocventas")
DropDownList4.SelectedValue = Session("ssl")
inputSMTP.Value = Session("smtp")
inputPUERTO.Value = Session("puerto")
inputUsername.Value = Session("username")
inputAcount.Value = Session("acount")
inputPassword.Value = Session("password")
Catch ex As Exception
End Try
End If
End Sub
'Private Function ReadXML(Xml As String, NodeName As String)
' Dim reader As System.Xml.XmlTextReader = New System.Xml.XmlTextReader(New System.IO.StringReader(Xml))
' Dim valor As String
' valor = ""
' Do While (reader.Read())
' If reader.NodeType = System.Xml.XmlNodeType.Element Then
' If reader.Name.ToUpper = NodeName.ToUpper Then
' valor = reader.ReadElementContentAsString
' End If
' End If
' Loop
' reader.Close()
' reader.Dispose()
' Return valor
'End Function
Protected Sub confirmar_Click(sender As Object, e As EventArgs) Handles confirmar.Click
'Busqueda de facturas venciadas Balance
Dim tRow As New TableRow()
Dim tCell As New TableCell()
ws = New DIS.DIServer
ws.Url = "http://SERVERIII/SAP/DIServer.asmx"
Try
Dim Respuesta As XmlNode
Dim sqldato As String = "update [Ecom].[dbo].[@IL_CONFIG_E] set rutaxml='" & inputxml.Value & "', rutapdf='" & inputpdf.Value & "', U_arttype='" & DropDownList1.SelectedValue & "',U_artcan='" & DropDownList2.SelectedValue & "',tipodoc='" & DropDownList3.SelectedValue & "' "
sqldato = sqldato & " ,ssl='" & DropDownList4.SelectedValue & "' "
sqldato = sqldato & " ,smtp='" & inputSMTP.Value & "' "
sqldato = sqldato & " ,puerto='" & inputPUERTO.Value & "' "
sqldato = sqldato & " ,username='" & inputUsername.Value & "' "
sqldato = sqldato & " ,acount='" & inputAcount.Value & "' "
sqldato = sqldato & " ,password='" & inputPassword.Value & "' "
Respuesta = ws.ExecuteSQL(Session("Token"), sqldato)
Dim fn As String = System.IO.Path.GetFileName(File1.PostedFile.FileName)
Dim bmp As System.Drawing.Bitmap
Dim ms As System.IO.MemoryStream
Dim byteimage() As Byte
Dim imgstring As String = ""
Dim idunico As String = Guid.NewGuid().ToString()
If File1.PostedFile.FileName <> "" Then
bmp = New System.Drawing.Bitmap(File1.PostedFile.InputStream)
ms = New System.IO.MemoryStream
bmp.Save(ms, System.Drawing.Imaging.ImageFormat.Png)
byteimage = ms.ToArray()
imgstring = Convert.ToBase64String(byteimage)
sqldato = "select count(id) as existe from [Ecom].[dbo].[color] "
Respuesta = ws.ExecuteSQL(Session("Token"), sqldato)
If ReadXML(Respuesta.InnerXml, "existe") = "0" Then
sqldato = "INSERT INTO [Ecom].[dbo].[color] ( [barratop] ,[infousu] ,[menu] ,[contenido],[img]) VALUES('" & Color0.Value & "','" & Color1.Value & "' ,'" & Color2.Value & "' ,'" & Color3.Value & "','" & imgstring & "') "
Respuesta = ws.ExecuteSQL(Session("Token"), sqldato)
Else
sqldato = "UPDATE [Ecom].[dbo].[color] SET img='" & imgstring & "', barratop= '" & Color0.Value & "', infousu= '" & Color1.Value & "' ,menu= '" & Color2.Value & "',contenido= '" & Color3.Value & "' "
Respuesta = ws.ExecuteSQL(Session("Token"), sqldato)
End If
Session("logo") = imgstring
Else
sqldato = "select count(id) as existe from [Ecom].[dbo].[color] "
Respuesta = ws.ExecuteSQL(Session("Token"), sqldato)
If ReadXML(Respuesta.InnerXml, "existe") = "0" Then
sqldato = "INSERT INTO [Ecom].[dbo].[color] ( [barratop] ,[infousu] ,[menu] ,[contenido] ) VALUES('" & Color0.Value & "','" & Color1.Value & "' ,'" & Color2.Value & "' ,'" & Color3.Value & "') "
Respuesta = ws.ExecuteSQL(Session("Token"), sqldato)
Else
sqldato = "UPDATE [Ecom].[dbo].[color] SET barratop= '" & Color0.Value & "', infousu= '" & Color1.Value & "' ,menu= '" & Color2.Value & "',contenido= '" & Color3.Value & "' "
Respuesta = ws.ExecuteSQL(Session("Token"), sqldato)
End If
End If
'sqldato = "select count(id) as existe from [Ecom].[dbo].[color] "
'Respuesta = ws.ExecuteSQL(Session("Token"), sqldato)
'If ReadXML(Respuesta.InnerXml, "existe") = "0" Then
' sqldato = "INSERT INTO [Ecom].[dbo].[color] ( [barratop] ,[infousu] ,[menu] ,[contenido],[img]) VALUES('" & Color0.Value & "','" & Color1.Value & "' ,'" & Color2.Value & "' ,'" & Color3.Value & "','" & imgstring & "') "
' Respuesta = ws.ExecuteSQL(Session("Token"), sqldato)
'Else
' sqldato = "UPDATE [Ecom].[dbo].[color] SET img='" & imgstring & "', barratop= '" & Color0.Value & "', infousu= '" & Color1.Value & "' ,menu= '" & Color2.Value & "',contenido= '" & Color3.Value & "' "
' Respuesta = ws.ExecuteSQL(Session("Token"), sqldato)
'End If
' pagewrapper.Style("background") = Color3.Value
Session("colorTop") = Color0.Value
Session("colorInfo") = Color1.Value
Session("colorMenu") = Color2.Value
Session("colorContenido") = Color3.Value
ClientScript.RegisterStartupScript(Me.[GetType](), "aleasrt", "alert('Configuracion Guardada');document.location.href='frmConfig';", True)
Catch ex As Exception
End Try
End Sub
'Protected Sub DESCARGAPRUEBA_Click(sender As Object, e As EventArgs) Handles DESCARGAPRUEBA.Click
' Dim filePath As String = "C:\\export\029BF843-7E57-4436-B3BD-9CF06672C55E.xml"
' Dim File = New FileInfo(filePath)
' If File.Exists Then
' Response.Clear()
' Response.ClearHeaders()
' Response.ClearContent()
' Response.AddHeader("Content-Disposition", "attachment; filename=" + File.Name)
' Response.AddHeader("Content-Length", File.Length.ToString())
' 'Response.ContentType = "text/plain"
' Response.Flush()
' Response.TransmitFile(File.FullName)
' Response.End()
' End If
'End Sub
Protected Sub PruebaEnvioMail_Click(sender As Object, e As EventArgs) Handles PruebaEnvioMail.Click
Dim dilon As String = "Envio Correcto"
Try
Dim oMsg As CDO.Message = New CDO.Message()
Dim iConfg As CDO.Configuration
Dim oFields As ADODB.Fields
Dim oField As ADODB.Field
iConfg = oMsg.Configuration
oFields = iConfg.Fields
'Canal de comunicacion
oField = oFields("http://schemas.microsoft.com/cdo/configuration/sendusing")
oField.Value = CDO.CdoSendUsing.cdoSendUsingPort
'1: cdoSendUsingPickup 2: cdoSendUsingPort
'IP del servidor SMTP
oField = oFields("http://schemas.microsoft.com/cdo/configuration/smtpserver")
oField.Value = inputSMTP.Value
'Tiempo de espera
oField = oFields("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout")
oField.Value = 20 'Segs
'Puerto del SMTP
oField = oFields("http://schemas.microsoft.com/cdo/configuration/smtpserverport")
oField.Value = inputPUERTO.Value '585 TCP/IP
'Tipo de autenticacion
oField = oFields("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate")
oField.Value = CDO.CdoProtocolsAuthentication.cdoBasic
'Nombre de usuario
oField = oFields("http://schemas.microsoft.com/cdo/configuration/sendusername")
oField.Value = inputUsername.Value
'Contraseña
oField = oFields("http://schemas.microsoft.com/cdo/configuration/sendpassword")
oField.Value = inputPassword.Value
'Utiliza SSL
oField = oFields("http://schemas.microsoft.com/cdo/configuration/smtpusessl")
If DropDownList4.SelectedValue = "SI" Then
oField.Value = True
Else
oField.Value = False
End If
'Actualizamos los datos de la cuenta SMTP
oFields.Update()
oMsg.Configuration = iConfg
oMsg.Subject = "Prueba"
'1) Solo texto
oMsg.HTMLBody = "Configuracion Correcta"
'2) Correo en HTML
'oMsg.HTMLBody = "<body></body>"
'Cuentas de Email
oMsg.ReplyTo = Session("acount")
oMsg.To = Session("acount")
oMsg.From = Session("acount")
'Adjuntos
'Dim Attchs As CDO.IBodyPart
'Attchs = oMsg.AddAttachment(adjXML)
'Attchs = oMsg.AddAttachment(adjPDF)
'Attchs = oMsg.AddAttachment("c:\Windows\Factura.pdf")
'Enviamos el correo
oMsg.Send()
'Limpiamos las variables
oMsg = Nothing
iConfg = Nothing
oFields = Nothing
oField = Nothing
' Return "Envio Correcto"
Session("errormail") = Nothing
ClientScript.RegisterStartupScript(Me.[GetType](), "aleasrta", "alert('Envio Correcto');document.location.href='frmConfig'; ", True)
Catch ex As Exception
'ClientScript.RegisterStartupScript(Me.[GetType](), "aleasrt", "alert('" & ex.Message & "');document.location.href='frmConfig';", True)
ClientScript.RegisterStartupScript(Me.[GetType](), "aleasrta", "alert('" & Replace(ex.Message, "'", "") & "');document.location.href='frmConfig'; ", True)
'Return ex.Message
End Try
End Sub
End Class