コード例 #1
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();
        }
コード例 #2
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;
 }
コード例 #3
0
ファイル: MainForm.cs プロジェクト: rollrat/swiss-tournament
        private void MainForm_Shown(object sender, EventArgs e)
        {
            new StartForm().ShowDialog();
            if (DBFileName != null)
            {
                DB = SqliteWrapper.Open(DBFileName);
                Tuple<DateTime, string> tuple = DB.Created();
                Manager = new DBManager(DB);
                lCreatedDateTime.Text = tuple.Item1.ToString();
                lCreatedMessage.Text = tuple.Item2;
                refresh_party();
                refresh_rounds_info();

                //
                // Load round more than two
                //
                var max_round = Manager.GetMaxRound();
                for (int i = 2; i <= max_round; i++)
                {
                    var nt = CreateTabPage();

                    var control = new RoundControl(i) { Dock = DockStyle.Fill };
                    nt.Controls.Add(control);
                    rounds.Add(i, control);
                }
            }
        }
コード例 #4
0
        public IDatastore LoadDataFromSource(DesignerItemBase sourceItem, IDatastore dataStore, ReportProgressMethod reportProgressMethod)
        {
            IModule     sourceObject     = objectResolver.GetModule(sourceItem.ID, sourceItem.ModuleDescription.ModuleType);
            IConnection connectionObject = objectResolver.GetConnection(sourceItem.ID);

            if (connectionObject == null)
            {
                if (runLog != null)
                {
                    string label = String.IsNullOrEmpty(sourceItem.ItemLabel) ? "-- No Label --" : sourceItem.ItemLabel;
                    throw new Exception("No connection was selected for the source '" + label + "'.");
                }
                dataStore = null;
            }

            ItemLog itemLog = ItemLog.CreateNew(sourceItem.ID, sourceItem.ItemLabel, sourceItem.ModuleDescription.ModuleType.Name, null);

            if (runLog != null)
            {
                var databaseInterface = SqliteWrapper.GetSqliteWrapper(runLog.RunLogPath, sourceItem.ID, sourceItem.ItemLabel);
                itemLog.DatabasePath = runLog.RunLogPath + "\\" + databaseInterface.GetDatabaseName();
                parentItemLog.SubFlowLogs.Add(itemLog);
            }

            ((IDataSource)sourceObject).LoadData(connectionObject, dataStore, reportProgressMethod);

            itemLog.EndTime = DateTime.Now;

            return(dataStore);
        }
コード例 #5
0
ファイル: CreateDB.cs プロジェクト: rollrat/swiss-tournament
 private void bCreate_Click(object sender, EventArgs e)
 {
     if (this.tbMessage.Text.Contains("'"))
     {
         MessageBox.Show("설명에는 '문자가 없어야합니다!", "Swiss Tournament", MessageBoxButtons.OK, MessageBoxIcon.Hand);
     }
     else if (this.tbMessage.Text.Length >= 0xff)
     {
         MessageBox.Show("설명이 너무 깁니다!", "Swiss Tournament", MessageBoxButtons.OK, MessageBoxIcon.Hand);
     }
     else
     {
         if (!Directory.Exists("db"))
         {
             Directory.CreateDirectory("db");
         }
         string path = "db/" + this.tbFileName.Text + ".db";
         if (File.Exists(path))
         {
             MessageBox.Show("같은 이름의 파일이 이미 존재합니다!", "Swiss Tournament", MessageBoxButtons.OK, MessageBoxIcon.Hand);
         }
         else
         {
             SqliteWrapper.CreateNew(path);
             SqliteWrapper wrapper = SqliteWrapper.Open(path);
             wrapper.EvalNqSql("create table created (time integer, msg varchar(255))");
             wrapper.EvalNqSql($"insert into created (time, msg) values ({DateTime.Now.Ticks}, '{this.tbMessage.Text}')");
             wrapper.EvalNqSql("create table members (ix int, name varchar(60), id int)");
             wrapper.EvalNqSql("create table history (ix int, p1 int, p2 int, status int, round int, desc varchar(255))");
             base.Close();
         }
     }
 }
        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;
        }
コード例 #7
0
        public void Test_CreateAndDelete_Successful()
        {
            string        tempPath      = Path.GetTempPath();
            Guid          dbName        = Guid.NewGuid();
            SqliteWrapper sqliteWrapper = new SqliteWrapper(tempPath, dbName.ToString());

            sqliteWrapper.Dispose();
            sqliteWrapper.DeleteDatabase();
        }
コード例 #8
0
ファイル: StartForm.cs プロジェクト: rollrat/swiss-tournament
 private void refresh()
 {
     if (Directory.Exists("db"))
     {
         this.lvFiles.Items.Clear();
         foreach (string str in Directory.GetFiles("db"))
         {
             Tuple <DateTime, string> tuple = SqliteWrapper.Open(str).Created();
             string[] items = new string[] { Path.GetFileName(str), tuple.Item2, tuple.Item1.ToString() };
             this.lvFiles.Items.Add(new ListViewItem(items));
         }
     }
 }
コード例 #9
0
        public IDatastore WriteToTarget(DesignerItemBase targetItem, IDatastore dataStore, ReportProgressMethod reportProgressMethod)
        {
            IModule            targetModule      = objectResolver.GetModule(targetItem.ID, targetItem.ModuleDescription.ModuleType);
            IConnection        connectionObject  = objectResolver.GetConnection(targetItem.ID);
            IDatabaseInterface databaseInterface = SqliteWrapper.GetSqliteWrapper(runLog.RunLogPath, targetItem.ID, targetItem.ItemLabel);

            ItemLog itemLog = ItemLog.CreateNew(targetItem.ID, targetItem.ItemLabel, targetItem.ModuleDescription.ModuleType.Name, runLog.RunLogPath + "\\" + databaseInterface.GetDatabaseName());

            ((IDataTarget)targetModule).WriteData(connectionObject, databaseInterface, dataStore, reportProgressMethod);

            itemLog.EndTime = DateTime.Now;
            parentItemLog.SubFlowLogs.Add(itemLog);

            return(dataStore);
        }
コード例 #10
0
        public void Execute()
        {
            var designerItem = itemWorker.DesignerItem;

            IModule     stepModule       = objectResolver.GetModule(designerItem.ID, designerItem.ModuleDescription.ModuleType);
            IConnection connectionObject = null;

            if (designerItem.ModuleDescription.Attributes.RequiresConnection)
            {
                connectionObject = objectResolver.GetConnection(designerItem.ID);
            }
            IDatabaseInterface databaseInterface = SqliteWrapper.GetSqliteWrapper(runLog.RunLogPath, designerItem.ID, designerItem.ItemLabel);

            ((IStep)stepModule).Execute(connectionObject, databaseInterface, ReportProgressMethod);
        }
 private void BeServerChangeStatus(object sender, RoutedEventArgs e)
 {
     if (ProcessWrapper.Instance.IsRunning == false)
     {
         using (SqliteWrapper sqlite = new SqliteWrapper())
         {
             List <ServerModel> res = sqlite.ExecuteSelect <ServerModel>().ToList();
             ProcessWrapper.Instance.Start(res.FirstOrDefault(a => a.target == 1).path);
         }
     }
     else if (ProcessWrapper.Instance.IsRunning == true)
     {
         ProcessManager.LogManager.ServerLogManager.Instance.GetLog();
         ProcessWrapper.Instance.Stop();
     }
 }
コード例 #12
0
        private void RefreshData()
        {
            List <ServerModel> serverModelList = null;

            using (SqliteWrapper sqliteWrapper = new SqliteWrapper())
            {
                serverModelList = sqliteWrapper.ExecuteSelect <ServerModel>().ToList();
            }
            FilePathSettingCollection   = new ObservableCollection <ServerModel>(serverModelList);
            FilePathSetting.DataContext = FilePathSettingCollection;
            FilePathSetting.Items.IndexOf(FilePathSettingCollection.Where(a => a.target == 1));
            ServerModel targetFile = FilePathSettingCollection.FirstOrDefault(a => a.target == 1);

            FilePathSetting.SelectedIndex = FilePathSettingCollection.IndexOf(targetFile);
            ServerListBox.DataContext     = FilePathSettingCollection;
            SetTergetFilePathText(targetFile.name, targetFile.path);
        }
コード例 #13
0
        private static void App_Startup(object sender, StartupEventArgs e)
        {
            //ファイルパスが設定されていない場合、初期設定画面を表示
            IEnumerable <ServerModel> res = null;

            using (SqliteWrapper sqlite = new SqliteWrapper())
            {
                res = sqlite.ExecuteSelect <ServerModel>();
            }
            if (res.Count() == 0 || res.FirstOrDefault(a => a.target == 1) == null)
            {
                new InitialSettingWindow().Show();
            }
            else
            {
                new MainWindow().Show();
            }
        }
コード例 #14
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();
        }
コード例 #15
0
        public JsonResult <BaseModel> Start()
        {
            BaseModel beServer = new BaseModel();

            if (ProcessWrapper.Instance.IsRunning == false)
            {
                using (SqliteWrapper sqlite = new SqliteWrapper())
                {
                    List <ServerModel> res = sqlite.ExecuteSelect <ServerModel>().ToList();
                    ProcessWrapper.Instance.Start(res.FirstOrDefault(a => a.target == 1).path);
                }
                beServer.Result = true;
            }
            else if (ProcessWrapper.Instance.IsRunning == true)
            {
                beServer.Result = false;
            }
            return(Json(beServer));
        }
コード例 #16
0
 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);
 }
コード例 #17
0
        private void logMenu_SelectedItemChanged(object sender, RoutedPropertyChangedEventArgs <object> e)
        {
            if (logMenu.SelectedItem != null)
            {
                TreeViewItem menuItem = logMenu.SelectedItem as TreeViewItem;
                ItemLog      itemLog  = menuItem.Tag as ItemLog;

                this.LogLeader.Visibility = System.Windows.Visibility.Visible;
                this.LogLeader.SetItemLog(itemLog);
                this.LogLeader.SetDetailedLogVisibility(Visibility.Hidden);

                if (itemLog.ExecutionSuccessful)
                {
                    ModuleDescription moduleDescription = moduleDescriptions.Where(t => t.ModuleType.Name == itemLog.ModuleDescriptionName).FirstOrDefault();
                    ILogRendering     module            = Activator.CreateInstance(moduleDescription.ModuleType) as ILogRendering;
                    if (module != null)
                    {
                        string        databaseName  = itemLog.DesignerItemId.ToString() + "_" + itemLog.DesignerItemDisplayName.ToString().Replace(" ", "_") + ".db";
                        SqliteWrapper sqliteWrapper = new SqliteWrapper(runLog.RunLogPath, databaseName);

                        this.LogLeader.SetDetailedLogVisibility(Visibility.Visible);
                        logContent.Content = module.RenderLogWindow(sqliteWrapper);
                    }
                    else
                    {
                        logContent.Content = null;
                    }
                }
                else
                {
                    MessageControl messageControl = new MessageControl("Unexpected error occurred", itemLog.ExecutionError); // TODO Show execution error in logcontent
                    messageControl.VerticalAlignment = System.Windows.VerticalAlignment.Top;
                    messageControl.SetMessageHeight(800);
                    logContent.Content = messageControl;
                }
            }
        }