-
Notifications
You must be signed in to change notification settings - Fork 0
/
frmImagen.aspx.vb
312 lines (202 loc) · 20.2 KB
/
frmImagen.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
299
300
301
302
303
304
305
306
307
308
309
310
311
312
Imports Modulo
Imports System.Xml
Imports System.Globalization
Imports System.IO
Imports System.Net
Imports System.Text
Partial Class frmImagen
Inherits System.Web.UI.Page
Public ws As DIS.DIServer
Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
If Not Page.IsPostBack Then
If Session("Imagen") = Session("ftp") Then
imagenperfil.Src = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAhIAAAISCAMAAACu49aNAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAyJpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdp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RLyeiEbCRYQUEa9fO5FIpBEhRsTrWiQSeUSIEfE6G4kE32cpR8QBw8QBJGxEyBHx+nUUEg1ECBLxJhWBxBQiBIl4MxeBBN+ULknEm9kIJBAhScSbiXASNiIkiXjzJpyEhQhRIt5YoSSqiBAl4k0tlMQUIkSJeJMPJZFFhCgRb2dDSdxBhCgRb38ZSgIRskS8/VEYCRcRskS8fRtGwkKEMBFvrRASDUQIE/E2FUKiighhIt5WQ0hMIUKYiLf5EBJZRAgTEYUEIkSJePfLEBIziBAmIpQEIqSJCCWBCGki3r2LSgIRUkSEkLAQIU5ERBKIkCPinROFBCIEiXiXikACEZJEnDyaRBUR4kREIIEIWSLCSSBCmIiTcyEkECFNxMn80SQQIU5ECIkMIsSJCCGRRYQ4EdFIIEKQiEgkECFJRBQSiBAl4uSrUBKIkCXi5L/CSCBCmIhQEoiQJiKMBCLEiYhCAhGiREQggQhZIsJJIEKYiBASiJAnIowEIsSJ+OfRJBAhT8RxSCBChIhjkECEDBH/vBKVBCKEiPj/qCQQIUVECIkHiBAnIoREHRHiRETbOBAhSMQ+Ev8VYAB7Ct9tl4K65QAAAABJRU5ErkJggg=="
Else
imagenperfil.Src = Session("Imagen")
End If
''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 = " select U_art,U_cantidad,U_observacion,U_imagen,Code from [@IL_DISCREPANCIA] where U_factura='" & Session("DocNumDis") & "' and U_status='1' "
' Respuesta = ws.ExecuteSQL(Session("Token"), sqldato)
' ReadXML(Respuesta.InnerXml, "U_art")
'Catch ex As Exception
'End Try
End If
End Sub
Protected Sub secretbutton_ServerClick(sender As Object, e As EventArgs) Handles secretbutton.ServerClick
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
Public Overloads Shared Function ResizeImage(bmSource As Drawing.Bitmap, TargetWidth As Int32, TargetHeight As Int32) As Drawing.Bitmap
Dim bmDest As New Drawing.Bitmap(TargetWidth, TargetHeight, Drawing.Imaging.PixelFormat.Format32bppArgb)
Dim nSourceAspectRatio = bmSource.Width / bmSource.Height
Dim nDestAspectRatio = bmDest.Width / bmDest.Height
Dim NewX = 0
Dim NewY = 0
Dim NewWidth = bmDest.Width
Dim NewHeight = bmDest.Height
If nDestAspectRatio = nSourceAspectRatio Then
'same ratio
ElseIf nDestAspectRatio > nSourceAspectRatio Then
'Source is taller
NewWidth = Convert.ToInt32(Math.Floor(nSourceAspectRatio * NewHeight))
NewX = Convert.ToInt32(Math.Floor((bmDest.Width - NewWidth) / 2))
Else
'Source is wider
NewHeight = Convert.ToInt32(Math.Floor((1 / nSourceAspectRatio) * NewWidth))
NewY = Convert.ToInt32(Math.Floor((bmDest.Height - NewHeight) / 2))
End If
Using grDest = Drawing.Graphics.FromImage(bmDest)
With grDest
.CompositingQuality = Drawing.Drawing2D.CompositingQuality.HighQuality
.InterpolationMode = Drawing.Drawing2D.InterpolationMode.HighQualityBicubic
.PixelOffsetMode = Drawing.Drawing2D.PixelOffsetMode.HighQuality
.SmoothingMode = Drawing.Drawing2D.SmoothingMode.AntiAlias
.CompositingMode = Drawing.Drawing2D.CompositingMode.SourceOver
.DrawImage(bmSource, NewX, NewY, NewWidth, NewHeight)
End With
End Using
Return bmDest
End Function
Protected Sub subirr_ServerClick(sender As Object, e As EventArgs) Handles subirr.ServerClick
' Dim misdatos As String = "ftp://192.168.52.105/" & File1.PostedFile.FileName
''FTP Server URL.
'Dim ftp As String = "ftp://192.168.52.105/"
''FTP Folder name. Leave blank if you want to upload to root folder.
'Dim ftpFolder As String = "/"
'Dim fileBytes As Byte() = Nothing
''Read the FileName and convert it to Byte array.
'Dim fileName As String = Path.GetFileName(File1.PostedFile.FileName)
'Using fileStream As New StreamReader(File1.PostedFile.InputStream)
' fileBytes = Encoding.UTF8.GetBytes(fileStream.ReadToEnd())
' fileStream.Close()
'End Using
'Try
' 'Create FTP Request.
' Dim request As FtpWebRequest = DirectCast(WebRequest.Create(ftp & ftpFolder & fileName), FtpWebRequest)
' request.Method = WebRequestMethods.Ftp.UploadFile
' 'Enter FTP Server credentials.
' 'request.Credentials = New NetworkCredential("UserName", "Password")
' request.ContentLength = fileBytes.Length
' request.UsePassive = True
' request.UseBinary = True
' request.ServicePoint.ConnectionLimit = fileBytes.Length
' request.EnableSsl = False
' Using requestStream As Stream = request.GetRequestStream()
' requestStream.Write(fileBytes, 0, fileBytes.Length)
' requestStream.Close()
' End Using
' Dim response As FtpWebResponse = DirectCast(request.GetResponse(), FtpWebResponse)
' response.Close()
'Catch ex As WebException
' 'Throw New Exception(TryCast(ex.Response, FtpWebResponse).StatusDescription)
'End Try
'Dim unicoID As String = Guid.NewGuid().ToString() & System.IO.Path.GetExtension(File1.PostedFile.FileName)
'Try
' Dim request As System.Net.FtpWebRequest = DirectCast(System.Net.WebRequest.Create(Session("ftp") & unicoID), System.Net.FtpWebRequest)
''request.Credentials = New System.Net.NetworkCredential("user", "password")
'request.Method = System.Net.WebRequestMethods.Ftp.UploadFile
'Dim s As IO.Stream = File1.PostedFile.InputStream
'Dim b(s.Length) As Byte
's.Read(b, 0, s.Length)
'Dim c(Encoding.UTF8.GetCharCount(b)) As Char
'Encoding.UTF8.GetChars(b, 0, s.Length, c, 0)
'Dim strz As System.IO.Stream = request.GetRequestStream()
'strz.Write(b, 0, b.Length)
'strz.Close()
'strz.Dispose()
'Catch ex As Exception
'End Try
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()
'Try
' If File1.PostedFile.ContentLength <> 0 Then
Try
'File1.PostedFile.SaveAs(Server.MapPath("/imagenes/") + idunico + System.IO.Path.GetExtension(File1.PostedFile.FileName))
'imagenperfil.Src = "file:///" + Server.MapPath("/imagenes/") + idunico + System.IO.Path.GetExtension(File1.PostedFile.FileName)
'Session("Imagen") = "file:///" + Server.MapPath("/imagenes/") + idunico + System.IO.Path.GetExtension(File1.PostedFile.FileName)
bmp = New System.Drawing.Bitmap(File1.PostedFile.InputStream)
Dim ratioX = 480 / bmp.Width
Dim ratioY = 480 / bmp.Height
Dim ratio = Math.Min(ratioX, ratioY)
Dim newWidth = (bmp.Width * ratio)
Dim newHeight = (bmp.Height * ratio)
bmp = New System.Drawing.Bitmap(bmp, New Drawing.Size(newWidth, newHeight))
ms = New System.IO.MemoryStream
bmp.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg)
byteimage = ms.ToArray()
imgstring = Convert.ToBase64String(byteimage)
ws = New DIS.DIServer
ws.Url = "http://SERVERIII/SAP/DIServer.asmx"
Dim Respuesta As XmlNode
Dim ahora = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
Dim sqldato As String = ""
sqldato = "select count(id) as existe from [Ecom].[dbo].[perfil] where usu='" & Session("usuCode") & "'"
Respuesta = ws.ExecuteSQL(Session("Token"), sqldato)
If ReadXML(Respuesta.InnerXml, "existe") = "0" Then
sqldato = "INSERT INTO [Ecom].[dbo].[perfil] ([tipo], [usu] ,[img]) VALUES('" & Session("usutipo") & "','" & Session("usuCode") & "' ,'" & imgstring & "') "
Respuesta = ws.ExecuteSQL(Session("Token"), sqldato)
Else
sqldato = "UPDATE [Ecom].[dbo].[perfil] SET img= '" & imgstring & "' where usu='" & Session("usuCode") & "'"
Respuesta = ws.ExecuteSQL(Session("Token"), sqldato)
End If
Session("Imagen") = "data:image/png;base64," & imgstring
ClientScript.RegisterStartupScript(Me.[GetType](), "aleasrt", "alert('Imagen guardada');document.location.href='frmImagen';", True)
Catch ex As Exception
End Try
'Try
' If File1.PostedFile.ContentLength <> 0 Then
' ws = New DIS.DIServer
' ws.Url = "http://SERVERIII/SAP/DIServer.asmx"
' Dim Respuesta As XmlNode
' Dim ahora = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
' Dim sqldato As String = ""
' If Session("usutipo") = "cliente" Then
' sqldato = "insert into [@IL_IMGS] (Code,Name,U_codigo ,U_tipo ,U_imagen,u_fecha )values((select COUNT(*)+1 from [@IL_IMGS] ),(select COUNT(*)+1 from [@IL_IMGS] ),'" & Session("usuCode") & "','cliente','" & unicoID & "','" & ahora & "') "
' Respuesta = ws.ExecuteSQL(Session("Token"), sqldato)
' 'sqldato = "update OCRD set U_IL_imagen='data:image/png;base64," & imgstring & "' where CardCode='" & Session("usuCode") & "'"
' 'Respuesta = ws.UpdateObject(Session("Token"), "oBusinessPartners", "<CardCode>" & Session("usuCode") & "</CardCode>", "<BusinessPartners><row><U_IL_imagen>" & imgstring & "</U_IL_imagen></row></BusinessPartners>", "")
' End If
' If Session("usutipo") = "venta" Then
' sqldato = "insert into [@IL_IMGS] (Code,Name,U_codigo ,U_tipo ,U_imagen,u_fecha )values((select COUNT(*)+1 from [@IL_IMGS] ),(select COUNT(*)+1 from [@IL_IMGS] ),'" & Session("usuCode") & "','venta','" & unicoID & "','" & ahora & "') "
' Respuesta = ws.ExecuteSQL(Session("Token"), sqldato)
' 'sqldato = "update OSLP set U_IL_imagen='data:image/png;base64," & imgstring & "' where SlpCode='" & Session("usuCode") & "'"
' ' Respuesta = ws.UpdateObject(Session("Token"), "oSalesPersons", "<SalesEmployeeCode>" & Session("usuCode") & "</SalesEmployeeCode>", "<SalesPersons><row><U_IL_imagen>" & imgstring & "</U_IL_imagen></row></SalesPersons>", "")
' End If
' If Session("usutipo") = "admin" Then
' sqldato = "insert into [@IL_IMGS] (Code,Name,U_codigo ,U_tipo ,U_imagen,u_fecha )values((select COUNT(*)+1 from [@IL_IMGS] ),(select COUNT(*)+1 from [@IL_IMGS] ),'" & Session("usuCode") & "','admin','" & unicoID & "','" & ahora & "') "
' Respuesta = ws.ExecuteSQL(Session("Token"), sqldato)
' 'sqldato = "update OSLP set U_IL_imagen='data:image/png;base64," & imgstring & "' where SlpCode='" & Session("usuCode") & "'"
' ' Respuesta = ws.UpdateObject(Session("Token"), "oSalesPersons", "<SalesEmployeeCode>" & Session("usuCode") & "</SalesEmployeeCode>", "<SalesPersons><row><U_IL_imagen>" & imgstring & "</U_IL_imagen></row></SalesPersons>", "")
' End If
' Session("Imagen") = Session("ftp") + unicoID
' ClientScript.RegisterStartupScript(Me.[GetType](), "aleasrt", "alert('Imagen guardada');document.location.href='frmImagen';", True)
' Else
' ClientScript.RegisterStartupScript(Me.[GetType](), "aleasrt", "alert('seleccione una imagen valida');document.location.href='frmImagen';", True)
' End If
'Catch ex As Exception
'End Try
End Sub
End Class