Esempio n. 1
0
        public static async Task ProcessQuotes(List <string> authors, int maxQuoteLength, string firebaseHost)
        {
            // Get max page numbers for every author
            PagingSpider pagingSpider = new PagingSpider(authors);

            pagingSpider.Run();

            // Convert the result to PagingEntity objects
            var pagingEntities = pagingSpider.CollectionEntityPipeline.ToEntityList <PagingEntity>();

            // Get all quotes from all pages for the author
            QuoteSpider quoteSpider = new QuoteSpider(pagingEntities.ToList())
            {
                ThreadNum = 4
            };

            quoteSpider.Run();

            // Convert the result to FirebaseQuote objects
            var firebaseQuotes = quoteSpider.CollectionEntityPipeline.ToFirebaseQuotes(maxQuoteLength);

            // Delete all existing quotes from firebase, then upload all quotes
            var firebaseService = new FirebaseService(firebaseHost);
            await firebaseService.ReUpload(firebaseQuotes, batchSize : 50);
        }
Esempio n. 2
0
        async void Login_Clicked(object sender, System.EventArgs e)
        {
            //NavigationPage nav = new NavigationPage(new MyTabbedPage());
            try
            {
                var user = await DependencyService.Get <IFirebaseAuthenticator>().LoginWithEmailPasswordAsync(emailEntry.Text, passwordEntry.Text);

                if (user != null)
                {
                    GeneralHelper.IsNotFirstLogin    = true;
                    SettingsService.LastUsedEmail    = emailEntry.Text;
                    SettingsService.LastUsedPassword = passwordEntry.Text;
                    FirebaseService.User             = user;

                    FirebaseService _firebaseService = new FirebaseService();
                    if (GeneralHelper.NotificationToken != null)
                    {
                        await _firebaseService.SendToken(GeneralHelper.NotificationToken);
                    }

                    await Navigation.PushModalAsync(new NavigationPage(new MyTabbedPage()));
                }
            }
            catch (Exception ex)
            {
                await DisplayAlert("Uyarı", ex.Message, "Tamam");
            }
        }
        private async Task <bool> CanSaveCategoryAsync()
        {
            if (Category == null)
            {
                return(false);
            }

            if (Category.CategoryName == "" || Category.CategoryName == null)
            {
                return(false);
            }

            if (States.Count == 0)
            {
                return(false);
            }

            if (States.FirstOrDefault(x => x.StateName == "") != null)
            {
                return(false);
            }
            if (!CanCreateState())
            {
                return(false);
            }

            return(await FirebaseService.IsCategoryNameAwailableAsync(Category));
        }
Esempio n. 4
0
        private async Task ShowItemsAsync()
        {
            List <ItemModel> items = new List <ItemModel>();

            Category.Items = new ObservableCollection <ItemModel>();
            if (SearchItem.ItemName != "")
            {
                items = await FirebaseService.GetItemsAsync(SearchItem, 20, null);
            }
            else if (VisibleState == States[0])
            {
                items = await FirebaseService.GetItemsAsync(Category, 20, null);
            }
            else
            {
                items = await FirebaseService.GetItemsAsync(VisibleState, 20, null);
            }

            foreach (var item in items)
            {
                var state = States.FirstOrDefault(x => x.StateID == item.StateID);
                item.State = state;
            }

            Category.Items = new ObservableCollection <ItemModel>(items);
        }
        private async void ViewLeaves()
        {
            try
            {
                //Todo----Optimize below code to run in lesser time.
                //todo----add suitable catch statement for this try.
                IsBusy    = true;
                IsVisible = false;
                ActivityIndicatorTitle = "Please wait while data is being loaded.";

                ListItems = new ObservableCollection <CalendarItem>();

                var x = await FirebaseService.GetAll(_month, _year);

                foreach (var item in x)
                {
                    ListItems.Add(item);
                }
            }
            finally
            {
                IsBusy = false;
                Title  = string.Join("\t", Title, string.Concat("(", _month, ' ', _year, ")"));
            }
        }
Esempio n. 6
0
        async Task ExecuteLoadStoriesCommand()
        {
            if (IsBusy)
            {
                return;
            }

            IsBusy = true;

            try
            {
                Stories.Clear();
                var stories = await FirebaseService.GetItemsAsync(true);

                foreach (var story in stories)
                {
                    Stories.Add(story);
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
            }
            finally
            {
                IsBusy = false;
            }
        }
Esempio n. 7
0
 public LoginPage()
 {
     NavigationPage.SetHasNavigationBar(this, false);
     NavigationPage.SetHasBackButton(this, false);
     InitializeComponent();
     service = new FirebaseService();
 }
        public static async System.Threading.Tasks.Task <IActionResult> Run([HttpTrigger] HttpRequest req, ILogger log)
        {
            log.LogInformation($"C# Timer trigger function executed at: {DateTime.Now}");

            var firebaseService  = new FirebaseService();
            var appCenterService = new AppCenterService(new HttpClient());

            var openWeatherService = new OpenWeatherService(new HttpClient());

            var notificacoes = await firebaseService.ObterNotificacoes();

            foreach (var notificacao in notificacoes)
            {
                var cidade = await openWeatherService.ObterClimaTempo(notificacao.Cidade);

                if (notificacao.DeveNotificarTemperaturaMinima(cidade.Principal.TemperaturaMinima))
                {
                    await appCenterService.AdicionarNotificacao(
                        new[] { notificacao.IdDispositivo }, "ClimaTempo",
                        "A temperatura caiu!",
                        $"Cidade de {notificacao.Cidade} com temperatura atual de {cidade.Principal.TemperaturaMinima}°.");
                }

                if (notificacao.DeveNotificarVentoVelocidadeMinima(Convert.ToDouble(cidade.Vento.Velocidade)))
                {
                    await appCenterService.AdicionarNotificacao(
                        new[] { notificacao.IdDispositivo }, "ClimaTempo",
                        "A velocidade do vendo caiu!",
                        $"Cidade de {notificacao.Cidade} com velocidade atual do vendo em {cidade.Vento.Velocidade}.");
                }
            }
            return(new OkObjectResult("OK"));
        }
Esempio n. 9
0
        /*****************************************************************/
        // METHODS
        /*****************************************************************/
        #region Methods

        /// <summary>
        /// Verify phone no.
        /// </summary>
        /// <param name="callBack">Callback for PCL</param>
        /// <param name="phoneNo">Phone no. to verify</param>
        /// <returns></returns>
        public Task <FirebaseResponse> VerifyPhoneNo(IFirebaseServiceCallBack callBack, string phoneNo)
        {
            this.FirebaseServiceCallBack = callBack;

            try
            {
                // Check if phone no. is white listed
                WhiteListedPhoneNo = FirebaseService.CheckForTestPhoneNo(phoneNo);
                // Verify phone no.
                PhoneAuthProvider.Instance.VerifyPhoneNumber(
                    phoneNo,
                    60,
                    TimeUnit.Seconds,
                    Activity,
                    this
                    );
                // Return response
                return(new Task <FirebaseResponse>(() => new FirebaseResponse(true)));
            }
            catch (Exception mes)
            {
                // Return exception
                return(new Task <FirebaseResponse>(() => new FirebaseResponse(mes.Message)));
            }
        }
Esempio n. 10
0
        private async Task CadastrarCommandAsync()
        {
            if (IsBusy)
            {
                return;
            }

            try
            {
                IsBusy = true;
                var userService = new FirebaseService();
                Result = await userService.RegistrarUsuario(Username, Password, Telefone, Email);

                if (Result)
                {
                    await Application.Current.MainPage.DisplayAlert("Sucesso", "Usuário Registrado", "Ok");

                    await Application.Current.MainPage.Navigation.PopToRootAsync();
                }
                else
                {
                    await Application.Current.MainPage.DisplayAlert("Erro", "Falha ao registrar usuário", "Ok");
                }
            }
            catch (Exception ex)
            {
                await Application.Current.MainPage.DisplayAlert("Erro", ex.Message, "Ok");
            }
            finally
            {
                IsBusy = false;
            }
        }
Esempio n. 11
0
        private async void Login()
        {
            try
            {
                ActivityIndicatorTitle = "Logging In. Please wait.";
                IsBusy = true;

                User userObject = PrismApplicationBase.Current.Container.Resolve(typeof(User)) as User;

                userObject.UserID   = _userId;
                userObject.Password = _password;
                userObject.UserName = await FirebaseService.GetUserNameAsync(_userId);

                if (!string.IsNullOrEmpty(await FirebaseService.LoginAsync(userObject)))
                {
                    await NavigationService.NavigateAsync("MainPage");
                }
                else
                {
                    await DialogService.DisplayAlertAsync("Log in failed !", "Incorrect ID or password. Please try again.", "OK");
                }
            }

            finally
            {
                IsBusy = false;
            }
        }
Esempio n. 12
0
        private async Task LoginCommandAsync()
        {
            if (IsBusy)
            {
                return;
            }

            try
            {
                IsBusy = true;
                var userService = new FirebaseService();
                Result = await userService.LoginUsuario(Username, Password);

                if (Result)
                {
                    MessagingCenter.Send <User>(this.User, "SucessoLogin");
                }
                else
                {
                    await Application.Current.MainPage.DisplayAlert("Erro", "Usuário/Senha inválido(s)", "Ok");
                }
            }
            catch (Exception ex)
            {
                await Application.Current.MainPage.DisplayAlert("Erro", ex.Message, "Ok");
            }
            finally
            {
                IsBusy = false;
            }
        }
Esempio n. 13
0
        private async Task RegistrarCommandAsync()
        {
            if (IsBusy)
            {
                return;
            }
            try
            {
                IsBusy = true;
                var firebaseService = new FirebaseService();
                Result = await firebaseService.AdicionarCatastrofe(this.Registrar);

                if (Result)
                {
                    await Application.Current.MainPage.DisplayAlert("Sucesso", "Desastre registrada com sucesso", "Ok");

                    MessagingCenter.Send(this.Registrar, "Registrar");
                }
                else
                {
                    await Application.Current.MainPage.DisplayAlert("Erro", "Falha ao registrar catástrofe", "Ok");
                }
            }
            catch (Exception ex)
            {
                await Application.Current.MainPage.DisplayAlert("Erro", ex.Message, "Ok");
            }
            finally
            {
                IsBusy = false;
            }
        }
Esempio n. 14
0
        public async Task <bool> PublishNew()
        {
            //get workouts from sheets
            var ws       = new SheetService();
            var workouts = (await ws.GetWorkouts()).EmptyIfNull().Where(wo => wo.Show == true);
            //get social calendars from sheets
            var socialCalendarIds = await ws.GetSocialCalendars();

            var extraCalendars = Mapper.Map <List <CalenderViewModel> >((await GetCalendarList()).Items);
            //factor out the all but social calendars
            var socialCalendars = extraCalendars.Where(cal => socialCalendarIds.EmptyIfNull().Select(s => s.CalendarID).Contains(cal.Id));

            var retVal = new List <CalenderViewModel>();

            retVal.AddRange(Mapper.Map <List <CalenderViewModel> >(workouts));
            retVal.AddRange(socialCalendars);

            var x = await retVal.ForkJoin(async cal => await GetThisWeekEventViewModels(cal));

            //todo: get items.

            //publish to firebase
            var fbSvc = new FirebaseService();
            await fbSvc.Publish(retVal, retVal.SelectMany(cal => cal.Items));

            return(retVal != null && retVal.Count > 0);
        }
Esempio n. 15
0
 public UsersController(MyContext context, IOptions <AppSettings> settings)
 {
     this._context   = context;
     this.apikey     = settings.Value.FirebaseApiKey;
     this.jwtService = new TokenService(this._context, settings);
     this.telBot     = new TelegramBot();
     this.auth       = new AuthService(context);
     this.firebase   = new FirebaseService(context, settings);
 }
Esempio n. 16
0
        private async Task <bool> CanSetCategoryNameAsync()
        {
            if (Category.CategoryName == "" || Category.CategoryName == null)
            {
                return(false);
            }

            return(await FirebaseService.IsCategoryNameAwailableAsync(Category));
        }
Esempio n. 17
0
 public LoginController(MyContext context, IOptions <AppSettings> settings)
 {
     this._context            = context;
     this.apikey              = settings.Value.FirebaseApiKey;
     this.currentConferenceId = settings.Value.CurrentConferenceID;
     this.jwtService          = new TokenService(this._context, settings);
     this.telBot              = new TelegramBot();
     this.fbService           = new FirebaseService(context, settings);
     this.auth = new AuthService(context);
 }
Esempio n. 18
0
        public void Test1()
        {
            FirebaseService firebaseService = new FirebaseService();
            var             activities      = firebaseService.OnceAsync <List <DayProgram> >("DayPrograms").Result[0];
            Activity        activita        = activities[(int)DateTime.Today.DayOfWeek]
                                              .Where(activity => activity.Start <= DateTime.Now.TimeOfDay).LastOrDefault();

            Assert.AreEqual("sleeping", activita.Name);
            Assert.AreEqual(TimeSpan.FromMinutes(1335), activita.Start);
        }
Esempio n. 19
0
        protected async override Task AddItems()
        {
            IEnumerable <IElement> elementsCollection = null;

            elementsCollection = new FirebaseService().GetUserFavorites(this.CurrentPosition, this.PageSize, user_id);

            foreach (IElement element in elementsCollection)
            {
                this.MyItems.Add(element);
            }
        }
Esempio n. 20
0
        public ShoppingListViewModel()
        {
            var service = new FirebaseService();
            Task <IReadOnlyCollection <FirebaseObject <ShoppingItem> > > items = service.GetShoppingListItems();

            ShoppingItems = new ObservableCollection <ShoppingItem>();

            foreach (var firebaseObject in items.Result)
            {
                ShoppingItems.Add(firebaseObject.Object);
            }
        }
 public MasterDetailView(Usuario usuario)
 {
     InitializeComponent();
     firebaseService = new FirebaseService();
     Produtos        = new ObservableCollection <ProdutoItemViewModel>();
     netService      = new NetService();
     this.usuario    = usuario;
     this.Master     = new MasterView(usuario);
     this.Detail     = new NavigationPage(new ConsultaProdutosView(usuario));
     carregarProdutos();
     // popularProdutos();
 }
Esempio n. 22
0
 private async Task <bool> CanSetItemNameAsync(ItemModel target)
 {
     if (target == null)
     {
         return(false);
     }
     if (target.ItemName == "")
     {
         return(false);
     }
     return(await FirebaseService.IsItemNameAwailableAsync(target));
 }
Esempio n. 23
0
        private async Task GetCategoryAsync(string categoryID)
        {
            if (!IsNewCategory)
            {
                await DialogService.DisplayPopupAsync();

                Category = await FirebaseService.GetCategoryAsync(categoryID);

                States = new ObservableCollection <StateModel>(await FirebaseService.GetStatesAsync(categoryID));
                await DialogService.PopAsync();
            }
        }
Esempio n. 24
0
        public MovieDetails(Movie movie, BackablePage moviesPage)
        {
            this.currentMovie = movie;
            this.moviesPage   = moviesPage;

            BindingContext = movie;

            FirebaseService firebaseService = new FirebaseService();

            IsFavourite = firebaseService.CheckIfIsFavourite(AccountManager.GetAccountId(), currentMovie).Result;

            InitializeComponent();
        }
Esempio n. 25
0
        public SongDetails(Song song, BackablePage songsPage)
        {
            this.currentSong = song;
            this.songsPage   = songsPage;

            BindingContext = song;

            FirebaseService firebaseService = new FirebaseService();

            IsFavourite = firebaseService.CheckIfIsFavourite(AccountManager.GetAccountId(), currentSong).Result;

            InitializeComponent();
        }
Esempio n. 26
0
        public BookDetails(Book book, BackablePage booksPage)
        {
            this.currentBook = book;
            this.booksPage   = booksPage;

            BindingContext = book;

            FirebaseService firebaseService = new FirebaseService();

            IsFavourite = firebaseService.CheckIfIsFavourite(AccountManager.GetAccountId(), currentBook).Result;

            InitializeComponent();
        }
        protected override void OnCreate(Bundle savedInstanceState)
        {
            TabLayoutResource = Resource.Layout.Tabbar;
            ToolbarResource   = Resource.Layout.Toolbar;

            base.OnCreate(savedInstanceState);

            Xamarin.Essentials.Platform.Init(this, savedInstanceState);
            XF.Material.Droid.Material.Init(this, savedInstanceState);
            Forms.SetFlags("CollectionView_Experimental");
            global::Xamarin.Forms.Forms.Init(this, savedInstanceState);
            LoadApplication(new App());
            FirebaseService.Init(this);
        }
Esempio n. 28
0
        async void Handle_Clicked(object sender, System.EventArgs e)
        {
            FirebaseService firebaseService = new FirebaseService();
            var             result          = await firebaseService.PostSurvey(_survey.Key, ((Choice)ChoiceList.SelectedItem).Key);

            if (result)
            {
                await DisplayAlert("Başarılı", "Anket oyunuz gönderilmiştir.", "Tamam");
            }
            else
            {
                await DisplayAlert("Başarısız", "Anket oyunuz gönderilemedi.", "Tamam");
            }
        }
Esempio n. 29
0
        private async Task SaveCategoryAsync()
        {
            if (!await CanSaveCategoryAsync())
            {
                return;
            }

            await DialogService.DisplayPopupAsync();

            var parameters = new NavigationParameters();

            if (IsUpdated)
            {
                parameters.Add("IsUpdated", true);
            }

            if (IsNewCategory)
            {
                var categoryID = await FirebaseService.InsertCategoryAsync(Category);

                for (int i = States.Count - 1; i >= 0; i--)
                {
                    States[i].CategoryID = categoryID;
                    await FirebaseService.InsertStateAsync(States[i]);
                }
            }
            else
            {
                await FirebaseService.UpdateCategoryAsync(Category);

                foreach (var state in States)
                {
                    if (state.StateID == null)
                    {
                        await FirebaseService.InsertStateAsync(state);
                    }
                    else
                    {
                        await FirebaseService.UpdateStateAsync(state);
                    }
                }
                foreach (var state in DeletedStates)
                {
                    await FirebaseService.DeleteStateAsync(state);
                }
            }
            await DialogService.PopAsync();

            await NavigationService.GoBackAsync(parameters);
        }
Esempio n. 30
0
        private async Task RefreshCategoriesAsync()
        {
            await DialogService.DisplayPopupAsync();

            var categoriesList = await FirebaseService.GetCategoriesAsync(20, null);

            if (categoriesList == null)
            {
                categoriesList = new List <CategoryModel>();
            }

            Categories = new ObservableCollection <CategoryModel>(categoriesList);
            await DialogService.PopAsync();
        }