using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using OliviaAddInPro.Helper; using OliviaAddInPro.Services; using ArcGIS.Core.Geometry; using static OliviaAddInPro.Model.ComunDef; using ArcGIS.Desktop.Framework.Threading.Tasks; using OliviaAddInPro.Services.LanzaSrv; namespace OliviaAddInPro.Model { class Recogida : TratamientoComun { //********************************************** //Se recogen en PaneRecogidaSub1 /** * Tipo de fracción */ public int TipoFrac { get; set; } = -1; /** * Tipo de fracción */ public string TipoFracStr { get; set; } = string.Empty; /** * Tipo de carga */ public int TipoCarg { get; set; } = -1; /** * Tipo de carga */ public string TipoCargStr { get; set; } = string.Empty; /** * Tipo de Vehículo */ public int TipoVehic { get; set; } = -1; /** * Tipo de Lateralidad */ public int TipoLate { get; set; } = -1; /** * kg capac camión */ public int KgMaxVehic { get; set; } = 0; /** * dens contenedor */ public int DensCont { get; set; } = 0; /** * Tiempo de vaciado del contenedor, en seg */ public int TVaciCont { get; set; } = 0; /** * kg de carga en cada contenedor */ public int KgCont { get; set; } = 0; /** * grados en º de giro del vehículo */ public int GiroVehic { get; set; } = 0; /* * * */ public double AnchoVehiculo { get; set; } public RecogidaServ Serv { get { return (RecogidaServ)ServCom; } set { ServCom = value; } } public LanzaRecoSrv LanzaSrv { get; set; } = null; public Recogida() { Serv = new RecogidaServ(this); LanzaSrv = new LanzaRecoSrv(); } public override Respuesta Ejecuta(ModosEjec modo) { Respuesta res = new Respuesta { Value = false }; Respuesta res2 = new Respuesta() { Value = TiposEjecucion.FinEjecNOk }; res = Serv.Ejecuta(modo); if (res.Value) { res = LanzaSrv.ejec(this, modo, TipoTtoStr); if (res.Value) { ProceSrv.ConfigConex(); res2 = ProceSrv.start(LanzaSrv.str_cfg, ProgrSrc._ProgrSrc); if (!LanzaSrv.EsperaProcess(GeneralDef.NombOlvTasks)) res2.Error.Add("No se ha podido cerrar oliviaTask."); } } if (res.HasError) { res2.Error.AddRange(res.Error); } return res2; } /** * Descodifica el nombre del sahpefile de entrada identificando el tipo de fracción y la carga para la recogida de residuos */ public override void decode_gdb(string shapefile, out string fraccion, out string carga) { int aux, auxl, carg, indice, fracc; string auxili, fra, auxi; indice = shapefile.IndexOf("_"); indice = indice + 2;//para saltarse la F que va antes del identificador del tipo de fracción auxili = shapefile.Substring(indice, 2); fracc = Convert.ToInt32(auxili); fraccion = RecogidaDef.tipos_fracc_str[fracc]; indice = shapefile.IndexOf("_", indice); indice = indice + 2;//para saltarse la C que va antes del identificador de los tipos de carga de los vehículos aux = shapefile.IndexOf("_", indice); auxi = ""; fra = shapefile.Substring(indice, 2); carg = Convert.ToInt32(fra); carga = RecogidaDef.tipos_fracc_str[fracc] + "_" + RecogidaDef.tipos_carg_str[carg]; //quita los espacios fraccion = fraccion.Replace(" ", "_"); carga = carga.Replace(" ", "_"); //////////////////////// auxi = shapefile; for (int i = 0; i < 2; i++) { indice = auxi.LastIndexOf("_"); auxi = auxi.Substring(0, indice); } auxl = indice - aux; if (auxl > 0) { auxili = shapefile.Substring(aux, auxl); carga = carga + auxili; } //concatena el timestamp carga = carga + shapefile.Substring(aux); } /** * Restaura el nombre original del campo si se ha truncado a 10 car al exportar a shp */ public override string[] GetCamposRestaura() { string[] camps = { RecogidaDef.campos_def.cons_id, RecogidaDef.campos_def.cons_nomrec, RecogidaDef.campos_def.cons_lateral , RecogidaDef.campos_def.cons_fracc, RecogidaDef.campos_def.cons_capac, RecogidaDef.campos_def.cons_uds, RecogidaDef.campos_def.cons_kgrec }; return camps; } /** * Rellena el array de filtros en base a la config */ public void RellenaFiltrosReco() { //se rellena el array de filtros RecogidaDef.filtro_str = new string[RecogidaDef.tipos_fracc_str.Length + RecogidaDef.tipos_carg_str.Length]; for (int i = 0; i < RecogidaDef.tipos_fracc_str.Length; i++) { //se comprueba que tipo de fracción se ha seleccionado. Si se ha seleccionado una fracción sin nombre (el campo en la capa es NULL, y en el comboBox de fracciiones aparece como "-") hay que modificar el filtro if (RecogidaDef.tipos_fracc_str[i] == "-") RecogidaDef.filtro_str[i] = RecogidaDef.campos_def.cons_fracc + " IS NULL"; else RecogidaDef.filtro_str[i] = RecogidaDef.campos_def.cons_fracc + "= '" + RecogidaDef.tipos_fracc_str[i] + "'"; } for (int i = RecogidaDef.tipos_fracc_str.Length; i < RecogidaDef.filtro_str.Length; i++) { RecogidaDef.filtro_str[i] = RecogidaDef.campos_def.cons_nomrec + "= '" + RecogidaDef.tipos_carg_str[i - RecogidaDef.tipos_fracc_str.Length] + "'"; } } } }