예제 #1
0
 public PollingPlace(Precinct p)
 {
     LocationName = p.LocationName;
     Address      = p.Address;
     CityStateZIP = p.CityStateZIP;
     PrecinctIds.Add(p.PrecinctSplitId);
 }
예제 #2
0
        public JsonResult LoadPrecinct(string provinceID, string districtID)
        {
            var xmlDoc   = XElement.Load(Server.MapPath(@"/Assets/client/data/Provinces_Data.xml"));
            var xElement = xmlDoc.Elements("Item").Where(x => x.Attribute("type").Value == "province" &&
                                                         x.Attribute("value").Value == provinceID);
            var xDistricts = xElement.Elements("Item").Where(x => x.Attribute("type").Value == "district" && x.Attribute("value").Value == districtID);
            var xPrecinct  = xDistricts.Elements("Item").Where(x => x.Attribute("type").Value == "precinct");

            var listPrecinct = new List <Precinct>();

            foreach (var item in xPrecinct)
            {
                var precinct = new Precinct();
                precinct.ProvinceID = provinceID;
                precinct.DistrictID = districtID;
                precinct.ID         = item.Attribute("id").Value;
                precinct.Name       = item.Attribute("value").Value;
                listPrecinct.Add(precinct);
            }

            return(Json(new
            {
                data = listPrecinct,
                status = true,
            }));
        }
예제 #3
0
        public IEnumerable <Precinct> ImportPrecinctData(string filePath)
        {
            List <Precinct> result = new List <Precinct>();

            using (StreamReader sr = new StreamReader(filePath)) {
                string line;
                char[] delimiters = new char[] { ',' };
                int    count      = 0;
                line = sr.ReadLine(); // throw out the first line
                try {
                    while ((line = sr.ReadLine()) != null)
                    {
                        count = count + 1;
                        if (count % 50 == 0)
                        {
                            Console.WriteLine("Read {0} precincts from input data", count);
                        }
                        string[] parts = line.Split(delimiters);
                        Precinct p     = new Precinct();
                        p.PrecinctSplitId = parts[0];
                        p.LocationName    = parts[1];
                        p.Address         = parts[2];
                        p.CityStateZIP    = parts[3] + ", " + parts[4] + "  " + parts[5];

                        result.Add(p);
                    }
                } catch (Exception e) {
                    Console.Write(e);
                    throw e;
                }
            }

            return(result);
        }
예제 #4
0
        public SubbandPrecinct(ResolutionLevel resolutionLevel, Subband subband, Precinct precinct)
        {
            ResolutionLevel = resolutionLevel;
            Subband         = subband;
            Precinct        = precinct;

            SubbandTileComponentSampleBounds_tb = ResolutionLevel.TilePartComponent.TileComponent.GetSubbandTileComponentSampleBounds_tb(subband);

            NCodeBlocksX = CeilDiv(SubbandTileComponentSampleBounds_tb.Width, ResolutionLevel.CodeBlockWidth);
            NCodeBlocksY = CeilDiv(SubbandTileComponentSampleBounds_tb.Height, ResolutionLevel.CodeBlockHeight);

            CodeBlockInclusionTagTree = new TagTree((uint)NCodeBlocksX, (uint)NCodeBlocksY);
            ZeroBitPlaneTagTree       = new TagTree((uint)NCodeBlocksX, (uint)NCodeBlocksY);

            CodeBlocks = new CodeBlock[NCodeBlocksY * NCodeBlocksX];

            var uRange = SubbandTileComponentSampleBounds_tb.XRange;
            var vRange = SubbandTileComponentSampleBounds_tb.YRange;

            TransformCoefficientValues = ResolutionLevel.TilePartComponent.ArithmeticType switch
            {
                ArithmeticType.Int32 => new Signal2D <int>(uRange, vRange),
                ArithmeticType.Single => new Signal2D <float>(uRange, vRange),
                ArithmeticType.Double => new Signal2D <double>(uRange, vRange),
                _ => throw NotSupported(ResolutionLevel.TilePartComponent.ArithmeticType)
            };
        }
예제 #5
0
        public ActionResult CreatePartial(Precinct obj)
        {
            if (Request.IsAjaxRequest())
            {
                dataManager.Precincts.Save(obj);

                return(Json(new { Name = obj.Name, Id = obj.Id, Key = "PrecinctId2" }, JsonRequestBehavior.AllowGet));
            }
            return(Json("", JsonRequestBehavior.AllowGet));
        }
예제 #6
0
 public void Save(Precinct obj)
 {
     if (obj.Id == 0)
     {
         context.Entry(obj).State = System.Data.Entity.EntityState.Added;
     }
     else
     {
         context.Entry(obj).State = System.Data.Entity.EntityState.Modified;
     }
     context.SaveChanges();
 }
예제 #7
0
        public WrongLocationDialog(Voter voter, Precinct place)
        {
            InitializeComponent();
            Owner             = Application.Current.MainWindow;
            VoterName.Content = GetFormattedName(voter);
            StringBuilder sb = new StringBuilder();

            sb.Append(place.Address);
            sb.Append("\n");
            sb.Append(place.CityStateZIP);
            LocationAddress.Text = sb.ToString();
        }
예제 #8
0
        public ActionResult Edit(Precinct obj, FormCollection collection)
        {
            string latitude  = collection["Latitude"];
            string longitude = collection["Longitude"];

            if (!string.IsNullOrEmpty(latitude) && !string.IsNullOrEmpty(longitude))
            {
                obj.Latitude  = double.Parse(latitude.Replace('.', ','));
                obj.Longitude = double.Parse(longitude.Replace('.', ','));
            }
            dataManager.Precincts.Save(obj);
            return(RedirectToAction("Show", new { Id = obj.Id }));
        }
예제 #9
0
        public ActionResult Create(Precinct obj, FormCollection collection)
        {
            //if (ModelState.IsValid)
            //{
            //    if (!dataManager.Precincts.GetAll()
            //        .Where(m => m.DistrictId == obj.DistrictId)
            //        .Any(o => o.Name == obj.Name))
            //    {
            //        dataManager.Precincts.Save(obj);
            //        return RedirectToAction("Show", new { Id = obj.Id });
            //    }
            //    else
            //        ModelState.AddModelError("Name",
            //            "УИК с названием \"" + obj.Name + "\" уже существует!");
            //}
            //ViewBag.Districts = from d in dataManager.Districts.GetAll()
            //                    select new SelectListItem
            //                    {
            //                        Text = d.Name,
            //                        Value = d.Id.ToString(),
            //                        Selected = obj.DistrictId == d.Id
            //                    };
            //var workers = new List<SelectListItem>
            //{
            //    new SelectListItem()
            //};
            //workers.AddRange(from w in dataManager.Workers.GetAll()
            //                 select new SelectListItem
            //                 {
            //                     Text = dataManager.Persons.Get(w.PersonId ?? 0).FullName,
            //                     Value = w.Id.ToString(),
            //                     Selected = w.Id == obj.WorkerId
            //                 });
            //ViewBag.Workers = workers;
            //return View(obj);
            string latitude  = collection["Latitude"];
            string longitude = collection["Longitude"];

            if (!string.IsNullOrEmpty(latitude) && !string.IsNullOrEmpty(longitude))
            {
                obj.Latitude  = double.Parse(latitude);
                obj.Longitude = double.Parse(longitude);
            }
            dataManager.Precincts.Save(obj);
            return(RedirectToAction("Show", new { Id = obj.Id }));
        }
예제 #10
0
 public ActionResult SetMapPosition(Precinct obj /*FormCollection collection*/)
 {
     /*string latitude = collection["Latitude"];
      * string longitude = collection["Longitude"];
      * string zoom = collection["Zoom"];
      * string iconPath = collection["IconPath"];
      * int id = int.Parse(collection["Id"]);
      * if (!string.IsNullOrEmpty(latitude) && !string.IsNullOrEmpty(longitude))
      * {
      *  var objFromDb = dataManager.Precincts.Get(id);
      *  objFromDb.Latitude = double.Parse(latitude.Replace('.', ','));
      *  objFromDb.Longitude = double.Parse(longitude.Replace('.', ','));
      *  objFromDb.Zoom = int.Parse(zoom);
      *  objFromDb.IconPath = iconPath;
      *  dataManager.Precincts.Save(objFromDb);
      * }*/
     return(View("Error"));
 }
예제 #11
0
        public JsonResult LoadPrecinct(int districtID)
        {
            var xmlLoadData = XDocument.Load(Server.MapPath(@"~/assets/client/data/Provinces_Data.xml"));
            //var district = xmlLoadData.Elements("Root").Elements("Item").Where(x => x.Attribute("type").Value == "province" && x.Attribute("id").Value == provinceID);
            var      precinct    = xmlLoadData.Elements("Root").Elements("Item").Elements("Item").Single(x => x.Attribute("type").Value == "district" && int.Parse(x.Attribute("id").Value) == districtID);
            var      list        = new List <Precinct>();
            Precinct getPrecinct = null;

            foreach (var item in precinct.Elements("Item").Where(x => x.Attribute("type").Value == "precinct"))
            {
                getPrecinct          = new Precinct();
                getPrecinct.ID       = int.Parse(item.Attribute("id").Value);
                getPrecinct.Name     = item.Attribute("value").Value;
                getPrecinct.District = int.Parse(item.Attribute("id").Value);
                list.Add(getPrecinct);
            }
            return(Json(
                       new
            {
                data = list,
                status = true
            }));
        }
예제 #12
0
 public WestendTests()
 {
     _db = new DatabaseDataContext();
     _precinct = _db.Precincts.Single(x => x.UrlName == "Vestegnen");
     _reportManager = new ReportManager(_precinct);
 }
예제 #13
0
 public ReportManager(Precinct precinct)
 {
     _precinct = precinct;
 }
예제 #14
0
 public FunenParserTestsTests()
 {
     _db = new DatabaseDataContext();
     _precinct = _db.Precincts.Single(x => x.UrlName == "Fyn");
     _reportManager = new ReportManager(_precinct);
 }
예제 #15
0
 public SouthSealandParserTests()
 {
     _db = new DatabaseDataContext();
     _precinct = _db.Precincts.Single(x => x.UrlName == "Sydsjaelland");
     _reportManager = new ReportManager(_precinct);
 }
예제 #16
0
 public EastJutlandParserTests()
 {
     _db = new DatabaseDataContext();
     _precinct = _db.Precincts.Single(x => x.UrlName == "Oestjylland");
     _reportManager = new ReportManager(_precinct);
 }
예제 #17
0
 public IHttpActionResult Get()
 {
     return(Ok(Precinct.GetCached()));
 }
예제 #18
0
 public CopenhagenTests()
 {
     _db = new DatabaseDataContext();
     _precinct = _db.Precincts.Single(x => x.UrlName == "Koebenhavn");
     _reportManager = new ReportManager(_precinct);
 }
예제 #19
0
        /// <summary>
        /// Called when the manager responds to a ballot request
        /// </summary>
        /// <param name="succes">
        /// whether or not the ballot request was a success
        /// </param>
        public void BallotResponse(Voter voter, bool success, VoterStatus oldStatus, VoterStatus newStatus)
        {
            if (!success && newStatus != VoterStatus.NotSeenToday && newStatus != VoterStatus.WrongLocation)
            {
                string message;
                if (newStatus == VoterStatus.ActiveVoter || newStatus == VoterStatus.SuspendedVoter ||
                    newStatus == VoterStatus.OutOfCounty || newStatus == VoterStatus.MailBallotNotReturned)
                {
                    message = GetFormattedName(voter) + "\nhas already checked in and received a ballot\n(style " +
                              voter.BallotStyle + ") at this location today.";
                }
                else
                {
                    message = GetFormattedName(voter) + "\nhas already checked in and did not receive a ballot\n" +
                              "at this location today.";
                }
                FlexibleMessageBox.Show(_ui._stationNativeWindow,
                                        message,
                                        "Already Checked In",
                                        MessageBoxButtons.OK,
                                        MessageBoxIcon.Stop);
            }

            switch (newStatus)
            {
            case VoterStatus.Ineligible:
                FlexibleMessageBox.Show(_ui._stationNativeWindow, "According to our records,\n" + GetFormattedName(voter) +
                                        "\nis not eligible to vote until " + voter.EligibleDate.Date.ToString("MM/dd/yyyy"));
                break;

            case VoterStatus.WrongLocation:
                Precinct p = _ui._station.Database.GetPrecinctBySplitId(voter.PrecinctSub);
                if (p != null && p.Address.Trim().Length > 0)
                {
                    WrongLocationDialog wrd    = null;
                    Boolean             result = false;
                    _ui._stationWindow.Dispatcher.Invoke(
                        System.Windows.Threading.DispatcherPriority.Normal,
                        new Action(
                            delegate {
                        wrd       = new WrongLocationDialog(voter, p);
                        wrd.Owner = _ui._stationWindow;
                        result    = (Boolean)wrd.ShowDialog();
                    }));
                    if (result == true)
                    {
                        string here  = _ui._station.PollingPlace.Address + ", " + _ui._station.PollingPlace.CityStateZIP;
                        string there = p.Address + ", " + p.CityStateZIP;
                        string url   = "https://maps.google.com/maps/dir/" + here.Replace(" ", "+") + "/" + there.Replace(" ", "+");
                        System.Diagnostics.Process.Start(url);
                    }
                }
                else
                {
                    FlexibleMessageBox.Show(_ui._stationNativeWindow, "The precinct where\n" + GetFormattedName(voter) + "\nis registered is" +
                                            " not participating\nin this election.");
                }
                break;

            case VoterStatus.VotedByMail:
                FlexibleMessageBox.Show(_ui._stationNativeWindow, "According to our records,\n" + GetFormattedName(voter) +
                                        "\nhas already submitted a vote by mail\nand should not receive a ballot.");
                break;

            case VoterStatus.EarlyVotedInPerson:
                FlexibleMessageBox.Show(_ui._stationNativeWindow, "According to our records,\n" + GetFormattedName(voter) +
                                        "\nhas already voted at an early voting location.");
                break;

            case VoterStatus.AbsenteeVotedInPerson:
                FlexibleMessageBox.Show(_ui._stationNativeWindow, "According to our records,\n" + GetFormattedName(voter) +
                                        "\nregistered as an absentee voter but did not receive their ballot.");
                break;

            default:
                break;
            }

            if (success)
            {
                switch ((VoterStatus)voter.PollbookStatus)
                {
                case VoterStatus.SuspendedVoter:
                case VoterStatus.OutOfCounty:
                case VoterStatus.MailBallotNotReturned:
                case VoterStatus.ActiveVoter:
                case VoterStatus.Provisional:
                    _ui._stationWindow.Dispatcher.Invoke(
                        System.Windows.Threading.DispatcherPriority.Normal,
                        new Action(
                            delegate {
                        var bd   = new GiveBallotDialog(voter);
                        bd.Owner = _ui._stationWindow;
                        bd.ShowDialog();
                    }));
                    break;

                default:
                    break;
                }
            }

            EnableFields(true);
            ClearFields();
            WaitingLabel.Content = string.Empty;
            Waiting = false;
        }