Пример #1
0
        private void btnLlamar_Click(object sender, EventArgs e)
        {
            string nroDestino = txtNroDestino.Text;
            string nroOrigen  = txtNroOrigen.Text;
            Random random     = new Random();

            if (txtNroDestino.Text != "" || txtNroDestino.Text[0] != '*')
            {
                if (txtNroDestino.Text[0] == '#')
                {
                    float             duracion = (float)random.Next(1, 50);
                    Provincial.Franja miFranja = Provincial.Franja.Franja_1;
                    switch (cmbFranja.Text)
                    {
                    case "Franja_1":
                        miFranja = Provincial.Franja.Franja_1;
                        break;

                    case "Franja_2":
                        miFranja = Provincial.Franja.Franja_2;
                        break;

                    case "Franja_3":
                        miFranja = Provincial.Franja.Franja_3;
                        break;
                    }

                    Provincial nuevaProvincial = new Provincial(txtNroOrigen.Text, miFranja, duracion, txtNroDestino.Text);
                    System.Threading.Thread.Sleep(1000);
                    try
                    {
                        centralita += nuevaProvincial;
                    }
                    catch (CentralitaException ex)
                    {
                        MessageBox.Show(ex.Message, "Error en: " + ex.NombreMetodo, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }

                    this.Close();
                }
                else
                {
                    float duracion = (float)random.Next(1, 50);
                    System.Threading.Thread.Sleep(1000);
                    Local nuevoLocal = new Local(txtNroOrigen.Text, duracion, txtNroDestino.Text, 2.65f);
                    try
                    {
                        centralita += nuevoLocal;
                    }
                    catch (CentralitaException ex)
                    {
                        MessageBox.Show(ex.Message, "Error en el " + ex.NombreMetodo, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                    this.Close();
                }
            }
        }
Пример #2
0
        public void GenerarLlamadas()
        {
            seguirGenerando = true;
            Random random = new Random();

            while (seguirGenerando)
            {
                float randDuracion = random.Next(1, 50);
                float randCosto    = (float)(random.NextDouble() * (5.6 - 0.5) + 0.5);

                System.Threading.Thread.Sleep(200);


                string nroDestino = "";
                if (random.Next(10) % 2 == 0)
                {
                    nroDestino = "#";
                }

                nroDestino += random.Next(0, 9999999).ToString();

                System.Threading.Thread.Sleep(200);

                string nroOrigen = random.Next(0, 9999999).ToString();

                System.Threading.Thread.Sleep(200);


                Provincial.Franja franja = (Provincial.Franja)(random.Next(2));



                if (nroDestino.StartsWith("#"))
                {
                    Provincial llamada = new Provincial(nroOrigen, franja, randDuracion, nroDestino);
                    this.centralita += llamada;
                    llamada.Guardar();
                    if (this.rtxtGeneradorLLamadas.InvokeRequired)
                    {
                        this.rtxtGeneradorLLamadas.BeginInvoke((MethodInvoker) delegate()
                        {
                            this.rtxtGeneradorLLamadas.Text = "Llamada Generada  \n\n" + llamada.ToString();
                        }
                                                               );
                    }
                    else
                    {
                        this.rtxtGeneradorLLamadas.Text = "Llamada Generada  \n\n" + llamada.ToString();
                    }
                }
                else
                {
                    Local llamada = new Local(nroOrigen, randDuracion, nroDestino, randCosto);
                    try
                    {
                        this.centralita += llamada;
                        llamada.Guardar();

                        if (this.rtxtGeneradorLLamadas.InvokeRequired)
                        {
                            this.rtxtGeneradorLLamadas.BeginInvoke((MethodInvoker) delegate()
                            {
                                this.rtxtGeneradorLLamadas.Text = "Llamada Generada  \n\n" + llamada.ToString();
                            }
                                                                   );
                        }
                        else
                        {
                            this.rtxtGeneradorLLamadas.Text = "Llamada Generada  \n\n" + llamada.ToString();
                        }
                    }
                    catch (CentralitaException ex)
                    {
                        MessageBox.Show(ex.Message);
                    }
                    catch (FallaLogException ex)
                    {
                        MessageBox.Show(ex.Message);
                    }
                }
                System.Threading.Thread.Sleep(3000);
            }
        }