예제 #1
0
        public void State()
        {
            string State = "";

            try
            {
                using (Model.AntiProcrastineEntities db = new Model.AntiProcrastineEntities())
                {
                    //Reviso el Estado de ANTI PROCRASTINE
                    // y Lo agrego el StateEventArgs
                    Model.AntiP AP = db.AntiP.First();
                    State = AP.State.ToString();
                    var e = new StateEventArgs();
                    e.State = State;
                    EventState(this, e);
                }
            }
            //cath para saber sobre error en Entity Framework
            catch (DbEntityValidationException ex)
            {
                StringBuilder sb = new StringBuilder();

                foreach (var failure in ex.EntityValidationErrors)
                {
                    sb.AppendFormat("{0} failed validation\n", failure.Entry.Entity.GetType());
                    foreach (var error in failure.ValidationErrors)
                    {
                        sb.AppendFormat("- {0} : {1}", error.PropertyName, error.ErrorMessage);
                        sb.AppendLine();
                    }
                }

                throw new DbEntityValidationException(
                          "Entity Validation Failed - errors follow:\n" +
                          sb.ToString(), ex

                          ); // Add the original exception as the innerException
            }
            catch (Exception ex)
            {
                State = ex.Message;
            }

            //return State;
        }
예제 #2
0
        public void Start()
        {
            try
            {
                using (Model.AntiProcrastineEntities db = new Model.AntiProcrastineEntities())
                {
                    Model.AntiP AP = db.AntiP.First();

                    //if (AP.State == "Down")
                    AP.State = "Up";

                    db.Entry(AP).State = System.Data.Entity.EntityState.Modified;
                    db.SaveChanges();
                    var e = new StateEventArgs();
                    e.State = "Up";
                    EventState(this, e);
                }
            }
            //cath para saber sobre error en Entity Framework
            catch (DbEntityValidationException ex)
            {
                StringBuilder sb = new StringBuilder();

                foreach (var failure in ex.EntityValidationErrors)
                {
                    sb.AppendFormat("{0} failed validation\n", failure.Entry.Entity.GetType());
                    foreach (var error in failure.ValidationErrors)
                    {
                        sb.AppendFormat("- {0} : {1}", error.PropertyName, error.ErrorMessage);
                        sb.AppendLine();
                    }
                }

                throw new DbEntityValidationException(
                          "Entity Validation Failed - errors follow:\n" +
                          sb.ToString(), ex

                          ); // Add the original exception as the innerException
            }
            catch (Exception ex)
            {
                string Error = ex.Message;
            }
        }
예제 #3
0
        //Metodo que se ejecuta cuando se consulta el estado del SISTEMA
        private void Control_ChangeState(object sender, Admin.StateEventArgs e)
        {
            Estado = e.State;

            if (Estado == "Down")
            {
                btnDeshabilitar.Visible = false;
                lblStatus.Text          = "Down";
                lblStatus.ForeColor     = Color.Red;
                lblStatus.Visible       = true;
            }
            else
            {
                btnDeshabilitar.Visible = true;
                lblStatus.Text          = "Up";
                lblStatus.ForeColor     = Color.Green;
                lblStatus.Visible       = true;
            }
        }