Esempio n. 1
0
        public async static Task DeleteAlert(int index)
        {
            var localAlerts = await GetAlerts();

            localAlerts.RemoveAt(index);
            await LocalStorageHelper.SaveObject(UserStorage.Alerts, localAlerts);
        }
Esempio n. 2
0
        private async Task Initialise(bool bForce = false)
        {
            this.SettingsButton.SetTitle(Config.Region == Config.RegionDef.UK ? "United Kingdom" : "Ireland", UIControlState.Normal);

            //this.AllFilmsButton.Enabled = this.AllCinemasButton.Enabled = false;

            this.BusyIndicator.StartAnimating();

            LocalStorageHelper lsh = new LocalStorageHelper();

            Console.WriteLine("Start data download " + DateTime.Now.ToLongTimeString());
            await lsh.DownloadFiles(bForce);

            Console.WriteLine("Start data deserialisation " + DateTime.Now.ToLongTimeString());
            await lsh.DeserialiseObjects();

            this.SearchButton.Enabled = true;

            Task tFilmData = LoadFilmData();

            Console.WriteLine("Initialisation complete " + DateTime.Now.ToLongTimeString());

            Application.UserLocation = locationManager.Location;

            LoadNearestCinemas();

            Console.WriteLine("Nearest cinemas loaded " + DateTime.Now.ToLongTimeString());

            this.BusyIndicator.StopAnimating();

            this.AllFilmsButton.Enabled = this.AllCinemasButton.Enabled = true;

            await tFilmData;
        }
Esempio n. 3
0
        private async void SettingsAlerts_Loaded(object sender, RoutedEventArgs e)
        {
            var alerts = await LocalStorageHelper.ReadObject <List <Alert> >(UserStorage.Alerts);

            vm.Alerts    = new ObservableCollection <Alert>(alerts);
            vm.CvsSource = from alert in vm.Alerts group alert by alert.Crypto;
        }
Esempio n. 4
0
        async public Task <bool> CreateUser()
        {
            if (IsValidateFields())
            {
                var existsEmail = await IsEmailExists(Email);

                if (existsEmail)
                {
                    MessageBox.Show("This email id already exists!", "SignUp", MessageBoxButton.OK, MessageBoxImage.Exclamation);
                    return(false);
                }
                var user = new User
                {
                    Id          = Guid.NewGuid(),
                    FirstName   = FirstName,
                    LastName    = LastName,
                    Email       = Email,
                    Password    = Password,
                    PhoneNumber = PhoneNumber,
                    UserType    = UserType.User
                };

                await LocalStorageHelper.InsertUser(user);

                return(true);
            }
            else
            {
                return(false);
            }
        }
Esempio n. 5
0
        private async Task Procces()
        {
            if (!this.IsNew)
            {
                await LocalStorageHelper.RewritePageFiles(this.PageToProcces);
            }

            var pr = new ImageProccesing();

            //var f = await ApplicationData.Current.LocalFolder.GetFileAsync(this.PageToProcces.FilePath);

            IList <Point> pnts = new List <Point>();

            pnts.Add(new Point(this.PointsData.LeftTopLinePoint.X * this.ScaleX,
                               this.PointsData.LeftTopLinePoint.Y * this.ScaleY));

            pnts.Add(new Point(this.PointsData.LeftBottomLinePoint.X * this.ScaleX,
                               this.PointsData.LeftBottomLinePoint.Y * this.ScaleY));

            pnts.Add(new Point(this.PointsData.RightBottomLinePoint.X * this.ScaleX,
                               this.PointsData.RightBottomLinePoint.Y * this.ScaleY));

            pnts.Add(new Point(this.PointsData.RightTopLinePoint.X * this.ScaleX,
                               this.PointsData.RightTopLinePoint.Y * this.ScaleY));

            pr.Quadraliteral(this.CapturedImage, pnts);

            await ApplicationData.Current.LocalFolder.CreateFileAsync(
                this.PageToProcces.ID.ToString() + "_processing" + ".jpg", CreationCollisionOption.ReplaceExisting);

            this.NavigationContext.NavigationService.GoBack();
        }
Esempio n. 6
0
        private static async Task Initialise(bool bForce = false)
        {
            LocalStorageHelper lsh = new LocalStorageHelper();
            await lsh.DownloadFiles(bForce);

            await lsh.DeserialiseObjects();
        }
Esempio n. 7
0
        public void Post([FromBody] ImageGalleryViewModel imageGalleryView)
        {
            if (!ModelState.IsValid)
            {
                Response.StatusCode = (int)HttpStatusCode.BadRequest;
                return;
            }

            ImageGallery imageGallery = imageGalleryView.ToBaseModel();

            // TODO: Convert user Id from Guid to String in DB
            Guid userCreated = new Guid(userManager.GetUserId(User));

            imageGallery.userCreated = userCreated;
            imageGallery.userChanged = userCreated;

            DateTime utcNow = DateTime.UtcNow;

            imageGallery.DateCreated = utcNow;
            imageGallery.DateChanged = utcNow;

            int imageGalleryId = imageGalleryBll.SaveImageGallery(imageGallery);

            // move images from temp folder
            if (imageGalleryId > 0 && imageGalleryView.createNew)
            {
                string tempFolderName = imageGallery.GetGalleryUniqueDir(imageGalleryView.tempGuid, true);
                string tempPath       = imageGalleryView.path;
                string storagePath    = imageGallery.GetGalleryUniquePath();

                LocalStorageHelper.MoveFromTempToStorage(storagePath, tempPath, tempFolderName);
            }
        }
Esempio n. 8
0
        private static async Task <PhotoPageArguements> GetPhotoPageArguements(StorageFile imageFile, bool isNewDocument = true)
        {
            var photoData = await PhotoCapturedData.CreatePhotoCapturedDataAsync(imageFile, ImageService.CategoryName);

            photoData.IsFromCamera = true;

            Page page = null;

            if (isNewDocument)
            {
                var createdDocument = await Document.CreateDocumentAsync(photoData);

                await SerializationProvider.Instance.AddDocument(createdDocument);

                page = createdDocument.Pages[0];
            }
            else
            {
                page = await Page.CreatePageAsync(photoData);
            }

            await LocalStorageHelper.CreatePageFiles(imageFile, page.ID);

            var photoPageArguements = new PhotoPageArguements()
            {
                PageToProcces = page,
                IsNew         = true,
            };

            return(photoPageArguements);
        }
Esempio n. 9
0
        private async Task CheckAlerts()
        {
            var localAlerts = await LocalStorageHelper.ReadObject <List <Alert> >(UserStorage.Alerts);

            var localSettings = new LocalSettings();
            var currency      = localSettings.Get <string>(UserSettings.Currency);

            var enabledAlerts = localAlerts.Where(x => x.Enabled).ToList();
            var alerts        = enabledAlerts.GroupBy(x => x.Crypto);

            /// More efficient: get price once for all alerts of the same crypto
            foreach (var alert in alerts)
            {
                var data = await Ioc.Default.GetService <ICryptoCompare>().GetPrice(alert.Key, currency);

                double price = double.Parse(data.Split(":")[1].Replace("}", ""));

                /// Go check each alert, and if the user is notified, disable it not to spam
                foreach (var a in alert)
                {
                    if (CheckAlert(a, price))
                    {
                        localAlerts[localAlerts.IndexOf(a)].Enabled = false;
                    }
                }
            }
            await LocalStorageHelper.SaveObject(UserStorage.Alerts, localAlerts);
        }
Esempio n. 10
0
        // ###############################################################################################
        internal async static Task GetCoinList()
        {
            // check cache before sending an unnecesary request
            var date = _LocalSettings.Get <double>(UserSettings.CoinListsDate);

            DateTime lastUpdate = DateTime.FromOADate((double)date);
            var      days       = DateTime.Today.CompareTo(lastUpdate);

            coinListPaprika = await LocalStorageHelper.ReadObject <List <CoinPaprikaCoin> >(UserStorage.CacheCoinPaprika);

            coinListGecko = await LocalStorageHelper.ReadObject <List <CoinGeckoCoin> >(UserStorage.CacheCoinGecko);

            // if empty list OR old cache -> refresh
            if (coinListPaprika.Count == 0 || coinListGecko.Count == 0 || days > 7)
            {
                coinListPaprika = await Ioc.Default.GetService <ICoinPaprika>().GetCoinList_();

                coinListGecko = await Ioc.Default.GetService <ICoinGecko>().GetCoinList_();

                _LocalSettings.Set(UserSettings.CoinListsDate, DateTime.Today.ToOADate());
                await LocalStorageHelper.SaveObject(UserStorage.CacheCoinPaprika, coinListPaprika);

                await LocalStorageHelper.SaveObject(UserStorage.CacheCoinGecko, coinListGecko);
            }
        }
Esempio n. 11
0
        async public Task <bool> CreateUser()
        {
            if (await IsValidateSignupFields())
            {
                var existsEmail = await IsEmailExists(Email);

                if (existsEmail)
                {
                    await _alertView.Show("This email id already exists!");

                    return(false);
                }
                var user = new User
                {
                    Id          = Guid.NewGuid(),
                    FirstName   = FirstName,
                    LastName    = LastName,
                    Email       = UserEmail,
                    Password    = NewPassword,
                    PhoneNumber = PhoneNumber,
                    UserType    = UserType.User
                };

                await LocalStorageHelper.InsertUser(user);

                return(true);
            }
            else
            {
                return(false);
            }
        }
Esempio n. 12
0
        async public Task <bool> Login()
        {
            bool isLoggedIn = false;

            if (await IsValidateLoginFields())
            {
                var users = await LocalStorageHelper.GetUsers();

                var user = users.SingleOrDefault(p => p.Email == Email);
                if (user != null)
                {
                    if (user.Password != Password)
                    {
                        await _alertView.Show("Password is incorect");

                        isLoggedIn = false;
                    }
                    else
                    {
                        isLoggedIn = true;
                    }
                }
                else
                {
                    await _alertView.Show("Inavlid user credentials!");

                    isLoggedIn = false;
                }
            }

            return(isLoggedIn);
        }
Esempio n. 13
0
        public async static Task AddPurchase(PurchaseModel purchase)
        {
            var portfolio = await GetPortfolio();

            portfolio.Add(purchase);
            await LocalStorageHelper.SaveObject(UserStorage.Portfolio6, portfolio);
        }
Esempio n. 14
0
        public static async Task <List <CmcCoin> > GetCmcCoins_(this IGithub service)
        {
            try {
                var response = await service.GetCmcCoins();

                return(response);

                //return JsonSerializer.Deserialize<List<CoinGeckoCoin>>(response.ToString());

                //coinList.Sort((x, y) => x.Symbol.CompareTo(y.Symbol));

                // Save on Local Storage, and save the Date
                await LocalStorageHelper.SaveObject("CoinList", response);

                //App._LocalSettings.Set(UserSettings.CoinListDate, DateTime.Today.ToOADate());

                return(new List <CmcCoin>());
            }
            catch (Exception ex) {
                //return new List<CmcCoin>();
                await new MessageDialog(ex.Message).ShowAsync();
                return(new List <CmcCoin>()
                {
                    new CmcCoin()
                    {
                        id = 1,
                        name = "Erro",
                        symbol = "ERR",
                        rank = 1
                    }
                });
            }
        }
        /// <summary>
        /// Invoked when the application is launched normally by the end user.  Other entry points
        /// will be used such as when the application is launched to open a specific file.
        /// </summary>
        /// <param name="e">Details about the launch request and process.</param>
        protected override async void OnLaunched(LaunchActivatedEventArgs e)
        {
            Frame rootFrame = Window.Current.Content as Frame;

            // Do not repeat app initialization when the Window already has content,
            // just ensure that the window is active
            if (rootFrame == null)
            {
                // Create a Frame to act as the navigation context and navigate to the first page
                rootFrame = new Frame();
                // Set the default language
                rootFrame.Language = Windows.Globalization.ApplicationLanguages.Languages[0];

                rootFrame.NavigationFailed += OnNavigationFailed;

                // Place the frame in the current Window
                Window.Current.Content = rootFrame;
            }

            // Switching decision between pages
            if (string.IsNullOrEmpty(e.Arguments))
            {
                // Register for notifications
                await RegisterPushNotifications("kinect-VOD-tutorial",
                                                "Endpoint=sb://kinect-demo.servicebus.windows.net/;SharedAccessKeyName=ListenPolicy;SharedAccessKey=KWaGKpa38A7ymRLDk/7qpTpZmla3nfmWN1AWto2R3zY=",
                                                "new-video-template",
                                                string.Format("$({0})", "RecordingData"),
                                                "New recorded video",
                                                string.Format("$({0})", "Caption"),
                                                "http://www.kinectingforwindows.com/images/notification_logo.png");

                // Navigate to the overview page
                rootFrame.Navigate(typeof(MainPage));
            }
            else
            {
                // Deserialize to RD
                RecordingData data = e.Arguments.DeserializeFromJson <RecordingData>();

                // Load recording history on first run
                if (_recordingHistory == null)
                {
                    _recordingHistory = await LocalStorageHelper.LoadFileContentAsync <ObservableCollection <RecordingData> >(RecordingFileName) ??
                                        new ObservableCollection <RecordingData>();
                }
                // Add to the list
                _recordingHistory.Add(data);

                // Save the new list locally
                await LocalStorageHelper.SaveFileContentAsync(RecordingFileName, _recordingHistory);

                // Navigate to the video page
                rootFrame.Navigate(typeof(VideoPage), data);
            }

            // Ensure the current window is active
            Window.Current.Activate();
        }
Esempio n. 16
0
        private async void Page_Loaded(object sender, RoutedEventArgs e)
        {
            // Read from the cache
            var coinMarket = await LocalStorageHelper.ReadObject <List <CoinMarket> >(UserStorage.CoinsCache);

            vm.CoinMarket = new ObservableCollection <CoinMarket>(coinMarket);

            await UpdatePage();
        }
Esempio n. 17
0
        private async Task LoadCinemaDetails()
        {
            Task taskCinemaFilmListing = null;

            if (SelectedFilm.Performances == null || SelectedFilm.Performances.Count == 0)
            {
                taskCinemaFilmListing = new LocalStorageHelper().GetCinemaFilmListings(SelectedCinema.ID);
            }

            if (pMain.Items.Contains(piFilmDetails))
            {
                this.pMain.Items.Remove(piFilmDetails);
            }

            if (pMain.Items.Contains(piCast))
            {
                this.pMain.Items.Remove(piCast);
            }

            if (pMain.Items.Contains(piReviews))
            {
                this.pMain.Items.Remove(piReviews);
            }

            if (!pMain.Items.Contains(piCinema))
            {
                pMain.Items.Add(piCinema);
            }

            ShellTile TileToFind = ShellTile.ActiveTiles.FirstOrDefault(x => x.NavigationUri.ToString().Contains(String.Format("CinemaID={0}", SelectedCinema.ID)));

            this.ApplicationBar.Buttons.Add(this.abibDirections);

            if (TileToFind == null)
            {
                this.ApplicationBar.Buttons.Add(this.abibPin);
            }

            if (Config.FavCinemas.Contains(SelectedCinema.ID))
            {
                this.ApplicationBar.Buttons.Add(this.abibRemFav);
            }
            else
            {
                this.ApplicationBar.Buttons.Add(this.abibAddFav);
            }

            this.ApplicationBar.Buttons.Add(this.abibShare);

            if (taskCinemaFilmListing != null)
            {
                await taskCinemaFilmListing;

                SelectedFilm = App.CinemaFilms[SelectedCinema.ID].First(f => f.EDI == SelectedFilm.EDI);
            }
        }
Esempio n. 18
0
 public JwtProvider(
     HttpClient httpClient,
     LocalStorageOption localStorageOption,
     LocalStorageHelper localStorageHelper
     )
 {
     _httpClient         = httpClient;
     _localStorageOption = localStorageOption;
     _localStorageHelper = localStorageHelper;
 }
Esempio n. 19
0
        public async Task UpdatePage()
        {
            vm.GlobalStats = await CoinGecko.GetGlobalStats();

            var market = await Ioc.Default.GetService <ICoinGecko>().GetCoinsMarkets_();

            market        = market.OrderBy(x => x.market_cap_rank).ToList();
            vm.CoinMarket = new ObservableCollection <CoinMarket>(market);

            await LocalStorageHelper.SaveObject(UserStorage.CoinsCache, vm.CoinMarket);
        }
Esempio n. 20
0
        public async static Task <List <PurchaseModel> > GetPortfolio(string filterCrypto = "")
        {
            var portfolio = await LocalStorageHelper.ReadObject <List <PurchaseModel> >(UserStorage.Portfolio6);

            if (filterCrypto != "")
            {
                portfolio = portfolio.Where(p => p.Crypto == filterCrypto).ToList();
            }

            return((portfolio.Count == 0) ? new List <PurchaseModel>() : portfolio);
        }
Esempio n. 21
0
        protected async override void OnNavigatedTo(NavigationEventArgs e)
        {
            tokens = LocalStorageHelper.GetAllItemsFromList();

            if (tokens.Count > 0)
            {
                foreach (var token in tokens.ToList())
                {
                    var folder = await FolderFileHelper.GetFolderForToken(token);

                    PopulateGrid(folder);
                }
            }
        }
Esempio n. 22
0
        public ActionResult Create([Bind(Include = "Id,Name,UnitPrice,InStock,Description,Image,CategoryId")] ProductViewModel productViewModel)
        {
            if (ModelState.IsValid)
            {
                // check if image was not uploaded
                if (productViewModel.Image == null)
                {
                    ModelState.AddModelError("Image", "A Product image is mandatory.");

                    ViewBag.CategoryId = new SelectList(_uow.Categories.GetAll(), "Id", "Name", productViewModel.CategoryId);

                    return(View(productViewModel));
                }

                productViewModel.Id = Guid.NewGuid();

                // save image and get final path
                var pathResult = LocalStorageHelper.SaveImage(productViewModel.Image, ImageCategory.Products, productViewModel.Id.ToString());

                // check if image saving was successful
                if (string.IsNullOrEmpty(pathResult))
                {
                    ModelState.AddModelError("Image", "Invalid image extension");

                    ViewBag.CategoryId = new SelectList(_uow.Categories.GetAll(), "Id", "Name", productViewModel.CategoryId);

                    return(View(productViewModel));
                }

                // create new product
                var product = new Product
                {
                    Id          = productViewModel.Id,
                    Name        = productViewModel.Name,
                    CategoryId  = productViewModel.CategoryId,
                    InStock     = productViewModel.InStock,
                    Description = productViewModel.Description,
                    Image       = pathResult,
                    UnitPrice   = productViewModel.UnitPrice
                };

                // save the new product
                _uow.Products.Add(product);
                _uow.Complete();
                return(RedirectToAction("Index"));
            }

            ViewBag.CategoryId = new SelectList(_uow.Categories.GetAll(), "Id", "Name", productViewModel.CategoryId);
            return(View(productViewModel));
        }
        private static async Task<RemoteRenderingServiceProfileFileData> TryLoadFromOverrideFile()
        {
            RemoteRenderingServiceProfileFileData fileData = null;
            try
            {
                fileData = await LocalStorageHelper.Load<RemoteRenderingServiceProfileFileData>(DefaultOverrideFilePath);
            }
            catch (Exception ex)
            {
                Debug.LogFormat(LogType.Warning, LogOption.NoStacktrace, null, "{0}",  $"Failed to load data from override file '{DefaultOverrideFilePath}'. Reason: {ex.Message}.");
            }

            return fileData;
        }
Esempio n. 24
0
        public async static void UpdateOneCryptoAlerts(string crypto, ObservableCollection <Alert> alerts)
        {
            var localAlerts = await GetAlerts();

            foreach (var alert in localAlerts.ToList())
            {
                if (alert.Crypto == crypto)
                {
                    localAlerts.Remove(alert);
                }
            }
            localAlerts.AddRange(alerts);
            await LocalStorageHelper.SaveObject(UserStorage.Alerts, localAlerts);
        }
Esempio n. 25
0
        public static async Task SavePortfolio(object portfolio)
        {
            var type = portfolio.GetType();

            if (type == typeof(List <PurchaseModel>))
            {
                await LocalStorageHelper.SaveObject(UserStorage.Portfolio6, portfolio);
            }
            else if (type == typeof(ObservableCollection <PurchaseModel>))
            {
                var p = new List <PurchaseModel>((ObservableCollection <PurchaseModel>)portfolio);
                await LocalStorageHelper.SaveObject(UserStorage.Portfolio6, p);
            }
        }
        private static async Task<FileData> TryLoadFromDeployedFile()
        {
            FileData fileData = default;
            try
            {
                fileData = await LocalStorageHelper.Load<FileData>(DefaultDeployedFilePath);
            }
            catch (Exception ex)
            {
                Debug.LogFormat(LogType.Warning, LogOption.NoStacktrace, null, "{0}", $"Failed to load data from account file '{DefaultDeployedFilePath}'. Reason: {ex.Message}.");
            }

            return fileData;
        }
Esempio n. 27
0
        private static async Task <FileData> TryLoadFromOverrideFile()
        {
            FileData fileData = default;

            try
            {
                fileData = await LocalStorageHelper.Load <FileData>(DefaultOverrideFilePath);
            }
            catch (Exception ex)
            {
                Debug.LogFormat(LogType.Error, LogOption.NoStacktrace, null, "{0}", $"Failed to load data from override file '{DefaultOverrideFilePath}'. Reason: {ex.Message}.");
            }

            return(fileData);
        }
Esempio n. 28
0
        /// <summary>
        /// Invoked when application execution is being suspended.  Application state is saved
        /// without knowing whether the application will be terminated or resumed with the contents
        /// of memory still intact.
        /// </summary>
        /// <param name="sender">The source of the suspend request.</param>
        /// <param name="e">Details about the suspend request.</param>
        private async void OnSuspending(object sender, SuspendingEventArgs e)
        {
            var deferral = e.SuspendingOperation.GetDeferral();
            //TODO: Save application state and stop any background activity
            var stocks = ViewModelLocator.Container.Resolve <IList <Stock> >();

            LocalStorageHelper.Data.Clear();
            foreach (var item in stocks)
            {
                LocalStorageHelper.Data.Add(item);
            }
            await LocalStorageHelper.Save <Stock>();

            deferral.Complete();
        }
Esempio n. 29
0
        /// <summary>
        /// Attempt to save the profile to the Override File Path.
        /// </summary>
        /// <param name="fallback"></param>
        /// <returns></returns>
        public static async Task Save(RemoteRenderingServiceProfile data)
        {
            if (data == null)
            {
                return;
            }

            try
            {
                await LocalStorageHelper.Save(DefaultOverrideFilePath, CreateFileData(data));
            }
            catch (Exception ex)
            {
                Debug.LogFormat(LogType.Warning, LogOption.NoStacktrace, null, $"Failed to save override file. Reason: {ex.Message}.");
            }
        }
        private async void LoadData()
        {
            this.randomStockData = new ObservableCollection <Stock>(await LocalStorageHelper.GetRandomStockData());
            await LocalStorageHelper.Restore <Stock>();

            if (LocalStorageHelper.Data.Count > 0)
            {
                foreach (Stock item in LocalStorageHelper.Data)
                {
                    this.Stocks.Add(item);
                }
            }
            else
            {
                this.Stocks.Add(this.GetNewStock("MSFT"));
            }
        }