Beispiel #1
0
        public ActionResult EditMOP(M_MOPModel model, int?SiteId, string eswbs)
        {
            string actionName = "EditMOP";

            _logger.Log(LogLevel.Trace, actionName + " :: started.");
            using (var db = new WebAppDbContext())
            {
                using (var transaction = db.Database.BeginTransaction())
                {
                    MopViewModels vm = new MopViewModels();
                    try
                    {
                        if (!ModelState.IsValid)
                        {
                            _logger.Log(LogLevel.Trace, actionName + " :: ended.");
                            Alert("Their is something went wrong!!!", NotificationType.error);
                            return(Json(model, JsonRequestBehavior.AllowGet));
                        }
                        if (model.PMS_No != null && model.MOP_No != null && model.SiteId != 0)
                        {
                            var obj = new M_MOP()
                            {
                                SiteId             = model.SiteId,
                                PMS_No             = model.PMS_No,
                                MOP_No             = model.MOP_No,
                                MOP_Desc           = model.MOP_Desc,
                                By_Whom            = model.By_Whom,
                                Periodicity        = model.Periodicity,
                                Period             = model.Period,
                                Doc                = model.Doc,
                                Task_Procedure     = model.Task_Procedure,
                                Safety_Precautions = model.Safety_Precautions,
                            };
                            db.Entry(obj).State = EntityState.Modified;
                        }
                        db.SaveChanges();
                        transaction.Commit();
                        if (SiteId != null && eswbs != null)
                        {
                            vm = GetMopData(SiteId, eswbs);
                        }
                        _logger.Log(LogLevel.Trace, actionName + " :: ended.");

                        return(Json(new { msg = "Data Updated Sucessfully!!!", model = vm.M_MOPModel_List, pmsNo = vm.pmsNo }, JsonRequestBehavior.AllowGet));
                    }
                    catch (Exception ex)
                    {
                        _logger.Log(LogLevel.Error, actionName + " EXCEPTION :: " + ex.ToString() + " INNER EXCEPTION :: " + ex.InnerException?.ToString());
                        transaction.Rollback();
                        Exception(ex);
                        Alert("Their is something went wrong!!!", NotificationType.error);
                        return(Json(vm.M_MOPModel_List));
                    }
                }
            }
        }
Beispiel #2
0
        public ActionResult AddMOP(M_MOP model, int?SiteId, string eswbs)
        {
            string actionName = "AddMOP";

            _logger.Log(LogLevel.Trace, actionName + " :: started.");
            using (var db = new WebAppDbContext())
            {
                using (var transaction = db.Database.BeginTransaction())
                {
                    MopViewModels vm = new MopViewModels();
                    try
                    {
                        if (!ModelState.IsValid)
                        {
                            _logger.Log(LogLevel.Trace, actionName + " :: ended.");
                            Alert("Their is something went wrong!!!", NotificationType.error);
                            return(Json(model, JsonRequestBehavior.AllowGet));
                        }
                        if (model.PMS_No != null && model.MOP_No != null && model.SiteId != 0)
                        {
                            db.M_MOP.Add(model);
                            db.SaveChanges();
                            transaction.Commit();
                        }
                        if (SiteId != null && eswbs != null)
                        {
                            vm = GetMopData(SiteId, eswbs);
                        }
                        _logger.Log(LogLevel.Trace, actionName + " :: ended.");
                        //  Alert("Data Saved Sucessfully!!!", NotificationType.success);
                        return(Json(new { msg = "Data Saved Sucessfully!!!", model = vm.M_MOPModel_List }, JsonRequestBehavior.AllowGet));
                    }
                    catch (Exception ex)
                    {
                        _logger.Log(LogLevel.Error, actionName + " EXCEPTION :: " + ex.ToString() + " INNER EXCEPTION :: " + ex.InnerException?.ToString());
                        transaction.Rollback();
                        Exception(ex);
                        Alert("Their is something went wrong!!!", NotificationType.error);
                        return(Json(vm.M_MOPModel_List));
                    }
                }
            }
        }
Beispiel #3
0
        public DataModel CalculateRoutineSchedule(Queue <DataModel> queue, M_MOP mop, DateTime nextDueDate, double totalDays)
        {
            DataModel model;

            if (nextDueDate.CompareTo(DateTime.Now) <= 0)
            {
                model = new DataModel()
                {
                    Id         = "[1]",
                    Period     = mop.Period,
                    Text       = mop.MOP_Desc,
                    StartDate  = nextDueDate.ToString(),
                    EndDate    = nextDueDate.AddHours(8).ToString(),
                    IsPastDate = true,
                    Color      = "#cb6bb2"
                };
            }
            else
            {
                if (nextDueDate.CompareTo(SlidingWindow) > 0)
                {
                    return(null);
                }

                model = new DataModel()
                {
                    Id        = "[1]",
                    Period    = mop.Period,
                    Text      = mop.MOP_Desc,
                    StartDate = nextDueDate.ToString(),
                    EndDate   = nextDueDate.AddHours(8).ToString(),
                    Color     = "#cb6bb2"
                };
            }

            queue.Enqueue(model);
            return(CalculateRoutineSchedule(queue, mop, nextDueDate.AddDays(totalDays), totalDays));
        }