Esempio n. 1
0
        protected async override void OnStart()
        {
            if (liteDB == null)
            {
                LiteDBHelper.StartLiteDB();
            }

            if (liteErrorLogDB == null)
            {
                LiteDBHelper.StartErrorLogLiteDB();
            }

            LiteDBHelper.MigrateLiteDB();

            // Handle when your app starts
            await ThemeManager.LoadThemeAsync();

            Jikan = new Jikan(useHttps: true);

            SettingsPreferences settings = StartSettings();

            if (settings.NotificationsIsOn && Device.RuntimePlatform == Device.Android)
            {
                await RunJobAsync(typeof(NotificationJob), WorkManagerConsts.AnimesNotificationWorkId);
            }


            //TODO: repetir o mesmo procedimento acima para essa parte, para o work de atualização de animes na lista de favoritos
            //(repetir também no BootBroadcastReceiver)
        }
Esempio n. 2
0
        /// <summary>
        /// Salva resultados da exceção em log liteDB
        /// </summary>
        /// <param name="exception"></param>
        public static void SaveExceptionData(this System.Exception exception)
        {
            var error = new ErrorLog()
            {
                Message           = exception.Message,
                Source            = exception.Source,
                StackTrace        = exception.StackTrace,
                ExceptionDate     = DateTime.Now,
                ExceptionTypeName = exception.GetType().ToString(),
            };

            switch (exception)
            {
            case JikanRequestException ex:

                string responseCode = $"{ex.ResponseCode} { (int)ex.ResponseCode}";
#if DEBUG
                Console.WriteLine($"Problema encontrado em :{responseCode}");
#endif
                DependencyService.Get <IToast>().MakeToastMessageLong(responseCode);

                error.AdditionalInfo = responseCode;

                break;

            case System.Exception exc:
#if DEBUG
                Console.WriteLine($"Problema encontrado em :{exc.Message}");
#endif
                DependencyService.Get <IToast>().MakeToastMessageLong(Lang.Lang.Error);

                break;
            }

            if (App.liteErrorLogDB == null)
            {
                LiteDBHelper.StartErrorLogLiteDB();
            }

            var errorLogCollection = App.liteErrorLogDB.GetCollection <ErrorLog>();
            errorLogCollection.Insert(error);

#if DEBUG
            foreach (var exc in errorLogCollection.FindAll())
            {
                Console.WriteLine($"exceção encontrada em: {exc.Id} {exc.ExceptionTypeName} {exc.Message}");
            }
#endif
        }