예제 #1
0
        public IEnumerable <OffenderExit> GetAllOffenderExitsForOffender(Offender offender)
        {
            var offenderExitRecords            = RepoHelper.GetRecords(_filepath);
            var offenderExitRecordsForOffender = offenderExitRecords.Where(r => exitMatchesOffender(r, offender));

            return(offenderExitRecordsForOffender.Select(constructOffenderExitEntity));
        }
        private string GetInsertValues(Offender offender)
        {
            StringBuilder sb = new StringBuilder();

            sb.AppendFormat("'{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}','{16}','{17}','{18}','{19}','{20}'",
                            offender.Remark,
                            offender.LabID,
                            offender.Name,
                            offender.Sex,
                            offender.Nation,
                            offender.BirthDay == ""?null:Convert.ToDateTime(offender.BirthDay).ToString(),
                            "",//offender.Nation,
                            offender.HomeAddr,
                            offender.LiveAddr,
                            offender.CardID,
                            offender.CaseName,
                            "",//offender.CaseNature,
                            offender.CompanyAreaID,
                            offender.SenderAddr,
                            offender.Sender,
                            offender.Tel,
                            null,//DBNull.Value,//offender.SendTime,
                            Guid.NewGuid().ToString().Replace("-", ""),
                            Guid.NewGuid().ToString().Replace("-", ""),
                            "123456",//INIT_SERVER_NO
                            Guid.NewGuid().ToString().Replace("-", "")
                            );
            return(sb.ToString());
        }
        public async Task <IActionResult> Edit(long id, [Bind("OffenderId,OffenderName,OffenderSummary")] Offender offender)
        {
            if (id != offender.OffenderId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(offender);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!OffenderExists(offender.OffenderId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(offender));
        }
 public OffenderNewLocationWorkflow(BloodhoundContext dbContext, long offenderId)
 {
     this.dbContext    = dbContext ?? throw new ArgumentNullException(nameof(offenderId));
     this.offender     = dbContext.Offenders.Find(offenderId) ?? throw new EntityNotFoundException(nameof(Offender), offenderId);
     this.lastLocation = dbContext.OffenderLocations.Where(x => x.OffenderId == this.offender.OffenderId).Take(1).OrderByDescending(x => x.LocationTime).FirstOrDefault();
     this.geoFences    = dbContext.OffenderGeoFences.Where(x => x.OffenderId == this.offender.OffenderId).ToList();
 }
예제 #5
0
        private Offender constructOffenderEntity(string[] dataFields)
        {
            var offender = new Offender
            {
                DOCNumber           = Convert.ToInt32(dataFields[0]),
                LastName            = dataFields[1],
                FirstName           = dataFields[2],
                MiddleInitial       = dataFields[3],
                Suffix              = dataFields[4],
                Race                = dataFields[5],
                Gender              = dataFields[6],
                HairColor           = dataFields[7],
                EyeColor            = dataFields[8],
                Height              = dataFields[9],
                Weight              = dataFields[10],
                DateOfBirthString   = dataFields[11],
                ReceptionDateString = dataFields[12],
                CurrentFacility     = dataFields.Length == 15
                    ? dataFields[13]
                    : string.Join("; ", dataFields[13], dataFields[14]),
                Status = dataFields.Length == 15
                    ? dataFields[14]
                    : dataFields[15]
            };


            DateTime.TryParse(offender.DateOfBirthString, out DateTime dob);
            offender.DateOfBirth = dob;

            DateTime.TryParse(offender.ReceptionDateString, out DateTime rd);
            offender.ReceptionDate = rd;

            return(offender);
        }
        public IEnumerable <OffenderReception> GetAllOffenderReceptionsForOffender(Offender offender)
        {
            var offenderRecptionRecords             = RepoHelper.GetRecords(_filepath);
            var offenderReceptionRecordsForOffender =
                offenderRecptionRecords.Where(r => receptionMatchesOffender(r, offender));

            return(offenderReceptionRecordsForOffender.Select(constructOffenderReceptionEntity));
        }
예제 #7
0
        public IEnumerable <OffenderSentence> GetAllOffenderSentencesForOffender(Offender offender)
        {
            var offenderSentenceRecords            = RepoHelper.GetRecords(_filepath);
            var offenderSentenceRecordsForOffender =
                offenderSentenceRecords.Where(r => sentenceMatchesOffender(r, offender));

            return(offenderSentenceRecordsForOffender.Select(constructOffenderSentenceEntity));
        }
        public IEnumerable <OffenderAlias> GetOffenderAliasesForOffender(Offender offender)
        {
            var offenderAliasRecords            = RepoHelper.GetRecords(_filepath);
            var offenderAliasRecordsForOffender =
                offenderAliasRecords.Where(r => aliasMatchesOffender(r, offender));

            return(offenderAliasRecordsForOffender.Select(constructOffenderAliasEntity));
        }
        public async Task <IActionResult> Create([Bind("OffenderId,OffenderName,OffenderSummary")] Offender offender)
        {
            if (ModelState.IsValid)
            {
                _context.Add(offender);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(offender));
        }
예제 #10
0
        public IActionResult Create(Offender offender)
        {
            if (ModelState.IsValid)
            {
                //set the status to be "in Custody"
                offender.StatusID = 1;

                //insert the offender in the database
                offenderOps.Insert(offender);
            }

            return(RedirectToAction("Index", "Offenders"));
        }
예제 #11
0
 public IActionResult Edit(Offender offender)
 {
     if (ModelState.IsValid)
     {
         var result = offenderOps.GetById(offender.OffenderID);
         result.HomeAddress = offender.HomeAddress;
         result.Name        = offender.Name;
         result.Surname     = offender.Surname;
         result.StatusID    = offender.StatusID;
         offenderOps.Update(result);
     }
     return(RedirectToAction("Index"));
 }
        public void TestOffenderExit()
        {
            // retreive the second offender
            Offender offender = this.dbContext.Offenders.Find(2L);

            Assert.IsNotNull(offender);

            // retreive the offender's geofence
            OffenderGeoFence geoFence = this.dbContext.OffenderGeoFences.FirstOrDefault(x => x.OffenderId == offender.OffenderId);

            Assert.IsNotNull(geoFence);

            // set the last location to inside their geofence
            this.dbContext.OffenderLocations.Add(new OffenderLocation()
            {
                OffenderId   = offender.OffenderId,
                Latitude     = (geoFence.NorthEastLatitude + geoFence.SouthWestLatitude) / 2,
                Longitude    = (geoFence.NorthEastLongitude + geoFence.SouthWestLongitude) / 2,
                LocationTime = DateTimeOffset.Now.AddMinutes(-1)
            });
            this.dbContext.SaveChanges();

            // the location outside the fence
            decimal        latitude     = geoFence.SouthWestLatitude + .0123M;
            decimal        longitude    = (geoFence.NorthEastLongitude + geoFence.SouthWestLongitude) / 2;
            DateTimeOffset locationTime = DateTimeOffset.Now;

            // add the location to the offender
            OffenderNewLocationWorkflow workflow = new OffenderNewLocationWorkflow(this.dbContext, offender.OffenderId);

            workflow.AddNewLocation(latitude, longitude, locationTime);

            // ensure the location was saved to the database
            OffenderLocation insideLocation = this.dbContext.OffenderLocations.Where(x => x.OffenderId == offender.OffenderId).OrderByDescending(x => x.LocationTime).Take(1).FirstOrDefault();

            Assert.IsNotNull(insideLocation, "Expected Offender to have a last location");
            Assert.AreEqual(latitude, insideLocation.Latitude, "Expected the last locations Latidude to equal {0}", latitude);
            Assert.AreEqual(longitude, insideLocation.Longitude, "Expected the last locations Longitude to equal {0}", longitude);
            Assert.AreEqual(locationTime, insideLocation.LocationTime, "Expected the last locations LocationTime to equal {0}", locationTime);

            // validate the event
            OffenderEvent entryEvent = this.dbContext.OffenderEvents.FirstOrDefault(x => x.OffenderLocationId == insideLocation.OffenderLocationId);

            Assert.IsNotNull(entryEvent, "No Offender Event was created for the Location.");
            Assert.AreEqual(geoFence.OffenderGeoFenceId, entryEvent.OffenderGeoFenceId, "Offender Event does not match the expected GeoFence");
            Assert.AreEqual(offender.OffenderId, entryEvent.OffenderId, "The Offender Event does not match the expected Offender");
            Assert.AreEqual(EventTypeIdentifiers.Exit, entryEvent.EventTypeId, "The Event Type was expected to be an Exit event");
        }
예제 #13
0
        public override void Read()
        {
            ComplaintType = (SupportSpamType)_worldPacket.ReadUInt8();
            Offender.Read(_worldPacket);

            switch (ComplaintType)
            {
            case SupportSpamType.Mail:
                MailID = _worldPacket.ReadUInt32();
                break;

            case SupportSpamType.Chat:
                Chat.Read(_worldPacket);
                break;

            case SupportSpamType.Calendar:
                EventGuid  = _worldPacket.ReadUInt64();
                InviteGuid = _worldPacket.ReadUInt64();
                break;
            }
        }
예제 #14
0
        private void PrintRecord(Offender offender)
        {
            try
            {
                cb.BeginText();

                AppendNewRow("First Name:", offender.FirstName, 1);
                AppendNewRow("Last Name:", offender.LastName, 1);
                AppendNewRow("Date of Birth:", offender.DateOfBirth.Value.ToShortDateString(), 1);
                AppendNewRow("Age:", offender.Age.ToString(), 1);
                AppendNewRow("Sex:", offender.Gender == "M" ? "Male" : "Female", 1);
                AppendNewRow("Height:", offender.Height.ToString() + " cm", 1);
                AppendNewRow("Weight:", offender.Weight.ToString() + " kg", 1);
                AppendNewRow("Nationality:", offender.Nationality, 1);
                AppendNewRow("Address:", offender.Address, 1);
                AppendNewRow("No. of Offenses:", offender.Offenses.Count.ToString(), 1);

                int i = 1;
                foreach (var offense in offender.Offenses)
                {
                    PrintSubRecord(offense, i++);

                    //add a new page if not enough space left
                    if (headerStartYoffSet < 150)
                    {
                        cb.EndText();
                        doc.NewPage();
                        cb.BeginText();
                        ResetOffsets();
                    }
                }
            }
            finally
            {
                cb.EndText();
            }
        }
 public void ResurrectMePlease(Offender o)
 {
     o.ResetOffender();
     activeOffenders.Remove(o);
 }
 private bool receptionMatchesOffender(string[] dataFields, Offender offender)
 {
     return(offender.DOCNumber == Convert.ToInt32(dataFields[DOC_NUMBER_INDEX]));
 }
예제 #17
0
        public Model.Case Map(Model.Case @case,
                              Offender offender           = null,
                              ContactInfo offenderContact = null,
                              Officer managedBy           = null,
                              Officer assignedTo          = null,
                              Person reportedBy           = null,
                              ContactInfo reporterContact = null,
                              Master breachCategories     = null,
                              Master offences             = null,
                              Attachment attachment       = null,
                              Certificate certificate     = null,
                              Premise premise             = null,
                              SanctionInfo sanctionInfo   = null)
        {
            if (!dict.TryGetValue(@case.ID, out Model.Case result))
            {
                dict[@case.ID] = @case;

                _contactInfoCache.Clear();
                _breachCategoriesCache.Clear();
                _offencesCache.Clear();
                _attachmentCache.Clear();
                _certificatesCache.Clear();
                _premiseCache.Clear();
                _sanctionInfoCache.Clear();
                _activityCache.Clear();
                _offenderContactInfoCache.Clear();

                if (!string.IsNullOrEmpty(offender?.Name))
                {
                    @case.Offender = offender;
                }

                if (!string.IsNullOrEmpty(managedBy?.Name))
                {
                    @case.ManagedBy = managedBy;
                }

                if (!string.IsNullOrEmpty(assignedTo?.Name))
                {
                    @case.AssignedTo = assignedTo;
                }

                if (!string.IsNullOrEmpty(reportedBy?.Name))
                {
                    @case.ReportedBy = reportedBy;
                }
                result = @case;
            }

            if ((reporterContact?.ID ?? 0) > 0 &&
                !_contactInfoCache.ContainsKey(reporterContact.ID))
            {
                _contactInfoCache[reporterContact.ID] = reporterContact;

                if (result.ReportedBy.ContactInfos == null)
                {
                    result.ReportedBy.ContactInfos = new List <ContactInfo>();
                }
                result.ReportedBy.ContactInfos.Add(reporterContact);
            }

            if ((offenderContact?.ID ?? 0) > 0 &&
                !_offenderContactInfoCache.ContainsKey(offenderContact.ID))
            {
                _offenderContactInfoCache[offenderContact.ID] = offenderContact;

                if (result.Offender.ContactInfos == null)
                {
                    result.Offender.ContactInfos = new List <ContactInfo>();
                }
                result.Offender.ContactInfos.Add(offenderContact);
            }

            if ((breachCategories?.ID ?? Guid.Empty) != Guid.Empty &&
                !_breachCategoriesCache.ContainsKey(breachCategories.ID))
            {
                _breachCategoriesCache[breachCategories.ID] = breachCategories;

                if (result.BreachCategories == null)
                {
                    result.BreachCategories = new List <Master>();
                }
                result.BreachCategories.Add(breachCategories);
            }

            if ((offences?.ID ?? Guid.Empty) != Guid.Empty &&
                !_offencesCache.ContainsKey(offences.ID))
            {
                _offencesCache[offences.ID] = offences;

                if (result.Offences == null)
                {
                    result.Offences = new List <Master>();
                }
                result.Offences.Add(offences);
            }

            if ((attachment?.ID ?? 0) > 0 &&
                !_attachmentCache.ContainsKey(attachment.ID))
            {
                _attachmentCache[attachment.ID] = attachment;

                if (result.Attachments == null)
                {
                    result.Attachments = new List <Attachment>();
                }
                result.Attachments.Add(attachment);
            }

            if ((certificate?.ID ?? 0) > 0 &&
                !_certificatesCache.ContainsKey(certificate.ID))
            {
                _certificatesCache[certificate.ID] = certificate;

                if (result.Certificates == null)
                {
                    result.Certificates = new List <Certificate>();
                }
                result.Certificates.Add(certificate);
            }

            if ((premise?.ID ?? 0) > 0 &&
                !_premiseCache.ContainsKey(premise.ID))
            {
                _premiseCache[premise.ID] = premise;

                if (result.Premises == null)
                {
                    result.Premises = new List <Premise>();
                }
                result.Premises.Add(premise);
            }

            if ((sanctionInfo?.ID ?? 0) > 0 &&
                !_sanctionInfoCache.ContainsKey(sanctionInfo.ID))
            {
                _sanctionInfoCache[sanctionInfo.ID] = sanctionInfo;

                if (result.SanctionInfos == null)
                {
                    result.SanctionInfos = new List <SanctionInfo>();
                }
                result.SanctionInfos.Add(sanctionInfo);
            }

            return(result);
        }
예제 #18
0
 public ActionResult EditOffender(Offender currOffender)
 {
     db.Entry(currOffender).State = EntityState.Modified;
     db.SaveChanges();
     return(RedirectToAction("AllOffenderDetail", new { offenderId = currOffender.Id }));
 }
예제 #19
0
 public void Remove(Offender entity)
 {
     throw new NotImplementedException();
 }
예제 #20
0
 public Offender Save(Offender offender)
 {
     return((Offender)Database.Save(offender));
 }
예제 #21
0
 public Offender Save(Offender offender)
 {
     offender.OffenderId = 1;
     offender            = (Offender)Database.Save(offender);
     return(offender);
 }