Calendario de Viajes cronograma cambio a Amchart4

This commit is contained in:
rakcsle
2024-10-17 19:04:50 -07:00
parent fb503d9643
commit ef3a0e7133
2 changed files with 1333 additions and 1010 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -73,7 +73,8 @@ Partial Class RepContratosCalendario
CveChofer:=DdlChoferFiltro.SelectedValue.ToEntero) Then CveChofer:=DdlChoferFiltro.SelectedValue.ToEntero) Then
DtAvance = ObjContratos.DtResultados.Copy() DtAvance = ObjContratos.DtResultados.Copy()
CargaCronograma(DdlTipoVistaCalendario.SelectedValue.ToEntero) CargaCronograma(DdlTipoVistaCalendario.SelectedValue.ToEntero)
CargaDiagramadeGant(DdlTipoVista.SelectedValue.ToEntero) 'CargaDiagramadeGant(DdlTipoVista.SelectedValue.ToEntero)
'CargaScheduler(DdlTipoVista.SelectedValue.ToEntero)
End If End If
GvContratos.DataSource = DtAvance GvContratos.DataSource = DtAvance
DdlEstatusContrato.Enabled = UsuarioActual.TienePermisoProceso(173) DdlEstatusContrato.Enabled = UsuarioActual.TienePermisoProceso(173)
@@ -89,9 +90,112 @@ Partial Class RepContratosCalendario
Public Shared Function GetLastDayOfMonth(ByVal dateTime As DateTime) As DateTime Public Shared Function GetLastDayOfMonth(ByVal dateTime As DateTime) As DateTime
Return New DateTime(dateTime.Year, dateTime.Month, DateTime.DaysInMonth(dateTime.Year, dateTime.Month)) Return New DateTime(dateTime.Year, dateTime.Month, DateTime.DaysInMonth(dateTime.Year, dateTime.Month))
End Function End Function
Private Sub CargaScheduler(Optional TipoVista As Integer = -1)
' var data = [
'{
'Id: 1,
'Subject: 'Board Meeting',
'Description: 'Meeting to discuss business goal of 2021.',
'StartTime: New Date(2021, 7, 1, 9, 0),
'EndTime: New Date(2021, 7, 2, 11, 0),
'RoomId: 1
'}]
'[ { text 'Room A', id: 1, color: '#98AFC7' },]
Dim StrFiltro As String = ""
If DdlTipoUnidad.SelectedValue.ToEntero > 0 Then StrFiltro = " AND CveTipoActivoFijo = " & DdlTipoUnidad.SelectedValue
Dim DtUnidades As DataTable = GlobalDTActivoFijos(UsuarioActual.CveEmpresa).FiltraParametros("Codigo <> '' AND MedidaVehicular IN (2,3) " & StrFiltro, Orderby:=" TipoActivoFijo ASC, CodigoNumeroOrden ASC", DistinctColumns:={"Codigo", "CveActivoFijo"})
Dim jsonData As New JArray()
Dim jsonCategorias As New JArray()
Dim strAF As New StringBuilder
Dim strData As New StringBuilder
Dim strAFData As New StringBuilder
strData.AppendLine("[")
For Each Row As DataRow In DtAvance.FiltraParametros("CodigoAF <> '' AND TipoEstatus <> 3").Rows
Dim FI As Date = Row("FechaInicial").ToString.ToDate
Dim FF As Date = Row("FechaFinal").ToString.ToDate
Dim obj As New JObject(
New JProperty("Id", Row("CveContrato").ToString),
New JProperty("Subject", $"{Row("CodigoAF").ToString}"),
New JProperty("Description", $"{Row("NombreAF")}"),
New JProperty("StartTime", $"new Date({FI.Year},{FI.Month - 1},{FI.Day},{FI.Hour},{FI.Minute})"),
New JProperty("EndTime", $"new Date({FF.Year},{FF.Month - 1},{FF.Day},{FF.Hour},{FF.Minute})"),
New JProperty("IsBlock", "true"),
New JProperty("RoomId", Row("CveAF").ToString)
)
jsonData.Add(obj)
strData.AppendLine("{")
strData.AppendLine($"Id: {Row("CveContrato").ToString},")
strData.AppendLine($"Subject: {$"'{Row("NumeroContrato").ToString}"}',")
strData.AppendLine($"StartTime: new Date({FI.Year},{FI.Month - 1},{FI.Day},{FI.Hour},{FI.Minute}),")
strData.AppendLine($"EndTime: new Date({FF.Year},{FF.Month - 1},{FF.Day},{FI.Hour},{FF.Minute}),")
strData.AppendLine($"RoomId: {Row("CveAF").ToString}")
strData.AppendLine("},")
strAF.AppendFormat("{0},", Row("CveAF"))
Next
strData.AppendLine("{}]")
If TipoVista = 1 Then 'solo con viajes
DtUnidades = DtUnidades.FiltraParametros($"CveActivoFijo IN ({strAF.ToString})")
End If
Dim random = New Random()
strAFData.AppendLine("[")
For Each Row As DataRow In DtUnidades.Rows
Dim obj As New JObject(
New JProperty("text", Row("Codigo").ToString),
New JProperty("id", Row("CveActivoFijo").ToString),
New JProperty("color", String.Format("#{0:X6}", random.Next(16777216)))
)
jsonCategorias.Add(obj)
strAFData.AppendLine("{")
strAFData.AppendLine($"text: '{Row("Codigo").ToString}',")
strAFData.AppendLine($"id: {Row("CveActivoFijo").ToString},")
strAFData.AppendLine($"color: '{String.Format("#{0:X6}", random.Next(16777216))}'")
strAFData.AppendLine("},")
Next
strAFData.AppendLine("{}]")
'RegistraScript($"cargaScheduler({jsonData.ToString()},{jsonCategorias.ToString()},{TipoVista});", "A1")
'RegistraScript($"cargaScheduler({strData.ToString().TrimEnd(","c) },{strAFData.ToString().TrimEnd(","c) },{TipoVista}, {$"new Date({txtFechaI.ToDate.ToString("yyyy, MM, dd, hh, MM")})"}, {$"new Date({txtFechaF.ToDate.ToString("yyyy, MM, dd, hh, MM")})"});", "A1")
Dim FechaInicio As Date = txtFechaI.Text.ToDate
Dim FechaFin As Date = txtFechaF.Text.ToDate
'strData.Append($",new Date({FechaInicio.Year},{FechaInicio.Month - 1},{FechaInicio.Day})")
'strData.Append($",new Date({FechaFin.Year},{FechaFin.Month - 1},{FechaFin.Day})")
'RegistraScript($"cargaScheduler({strData.ToString().TrimEnd(","c) },{strAFData.ToString().TrimEnd(","c) },{TipoVista}, {$" new Date({FechaInicio.Year},{FechaInicio.Month - 1},{FechaInicio.Day})"}, {$"new Date({FechaFin.Year},{FechaFin.Month - 1},{FechaFin.Day})"});", "A1")
RegistraScript($"cargaScheduler({strData.ToString().TrimEnd(","c) },{strAFData.ToString().TrimEnd(","c) },{TipoVista}, {$" new Date({FechaInicio.Year},{FechaInicio.Month - 1},{FechaInicio.Day})"}, {$"new Date(2024,09,5)"});", "A1")
UPScheduler.Update()
End Sub
Private Sub CargaCronograma(Optional TipoVista As Integer = -1) Private Sub CargaCronograma(Optional TipoVista As Integer = -1)
If DtAvance IsNot Nothing Then If DtAvance IsNot Nothing Then
Dim strData As New StringBuilder
Dim strAFData As New StringBuilder
'Dim separator As String = "" 'Dim separator As String = ""
'Dim str As New StringBuilder() 'Dim str As New StringBuilder()
'str.AppendLine("datosGant=[") 'str.AppendLine("datosGant=[")
@@ -112,6 +216,7 @@ Partial Class RepContratosCalendario
Dim strAF As New StringBuilder Dim strAF As New StringBuilder
'se quitan los estatus cancelados 'se quitan los estatus cancelados
Dim randomNumber As New Random Dim randomNumber As New Random
strData.AppendLine("[")
For Each Row As DataRow In DtAvance.FiltraParametros("CodigoAF <> '' AND TipoEstatus <> 3").Rows For Each Row As DataRow In DtAvance.FiltraParametros("CodigoAF <> '' AND TipoEstatus <> 3").Rows
Dim obj As New JObject( Dim obj As New JObject(
@@ -127,6 +232,23 @@ Partial Class RepContratosCalendario
New JProperty("fechaFinalViaje", Row("FechaFinal").ToString().ToDateTime().ToString("yyyy-MM-dd HH:mm:ss")) New JProperty("fechaFinalViaje", Row("FechaFinal").ToString().ToDateTime().ToString("yyyy-MM-dd HH:mm:ss"))
) )
jsonData.Add(obj) jsonData.Add(obj)
Dim FI As Date = Row("FechaInicial").ToString.ToDate
Dim FF As Date = Row("FechaFinal").ToString.ToDate
strData.AppendLine("{")
strData.AppendLine($"category: '{Row("CodigoAF").ToString}',")
strData.AppendLine($"fromDate: '{FI.ToString("yyyy-MM-dd HH:mm:ss")}',")
strData.AppendLine($"toDate: '{FF.ToString("yyyy-MM-dd HH:mm:ss")}',")
'strData.AppendLine($"columnSettings: {{fill: '{String.Format("#{0:X6}", random.Next(16777216))}'}},")
strData.AppendLine($"unidad: '{Row("NombreAF").ToString}',")
strData.AppendLine($"color: am4core.color('" & String.Format("#{0:X6}", random.Next(16777216)) & "'),")
strData.AppendLine($"cveContrato: {Row("CveContrato").ToString.ToEntero},")
strData.AppendLine($"contrato: '{Row("NumeroContrato").ToString}',")
strData.AppendLine($"fechaFinalViaje: '{FF.ToString("yyyy-MM-dd HH:mm:ss")}'")
strData.AppendLine("},")
strAF.AppendFormat("{0},", Row("CveAF")) strAF.AppendFormat("{0},", Row("CveAF"))
'uniad contrato y duracion 'uniad contrato y duracion
@@ -139,29 +261,29 @@ Partial Class RepContratosCalendario
'separator = "," 'separator = ","
Next Next
strData.AppendLine("{}]")
If TipoVista = 1 Then 'solo con viajes If TipoVista = 1 Then 'solo con viajes
DtUnidades = DtUnidades.FiltraParametros($"CveActivoFijo IN ({strAF.ToString})") DtUnidades = DtUnidades.FiltraParametros($"CveActivoFijo IN ({strAF.ToString})")
End If End If
'CATEGORIAS 'AGREGAR TODAS LAS UNIDADES 'CATEGORIAS 'AGREGAR TODAS LAS UNIDADES
strAFData.AppendLine("[")
For Each Row As DataRow In DtUnidades.Rows For Each Row As DataRow In DtUnidades.Rows
Dim obj As New JObject( Dim obj As New JObject(
New JProperty("category", Row("Codigo")) New JProperty("category", Row("Codigo"))
) )
jsonCategorias.Add(obj) jsonCategorias.Add(obj)
strAFData.AppendLine("{")
strAFData.AppendLine($"category: '{Row("Codigo").ToString}',")
strAFData.AppendLine("},")
Next Next
Dim FechaI = txtFechaI.Text.ToDateTime() strAFData.AppendLine("{}]")
Dim FechaF = txtFechaF.Text.ToDateTime()
'Dim ScriptZoomx = $"zoomAxis({FechaI.Year},{FechaI.Month - 1},{FechaI.Day},{FechaF.Year},{FechaF.Month - 1},{FechaF.Day});" 'RegistraScript($"cargaDiagramaGrant({jsonData.ToString()},{jsonCategorias.ToString()},{TipoVista});", $"{random.Next(16777216)}")
'Dim ScriptZoomy = $"zoomAxisy(0,{If(jsonCategorias.Count > 9, 9, jsonCategorias.Count - 1)});" RegistraScript($"cargaDiagramaGrantAMC4({strData.ToString().Replace(",{}", "")},{strAFData.ToString().Replace(",{}", "")},{TipoVista});", $"{random.Next(16777216)}")
'RegistraScript($"cargaDiagramaGrant({jsonData.ToString()},{jsonCategorias.ToString()},{TipoVista});{ScriptZoomx};{ScriptZoomy};", "A1")
'RegistraScript($"cargaDiagramaGrant({jsonData.ToString()},{jsonCategorias.ToString()},{TipoVista});", "A1")
'str.AppendLine("];loadGant();")
'RegistraScript(str.ToString())
UPPGantt.Update() UPPGantt.Update()
UPGat.Update() UPGat.Update()
@@ -722,8 +844,9 @@ Partial Class RepContratosCalendario
End Sub End Sub
Protected Sub RBTipoVista_SelectedIndexChanged(sender As Object, e As EventArgs) Protected Sub RBTipoVista_SelectedIndexChanged(sender As Object, e As EventArgs)
InicializaCalendar() InicializaCalendar()
CargaCronograma() 'CargaCronograma()
CargaDiagramadeGant() 'CargaDiagramadeGant()
CargaScheduler(DdlTipoVista.SelectedValue.ToEntero)
End Sub End Sub
Protected Sub DdlTipoVista_SelectedIndexChanged(sender As Object, e As EventArgs) Protected Sub DdlTipoVista_SelectedIndexChanged(sender As Object, e As EventArgs)
@@ -747,4 +870,6 @@ Partial Class RepContratosCalendario
Protected Sub DdlTipoVistaCalendario_SelectedIndexChanged(sender As Object, e As EventArgs) Protected Sub DdlTipoVistaCalendario_SelectedIndexChanged(sender As Object, e As EventArgs)
CargaCronograma(DdlTipoVistaCalendario.SelectedValue.ToEntero) CargaCronograma(DdlTipoVistaCalendario.SelectedValue.ToEntero)
End Sub End Sub
End Class End Class