예제 #1
0
        public App()
        {
            InitializeComponent();
            RequestedTheme = Windows.UI.Xaml.ApplicationTheme.Light;

            SqliteEngine.UseWinSqlite3(); //Configuring library to use SDK version of SQLite
            using (SqliteConnection db = new SqliteConnection("Filename=sqlite.db"))
            {
                db.Open();
                String tableCommand = "CREATE TABLE IF NOT EXISTS Table1 (" +
                                      "Primary_Key INTEGER PRIMARY KEY AUTOINCREMENT, " +
                                      "Index INTEGER NULL" +
                                      "Text_Entry NVARCHAR(2048) NULL)";

                SqliteCommand createTable = new SqliteCommand(tableCommand, db);
                try
                {
                    createTable.ExecuteReader();
                }
                catch (SqliteException)
                {
                    //Do nothing
                }
            }
        }
예제 #2
0
 public void CreateLocalDB()
 {
     //create sqlite database
     SqliteEngine.UseWinSqlite3();
     SQLite offline_baza = new SQLite();
     //  StorageFile SqliteDatabase = await ApplicationData.Current.LocalFolder.CreateFileAsync("iFe.sqlite", CreationCollisionOption.ReplaceExisting);
 }
예제 #3
0
        public App()
        {
            InitializeComponent();

            // Deferred execution until used. Check https://msdn.microsoft.com/library/dd642331(v=vs.110).aspx for further info on Lazy<T> class.
            _activationService = new Lazy <ActivationService>(CreateActivationService);

            SqliteEngine.UseWinSqlite3(); //Configuring library to use SDK version of SQLite
            using (SqliteConnection db = new SqliteConnection("Filename=sqlite.db"))
            {
                db.Open();
                String tableCommand = "CREATE TABLE IF NOT EXISTS Table1 (" +
                                      "Primary_Key INTEGER PRIMARY KEY AUTOINCREMENT, " +
                                      "Text_Entry NVARCHAR(2048) NULL)";

                SqliteCommand createTable = new SqliteCommand(tableCommand, db);
                try
                {
                    createTable.ExecuteReader();
                }
                catch (SqliteException)
                {
                    //Do nothing
                }
            }
        }
예제 #4
0
        public async Task Initialize()
        {
            // Configure library to use SDK version of SQLite, which is shared
            // therefore possibly faster load.
            SqliteEngine.UseWinSqlite3();

            using (var db = new GameContext())
                await db.Database.MigrateAsync();
        }
예제 #5
0
        public MainPage()
        {
            InitializeComponent();

            SqliteEngine.UseWinSqlite3(); //Configuring library to use SDK version of SQLite

            _wifiScanner = new WifiAdapterScanner();

            DataContext = _wifiScanner;
        }
예제 #6
0
        /// <summary>
        /// Initializes the singleton application object.  This is the first line of authored code
        /// executed, and as such is the logical equivalent of main() or WinMain().
        /// </summary>
        public App()
        {
            this.InitializeComponent();
            this.Suspending += OnSuspending;

            SqliteEngine.UseWinSqlite3(); //Configuring library to use SDK version of SQLite
            using (SqliteConnection db = new SqliteConnection(Constants.PathDatabase))
            {
                db.Open();
                String tblConfigServer = "CREATE TABLE IF NOT EXISTS ConfigServer (ServerId INTEGER PRIMARY KEY AUTOINCREMENT, ServiceBase NVARCHAR(300) NULL, TotalFrame INTEGER NULL, QueueURL NVARCHAR(300) NULL, AccessKeyName NVARCHAR(300) NULL, AccessKeyValue NVARCHAR(300) NULL, BusTopicName NVARCHAR(300) NULL, BusKeySend NVARCHAR(300) NULL, AzureName NVARCHAR(300) NULL, AzureKey NVARCHAR(300) NULL, AzureContainer NVARCHAR(300) NULL, AzureUrlHost NVARCHAR(300) NULL)";
                String tblConfigCamera = "CREATE TABLE IF NOT EXISTS ConfigCamera (CameraId INTEGER PRIMARY KEY AUTOINCREMENT, CameraIP NVARCHAR(300) NULL, CameraType NVARCHAR(300) NULL, CameraUser NVARCHAR(300) NULL, CameraPass NVARCHAR(300) NULL, StreaURI NVARCHAR(500) NULL, IndexView INTEGER NULL, BoxWidth INTEGER NULL, BoxHeight INTEGER NULL, BoxPointX INTEGER NULL, BoxPointY INTEGER NULL)";

                SqliteCommand createConfigServer = new SqliteCommand(tblConfigServer, db);
                SqliteCommand createConfigCamera = new SqliteCommand(tblConfigCamera, db);
                try
                {
                    createConfigServer.ExecuteReader();
                    createConfigCamera.ExecuteReader();
                    createConfigCamera.Dispose();
                    createConfigServer.Dispose();
                    db.Close();
                }
                catch (SqliteException e)
                {
                    db.Close();
                }
            }

            try
            {
                InfoSettingFix.InfoSetting = new ServiceUtil().GetCameraAPI();
                //Load cấu hình service bus
                //"https://vcb-poc-stag.servicebus.windows.net/face-detection"
                ServiceBusSetting.QueueURL = InfoSettingFix.InfoSetting.QueueURL;
                //"RootManageSharedAccessKey"
                ServiceBusSetting.AccessKeyName = InfoSettingFix.InfoSetting.AccessKeyName;
                //"DiW5SEtn5tr6+LM/Jji52KIUyjUNCA2EcFle3USKxYg="
                ServiceBusSetting.AccessKeyValue = InfoSettingFix.InfoSetting.AccessKeyValue;

                //Load cấu hình Azure Storage
                //"ntsstorageaccount"
                AzureStorageUtils.StorageAccountName = InfoSettingFix.InfoSetting.AzureName;
                //"8j0q5p8UbWjnVcBw6ht/Du3rZ4IXjEHeaQyhkynLOcQUfs5fdcmkeOq2ooLNz2uKtSQUT0sidUh3YbQ4hbyU2A=="
                AzureStorageUtils.StorageAccountKey = InfoSettingFix.InfoSetting.AzureKey;
                //"TimeAttendance.Client"
                AzureStorageUtils.StorageContainer = InfoSettingFix.InfoSetting.AzureContainer;
                //"https://ntsstorageaccount.blob.core.windows.net/"
                AzureStorageUtils.UrlHostImage = InfoSettingFix.InfoSetting.AzureUrlHost;
            }
            catch (Exception ex)
            {
                InfoSettingFix.InfoSetting = new InfoSettingModel();
            }
        }
예제 #7
0
 public static void Init()
 {
     SqliteEngine.UseWinSqlite3(); // use builtin Sqlite library
     using (connection)
     {
         // TODO: handle SqliteException (but how, reasonably?)
         connection.Open();
         new SqliteCommand("CREATE TABLE IF NOT EXISTS tasks ( uuid TEXT PRIMARY KEY, task TEXT NOT NULL )", connection).ExecuteNonQuery();
         new SqliteCommand("CREATE TABLE IF NOT EXISTS sync_backlog ( backlog_id INTEGER PRIMARY KEY AUTOINCREMENT, sync_key TEXT, task TEXT NOT NULL )", connection).ExecuteNonQuery();
         new SqliteCommand("CREATE TABLE IF NOT EXISTS metadata ( key TEXT PRIMARY KEY, value TEXT NOT NULL )", connection).ExecuteNonQuery();
     }
 }
예제 #8
0
        public static int ExecteNonQuery(string connectionString, CommandType cmdType, string cmdText, params SqliteParameter[] commandParameters)
        {
            SqliteEngine.UseWinSqlite3();
            var cmd = new SqliteCommand();

            using (var conn = new SqliteConnection(connectionString))
            {
                //通过PrePareCommand方法将参数逐个加入到SqlCommand的参数集合中
                PrepareCommand(cmd, conn, null, cmdType, cmdText, commandParameters);
                int val = cmd.ExecuteNonQuery();
                //清空SqlCommand中的参数列表
                cmd.Parameters.Clear();
                return(val);
            }
        }
예제 #9
0
        public async void loadData()
        {
            if (m_cnn == null)
            {
                string path = Path.Combine(ApplicationData.Current.LocalFolder.Path, "db.sqlite");
                SqliteEngine.UseWinSqlite3();
                m_cnn = new SqliteConnection("Filename=study.db");
                await m_cnn.OpenAsync();

                string sql = " CREATE TABLE IF NOT EXISTS chapterInfo ("
                             + " id INTEGER PRIMARY KEY AUTOINCREMENT,"
                             + " path text,"
                             + " marked text)";
                var cmd = new SqliteCommand(sql, m_cnn);
                await cmd.ExecuteNonQueryAsync();
            }
        }
예제 #10
0
        private void CreateDbFile()
        {
            SqliteEngine.UseWinSqlite3(); //Configuring library to use SDK version of SQLite
            using (SqliteConnection db = new SqliteConnection("Filename=" + dbFile))
            {
                db.Open();

                try
                {
                    // Client table
                    String tableCommand = "CREATE TABLE IF NOT EXISTS CLIENTS (ClientID	INTEGER PRIMARY KEY AUTOINCREMENT,	CompanyName	TEXT, "+
                                          "ContactName	TEXT,	PhoneNumber	TEXT,	Email	TEXT ,	Status	TEXT,	InsertEtime	INTEGER ) ";
                    SqliteCommand createTable = new SqliteCommand(tableCommand, db);
                    createTable.ExecuteReader();

                    // User table
                    tableCommand = "CREATE TABLE IF NOT EXISTS USERS (UserName	TEXT, "+
                                   "UserID TEXT PRIMARY KEY NOT NULL UNIQUE, Password	TEXT, UserType TEXT,	InsertEtime	INTEGER ) ";
                    createTable = new SqliteCommand(tableCommand, db);
                    createTable.ExecuteReader();

                    // Jobs table
                    tableCommand = "CREATE TABLE IF NOT EXISTS JOBS (	JobID	INTEGER PRIMARY KEY AUTOINCREMENT, 	ClientID	INTEGER, ClientName TEXT, JobName	TEXT"+
                                   ",	JobDescription	TEXT,	SalesTax	REAL NOT NULL DEFAULT 6,	DefaultHeight	REAL,	InsertEtime	INTEGER,	MarkupPct	REAL NOT NULL DEFAULT 30)";

                    createTable = new SqliteCommand(tableCommand, db);
                    createTable.ExecuteReader();

                    tableCommand = "CREATE TABLE IF NOT EXISTS VERSION (Version	REAL)";
                    createTable.ExecuteReader();

                    String versionSql = "Insert into VERSION (Version) values (" + _schemaVersion + ")";
                }
                catch (SqliteException e)
                {
                    //TODO: logging
                    Console.WriteLine(e.Message);
                }
                finally
                {
                    db.Close();
                }
            }
        }
예제 #11
0
 /// <summary>
 /// Initializes the singleton application object.  This is the first line of authored code
 /// executed, and as such is the logical equivalent of main() or WinMain().
 /// </summary>
 public App()
 {
     this.InitializeComponent();
     this.Suspending += OnSuspending;
     SqliteEngine.UseWinSqlite3();
     using (SqliteConnection db = new SqliteConnection("Filename=sqliteSample.db"))
     {
         db.Open();
         String        tableCommand = "CREATE TABLE IF NOT EXISTS Items (id INTEGER PRIMARY KEY AUTOINCREMENT, name NVARCHAR(30) NULL)";
         SqliteCommand createTable  = new SqliteCommand(tableCommand, db);
         try
         {
             createTable.ExecuteReader();
         }
         catch (SqliteException)
         {
         }
     }
 }
예제 #12
0
        public static void CreateDB()
        {
            SqliteEngine.UseWinSqlite3();

            using (SqliteConnection db = new SqliteConnection(DBFileName))
            {
                db.Open();
                using (SqliteCommand createTable = new SqliteCommand(dbSetup, db))
                {
                    try
                    {
                        createTable.ExecuteNonQuery();
                    }
                    catch (SqliteException e)
                    {
                        System.Diagnostics.Debug.WriteLine(e.ToString());
                    }
                }
            }
        }
예제 #13
0
 private void SaveToBdd(String type, String value)
 {
     SqliteEngine.UseWinSqlite3(); //Configuring library to use SDK version of SQLite
     using (SqliteConnection db = new SqliteConnection("Filename=edf.db"))
     {
         db.Open();
         String        sql     = "UPDATE EDF SET " + type + " = '" + value + "'";
         SqliteCommand command = new SqliteCommand(sql, db);
         try
         {
             command.ExecuteReader();
             status.Text = "Save BDD OK";
         }
         catch (SqliteException)
         {
             //Do nothing
             status.Text = "Erreur de sauvegarde dans la BDD";
         }
     }
 }  // la trame est sauvée en bdd avec sqlite
예제 #14
0
 private DatabaseHelper()
 {
     // 初始化数据库
     try
     {
         // Configuring library to use SDK version of SQLite
         SqliteEngine.UseWinSqlite3();
     }
     catch (InvalidOperationException exception)
     {
         Debug.WriteLine(exception);
     }
     FolderDatabase = new FolderDatabase(DbFileName);
     FolderDatabase.Create();
     ImageDatabase = new ImageDatabase(DbFileName);
     ImageDatabase.Create();
     MemoryListDatabase = new MemoryListDatabase(DbFileName);
     MemoryListDatabase.Create();
     MemoryImageDatabase = new MemoryImageDatabase(DbFileName);
     MemoryImageDatabase.Create();
 }
예제 #15
0
 /// <summary>
 /// Initializes the singleton application object.  This is the first line of authored code
 /// executed, and as such is the logical equivalent of main() or WinMain().
 /// </summary>
 public App()
 {
     this.InitializeComponent();
     this.Suspending += OnSuspending;
     SqliteEngine.UseWinSqlite3(); //Configuring library to use SDK version of SQLite
     using (SqliteConnection db = new SqliteConnection("Filename=Todo.db"))
     {
         db.Open();
         String        tableCommand = "CREATE TABLE IF NOT EXISTS TodoList (Primary_Key INTEGER PRIMARY KEY AUTOINCREMENT, Title_Entry NVARCHAR(2048) NULL, Content_Entry NVARCHAR(2048) NULL, Id INTEGER NULL, Ticks_Entry INTEGER NULL, Done INTEGER NULL)";
         SqliteCommand createTable  = new SqliteCommand(tableCommand, db);
         try
         {
             createTable.ExecuteReader();
         }
         catch (SqliteException e)
         {
             System.Diagnostics.Debug.WriteLine(e);
             //Do nothing
         }
     }
 }
        /// <summary>
        /// Initializes the singleton application object.  This is the first line of authored code
        /// executed, and as such is the logical equivalent of main() or WinMain().
        /// </summary>
        public App()
        {
            this.InitializeComponent();
            this.Suspending += OnSuspending;

            SqliteEngine.UseWinSqlite3();                                                  //Configuring library to use SDK version of SQLite
            using (SqliteConnection db = new SqliteConnection("Filename=sqliteSample.db")) //Name of .db file doesn't matter, but should be consistent across all SqliteConnection objects
            {
                db.Open();                                                                 //Open connection to database
                String        tableCommand = "CREATE TABLE IF NOT EXISTS MyTable (Primary_Key INTEGER PRIMARY KEY AUTOINCREMENT, Text_Entry NVARCHAR(2048) NULL)";
                SqliteCommand createTable  = new SqliteCommand(tableCommand, db);
                try
                {
                    createTable.ExecuteReader(); //Execute command, throws SqliteException error if command doesn't execute properly
                }
                catch (SqliteException e)
                {
                    //Do nothing
                }
            }
        }
예제 #17
0
        /// <summary>
        /// Initializes the singleton application object.  This is the first line of authored code
        /// executed, and as such is the logical equivalent of main() or WinMain().
        /// </summary>
        public App()
        {
            this.InitializeComponent();
            this.Suspending += OnSuspending;

            SqliteEngine.UseWinSqlite3(); //Configuring library to use SDK version of SQLite
            using (SqliteConnection db = new SqliteConnection("Filename=MyFavoriteWebDB.db"))
            {
                db.Open();
                string        tb          = "CREATE TABLE IF NOT EXISTS Usuarios (Id INTEGER PRIMARY KEY AUTOINCREMENT, Nome NVARCHAR(255) NOT NULL, Email NVARCHAR(255) NOT NULL, Senha NVARCHAR(255) NOT NULL)";
                SqliteCommand createTable = new SqliteCommand(tb, db);
                try
                {
                    createTable.ExecuteReader();
                }
                catch (SqliteException e)
                {
                    //Do nothing
                }
            }
        }
예제 #18
0
 /// <summary>
 /// Initializes the singleton application object.  This is the first line of authored code
 /// executed, and as such is the logical equivalent of main() or WinMain().
 /// </summary>
 public App()
 {
     this.InitializeComponent();
     this.Suspending += OnSuspending;
     SqliteEngine.UseWinSqlite3(); //Configuring library to use SDK version of SQLite
     using (SqliteConnection db = new SqliteConnection("Filename=didit1_db.db"))
     {
         db.Open();
         string tableCommand = "CREATE TABLE IF NOT EXISTS Habit (Primary_Key INTEGER PRIMARY KEY AUTOINCREMENT, text_habit NVARCHAR(2048) NULL)";
         // String tableCommand = "CREATE TABLE IF NOT EXISTS MyTable (Primary_Key INTEGER PRIMARY KEY AUTOINCREMENT, Text_Entry NVARCHAR(2048) NULL)";
         SqliteCommand createTable = new SqliteCommand(tableCommand, db);
         try
         {
             createTable.ExecuteReader();
         }
         catch (SqliteException e)
         {
             //Do nothing
         }
     }
 }
예제 #19
0
        /// <summary>
        /// Initializes the singleton application object.  This is the first line of authored code
        /// executed, and as such is the logical equivalent of main() or WinMain().
        /// </summary>
        public App()
        {
            this.InitializeComponent();
            this.Suspending += OnSuspending;

            SqliteEngine.UseWinSqlite3();
            using (SqliteConnection db = new SqliteConnection("FileName=sqliteSample.db"))
            {
                db.Open();
                String tableCommand =
                    "CREATE TABLE IF NOT EXISTS Titles (Primary_Key INTEGER PRIMARY KEY AUTOINCREMENT, Text_Entry NVARCHAR(2048) NULL)";
                SqliteCommand createTable = new SqliteCommand(tableCommand, db);
                try
                {
                    createTable.ExecuteReader();
                }
                catch (Exception)
                {
                    //Do Nothing
                }
            }
        }
예제 #20
0
    public async Task <bool> CreateAsync()
    {
        bool result = false;

        SqliteEngine.UseWinSqlite3();
        using (SqliteConnection connection = new SqliteConnection(connection_string))
        {
            await connection.OpenAsync();

            SqliteCommand create = new SqliteCommand(table_create, connection);
            try
            {
                await create.ExecuteNonQueryAsync();

                result = true;
            }
            catch (SqliteException)
            {
                result = false;
            }
            connection.Close();
        }
        return(result);
    }
예제 #21
0
 /// <summary>
 /// Initializes the singleton application object.  This is the first line of authored code
 /// executed, and as such is the logical equivalent of main() or WinMain().
 /// </summary>
 public App()
 {
     this.InitializeComponent();
     this.Suspending += OnSuspending;
     SqliteEngine.UseWinSqlite3(); //Configuring library to use SDK version of SQLite
 }
예제 #22
0
 public DatabaseModel()
 {
     //Forces the use of Windows 10 packaged SQLite.
     SqliteEngine.UseWinSqlite3();
 }
예제 #23
0
        /// <summary>
        /// Initializes the singleton application object.  This is the first line of authored code
        /// executed, and as such is the logical equivalent of main() or WinMain().
        /// </summary>
        public App()
        {
            this.InitializeComponent();
            this.Suspending += OnSuspending;


            SqliteEngine.UseWinSqlite3();             //Configuring library to use SDK version of SQLite
            using (SqliteConnection db = new SqliteConnection("Filename=Solarizr_DB.db"))
            {
                db.Open();

                String _AddresstableCommand = "CREATE TABLE IF NOT EXISTS Address_tbl (" +
                                              "PK_ID INTEGER PRIMARY KEY AUTOINCREMENT," +
                                              "Street text NULL, " +
                                              "Suburb text NULL, " +
                                              "City text NULL, " +
                                              "Postal_Code text NULL," +
                                              "Country text NULL);";

                String _UsertableCommand = "CREATE TABLE IF NOT EXISTS User_tbl (" +
                                           "PK_ID INTEGER PRIMARY KEY AUTOINCREMENT," +
                                           "Name text NULL, " +
                                           "Phone text NULL," +
                                           "FK_AdID INTEGER NULL," +
                                           "FOREIGN KEY (FK_AdID) REFERENCES Address_tbl(PK_ID));";

                String _AppointmenttableCommand = "CREATE TABLE IF NOT EXISTS Appointment_tbl (" +
                                                  "PK_ID INTEGER PRIMARY KEY AUTOINCREMENT," +
                                                  "Date text NULL, " +
                                                  "Status text NULL, " +
                                                  "Submitted BLOB NULL, " +
                                                  "FK_CID INTEGER NULL, " +
                                                  "FK_SMID INTEGER NULL, " +
                                                  "FK_AdID INTEGER NULL, " +
                                                  "FOREIGN KEY (FK_CID) REFERENCES user_tbl(PK_ID)," +
                                                  "FOREIGN KEY (FK_SMID) REFERENCES user_tbl(PK_ID)," +
                                                  "FOREIGN KEY (FK_AdID) REFERENCES Address_tbl(PK_ID));";

                String _NotetableCommand = "CREATE TABLE IF NOT EXISTS Note_tbl (" +
                                           "PK_ID INTEGER PRIMARY KEY AUTOINCREMENT," +
                                           "Note text NULL, " +
                                           "FK_ApID INTEGER NULL, " +
                                           "FOREIGN KEY (FK_ApID) REFERENCES Appointment_tbl(PK_ID));";

                String _PicturetableCommand = "CREATE TABLE IF NOT EXISTS Picture_tbl (" +
                                              "PK_ID INTEGER PRIMARY KEY AUTOINCREMENT," +
                                              "Path text NULL, " +
                                              "FK_ApID INTEGER NULL, " +
                                              "FOREIGN KEY (FK_ApID) REFERENCES Appointment_tbl(PK_ID));";

                SqliteCommand _createUserTable        = new SqliteCommand(_AddresstableCommand, db);
                SqliteCommand _createAddressTable     = new SqliteCommand(_UsertableCommand, db);
                SqliteCommand _createAppointmentTable = new SqliteCommand(_AppointmenttableCommand, db);
                SqliteCommand _createNoteTable        = new SqliteCommand(_NotetableCommand, db);
                SqliteCommand _createPictureTable     = new SqliteCommand(_PicturetableCommand, db);

                try
                {
                    _createAddressTable.ExecuteReader();
                    _createUserTable.ExecuteReader();
                    _createAppointmentTable.ExecuteReader();
                    _createNoteTable.ExecuteReader();
                    _createPictureTable.ExecuteReader();
                }
                catch (SqliteException e)
                {
                    Debug.WriteLine("DB CREATION FAILED");
                    Debug.WriteLine("");
                    Debug.WriteLine(e.Message + ": " + e.InnerException);
                    Debug.WriteLine(e.SqliteErrorCode);
                    Debug.WriteLine(e.StackTrace);
                }
                db.Close();
            }
        }
예제 #24
0
        public DBService()
        {
            SqliteEngine.UseWinSqlite3(); //Configuring library to use SDK version of SQLite

            VerifyConnection();
        }