コード例 #1
0
ファイル: EmailTasks.cs プロジェクト: ruacol/profiling2
        public void SendRespondedToEmail(string username, int requestId)
        {
            Request   request = this.requestTasks.Get(requestId);
            AdminUser user    = this.userTasks.GetAdminUser(username);

            if (request != null && user != null)
            {
                ScreeningEntity screeningEntity = user.GetScreeningEntity();

                string subject = "Notification - Response to Screening Request";
                string body    = "This is an automated notification. " + screeningEntity + " has responded to screening request: "
                                 + "<a href='" + APPLICATION_URL + "Screening/Consolidate/Request/" + request.Id.ToString() + "'>"
                                 + request.Headline + "</a>.<br />";

                //foreach (RequestPerson rp in request.Persons.Where(x => !x.Archive))
                //{
                //    body += "\n";
                //    body += "Name: " + rp.Person.Name + "\n";
                //    ScreeningRequestPersonEntity srpe = rp.GetScreeningRequestPersonEntity(screeningEntity.ScreeningEntityName);
                //    if (srpe != null)
                //        body += "Color: " + srpe.ScreeningResult + "\n";
                //}

                this.SendMailMessage(this.userTasks.GetUsersWithRole(AdminRole.ScreeningRequestConsolidator),
                                     this.userTasks.GetAdminUser(username),
                                     subject, body, true);
            }
        }
コード例 #2
0
        public void CreateScreeningRequestPersonEntitiesForRequest(Request request, ScreeningEntity screeningEntity, string username)
        {
            if (request != null && screeningEntity != null)
            {
                ScreeningResult screeningResult = this.GetScreeningResult(ScreeningResult.PENDING);
                foreach (RequestPerson rp in request.Persons.Where(x => !x.Archive))
                {
                    // only create new ScreeningRequestPersonEntity if one doesn't already exist
                    if (rp.GetMostRecentScreeningRequestPersonEntity(screeningEntity.ScreeningEntityName) == null)
                    {
                        // persist new ScreeningRequestPersonEntity for this RequestPerson
                        ScreeningRequestPersonEntity newSrpe = new ScreeningRequestPersonEntity()
                        {
                            RequestPerson   = rp,
                            ScreeningEntity = screeningEntity,
                            ScreeningResult = screeningResult
                        };

                        // copy screening results from last known screening by this screening entity
                        ScreeningRequestPersonEntity lastSrpe = rp.Person.GetLatestScreeningEntityResponse(screeningEntity.ScreeningEntityName);
                        if (lastSrpe != null)
                        {
                            newSrpe.ScreeningResult = lastSrpe.ScreeningResult;
                            newSrpe.Reason          = lastSrpe.Reason;
                            newSrpe.Commentary      = lastSrpe.Commentary;
                        }
                        newSrpe = this.SaveOrUpdateScreeningRequestPersonEntity(newSrpe, username, ScreeningStatus.ADDED);
                    }
                }
            }
        }
        /// <summary>
        /// Ported from Profiling1.
        /// </summary>
        /// <param name="request"></param>
        /// <param name="screeningEntity"></param>
        /// <param name="sortByRank"></param>
        /// <returns></returns>
        public byte[] GetExport(Request request, ScreeningEntity screeningEntity, bool sortByRank)
        {
            //sets the document information such as authors, etc.
            Pdf pdf = SetDocumentInformation();

            //landscape format
            pdf.IsLandscape = true;

            //creates the section that holds document content
            Section section = pdf.Sections.Add();

            //sets the header and footer for document
            section = SetHeaderFooter(request, section);

            //sets the title for document
            section = SetTitle(request, screeningEntity, section);

            //sets the request details
            section = SetRequestDetails(request, section);

            //sets the persons attached to the request
            section = SetPersonsAttached(request, screeningEntity, sortByRank, section);

            //creates the pdf in a byte array
            return(GetByteArray(pdf));
        }
コード例 #4
0
ファイル: LuceneController.cs プロジェクト: ruacol/profiling2
 public ActionResult ScreeningResponseSearch(SearchViewModel vm)
 {
     if (ModelState.IsValid)
     {
         AdminUser user = this.userTasks.GetAdminUser(User.Identity.Name);
         if (user != null)
         {
             ScreeningEntity entity = user.GetScreeningEntity();
             if (entity != null)
             {
                 IList <LuceneSearchResult> results = this.luceneTasks.ScreeningResponseSearch(vm.Term, entity.ScreeningEntityName, 50);
                 ViewData["results"] = results;
                 return(View(vm));
             }
             else
             {
                 ModelState.AddModelError("ScreeningEntity", "User is not a member of any screening entity.");
             }
         }
         else
         {
             ModelState.AddModelError("User", "User does not exist.");
         }
     }
     return(ScreeningResponseSearch());
 }
        /// <summary>
        /// Sets the persons attached
        /// </summary>
        /// <param name="section">Pdf section to which perons attached should be added</param>
        /// <param name="requestId">Id of request</param>
        /// <returns>Pdf section object</returns>
        private Section SetPersonsAttached(Request request, ScreeningEntity screeningEntity, bool sortByRank, Section section)
        {
            Row   row;
            Table attachedPersons = new Table(section);

            attachedPersons.ColumnWidths              = "100 80 60 230 230";
            attachedPersons.Margin.Top                = 18;
            attachedPersons.DefaultCellBorder         = new BorderInfo((int)BorderSide.Bottom, new Color("Black"));
            attachedPersons.DefaultCellPadding.Top    = 9;
            attachedPersons.DefaultCellPadding.Right  = 9;
            attachedPersons.DefaultCellPadding.Bottom = 9;
            attachedPersons.DefaultCellPadding.Left   = 9;

            if (request.Persons.Where(x => !x.Archive).Any())
            {
                row = attachedPersons.Rows.Add();
                row = SetPersonAttachedHeaderRow(row);
                foreach (RequestPerson requestPerson in request.Persons.Where(x => !x.Archive).OrderBy(x => sortByRank ? x.Person.CurrentRankSortOrder : x.Id))
                {
                    row = attachedPersons.Rows.Add();
                    row = SetPersonAttachedRow(screeningEntity, row, requestPerson);
                }
            }

            section.Paragraphs.Add(attachedPersons);
            return(section);
        }
コード例 #6
0
 public virtual void RemoveScreeningEntity(ScreeningEntity se)
 {
     if (this.ScreeningEntities.Contains(se))
     {
         this.ScreeningEntities.Remove(se);
         se.Users.Remove(this);
     }
 }
コード例 #7
0
 public virtual void AddScreeningEntity(ScreeningEntity se)
 {
     if (!this.ScreeningEntities.Contains(se))
     {
         this.ScreeningEntities.Add(se);
         se.Users.Add(this);
     }
 }
コード例 #8
0
        public IList <ScreeningRequestPersonEntity> GetScreeningResponsesByEntity(string screeningEntityName)
        {
            ScreeningEntity se = this.GetScreeningEntity(screeningEntityName);
            IDictionary <string, object> criteria = new Dictionary <string, object>();

            criteria.Add("ScreeningEntity", se);
            criteria.Add("Archive", false);
            return(this.srpeRepository.FindAll(criteria)
                   .Where(x => x.RequestPerson != null && x.RequestPerson.Request != null && x.RequestPerson.Request.ResponseDate(se.ScreeningEntityName).HasValue)
                   .ToList());
        }
コード例 #9
0
        public ActionResult Browse(string code)
        {
            AdminUser       user            = this.userTasks.GetAdminUser(User.Identity.Name);
            ScreeningEntity screeningEntity = user.GetScreeningEntity();

            if (!string.IsNullOrEmpty(code))
            {
                ViewBag.Code = code;
                return(View());
            }
            return(new HttpNotFoundResult());
        }
コード例 #10
0
ファイル: InputsController.cs プロジェクト: ruacol/profiling2
        // The following is a list of all screening responses submitted by JHRO to the ODSRSG as of 7/17/2013 5:05:03 PM.
        public ActionResult All()
        {
            AdminUser       user = this.userTasks.GetAdminUser(User.Identity.Name);
            ScreeningEntity se   = user.GetScreeningEntity();

            if (se == null)
            {
                return(new HttpNotFoundResult());
            }

            ViewBag.ScreeningEntity = se;
            return(View((from srpe in this.screeningTasks.GetScreeningResponsesByEntity(se.ScreeningEntityName) select new ScreeningRequestPersonEntityDataTableView(srpe)).ToList()));
        }
コード例 #11
0
        protected string GetUserScreeningEntityName()
        {
            AdminUser user = this.userTasks.GetAdminUser(User.Identity.Name);

            if (user != null)
            {
                ScreeningEntity entity = user.GetScreeningEntity();
                if (entity != null)
                {
                    return(entity.ScreeningEntityName);
                }
            }
            return(null);
        }
コード例 #12
0
        public ActionResult RequestAction(int id)
        {
            Request request = this.requestTasks.Get(id);

            if (request != null)
            {
                ViewBag.Request           = request;
                ViewBag.ScreeningEntities = ScreeningEntity.GetNames(request.GetCreatedDate());
                ConsolidateViewModel cvm = new ConsolidateViewModel(request, this.screeningTasks.GetScreeningResults(request.GetCreatedDate()));
                return(View(cvm));
            }
            else
            {
                return(new HttpNotFoundResult());
            }
        }
コード例 #13
0
        private Workbook ConstructWorkbook()
        {
            Workbook  workBook  = new Workbook();
            Worksheet workSheet = AddWorkSheet(ref workBook);

            workSheet = AddColumnHeadings(workSheet);
            for (int i = 0; i < this.NominatedRequestPersons.Count; i++)
            {
                RequestPerson rp = this.NominatedRequestPersons[i];
                workSheet.Cells[i + 1, 0].PutValue(rp.Person.Name);
                int j = 0;
                for (j = 0; j < this.ScreeningEntities.Count; j++)
                {
                    ScreeningEntity se = this.ScreeningEntities[j];
                    ScreeningRequestPersonEntity srpe = rp.GetMostRecentScreeningRequestPersonEntity(se.ScreeningEntityName);
                    if (srpe != null)
                    {
                        workSheet.Cells[i + 1, j + 1].PutValue(srpe.ScreeningResult.ToString());
                        workSheet.Cells[i + 1, j + 1].SetStyle(GetCellStyleForResult(srpe.ScreeningResult.ToString()));
                    }
                }
                //dsrsg
                ScreeningRequestPersonRecommendation srpr = rp.GetScreeningRequestPersonRecommendation();
                if (srpr != null)
                {
                    workSheet.Cells[i + 1, j + 1].PutValue(srpr.ScreeningResult.ToString());
                    workSheet.Cells[i + 1, j + 1].SetStyle(GetCellStyleForResult(srpr.ScreeningResult.ToString()));
                }
                //the user's commentary and reason; dsrsg commentary if no screening entity
                if (!string.IsNullOrEmpty(this.UserScreeningEntityName))
                {
                    ScreeningRequestPersonEntity srpe = rp.GetMostRecentScreeningRequestPersonEntity(this.UserScreeningEntityName);
                    if (srpe != null)
                    {
                        workSheet.Cells[i + 1, j + 2].PutValue(srpe.Reason);
                        workSheet.Cells[i + 1, j + 3].PutValue(srpe.Commentary);
                    }
                }
                else
                if (srpr != null)
                {
                    workSheet.Cells[i + 1, j + 3].PutValue(srpr.Commentary);
                }
            }
            workSheet.AutoFitColumns();
            return(workBook);
        }
コード例 #14
0
ファイル: RespondViewModel.cs プロジェクト: ruacol/profiling2
        public RespondViewModel(Request request, IEnumerable <ScreeningResult> srs, ScreeningEntity screeningEntity)
        {
            this.Id             = request.Id;
            this.SubmitResponse = false;
            this.Responses      = new Dictionary <int, ScreeningRequestPersonEntityViewModel>();

            if (screeningEntity != null)
            {
                foreach (RequestPerson rp in request.Persons.Where(x => !x.Archive))
                {
                    ScreeningRequestPersonEntity          srpe = rp.GetMostRecentScreeningRequestPersonEntity(screeningEntity.ScreeningEntityName);
                    ScreeningRequestPersonEntityViewModel vm   = new ScreeningRequestPersonEntityViewModel(srpe);

                    vm.PopulateDropDowns(srs);
                    this.Responses[rp.Id] = vm;
                }
            }
        }
コード例 #15
0
        /// <summary>
        /// Sets the title
        /// </summary>
        /// <param name="section">Pdf section for which to set the title</param>
        /// <returns>Pdf section object</returns>
        protected Section SetTitle(Request request, ScreeningEntity screeningEntity, Section section)
        {
            string s = "Request for Screening #" + request.ReferenceNumber;

            if (screeningEntity != null)
            {
                s += ", Response From " + screeningEntity.ToString();
            }
            Text text = new Text(section, s);

            text.TextInfo.FontSize    = 18;
            text.TextInfo.IsUnderline = true;
            text.TextInfo.Alignment   = AlignmentType.Left;
            text.Margin.Top           = 24;
            text.Margin.Bottom        = 24;
            section.Paragraphs.Add(text);
            return(section);
        }
コード例 #16
0
        // will only allow one ScreeningEntity per user.
        public bool SetScreeningEntity(int screeningEntityId, int userId)
        {
            ScreeningEntity se = this.screeningEntityRepository.Get(screeningEntityId);
            AdminUser       u  = this.userTasks.GetAdminUser(userId);

            if (u != null)
            {
                foreach (ScreeningEntity e in this.screeningEntityRepository.GetAll())
                {
                    u.RemoveScreeningEntity(e);
                }
                if (se != null)
                {
                    u.AddScreeningEntity(se);
                }
                return(true);
            }
            return(false);
        }
コード例 #17
0
        public ActionResult RequestAction(int id)
        {
            Request request = this.requestTasks.Get(id);

            if (request != null)
            {
                ViewBag.Request           = request;
                ViewBag.ScreeningEntities = ScreeningEntity.GetNames(request.GetCreatedDate());
                this.screeningTasks.CreateScreeningRequestPersonFinalDecisionsForRequest(request, User.Identity.Name);  // prepopulate results from recommendations
                FinalizeViewModel cvm = new FinalizeViewModel(request,
                                                              this.screeningTasks.GetScreeningResults(request.GetCreatedDate()),
                                                              this.screeningTasks.GetScreeningSupportStatuses());
                return(View(cvm));
            }
            else
            {
                return(new HttpNotFoundResult());
            }
        }
コード例 #18
0
        public IList <Person> SearchScreeningEntityResponses(string term, int screeningEntityId)
        {
            IList <Person> persons = new List <Person>();

            ScreeningEntity entity = this.GetScreeningEntity(screeningEntityId);

            if (entity != null)
            {
                IList <ScreeningRequestPersonEntity> srpes = this.screeningEntityQueries.SearchScreenings(term, screeningEntityId);
                foreach (ScreeningRequestPersonEntity srpe in srpes)
                {
                    if (srpe.RequestPerson.Person.GetLatestScreeningEntityResponse(entity.ScreeningEntityName) == srpe)
                    {
                        persons.Add(srpe.RequestPerson.Person);
                    }
                }
            }

            return(persons);
        }
コード例 #19
0
        public ScreeningRequestEntityResponse SetEntityResponse(Request request, ScreeningEntity entity)
        {
            IDictionary <string, object> criteria = new Dictionary <string, object>();

            criteria.Add("Request", request);
            criteria.Add("ScreeningEntity", entity);
            ScreeningRequestEntityResponse response = this.srerRepo.FindOne(criteria);  // unique index exists over these two columns

            if (response != null)
            {
                response.Archive = false;
            }
            else
            {
                response                 = new ScreeningRequestEntityResponse();
                response.Request         = request;
                response.ScreeningEntity = entity;
            }
            response.ResponseDateTime = DateTime.Now;
            return(this.srerRepo.SaveOrUpdate(response));
        }
コード例 #20
0
        public RequestPersonViewModel(RequestPerson rp)
        {
            this.Id    = rp.Id;
            this.Notes = rp.Notes;
            if (rp.Request != null)
            {
                this.RequestId   = rp.Request.Id;
                this.RequestName = rp.Request.Headline;
            }

            this.EntityResults = new List <ScreeningResultViewModel>();
            string[] entities = ScreeningEntity.GetNames(rp.Request.GetCreatedDate());
            foreach (string entity in entities)
            {
                ScreeningRequestPersonEntity srpe = rp.GetScreeningRequestPersonEntity(entity);
                if (srpe != null)
                {
                    this.EntityResults.Add(new ScreeningResultViewModel()
                    {
                        Name       = srpe.ScreeningEntity.ToString(),
                        Result     = srpe.ScreeningResult.ToString(),
                        Reason     = srpe.Reason,
                        Commentary = srpe.Commentary,
                        Date       = srpe.MostRecentHistory.DateStatusReached
                    });
                }
                else
                {
                    this.EntityResults.Add(new ScreeningResultViewModel()
                    {
                        Name = entity
                    });
                }
            }

            ScreeningRequestPersonRecommendation srpr = rp.GetScreeningRequestPersonRecommendation();

            if (srpr != null)
            {
                this.RecommendationResult = new ScreeningResultViewModel()
                {
                    Name       = "Recommended",
                    Result     = srpr.ScreeningResult.ToString(),
                    Commentary = srpr.Commentary,
                    Date       = srpr.MostRecentHistory.DateStatusReached
                }
            }
            ;

            ScreeningRequestPersonFinalDecision srpfd = rp.GetScreeningRequestPersonFinalDecision();

            if (srpfd != null)
            {
                this.FinalResult = new ScreeningResultViewModel()
                {
                    Name       = "Final Decision",
                    Result     = srpfd.ScreeningResult.ToString(),
                    Commentary = srpfd.Commentary,
                    Date       = srpfd.MostRecentHistory.DateStatusReached
                };
                this.FinalSupportStatus = srpfd.ScreeningSupportStatus.ToString();
            }
        }
    }
        /// <summary>
        /// Sets a row in the person attached
        /// </summary>
        /// <param name="row">The row that has already been added to the persons attached table</param>
        /// <param name="person">The person whose details should be added to the row</param>
        /// <returns>Pdf row object</returns>
        private Row SetPersonAttachedRow(ScreeningEntity screeningEntity, Row row, RequestPerson requestPerson)
        {
            string   personName;
            Text     text;
            Cell     cell;
            TextInfo textInfo = new TextInfo();

            row.VerticalAlignment = VerticalAlignmentType.Top;
            row.IsBroken          = false;

            //text customization for labels in request details
            textInfo.FontSize           = 12;
            textInfo.IsTrueTypeFontBold = false;
            textInfo.Alignment          = AlignmentType.Center;

            //Name Column
            personName = requestPerson.Person.Name;
            cell       = row.Cells.Add(personName.Trim(), textInfo);

            //Military ID Column
            cell = row.Cells.Add(requestPerson.Person.MilitaryIDNumber, textInfo);

            //Color
            ScreeningRequestPersonEntity srpe = requestPerson.GetMostRecentScreeningRequestPersonEntity(screeningEntity.ScreeningEntityName);
            string color = string.Empty;

            if (srpe != null)
            {
                color = srpe.ScreeningResult.ToString();
            }
            cell = row.Cells.Add();
            text = new Text(color);
            if (!string.IsNullOrEmpty(color))
            {
                //Green
                if (color.Equals(ScreeningResult.GREEN, StringComparison.OrdinalIgnoreCase))
                {
                    text.TextInfo.BackgroundColor = new Color("Green");
                    text.TextInfo.Color           = new Color("White");
                }
                //Yellow
                else if (color.Equals(ScreeningResult.YELLOW, StringComparison.OrdinalIgnoreCase))
                {
                    text.TextInfo.BackgroundColor = new Color("Yellow");
                    text.TextInfo.Color           = new Color("Black");
                }
                //Red
                else if (color.Equals(ScreeningResult.RED, StringComparison.OrdinalIgnoreCase))
                {
                    text.TextInfo.BackgroundColor = new Color("Red");
                    text.TextInfo.Color           = new Color("White");
                }
            }
            text.TextInfo.Alignment   = AlignmentType.Center;
            text.TextInfo.LineSpacing = 6;
            cell.Paragraphs.Add(text);

            //Reason
            cell = row.Cells.Add(srpe != null ? srpe.Reason : string.Empty, textInfo);

            //Commentary
            cell = row.Cells.Add(srpe != null ? srpe.Commentary : string.Empty, textInfo);

            return(row);
        }