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;
        }
Exemplo n.º 2
0
        private void ListBoxInDeleteBtn_MouseLeftButtonDown(object sender, RoutedEventArgs e)
        {
            Button deleteCmd = (Button)sender;

            if (deleteCmd.DataContext is ServerModel deleteItem)
            {
                if (deleteItem.target == 1)
                {
                    MessageBoxUtil.WarningMessageBoxShow("起動対象のサーバとなっているので削除はできません。");
                    return;
                }

                using (SqliteWrapper sqliteWrapper = new SqliteWrapper(true))
                {
                    try
                    {
                        sqliteWrapper.ExecuteDelete(deleteItem);
                        sqliteWrapper.Commit();
                    }
                    catch
                    {
                        sqliteWrapper.RollBack();
                    }
                }
            }
            RefreshData();
        }
Exemplo n.º 3
0
 private void FilePathSetting_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     if (IsCombBoxSelectionChanged)
     {
         ComboBox selectItem = (ComboBox)sender;
         if ((ServerModel)selectItem.SelectedItem == null)
         {
             return;
         }
         using (SqliteWrapper sqliteWrapper = new SqliteWrapper(true))
         {
             try
             {
                 ServerModel nowTarget = sqliteWrapper.ExecuteSelect <ServerModel>().FirstOrDefault(a => a.target == 1);
                 nowTarget.target = 0;
                 sqliteWrapper.ExecuteUpdata(nowTarget);
                 ServerModel selectTarget = sqliteWrapper.ExecuteSelectOne <ServerModel>(((ServerModel)selectItem.SelectedItem).id);
                 selectTarget.target = 1;
                 sqliteWrapper.ExecuteUpdata(selectTarget);
                 sqliteWrapper.Commit();
             }
             catch
             {
                 sqliteWrapper.RollBack();;
             }
         }
     }
     IsCombBoxSelectionChanged = true;
 }
Exemplo n.º 4
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);
 }