private void UserControl_Initialized(object sender, EventArgs e)
        {
            string baseAddres = String.Empty;

            using (SqliteWrapper sqliteWrapper = new SqliteWrapper(true))
            {
                try
                {
                    if (sqliteWrapper.ExecuteSelect <WebApiModel>().Count() == 0)
                    {
                        WebApiModel webApiModel = new WebApiModel()
                        {
                            base_addres = "http://localhost:1000/"
                        };
                        sqliteWrapper.ExecuteInsert(webApiModel);
                        sqliteWrapper.Commit();
                    }
                    baseAddres = sqliteWrapper.ExecuteSelect <WebApiModel>().FirstOrDefault().base_addres;
                }
                catch (Exception ex)
                {
                    sqliteWrapper.RollBack();
                }
            }
            BaseAddressTextBox.Text = baseAddres;
        }
示例#2
0
        private void AddBtn_Click(object sender, RoutedEventArgs e)
        {
            if (string.IsNullOrEmpty(NameTextBox.Text) || string.IsNullOrWhiteSpace(NameTextBox.Text))
            {
                MessageBoxUtil.WarningMessageBoxShow($"{NameTextBlock.Text}が未入力または空白で構成されています。");
                return;
            }
            if (string.IsNullOrEmpty(AddFilePathTextBox.Text) || string.IsNullOrWhiteSpace(AddFilePathTextBox.Text))
            {
                MessageBoxUtil.WarningMessageBoxShow($"{AddSelectFilePathBtn.Content}が未入力または空白で構成されています。");
                return;
            }
            if (!File.Exists(AddFilePathTextBox.Text))
            {
                MessageBoxUtil.WarningMessageBoxShow($"ファイルが存在しません。");
                return;
            }
            if (FilePathSettingCollection.FirstOrDefault(a => a.name.Equals(NameTextBox.Text)) != null)
            {
                MessageBoxUtil.WarningMessageBoxShow($"名前が重複しています。");
                return;
            }

            ServerModel serverModelList = new ServerModel()
            {
                name = NameTextBox.Text,
                path = AddFilePathTextBox.Text
            };

            using (SqliteWrapper sqliteWrapper = new SqliteWrapper(true))
            {
                try
                {
                    sqliteWrapper.ExecuteInsert(serverModelList);
                    sqliteWrapper.Commit();
                }
                catch
                {
                    sqliteWrapper.RollBack();;
                }
            }
            RefreshData();
        }
 private bool InsertInitData(string inputName, string inputFilePath)
 {
     using (SqliteWrapper sqlite = new SqliteWrapper(true))
     {
         try
         {
             sqlite.ExecuteInsert(new ServerModel()
             {
                 name = inputName, path = inputFilePath, target = 1
             });
             sqlite.Commit();
         }
         catch
         {
             sqlite.RollBack();
             return(false);
         }
     }
     return(true);
 }