示例#1
0
 private void btnBorrar_Click(object sender, EventArgs e)
 {
     try
     {
         if (dgvProductos.SelectedRows.Count > 0)
         {
             ProductoLogica logica = new ProductoLogica();
             bool           estado = MessageBox.Show("Esta seguro que desea borrar este producto?.", "Esta seguro?", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) == DialogResult.Yes;
             if (estado)
             {
                 int id = Convert.ToInt32(dgvProductos.CurrentRow.Cells[0].Value);
                 logica.Borrar(id);
             }
             dgvProductos.DataSource = logica.SeleccionarTodos();
             lblSuccess.Text         = "*Se eliminó satisfactoriamente.";
             lblSuccess.Visible      = true;
             MessageTimer.Start();
         }
         else
         {
             MessageBox.Show("Debe seleccionar un producto de la tabla.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
     }
     catch (Exception ex)
     {
         lblError.Text    = "*" + ex.Message;
         lblError.Visible = true;
         MessageTimer.Start();
     }
 }
示例#2
0
        public HawkwindSpeak()
        {
            Name = "Hawkwind";

            _Timer = new MessageTimer(this);
            _Timer.Start();
        }
        private void DoPublish(string subject, Message message, uint delay = 0)
        {
            if (Message.RECEIVE_ONLY == subject)
            {
                throw new InvalidOperationException(Resources.NatsMessagingProvider_PublishReceiveOnlyMessage);
            }

            log.Debug(Resources.NatsMessagingProvider_PublishMessage_Fmt, subject, delay, message);
            string formattedMessage = NatsCommand.FormatPublishMessage(subject, message);

            log.Trace(Resources.NatsMessagingProvider_LogSent_Fmt, formattedMessage);

            if (delay == 0)
            {
                Write(formattedMessage);
            }
            else
            {
                var delayTimer = new MessageTimer(delay, formattedMessage)
                {
                    AutoReset = false
                };
                delayTimer.Elapsed += DelayedPublishElapsedHandler;
                delayTimer.Enabled  = true;
            }
        }
示例#4
0
 private void btnEliminar_Click(object sender, EventArgs e)
 {
     if (dgvProductos.SelectedRows.Count > 0)
     {
         bool estado = MessageBox.Show("Esta seguro que desea borrar este producto?.", "Esta seguro?", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) == DialogResult.Yes;
         if (estado)
         {
             foreach (DataGridViewRow item in this.dgvProductos.SelectedRows)
             {
                 dgvProductos.Rows.RemoveAt(item.Index);
                 count_fila--;
             }
         }
     }
     else
     {
         MessageTimer.Start();
         lblSuccess.Visible = false;
         lblError.Text      = "*Debe seleccionar un producto de la tabla.";
         lblError.Visible   = true;
     }
     cmbProductos.SelectedItem = null;
     cmbProductos.Text         = "";
     nudCantidad.Value         = 0;
 }
示例#5
0
        public void Send()
        {
            var message = OutgoingMessages.Take(TokenSource.Token);

            MessageWaitHandle.WaitOne();
            TwitchClient.SendMessage(message.Msg);
            MessageWaitHandle.Reset();
            MessageTimer.Start();
        }
示例#6
0
        public override void OnAfterDelete()
        {
            if (_Timer != null)
            {
                _Timer.Stop();
            }

            _Timer = null;

            base.OnAfterDelete();
        }
示例#7
0
        public override void OnMovement(Mobile m, Point3D oldLocation)
        {
            if (m.AccessLevel > AccessLevel.Player && m.Hidden)
            {
                return;
            }

            if (m is PlayerMobile && m.InRange(this, 10) && _Timer == null)
            {
                _Timer = new MessageTimer(this);
                _Timer.Start();
            }
        }
示例#8
0
    static Text LoadText(float duration)
    {
        GameObject messageText = Resources.Load <GameObject>("MessageText");
        GameObject tmpText     = GameObject.Instantiate(messageText, messageBox.transform);

        tmpText.transform.localPosition = Vector3.zero;
        tmpTextAnimator.Add(tmpText.GetComponent <Animator>());

        MessageTimer.Register(PlayDestroyAnim, duration);
        Text text = tmpText.transform.GetChild(0).GetChild(0).GetComponent <Text>();

        return(text);
    }
        private void AddTimer()
        {
            MessageTimer newTimer = new MessageTimer()
            {
                Message   = "Enter you message and enble timer(Togle button ->)!",
                IsEnabled = false,
                Interval  = new TimeSpan(0, 0, 10).Ticks,
                LastShow  = DateTime.Now
            };

            MessageTimers.Add(newTimer);
            AssistantDb.Instance.Timers.Add(newTimer);
            SaveChange();
        }
    public static void Register(Action onComplete, float duration)
    {
        MessageTimerManager managerInScene = Object.FindObjectOfType <MessageTimerManager>();

        if (managerInScene == null)
        {
            GameObject managerGo = new GameObject("MessageTimerManager");
            manager = managerGo.AddComponent <MessageTimerManager>();
        }
        else
        {
            manager = managerInScene;
        }

        MessageTimer newTimer = new MessageTimer(onComplete, duration);

        manager.AddTimer(newTimer);
    }
示例#11
0
        private void DoPublish(string subject, string json, uint delay = 0)
        {
            log.Debug(Resources.NatsClient_PublishMessage_Fmt, subject, delay, json);
            string formattedMessage = NatsCommand.FormatPublishMessage(subject, json);

            log.Trace(Resources.NatsClient_LogSent_Fmt, formattedMessage);

            if (delay == 0)
            {
                Write(formattedMessage);
            }
            else
            {
                var delayTimer = new MessageTimer(delay, formattedMessage);
                delayTimer.Elapsed += DelayedPublishElapsedHandler;
                delayTimer.Enabled  = true;
            }
        }
示例#12
0
        private void btnGuardar_Click(object sender, EventArgs e)
        {
            int              id = 0;
            Producto         p;
            ProductoLogica   logica  = new ProductoLogica();
            InventarioLogica logica2 = new InventarioLogica();

            if (dgvProductos.Rows.Count > 0)
            {
                // se crea el encabezado de la salida de productos
                logica2.CrearSalidaProductos(usuario);
                foreach (DataGridViewRow item in dgvProductos.Rows)
                {
                    id          = Convert.ToInt32(item.Cells[0].Value.ToString());
                    p           = logica.SeleccionarPorId(id);
                    p.cantidad -= Convert.ToInt32(item.Cells[6].Value.ToString());
                    logica.Actualizar(p);
                    Inventario inventario = new Inventario();
                    inventario.producto = p;
                    inventario.cantidad = Convert.ToInt32(item.Cells[6].Value.ToString());

                    // se crea el detalle de la salida de productos
                    logica2.SalidaProductos(inventario);
                }

                dgvProductos.Rows.Clear();
                count_fila = 0;
                MessageTimer.Start();
                lblError.Visible   = false;
                lblSuccess.Text    = "*Se ha guardado la salida de productos.";
                lblSuccess.Visible = true;
            }
            else
            {
                MessageTimer.Start();
                lblSuccess.Visible = false;
                lblError.Text      = "*Debe agregar productos de salida.";
                lblError.Visible   = true;
            }
        }
示例#13
0
        private void btnGuardar_Click(object sender, EventArgs e)
        {
            try
            {
                RolLogica     logicaRoll    = new RolLogica();
                UsuarioLogica logicaUsuario = new UsuarioLogica();


                Usuario usuario = new Usuario();

                usuario.nombre     = txtNombre.Text;
                usuario.usuario    = txtUsuario.Text;
                usuario.contrasena = txtContrasena.Text;
                usuario.roll       = logicaRoll.SeleccionarPorId(cmbRoll.SelectedIndex);

                Usuario u = logicaUsuario.SeleccionarPorId(Convert.ToInt32(txtId.Text));

                if (u != null)
                {
                    usuario.id = Convert.ToInt32(txtId.Text);
                    logicaUsuario.Actualizar(usuario);
                }
                else
                {
                    logicaUsuario.Crear(usuario);
                }
                dgvUsuarios.DataSource          = logicaUsuario.SeleccionarTodos();
                dgvUsuarios.CurrentRow.Selected = false;
                MessageTimer.Start();
                lblSuccess.Text    = "*Guardado con éxito";
                lblSuccess.Visible = true;
            }
            catch (Exception ex)
            {
                lblError.Text    = "*" + ex.Message;
                lblError.Visible = true;
                MessageTimer.Start();
            }
        }
示例#14
0
        private void btnGuardar_Click(object sender, EventArgs e)
        {
            try
            {
                CategoriaLogica logicaCategoria = new CategoriaLogica();
                ProductoLogica  logicaProducto  = new ProductoLogica();


                Producto producto = new Producto();

                producto.nombre = txtNombre.Text;
                producto.marca  = txtMarca.Text;

                string unidad = cmbMedida.SelectedIndex == 0 ? "Kg" :
                                cmbMedida.SelectedIndex == 1 ? "g" :
                                cmbMedida.SelectedIndex == 2 ? "mL" :
                                cmbMedida.SelectedIndex == 3 ? "L" :
                                cmbMedida.SelectedIndex == 4 ? "oz" : "Kg";

                int     cantidad    = 0;
                int     minCantidad = 0;
                decimal precio      = 0m;
                decimal peso        = 0m;

                if (!int.TryParse(txtMinCantidad.Text, out minCantidad) ||
                    !int.TryParse(txtCantidad.Text, out cantidad) ||
                    !decimal.TryParse(txtPrecio.Text, out precio) ||
                    !decimal.TryParse(txtPeso.Text, out peso))
                {
                    lblError.Text = "*Debe ser un valor numérico."; lblError.Visible = true;
                }

                producto.peso        = peso;
                producto.unidad      = unidad;
                producto.cantidad    = cantidad;
                producto.minCantidad = minCantidad;
                producto.precio      = precio;
                producto.categoria   = logicaCategoria.SeleccionarPorId(cmbArea.SelectedIndex);

                Producto p = logicaProducto.SeleccionarPorId(Convert.ToInt32(txtId.Text));

                if (p != null)
                {
                    producto.id = Convert.ToInt32(txtId.Text);
                    logicaProducto.Actualizar(producto);
                }
                else
                {
                    logicaProducto.Crear(producto);
                }


                dgvProductos.DataSource          = logicaProducto.SeleccionarTodos();
                dgvProductos.CurrentRow.Selected = false;
                MessageTimer.Start();
                lblSuccess.Text    = "*Guardado con éxito.";
                lblSuccess.Visible = true;
                btnLimpiar_Click(this, null);
            }
            catch (Exception ex)
            {
                lblError.Text    = "*" + ex.Message;
                lblError.Visible = true;
                MessageTimer.Start();
            }
        }
示例#15
0
 private void MessageTimer_Tick(object sender, EventArgs e)
 {
     lblError.Visible   = false;
     lblSuccess.Visible = false;
     MessageTimer.Stop();
 }
示例#16
0
        private void btnAgregar_Click(object sender, EventArgs e)
        {
            bool existe   = false;
            int  num_fila = 0;

            ProductoLogica logica = new ProductoLogica();

            if (cmbProductos.SelectedItem == null)
            {
                lblSuccess.Visible = false;
                MessageTimer.Start();
                lblError.Text    = "*Debe seleccionar un producto.";
                lblError.Visible = true;
            }

            Producto p        = logica.SeleccionarPorId(((Producto)cmbProductos.SelectedItem).id);
            int      cantidad = Convert.ToInt32(nudCantidad.Value);

            if (count_fila == 0)
            {
                dgvProductos.Rows.Add(p.id, p.nombre, p.marca, p.pesoUnidad, p.precio, p.cantidad, cantidad);
                int cantidadFinal = Convert.ToInt32(dgvProductos.Rows[count_fila].Cells[5].Value) + cantidad;
                dgvProductos.Rows[count_fila].Cells[7].Value = cantidadFinal;
                count_fila++;
                MessageTimer.Start();
                lblError.Visible   = false;
                lblSuccess.Text    = "*Agregado con éxito.";
                lblSuccess.Visible = true;
            }
            else
            {
                foreach (DataGridViewRow item in dgvProductos.Rows)
                {
                    if (item.Cells[0].Value.ToString() == (cmbProductos.SelectedIndex + 1).ToString())
                    {
                        existe   = true;
                        num_fila = item.Index;
                    }
                }

                if (existe)
                {
                    MessageTimer.Start();
                    lblSuccess.Visible = false;
                    lblError.Text      = "*Éste producto ya se encuentra agregado.";
                    lblError.Visible   = true;
                }
                else
                {
                    dgvProductos.Rows.Add(p.id, p.nombre, p.marca, p.pesoUnidad, p.precio, p.cantidad, cantidad);
                    int cantidadFinal = Convert.ToInt32(dgvProductos.Rows[count_fila].Cells[5].Value) + cantidad;
                    dgvProductos.Rows[count_fila].Cells[7].Value = cantidadFinal;
                    count_fila++;
                    MessageTimer.Start();
                    lblError.Visible   = false;
                    lblSuccess.Text    = "*Agregado con éxito.";
                    lblSuccess.Visible = true;
                }
            }

            cmbProductos.SelectedItem        = null;
            cmbProductos.Text                = "";
            nudCantidad.Value                = 0;
            dgvProductos.CurrentRow.Selected = false;
        }
示例#17
0
        private void btnGuardar_Click(object sender, EventArgs e)
        {
            try
            {
                //---------------------------------------\\
                // ACTUALIZAR O CREAR ROLES O CATEGORÍAS \\
                //---------------------------------------\\

                ////// ROLES //////
                if (cmbTipo.SelectedIndex == 2)
                {
                    RolLogica logicaRol = new RolLogica();
                    // Nuevo Rol
                    Rol rol = new Rol();
                    rol.nombre = txtNombre.Text;

                    // Actualizar o Crear Rol
                    Rol r = logicaRol.SeleccionarPorId(Convert.ToInt32(txtId.Text));
                    if (r != null)
                    {
                        rol.id = Convert.ToInt32(txtId.Text);
                        logicaRol.Actualizar(rol);
                        dgvRoles.DataSource = logicaRol.SeleccionarTodos();
                    }
                    else
                    {
                        logicaRol.Crear(rol);
                        dgvRoles.DataSource = logicaRol.SeleccionarTodos();
                    }
                }
                else
                {
                    ////// CATEGORÍAS //////
                    if (cmbTipo.SelectedIndex == 1)
                    {
                        CategoriaLogica logicaCategoria = new CategoriaLogica();
                        // Nueva Categoría
                        Categoria categoria = new Categoria();
                        categoria.nombre = txtNombre.Text;

                        // Actualizar o Crear Categoría
                        Categoria c = logicaCategoria.SeleccionarPorId(Convert.ToInt32(txtId.Text));


                        if (c != null)
                        {
                            categoria.id = Convert.ToInt32(txtId.Text);
                            logicaCategoria.Actualizar(categoria);
                            dgvCategorias.DataSource = logicaCategoria.SeleccionarTodos();
                        }
                        else
                        {
                            logicaCategoria.Crear(categoria);
                            dgvCategorias.DataSource = logicaCategoria.SeleccionarTodos();
                        }
                    }
                    else
                    {
                        MessageTimer.Start();
                        lblError.Text    = "*Debe seleccionar un tipo";
                        lblError.Visible = true;
                    }
                }

                cmbTipo.Enabled = true;
                MessageTimer.Start();
                lblSuccess.Text                   = "*Guardado con éxito";
                lblSuccess.Visible                = true;
                txtId.Text                        = "0";
                cmbTipo.Enabled                   = true;
                txtNombre.Text                    = "";
                cmbTipo.SelectedIndex             = 0;
                dgvRoles.CurrentRow.Selected      = false;
                dgvCategorias.CurrentRow.Selected = false;
            }
            catch (Exception ex)
            {
                lblError.Text    = "*" + ex.Message;
                lblError.Visible = true;
                MessageTimer.Start();
            }
        }
 public void AddTimer(MessageTimer timer)
 {
     timersToAdd.Add(timer);
 }
        protected override void Seed(TwitchAssistantContext context)
        {
            MessageTimer[] timers = new MessageTimer[]
            {
                new MessageTimer()
                {
                    LastShow = DateTime.Now, Interval = new TimeSpan(0, 5, 0).Ticks, IsEnabled = true, Message = "enter !help for get all commands!"
                },
            };
            context.MessageTimers.AddRange(timers);

            DefaultCommand[] defaultCommands = new DefaultCommand[]
            {
                new DefaultCommand()
                {
                    Id                    = 1, Name = "help", Message = true, IsEnabled = true, Whisp = false,
                    Description           = "Get all enabled commands", Action = "Help", UserLevel = TwitchRangs.Unfollower,
                    IsGlobalCooldown      = false, GlobalCooldown = new TimeSpan(0, 0, 10).Ticks,
                    IsGlobalErrorResponse = false, IsUserLevelErrorResponse = true, IsWhispErrors = true,
                    IsChatErrors          = false
                },
                new DefaultCommand()
                {
                    Id                    = 2, Name = "hello", Message = true, IsEnabled = false, Whisp = false,
                    Description           = "Say hello with you name", Action = "SayHello", UserLevel = TwitchRangs.Unfollower,
                    IsGlobalCooldown      = false, GlobalCooldown = new TimeSpan(0, 0, 10).Ticks,
                    IsGlobalErrorResponse = false, IsUserLevelErrorResponse = true, IsWhispErrors = true,
                    IsChatErrors          = false
                },
                new DefaultCommand()
                {
                    Id                    = 3, Name = "myinfo", Message = true, IsEnabled = true, Whisp = false,
                    Description           = "Check you info", Action = "MyInfo", UserLevel = TwitchRangs.Unfollower,
                    IsGlobalCooldown      = false, GlobalCooldown = new TimeSpan(0, 0, 10).Ticks,
                    IsGlobalErrorResponse = false, IsUserLevelErrorResponse = true, IsWhispErrors = true,
                    IsChatErrors          = false
                },
                new DefaultCommand()
                {
                    Id             = 4, Name = "userInfo", Message = true, IsEnabled = true, Whisp = false,
                    Description    = "(and username) Check user info", Action = "UserInfo",
                    UserLevel      = TwitchRangs.Moderator, IsGlobalCooldown = false,
                    GlobalCooldown = new TimeSpan(0, 0, 10).Ticks, IsGlobalErrorResponse = false, IsUserLevelErrorResponse = true, IsWhispErrors = true,
                    IsChatErrors   = false
                },
                new DefaultCommand()
                {
                    Id                    = 5, Name = "coins", Message = true, IsEnabled = true, Whisp = false,
                    Description           = $"Check you coins", Action = "Coins", UserLevel = TwitchRangs.Unfollower,
                    IsGlobalCooldown      = false, GlobalCooldown = new TimeSpan(0, 0, 10).Ticks,
                    IsGlobalErrorResponse = false, IsUserLevelErrorResponse = true, IsWhispErrors = true,
                    IsChatErrors          = false
                },
                new DefaultCommand()
                {
                    Id                    = 6, Name = "uptime", Message = true, IsEnabled = true, Whisp = false,
                    Description           = "Get translation upTime", Action = "UpTime", UserLevel = TwitchRangs.Unfollower,
                    IsGlobalCooldown      = false, GlobalCooldown = new TimeSpan(0, 0, 10).Ticks,
                    IsGlobalErrorResponse = false, IsUserLevelErrorResponse = true, IsWhispErrors = true,
                    IsChatErrors          = false
                },
            };

            PlayerCommand[] playerCommands = new PlayerCommand[]
            {
                new PlayerCommand()
                {
                    Id             = 7, Name = "sr", Message = true, IsEnabled = true, Whisp = false,
                    Description    = "(and youtube link) Add song to chat playlist", Action = "SongRequest",
                    UserLevel      = TwitchRangs.Unfollower, IsGlobalCooldown = false,
                    GlobalCooldown = new TimeSpan(0, 0, 10).Ticks, IsGlobalErrorResponse = false, IsUserLevelErrorResponse = true, IsWhispErrors = true,
                    IsChatErrors   = false
                },
                new PlayerCommand()
                {
                    Id             = 8, Name = "srf", Message = true, IsEnabled = true, Whisp = false,
                    Description    = "(and youtube link) Add song to chat playlist with out queue",
                    Action         = "SongRequestFirst", UserLevel = TwitchRangs.Unfollower, IsGlobalCooldown = false,
                    GlobalCooldown = new TimeSpan(0, 0, 10).Ticks, IsGlobalErrorResponse = false, IsUserLevelErrorResponse = true, IsWhispErrors = true,
                    IsChatErrors   = false
                },
                new PlayerCommand()
                {
                    Id                    = 9, Name = "ss", Message = true, IsEnabled = true, Whisp = false,
                    Description           = "Skip current song", Action = "SkipSong", UserLevel = TwitchRangs.Unfollower,
                    IsGlobalCooldown      = false, GlobalCooldown = new TimeSpan(0, 0, 10).Ticks,
                    IsGlobalErrorResponse = false, IsUserLevelErrorResponse = true, IsWhispErrors = true,
                    IsChatErrors          = false
                },
                new PlayerCommand()
                {
                    Id             = 10, Name = "sql", Message = true, IsEnabled = true, Whisp = false,
                    Description    = "Chat playlist queue length", Action = "SongQeueLeght",
                    UserLevel      = TwitchRangs.Unfollower, IsGlobalCooldown = false,
                    GlobalCooldown = new TimeSpan(0, 0, 10).Ticks, IsGlobalErrorResponse = false, IsUserLevelErrorResponse = true, IsWhispErrors = true,
                    IsChatErrors   = false
                },
                new PlayerCommand()
                {
                    Id                    = 11, Name = "song", Message = true, IsEnabled = true, Whisp = false,
                    Description           = "Current song info", Action = "CurentSong", UserLevel = TwitchRangs.Unfollower,
                    IsGlobalCooldown      = false, GlobalCooldown = new TimeSpan(0, 0, 10).Ticks,
                    IsGlobalErrorResponse = false, IsUserLevelErrorResponse = true, IsWhispErrors = true,
                    IsChatErrors          = false
                },
                new PlayerCommand()
                {
                    Id             = 12, Name = "playlist", Message = false, IsEnabled = false, Whisp = false,
                    Description    = "Get streamer playlist", Action = "StreamerPlaylist",
                    UserLevel      = TwitchRangs.Unfollower, IsGlobalCooldown = false,
                    GlobalCooldown = new TimeSpan(0, 0, 10).Ticks, IsGlobalErrorResponse = false, IsUserLevelErrorResponse = true, IsWhispErrors = true,
                    IsChatErrors   = false
                },
                new PlayerCommand()
                {
                    Id                    = 13, Name = "cPlaylist", Message = true, IsEnabled = true, Whisp = false,
                    Description           = "Get chat playlist", Action = "ChatPlaylist", UserLevel = TwitchRangs.Unfollower,
                    IsGlobalCooldown      = false, GlobalCooldown = new TimeSpan(0, 0, 10).Ticks,
                    IsGlobalErrorResponse = false, IsUserLevelErrorResponse = true, IsWhispErrors = true,
                    IsChatErrors          = false
                },
            };

            CustomCommand[] customCommands = new CustomCommand[] { };


            context.DefaultCommands.AddRange(defaultCommands);
            context.PlayerCommands.AddRange(playerCommands);
            context.CustomCommands.AddRange(customCommands);
            base.Seed(context);
        }
示例#20
0
 public void StartMessageWatching()
 {
     MessageTimer.Start();
 }
示例#21
0
 public void StopMessageWatching()
 {
     MessageTimer.Stop();
 }
示例#22
0
        private void DoPublish(string subject, string json, uint delay = 0)
        {
            log.Debug(Resources.NatsClient_PublishMessage_Fmt, subject, delay, json);
            string formattedMessage = NatsCommand.FormatPublishMessage(subject, json);
            log.Trace(Resources.NatsClient_LogSent_Fmt, formattedMessage);

            if (delay == 0)
            {
                Write(formattedMessage);
            }
            else
            {
                var delayTimer = new MessageTimer(delay, formattedMessage);
                delayTimer.Elapsed += DelayedPublishElapsedHandler;
                delayTimer.Enabled = true;
            }
        }