Ejemplo n.º 1
0
        //method for reading all configs
        public List <NLogConfigurationDefinition> GetConfigs()
        {
            _logger.Info($"Method for reading all NLog configurations fired.");

            try
            {
                return(_realm.All <NLogConfigurationDefinition>().ToList().OrderBy(x => x.Identity).ToList());
            }
            catch (Exception ex)
            {
                _logger.Error($"Error while trying read list NLog configs list: {ex.Message}.");
                return(new List <NLogConfigurationDefinition>());
            }
        }
        public List <S7PlcConnectionDefinition> GetAllS7Connections()
        {
            _logger.Info($"Method for reading all S7 connections fired.");

            try
            {
                return(_realm.All <S7PlcConnectionDefinition>().ToList().OrderBy(x => x.PLCconnectionID).ToList());
            }
            catch (Exception ex)
            {
                _logger.Error($"Error while trying read list of all S7 connections from DB: {ex.Message}.");
                return(new List <S7PlcConnectionDefinition>());
            }
        }
Ejemplo n.º 3
0
        public List <StopsRealmModel> GetAll()
        {
            try
            {
                var model = _realm.All <StopsRealmModel>().OrderBy((arg) => arg.stop_name).ToList();

                return(model);
            }
            catch (Exception pException)
            {
                System.Diagnostics.Debug.WriteLine("Error StopsDataLayerRealm->GetAll " + pException.Message);
            }
            return(null);
        }
Ejemplo n.º 4
0
        public List <SMSrecipientDefinition> GetAllActualRecipients()
        {
            _logger.Info($"Methd for reading all SMS recipients fired.");

            try
            {
                return(_realm.All <SMSrecipientDefinition>().ToList().OrderBy(x => x.Identity).ToList());
            }
            catch (Exception ex)
            {
                _logger.Error($"Error while trying read list of all SMS recipients: {ex.Message}.");
                return(new List <SMSrecipientDefinition>());
            }
        }
Ejemplo n.º 5
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            // Create your application here
            string pname = Intent.GetStringExtra("productName");

            System.Console.WriteLine("pname is :" + pname);

            SetContentView(Resource.Layout.cartLayout);
            spinView  = FindViewById <Spinner>(Resource.Id.spin);
            cartItems = FindViewById <ListView>(Resource.Id.cartList);
            text      = FindViewById <TextView>(Resource.Id.cartTxt);

            userName = Intent.GetStringExtra("nameValue");

            var config = new RealmConfiguration()
            {
                SchemaVersion = 1
            };

            realmObj = Realm.GetInstance(config);

            var productdata = realmObj.All <products>();


            var cartData = realmObj.All <cartProducts>();

            foreach (var temp in productdata)
            {
                var list = new cartProducts();
                if (pname == temp.Name)
                {
                    list.cartIName     = temp.Name;
                    list.cartIQuantity = "1";
                    Items.Add(list);
                }
            }

            ArrayAdapter spinAdapter = new ArrayAdapter(this, Android.Resource.Layout.SimpleListItem1, spinnerValue);

            spinView.Adapter = spinAdapter;

            spinView.ItemSelected += spinnerSelection;


            var cartList = new cartAdapter(this, Items);

            cartItems.SetAdapter(cartList);
        }
Ejemplo n.º 6
0
        private List <AlarmLanguagesDefinition> GetAllAlarmsForConnection(int plcConnectionID)
        {
            _logger.Info($"Starting to return all alarm texts for PLC connection with ID: {plcConnectionID}.");

            try
            {
                return(_realm.All <AlarmLanguagesDefinition>().Where(x => x.PLCconnectionID == plcConnectionID).ToList().OrderBy(x => x.AlarmIdentity).ToList());
            }
            catch (Exception ex)
            {
                _logger.Error($"Failed to read list af all alarm texts for PLC connection with ID: {plcConnectionID}. Exception: {ex.Message}.");
                return(new List <AlarmLanguagesDefinition>());
            }
        }
Ejemplo n.º 7
0
        public List <GeoComuniITRealmModel> GetAll()
        {
            try
            {
                var model = _realm.All <GeoComuniITRealmModel>().OrderBy((arg) => arg.DenominazioneInItaliano).ToList();

                return(model);
            }
            catch (Exception pException)
            {
                System.Diagnostics.Debug.WriteLine("Error GeoComuniITDataLayerRealm->GetAll " + pException.Message);
            }
            return(null);
        }
        public long QueryThousand()
        {
            Clear();
            InsertThousandItems();

            var watch = Stopwatch.StartNew();

            var results = _realm.All <Person>().Where(c => c.Id > 0).ToList();

            watch.Stop();

            System.Diagnostics.Debug.WriteLine($"Elapsed: {watch.ElapsedMilliseconds}");
            return(watch.ElapsedMilliseconds);
        }
Ejemplo n.º 9
0
        public async System.Threading.Tasks.Task GetsSyncedTasks()
        {
            User user = app.LogInAsync(Credentials.Anonymous()).Result;

            config = new SyncConfiguration("My Project", user);
            Realm realm = await Realm.GetInstanceAsync(config);

            var tasks = realm.All <RealmTask>();

            Assert.AreEqual(1, tasks.Count());
            tasks = realm.All <RealmTask>().Where(t => t.Status == "Open");
            Assert.AreEqual(1, tasks.Count());
            return;
        }
        public List <GeoCountriesRealmModel> GetAll()
        {
            try
            {
                var model = _realm.All <GeoCountriesRealmModel>().OrderBy((arg) => arg.nome_stato).ToList();

                return(model);
            }
            catch (Exception pException)
            {
                System.Diagnostics.Debug.WriteLine("Error GeoCountriesDataLayerRealm->GetAll " + pException.Message);
            }
            return(null);
        }
Ejemplo n.º 11
0
        public List <TipoTitoloEvasoRealmModel> GetAll()
        {
            try
            {
                var model = _realm.All <TipoTitoloEvasoRealmModel>().OrderBy((arg) => arg.IDTipoTitoloEvaso).ToList();

                return(model);
            }
            catch (Exception pException)
            {
                System.Diagnostics.Debug.WriteLine("Error TipoTitoloEvasoDataLayerRealm->GetAll " + pException.Message);
            }
            return(null);
        }
Ejemplo n.º 12
0
        //method for getting full ist of alarm profiles - main definitions
        public List <AlarmProfileDefinition> GetListOfAllProfiles()
        {
            _logger.Info($"Method for reading full list of profiles fired.");

            try
            {
                return(_realm.All <AlarmProfileDefinition>().ToList().OrderBy(x => x.Identity).ToList());
            }
            catch (Exception ex)
            {
                _logger.Error($"Error while trying read list of alarm profiles from DB: {ex.Message}.");
                return(new List <AlarmProfileDefinition>());
            }
        }
Ejemplo n.º 13
0
        public List <MotiviSanzioniRealmModel> GetAll()
        {
            try
            {
                var model = _realm.All <MotiviSanzioniRealmModel>().OrderBy((arg) => arg.NumeroVerbali).ToList();

                return(model);
            }
            catch (Exception pException)
            {
                System.Diagnostics.Debug.WriteLine("Error MotiviSanzioniDataLayerRealm->GetAll " + pException.Message);
            }
            return(null);
        }
Ejemplo n.º 14
0
        private void Toggle(string destination)
        {
            IsFullTabSelected = (destination == ListTabs.FULL);

            if (IsFullTabSelected)
            {
                Entries = _realm.All <VocabEntry>();
            }
            else
            {
                Entries = _realm.All <VocabEntry>().Where(x => x.IsBookmarked);
            }
            OnPropertyChanged(nameof(Entries));
        }
Ejemplo n.º 15
0
        public List <CalendarDatesRealModel> GetAll()
        {
            try
            {
                var model = _realm.All <CalendarDatesRealModel>().OrderBy((arg) => arg.service_id).ToList();

                return(model);
            }
            catch (Exception pException)
            {
                System.Diagnostics.Debug.WriteLine("Error CalendarDatesDataLayerRealm->GetAll " + pException.Message);
            }
            return(null);
        }
Ejemplo n.º 16
0
        public void ResultsShouldSendNotifications()
        {
            var       query   = _realm.All <Person>();
            ChangeSet changes = null;
            NotificationCallbackDelegate <Person> cb = (s, c, e) => changes = c;

            using (query.SubscribeForNotifications(cb))
            {
                _realm.Write(() => _realm.CreateObject <Person>());

                TestHelpers.RunEventLoop();
                Assert.That(changes, Is.Not.Null);
                Assert.That(changes.InsertedIndices, Is.EquivalentTo(new int[] { 0 }));
            }
        }
Ejemplo n.º 17
0
        //Realm.DeleteRealm(RealmConfiguration.DefaultConfiguration);

        //   private Transaction transaction;
        //public void BeginWrite()
        //{
        //	transaction = realm.BeginWrite();
        //}
        //public void AddItem()
        //{
        //	transaction = realm.BeginWrite();
        //}
        //public void EndWrite()
        //{
        //	transaction.Commit();
        //	transaction.Dispose();
        //}


        public ItemData GetItem(int id, ItemType itemType = ItemType.Matter)
        {
            if (realm == null)
            {
                InitRealm();
            }
            if (itemType > ItemType._PW_STARTS_HERE_)
            {
                return(realm.All <ItemData>().FirstOrDefault(i => i.Id == id && i.iListType == (int)itemType));
            }
            else
            {
                return(realm.All <ItemData>().FirstOrDefault(i => i.Id == id && i.iItemType == (int)itemType));
            }
        }
Ejemplo n.º 18
0
        public async Task <IEnumerable <Song> > GetAllAsync(bool forceRefresh = false)
        {
            try
            {
                var songs = realm.All <Song>().AsEnumerable <Song>();
                return(await Task.FromResult(songs));
            }
            catch (Exception e)
            {
                Debug.WriteLine("Something went wrong with getting all the songs from the datastore. SONGREALMDATASTORE.cs");
                Debug.WriteLine(e.Message);

                return(Enumerable.Empty <Song>());
            }
        }
Ejemplo n.º 19
0
        public IQueryable <ProfileRealm> ToRealmResults(Realm realm)
        {
            ParameterExpression parameterExpression;
            // ISSUE: method reference
            // ISSUE: method reference
            // ISSUE: field reference
            TokenInfoRealm tokenInfo = ((IQueryable <TokenInfoRealm>)realm.All <TokenInfoRealm>()).Where <TokenInfoRealm>(Expression.Lambda <Func <TokenInfoRealm, bool> >((Expression)Expression.AndAlso((Expression)Expression.OrElse(x.InstituteUserId == this._instituteUserId, (Expression)Expression.Equal(x.TutelaryId, (Expression)Expression.Call(this._instituteUserId, (MethodInfo)MethodBase.GetMethodFromHandle(__methodref(int.ToString)), Array.Empty <Expression>()))), (Expression)Expression.Equal((Expression)Expression.Convert((Expression)Expression.Property((Expression)parameterExpression, (MethodInfo)MethodBase.GetMethodFromHandle(__methodref(TokenInfoRealm.get_Role))), typeof(int)), (Expression)Expression.Field((Expression)Expression.Constant((object)this, typeof(GetProfileByUserIdAndInstituteCodeSpecification)), FieldInfo.GetFieldFromHandle(__fieldref(GetProfileByUserIdAndInstituteCodeSpecification._userRole))))), parameterExpression)).FirstOrDefault <TokenInfoRealm>();
            InstituteRealm institute = (InstituteRealm)realm.Find <InstituteRealm>(this._instituteCode);

            if (tokenInfo == null)
            {
                return(Enumerable.Empty <ProfileRealm>().AsQueryable <ProfileRealm>());
            }
            return(((IQueryable <ProfileRealm>)realm.All <ProfileRealm>()).Where <ProfileRealm>((Expression <Func <ProfileRealm, bool> >)(x => x.Institute == institute && x.TokenInfo == tokenInfo)));
        }
Ejemplo n.º 20
0
        public async Task <bool> AddNewItemAsync(Photo item)
        {
            //var transaction = realm.BeginWrite();
            var photoUrl = $"http://farm{item.farm}.staticflickr.com/{item.server}/{item.id}_{item.secret}_h.jpg";
            var newItem  = new PhotoUrl
            {
                Title = item.title,
                Url   = photoUrl
            };

            realm.Write(() => realm.Add(newItem));
            AllPhotos = realm.All <PhotoUrl>();

            return(await Task.FromResult(true));
        }
Ejemplo n.º 21
0
 public async Task <bool> UpdateItemAsync(Item item)
 {
     try
     {
         var oldItem = realm.All <Item>().Where((Item arg) => arg.TitleText == item.TitleText).FirstOrDefault();
         oldItem = item;
         realm.Add(oldItem, true);
         return(await Task.FromResult(true));
     }
     catch (Exception ex)
     {
         Debug.WriteLine(ex.Message);
         return(await Task.FromResult(false));
     }
 }
Ejemplo n.º 22
0
        public override async Task LoadAsync()
        {
            Ocupado = true;
            try
            {
                List <PokemonRealm> pokemonsDB = _realm.All <PokemonRealm>().ToList();

                if (pokemonsDB.Count() == 0)
                {
                    var pokemonsAPI = await _pokemonService.GetPokemonsAsync();

                    foreach (var pokemon in pokemonsAPI)
                    {
                        _realm.Write(() =>
                        {
                            PokemonRealm pokeRealm = new PokemonRealm
                            {
                                Id     = pokemon.Id,
                                Name   = pokemon.Name.ToUpper(),
                                Height = pokemon.Height,
                                Image  = GetImageStreamFromUrl(pokemon.Sprites.FrontDefault.AbsoluteUri)
                            };

                            _realm.Add(pokeRealm);
                        });
                    }

                    pokemonsDB = _realm.All <PokemonRealm>().ToList();
                }



                Pokemons.Clear();

                foreach (var pokemon in pokemonsDB)
                {
                    Pokemons.Add(pokemon);
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine("Erro", ex.Message);
            }
            finally
            {
                Ocupado = false;
            }
        }
            protected override string RunInBackground(params TranslateParams[] translateParams)
            {
                string translateResult = null;

                if (translateParams == null || translateParams.Length < 1)
                {
                    return(translateResult);
                }
                TranslateParams tparam = translateParams[0];

                tparam.TextToTranslate = tparam.TextToTranslate.ToLower().Trim();

                if (string.IsNullOrEmpty(tparam.TextToTranslate))
                {
                    return(translateResult);
                }

                Realm realm   = DbManager.GetRealm();
                bool  isFound = false;

                if (tparam.IsRuToEng)
                {
                    Translation translation = realm.All <Translation>().Where(t => t.RuText.Equals(tparam.TextToTranslate)).FirstOrDefault();
                    if (translation != null)
                    {
                        translateResult = translation.EngText;
                        isFound         = true;
                    }
                }
                else
                {
                    Translation translation = realm.All <Translation>().Where(t => t.EngText.Equals(tparam.TextToTranslate)).FirstOrDefault();
                    if (translation != null)
                    {
                        translateResult = translation.RuText;
                        isFound         = true;
                    }
                }
                if (!isFound)
                {
                    translateResult = Translator.Translate(tparam.TextToTranslate, tparam.IsRuToEng);
                    Translation translation = new Translation();
                    translation.EngText = (tparam.IsRuToEng ? translateResult : tparam.TextToTranslate);
                    translation.RuText  = (tparam.IsRuToEng ? tparam.TextToTranslate : translateResult);
                    realm.Write(() => realm.Add <Translation>(translation));
                }
                return(translateResult);
            }
Ejemplo n.º 24
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            RequestWindowFeature(Android.Views.WindowFeatures.ActionBar);
            this.ActionBar.NavigationMode = ActionBarNavigationMode.Tabs;
            base.OnCreate(savedInstanceState);

            SetContentView(Resource.Layout.FrameLayout);
            realmDB  = Realm.GetInstance();
            nameInfo = Intent.GetStringExtra("useremail");
            var userinfodbObj = realmDB.All <UserInfoDB>().Where(d => d.email == nameInfo.ToLower()).First();


            _FragmentsArray = new Fragment[]
            {
                new Tab1(userinfodbObj),

                new Tab2(this),

                new Tab3(this)
            };

            AddTabToActionBar("First Tab");

            AddTabToActionBar("Second Tab");

            AddTabToActionBar("Third Tab");
        }
Ejemplo n.º 25
0
        public async Task InitListView()
        {
            Realm RealmContext = null;

            try
            {
                if (User.AllLoggedIn.Count() > 1)
                {
                    foreach (var _u in User.AllLoggedIn)
                    {
                        await _u.LogOutAsync();
                    }
                }
                if (User.Current == null)
                {
                    if (await MyRealm.Login(API_USERNAME, API_PASSWORD) == null)
                    {
                        return;
                    }
                }
                RealmContext = MyRealm.RealmContext;
                using (var transaction = RealmContext.BeginWrite())
                {
                    RealmContext.RemoveAll <TrackMessage>();
                    RealmContext.Add(new TrackMessage {
                        Id = 0, Text = "Please wait, service starting"
                    });
                    transaction.Commit();
                }
                listView.ItemsSource = TrackMessage = RealmContext.All <TrackMessage>();
            }
            catch (Exception e) { Console.WriteLine($"{Constants.TAG} Erreur {e.GetType().FullName} {e.Message}"); }
        }
Ejemplo n.º 26
0
        protected override void PreImport(BeatmapSetInfo beatmapSet, Realm realm)
        {
            // We are about to import a new beatmap. Before doing so, ensure that no other set shares the online IDs used by the new one.
            // Note that this means if the previous beatmap is restored by the user, it will no longer be linked to its online IDs.
            // If this is ever an issue, we can consider marking as pending delete but not resetting the IDs (but care will be required for
            // beatmaps, which don't have their own `DeletePending` state).

            if (beatmapSet.OnlineID > 0)
            {
                var existingSetWithSameOnlineID = realm.All <BeatmapSetInfo>().SingleOrDefault(b => b.OnlineID == beatmapSet.OnlineID);

                if (existingSetWithSameOnlineID != null)
                {
                    existingSetWithSameOnlineID.DeletePending = true;
                    existingSetWithSameOnlineID.OnlineID      = -1;

                    foreach (var b in existingSetWithSameOnlineID.Beatmaps)
                    {
                        b.OnlineID = -1;
                    }

                    LogForModel(beatmapSet, $"Found existing beatmap set with same OnlineID ({beatmapSet.OnlineID}). It will be deleted.");
                }
            }
        }
Ejemplo n.º 27
0
        private bool ModifyGroup(int identity, string modifiedBy,
                                 byte[] recipientsArray, int amountOfRecipients)
        {
            _logger.Info($"Method for modifying SMS recipients group with ID: {identity} started.");

            try
            {
                SMSrecipientsGroupDefinition definition = _realm.All <SMSrecipientsGroupDefinition>().Single(x => x.Identity == identity);

                using (var trans = _realm.BeginWrite())
                {
                    definition.ModifiedBy         = modifiedBy;
                    definition.RecipientsArray    = recipientsArray;
                    definition.AmountOfRecipients = amountOfRecipients;
                    trans.Commit();
                }

                _logger.Info($"Modifying SMS recipients group with ID = {identity} successfull.");

                return(true);
            }
            catch (Exception ex)
            {
                _logger.Error($"Error while trying to modify existing SMS recipients group with ID: {identity}. Exception: {ex.Message}.");
                return(false);
            }
        }
Ejemplo n.º 28
0
        public void Init()
        {
            //using (var real)
            Config = new RealmConfiguration()
            {
                SchemaVersion = 1,
                ShouldDeleteIfMigrationNeeded = true
            };
            //Config.
            _realm      = Realm.GetInstance(Config);
            RealmThread = Thread.CurrentThread;
            //_realm.Error
            _realm.RealmChanged += _realm_RealmChanged;

            //Message msg;

            IDisposable msgToken = _realm.All <Message>().SubscribeForNotifications((sender, changes, errors) =>
            {
                if (changes != null)
                {
                    System.Diagnostics.Debug.WriteLine(changes.ModifiedIndices.Count());
                    System.Diagnostics.Debug.WriteLine(changes.DeletedIndices.Count());
                    System.Diagnostics.Debug.WriteLine(changes.InsertedIndices.Count());
                    System.Diagnostics.Debug.WriteLine("");
                }
            });
        }
Ejemplo n.º 29
0
        public async Task <bool> RemoveEmployee(EmployeeViewModel employee)
        {
            try
            {
                _realm = Realm.GetInstance("RealmTest");

                _realm.Refresh();

                int employeeID       = employee.EmployeeID;
                var originalEmployee = _realm.All <Employee>().First(x => x.EmployeeID == employeeID);

                // NOTE: Cascading deletes are not currently supported with Realm
                using (var trans = _realm.BeginWrite())
                {
                    _realm.Remove(originalEmployee);
                    trans.Commit();
                }

                Device.BeginInvokeOnMainThread(() =>
                {
                    Employees.Remove(employee);
                });
            }
            catch (Exception ex)
            {
                //throw ex;
                return(false);
            }

            return(true);
        }
Ejemplo n.º 30
0
        public async Task LoadEmployees(int?excludedEmployeeID = null)
        {
            try
            {
                _realm = Realm.GetInstance("RealmTest");

                // Basically the equivalent of an IIS Reset bomb drop - when all else fails just refresh :(
                _realm.Refresh();

                var employees = _realm.All <Employee>().ToList();

                if (employees != null)
                {
                    Device.BeginInvokeOnMainThread(() =>
                    {
                        Employees.Clear();

                        foreach (var employee in employees)
                        {
                            if (!excludedEmployeeID.HasValue || excludedEmployeeID.Value != employee.EmployeeID)
                            {
                                Employees.Add(new EmployeeViewModel(employee));
                            }
                        }
                    });
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Ejemplo n.º 31
0
        public JournalEntriesViewModel()
        {
            _realm = Realm.GetInstance();

            Entries = _realm.All<JournalEntry>();

            AddEntryCommand = new Command(AddEntry);
            DeleteEntryCommand = new Command<JournalEntry>(DeleteEntry);
        }
Ejemplo n.º 32
0
        protected override void OnAppearing()
        {
            base.OnAppearing();
            _realm = Realm.GetInstance();

            var query = _realm.All<DemoObject>().OrderByDescending(o => o.Date) as RealmResults<DemoObject>;
            listView.ItemsSource = query.ToNotifyCollectionChanged(e =>
            {
                // recover from the error - recreate the query or show message to the user
                System.Diagnostics.Debug.WriteLine(e);
            }) as IEnumerable<DemoObject>;
        }