Example #1
0
        public void UpdateAttachment(int?id)
        {
            IServiceDataModel dataModel = ServiceSystem.GetServiceModel(EnscoConstants.EntityModel.Attachment);

            if (id != 0)
            {
                string source = this.Session["Source"] == null ? "" : this.Session["Source"].ToString();
                IEnumerable <AttachmentModel> attachments = ServiceSystem.GetAttachments(source, "0");
                if (attachments != null)
                {
                    foreach (AttachmentModel attachment in attachments)
                    {
                        attachment.SourceFormId = id?.ToString();
                        attachment.SourceForm   = "CapaPlan";
                        dataModel.Update(attachment);
                    }
                }
            }
            else
            {
                string[] arr = this.Request.Form.GetValues("Removed");
                if (arr != null)
                {
                    foreach (string path in arr)
                    {
                        AttachmentModel attachment = dataModel.GetItem(string.Format("FilePath =\"{0}\"", HttpUtility.UrlDecode(path)), "Id");
                        if (attachment != null)
                        {
                            dataModel.Delete(attachment);
                        }
                    }
                }
            }
        }
Example #2
0
        public ActionResult UploadPartial(int id, string source, bool readOnly = false)
        {
            AttachmentSource att = new AttachmentSource();

            att.SourceForm        = source;
            att.SourceFormId      = id;
            att.Attachments       = ServiceSystem.GetAttachments(source, id.ToString());
            this.ViewBag.readOnly = readOnly;
            return(PartialView("UploadPartial", att));
        }
Example #3
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 #4
0
        public static ReviewModel GetReview(int id)
        {
            IOAPServiceDataModel dataModel = GetServiceModel(OAPDataModelType.Review);
            ReviewModel          review    = dataModel.GetItem(string.Format("Id={0}", id), "Id");

            var user = ServiceSystem.GetUser(review.ReviewerPassportId);

            review.Reviewer = user.DisplayName;

            review.Attachments = ServiceSystem.GetAttachments("Review", review.Id.ToString());
            return(review);
        }
Example #5
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 #6
0
        public ActionResult Control(int oapChecklistId, int oapChecklistQuestionId, Guid rigOapChecklistId, bool showLastNoAnswerControl = false)
        {
            var oapChecklistClient = GetClient <OapChecklistClient>();
            RigOapChecklistQuestionNoAnswerComment noAnswer = null;

            if (showLastNoAnswerControl)
            {
                noAnswer = oapChecklistClient.GetAllQuestionNoAnswersAsync(oapChecklistId, oapChecklistQuestionId).Result?.Result.Data?.LastOrDefault();
            }
            else
            {
                noAnswer = oapChecklistClient.GetFirstQuestionOpenNoAnswersAsync(oapChecklistId, oapChecklistQuestionId).Result?.Result?.Data;
            }

            // If there is no existing no answer, create a new one
            if (noAnswer == null)
            {
                int userId = UtilitySystem.CurrentUserId;
                noAnswer = createNoAnswer(oapChecklistId, oapChecklistQuestionId, rigOapChecklistId, userId);
            }

            // Mapping to view model
            var config    = new MapperConfiguration(cfg => cfg.CreateMap <RigOapChecklistQuestionNoAnswerComment, NoAnswerControlViewModel>());
            var mapper    = config.CreateMapper();
            var viewModel = mapper.Map <NoAnswerControlViewModel>(noAnswer);

            viewModel.StartUserId = noAnswer.StartCommentBy;
            viewModel.EndUserId   = noAnswer.EndCommentBy;
            viewModel.Attachments = ServiceSystem.GetAttachments("Oap - No Answer Control", viewModel.Id.ToString());

            // Replace user ids by user names
            if (viewModel.StartCommentBy != null)
            {
                viewModel.StartCommentBy = ServiceSystem.GetUser(int.Parse(viewModel.StartCommentBy))?.DisplayName;
            }

            if (viewModel.EndCommentBy != null)
            {
                viewModel.EndCommentBy = ServiceSystem.GetUser(int.Parse(viewModel.EndCommentBy))?.DisplayName;
            }

            return(PartialView("NoAnswerCommentPartial", viewModel));
        }
Example #7
0
        public static LessonLearnedModel GetLessonLearned(int id)
        {
            var dataModel = GetServiceModel(OAPDataModelType.LessonLearned);
            LessonLearnedModel lessonLearned = dataModel.GetItem(string.Format("Id={0}", id), "Id");

            IIrmaServiceDataModel approvalDataModel = IrmaServiceSystem.GetServiceModel(IrmaConstants.IrmaPobModels.Approval);

            var approvals = approvalDataModel.GetItems(
                string.Format("RequestItemId={0}", lessonLearned.Id), "Id").Cast <ApprovalModel>().ToList();

            foreach (var approver in approvals)
            {
                var user = ServiceSystem.GetUser((int)approver.Approver);
                approver.Position = (int)user.Position;
                approver.Initialize();
            }
            lessonLearned.Approvals = approvals;

            dataModel = OAPServiceSystem.GetServiceModel(OAPDataModelType.LessonLearnedType);
            LessonLearnedType lessonType = (LessonLearnedType)dataModel.GetItem(string.Format("Id={0}", lessonLearned.TypeId), "Id");

            lessonLearned.Type = lessonType;

            lessonLearned.Attachments = ServiceSystem.GetAttachments("Lessons Learned", lessonLearned.Id.ToString());

            dataModel = GetServiceModel(OAPDataModelType.LessonLearnedOriginator);
            var originators = dataModel.GetItems(string.Format("LessonId={0}", lessonLearned.Id), "Id").Cast <LessonLearnedOriginatorModel>().ToList();

            foreach (var originator in originators)
            {
                var user = ServiceSystem.GetUser(originator.PassportId);
                originator.Position = (int)user.Position;
            }
            lessonLearned.Originators = originators;

            return(lessonLearned);
        }