Exemplo n.º 1
0
        public async Task <IActionResult> PutErrorHistory(int id, ErrorHistory errorHistory)
        {
            if (id != errorHistory.Id)
            {
                return(BadRequest());
            }

            _context.Entry(errorHistory).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!ErrorHistoryExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Exemplo n.º 2
0
        public async Task <ActionResult <ErrorHistory> > PostErrorHistory(ErrorHistory errorHistory)
        {
            _context.ErrorHistory.Add(errorHistory);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetErrorHistory", new { id = errorHistory.Id }, errorHistory));
        }
Exemplo n.º 3
0
        private static void AddRow(ErrCategory category,
                                   ErrLevel level,
                                   string factoryID,
                                   string shopID,
                                   string lotID,
                                   string productID,
                                   string productVer,
                                   string processID,
                                   string eqpID,
                                   string stepID,
                                   string reason,
                                   string detail
                                   )
        {
            Outputs.ErrorHistory item = new ErrorHistory();

            item.VERSION_NO = ModelContext.Current.VersionNo;

            item.ERR_CATEGORY    = category.ToString();
            item.ERR_LEVEL       = level.ToString();
            item.FACTORY_ID      = factoryID;
            item.SHOP_ID         = shopID;
            item.LOT_ID          = lotID;
            item.PRODUCT_ID      = productID;
            item.PRODUCT_VERSION = productVer;
            item.PROCESS_ID      = processID;
            item.EQP_ID          = eqpID;
            item.STEP_ID         = stepID;
            item.ERR_REASON      = reason;
            item.REASON_DETAIL   = detail;

            OutputMart.Instance.ErrorHistory.Add(item);
        }
Exemplo n.º 4
0
        public async Task <ActionResult <Error> > PostError([FromBody] ErrorDto errorDto)
        {
            Error error = _mapper.Map <Error>(errorDto);

            error.Status      = _context.Status.SingleOrDefault(s => s.Id == error.StatusId);
            error.Priority    = _context.Priority.SingleOrDefault(p => p.Id == error.PriorityId);
            error.Impact      = _context.Impact.SingleOrDefault(i => i.Id == error.ImpactId);
            error.User        = _context.Users.SingleOrDefault(u => u.Id == error.UserId);
            error.DateCreated = DateTime.Now;
            _context.Error.Add(error);
            var errorHistory = new ErrorHistory
            {
                Error   = error,
                Action  = _context.Action.SingleOrDefault(a => a.Name == "Ввод"),
                Comment = "",
                User    = error.User,
                Date    = DateTime.Now
            };

            _context.ErrorHistory.Add(errorHistory);
            await _context.SaveChangesAsync();

            var err = _mapper.Map <ErrorDto>(error);

            return(CreatedAtAction("GetError", new { id = error.Id }, err));
        }
Exemplo n.º 5
0
 public ActionResult Edit(ErrorHistory errorhistory)
 {
     if (ModelState.IsValid)
     {
         objErrorHistoryBO.UpdateErrorHistory(errorhistory);
         return(RedirectToAction("Index"));
     }
     return(View(errorhistory));
 }
Exemplo n.º 6
0
        public static void WriteErrorHistory(ErrorLevel errorLevel, string reason)
        {
            ErrorHistory info = new ErrorHistory();

            info.LEVEL  = errorLevel.ToString();
            info.REASON = reason;

            OutputMart.Instance.ErrorHistory.Add(info);
        }
Exemplo n.º 7
0
 public ActionResult Create(ErrorHistory errorhistory)
 {
     if (ModelState.IsValid)
     {
         objErrorHistoryBO.InsertErrorHistory(errorhistory);
         return(RedirectToAction("Index"));
     }
     return(View(errorhistory));
 }
Exemplo n.º 8
0
 public void UpdateErrorHistory(ErrorHistory objErrorHistory)
 {
     try
     {
         context.Entry(objErrorHistory).State = EntityState.Modified;
         context.SaveChanges();
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Exemplo n.º 9
0
 public void DeleteErrorHistory(int errorHistoryId)
 {
     try
     {
         ErrorHistory objErrorHistory = context.ErrorHistories.Find(errorHistoryId);
         context.ErrorHistories.Remove(objErrorHistory);
         context.SaveChanges();
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Exemplo n.º 10
0
        // GET: /Admin/Error/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            ErrorHistory errorhistory = objErrorHistoryBO.GetErrorHistory(id.Value);

            if (errorhistory == null)
            {
                return(HttpNotFound());
            }
            return(View(errorhistory));
        }
Exemplo n.º 11
0
 public void InsertErrorHistory(ErrorHistory objErrorHistory)
 {
     try
     {
         objErrorHistory.ErrorLogTime = DateTime.Now;
         if (!string.IsNullOrEmpty(Helper.UserData))
         {
             objErrorHistory.FKUserId = Helper.UserId;
         }
         context.ErrorHistories.Add(objErrorHistory);
         context.SaveChanges();
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Exemplo n.º 12
0
        public async Task <ActionResult <ErrorHistoryResponse> > Update(int id, [FromBody] ErrorHistoryItemRequest request)
        {
            var user = await db.Users.FirstOrDefaultAsync(x => x.Login == User.Identity.Name);

            var error = await db.Errors.FindAsync(id);

            if (error == null)
            {
                return(BadRequest("The is no error"));
            }

            if (error.State >= (Error.StateEnum)request.Action)
            {
                return(BadRequest($"State '{(Error.StateEnum)request.Action}' cannot become after '{error.State}'"));
            }

            var historyItem = new ErrorHistory
            {
                Date    = DateTime.Now,
                Action  = request.Action,
                Comment = request.Comment,
                UserId  = user.Id,
                ErrorId = id
            };

            error.State = (Error.StateEnum)historyItem.Action;

            db.ErrorHistory.Add(historyItem);
            db.Update(error);

            await db.SaveChangesAsync();

            return(new ErrorHistoryResponse
            {
                Id = historyItem.Id,
                Date = historyItem.Date,
                Action = historyItem.Action,
                Comment = historyItem.Comment,
                User = new UserResponse
                {
                    Name = user.Name,
                    Surname = user.Surname
                }
            });
        }
Exemplo n.º 13
0
        public async Task <ActionResult <ErrorPreviewResponse> > Create([FromBody] NewErrorRequest request)
        {
            var user = await db.Users.FirstOrDefaultAsync(x => x.Login == User.Identity.Name);

            var error = new Error
            {
                CreateDate       = DateTime.Now,
                ShortDescription = request.ShortDescription,
                Description      = request.Description,
                State            = Error.StateEnum.New,
                Urgency          = request.Urgency,
                Criticality      = request.Criticality
            };

            db.Errors.Add(error);

            await db.SaveChangesAsync();

            var firstHistoryItem = new ErrorHistory
            {
                Date    = DateTime.Now,
                Action  = ErrorHistory.ActionEnum.Input,
                Comment = "Init",
                UserId  = user.Id,
                ErrorId = error.Id
            };

            db.ErrorHistory.Add(firstHistoryItem);

            await db.SaveChangesAsync();

            return(new ErrorPreviewResponse
            {
                Id = error.Id,
                CreateDate = error.CreateDate,
                ShortDescription = error.ShortDescription,
                State = error.State,
                Urgency = error.Urgency,
                Criticality = error.Criticality
            });
        }
Exemplo n.º 14
0
        /// <summary>
        /// Treains the neural network over a given number of epochs using backpropagation.
        /// </summary>
        /// <param name="epochs">THe number of iterations to which the neural network will train before failing.</param>
        /// <param name="minimumError">The minimum error which the network must reach to </param>
        /// <param name="learningRate">The learning rate at which the network will begin to learn.</param>
        /// <param name="momentum">The momentum at which the network will begin to learn.</param>
        /// <param name="nudging">Enables nudging of the neural network during training.</param>
        /// <returns>Whether or not the network was successful in learning.</returns>
        public int Train(int epochs, double minimumError, bool nudging = false, params double[] learningParameters)
        {
            ErrorHistory.Clear();
            int    epoch = 0;
            double error = 0;

            do
            {
                epoch++;

                //Train online or perform batch training
                if (online)
                {
                    error = trainingSet.Select(
                        dp => network.Train(dp, learningParameters))
                            .Sum();
                }
                else
                {
                    error = network.Train(trainingSet, learningParameters);
                }

                this.ErrorHistory.Add(error);

                //NUDGING
                if (nudging && ErrorHistory
                    .SkipWhile(i => i < ErrorHistory.Count() - 10)
                    .StdDev() < .0000075)
                {
                    network.NudgeWeights(); //Nudge the weights
                }

#if DEBUG
                Console.WriteLine("Epoch {0}: Error = {1};", epoch, error);
#endif
            }while (epoch < epochs && error > minimumError);
            return(epoch);
        }
Exemplo n.º 15
0
        public double train(TrainingTemplate trainingTemplate, int extMaxGenerations, ErrorHistory errorProg)
        {
            //This is simple but the ideea is suposed to be that in larger networks here I do a foreach over the neurons
            double error = this.trainingMethod.trainNetwork(trainingTemplate, perceptron, extMaxGenerations, errorProg);

            return(error);
        }
        public void OnException(ExceptionContext filterContext)
        {
            var area = "";//todo....

            var controller = (filterContext.RouteData.Values["controller"] ?? "").ToString();
            var action     = (filterContext.RouteData.Values["action"] ?? "").ToString();

            //səbəbkar erroru tapmaq
            while (filterContext.Exception.InnerException != null)
            {
                filterContext.Exception = filterContext.Exception.InnerException;
            }

            var model = new HandleErrorInfo(filterContext.Exception, controller, action);

            try
            {
                using (var db = new CvDbContext())
                {
                    var entity = new ErrorHistory();
                    if (!string.IsNullOrWhiteSpace(area))
                    {
                        entity.AreaName = area;
                    }
                    if (!string.IsNullOrWhiteSpace(controller))
                    {
                        entity.ControllerName = controller;
                    }
                    if (!string.IsNullOrWhiteSpace(action))
                    {
                        entity.ActionName = action;
                    }

                    if (filterContext.Exception is HttpException)
                    {
                        entity.ErrorCode = (filterContext.Exception as HttpException).GetHttpCode();
                    }
                    else if (filterContext.Exception is SqlException)
                    {
                        entity.ErrorCode    = (filterContext.Exception as SqlException).Number;
                        entity.ErrorMessage = filterContext.Exception.Message;
                    }
                    else
                    {
                        entity.ErrorMessage = filterContext.Exception.Message;
                    }
                    logger.Fatal(entity.ErrorMessage);
                    entity.CreatedDate = DateTime.Now;
                    db.ErrorHistories.Add(entity);
                    db.SaveChanges();
                }
            }
            catch (Exception)
            {
                //logger.Fatal(ex)
            }

            filterContext.Result = new ViewResult
            {
                ViewName = "~/Views/Home/ErrorPage.cshtml",

                //MasterName = "~/Views/Shared/_Layout.cshtml",
                ViewData = new ViewDataDictionary <HandleErrorInfo>(model),
                TempData = filterContext.Controller.TempData
            };

            filterContext.ExceptionHandled = true;
        }
Exemplo n.º 17
0
        public async Task <IActionResult> PutError(int id, ErrorDto errorDto)
        {
            var errorBf    = _context.Error.SingleOrDefault(e => e.Id == id);
            var prevStatus = errorBf.Status;
            var error      = _mapper.Map <Error>(errorDto);
            var status     = _context.Status.SingleOrDefault(s => s.Id == errorDto.StatusId);

            if (id != error.Id)
            {
                return(BadRequest());
            }

            var action = new Models.Action();

            // check statuses
            if (prevStatus.Name != status.Name)
            {
                if (prevStatus.Name == ErrorStatusTypes.New &&
                    status.Name != ErrorStatusTypes.Opened)
                {
                    return(BadRequest());
                }
                if (prevStatus.Name == ErrorStatusTypes.Opened &&
                    status.Name != ErrorStatusTypes.Solved)
                {
                    return(BadRequest());
                }
                if (prevStatus.Name == ErrorStatusTypes.Solved &&
                    (status.Name != ErrorStatusTypes.Opened &&
                     status.Name != ErrorStatusTypes.Closed))
                {
                    return(BadRequest());
                }
                if (prevStatus.Name == ErrorStatusTypes.Closed)
                {
                    return(BadRequest());
                }

                if (status.Name == ErrorStatusTypes.Opened)
                {
                    action = _context.Action.SingleOrDefault(a => a.Name == "Открытие");
                }
                if (status.Name == ErrorStatusTypes.Solved)
                {
                    action = _context.Action.SingleOrDefault(a => a.Name == "Решение");
                }
                if (status.Name == ErrorStatusTypes.Closed)
                {
                    action = _context.Action.SingleOrDefault(a => a.Name == "Закрытие");
                }

                // all good
                var errorHistory = new ErrorHistory {
                    Error   = error,
                    Action  = action,
                    Comment = error.ErrorHistory.ToList()[error.ErrorHistory.Count - 1].Comment,
                    User    = _context.Users.SingleOrDefault(u => u.Id == errorDto.UserId),
                    Date    = DateTime.Now
                };

                _context.ErrorHistory.Add(errorHistory);
            }

            var entry = _context.Entry(error);

            entry.Property(e => e.ShortDesc).IsModified   = true;
            entry.Property(e => e.Description).IsModified = true;
            entry.Property(e => e.PriorityId).IsModified  = true;
            entry.Property(e => e.ImpactId).IsModified    = true;
            entry.Property(e => e.StatusId).IsModified    = true;

            try {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException) {
                if (!ErrorExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Exemplo n.º 18
0
        public async Task <IActionResult> Update(editClass ed)
        {
            err err1 = await db.Errors.FirstOrDefaultAsync(p => p.id == ed.Err.id);



            string a = Request.Form["status"].ToString();



            if (err1.statusId != 4)
            {
                if (a == "Открытая")
                {
                    Models.Status st = await db.Statuses.FirstOrDefaultAsync(p => p.id == 2);

                    err1.status = st;
                }
                if (a == "Решенная")
                {
                    Models.Status st = await db.Statuses.FirstOrDefaultAsync(p => p.id == 3);

                    err1.status = st;
                }
                if (a == "Закрытая")
                {
                    Models.Status st = await db.Statuses.FirstOrDefaultAsync(p => p.id == 4);

                    err1.status = st;
                }
                ErrorHistory e = new ErrorHistory();
                if (a == "Открытая")
                {
                    e.act = "Открытие";
                }
                if (a == "Решенная")
                {
                    e.act = "Решение";
                }
                if (a == "Закрытая")
                {
                    e.act = "Закрытие";
                }
                ed.Err.user_id = User.Identity.Name;

                e.errId = ed.Err.id;


                if (ed.buf != null && err1.status != null)
                {
                    e.comnt = ed.buf;
                }


                e.date    = DateTime.Now;
                e.user_id = ed.Err.user_id;

                db.ErHstr.Add(e);
                db.Errors.Update(err1);
                await db.SaveChangesAsync();

                return(RedirectToAction("Index", "Home"));
            }


            return(RedirectToAction("Index", "Home"));
        }
Exemplo n.º 19
0
 public double train(TrainingTemplate trainingTemplate, int extMaxGenerations, ErrorHistory errorProg)
 {
     //Note to self 0.1 is right out of my ass
     return(trainer.trainNetwork(trainingTemplate, inputLayer, outputLayer, hiddenLayer, extMaxGenerations, 0.1, errorProg));
 }
Exemplo n.º 20
0
        private void button1_Click(object sender, EventArgs e)
        {
            neuron = new Neuron("AND-Neuron", 0, 2);
            neuron.addNewInput("input1", 0, 0);
            neuron.addNewInput("input2", 0, 0);
            PerceptronNetwork pn = new PerceptronNetwork(neuron);

            TrainingTemplate andTemplate = new TrainingTemplate("AND Template");

            andTemplate.addTrainingRow(new TrainingRow(new List <double> {
                0, 0
            }, new List <double> {
                0
            }));
            andTemplate.addTrainingRow(new TrainingRow(new List <double> {
                0, 1
            }, new List <double> {
                0
            }));
            andTemplate.addTrainingRow(new TrainingRow(new List <double> {
                1, 0
            }, new List <double> {
                0
            }));
            andTemplate.addTrainingRow(new TrainingRow(new List <double> {
                1, 1
            }, new List <double> {
                1
            }));

            TrainingTemplate orTemplate = new TrainingTemplate("OR Template");

            orTemplate.addTrainingRow(new TrainingRow(new List <double> {
                0, 0
            }, new List <double> {
                0
            }));
            orTemplate.addTrainingRow(new TrainingRow(new List <double> {
                0, 1
            }, new List <double> {
                1
            }));
            orTemplate.addTrainingRow(new TrainingRow(new List <double> {
                1, 0
            }, new List <double> {
                1
            }));
            orTemplate.addTrainingRow(new TrainingRow(new List <double> {
                1, 1
            }, new List <double> {
                1
            }));

            TrainingTemplate xorTemplate = new TrainingTemplate("XOR Template");

            xorTemplate.addTrainingRow(new TrainingRow(new List <double> {
                0, 0
            }, new List <double> {
                0
            }));
            xorTemplate.addTrainingRow(new TrainingRow(new List <double> {
                0, 1
            }, new List <double> {
                1
            }));
            xorTemplate.addTrainingRow(new TrainingRow(new List <double> {
                1, 0
            }, new List <double> {
                1
            }));
            xorTemplate.addTrainingRow(new TrainingRow(new List <double> {
                1, 1
            }, new List <double> {
                0
            }));


            templatesList = new List <TrainingTemplate>();

            ErrorHistory errorProg = new ErrorHistory();

            double error = pn.train(xorTemplate, 100, errorProg);

            labelWeight1.Text = neuron.inputs[0].weight.ToString("N3");

            labelWeight2.Text = neuron.inputs[1].weight.ToString("N3");

            labelError.Text = error.ToString("N3");



            for (int X = 0; X < errorProg.errorPoints.Count; X++)
            {
                chart1.Series["Error"].Points.AddXY(X, errorProg.errorPoints[X]);
            }

            //chart1.DataBind(errorProg);
        }