コード例 #1
0
        public void TestAttachmentRetrieval()
        {
            var sut = new PatService();

            byte[] fileData = sut.RetrieveAttachment(113);
            System.IO.File.WriteAllBytes("c:\\UserData\\Temp\\TommyHawks.clf", fileData);
        }
コード例 #2
0
        /// <summary>
        /// To reviews questionnaire.
        /// </summary>
        /// <param name="id">The upload Id.</param>
        /// <param name="projectId">The project Id.</param>
        /// <returns></returns>
        public ActionResult ReviewQuestionnaire(int id, int projectId)
        {
            if (!CanEdit)
            {
                return(RedirectToNoAccessAction());
            }

            var uploadId = id;

            ViewBag.UploadId    = uploadId;
            ViewBag.UploadName  = AppHelper.GetSessionUploadName(Session);
            ViewBag.ProjectId   = projectId;
            ViewBag.ProjectName = AppHelper.GetSessionProjectName(Session);

            if (ViewBag.UploadId < 1 || ViewBag.ProjectId < 1)
            {
                return(RedirectToProjectList());
            }

            // find the extra colums of the questionnare based on the upload Id
            var viewModel = PatService.GetQuestionAnswersByUploadId(uploadId);

            if (viewModel == null || viewModel.Count < 1)
            {
                TempData[CommonConstants.FlashMessageTypeWarning] = string.Format(@"Extra columns of Questionnaire with Upload Id: {0} not found, Please try again later.", uploadId);
                return(RedirectToPreviousAction());
            }

            // get the extra columns header
            ViewBag.ExtraColumnHeaders = viewModel.Select(qa => new Column(qa.QuestionCode).SetLabel(qa.QuestionText)).ToList();

            return(View("List"));
        }
コード例 #3
0
        /// <summary>
        /// Display the Review Questions and Answers screen
        /// </summary>
        /// <param name="id">The review Id.</param>
        /// <returns></returns>
        public ActionResult Edit(int id)
        {
            var reviewID = id;

            // find the detail Questionnare = the header data
            var viewModel = PatService.GetReviewQuestionnaire(reviewID);

            if (viewModel == null)
            {
                TempData[CommonConstants.FlashMessageTypeWarning] = string.Format(@"Questionnaire with Review Id: {0} not found, Please try again later.", reviewID);
                return(RedirectToPreviousAction());
            }

            // double check DR01039408
            var project = PatService.GetProject(viewModel.ProjectID);

            if (project != null && !project.IsContractMonitoringOrContractSiteVisit())
            {
                // that's fine
            }
            else
            {
                return(RedirectToInvalidRequest());
            }

            return(View(viewModel));
        }
コード例 #4
0
        public void TestProjectGetAll()
        {
            var sut         = new PatService();
            var projectList = sut.GetProjects();

            Assert.IsTrue(projectList.Count > 0);
        }
コード例 #5
0
        public void TestProjectDelete()
        {
            var sut     = new PatService();
            var success = sut.DeleteProject(23, "UnitTest");

            Assert.IsTrue(success);
        }
コード例 #6
0
        public void TestUserSettingsGetAll()
        {
            var sut     = new PatService();
            var results = sut.GetSettingsFor("SC0779");

            Assert.IsTrue(results.Count > 0);
        }
コード例 #7
0
        /// <summary>
        /// To load the bulletin and return it as a JSON data
        /// </summary>
        /// <param name="gridSettings">The grid settings.</param>
        /// <param name="bulletinType">Type of the bulletin.e.g. STD or FAQ</param>
        /// <returns></returns>
        public ActionResult GridDataBulletin(GridSettings gridSettings,
                                             string bulletinType = DataConstants.StandardBulletinType)
        {
            var bulletinList  = PatService.GetBulletins(gridSettings, bulletinType, CanEdit);
            var totalBulletin = PatService.CountBulletins(gridSettings, bulletinType, CanEdit);

            var jsonData = new
            {
                total   = AppHelper.PagesInTotal(totalBulletin, gridSettings.PageSize),
                page    = gridSettings.PageIndex,
                records = totalBulletin,
                rows    = (
                    from e in bulletinList.AsEnumerable()
                    select new
                {
                    id = e.BulletinId,
                    cell = new List <string>
                    {
                        AppHelper.FormatInteger(e.BulletinId),
                        AppHelper.ShortDate(e.EndDate),
                        BulletinViewLink(e)
                    }
                }
                    ).ToArray()
            };

            return(Json(jsonData, JsonRequestBehavior.AllowGet));
        }
コード例 #8
0
        public ActionResult AddMore()
        {
            var msg = String.Empty;

            var projectId    = AppHelper.GetSessionProjectId(Session);
            var loggedInUser = new PatUser(Request.LogonUserIdentity);

            if (HttpContext.Session != null)
            {
                var sessionKey = HttpContext.Session.SessionID;

                if (Request.Form["ids[]"] == null)
                {
                    //  User has deselected all of the Claims
                    var emptyList = new List <int>();
                    Session["ids"] = emptyList.ToArray();
                    PatService.SaveSampleSelections(projectId, sessionKey, emptyList, loggedInUser.LoginName);
                }
                else
                {
                    var intArr = Array.ConvertAll(Request.Form["ids[]"].Split(','), Convert.ToInt32);
                    Session["ids"] = intArr;
                    PatService.SaveSampleSelections(projectId, sessionKey, intArr.ToList(), loggedInUser.LoginName);
                }
            }
            return(Json(new { success = true, message = msg }, JsonRequestBehavior.AllowGet));
        }
コード例 #9
0
        public void TestGetSessions()
        {
            var sut  = new PatService();
            var list = sut.GetDistinctSessionKeys();

            Assert.IsTrue(list.Length > 0);
        }
コード例 #10
0
        public void TestGetProjectContractSelections()
        {
            var sut       = new PatService();
            var contracts = sut.GetProjectContractSelections(13);

            Assert.AreEqual("DES,HLS,JSA", contracts);
        }
コード例 #11
0
        private Grid GenerateSampleGrid(string sessionKey)
        {
            var totRecs = PatService.GetSample(sessionKey).Count;
            var g       = new Grid("sample");

            g.AddColumn(new Column("rowNumber").SetLabel("#").SetWidth(50).SetFixedWidth(true).SetAlign(Align.Right).SetSortable(false));
            g.AddColumn(new Column("ClaimId").SetLabel(CommonConstants.ReviewColumnClaimId).SetWidth(70).SetFixedWidth(true).SetSortable(false));
            g.AddColumn(new Column("JobseekerId").SetLabel(CommonConstants.ReviewColumnJobseekerId).SetWidth(70).SetFixedWidth(true).SetAlign(Align.Center).SetSortable(false));
            g.AddColumn(new Column("Amount").SetLabel(CommonConstants.ReviewColumnClaimAmount).SetWidth(60).SetAlign(Align.Right).SetFixedWidth(true).SetSortable(false));
            g.AddColumn(new Column("ManualSpecialClaimFlag").SetLabel(CommonConstants.ReviewColumnManualSpecialClaim).SetWidth(80).SetFixedWidth(true).SetAlign(Align.Center).SetSortable(false));
            g.AddColumn(new Column("AutoSpecialClaimFlag").SetLabel(CommonConstants.ReviewColumnAutoSpecialClaim).SetWidth(80).SetFixedWidth(true).SetAlign(Align.Center).SetSortable(false));
            g.AddColumn(new Column("ClaimStatusDesc").SetLabel("Claim Status").SetWidth(80).SetFixedWidth(true).SetAlign(Align.Center).SetSortable(false));
#if DEBUG
            //g.AddColumn( new Column( "ClaimType" ).SetLabel( "Type" ).SetWidth( 70 ).SetFixedWidth( true ).SetAlign( Align.Center ) );
            //g.AddColumn( new Column( "CreationDate" ).SetLabel( "Date" ).SetWidth( 60 ).SetFixedWidth( true ).SetAlign( Align.Right ) );

            //g.AddColumn( new Column( "OrgCode" ).SetLabel( "OrgCode" ).SetWidth( 70 ).SetFixedWidth( true ).SetAlign( Align.Center ) );
            //g.AddColumn( new Column( "OrgDesc" ).SetLabel( "Org" ).SetWidth( 150 ).SetFixedWidth( true ) );
            //g.AddColumn( new Column( "EsaCode" ).SetLabel( "EsaCode" ).SetWidth( 70 ).SetFixedWidth( true ).SetAlign( Align.Center ) );
            //g.AddColumn( new Column( "SiteCode" ).SetLabel( "SiteCode" ).SetWidth( 70 ).SetFixedWidth( true ).SetAlign( Align.Center ) );
            //g.AddColumn( new Column( "SiteDesc" ).SetLabel( "Site" ).SetWidth( 210 ).SetFixedWidth( true ) );
#endif
            g.SetHeight(CommonConstants.GridStandardHeight);
            g.SetScroll(true);
            //g.SetAutoWidth( true ); //  will force the grid to fit the width of the parent element
            g.SetWidth(CommonConstants.GridStandardWidth);
            g.SetMultiSelect(true);
            g.SetUrl(VirtualPathUtility.ToAbsolute("~/Sample/GridDataSample/"));
            g.SetRowNum(totRecs);               //  Sets the number of rows displayed initially
            g.OnSelectAll("pat.sampleClaimList_RowSelected()");
            g.OnSelectRow("pat.sampleClaimList_RowSelected()");
            g.OnLoadComplete("pat.sampleClaimList_LoadEvent();");
            return(g);
        }
コード例 #12
0
        public void TestProjectContractGetAll()
        {
            var sut  = new PatService();
            var list = sut.GetProjectContracts();

            Assert.IsTrue(list.Any());
        }
コード例 #13
0
        public void TestSampleNameIsUsed()
        {
            var sut    = new PatService();
            var isUsed = sut.SampleNameIsUsed("Upload 378 - ORSR - 4EAM - FQ40", 17);

            Assert.IsTrue(isUsed);
        }
コード例 #14
0
        public void TestUploadCountByProjectId()
        {
            var sut      = new PatService();
            var nUploads = sut.CountUploads(13);

            Assert.IsTrue(nUploads > 0);
        }
コード例 #15
0
        /// <summary>
        /// Only Admin user can have access to delete
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        private ActionResult Delete(int id)
        {
            if (!CanEdit)
            {
                return(RedirectToNoAccessAction());
            }

            // check if bulletin still exists
            var model = PatService.GetBulletin(id);

            if (model != null)
            {
                PatService.DeleteBulletin(id);

                var activity = string.Format(@"The Bulletin / FAQ has been successfully deleted: {0}", model.BulletinTitle);
                PatService.SaveActivity(activity, User.Identity.Name.RemoveDomain());

                TempData[CommonConstants.FlashMessageTypeInfo] = activity;
            }
            else
            {
                TempData[CommonConstants.FlashMessageTypeWarning] = string.Format(@"The Bulletin / FAQ record with Id: {0} is not found. Please try again.", id);
            }

            return(RedirectToAction("Index", "Home"));
        }
コード例 #16
0
        public void TestReviewCount()
        {
            var sut         = new PatService();
            var reviewCount = sut.CountReviews(13);

            Assert.AreEqual(8, reviewCount);
        }
コード例 #17
0
        public void TestUserRecentActivity()
        {
            var sut          = new PatService();
            var activityList = sut.GetActivities(string.Empty, DateTime.Now.Subtract(new TimeSpan(4, 0, 0, 0)), DateTime.Now);

            Assert.IsTrue(activityList.Count > 0);
        }
コード例 #18
0
        public void TestGetAllReviewsForProjectIdPaged()
        {
            var sut  = new PatService();
            var list = sut.GetProjectReviews(17, AppHelper.DefaultGridSettings());

            Assert.IsTrue(list.Any());
        }
コード例 #19
0
        private Grid GenerateActivityGrid()
        {
            DateTime to;
            DateTime @from;
            var      userId = GetQueryParas(out to, out @from);

            var totActivities = PatService.GetActivities(userId, from, to).Count;

            var g = new Grid("activity");

            g.AddColumn(new Column("rowNo").SetLabel("#").SetWidth(60).SetAlign(Align.Right));
            g.AddColumn(new Column("ActivityId").SetLabel("Activity Id").SetWidth(60).SetAlign(Align.Center));
            g.AddColumn(new Column("UserId").SetLabel("UserId").SetWidth(60).SetAlign(Align.Center));
            g.AddColumn(new Column("Activity").SetLabel("Activity").SetWidth(200));

            g.AddColumn(new Column("CreatedOn").SetLabel("Date").SetWidth(80));
            g.SetUrl(VirtualPathUtility.ToAbsolute("~/Home/GridDataActivity"));

            g.SetHeight(CommonConstants.GridStandardHeight); //  set this tall enough and you wont see the scroll bars
            g.SetWidth(CommonConstants.GridStandardWidth);
            g.SetAutoWidth(true);                            //  will force the grid to fit the width of the parent element
            g.SetRowNum(totActivities);                      //  Sets the number of rows displayed initially
            g.SetViewRecords(true);                          //  isplays the total number of rows in the dataset
            return(g);
        }
コード例 #20
0
        private ActionResult Save(ProjectAttachment viewModel)
        {
            if (ModelState.IsValid)
            {
                // remove the path only get the file name
                viewModel.Url = Path.GetFileName(viewModel.Url);

                // save the attachment only applicable for uploading a new file (attachment is not ammendable) !!!
                byte[] attachmentInBytes = null;
                if (viewModel.Attachment != null && viewModel.Attachment.ContentLength > 0 && viewModel.Attachment.InputStream != null)
                {
                    attachmentInBytes = viewModel.Attachment.InputStream.ToByteArray();

                    // overwrite the url with the file name only (exclude the path)
                    viewModel.Url = Path.GetFileName(viewModel.Attachment.FileName);
                }

                viewModel.CreatedBy = User.Identity.Name.RemoveDomain();
                viewModel.UpdatedBy = User.Identity.Name.RemoveDomain();
                PatService.SaveAttachment(viewModel, attachmentInBytes);
                TempData[CommonConstants.FlashMessageTypeInfo] = string.Format(@"Attachment uploaded/ saved successfully: {0} - {1}.", viewModel.Id, viewModel.DocumentName);
                return(RedirectToProjectDetailsPageTab(viewModel.ProjectId, CommonConstants.ProjectTab_Documents));
            }
            return(View("Edit", viewModel));
        }
コード例 #21
0
        public void TestUniqueProjectNameOnExistingProject()
        {
            var sut    = new PatService();
            var result = sut.IsProjectNameUsed("Steves unit test project", 0);

            Assert.IsTrue(result);
        }
コード例 #22
0
        /// <summary>
        /// Downloads the specified attachment.
        /// </summary>
        /// <param name="id">The identifier.</param>
        /// <returns></returns>
        public ActionResult Download(int id)
        {
            // check if attachment still exists
            var model = PatService.GetAttachment(id);

            if (model != null)
            {
                var attachmentByte = PatService.RetrieveAttachment(id);
                if (attachmentByte != null)
                {
                    // set the content type based on the file name extension
                    var contentType = string.Format("*/{0}", Path.GetExtension(model.Url));

                    //dehydrate the binary into a file and then stream it to the client
                    return(File(attachmentByte, contentType, model.Url));
                }
                // set default to error
                TempData[CommonConstants.FlashMessageTypeWarning] = string.Format(@"Attachment: {0} is having a null byte. Please try again.", id);
            }
            else
            {
                // set default to error
                TempData[CommonConstants.FlashMessageTypeWarning] = string.Format(@"Attachment: {0} is not found. Please try again.", id);
            }

            var projectId = AppHelper.GetSessionProjectId(Session);

            return(RedirectToProjectDetailsPageTab(projectId, CommonConstants.ProjectTab_Documents));
        }
コード例 #23
0
        public void TestCountProjectsByUploadBoundaryDateRange()
        {
            var sut   = new PatService();
            var count = sut.CountProjects(AppHelper.DefaultGridSettings(), new DateTime(2013, 9, 27), new DateTime(2013, 9, 27));

            Assert.IsTrue(count == 1);
        }
コード例 #24
0
        public static bool DoJob(string taskName, string how)
        {
            var activityRepository = new UserActivityRepository <UserActivity>();
            var patService         = new PatService();
            var control            = patService.GetControlFile();

            StartJob(taskName, how, activityRepository);

            //  Get rid of any unused samples
            SampleCleanup(patService);

            //  Refresh the Compliance indicators for PAM
            UpdateComplianceIndicators(patService, how, control);

            //  Get outcomes from Staton's spreadsheet
            BatchUpdateReviewOutcomes(patService, how, control);

            HealthCheck(patService, control.LastBatchRun, how);

            EndJob(taskName, activityRepository);

            control.LastBatchRun = DateTime.Now;
            control.UpdatedBy    = BatchUser;
            patService.UpdateControl(control);

            return(true);
        }
コード例 #25
0
        public void TestUniqueProjectNameOnMissingProject()
        {
            var sut    = new PatService();
            var result = sut.IsProjectNameUsed("Steves Project", 0);

            Assert.IsFalse(result);
        }
コード例 #26
0
        public ActionResult Create(Bulletin model)
        {
            if (!CanEdit)
            {
                return(RedirectToNoAccessAction());
            }

            if (ModelState.IsValid)
            {
                if (!string.IsNullOrWhiteSpace(model.ProjectField))
                {
                    // check if project is valid
                    var project = PatService.GetProject(model.ProjectId);
                    if (project == null)
                    {
                        AddErrorMessage("ProjectField", string.Format("Project Id: {0} not found. Please use a valid project", model.ProjectId));
                        return(View(model));
                    }
                }

                model.CreatedBy = User.Identity.Name.RemoveDomain();
                var newID = PatService.CreateBulletin(model);
                if (newID > 0)
                {
                    // DR01039391; The Bulletin/FAQ has been successfully submitted.
                    TempData[CommonConstants.FlashMessageTypeInfo] = string.Format(@"The Bulletin/ FAQ has been successfully submitted: {0}", model.BulletinTitle);
                    return(RedirectToAction("Index", "Home", new { bulletinType = model.BulletinType }));
                }
                TempData[CommonConstants.FlashMessageTypeError] = string.Format(@"The Bulletin/ FAQ submission was failed: {0}. Please try again.", model.BulletinTitle);
            }

            return(View(model));
        }
コード例 #27
0
        /// <summary>
        /// to get Questionnaires data as JSON
        /// </summary>
        /// <param name="gridSettings">The grid settings.</param>
        /// <param name="id">The upload Id.</param>
        /// <returns></returns>
        public ActionResult QuestionnaireGetData(MvcJqGrid.GridSettings gridSettings, int id)
        {
            try
            {
                var data         = PatService.GetReviewQuestionnaireData(gridSettings, id);
                var totalRecords = PatService.CountReviewQuestionnairesByUploadId(id);

                var jsonData = new
                {
                    total   = AppHelper.PagesInTotal(totalRecords, gridSettings.PageSize),
                    page    = gridSettings.PageIndex,
                    records = totalRecords,
                    rows    = (
                        from e in data.AsEnumerable()
                        select new
                    {
                        id = 1,
                        cell = SetQuestionnaireColumns(e)
                    }
                        ).ToArray()
                };

                return(Json(jsonData, JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                Elmah.ErrorLog.GetDefault(null).Log(new Elmah.Error(ex));
                throw;
            }
        }
コード例 #28
0
        /// <summary>
        /// To display the Bulletin View screen, everyone can have access to this screen
        /// </summary>
        /// <param name="id">Bulletin Id</param>
        /// <returns></returns>
        public ActionResult View(int id)
        {
            var model = PatService.GetBulletin(id);

            if (model != null)
            {
                // get the bulletin type description from ADW
                ViewBag.BulletinTypeDescription = PatService.GetBulletinTypeDescription(model.BulletinType);

                // get the project description
                if (model.ProjectId > 0)
                {
                    var project = PatService.GetProject(model.ProjectId);
                    if (project != null)
                    {
                        model.ProjectField = string.Format("{0} - {1}", project.ProjectId, project.ProjectName);
                    }
                }
            }
            else
            {
                AddErrorMessage(string.Format(@"The Bulletin/ FAQ record with Id: {0} is not found. Please try again.", id));
            }
            ViewBag.CanEdit = CanEdit;
            return(View(model));
        }
コード例 #29
0
        private ActionResult SaveChanges(List <CheckList> viewModels)
        {
            TempData[CommonConstants.FlashMessageTypeInfo] = string.Format(@"CheckList(s): 0 record saved");

            if (viewModels.Any())
            {
                foreach (var viewModel in viewModels)
                {
                    viewModel.CreatedBy = User.Identity.Name.RemoveDomain();
                    viewModel.CreatedOn = DateTime.Now;
                    viewModel.UpdatedBy = User.Identity.Name.RemoveDomain();
                    viewModel.UpdatedOn = DateTime.Now;

                    PatService.SaveCheckList(viewModel);
                }

                var reviewIds = string.Join(", ", viewModels.Select(c => c.ReviewID));
                TempData[CommonConstants.FlashMessageTypeInfo] = string.Format(@"CheckList(s): {0} saved successfully", reviewIds);
            }

            // clear the session
            AppHelper.ClearSessionCheckLists(Session);

            // must exit to the caller otherwise the session will become dirty again.
            return(RedirectToPreviousAction());
        }
コード例 #30
0
        private string GenerateReviewDetails(Review review)
        {
            var label = new[] {
                "Review ID",
                "Org Code",
                "Org Name",
                "ESA Code",
                "ESA Name",
                "Site Code",
                "Site Name",
                "State Code",
                "Job Seeker ID",
                "Job Seeker Given Name",
                "Job Seeker Surname",
                "Claim ID",
                "Claim Type",
                "Claim Description",
                "Claim Amount",
                "Claim Creation Date",
                "Managed By",
                "Contract Type",
                "Contract Type Description",
                "Auto Special Claim Flag",
                "Manual Special Claim Flag",
                "Activity ID",
                "Review Status"
            };

            var data = new[] {
                review.ReviewId.ToString(CultureInfo.InvariantCulture),
                review.OrgCode,
                PatService.GetOrgName(review.OrgCode),
                review.ESACode,
                PatService.GetEsaDescription(review.ESACode),
                review.SiteCode,
                PatService.GetSiteDescription(review.SiteCode),
                review.StateCode,
                review.JobseekerId.ToString(CultureInfo.InvariantCulture),
                review.JobSeekerGivenName,
                review.JobSeekerSurname,
                review.ClaimId.ToString(CultureInfo.InvariantCulture),
                review.ClaimType,
                PatService.GetClaimTypeDescription(review.ClaimType),
                AppHelper.NullableDollarAmount(review.ClaimAmount),
                AppHelper.ShortDate(review.ClaimCreationDate),
                review.ManagedBy,
                review.ContractType,
                PatService.GetContractTypeDescription(review.ContractType),
                AppHelper.FlagOut(review.AutoSpecialClaim),
                AppHelper.FlagOut(review.ManualSpecialClaim),
                review.ActivityId.ToString(CultureInfo.InvariantCulture),
                review.Status()
            };

            var html = AppHelper.TableFromArray(label, data, "Review Details", showEmpty: true);

            AppHelper.SetSessionReviewDetails(Session, html);
            return(html);
        }