538 lines
28 KiB
Plaintext
538 lines
28 KiB
Plaintext
<%@ WebHandler Language="VB" Class="SIGPolizaVirtual" %>
|
|
|
|
Imports Fluent
|
|
Imports System
|
|
Imports System.Web
|
|
Imports System.Net.Http
|
|
Imports System.Web.Http
|
|
Imports System.Data
|
|
Imports Newtonsoft.Json
|
|
Imports Newtonsoft.Json.Linq
|
|
Imports Extensiones
|
|
Imports System.IO
|
|
Imports System.Runtime.CompilerServices
|
|
|
|
Public Class SIGPolizaVirtual : Implements IHttpHandler, IRequiresSessionState
|
|
|
|
Protected ReadOnly Property User As String = "cslth.2809@jcilink.com"
|
|
Protected ReadOnly Property Password As String = "ff31580a95f36b51ad27f970428b77a5a9245076"
|
|
|
|
#Region "U S U A R I O - T O K E N"
|
|
|
|
Private Function ValidaUsuarioSistema(CveEmpresa As Integer, Optional CveUsuario As Integer = 100) As Usuario
|
|
|
|
Dim UsuarioToken As Usuario = Nothing
|
|
Dim ObjUsuarios As New ClsSisUsuarios
|
|
If ObjUsuarios.GetUsuarios(CveUsuario) Then
|
|
If ObjUsuarios.DtResultados.Rows.Count > 0 Then
|
|
Dim Usuario = ObjUsuarios.DtResultados.Rows(0)("Usuario").ToString()
|
|
Dim Contrasenia = ObjUsuarios.DtResultados.Rows(0)("Contraseña").ToString()
|
|
UsuarioToken = ObjUsuarios.ValidaUsuario(Usuario, Contrasenia, IMEI, CveEmpresa)
|
|
UsuarioToken.CveEmpresa = CveEmpresa
|
|
CreaObjetoEmpresa(UsuarioToken)
|
|
End If
|
|
End If
|
|
ObjUsuarios.Dispose()
|
|
Return UsuarioToken
|
|
End Function
|
|
Private Sub CreaObjetoEmpresa(ByRef UsuarioToken As Usuario)
|
|
|
|
Dim ObjEmpresa As New ClsSisEmpresas()
|
|
If ObjEmpresa.GetEmpresas(UsuarioToken.CveEmpresa, "-1", "-1", "-1", "-1") Then
|
|
If ObjEmpresa.GetEmpresasFuncionalidades(UsuarioToken.CveEmpresa) Then
|
|
Dim dttmp As Data.DataTable = ObjEmpresa.DtResultados
|
|
|
|
Dim EmpresasFuncionalidades As New HybridDictionary
|
|
For Each Row As Data.DataRow In dttmp.Rows
|
|
EmpresasFuncionalidades.Add(Convert.ToInt32(Row("CveFuncionalidad")), Row("Valor").ToString)
|
|
Next
|
|
ObjEmpresa.Empresa.SetFuncionalidades(EmpresasFuncionalidades)
|
|
End If
|
|
|
|
UsuarioToken.Empresa = ObjEmpresa.Empresa
|
|
End If
|
|
ObjEmpresa.Dispose()
|
|
End Sub
|
|
#End Region
|
|
|
|
Public Sub ProcessRequest(ByVal context As HttpContext) Implements IHttpHandler.ProcessRequest
|
|
context.Response.ContentType = "application/json"
|
|
Dim usuario = ValidaUsuarioSistema(140, 100)
|
|
Dim ObjFactura As New Modelos.Factura(usuario, 898028, 140)
|
|
|
|
GeneraPolizaVentaWS(context, ObjFactura)
|
|
'GeneraPolizaVentaLTHWSD(context)
|
|
'GeneraIndicadores(context)
|
|
End Sub
|
|
|
|
|
|
Public ReadOnly Property IsReusable() As Boolean Implements IHttpHandler.IsReusable
|
|
Get
|
|
Return False
|
|
End Get
|
|
End Property
|
|
|
|
Protected Sub GeneraPolizaVentaWS(ByVal context As HttpContext, ObjFactura As Modelos.Factura)
|
|
Dim obj As New MPolizaVentaWS
|
|
'DATOS DEL CLIENTE
|
|
obj.customer_name = ObjFactura.Cliente.Nombre
|
|
obj.customer_last_name1 = ""
|
|
obj.customer_last_name2 = ""
|
|
obj.customer_birthday = Nothing
|
|
obj.customer_phone = ObjFactura.Cliente.Telefono
|
|
obj.customer_email = ObjFactura.Cliente.Mail
|
|
obj.customer_gender = "03" 'OTRO GENERO
|
|
obj.customer_advertising = False
|
|
obj.customer_car_brand = "00"
|
|
obj.customer_car_model = "00"
|
|
obj.customer_car_year = ObjFactura.Fecha.Year
|
|
|
|
'DATOS DE VENTA
|
|
obj.sale_date = Now
|
|
obj.sale_paidby = "01"
|
|
obj.sale_type = "01" 'PISO
|
|
obj.sale_type_service = "01" 'PARTICULAR
|
|
obj.sale_total = ObjFactura.Total
|
|
obj.sale_discount = 0 'ObjFactura.SubTotal
|
|
obj.sale_id = GuidGenerator.GenerateTimeBasedGuid().ToString()
|
|
|
|
'Dim PS = ObjFactura.DtDetalle.Rows(0)
|
|
'DATOS DEL PRODUCTO
|
|
obj.product_code = "174925"
|
|
obj.product_unique_code = "65047187"
|
|
obj.product_sale_type = "02" 'AJUSTE
|
|
|
|
'DATOS DE USADO
|
|
obj.used_product = True
|
|
obj.used_brand = "01"
|
|
obj.used_bci = "25"
|
|
obj.used_month = 1
|
|
obj.used_year = 2015
|
|
obj.used_sale_date = ObjFactura.Fecha
|
|
|
|
EnviarPolizaVentaWS(context, obj)
|
|
End Sub
|
|
|
|
Protected Sub GeneraPolizaVentaLTHWSD(ByVal context As HttpContext, ObjFactura As Modelos.Factura)
|
|
Dim obj As New MPolizaVentaLTHWSD
|
|
'DATOS DEL CLIENTE
|
|
obj.customer_name = "JOSE ENRIQUE"
|
|
obj.customer_last_name1 = "VIZCARA"
|
|
obj.customer_last_name2 = "RENDON"
|
|
obj.customer_birthday = Now
|
|
obj.customer_phone = "8186545256"
|
|
obj.customer_email = "mail@mail.com"
|
|
obj.customer_gender = "02"
|
|
obj.customer_advertising = False
|
|
obj.customer_car_brand = "02"
|
|
obj.customer_car_model = "741"
|
|
obj.customer_car_year = 2015
|
|
|
|
'DATOS DE VENTA
|
|
obj.sale_date = Now
|
|
obj.sale_paidby = "01"
|
|
obj.sale_type = "01"
|
|
obj.sale_type_service = "01"
|
|
obj.sale_discount = 0
|
|
obj.sale_id = GuidGenerator.GenerateTimeBasedGuid().ToString()
|
|
|
|
'DATOS DEL PRODUCTO
|
|
obj.product_code = "174925"
|
|
obj.product_unique_code = "65047187"
|
|
obj.product_sale_type = "01"
|
|
|
|
'DATOS DE USADO
|
|
obj.used_product = True
|
|
obj.used_brand = "01"
|
|
obj.used_bci = "25"
|
|
obj.used_month = 1
|
|
obj.used_year = 2015
|
|
obj.used_sale_date = Now
|
|
|
|
EnviarPolizaVentaLTHWSD(context, obj)
|
|
End Sub
|
|
Protected Sub GeneraIndicadores(ByVal context As HttpContext)
|
|
Dim obj As New MIndicador(True)
|
|
EnviarPolizaIndicadores(context, obj)
|
|
End Sub
|
|
|
|
Protected Sub EnviarPolizaVentaLTHWSD(ByVal context As HttpContext, obj As MPolizaVentaLTHWSD)
|
|
Dim Retorno As String = "[]"
|
|
Try
|
|
Using wc As New HttpClient()
|
|
Dim Url = New Uri("http://polizavirtual.com.mx/lthwsd/api/Venta")
|
|
Dim Parametros = New List(Of KeyValuePair(Of String, String))
|
|
|
|
Parametros.Add(New KeyValuePair(Of String, String)("User", User))
|
|
Parametros.Add(New KeyValuePair(Of String, String)("password", Password))
|
|
Parametros.Add(New KeyValuePair(Of String, String)("customer_name", obj.customer_name))
|
|
Parametros.Add(New KeyValuePair(Of String, String)("customer_last_name1", obj.customer_last_name1))
|
|
Parametros.Add(New KeyValuePair(Of String, String)("customer_last_name2", obj.customer_last_name1))
|
|
Parametros.Add(New KeyValuePair(Of String, String)("customer_birthday", obj.customer_birthday.ToString("yyyy-MM-dd HH:mm:ss")))
|
|
Parametros.Add(New KeyValuePair(Of String, String)("customer_phone", obj.customer_phone))
|
|
Parametros.Add(New KeyValuePair(Of String, String)("customer_email", obj.customer_email))
|
|
Parametros.Add(New KeyValuePair(Of String, String)("customer_gender", obj.customer_gender))
|
|
Parametros.Add(New KeyValuePair(Of String, String)("customer_advertising", obj.customer_advertising.ToString()))
|
|
Parametros.Add(New KeyValuePair(Of String, String)("sale_date", obj.sale_date.ToString("yyyy-MM-dd HH:mm:ss")))
|
|
Parametros.Add(New KeyValuePair(Of String, String)("sale_paidby", obj.sale_paidby))
|
|
Parametros.Add(New KeyValuePair(Of String, String)("sale_type", obj.sale_type))
|
|
Parametros.Add(New KeyValuePair(Of String, String)("sale_type_service", obj.sale_type_service))
|
|
Parametros.Add(New KeyValuePair(Of String, String)("product_code", obj.product_code))
|
|
Parametros.Add(New KeyValuePair(Of String, String)("product_unique_code", obj.product_unique_code))
|
|
Parametros.Add(New KeyValuePair(Of String, String)("product_sale_type", obj.product_sale_type))
|
|
Parametros.Add(New KeyValuePair(Of String, String)("used_product", obj.used_product.ToString()))
|
|
Parametros.Add(New KeyValuePair(Of String, String)("used_brand", obj.used_brand))
|
|
Parametros.Add(New KeyValuePair(Of String, String)("used_bci", obj.used_bci))
|
|
Parametros.Add(New KeyValuePair(Of String, String)("used_month", obj.used_month.ToString()))
|
|
Parametros.Add(New KeyValuePair(Of String, String)("used_year", obj.used_year.ToString()))
|
|
Parametros.Add(New KeyValuePair(Of String, String)("used_sale_date", obj.used_sale_date.ToString()))
|
|
Parametros.Add(New KeyValuePair(Of String, String)("customer_car_brand", obj.customer_car_brand.ToString()))
|
|
Parametros.Add(New KeyValuePair(Of String, String)("customer_car_model", obj.customer_car_model.ToString()))
|
|
Parametros.Add(New KeyValuePair(Of String, String)("customer_car_year", obj.customer_car_year.ToString()))
|
|
Parametros.Add(New KeyValuePair(Of String, String)("sale_discount", obj.sale_discount.ToString()))
|
|
Parametros.Add(New KeyValuePair(Of String, String)("sale_id", obj.sale_id.ToString()))
|
|
|
|
Dim content As New FormUrlEncodedContent(Parametros)
|
|
Dim response = wc.PostAsync(Url, content).Result
|
|
|
|
Retorno = response.Content.ReadAsStringAsync().Result
|
|
End Using
|
|
|
|
Catch ex As Exception
|
|
ex.GuardaLog(ex.Message)
|
|
End Try
|
|
|
|
context.Response.Write(Retorno)
|
|
End Sub
|
|
|
|
Protected Sub EnviarPolizaVentaWS(ByVal context As HttpContext, obj As MPolizaVentaWS)
|
|
Dim Retorno As String = "[]"
|
|
Try
|
|
Using wc As New HttpClient()
|
|
Dim Url = New Uri("http://polizavirtual.com.mx/webservice/api/Venta")
|
|
|
|
Dim Parametros = New List(Of KeyValuePair(Of String, String))
|
|
|
|
Parametros.Add(New KeyValuePair(Of String, String)("User", User))
|
|
Parametros.Add(New KeyValuePair(Of String, String)("password", Password))
|
|
Parametros.Add(New KeyValuePair(Of String, String)("customer_name", obj.customer_name))
|
|
Parametros.Add(New KeyValuePair(Of String, String)("customer_last_name1", obj.customer_last_name1))
|
|
Parametros.Add(New KeyValuePair(Of String, String)("customer_last_name2", obj.customer_last_name1))
|
|
Parametros.Add(New KeyValuePair(Of String, String)("customer_birthday", obj.customer_birthday.ToString("yyyy-MM-dd HH:mm:ss")))
|
|
Parametros.Add(New KeyValuePair(Of String, String)("customer_phone", obj.customer_phone))
|
|
Parametros.Add(New KeyValuePair(Of String, String)("customer_email", obj.customer_email))
|
|
Parametros.Add(New KeyValuePair(Of String, String)("customer_gender", obj.customer_gender))
|
|
Parametros.Add(New KeyValuePair(Of String, String)("customer_advertising", obj.customer_advertising.ToString()))
|
|
Parametros.Add(New KeyValuePair(Of String, String)("sale_date", obj.sale_date.ToString("yyyy-MM-dd HH:mm:ss")))
|
|
Parametros.Add(New KeyValuePair(Of String, String)("sale_paidby", obj.sale_paidby))
|
|
Parametros.Add(New KeyValuePair(Of String, String)("sale_type", obj.sale_type))
|
|
Parametros.Add(New KeyValuePair(Of String, String)("sale_type_service", obj.sale_type_service))
|
|
Parametros.Add(New KeyValuePair(Of String, String)("product_code", obj.product_code))
|
|
Parametros.Add(New KeyValuePair(Of String, String)("product_unique_code", obj.product_unique_code))
|
|
Parametros.Add(New KeyValuePair(Of String, String)("product_sale_type", obj.product_sale_type))
|
|
Parametros.Add(New KeyValuePair(Of String, String)("sale_total", obj.sale_total.ToString()))
|
|
Parametros.Add(New KeyValuePair(Of String, String)("used_product", obj.used_product.ToString()))
|
|
Parametros.Add(New KeyValuePair(Of String, String)("used_brand", obj.used_brand))
|
|
Parametros.Add(New KeyValuePair(Of String, String)("used_bci", obj.used_bci))
|
|
Parametros.Add(New KeyValuePair(Of String, String)("used_month", obj.used_month.ToString()))
|
|
Parametros.Add(New KeyValuePair(Of String, String)("used_year", obj.used_year.ToString()))
|
|
Parametros.Add(New KeyValuePair(Of String, String)("used_sale_date", obj.used_sale_date.ToString("yyyy-MM-dd HH:mm:ss")))
|
|
Parametros.Add(New KeyValuePair(Of String, String)("customer_car_brand", obj.customer_car_brand.ToString()))
|
|
Parametros.Add(New KeyValuePair(Of String, String)("customer_car_model", obj.customer_car_model.ToString()))
|
|
Parametros.Add(New KeyValuePair(Of String, String)("customer_car_year", obj.customer_car_year.ToString()))
|
|
Parametros.Add(New KeyValuePair(Of String, String)("sale_discount", obj.sale_discount.ToString()))
|
|
Parametros.Add(New KeyValuePair(Of String, String)("sale_id", obj.sale_id.ToString()))
|
|
|
|
Dim content As New FormUrlEncodedContent(Parametros)
|
|
Dim response = wc.PostAsync(Url, content).Result
|
|
|
|
Retorno = response.Content.ReadAsStringAsync().Result
|
|
End Using
|
|
|
|
Catch ex As Exception
|
|
ex.GuardaLog(ex.Message)
|
|
End Try
|
|
|
|
context.Response.Write(Retorno)
|
|
End Sub
|
|
|
|
Protected Sub EnviarPolizaIndicadores(ByVal context As HttpContext, obj As MIndicador)
|
|
Dim Retorno As String = "[]"
|
|
Try
|
|
Using wc As New HttpClient()
|
|
Dim Url = New Uri("http://polizavirtual.com.mx/webservice/api/Indicadores")
|
|
|
|
Dim Parametros = New List(Of KeyValuePair(Of String, String))
|
|
|
|
Parametros.Add(New KeyValuePair(Of String, String)("User", User))
|
|
Parametros.Add(New KeyValuePair(Of String, String)("password", Password))
|
|
Parametros.Add(New KeyValuePair(Of String, String)("v_b_optima", obj.v_b_optima.ToString()))
|
|
Parametros.Add(New KeyValuePair(Of String, String)("v_b_fullpower", obj.v_b_fullpower.ToString()))
|
|
Parametros.Add(New KeyValuePair(Of String, String)("v_b_hitec", obj.v_b_hitec.ToString()))
|
|
Parametros.Add(New KeyValuePair(Of String, String)("v_b_agm", obj.v_b_agm.ToString()))
|
|
Parametros.Add(New KeyValuePair(Of String, String)("v_b_suv", obj.v_b_suv.ToString()))
|
|
Parametros.Add(New KeyValuePair(Of String, String)("v_b_taxi", obj.v_b_taxi.ToString()))
|
|
Parametros.Add(New KeyValuePair(Of String, String)("v_b_america", obj.v_b_america.ToString()))
|
|
Parametros.Add(New KeyValuePair(Of String, String)("v_b_lth", obj.v_b_lth.ToString()))
|
|
Parametros.Add(New KeyValuePair(Of String, String)("v_b_cronos", obj.v_b_cronos.ToString()))
|
|
Parametros.Add(New KeyValuePair(Of String, String)("v_b_diener", obj.v_b_diener.ToString()))
|
|
Parametros.Add(New KeyValuePair(Of String, String)("v_b_heavyduty", obj.v_b_heavyduty.ToString()))
|
|
Parametros.Add(New KeyValuePair(Of String, String)("v_m_lth", obj.v_m_lth.ToString()))
|
|
Parametros.Add(New KeyValuePair(Of String, String)("v_o_filtros", obj.v_o_filtros.ToString()))
|
|
Parametros.Add(New KeyValuePair(Of String, String)("v_o_lub1", obj.v_o_lub1.ToString()))
|
|
Parametros.Add(New KeyValuePair(Of String, String)("v_o_lubgalon", obj.v_o_lubgalon.ToString()))
|
|
Parametros.Add(New KeyValuePair(Of String, String)("v_o_lub5", obj.v_o_lub5.ToString()))
|
|
Parametros.Add(New KeyValuePair(Of String, String)("v_o_aa", obj.v_o_aa.ToString()))
|
|
Parametros.Add(New KeyValuePair(Of String, String)("v_o_aaa", obj.v_o_aaa.ToString()))
|
|
Parametros.Add(New KeyValuePair(Of String, String)("g_b_optima", obj.g_b_optima.ToString()))
|
|
Parametros.Add(New KeyValuePair(Of String, String)("g_b_fullpower", obj.g_b_fullpower.ToString()))
|
|
Parametros.Add(New KeyValuePair(Of String, String)("g_b_hitec", obj.g_b_hitec.ToString()))
|
|
Parametros.Add(New KeyValuePair(Of String, String)("g_b_agm", obj.g_b_agm.ToString()))
|
|
Parametros.Add(New KeyValuePair(Of String, String)("g_b_suv", obj.g_b_suv.ToString()))
|
|
Parametros.Add(New KeyValuePair(Of String, String)("g_b_taxi", obj.g_b_taxi.ToString()))
|
|
Parametros.Add(New KeyValuePair(Of String, String)("g_b_america", obj.g_b_america.ToString()))
|
|
Parametros.Add(New KeyValuePair(Of String, String)("g_b_lth", obj.g_b_lth.ToString()))
|
|
Parametros.Add(New KeyValuePair(Of String, String)("g_b_cronos", obj.g_b_cronos.ToString()))
|
|
Parametros.Add(New KeyValuePair(Of String, String)("g_b_diener", obj.g_b_diener.ToString()))
|
|
Parametros.Add(New KeyValuePair(Of String, String)("g_b_heavyduty", obj.g_b_heavyduty.ToString()))
|
|
Parametros.Add(New KeyValuePair(Of String, String)("g_m_lth", obj.g_m_lth.ToString()))
|
|
Parametros.Add(New KeyValuePair(Of String, String)("a_b_optima", obj.a_b_optima.ToString()))
|
|
Parametros.Add(New KeyValuePair(Of String, String)("a_b_fullpower", obj.a_b_fullpower.ToString()))
|
|
Parametros.Add(New KeyValuePair(Of String, String)("a_b_hitec", obj.a_b_hitec.ToString()))
|
|
Parametros.Add(New KeyValuePair(Of String, String)("a_b_agm", obj.a_b_agm.ToString()))
|
|
Parametros.Add(New KeyValuePair(Of String, String)("a_b_suv", obj.a_b_suv.ToString()))
|
|
Parametros.Add(New KeyValuePair(Of String, String)("a_b_taxi", obj.a_b_taxi.ToString()))
|
|
Parametros.Add(New KeyValuePair(Of String, String)("a_b_america", obj.a_b_america.ToString()))
|
|
Parametros.Add(New KeyValuePair(Of String, String)("a_b_lth", obj.a_b_lth.ToString()))
|
|
Parametros.Add(New KeyValuePair(Of String, String)("a_b_cronos", obj.a_b_cronos.ToString()))
|
|
Parametros.Add(New KeyValuePair(Of String, String)("a_b_diener", obj.a_b_diener.ToString()))
|
|
Parametros.Add(New KeyValuePair(Of String, String)("a_b_heavyduty", obj.a_b_heavyduty.ToString()))
|
|
|
|
Dim content As New FormUrlEncodedContent(Parametros)
|
|
Dim response = wc.PostAsync(Url, content).Result
|
|
|
|
Retorno = response.Content.ReadAsStringAsync().Result
|
|
End Using
|
|
|
|
Catch ex As Exception
|
|
ex.GuardaLog(ex.Message)
|
|
End Try
|
|
|
|
context.Response.Write(Retorno)
|
|
End Sub
|
|
|
|
End Class
|
|
|
|
Public Class MPolizaVentaLTHWSD
|
|
Public Property customer_name As String
|
|
Public Property customer_last_name1 As String
|
|
Public Property customer_last_name2 As String
|
|
Public Property customer_birthday As DateTime
|
|
Public Property customer_phone As String
|
|
Public Property customer_email As String
|
|
Public Property customer_gender As String
|
|
Public Property customer_advertising As Boolean
|
|
Public Property sale_date As DateTime
|
|
Public Property sale_paidby As String
|
|
Public Property sale_type As String
|
|
Public Property sale_type_service As String
|
|
Public Property product_code As String
|
|
Public Property product_unique_code As String
|
|
Public Property product_sale_type As String
|
|
Public Property used_product As Boolean
|
|
Public Property used_brand As String
|
|
Public Property used_bci As String
|
|
Public Property used_month As Integer
|
|
Public Property used_year As Integer
|
|
Public Property used_sale_date As DateTime
|
|
Public Property customer_car_brand As String
|
|
Public Property customer_car_model As String
|
|
Public Property customer_car_year As Integer
|
|
Public Property sale_discount As Decimal
|
|
Public Property sale_id As String
|
|
End Class
|
|
|
|
Public Class MPolizaVentaWS
|
|
Public Property customer_name As String
|
|
Public Property customer_last_name1 As String
|
|
Public Property customer_last_name2 As String
|
|
Public Property customer_birthday As DateTime
|
|
Public Property customer_phone As String
|
|
Public Property customer_email As String
|
|
Public Property customer_gender As String
|
|
Public Property customer_advertising As Boolean
|
|
Public Property sale_date As DateTime
|
|
Public Property sale_paidby As String
|
|
Public Property sale_type As String
|
|
Public Property sale_type_service As String
|
|
Public Property sale_total As Decimal
|
|
Public Property product_code As String
|
|
Public Property product_unique_code As String
|
|
Public Property product_sale_type As String
|
|
Public Property used_product As Boolean
|
|
Public Property used_brand As String
|
|
Public Property used_bci As String
|
|
Public Property used_month As Integer
|
|
Public Property used_year As Integer
|
|
Public Property used_sale_date As DateTime
|
|
Public Property customer_car_brand As String
|
|
Public Property customer_car_model As String
|
|
Public Property customer_car_year As Integer
|
|
Public Property sale_discount As Decimal
|
|
Public Property sale_id As String
|
|
End Class
|
|
|
|
Public Class MIndicador
|
|
|
|
Sub New(Optional UsaValoresPrueba As Boolean = False)
|
|
If UsaValoresPrueba Then
|
|
Dim Index As Integer = 0
|
|
For Each p As Reflection.PropertyInfo In Me.GetType().GetProperties()
|
|
Index = Index + 1
|
|
p.SetValue(Me, Convert.ChangeType(Index, p.PropertyType), Nothing)
|
|
Next
|
|
End If
|
|
End Sub
|
|
|
|
Public Property v_b_optima As Integer
|
|
Public Property v_b_fullpower As Integer
|
|
Public Property v_b_hitec As Integer
|
|
Public Property v_b_agm As Integer
|
|
Public Property v_b_suv As Integer
|
|
Public Property v_b_taxi As Integer
|
|
Public Property v_b_america As Integer
|
|
Public Property v_b_lth As Integer
|
|
Public Property v_b_cronos As Integer
|
|
Public Property v_b_diener As Integer
|
|
Public Property v_b_heavyduty As Integer
|
|
Public Property v_m_lth As Integer
|
|
Public Property v_o_filtros As Integer
|
|
Public Property v_o_lub1 As Integer
|
|
Public Property v_o_lubgalon As Integer
|
|
Public Property v_o_lub5 As Integer
|
|
Public Property v_o_aa As Integer
|
|
Public Property v_o_aaa As Integer
|
|
Public Property g_b_optima As Integer
|
|
Public Property g_b_fullpower As Integer
|
|
Public Property g_b_hitec As Integer
|
|
Public Property g_b_agm As Integer
|
|
Public Property g_b_suv As Integer
|
|
Public Property g_b_taxi As Integer
|
|
Public Property g_b_america As Integer
|
|
Public Property g_b_lth As Integer
|
|
Public Property g_b_cronos As Integer
|
|
Public Property g_b_diener As Integer
|
|
Public Property g_b_heavyduty As Integer
|
|
Public Property g_m_lth As Integer
|
|
Public Property a_b_optima As Integer
|
|
Public Property a_b_fullpower As Integer
|
|
Public Property a_b_hitec As Integer
|
|
Public Property a_b_agm As Integer
|
|
Public Property a_b_suv As Integer
|
|
Public Property a_b_taxi As Integer
|
|
Public Property a_b_america As Integer
|
|
Public Property a_b_lth As Integer
|
|
Public Property a_b_cronos As Integer
|
|
Public Property a_b_diener As Integer
|
|
Public Property a_b_heavyduty As Integer
|
|
End Class
|
|
|
|
|
|
|
|
Namespace Fluent
|
|
Public Enum GuidVersion
|
|
TimeBased = &H1
|
|
Reserved = &H2
|
|
NameBased = &H3
|
|
Random = &H4
|
|
End Enum
|
|
|
|
Partial Public Module GuidGenerator
|
|
Public Const ByteArraySize = 16
|
|
Public Const VariantByte = 8
|
|
Public Const VariantByteMask = &H3F
|
|
Public Const VariantByteShift = &H80
|
|
Public Const VersionByte = 7
|
|
Public Const VersionByteMask = &HF
|
|
Public Const VersionByteShift = 4
|
|
Private Const TimestampByte As Byte = 0
|
|
Private Const GuidClockSequenceByte As Byte = 8
|
|
Private Const NodeByte As Byte = 10
|
|
Private ReadOnly GregorianCalendarStart As DateTimeOffset = New DateTimeOffset(1582, 10, 15, 0, 0, 0, TimeSpan.Zero)
|
|
Public Property DefaultClockSequence As Byte()
|
|
Public Property DefaultNode As Byte()
|
|
|
|
Sub New()
|
|
DefaultClockSequence = New Byte(1) {}
|
|
DefaultNode = New Byte(5) {}
|
|
Dim random = New Random
|
|
random.NextBytes(DefaultClockSequence)
|
|
random.NextBytes(DefaultNode)
|
|
End Sub
|
|
|
|
<Extension()>
|
|
Function GetVersion(ByVal guid As Guid) As GuidVersion
|
|
Dim bytes = guid.ToByteArray
|
|
Return ((bytes(VersionByte) And &HFF) >> VersionByteShift)
|
|
End Function
|
|
|
|
Function GetDateTimeOffset(ByVal guid As Guid) As DateTimeOffset
|
|
Dim bytes As Byte() = guid.ToByteArray
|
|
bytes(VersionByte) = bytes(VersionByte) And CByte(VersionByteMask)
|
|
bytes(VersionByte) = bytes(VersionByte) Or (CByte(GuidVersion.TimeBased) >> VersionByteShift)
|
|
Dim timestampBytes = New Byte(7) {}
|
|
Array.Copy(bytes, TimestampByte, timestampBytes, 0, 8)
|
|
Dim timestamp As Long = BitConverter.ToInt64(timestampBytes, 0)
|
|
Dim ticks As Long = timestamp + GregorianCalendarStart.Ticks
|
|
|
|
Return New DateTimeOffset(ticks, TimeSpan.Zero)
|
|
End Function
|
|
|
|
Function GetDateTime(ByVal guid As Guid) As Date
|
|
Return GetDateTimeOffset(guid).DateTime
|
|
End Function
|
|
|
|
Function GetLocalDateTime(ByVal guid As Guid) As Date
|
|
Return GetDateTimeOffset(guid).LocalDateTime
|
|
End Function
|
|
|
|
Function GetUtcDateTime(ByVal guid As Guid) As Date
|
|
Return GetDateTimeOffset(guid).UtcDateTime
|
|
End Function
|
|
|
|
Function GenerateTimeBasedGuid() As Guid
|
|
Return GenerateTimeBasedGuid(DateTimeOffset.UtcNow, DefaultClockSequence, DefaultNode)
|
|
End Function
|
|
|
|
Function GenerateTimeBasedGuid(ByVal dateTime As Date) As Guid
|
|
Return GenerateTimeBasedGuid(dateTime, DefaultClockSequence, DefaultNode)
|
|
End Function
|
|
|
|
Function GenerateTimeBasedGuid(ByVal dateTime As DateTimeOffset) As Guid
|
|
Return GenerateTimeBasedGuid(dateTime, DefaultClockSequence, DefaultNode)
|
|
End Function
|
|
|
|
Function GenerateTimeBasedGuid(ByVal dateTime As Date, ByVal clockSequence As Byte(), ByVal node As Byte()) As Guid
|
|
Return GenerateTimeBasedGuid(New DateTimeOffset(dateTime), clockSequence, node)
|
|
End Function
|
|
|
|
Function GenerateTimeBasedGuid(ByVal dateTime As DateTimeOffset, ByVal clockSequence As Byte(), ByVal node As Byte()) As Guid
|
|
If clockSequence Is Nothing Then Throw New ArgumentNullException("clockSequence")
|
|
If node Is Nothing Then Throw New ArgumentNullException("node")
|
|
If clockSequence.Length <> 2 Then Throw New ArgumentOutOfRangeException("clockSequence", "The clockSequence must be 2 bytes.")
|
|
If node.Length <> 6 Then Throw New ArgumentOutOfRangeException("node", "The node must be 6 bytes.")
|
|
Dim ticks = (dateTime - GregorianCalendarStart).Ticks
|
|
Dim guid = New Byte(15) {}
|
|
Dim timestamp = BitConverter.GetBytes(ticks)
|
|
Array.Copy(node, 0, guid, NodeByte, Math.Min(6, node.Length))
|
|
Array.Copy(clockSequence, 0, guid, GuidClockSequenceByte, Math.Min(2, clockSequence.Length))
|
|
Array.Copy(timestamp, 0, guid, TimestampByte, Math.Min(8, timestamp.Length))
|
|
guid(VariantByte) = guid(VariantByte) And CByte(VariantByteMask)
|
|
guid(VariantByte) = guid(VariantByte) Or CByte(VariantByteShift)
|
|
guid(VersionByte) = guid(VersionByte) And CByte(VersionByteMask)
|
|
guid(VersionByte) = guid(VersionByte) Or (CByte(GuidVersion.TimeBased) << VersionByteShift)
|
|
Return New Guid(guid)
|
|
End Function
|
|
End Module
|
|
End Namespace
|