コード例 #1
0
        public Response SaveDataSplit(object json, string name)
        {
            SatellitesBatch satellites = (SatellitesBatch)(cache.Get("satellites"));

            SatelliteData data = new SatelliteData();

            data      = Newtonsoft.Json.JsonConvert.DeserializeObject <SatelliteData>(json.ToString());
            data.Name = name;

            if (satellites != null)
            {
                int index = satellites.Satellites.FindIndex(x => x.Name.ToUpper().Equals(name.ToUpper()));
                if (index > -1)
                {
                    satellites.Satellites.RemoveAt(index);
                }
                satellites.Satellites.Add(data);
            }
            else
            {
                satellites = new SatellitesBatch();
                satellites.Satellites.Add(data);
            }
            cache.Insert("satellites", satellites);

            return(new Response(200, null, null));
        }
コード例 #2
0
        public Response GetDataSplit()
        {
            SatellitesBatch satellites = (SatellitesBatch)(cache.Get("satellites"));
            bool            validation = false;

            if (satellites != null && satellites.Satellites.Count == 3)
            {
                foreach (SatelliteData sat in satellites.Satellites)
                {
                    validation = ValidateSatelliteData(sat);
                    if (!validation)
                    {
                        break;
                    }
                }
            }

            if (validation)
            {
                Calculate(satellites.Satellites);
            }

            int intCode = (ShipCoordinates != null && ShipMessage != null) ? 200 : 404;

            return(new Response(intCode, ShipCoordinates, (intCode == 404 ? "Falta información" : ShipMessage)));
        }
コード例 #3
0
        public Response GetSecret(object json)
        {
            SatellitesBatch satellites = Newtonsoft.Json.JsonConvert.DeserializeObject <SatellitesBatch>(json.ToString());
            bool            validation = false;

            if (satellites != null && satellites.Satellites.Count == 3)
            {
                foreach (SatelliteData sat in satellites.Satellites)
                {
                    validation = ValidateSatelliteData(sat);
                    if (!validation)
                    {
                        break;
                    }
                }
            }

            if (validation)
            {
                Calculate(satellites.Satellites);
            }

            return(new Response((ShipCoordinates != null && ShipMessage != null) ? 200 : 404, ShipCoordinates, ShipMessage));
        }