public ActionResult FixAddresses(int?id)
        {
            id = id ?? 0;

            string data     = "<table>";
            int    pageSize = 40;

            foreach (var addr in (from a in this.db.PersonAddress.Include("Person") where a.Quality == 0 select a).OrderBy(f => f.Person.LastName).ThenBy(f => f.Person.FirstName).Skip(id.Value * pageSize).Take(pageSize))
            {
                string oldAddr = addr.Street + "<br/>" + addr.City + " " + addr.State + " " + addr.Zip;

                GeographyServices.RefineAddressWithGeography(addr);

                data += string.Format("<tr><td><b>{0}</b></td><td style=\"white-space:nowrap\">{1}</td><td>{2}</td></tr>",
                                      addr.Person.ReverseName,
                                      oldAddr,
                                      string.Format("Mailing: {0},  GeoLocation: {1}<br/>{2}",
                                                    addr.Quality & 0x000f,
                                                    (addr.Quality & 0x00f0) >> 4,
                                                    HttpUtility.HtmlEncode(string.Format("[{0}][{1}][{2}][{3}]", addr.Street, addr.City, addr.State, addr.Zip)))
                                      );
            }
            this.db.SaveChanges();
            return(new ContentResult {
                Content = data + "</table>", ContentType = "text/html"
            });
        }
Example #2
0
        ///// <summary>
        /////
        ///// </summary>
        ///// <param name="id">mission geography id</param>
        ///// <returns></returns>
        //public ActionResult MissionsNear(Guid id)
        //{
        //    MapDataRequests model = new MapDataRequests { Modes = MapModes.MissionDetails, Zoom = 11 };
        //    using (var ctx = GetContext())
        //    {
        //        var center = (from g in ctx.MissionGeography where g.Id == id select g).First().Geography;
        //        model.CenterLat = center.Lat.Value;
        //        model.CenterLong = center.Long.Value;

        //        model.Missions.AddRange(ctx.MissionsNearGeographyId(id, 2).Select(f => f.Value).AsEnumerable());
        //    }

        //    return BuildView("Related Missions", model);
        //}

        public ActionResult Index(Guid?mission)
        {
            var center = GeographyServices.GetDefaultLocation();

            MapDataRequests model = new MapDataRequests {
                CenterLat = center.Lat.Value, CenterLong = center.Long.Value, Zoom = 9
            };

            if (mission.HasValue)
            {
                model.Modes = MapModes.MissionDetails;
                model.Missions.Add(mission.Value);
            }
            else
            {
                model.Modes |= MapModes.MissionBrowser;
                model.Title  = "Mission History";
            }

            if (User.IsInRole("cdb.users"))
            {
                model.Title       = "";
                model.Modes      |= MapModes.MemberHouses;
                ViewData["units"] = UnitsController.GetUnitSelectList(this.db, null);
            }

            return(BuildView("Map", model));
        }
Example #3
0
        public ActionResult FixAddresses(int?id)
        {
            id = id ?? 0;

            string data     = "<table>";
            int    pageSize = 40;

            foreach (var addr in (from a in this.db.PersonAddress.Include("Person") where a.Quality == (int)GeocodeQuality.Unknown select a).OrderBy(f => f.Person.LastName).ThenBy(f => f.Person.FirstName).Skip(id.Value * pageSize).Take(pageSize))
            {
                string oldAddr = addr.Street + "<br/>" + addr.City + " " + addr.State + " " + addr.Zip;

                GeographyServices.RefineAddressWithGeography(addr);

                data += string.Format("<tr><td><b>{0}</b></td><td style=\"white-space:nowrap\">{1}</td><td>{2}</td></tr>",
                                      addr.Person.ReverseName,
                                      oldAddr,
                                      string.Format("Quality: {0}<br/>{2}",
                                                    addr.Quality,
                                                    HttpUtility.HtmlEncode(string.Format("[{0}][{1}][{2}][{3}]", addr.Street, addr.City, addr.State, addr.Zip)))
                                      );
            }
            try
            {
                this.db.SaveChanges();
            }
            catch (DbEntityValidationException ex)
            {
                LogManager.GetLogger("AdminController").ErrorFormat("Validation error: {0}",
                                                                    string.Join("\n", ex.EntityValidationErrors.SelectMany(f => f.ValidationErrors.Select(g => g.PropertyName + ": " + g.ErrorMessage))));
                data += "<tr><td colspan=23>DIDN'T SAVE ANY CHANGES BECAUSE OF VALIDATION EXCEPTIONS. CHECK LOGS.</td></tr>";
            }
            return(new ContentResult {
                Content = data + "</table>", ContentType = "text/html"
            });
        }
Example #4
0
 public MasterCampaignController()
 {
     _industryService        = new IndustryServices();
     _businessgroupService   = new BusinessGroupServices();
     _businesslineService    = new BusinessLineServices();
     _segmentService         = new SegmentServices();
     _geographyService       = new GeographyServices();
     _themeService           = new ThemeServices();
     _masterCampaignServices = new MasterCampaignServices();
     _tacticCampaignServices = new TacticCampaignServices();
 }
Example #5
0
        public TacticCampaignController()
        {
            _industryService        = new IndustryServices();
            _businessgroupService   = new BusinessGroupServices();
            _businesslineService    = new BusinessLineServices();
            _segmentService         = new SegmentServices();
            _geographyService       = new GeographyServices();
            _themeService           = new ThemeServices();
            _tacticCampaignServices = new TacticCampaignServices();
            _childCampaignServices  = new ChildCampaignServices();
            _masterCampaignServices = new MasterCampaignServices();

            _metricReachServices    = new MetricReachServices();
            _metricResponseServices = new MetricResponseServices();
            _journeyStageServices   = new JourneyStageServices();
            _digitalTouchpoint      = new DigitalTouchpoint();
        }
        public ActionResult SubmitWaypoint(WaypointView wpt)
        {
            List <SubmitError> errors = new List <SubmitError>();
            Guid result = Guid.Empty;

            if (!User.IsInRole("cdb.missioneditors"))
            {
                return(GetLoginError());
            }

            MissionGeography geog = null;

            geog = (from g in this.db.MissionGeography where g.Id == wpt.Id select g).FirstOrDefault();
            if (geog == null)
            {
                geog = new MissionGeography {
                    Mission = (from m in this.db.Missions where m.Id == wpt.EventId select m).First()
                };
                this.db.MissionGeography.Add(geog);
            }

            //try
            //{
            if (geog.Kind != wpt.Kind)
            {
                geog.Kind = wpt.Kind;
            }
            if (geog.InstanceId != wpt.InstanceId)
            {
                geog.InstanceId = wpt.InstanceId;
            }

            SqlGeography defaultCoord = GeographyServices.GetDefaultLocation();

            wpt.Lat  = Math.Abs(wpt.Lat) * Math.Sign(defaultCoord.Lat.Value);
            wpt.Long = Math.Abs(wpt.Long) * Math.Sign(defaultCoord.Long.Value);

            SqlGeography geography = wpt.AsSqlGeography();

            if (string.Format("{0}", geog.Geography) != string.Format("{0}", geography))
            {
                geog.Geography = geography;
            }
            if (geog.Description != wpt.Description)
            {
                geog.Description = wpt.Description;
            }
            if (geog.Time != wpt.Time)
            {
                geog.Time = wpt.Time;
            }

            if (errors.Count == 0)
            {
                this.db.SaveChanges();
            }

            //}
            //catch (RuleViolationsException ex)
            //{
            //  //this.CollectRuleViolations(ex, fields);
            //  foreach (RuleViolation v in ex.Errors)
            //  {
            //    errors.Add(new SubmitError { Error = v.ErrorMessage, Property = v.PropertyName, Id = new[] { v.EntityKey } });
            //  }
            //}

            return(Data(new SubmitResult <GeographyView>
            {
                Errors = errors.ToArray(),
                Result = (errors.Count > 0) ?
                         (GeographyView)null :
                         GeographyView.BuildGeographyView(geog)
                         //new WaypointView
                         //{
                         //    Id = newView.Id,
                         //    MissionId = newView.Mission.Id,
                         //    Kind = newView.Kind,
                         //    Desc = newView.Description,
                         //    Lat = GeographyServices.FormatCoordinate(newView.Geography.Lat.Value, this.UserSettings.CoordinateDisplay),
                         //    Long = GeographyServices.FormatCoordinate(newView.Geography.Long.Value, this.UserSettings.CoordinateDisplay),
                         //    Instance = newView.InstanceId,
                         //    Time = newView.Geography.M.IsNull ? (DateTime?)null : DateTime.FromOADate(newView.Geography.M.Value)
                         //}
            }));
        }