Esempio n. 1
0
        public async Task Test_Return_City_isNotNull()
        {
            // Arrange
            var local = await ServiceHttp.GetCity(-23.620635, -46.607222).ConfigureAwait(false);

            // Assert
            Assert.IsNotNull(local);
        }
Esempio n. 2
0
        internal async void ThisOnAppearing()
        {
            try
            {
                IsLoad = true;

                // verifica se tem internet
                if (Connectivity.NetworkAccess != NetworkAccess.Internet)
                {
                    await App.Current.MainPage.DisplayAlert("Informativo", "Sem Conexão com a Internet.", "ok");

                    return;
                }

                var location = await Geolocation.GetLastKnownLocationAsync();

                // pegou uma localização?
                if (location != null)
                {
                    Local = await ServiceHttp.GetCity(location.Latitude, location.Longitude).ConfigureAwait(false);

                    WeatherLocal = await ServiceHttp.GetWeather(location.Latitude, location.Longitude).ConfigureAwait(false);

                    Temperature     = Math.Round(WeatherLocal.Currently.Temperature, 0).ToString();
                    SensacaoTermica = Math.Round(WeatherLocal.Currently.ApparentTemperature, 0).ToString();
                    VentoVelocidade = Math.Round(WeatherLocal.Currently.WindSpeed, 2).ToString();
                    var list = WeatherLocal.Daily.Data;
                    Summary = WeatherLocal.Currently.Summary;

                    int cont = 1;
                    foreach (Datum datum in list)
                    {
                        if (cont == 7)
                        {
                            break;
                        }

                        datum.Day = String.Format(new CultureInfo("pt-BR"), "{0:dddd }", DateTime.Now.AddDays(cont));
                        Dailys.Add(datum);
                        cont++;
                    }
                }
                else
                {
                    Temperature = "-";
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.Message);
            }
            finally
            {
                IsLoad = false;
            }
        }
Esempio n. 3
0
        public async Task Test_Return_City_equals_sao_paulo()
        {
            // Arrange
            var local = await ServiceHttp.GetCity(-23.620635, -46.607222).ConfigureAwait(false);

            //Act
            var very_local = "São Paulo";

            // Assert
            Assert.AreSame(local, very_local);
        }
Esempio n. 4
0
        /// <summary>
        /// Добавить новый сервис
        /// </summary>
        /// <param name="xmlnode">секция конфигурации</param>
        public IService AddService(XmlNode xmlnode)
        {
            IService srv = null;
            //Выберем адаптер по типу
            String _type    = xmlnode.Attributes["type"].Value;
            bool   _enabled = true;

            try
            {
                _enabled = Convert.ToBoolean(xmlnode.Attributes["enabled"].Value);
                //Не загружать сервис
                if (!_enabled)
                {
                    return(null);
                }
            }
            catch (Exception e) { }

            String _description = "";

            try
            {
                _description = xmlnode.Attributes["description"].Value;
            }
            catch { }
            switch (_type.ToLower())
            {
            case "mssql":
                srv = new ServiceMSSQL();
                break;

            case "oracle":
                srv = new ServiceOracle();
                break;

            case "oledb":
                srv = new ServiceOleDb();
                break;

            case "snapshot":
                srv = new ServiceSnapshot();
                break;

            case "alert":
                srv = new ServiceAlert();
                break;

            case "http":
                srv = new ServiceHttp();
                break;

            case "exec":
                srv = new ServiceExec();
                break;

            case "timer":
                srv = new ServiceDelay();
                break;

            case "dll":
                srv = new ServiceDll();
                break;

            case "xml2mssql":
                srv = new ServiceXml2MSSQL();
                break;

            case "custom":
                String _assembly = "";
                //_assembly = xmlnode.Attributes["assembly"].Value;
                //Взять из раздела Init
                _type     = _assembly = xmlnode.ChildNodes[0].Attributes["type"].Value;
                _assembly = xmlnode.ChildNodes[0].Attributes["assembly"].Value;
                Assembly asmbl = Assembly.LoadFrom(_assembly);
                srv = (IService)asmbl.CreateInstance(_type, true);
                break;

            default:
                return(null);
            }
            srv.Server      = _server;
            srv.Name        = xmlnode.Attributes["name"].Value;
            srv.Description = _description;
            srv.Init(xmlnode.SelectSingleNode("init"));

            //Внесём его в коллекцию
            if (_services == null)
            {
                _services = new IService[1];
            }
            else
            {
                int        cnt = _services.Length;
                IService[] old = _services;
                _services = new IService[cnt + 1];
                old.CopyTo(_services, 0);
            }
            srv.Id = _services.Length - 1;
            _services[_services.GetUpperBound(0)] = srv;
            return(srv);
        }