Example #1
0
        public static bool HasComments(this OapGenericCheckListFlatModel question, RigOapChecklist rigOapChecklist)
        {
            IOAPServiceDataModel       dataModel = OAPServiceSystem.GetServiceModel(OAPServiceSystem.OAPDataModelType.Comment);
            IEnumerable <CommentModel> comments  = dataModel.GetItems(string.Format("QuestionId=\"{0}\" AND SourceFormId=\"{1}\"", question.QuestionId, rigOapChecklist.Id.ToString()), "Id").Cast <CommentModel>();

            return(comments.Count() > 0);
        }
Example #2
0
        private void LessonLearnedViewBag(dynamic viewBag)
        {
            dataModel = OAPServiceSystem.GetServiceModel(OAPServiceSystem.OAPDataModelType.LessonLearnedType);
            IEnumerable <LessonLearnedType> types = dataModel.GetAllItems().Cast <LessonLearnedType>();

            viewBag.LessonTypes = types;
        }
Example #3
0
        // GET: IRMA/LessonsLearned
        public ActionResult Index()
        {
            dataModel = OAPServiceSystem.GetServiceModel(OAPServiceSystem.OAPDataModelType.LessonLearned);
            var lessonsLearned = dataModel.GetAllItems().Cast <LessonLearnedModel>().ToList();

            return(View(lessonsLearned));
        }
Example #4
0
        public ActionResult ApprovalProcessApproval(int Id, int ApprovalId, int Approver, int Status, string Comment)
        {
            string                comment       = (Comment == "null") ? "" : Comment; // DevExpress sending the 'null' string when textbox is empty
            LessonLearnedModel    lessonLearned = (LessonLearnedModel)Session["LessonLearnedModel"];
            IIrmaServiceDataModel serviceSystem = IrmaServiceSystem.GetServiceModel(IrmaConstants.IrmaPobModels.Approval);
            ApprovalModel         approval      = serviceSystem.GetItem(string.Format("Id={0}", ApprovalId), "Id");

            approval.ApprovedDate     = DateTime.Now;
            approval.ApproverComments = Comment;
            approval.Status           = Status;
            lessonLearned.Approvals.FirstOrDefault(a => a.Id == ApprovalId).Status = Status;
            switch (Status)
            {
            case (int)IrmaConstants.ApprovalStatus.Approved:
                var approvedCount = lessonLearned.GetApprovals().Where(a => a.Status == (int)IrmaConstants.ApprovalStatus.Approved).Count();
                var totalCount    = lessonLearned.GetApprovals().Count();
                if (approvedCount == totalCount)     // Proceeds with the workflow / auto close
                {
                    lessonLearned.Status = "Closed";
                }
                break;

            case (int)IrmaConstants.ApprovalStatus.Rejected:
                lessonLearned.Status      = "Rejected";
                approval.ApproverComments = Comment;
                break;
            }
            dataModel = OAPServiceSystem.GetServiceModel(OAPServiceSystem.OAPDataModelType.LessonLearned);
            dataModel.Update(lessonLearned);
            serviceSystem.Update(approval);

            return(RedirectToAction("Edit", new { Id = Id }));
        }
Example #5
0
        public ActionResult ControlAddReview(ReviewModel reviewModel, string SourceForm, string SourceFormId)
        {
            if (ModelState.IsValid)
            {
                dataModel = OAPServiceSystem.GetServiceModel(OAPServiceSystem.OAPDataModelType.Review);
                BusinessUnitModel businessUnit = ServiceSystem.GetBusinessUnitByRigId(UtilitySystem.Settings.RigId);
                ReviewModel       newReview    = new ReviewModel()
                {
                    RigId              = UtilitySystem.Settings.RigId,
                    Comment            = reviewModel.Comment,
                    ReviewerPassportId = reviewModel.ReviewerPassportId,
                    RequestedBy        = UtilitySystem.CurrentUserId,
                    SourceBU           = businessUnit.Id,
                    SourceForm         = SourceForm,
                    SourceFormId       = SourceFormId.ToString(),
                    DateCreated        = DateTimeOffset.Now
                };
                dataModel.Add(newReview);
                ServiceSystem.AddTask(sourceForm: "Review", sourceFormId: SourceFormId, assigneeUserId: newReview.ReviewerPassportId,
                                      dueDate: reviewModel.DueDate, sourceFormUrl: Request.UrlReferrer.PathAndQuery);
            }
            else
            {
                ViewData["UpdateError"] = true;
            }

            return(Control(SourceForm, SourceFormId));
        }
Example #6
0
        public ActionResult InlineControlAdd(CommentModel rowModel, string SourceForm, string SourceFormId, string QuestionId, string QuestionText)
        {
            if (ModelState.IsValid)
            {
                dataModel = OAPServiceSystem.GetServiceModel(OAPServiceSystem.OAPDataModelType.Comment);
                CommentModel newComment = new CommentModel()
                {
                    SourceForm        = SourceForm,
                    SourceFormId      = SourceFormId,
                    QuestionId        = QuestionId,
                    CommentDate       = DateTimeOffset.Now,
                    CommenterPassport = GetUserPassportId(),
                    QuestionText      = QuestionText,
                    Comment           = rowModel.Comment,
                    Rig = UtilitySystem.Settings.RigId
                };

                newComment = dataModel.Add(newComment);
            }
            else
            {
                ViewData["UpdateError"] = true;
            }
            return(InlineControl(SourceForm, SourceFormId, QuestionId, QuestionText));
        }
Example #7
0
        public ActionResult LessonsLearnedAddOriginatorsPartial(LL_EditOriginatorsGridRowModel rowModel)
        {
            // Add Originator logic
            var lessonLearnedModel = (LessonLearnedModel)Session["LessonLearnedModel"];
            List <LessonLearnedOriginatorModel> originators = lessonLearnedModel.Originators;

            if (ModelState.IsValid)
            {
                LessonLearnedOriginatorModel newOriginator = new LessonLearnedOriginatorModel()
                {
                    LessonId = lessonLearnedModel.Id, PassportId = rowModel.PassportId, RigFacility = rowModel.RigFacility
                };
                var user = ServiceSystem.GetUser(rowModel.PassportId);
                newOriginator.Position = (int)user.Position;
                if (Ensco.Utilities.UtilitySystem.Settings.RigId != 1)
                {
                    newOriginator.RigFacility = Ensco.Utilities.UtilitySystem.Settings.RigId;
                }
                dataModel     = OAPServiceSystem.GetServiceModel(OAPServiceSystem.OAPDataModelType.LessonLearnedOriginator);
                newOriginator = dataModel.Add(newOriginator);
                originators.Add(newOriginator);
            }
            else
            {
                ViewData["UpdateError"] = true;
            }

            return(LessonsLearnedOriginatorsPartial());
            //return PartialView("LessonLearnedOriginatorsPartial", originators);
        }
Example #8
0
        public ActionResult ControlAddRow(CommentModel commentModel, string sourceForm, string sourceFormId)
        {
            ViewBag.SouceForm    = sourceForm;
            ViewBag.SourceFormId = sourceFormId;
            if (ModelState.IsValid)
            {
                dataModel = OAPServiceSystem.GetServiceModel(OAPServiceSystem.OAPDataModelType.Comment);

                string      key         = HttpContext.Session.SessionID + "_UserSessionInfo";
                UserSession userSession = (UserSession)HttpContext.Session[key];

                CommentModel newComment = new CommentModel
                {
                    Comment           = commentModel.Comment,
                    CommentDate       = DateTimeOffset.Now,
                    CommenterPassport = userSession.UserId,
                    Rig          = UtilitySystem.Settings.RigId,
                    SourceForm   = sourceForm,
                    SourceFormId = sourceFormId
                };

                newComment = dataModel.Add(newComment);
            }
            else
            {
                ViewData["UpdateError"] = true;
            }
            return(Control(sourceForm, sourceFormId));
        }
Example #9
0
        public PartialViewResult IndexLessonsAddGridView(LL_IndexGridRowModel rowModel)
        {
            dataModel = OAPServiceSystem.GetServiceModel(OAPServiceSystem.OAPDataModelType.LessonLearned);

            BusinessUnitModel objBU = ServiceSystem.GetBusinessUnitByRigId(UtilitySystem.Settings.RigId);

            if (ModelState.IsValid)
            {
                var newLesson = new LessonLearnedModel()
                {
                    DateStarted       = DateTimeOffset.Now,
                    Title             = rowModel.Title,
                    ImpactLevel       = rowModel.ImpactLevel,
                    Status            = LessonsLearnedStatus.Open.ToString(),
                    SourceForm        = "Lessons Learned",
                    SourceRigFacility = UtilitySystem.Settings.RigId,
                    SourceBU          = objBU.Id,
                    TypeId            = rowModel.TypeId
                };
                dataModel.Add(newLesson);
            }
            else
            {
                ViewData["UpdateError"] = true;
            }
            return(IndexLessonsGridView());
        }
Example #10
0
        public ActionResult Edit([Bind(Include = "Id,Comment")] ReviewModel model)
        {
            ReviewModel review = OAPServiceSystem.GetReview(model.Id);

            review.Comment = model.Comment;
            OAPServiceSystem.UpdateReview(review);
            return(Edit(model.Id));
        }
Example #11
0
        public ActionResult Cancel(int id)
        {
            LessonLearnedModel lessonLearned = OAPServiceSystem.GetLessonLearned(id);

            lessonLearned.Status = "Canceled";
            dataModel            = OAPServiceSystem.GetServiceModel(OAPServiceSystem.OAPDataModelType.LessonLearned);
            dataModel.Update(lessonLearned);
            return(RedirectToAction("Index"));
        }
Example #12
0
        public ActionResult ControlDeleteRow(int Id, string sourceForm, string sourceFormId)
        {
            dataModel = OAPServiceSystem.GetServiceModel(OAPServiceSystem.OAPDataModelType.Comment);
            CommentModel comment = dataModel.GetItem(string.Format("Id={0}", Id), "Id");

            if (comment != null)
            {
                dataModel.Delete(comment);
            }
            return(Control(sourceForm, sourceFormId));
        }
Example #13
0
        public ActionResult ControlSignReview(int Id, string Comment, string returnUrl = null)
        {
            dataModel = OAPServiceSystem.GetServiceModel(OAPServiceSystem.OAPDataModelType.Review);
            ReviewModel review = dataModel.GetItem(string.Format("Id={0}", Id), "Id");

            review.ReviewDate = DateTimeOffset.Now;
            review.Comment    = Comment;
            dataModel.Update(review);

            return(Redirect(returnUrl ?? "Index"));
        }
Example #14
0
        public ActionResult InlineControlDelete(int Id, string SourceForm, string SourceFormId, string QuestionId, string QuestionText)
        {
            dataModel = OAPServiceSystem.GetServiceModel(OAPServiceSystem.OAPDataModelType.Comment);
            CommentModel comment = dataModel.GetItem(string.Format("Id={0}", Id), "Id");

            if (comment != null)
            {
                dataModel.Delete(comment);
            }

            return(InlineControl(SourceForm, SourceFormId, QuestionId, QuestionText));
        }
Example #15
0
        // GET: IRMA/Comments
        public ActionResult GetAllComments()
        {
            dataModel = OAPServiceSystem.GetServiceModel(OAPServiceSystem.OAPDataModelType.Comment);
            IEnumerable <CommentModel> comments = dataModel.GetAllItems().Cast <CommentModel>();

            foreach (CommentModel comment in comments)
            {
                UserModel user = ServiceSystem.GetUser((int)comment.CommenterPassport); // Populates position field
                comment.Position = (int)user.Position;
            }
            return(PartialView("GetAllComments", comments));
        }
Example #16
0
        public ActionResult GetAllReviews()
        {
            dataModel = OAPServiceSystem.GetServiceModel(OAPServiceSystem.OAPDataModelType.Review);
            IEnumerable <ReviewModel> reviews = dataModel.GetAllItems().Cast <ReviewModel>();

            foreach (ReviewModel review in reviews)
            {
                review.Attachments = ServiceSystem.GetAttachments("Review", review.Id.ToString());
            }

            return(PartialView("GetAllReviews", reviews));
        }
Example #17
0
 public ActionResult LessonsLearnedApprovalAddPartial(ApprovalModel rowModel)
 {
     if (ModelState.IsValid)
     {
         var lessonModel = (LessonLearnedModel)Session["LessonLearnedModel"];
         rowModel.RequestInfo = Url.Action("ApprovalProcessApproval");
         OAPServiceSystem.AddApprover(rowModel, lessonModel);
     }
     else
     {
         ViewData["UpdateError"] = true;
     }
     return(LessonsLearnedApprovalPartial());
 }
Example #18
0
        public ActionResult Control(string SourceForm, string SourceFormId)
        {
            ViewBag.SourceForm   = SourceForm;
            ViewBag.SourceFormId = SourceFormId;
            dataModel            = OAPServiceSystem.GetServiceModel(OAPServiceSystem.OAPDataModelType.Review);
            IEnumerable <ReviewModel> reviews = dataModel.GetItems(string.Format("SourceForm=\"{0}\" AND SourceFormId=\"{1}\"", SourceForm, SourceFormId), "Id").Cast <ReviewModel>();

            foreach (ReviewModel review in reviews)
            {
                review.Attachments = ServiceSystem.GetAttachments("Review", review.Id.ToString());
            }

            return(PartialView("Control", reviews));
        }
Example #19
0
        public ActionResult LessonsLearnedDeleteOriginatorsPartial(int Id)
        {
            dataModel = OAPServiceSystem.GetServiceModel(OAPServiceSystem.OAPDataModelType.LessonLearnedOriginator);
            var originator = (LessonLearnedOriginatorModel)dataModel.GetItem(string.Format("Id={0}", Id), "Id");

            if (originator != null)
            {
                dataModel.Delete(originator);
                var lessonLearnedModel = (LessonLearnedModel)Session["LessonLearnedModel"];
                lessonLearnedModel.Originators.RemoveAll(o => o.Id == originator.Id);
            }

            return(LessonsLearnedOriginatorsPartial());
        }
Example #20
0
        public ActionResult InlineControlUpdate(CommentModel rowModel, string SourceForm, string SourceFormId, string QuestionId, string QuestionText)
        {
            dataModel = OAPServiceSystem.GetServiceModel(OAPServiceSystem.OAPDataModelType.Comment);
            CommentModel comment = dataModel.GetItem(string.Format("Id={0}", rowModel.Id), "Id");

            if (comment != null)
            {
                comment.Comment           = rowModel.Comment;
                comment.CommentDate       = DateTimeOffset.Now;
                comment.CommenterPassport = GetUserPassportId();
                dataModel.Update(comment);
            }

            return(InlineControl(SourceForm, SourceFormId, QuestionId, QuestionText));
        }
Example #21
0
        public ActionResult Close(int?id)
        {
            if (!id.HasValue)
            {
                return(RedirectToAction("Index"));
            }

            dataModel = OAPServiceSystem.GetServiceModel(OAPServiceSystem.OAPDataModelType.LessonLearned);
            LessonLearnedModel lessonLearned = OAPServiceSystem.GetLessonLearned(id.Value);

            lessonLearned.Status          = "Closed";
            Session["LessonLearnedModel"] = lessonLearned;
            dataModel.Update(lessonLearned);

            return(RedirectToAction("Index"));
        }
Example #22
0
        public PartialViewResult IndexLessonsGridView()
        {
            dataModel = OAPServiceSystem.GetServiceModel(OAPServiceSystem.OAPDataModelType.LessonLearned);
            var lessonsLearned = dataModel.GetAllItems().Cast <LessonLearnedModel>().ToList();

            dataModel = OAPServiceSystem.GetServiceModel(OAPServiceSystem.OAPDataModelType.LessonLearnedType);
            LessonLearnedViewBag(ViewBag);
            foreach (var lesson in lessonsLearned)
            {
                if (lesson.TypeId != null)
                {
                    lesson.Type = dataModel.GetItem(string.Format("Id={0}", lesson.TypeId), "Id");
                }
            }
            return(PartialView("IndexLessonsGridView", lessonsLearned));
        }
Example #23
0
        public ActionResult Control(string sourceForm, string sourceFormId, bool readOnly = false)
        {
            // This will return records with QuestionId = null
            dataModel = OAPServiceSystem.GetServiceModel(OAPServiceSystem.OAPDataModelType.Comment);
            IEnumerable <CommentModel> comments = dataModel.GetItems(string.Format("SourceForm=\"{0}\" AND SourceFormId=\"{1}\" AND QuestionId=null", sourceForm, sourceFormId), "Id").Cast <CommentModel>();

            foreach (CommentModel comment in comments)
            {
                UserModel user = ServiceSystem.GetUser((int)comment.CommenterPassport); // Populates position field
                comment.Position = (int)user.Position;
            }
            ViewBag.SourceForm   = sourceForm;
            ViewBag.SourceFormId = sourceFormId;
            ViewBag.ReadOnly     = readOnly;

            return(PartialView("Control", comments));
        }
Example #24
0
        public ActionResult Edit(int id)
        {
            LessonLearnedModel lessonLearned = OAPServiceSystem.GetLessonLearned(id);

            Session["LessonLearnedModel"] = lessonLearned;
            ViewBag.LessonStatus          = lessonLearned.Status;

            LessonLearnedViewBag(ViewBag);
            ViewBag.IsEditable   = lessonLearned.IsEditable;
            ViewBag.ImpactLevels = Enum.GetNames(typeof(LessonsLearnedImpact)).ToList();

            if (lessonLearned != null)
            {
                return(View("LessonForm", lessonLearned));
            }
            return(RedirectToAction("Index"));
        }
Example #25
0
        public ActionResult InlineControl(string SourceForm, string SourceFormId, string QuestionId, string QuestionText, bool readOnly = false)
        {
            ViewBag.ReadOnly     = readOnly;
            ViewBag.SourceForm   = SourceForm;
            ViewBag.SourceFormId = SourceFormId;
            ViewBag.QuestionId   = QuestionId;
            ViewBag.QuestionText = QuestionText;

            dataModel = OAPServiceSystem.GetServiceModel(OAPServiceSystem.OAPDataModelType.Comment);
            IEnumerable <CommentModel> comments = dataModel.GetItems(string.Format("SourceFormId=\"{0}\" AND QuestionId=\"{1}\"", SourceFormId, QuestionId), "Id").Cast <CommentModel>();

            foreach (CommentModel comment in comments)
            {
                UserModel user = ServiceSystem.GetUser(comment.CommenterPassport); // Populates position field
                comment.Position = (int)user.Position;
            }
            return(PartialView("InlineControl", comments));
        }
Example #26
0
        public PartialViewResult Control(string SourceForm, int SourceFormId)
        {
            ViewBag.SourceForm   = SourceForm;
            ViewBag.SourceFormId = SourceFormId;

            dataModel = OAPServiceSystem.GetServiceModel(OAPServiceSystem.OAPDataModelType.LessonLearned);
            var lessonsLearned = dataModel.GetItems(string.Format("SourceForm=\"{0}\" AND SourceFormId={1}", SourceForm, SourceFormId), "Id").Cast <LessonLearnedModel>().ToList();

            dataModel = OAPServiceSystem.GetServiceModel(OAPServiceSystem.OAPDataModelType.LessonLearnedType);
            LessonLearnedViewBag(ViewBag);
            foreach (var lesson in lessonsLearned)
            {
                if (lesson.TypeId != null)
                {
                    lesson.Type = dataModel.GetItem(string.Format("Id={0}", lesson.TypeId), "Id");
                }
            }
            return(PartialView("Control", lessonsLearned));
        }
Example #27
0
        public ActionResult SubmitForApproval()
        {
            LessonLearnedModel lessonLearned = (LessonLearnedModel)Session["LessonLearnedModel"];

            if (lessonLearned == null)
            {
                return(RedirectToAction("Index"));
            }
            var approvals         = lessonLearned.Approvals.Where(a => a.Type == (int)ApprovalModel.ApprovalType.LessonsLearnedApproval);
            var approvalDataModel = IrmaServiceSystem.GetServiceModel(IrmaConstants.IrmaPobModels.Approval);

            foreach (var approval in approvals)
            {
                approval.Status = (int)IrmaConstants.ApprovalStatus.PendingApproval;
                approvalDataModel.Update(approval);
            }
            lessonLearned.Status = "Pending Approval";
            dataModel            = OAPServiceSystem.GetServiceModel(OAPServiceSystem.OAPDataModelType.LessonLearned);
            dataModel.Update(lessonLearned);

            return(RedirectToAction("Edit", new { Id = lessonLearned.Id }));
        }
Example #28
0
        public PartialViewResult ControlAddGridRow(LL_IndexGridRowModel rowModel, string SourceForm, int SourceFormId)
        {
            dataModel = OAPServiceSystem.GetServiceModel(OAPServiceSystem.OAPDataModelType.LessonLearned);
            BusinessUnitModel objBU = ServiceSystem.GetBusinessUnitByRigId(UtilitySystem.Settings.RigId);

            if (ModelState.IsValid)
            {
                var newLesson = new LessonLearnedModel()
                {
                    DateStarted       = DateTimeOffset.Now,
                    Title             = rowModel.Title,
                    ImpactLevel       = rowModel.ImpactLevel,
                    SourceRigFacility = UtilitySystem.Settings.RigId,
                    SourceBU          = objBU.Id,
                    TypeId            = rowModel.TypeId,
                    Status            = LessonsLearnedStatus.Open.ToString(),
                    SourceForm        = SourceForm,
                    SourceFormId      = SourceFormId,
                    SourceFormURL     = Request.UrlReferrer.AbsoluteUri
                };
                newLesson = dataModel.Add(newLesson);
                dataModel = OAPServiceSystem.GetServiceModel(OAPServiceSystem.OAPDataModelType.LessonLearnedOriginator);
                LessonLearnedOriginatorModel originator = new LessonLearnedOriginatorModel();
                originator.LessonId = newLesson.Id;
                string      key         = HttpContext.Session.SessionID + "_UserSessionInfo";
                UserSession userSession = (UserSession)HttpContext.Session[key];
                originator.PassportId  = userSession.UserId;
                originator.RigFacility = UtilitySystem.Settings.RigId;
                dataModel.Add(originator);
            }
            else
            {
                ViewBag.UpdateError = string.Join(",", ModelState.Values.SelectMany(e => e.Errors).Select(e => e.ErrorMessage));
            }
            return(Control(SourceForm, SourceFormId));
        }
Example #29
0
        public RedirectToRouteResult Save([ModelBinder(typeof(DevExpressEditorsBinder))] LessonLearnedModel formLessonModel)
        {
            LessonLearnedModel lessonLearned = (LessonLearnedModel)Session["LessonLearnedModel"];
            List <LessonLearnedOriginatorModel> originators = lessonLearned.Originators;

            if (originators.Count == 0)
            {
                return(RedirectToAction("Edit", new { Id = lessonLearned.Id }));
            }

            lessonLearned.TypeId            = formLessonModel.TypeId;
            lessonLearned.Title             = formLessonModel.Title;
            lessonLearned.SourceBU          = formLessonModel.SourceBU;
            lessonLearned.SourceRigFacility = formLessonModel.SourceRigFacility;
            lessonLearned.Topic             = formLessonModel.Topic;
            lessonLearned.ImpactLevel       = formLessonModel.ImpactLevel;
            lessonLearned.eMocId            = formLessonModel.eMocId;
            lessonLearned.Description       = formLessonModel.Description;

            dataModel = OAPServiceSystem.GetServiceModel(OAPServiceSystem.OAPDataModelType.LessonLearned);
            dataModel.Update(lessonLearned);

            return(RedirectToAction("Edit", new { Id = lessonLearned.Id }));
        }
Example #30
0
        public ActionResult Edit(int id)
        {
            ReviewModel review = OAPServiceSystem.GetReview(id);

            return(View(review));
        }