PageRenderTime 40ms CodeModel.GetById 16ms RepoModel.GetById 0ms app.codeStats 0ms

/CapaLogica/LogicaSilverlight/LogicaSilverlight/data/Vehiculo.cs

#
C# | 216 lines | 186 code | 25 blank | 5 comment | 0 complexity | c83e2429a01e40886509251d65cc6555 MD5 | raw file
  1. using System;
  2. using System.Net;
  3. using System.Windows;
  4. using System.Windows.Controls;
  5. using System.Windows.Documents;
  6. using System.Windows.Ink;
  7. using System.Windows.Input;
  8. using System.Windows.Media;
  9. using System.Windows.Media.Animation;
  10. using System.Windows.Shapes;
  11. using System.Collections.Generic;
  12. namespace LogicaSilverlight.data
  13. {
  14. public class Vehiculo
  15. {
  16. private int id;
  17. private string matricula;
  18. private TimeSpan tiempoMaxUso;
  19. private TimeSpan tiempoUsoSalida;
  20. private TimeSpan tiempoUsoLlegada;
  21. private DateTime inicio;
  22. private DateTime fin;
  23. private TimeSpan tolerancia;
  24. private List<Pedido> pedidos;
  25. private List<Caracteristicas> caracteristicas;
  26. private List<Escenario> escenarios;
  27. private List<Capacidad> capacidades;
  28. public Vehiculo(int id, string matricula, TimeSpan tiempoMaxUso, TimeSpan tiempoUsoSalida, TimeSpan tiempoUsoLlegada, DateTime inicio, DateTime fin, TimeSpan tolerancia)
  29. {
  30. this.id = id;
  31. this.matricula = matricula;
  32. this.tiempoMaxUso = tiempoMaxUso;
  33. this.tiempoUsoSalida = tiempoUsoSalida;
  34. this.tiempoUsoLlegada = tiempoUsoLlegada;
  35. this.inicio = inicio;
  36. this.fin = fin;
  37. this.tolerancia = tolerancia;
  38. pedidos = new List<Pedido>();
  39. caracteristicas = new List<Caracteristicas>();
  40. escenarios = new List<Escenario>();
  41. capacidades = new List<Capacidad>();
  42. }
  43. public VRP.Vehicle getVRPVehiculo()
  44. {
  45. #region CREO EL VEHICULO
  46. VRP.Vehicle vehicleVRP = new VRP.Vehicle()
  47. {
  48. compartments = new List<object>(),
  49. //originItem. NO SE ESPECIFICA EN CASO DE QUE EL VEHICULO PARTA DEL DEPOSITO COMO EN ESTE CASO.
  50. //destinationItem. IDEM AL ANTERIOR PERO EL FINAL.
  51. departureTime = tiempoUsoSalida,
  52. arrivalTime = tiempoUsoLlegada,
  53. timeWindows = new Dictionary<int,List<object>>(),
  54. maxUsage = tiempoMaxUso,
  55. //maxCost FALTA PEDIRLO O NO VA
  56. //productReloadingPoints= new System.Collections.ObjectModel.ObservableCollection<object>(),//LO DEJO VACIO O NO VA.
  57. code=id,
  58. };
  59. #endregion
  60. #region CARGA DE LA VENTAN DE TIEMPO
  61. //TAMBIEN PUEDE SER QUE NO ALLA VENTANA DE TIEMPO
  62. VRP.TimeWindow t = new VRP.TimeWindow()
  63. {
  64. code=1,
  65. startingTime= inicio,
  66. endingTime= fin,
  67. period=1
  68. };
  69. List<object> listaVentanaTiempo=new List<object>();
  70. listaVentanaTiempo.Add(t);
  71. vehicleVRP.timeWindows.Add(1,listaVentanaTiempo);
  72. #endregion
  73. #region LLENO LAS CARACTERIRSTICAS Y CAPACIDADES
  74. VRP.Compartment comportament = new VRP.Compartment();
  75. comportament.code = id;
  76. comportament.capacities = new Dictionary<string, object>();
  77. foreach (var item in capacidades)
  78. {
  79. comportament.capacities.Add(item.Nombre, new VRP.Capacity()
  80. {
  81. name=item.Nombre,
  82. value=item.Cantidad,
  83. code=item.IdCapacidad.ToString()
  84. });
  85. }
  86. comportament.characteristics = new Dictionary<int, object>();
  87. foreach (var item in caracteristicas)
  88. {
  89. comportament.characteristics.Add(item.Id, new VRP.Characteristic()
  90. {
  91. code=item.Id
  92. });
  93. }
  94. vehicleVRP.compartments.Add(comportament);
  95. #endregion
  96. return vehicleVRP;
  97. }
  98. public void sacarPedido(Pedido p)
  99. {
  100. pedidos.Remove(p);
  101. }
  102. public void agregarPedido(Pedido p)
  103. {
  104. pedidos.Add(p);
  105. }
  106. public void sacarCaracteristica(Caracteristicas c)
  107. {
  108. caracteristicas.Remove(c);
  109. }
  110. public void agregarCaracteristica(Caracteristicas c)
  111. {
  112. caracteristicas.Add(c);
  113. }
  114. public void sacarEscenario(Escenario e)
  115. {
  116. escenarios.Remove(e);
  117. }
  118. public void agregarEscenario(Escenario e)
  119. {
  120. escenarios.Add(e);
  121. }
  122. public void sacarCapacidades(Capacidad c)
  123. {
  124. capacidades.Remove(c);
  125. }
  126. public void agregarCapacidades(Capacidad c)
  127. {
  128. capacidades.Add(c);
  129. }
  130. public List<Pedido> Pedidos
  131. {
  132. get { return pedidos; }
  133. set { pedidos = value; }
  134. }
  135. public List<Caracteristicas> Caracteristicas
  136. {
  137. get { return caracteristicas; }
  138. set { caracteristicas = value; }
  139. }
  140. public List<Escenario> Escenarios
  141. {
  142. get { return escenarios; }
  143. set { escenarios = value; }
  144. }
  145. public List<Capacidad> Capacidades
  146. {
  147. get { return capacidades; }
  148. set { capacidades = value; }
  149. }
  150. public int Id
  151. {
  152. get { return id; }
  153. set { id = value; }
  154. }
  155. public TimeSpan TiempoMaxUso
  156. {
  157. get { return tiempoMaxUso; }
  158. set { tiempoMaxUso = value; }
  159. }
  160. public DateTime Inicio
  161. {
  162. get { return Inicio; }
  163. set { Inicio = value; }
  164. }
  165. public DateTime Fin
  166. {
  167. get { return fin; }
  168. set { fin = value; }
  169. }
  170. public TimeSpan Tolerancia
  171. {
  172. get { return tolerancia; }
  173. set { tolerancia = value; }
  174. }
  175. public TimeSpan TiempoUsoSalida
  176. {
  177. get { return tiempoUsoSalida; }
  178. set { tiempoUsoSalida = value; }
  179. }
  180. public TimeSpan TiempoUsoLlegada
  181. {
  182. get { return tiempoUsoLlegada; }
  183. set { tiempoUsoLlegada = value; }
  184. }
  185. public string Matricula
  186. {
  187. get { return matricula; }
  188. set { matricula = value; }
  189. }
  190. }
  191. }