Пример #1
0
        public void SetLocation(DFLocation location, bool performLayout = true)
        {
            if (!ReadyCheck())
            {
                return;
            }

            // Validate
            if (this.isSet)
            {
                throw new Exception("This location has already been set.");
            }
            if (!location.Loaded)
            {
                throw new Exception("DFLocation not loaded.");
            }

            // Set summary
            summary           = new LocationSummary();
            summary.MapID     = location.MapTableData.MapId;
            summary.Longitude = (int)location.MapTableData.Longitude;
            summary.Latitude  = (int)location.MapTableData.Latitude;
            DFPosition mapPixel   = MapsFile.LongitudeLatitudeToMapPixel(summary.Longitude, summary.Latitude);
            DFPosition worldCoord = MapsFile.MapPixelToWorldCoord(mapPixel.X, mapPixel.Y);

            summary.MapPixelX      = mapPixel.X;
            summary.MapPixelY      = mapPixel.Y;
            summary.WorldCoordX    = worldCoord.X;
            summary.WorldCoordZ    = worldCoord.Y;
            summary.RegionName     = location.RegionName;
            summary.LocationName   = location.Name;
            summary.WorldClimate   = (MapsFile.Climates)location.Climate.WorldClimate;
            summary.LocationType   = location.MapTableData.LocationType;
            summary.DungeonType    = location.MapTableData.DungeonType;
            summary.HasDungeon     = location.HasDungeon;
            summary.Climate        = ClimateSwaps.FromAPIClimateBase(location.Climate.ClimateType);
            summary.Nature         = ClimateSwaps.FromAPITextureSet(location.Climate.NatureSet);
            summary.SkyBase        = location.Climate.SkyBase;
            summary.BlockWidth     = location.Exterior.ExteriorData.Width;
            summary.BlockHeight    = location.Exterior.ExteriorData.Height;
            summary.LegacyLocation = location;

            // Assign starting climate
            CurrentSeason    = ClimateSeason.Summer;
            CurrentClimate   = summary.Climate;
            CurrentNatureSet = summary.Nature;

            // Perform layout
            if (performLayout)
            {
                LayoutLocation(ref location);
                ApplyClimateSettings();
            }

            // Set location rect
            SetLocationRect();

            // Seal location
            isSet = true;
        }
Пример #2
0
        /// <summary>
        /// Get the Location Summary for a given Location ID
        /// </summary>
        /// <param name="LocationID">Unique ID of the location</param>
        /// <returns>LocationSummaryDTO</returns>
        public async Task <LocationSummary> GetLocationSummaryByID(long ID)
        {
            var netWorkLocation = await _networkLocationClient.GetNetworkLocationByID(ID);

            //map the location info
            LocationSummary locaSummary = _mapper.Map <LocationSummary>(netWorkLocation);

            locaSummary.ID = netWorkLocation.CSNetID;
            //get sensor summary info
            locaSummary.SensorSummary = new List <SensorSummary>();

            locaSummary.SensorSummary.Add(await PreareSensorSummaryForNetwork(netWorkLocation.CSNetID));

            return(locaSummary);


            ////get location info
            //var loc = (await _locationClient.GetLocationByID(ID));

            ////map the location info
            //LocationSummary locaSummary = _mapper.Map<LocationSummary>(loc);

            ////get sensor summary info
            //locaSummary.SensorSummary = await PrepareLocationSummary(loc);

            ////prepare and return location summary
            //return locaSummary;
        }
        private static ConsoleColor ColourForLocationSummary(LocationSummary locationSummary)
        {
            if (locationSummary.Status == SawmillStatus.Geocoded && locationSummary.Count == 0)
            {
                return(ConsoleColor.Yellow);
            }
            else if (locationSummary.Status == SawmillStatus.SkippedAsEmpty && locationSummary.Count > 0)
            {
                return(ConsoleColor.Yellow);
            }
            else if (locationSummary.Status != SawmillStatus.Geocoded && locationSummary.Count > 0)
            {
                return(ConsoleColor.Red);
            }

            return(ConsoleColor.Green);
        }
Пример #4
0
 private void SaveChanges()
 {
     if (_isNew)
     {
         Platform.GetService(
             delegate(ILocationAdminService service)
         {
             var response     = service.AddLocation(new AddLocationRequest(_locationDetail));
             _locationRef     = response.Location.LocationRef;
             _locationSummary = response.Location;
         });
     }
     else
     {
         Platform.GetService(
             delegate(ILocationAdminService service)
         {
             var response     = service.UpdateLocation(new UpdateLocationRequest(_locationDetail));
             _locationRef     = response.Location.LocationRef;
             _locationSummary = response.Location;
         });
     }
 }
Пример #5
0
        private static void PopulateLocationStatistics(TreeStatistics treeStatistics, List <WhoWhatWhereWhen> whoWhatWhereWhen)
        {
            var allLocations = whoWhatWhereWhen
                               .Select(p => p.Where.Location)
                               .ToList();

            var locationStatusEnums = Enum.GetValues(typeof(SawmillStatus));

            foreach (SawmillStatus locationEnumStatus in locationStatusEnums)
            {
                var locationSummary = new LocationSummary
                {
                    Count  = allLocations.Count(d => d.Status == locationEnumStatus),
                    Status = locationEnumStatus,
                };

                treeStatistics.LocationCountsByStatus.Add(locationSummary);
            }

            treeStatistics.LocationIssuesExist = treeStatistics
                                                 .LocationCountsByStatus
                                                 .Where(d => d.Status != SawmillStatus.Geocoded)
                                                 .Any(d => d.Count > 0);
        }
        public LocationSummary TransferLocationInfo(string clientName, string latitude, string longitude)
        {
            try
            {
                lock (_doTransferLocationInfoWorkSync)
                {
                    string realName = string.Empty;
                    try
                    {
                        if (string.IsNullOrEmpty(clientName))
                            throw new ApplicationException("invalid client name");
                        var loc = new GeoCoordinate(double.Parse(latitude), double.Parse(longitude));

                        //Let us find the real name
                        if (ListTPSummary.Count > 0 && ListTPSummary[0].ListOfItems != null && ListTPSummary[0].ListOfItems.Count>0)
                        {
                            foreach (EmployeeDetail ed in ListTPSummary[0].ListOfItems)
                            {
                                if (ed.Email.ToLower().Contains(clientName.ToLower()))
                                {
                                    realName = ed.Name;
                                    continue;
                                }
                            }
                        }
                    }
                    catch
                    {
                        LocationSummary ls = new LocationSummary();
                        Location l = new Location();
                        l.ClientName = "No cookie for you!";
                        ls.ListOfItems.Add(l);
                        return ls;
                    }

                    bool clientFound = false;
                    //Find if this clientName exists in the list
                    foreach (Location l in LocationSummary.ListOfItems)
                    {
                        if (l.ClientName.ToLower() == clientName.ToLower())
                        {
                            l.Latitude = latitude;
                            l.Longitude = longitude;
                            l.Timestamp = DateTime.Now;
                            l.RealName = realName;
                            clientFound = true;
                            break;
                        }
                    }

                    //This is a new client
                    if (clientFound == false)
                    {
                        Location newLocation = new Location();
                        newLocation.Longitude = longitude;
                        newLocation.Latitude = latitude;
                        newLocation.ClientName = clientName;
                        newLocation.Timestamp = DateTime.Now; //DateTime.Now.ToString("D");
                        newLocation.Link = @"http://maps.google.com/maps?q=" + clientName + @"@" + latitude + "," + longitude;
                        LocationSummary.ListOfItems.Add(newLocation);
                    }

                    var selfCoord = new GeoCoordinate(double.Parse(latitude), double.Parse(longitude));
                    foreach (Location l in LocationSummary.ListOfItems)
                    {
                        var otherCoord = new GeoCoordinate(double.Parse(l.Latitude), double.Parse(l.Longitude));
                        var distance = selfCoord.GetDistanceTo(otherCoord);
                        var distanceInMiles = 0.000621371192 * distance;
                        if (distanceInMiles >= 1)
                            l.Distance = distanceInMiles.ToString("F") + " miles";
                        else
                            l.Distance = (distanceInMiles * 1760).ToString("F") + " yards";
                    }

                    LocationSummary.DisplayDate = DateTime.Now.ToString("D");
                    LocationSummary.UpdateAge();

                    //Map display related info
                    //Step 1: fill up AllLocationsForMap
                    //[
                    //  ['Bondi Beach', -33.890542, 151.274856, 4],
                    //  ['Coogee Beach', -33.923036, 151.259052, 5],
                    //  ['Cronulla Beach', -34.028249, 151.157507, 3],
                    //  ['Manly Beach', -33.80010128657071, 151.28747820854187, 2],
                    //  ['Maroubra Beach', -33.950198, 151.259302, 1]
                    //]

                    StringBuilder st = new StringBuilder();
                    int count = 0;

                    var arr = new List<object>();
                    foreach (Location l in LocationSummary.ListOfItems)
                    {
                        if(string.IsNullOrEmpty(l.RealName))
                            st.Append("['" + l.ClientName + "'," + l.Latitude + "," + l.Longitude + "," + (++count).ToString() + "]");
                        else
                            st.Append("['" + l.RealName + "'," + l.Latitude + "," + l.Longitude + "," + (++count).ToString() + "]");
                        if (count < LocationSummary.ListOfItems.Count())
                            st.Append(",");
                    }
                    LocationSummary.AllLocationsForMap = "[" + Environment.NewLine + st.ToString() + Environment.NewLine + "]";
                }
            }
            catch
            {
                LocationSummary ls = new LocationSummary();
                Location l = new Location();
                l.ClientName = "No cookie for you!";
                ls.ListOfItems.Add(l);
                return ls;
            }
            return LocationSummary;
        }
 public UpdateLocationResponse(LocationSummary summary)
 {
     this.Location = summary;
 }
Пример #8
0
 public AddLocationResponse(LocationSummary location)
 {
     this.Location = location;
 }
Пример #9
0
        public void SetLocation(DFLocation location, bool performLayout = true)
        {
            if (!ReadyCheck())
                return;

            // Validate
            if (this.isSet)
                throw new Exception("This location has already been set.");
            if (!location.Loaded)
                throw new Exception("DFLocation not loaded.");

            // Set summary
            summary = new LocationSummary();
            summary.ID = location.MapTableData.MapId;
            summary.Longitude = (int)location.MapTableData.Longitude;
            summary.Latitude = (int)location.MapTableData.Latitude;
            DFPosition mapPixel = MapsFile.LongitudeLatitudeToMapPixel(summary.Longitude, summary.Latitude);
            DFPosition worldCoord = MapsFile.MapPixelToWorldCoord(mapPixel.X, mapPixel.Y);
            summary.MapPixelX = mapPixel.X;
            summary.MapPixelY = mapPixel.Y;
            summary.WorldCoordX = worldCoord.X;
            summary.WorldCoordZ = worldCoord.Y;
            summary.RegionName = location.RegionName;
            summary.LocationName = location.Name;
            summary.WorldClimate = location.Climate.WorldClimate;
            summary.LocationType = location.MapTableData.LocationType;
            summary.DungeonType = location.MapTableData.DungeonType;
            summary.HasDungeon = location.HasDungeon;
            summary.Climate = ClimateSwaps.FromAPIClimateBase(location.Climate.ClimateType);
            summary.Nature = ClimateSwaps.FromAPITextureSet(location.Climate.NatureSet);
            summary.SkyBase = location.Climate.SkyBase;
            summary.BlockWidth = location.Exterior.ExteriorData.Width;
            summary.BlockHeight = location.Exterior.ExteriorData.Height;

            // Assign starting climate
            CurrentSeason = ClimateSeason.Summer;
            CurrentClimate = summary.Climate;
            CurrentNatureSet = summary.Nature;

            // Perform layout
            if (performLayout)
            {
                LayoutLocation(ref location);
                ApplyClimateSettings();
            }

            // Seal location
            isSet = true;
        }
 public AddLocationResponse(LocationSummary location)
 {
     this.Location = location;
 }
Пример #11
0
 public UpdateLocationResponse(LocationSummary summary)
 {
     this.Location = summary;
 }