private void btnDespachar_Click(object sender, EventArgs e)
        {
            //### Confirmar si hay Carros para Despachar
            if (IdCarros.Count > 0)
            {
                z_carros carros = new z_carros();
                exp = exp.getObjecte_expedientes(IdExpediente);

                DatosLogin.LogPrimerDespacho = false;

                //### Sólo Si es el Primer Despacho, Actualiza la Hora del Expediente.
                if (exp.material_despachado == "")
                {
                    exp.ActualizarFechaExpediente(IdExpediente);
                    DatosLogin.LogPrimerDespacho = true;
                }

                //### Asigna el Estado NOTEMPORAL a los Carros que se Despacharán.
                for (int a = 0; a < IdCarros.Count; a++)
                {
                    carros.actualizarZcarrosLlamadoEspecifico(IdCarros[a], IdExpediente);
                }


                if (confirmado)
                {
                    DialogResult = DialogResult.OK;
                    Close();
                    return;
                }

                try
                {
                    if (AlarmaGeneral)
                    {
                        Despacho.ConfirmarDespacho(IdCarros, IdExpediente, true);
                    }
                    else
                    {
                        if (Batallon != 0)
                        {
                            Despacho.ConfirmarDespacho(IdCarros, IdExpediente, Batallon);
                        }
                        else
                        {
                            Despacho.ConfirmarDespacho(IdCarros, IdExpediente);
                        }
                    }
                    confirmado          = true;
                    btnDespachar.Text   = "Cerrar";
                    btnAgregar.Enabled  = false;
                    btnCancelar.Enabled = false;
                }
                catch (Exception ex)
                {
                    Log.ShowAndLog(ex);
                }

                //### Asigna la Hora de 6-0 a los Carros Despachados
                for (int i = 0; i < IdCarros.Count; i++)
                {
                    BitacoraLlamado.NuevoEvento(exp.id_expediente, IdCarros[i],
                                                BitacoraLlamado.Carro,
                                                "6-0");
                }


                string StIdCarro     = "";
                string StIdConductor = "";

                string CDString      = "";
                string CDStringFinal = "";
                for (int x = 0; x < IdCarros.Count; x++)
                {
                    CDString += carros.ObtenerNombreCarro(IdCarros[x]) + ",";

                    carros         = carros.getObjectz_carros(IdCarros[x]);
                    StIdCarro     += carros.id_carro + ",";
                    StIdConductor += carros.id_conductor + ",";
                }
                CDString     += "#";
                CDStringFinal = CDString.Replace(",#", "");

                StIdCarro     += "#";
                StIdCarro      = StIdCarro.Replace(",#", "");
                StIdConductor += "#";
                StIdConductor  = StIdConductor.Replace(",#", "");



                int TipoTw = 2; //### Para Despachos debe ser Valor 2


                //############################################################
                //### Insertar Servicio por Carro Despachado JSON MULTIPLE ###
                //############################################################
                //                 public z_servicio(int id_carro, DateTime fecha, int estado, int id_conductor, string motivo_fuera_servicio)
                //z_servicio servicio = new z_servicio(99, System.DateTime.Now, 4, 99, "Despacho de carros: Se genera el despacho de los carros " + CDStringFinal + "");
                //servicio.Insert(servicio);
                //string strIdCarros, string strIdConductores, string strCarros

                //### Insert Multiple en Z_SERVICIOS
                z_servicio servicio = new z_servicio();
                servicio.InsertMultiple(StIdCarro, StIdConductor, CDString);

                //### JSON Multiple en servicio
                if (carros.GetParametroPrioridad(6) == "TRUE")
                {
                    JsonServicioClaves jsc = new JsonServicioClaves();
                    jsc.JsonServicioHoraMultipleJSON(StIdCarro, 4, StIdConductor, "En Acto", "Azul", false);

                    //### Actualiz Todos los Carros   :)
                    jsc.JsonServicioHoraMultipleJSON_TodosLosCarros();
                }



                //###########################
                //### Publicar en Twitter ###
                //###########################
                if (carros.GetParametroPrioridad(1) == "TRUE")
                {
                    if (CDStringFinal != "#")
                    {
                        System.Diagnostics.Process proceso = new System.Diagnostics.Process();
                        proceso.StartInfo.FileName       = @"C:\ZEUS_CBMS\New_App_Twitter\App_Twitter_Mod.exe";
                        proceso.StartInfo.Arguments      = TipoTw.ToString() + " " + IdExpediente.ToString() + " " + DatosLogin.InvokeTwitter.ToString() + " " + CDStringFinal;
                        proceso.StartInfo.CreateNoWindow = true;
                        proceso.StartInfo.WindowStyle    = System.Diagnostics.ProcessWindowStyle.Hidden;
                        proceso.Start();
                    }
                }



                //#################
                //### App VIPER ###
                //#################
                var llam = new z_llamados();
                llam = llam.getObjectz_llamados(exp.codigo_llamado);


                //############################
                //### Producción CBMS ########
                //############################
                //# ID Usuario
                string text3 = "\"uEpZYQpJz2;"; //"\"6jD2ex00SN;";
                //# Password
                text3 += "M29vzK1BEg;";         //"a057ldMhGm;";



                //# Expediente
                text3 += exp.id_expediente.ToString() + ";";
                //# Fecha
                text3 += exp.fecha.ToString() + ";";

                ////# Clave con 0-4 para 10-12
                //if (llam.clave.ToString() == "10-12")
                //{
                //    text3 += llam.clave.ToString() + " A " + exp.cero4_10_12.ToString() + ";";
                //}
                //else
                //{
                text3 += llam.clave.ToString() + ";";
                //}

                //# Calle
                text3 += exp.seis2.ToString() + ";";
                //# Esquina
                text3 += exp.cero5.ToString() + ";";
                //# Carros
                text3 += CDStringFinal + ";";
                //# ID Area
                text3 += exp.id_area.ToString() + ";";
                //# Comuna
                text3 += exp.comuna.ToString() + ";";
                //# O-4
                text3 += exp.OrigenAlamarma.ToString() + ";";
                //# Latitud
                string[] array = exp.e_lat_long.ToString().Split(',');
                text3 += array[0].ToString() + ";";
                //# Longitud
                text3 += array[1].ToString() + ";";
                //# Incendio
                if (DatosLogin.InvokeTwitter == "FT1")
                {
                    text3 += "";
                }

                //if (DatosLogin.InvokeTwitter == "FT2")
                //{
                //    int intPrincipal = Convert.ToInt32(exp.codigo_principal.ToString());
                //    if (intPrincipal > 49)
                //    {
                //        text3 += "SALE A INCENDIO ";
                //    }
                //    else
                //    {
                //        text3 += "SALE";
                //    }
                //}

                ////### Incendios Estructural
                //if (DatosLogin.InvokeTwitter == "FT3")
                //{
                //    text3 += "INCENDIO";
                //}

                //if (DatosLogin.InvokeTwitter == "FT4")
                //{
                //    text3 += "2da ALARMA DE INCENDIO";
                //}

                //if (DatosLogin.InvokeTwitter == "FT5")
                //{
                //    text3 += "3ra ALARMA DE INCENDIO";
                //}

                //if (DatosLogin.InvokeTwitter == "FT6")
                //{
                //    text3 += "4ta ALARMA DE INCENDIO";
                //}

                //if (DatosLogin.InvokeTwitter == "FT7")
                //{
                //    text3 += "5ta ALARMA DE INCENDIO";
                //}

                //if (DatosLogin.InvokeTwitter == "FT8")
                //{
                //    text3 += "6ta ALARMA DE INCENDIO";
                //}

                //if (DatosLogin.InvokeTwitter == "FT9")
                //{
                //    text3 += "7ma ALARMA DE INCENDIO";
                //}

                ////### Incendios Forestal
                //if (DatosLogin.InvokeTwitter == "FT3F")
                //{
                //    text3 += "INCENDIO FORESTAL";
                //}

                //if (DatosLogin.InvokeTwitter == "FT4F")
                //{
                //    text3 += "2da ALARMA FORESTAL";
                //}

                //if (DatosLogin.InvokeTwitter == "FT5F")
                //{
                //    text3 += "3ra ALARMA FORESTAL";
                //}

                //if (DatosLogin.InvokeTwitter == "FT6F")
                //{
                //    text3 += "4ta ALARMA FORESTAL";
                //}

                //if (DatosLogin.InvokeTwitter == "FT7F")
                //{
                //    text3 += "5ta ALARMA FORESTAL";
                //}

                //if (DatosLogin.InvokeTwitter == "FT8F")
                //{
                //    text3 += "6ta ALARMA FORESTAL";
                //}

                //if (DatosLogin.InvokeTwitter == "FT9F")
                //{
                //    text3 += "7ma ALARMA FORESTAL";
                //}



                if (DatosLogin.InvokeTwitter == "FT2")
                {
                    int intPrincipal = Convert.ToInt32(exp.codigo_principal.ToString());
                    if (intPrincipal > 49)
                    {
                        text3 += "SALE A BATALLON DE INCENDIO ";
                    }
                    else
                    {
                        text3 += "SALE";
                    }
                }

                //### Incendios Estructural
                if (DatosLogin.InvokeTwitter == "FT3")
                {
                    text3 += "1er BATALLON DE INCENDIO ";
                }

                if (DatosLogin.InvokeTwitter == "FT4")
                {
                    text3 += "2do BATALLON DE INCENDIO ";
                }

                if (DatosLogin.InvokeTwitter == "FT5")
                {
                    text3 += "3er BATALLON DE INCENDIO ";
                }

                if (DatosLogin.InvokeTwitter == "FT6")
                {
                    text3 += "4to BATALLON DE INCENDIO ";
                }

                if (DatosLogin.InvokeTwitter == "FT7")
                {
                    text3 += "5to BATALLON DE INCENDIO ";
                }

                if (DatosLogin.InvokeTwitter == "FT8")
                {
                    text3 += "6to BATALLON DE INCENDIO ";
                }

                if (DatosLogin.InvokeTwitter == "FT9")
                {
                    text3 += "7mo BATALLON DE INCENDIO ";
                }

                //### Incendios Forestal
                if (DatosLogin.InvokeTwitter == "FT3F")
                {
                    text3 += "INCENDIO FORESTAL";
                }

                if (DatosLogin.InvokeTwitter == "FT4F")
                {
                    text3 += "2da ALARMA FORESTAL";
                }

                if (DatosLogin.InvokeTwitter == "FT5F")
                {
                    text3 += "3ra ALARMA FORESTAL";
                }

                if (DatosLogin.InvokeTwitter == "FT6F")
                {
                    text3 += "4ta ALARMA FORESTAL";
                }

                if (DatosLogin.InvokeTwitter == "FT7F")
                {
                    text3 += "5ta ALARMA FORESTAL";
                }

                if (DatosLogin.InvokeTwitter == "FT8F")
                {
                    text3 += "6ta ALARMA FORESTAL";
                }

                if (DatosLogin.InvokeTwitter == "FT9F")
                {
                    text3 += "7ma ALARMA FORESTAL";
                }



                //# Terminar Argumento
                text3 += "\"";


                //### Chequear si esta habilitado VIPER
                if (carros.GetParametroPrioridad(2) == "TRUE")
                {
                    System.Diagnostics.Process proceso2 = new System.Diagnostics.Process();
                    proceso2.StartInfo.FileName       = @"C:\ZEUS_CBMS\Viper\viper - Acceso directo";
                    proceso2.StartInfo.Arguments      = text3;
                    proceso2.StartInfo.CreateNoWindow = true;
                    proceso2.StartInfo.WindowStyle    = System.Diagnostics.ProcessWindowStyle.Hidden;
                    proceso2.Start();
                }



                //###########################
                //###   JSON Emergencia   ###
                //###########################
                //var llam = new z_llamados();
                //llam = llam.getObjectz_llamados(exp.codigo_llamado);
                string   sector_r = exp.comuna.ToString().Replace("/", "-");
                string[] array2   = exp.e_lat_long.ToString().Split(',');
                //string CarrosSlach = CDStringFinal.Replace(",", "/");   //### NOMBRES de Carros
                string CarrosSlach = StIdCarro.Replace(",", "/");         //### ID de Carros

                string[] GetFechaHora = exp.fecha.ToString().Split(' ');

                JsonEmergencia emergencia = new JsonEmergencia();
                emergencia.expediente  = exp.id_expediente.ToString();
                emergencia.correlativo = exp.correlativo.ToString();
                emergencia.fecha       = GetFechaHora[0].ToString();
                emergencia.hora        = GetFechaHora[1].ToString();

                emergencia.id_acto     = exp.codigo_principal.ToString();
                emergencia.id_llamado  = llam.codigo_llamado.ToString();
                emergencia.calle       = exp.seis2.ToString().Replace("Ñ", "N");
                emergencia.casa        = exp.casa.ToString();
                emergencia.block       = exp.block.ToString();
                emergencia.piso        = exp.Piso.ToString();
                emergencia.villa       = exp.comuna.ToString().Replace("Ñ", "N");
                emergencia.area        = exp.id_area.ToString();
                emergencia.comuna      = exp.comuna_real.ToString().Replace("Ñ", "N");
                emergencia.esquina     = exp.cero5.ToString();
                emergencia.carros      = CarrosSlach.Replace("Ñ", "N");
                emergencia.casa        = exp.casa.ToString();
                emergencia.esquina     = exp.cero5.ToString().Replace("Ñ", "N");
                emergencia.quien_llama = exp.quien_llama.ToString().Replace("Ñ", "N");
                emergencia.telefono    = exp.telefono.ToString();
                emergencia.estado      = exp.activo.ToString();
                emergencia.operadora   = DatosLogin.NomUsuario.ToString().Replace("Ñ", "N");
                emergencia.latitud     = array2[0].ToString();
                emergencia.longitud    = array2[1].ToString();
                //# Tono de Llamado
                string strTono = "";
                if (Batallon != 0)
                {
                    strTono         = "1";
                    emergencia.acto = "BATALLON DE INCENDIO";
                }
                else
                {
                    strTono         = new e_expedientes().Get_Id_Tono(exp.codigo_principal.ToString());
                    emergencia.acto = llam.clave.ToString();
                }
                emergencia.tono = strTono;

                //### Incluir Notificación ZEUS Alerta
                if (carros.GetParametroPrioridad(8).Equals("TRUE"))
                {
                    emergencia.mobile = true;
                }
                else
                {
                    emergencia.mobile = false;
                }

                string json   = JsonConvert.SerializeObject(emergencia);
                string json_2 = json.Replace("\"", "%");
                string json_3 = json_2.Replace(" ", "?");

                if (carros.GetParametroPrioridad(6).Equals("TRUE"))
                {
                    System.Diagnostics.Process proceso2 = new System.Diagnostics.Process();
                    proceso2.StartInfo.FileName       = @"C:\ZEUS_CBMS\Apolo\emergencias.py";
                    proceso2.StartInfo.Arguments      = json_3.ToString();
                    proceso2.StartInfo.CreateNoWindow = true;
                    proceso2.StartInfo.WindowStyle    = System.Diagnostics.ProcessWindowStyle.Hidden;
                    proceso2.Start();
                    //MessageBox.Show(json_3, "Json ZEUS            :)");
                }

                //### Escribir JSON MultiPuestaServicio
                string       fic = @"C:\ZEUS_CBMS\ZTablasApolo\JsonExpediente_" + System.DateTime.Now.ToString("yyyyMMddhhmmss") + ".txt";
                StreamWriter sw  = new StreamWriter(fic);
                sw.WriteLine("JSON Despacho ZEUS");
                sw.WriteLine("");
                sw.WriteLine(json_3);
                sw.Close();



                //######################## OJO
                //### Tonos Selectivos ### Agregar esta linea "using System.Linq;"
                //######################## para Distinct()
                string strParametros = "";
                if (Batallon > 0)
                {
                    //# Tono de Incendio
                    strParametros = "100,90,50";
                }
                else
                {
                    //# Tonos Selectivos
                    int[] IdCias = new int[IdCarros.Count];
                    for (int x = 0; x < IdCarros.Count; x++)
                    {
                        carros    = carros.getObjectz_carros(IdCarros[x]);
                        IdCias[x] = carros.id_compania;
                    }
                    //# Ordenar y Eliminar Compañias Repetidas
                    Array.Sort(IdCias);
                    //if (IdCias.Length > 1)
                    //{
                    //    IEnumerable<int> IdCiasUnico = IdCias.Distinct();
                    //}
                    //else
                    //{
                    //    IEnumerable<int> IdCiasUnico = IdCias;
                    //}


                    List <int> IdCiasUnico = new List <int>();
                    foreach (int i in IdCias)
                    {
                        if (!IdCiasUnico.Contains(i))
                        {
                            IdCiasUnico.Add(i);
                        }
                    }

                    //# Agrupa Tipo de Llamado
                    int ClavPrincipal  = exp.codigo_principal;
                    int TonoDelLlamado = 0;
                    if (EsLlamadoComandancia(ClavPrincipal))
                    {
                        TonoDelLlamado = 70;
                    }
                    if (EsRescate(ClavPrincipal))
                    {
                        TonoDelLlamado = 60;
                    }
                    if (EsOtrosServicios(ClavPrincipal))
                    {
                        TonoDelLlamado = 80;
                    }

                    //# Crear el String de Parámetro
                    foreach (int c in IdCiasUnico)
                    {
                        strParametros += c.ToString() + ",";
                    }

                    strParametros = "99," + strParametros + TonoDelLlamado;
                } //Fin If

                //MessageBox.Show("ParamSelectivo:  " + strParametros, "Tonos ZEUS");
                //### Activar Tonos
                if (carros.GetParametroPrioridad(3).Equals("TRUE"))
                {
                    System.Diagnostics.Process proceso2 = new System.Diagnostics.Process();
                    proceso2.StartInfo.FileName       = @"C:\ZEUS_CBMS\Tonos\TonosDesdeZeus.exe";
                    proceso2.StartInfo.Arguments      = strParametros;
                    proceso2.StartInfo.CreateNoWindow = true;
                    proceso2.StartInfo.WindowStyle    = System.Diagnostics.ProcessWindowStyle.Hidden;
                    proceso2.Start();
                }
            } //# Fin IF Si hay Carros
            else
            {
                MessageBox.Show("No hay Carros Seleccionados para ser Despachados", "ZEUS");
            } //# Fin IF Si hay Carros
        }
Example #2
0
        private void btn_AsignacionMasiva_Click(object sender, EventArgs e)
        {
            var           carros_prep = new z_carros_prep();
            z_conductores conductor   = new z_conductores();
            z_carros      carro       = new z_carros();

            if (Convert.ToInt32(this.dg_EntregaTurno.Rows.Count) >= 1)
            {
                if (MessageBox.Show(
                        "Está segura(o) que desea asignar los Conductores ?", "Asignación Automática de Conductores", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    //MessageBox.Show("La Respuesta es YES", "Sistema de ZEUS");
                    //carros_prep.AsignacionMasivaDeConductores();


                    //# Carros Preparados para ser Asignados
                    if (carros_prep.CarrosPreparados().Tables[0].Rows.Count > 0)
                    {
                        foreach (DataRow row_est in carros_prep.CarrosPreparados().Tables[0].Rows)
                        {
                            //string strConductor = "";
                            //if (row_est["tipo_conductor"].ToString() != "")
                            //{
                            //    strConductor = ObtieneNombreDeConductor(Convert.ToInt32(row_est["id_conductor"].ToString()), Convert.ToInt32(row_est["tipo_conductor"].ToString()));
                            //}

                            //# Poner en Servicio el Carro con el Conductor Asignado
                            if (Convert.ToInt32(row_est["estado"].ToString()) == 1)
                            {
                                int id_conductor = Convert.ToInt32(row_est["id_conductor"].ToString());
                                carro = carro.getObjectz_carros(row_est["nombre"].ToString());
                                var carros = new List <int> {
                                    carro.id_carro
                                };

                                if (carro.estado == 1 && carro.id_conductor != 0)
                                {
                                    // Fuera de Servicio con este Conductor
                                    Conductor.FueraServicio(carro.id_conductor, carros);
                                }
                                Conductor.PuestaEnServicio(id_conductor, carros, null);
                            }

                            //# Poner Fuera de Servicio
                            if (Convert.ToInt32(row_est["estado"].ToString()) == 2)
                            {
                                carro = carro.getObjectz_carros(row_est["nombre"].ToString());
                                Carro.FueraServicio(carro.id_carro, row_est["observacion2"].ToString());
                                //Estado = 2;
                                BitacoraGestion.NuevoEvento(1, 1, "Carro: " + carro.nombre + " Fuera de Servicio.");
                            }

                            //# Poner Sin Conductor
                            if (Convert.ToInt32(row_est["estado"].ToString()) == 3)
                            {
                                carro = carro.getObjectz_carros(row_est["nombre"].ToString());
                                Carro.SinConductor(carro.id_carro, row_est["observacion2"].ToString());
                                BitacoraGestion.NuevoEvento(DatosLogin.LoginUsuario, DatosLogin.LoginUsuario,
                                                            "Carro: " + carro.nombre + " Sin coductor");
                            }
                        }

                        //################################################################
                        //### Actualizar Todos los Carros Despues de Preparar Material ###
                        //### JSON Multiple en servicio                                ###
                        //################################################################
                        if (carro.GetParametroPrioridad(6) == "TRUE")
                        {
                            //### Actualiz Todos los Carros   :)
                            JsonServicioClaves jsc = new JsonServicioClaves();
                            jsc.JsonServicioHoraMultipleJSON_TodosLosCarros();
                        }
                    }


                    carros_prep.EliminarTosLosConductores();
                    CargarGrilla();
                    MessageBox.Show(":)   Se han asignado todos los conductores...", "Sistema de ZEUS");
                    Close();
                }
            }
            else
            {
                MessageBox.Show("No ha ingresado conductores para ser asignados...", "Sistema de ZEUS");
            }
        }