Ejemplo n.º 1
0
        private void WorkEditText_TextChanged(object sender, Android.Text.TextChangedEventArgs e)
        {
            if (!string.IsNullOrWhiteSpace(syllabelsTextView.Text))
            {
                syllabelsTextView.Text = "";                                 //clearing textview content
            }
            List <string> list = String.Concat(e.Text).Split("\n").ToList(); //loading words in text

            if (string.IsNullOrEmpty(String.Concat(e.Text)))
            {
                syllabelsTextView.Visibility = ViewStates.Gone;                                              //hide syllables edittext if text is empty
            }
            else
            {
                syllabelsTextView.Visibility = ViewStates.Visible;
            }
            foreach (var line in list)
            {
                if (!string.IsNullOrWhiteSpace(line))
                {
                    syllabelsTextView.Text += SQLiteDb.CountSyllables(line) + "\n";                                   // adding count of syllables in line
                }
                else
                {
                    syllabelsTextView.Text += 0 + "\n";
                }
            }
        }
Ejemplo n.º 2
0
 public override void OnBackPressed() // BackPressed or Save button clicked
 {
     try
     {
         if (string.IsNullOrEmpty(workEditText.Text))
         {
             throw new ArgumentNullException();                                          // not saving if text is empty
         }
         if (work == null)
         {
             work = new Work();               // if not loaded creating new work
         }
         if (string.IsNullOrEmpty(titleEditText.Text))
         {
             titleEditText.Text = "Nowe dzieło (" + (SQLiteDb.GetWorks().Where(w => w.Title.Contains("Nowe dzieło")).Count() + 1) + ")"; // filling title if empty
         }
         if (work.Text != workEditText.Text || work.Title != titleEditText.Text)                                                         //saving work if changed or new
         {
             work.Text     = workEditText.Text;
             work.Title    = titleEditText.Text;
             work.Modified = DateTime.Now;
             SQLiteDb.SaveWork(work);
         }
         else
         {
             throw new ArgumentNullException();
         }
     }
     catch
     {
         Toast.MakeText(this, "Nie zapisano", ToastLength.Short).Show();
     }
     base.OnBackPressed();
 }
Ejemplo n.º 3
0
 /// <summary>
 /// CREATE BLANK SQLITE DATABASE
 /// </summary>
 /// <param name="path"></param>
 static public void CreateTemplatesTable(string path)
 {
     if (System.IO.File.Exists(path))
     {
                         #if NCORE
         Console.Clear();
         Console.Error.Write("File Exists...\n\"{0}\"", path);
                         #else
         System.Windows.Forms.MessageBox.Show(
             string.Format("File Exists...\n\"{0}\"", path),
             "Error",
             System.Windows.Forms.MessageBoxButtons.OK,
             System.Windows.Forms.MessageBoxIcon.Error
             );
                         #endif
         return;
     }
     using (System.IO.FileStream fs = System.IO.File.Create(path, 0))
     {
     }
     using (SQLiteDb db = new SQLiteDb(path))
         using (DataSet ds = db.Insert("templates", sql_create_templates, SelectTemplatesAdapter))
             using (DataView v = ds.GetDataView("templates"))
                 foreach (DataRowView rv in v)
                 {
                     //				Templates.Add(TemplateElement.FromRowView(rv));
                 }
 }
Ejemplo n.º 4
0
        private void CheckIfDataLoaded() // thread checking if WordLibraries are loaded
        {
            Thread dataLoaded = new Thread(dl =>
            {
                var rhymesLoaded   = false;
                var synonymsLoaded = false;
                do
                {
                    if (SQLiteDb.RhymesLoaded())
                    {
                        rhymesLoaded = true;
                        this.RunOnUiThread(() =>
                        {
                            findRhymesButton.SetTextColor(colors);
                        });
                    }
                    if (SQLiteDb.SynonymsLoaded())
                    {
                        synonymsLoaded = true;
                        this.RunOnUiThread(() =>
                        {
                            findSynonymsButton.SetTextColor(colors);
                        });
                    }
                }while (!(rhymesLoaded && synonymsLoaded));
            });

            dataLoaded.Start();
        }
Ejemplo n.º 5
0
 public virtual void Delete(T data)
 {
     using (var conn = SQLiteDb.GetConnection())
     {
         conn.Delete <T>(data.Id);
     }
 }
Ejemplo n.º 6
0
            public void Update(SQLiteDb.CBParams cb)
            {
                using (SQLiteSettingsContext C = SC.NewContext) using (SQLiteDb db = new SQLiteDb(SC.SettingsFile))
                    {
//					this.Act1(C,db,defaultaction,cb);
                    }
            }
Ejemplo n.º 7
0
            public setting GetValue(string name, string grp)
            {
                setting s = null;

                using (SQLiteDb db = new SQLiteDb(datafile)) s = GetValue(db, name, null, grp);
                return(s);
            }
Ejemplo n.º 8
0
        public void TestMethod1()
        {
            //Produit p = new Produit("58", "aziz", "eeee");
            //IDAoImpProduit daopr = new IDAoImpProduit();
            //bool veri=daopr.ajout(p);
            //Assert.IsTrue(veri);
            //IFakeDAO fake = Substitute.For<ISQliteDB>();
            // fake.ajout().Returns(true);
            // ConsoleProduit d = new ConsoleProduit();
            //  bool pp = d.ajoutt(fake);
            //  Assert.IsTrue(pp);
            //Arrange
            var sqlite       = new SQLiteDb();
            var productStore = new SQLiteProductStore(sqlite);
            var pageService  = Substitute.For <IPageService>();
            var addService   = Subtitute.For <IProductStore>();
            var vm           = new ProductsPageViewModel(productStore, pageService);


            //Act
            vm.LoadDataCommand.Execute(null);
            var x = vm.Products;

            vm.AddProductCommand.Execute(null);
            //Assert

            Assert.IsNotNull(x);
        }
Ejemplo n.º 9
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.Settings);
            // Create your application here
            var toolbar = FindViewById <Android.Support.V7.Widget.Toolbar>(Resource.Id.settingsToolbar);

            SetSupportActionBar(toolbar);
            prefs  = PreferenceManager.GetDefaultSharedPreferences(this);
            editor = prefs.Edit();
            SupportActionBar.Title = "Ustawienia";
            Switch gpsSwitch = FindViewById <Switch>(Resource.Id.gpsSwitch);

            gpsSwitch.Checked = prefs.GetBoolean("settingsNotifications", true);
            ChangeText(gpsSwitch);

            Button logout = FindViewById <Button>(Resource.Id.logOutButton);

            gpsSwitch.CheckedChange += (o, e) =>
            {
                editor.PutBoolean("settingsNotifications", e.IsChecked);
                editor.Apply();
                ChangeText(gpsSwitch);
            };

            logout.Click += async(o, e) =>
            {
                await SQLiteDb.LogOut();

                FinishActivity(0);
                var intent = new Intent(this, typeof(SignInActivity));
                StartActivity(intent);
                Finish();
            };
        }
Ejemplo n.º 10
0
 public virtual IList <T> List()
 {
     using (var conn = SQLiteDb.GetConnection())
     {
         return(conn.Table <T>().ToList());
     }
 }
Ejemplo n.º 11
0
 public virtual void Update(T data)
 {
     using (var conn = SQLiteDb.GetConnection())
     {
         conn.Update(data);
     }
 }
Ejemplo n.º 12
0
 public virtual T GetById(int id)
 {
     using (var conn = SQLiteDb.GetConnection())
     {
         return(conn.Get <T>(id));
     }
 }
Ejemplo n.º 13
0
            public setting SetValue(setting value, bool force)
            {
                setting o = value;

                using (SQLiteDb db = new SQLiteDb(datafile)) o = SetValue(db, value, force);
                return(o);
            }
Ejemplo n.º 14
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.RoomsList);

            rooms = SQLiteDb.GetRooms(this).ToList();

            expandableListView = FindViewById <ExpandableListView>(Resource.Id.roomsExpandableListView);

            var toolbar = FindViewById <Android.Support.V7.Widget.Toolbar>(Resource.Id.roomsListToolbar);

            SetSupportActionBar(toolbar);
            SupportActionBar.Title = "Zgłoś zagrożenie";

            adapter = new RoomsListAdapter(this, rooms);
            expandableListView.SetAdapter(adapter);

            expandableListView.ChildClick += (o, e) =>
            {
                var    roomName  = adapter.GetChild(e.GroupPosition, e.ChildPosition).ToString();
                var    floorName = adapter.GetGroup(e.GroupPosition).ToString();
                var    intent    = new Intent(this, typeof(WriteReportDataActivity));
                Bundle extras    = new Bundle();
                extras.PutString("choosenFloor", floorName);
                extras.PutString("choosenRoom", roomName);
                intent.PutExtras(extras);
                StartActivity(intent);
                Finish();
            };
        }
Ejemplo n.º 15
0
 public override DataSet UpdateCategory(string q)
 {
     category.Tables.Clear();
     using (SQLiteDb db = new SQLiteDb(datafile))
         category = db.Delete(Context.CategoryName, q, UpdateCategoryAdapter, UpdateCategoryFillOperation);
     return(category);
 }
Ejemplo n.º 16
0
 /// <summary>
 /// Get the db connection up and running.
 /// </summary>
 /// <returns></returns>
 private async Task CreateDBConnection()
 {
     if (_db == null)
     {
         _db = await SQLiteDb.DB();
     }
 }
Ejemplo n.º 17
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            Xamarin.Essentials.Platform.Init(this, savedInstanceState);
            SetContentView(Resource.Layout.activity_main);

            toolbar = FindViewById <Android.Support.V7.Widget.Toolbar>(Resource.Id.toolbar);
            SetSupportActionBar(toolbar);

            FloatingActionButton fab = FindViewById <FloatingActionButton>(Resource.Id.fab);

            fab.Click += FabOnClick;

            //DrawerLayout drawer = FindViewById<DrawerLayout>(Resource.Id.drawer_layout);
            //ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(this, drawer, toolbar, Resource.String.navigation_drawer_open, Resource.String.navigation_drawer_close);
            //drawer.AddDrawerListener(toggle);
            //toggle.SyncState();

            NavigationView navigationView = FindViewById <NavigationView>(Resource.Id.nav_view);

            navigationView.SetNavigationItemSelectedListener(this);

            worksList    = SQLiteDb.GetWorks();
            mainListView = FindViewById <ListView>(Resource.Id.mainListView);
            mainListView.SetSelection(0);

            mainListView.ItemClick     += MainListView_ItemClick;
            mainListView.ItemLongClick += MainListView_ItemLongClick;
            UpdateAdapter();
            SQLiteDb.StartApp(this); // starting load words to library
        }
Ejemplo n.º 18
0
 public virtual T Insert(T data)
 {
     using (var conn = SQLiteDb.GetConnection())
     {
         conn.Insert(data);
         return(data);
     }
 }
Ejemplo n.º 19
0
 /// <inheritdoc/>
 public override DataSet Select(string q)
 {
     if (data == null)
     {
         data = new DataSet();
     }
     data.Tables.Clear(); using (SQLiteDb db = new SQLiteDb(datafile)) data = db.Select(Context.TableName, q, AdapterSelect, FillSelect); return(data);
 }
Ejemplo n.º 20
0
 public override DataSet SelectCategory(string q)
 {
     category.Tables.Clear();
     category.Tables.Add(Context.CategoryName);
     using (SQLiteDb db = new SQLiteDb(datafile))
         category = db.Select(Context.CategoryName, q, SelectCategoryAdapter, SelectCategoryFillOperation);
     return(category);
 }
Ejemplo n.º 21
0
 public IList <NFcItem> ListByNFc(int nfcId)
 {
     using (var conn = SQLiteDb.GetConnection())
     {
         return(conn.Table <NFcItem>()
                .Where(item => item.NFcId == nfcId)
                .ToList());
     }
 }
Ejemplo n.º 22
0
        /// <summary>
        /// 删除所有数据
        /// </summary>
        public void DeleteAll()
        {
            SqlDb db = new SQLiteDb(_connString);

            db.IsShowSqlToConsole = _isShowSqlToConsole;
            var dbFactory  = db.DbBuilder.DbFactory;
            var dbOperator = dbFactory.GetDbParamOperator();
            var result     = db.Delete <UserInfo>("", null);
        }
Ejemplo n.º 23
0
        public static List <Certificate> Query(string sSerialNo, string sCertData, string sPwd)
        {
            SqlDb db         = new SQLiteDb();
            var   dbFactory  = db.DbBuilder.DbFactory;
            var   dbOperator = dbFactory.GetDbParamOperator();

            var dblist = db.Query <Certificate>("SerialNo,CertData,CommonName", "1>0");

            return(dblist);
        }
Ejemplo n.º 24
0
        public void CreateTable(string dbPath)
        {
            if (File.Exists(dbPath))
            {
                File.Delete(dbPath);
            }
            SqlDb db = new SQLiteDb(_connString);

            db.IsShowSqlToConsole = _isShowSqlToConsole;
            var sql    = "create  table UserInfo(UserId int not null,UserName  varchar(50),Age int,Email varchar(50))";
            var result = db.ExecuteNoneQuery(sql, null);
        }
Ejemplo n.º 25
0
 void Event_ExecuteNonQuery(object sender, RoutedEventArgs args)
 {
     if (!database.IsLoaded)
     {
         return;
     }
     using (var db = new SQLiteDb(database.DataFile))
     {
         try { data = db.Insert(edit.Text, DBInsert); }
         catch (Exception error) { ThrowException(error, queryError: true); }
     }
 }
Ejemplo n.º 26
0
        /// <summary>
        /// 修改数据
        /// </summary>
        public void Update()
        {
            SqlDb db = new SQLiteDb(_connString);

            db.IsShowSqlToConsole = _isShowSqlToConsole;
            var dbFactory  = db.DbBuilder.DbFactory;
            var dbOperator = dbFactory.GetDbParamOperator();

            //根据修改字段参数及值、过滤SQL、过滤参数修改数据
            var result = db.Update <UserInfo>(new { UserName = "******" }, "UserId=4", null);

            result = db.Update <UserInfo>(new { UserName = "******" }, string.Format("UserId={0}UserId", dbOperator), new { UserId = 4 });
        }
Ejemplo n.º 27
0
        public EzServer(EzServerSettings settings)
        {
            Settings = settings;
            LogProvider <EzLogger> .Provider.Configure(Settings);

            _logger = LogProvider <EzLogger> .GetLogger(this);

            _handlers      = new Dictionary <int, IHandler>();
            _server        = new AsyncEventServer(Settings.ListenIpAddress, Settings.Port, this, Settings.ServerSettings);
            Clients        = new ClientLookup();
            Database       = new SQLiteDb(settings.DatabaseSettings.SQLitePath);
            SessionManager = new SessionManager();
        }
Ejemplo n.º 28
0
        public FormSincronizacao()
        {
            InitializeComponent();

            db            = new SQLiteDb();
            sincronizacao = db.LeDados <Sincronizacao>();

            if (sincronizacao != null)
            {
                url.Text      = sincronizacao.url;
                endpoint.Text = sincronizacao.endpoint;
                acesso.Text   = sincronizacao.acesso;
            }
        }
Ejemplo n.º 29
0
        public FormLote()
        {
            InitializeComponent();

            db   = new SQLiteDb();
            lote = db.LeDados <Lote>();

            if (lote != null)
            {
                Nome.Text           = lote.Nome;
                Inseminacao.Text    = lote.Inseminacao;
                Dieta.Text          = lote.Dieta;
                Infraestrutura.Text = lote.Infraestrutura;
            }
        }
Ejemplo n.º 30
0
        public static object GetMaxId()
        {
            string sConn      = PlavyConfig.GetConnectionString("db");
            SqlDb  db         = new SQLiteDb(sConn);
            var    dbFactory  = db.DbBuilder.DbFactory;
            var    dbOperator = dbFactory.GetDbParamOperator();

            var dblist = db.ExecuteScalar("select max(id) from tb_certs");

            if (dblist == null)
            {
                return(-1);
            }
            return(dblist);
        }