コード例 #1
0
ファイル: status_ctrl.cs プロジェクト: printedheart/logwizard
        // sets the status for a given period - after that ends, the previous status is shown
        // if < 0, it's forever
        public void set_status(string msg, status_type type = status_type.msg, int set_status_for_ms = 7500) {
            if (set_status_for_ms <= 0)
                statuses_.Clear();

            if (type == status_type.err)
                // show errors longer
                set_status_for_ms = Math.Max(set_status_for_ms, 15000);

            // 1.5.6+ special case - if the status is the same
            bool same_status = false;
            if ( statuses_.Count > 0)
                if (statuses_.Last().Item1 == msg && statuses_.Last().Item2 == type) {
                    // same message
                    statuses_.RemoveAt( statuses_.Count - 1);
                    same_status = true;
                }

            statuses_.Add(new Tuple<string, status_type, DateTime>(msg, type, set_status_for_ms > 0 ? DateTime.Now.AddMilliseconds(set_status_for_ms) : DateTime.MaxValue));
            if (same_status)
                return;
            show_last_status();

            if (type == status_type.err)
                util.beep(util.beep_type.err);
        }
コード例 #2
0
        public IHttpActionResult Putstatus_type(int id, status_type status_type)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != status_type.id_status)
            {
                return(BadRequest());
            }

            db.Entry(status_type).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!status_typeExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
コード例 #3
0
        public async Task Put()
        {
            //Arrange
            var get = await controller.Get(1);

            var okgetResult = Assert.IsType <OkObjectResult>(get);
            var entity      = Assert.IsType <status_type>(okgetResult.Value);


            var newEntity = new status_type();

            newEntity.status = "deployed";
            //should test the equals Equatable for all these too
            var huh = entity.Equals(newEntity);

            entity.status = "testEdit";
            // Act
            var response = await controller.Put(1, entity);

            // Assert
            var okResult = Assert.IsType <OkObjectResult>(response);
            var result   = Assert.IsType <status_type>(okResult.Value);

            Assert.Equal(entity.status, result.status);
        }
コード例 #4
0
        public IHttpActionResult Getstatus_type(int id)
        {
            status_type status_type = db.status_type.Find(id);

            if (status_type == null)
            {
                return(NotFound());
            }

            return(Ok(status_type));
        }
コード例 #5
0
        public IHttpActionResult Poststatus_type(status_type status_type)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.status_type.Add(status_type);
            db.SaveChanges();

            return(CreatedAtRoute("DefaultApi", new { id = status_type.id_status }, status_type));
        }
コード例 #6
0
        public IHttpActionResult Deletestatus_type(int id)
        {
            status_type status_type = db.status_type.Find(id);

            if (status_type == null)
            {
                return(NotFound());
            }

            db.status_type.Remove(status_type);
            db.SaveChanges();

            return(Ok(status_type));
        }
コード例 #7
0
 public async Task <IActionResult> Put(int id, [FromBody] status_type entity)
 {
     try
     {
         if (id < 0 || !isValid(entity))
         {
             return(new BadRequestResult());
         }
         return(Ok(await agent.Update <status_type>(id, entity)));
     }
     catch (Exception ex)
     {
         return(await HandleExceptionAsync(ex));
     }
 }
コード例 #8
0
 public async Task <IActionResult> Post([FromBody] status_type entity)
 {
     try
     {
         if (!isValid(entity))
         {
             return(new BadRequestResult());
         }
         //sm(agent.Messages);
         return(Ok(await agent.Add <status_type>(entity)));
     }
     catch (Exception ex)
     {
         //sm(agent.Messages);
         return(await HandleExceptionAsync(ex));
     }
 }
コード例 #9
0
        public async Task Post()
        {
            //Arrange
            var entity = new status_type()
            {
                status = "TestPost"
            };


            //Act
            var response = await controller.Post(entity);

            // Assert
            var okResult = Assert.IsType <OkObjectResult>(response);
            var result   = Assert.IsType <status_type>(okResult.Value);


            Assert.Equal("TestPost", result.status);
        }
コード例 #10
0
        // sets the status for a given period - after that ends, the previous status is shown
        // if < 0, it's forever
        public void set_status(string msg, status_type type = status_type.msg, int set_status_for_ms = 7500)
        {
            bool was_showing_error = is_showing_error;

            if (set_status_for_ms <= 0)
            {
                statuses_.Clear();
            }

            if (type == status_type.err)
            {
                // show errors longer
                set_status_for_ms = Math.Max(set_status_for_ms, 15000);
            }

            // 1.5.6+ special case - if the status is the same
            bool same_status = false;

            if (statuses_.Count > 0)
            {
                if (statuses_.Last().Item1 == msg && statuses_.Last().Item2 == type)
                {
                    // same message
                    statuses_.RemoveAt(statuses_.Count - 1);
                    same_status = true;
                }
            }

            statuses_.Add(new Tuple <string, status_type, DateTime>(msg, type, set_status_for_ms > 0 ? DateTime.Now.AddMilliseconds(set_status_for_ms) : DateTime.MaxValue));
            if (same_status)
            {
                return;
            }
            show_last_status();

            // 1.8.6+ (if showing a new error, no need to beep again)
            if (type == status_type.err && !was_showing_error)
            {
                util.beep(util.beep_type.err);
            }
        }
コード例 #11
0
ファイル: status_ctrl.cs プロジェクト: printedheart/logwizard
 private Color status_bg_color(status_type type) {
     return type == status_type.err ? Color.Yellow : util.transparent;
 }
コード例 #12
0
ファイル: status_ctrl.cs プロジェクト: printedheart/logwizard
 private Color status_color(status_type type) {
     return type == status_type.err ? Color.DarkRed : util.transparent;
 }
コード例 #13
0
 private Color status_bg_color(status_type type)
 {
     return(type == status_type.err ? Color.Yellow : util.transparent);
 }
コード例 #14
0
 private Color status_color(status_type type)
 {
     return(type == status_type.err ? Color.DarkRed : util.transparent);
 }