示例#1
0
        public static void Run <THost>() where THost : IHost, new()
        {
            using IHost host = new THost();

            HostConfiguration config = HostConfiguration.Debug;

            //
            // Konfiguracio kiolvasasa az [appname].runtimeconfig.json fajlbol
            //

            object?data = AppContext.GetData("hostConfiguration");

            if (data != null)
            {
                Enum.TryParse(data.ToString(), out config);
            }

            using IHostRunner runner = CreateRunner(host, config);

            //
            // Blokkolodik
            //

            runner.Start();
        }
示例#2
0
        public bool UpdateServer(THost tHost)
        {
            bool   b   = false;
            string sql = @"UPDATE t_host SET name=@name,ip=@ip,war=@war,username=@username,password=@password,instructions=@instructions WHERE id=@id";

            SQLiteParameter[] parameters =
            {
                new SQLiteParameter("@name",         tHost.name),
                new SQLiteParameter("@ip",           tHost.ip),
                new SQLiteParameter("@war",          tHost.war),
                new SQLiteParameter("@username",     tHost.username),
                new SQLiteParameter("@password",     tHost.password),
                new SQLiteParameter("@instructions", tHost.instructions),
                new SQLiteParameter("@id",           tHost.id),
            };
            if (SQLiteHelper.ExecuteSql(sql, parameters) != 1)
            {
                b = false;
            }
            else
            {
                b = true;
            }

            return(b);
        }
示例#3
0
        public bool AddServer(THost tHost)
        {
            bool   b   = false;
            string sql = @"INSERT INTO t_host (name,ip,war,username,password,instructions) VALUES(@name,@ip,@war,@username,@password,@instructions)";

            SQLiteParameter[] parameters =
            {
                new SQLiteParameter("@name",         tHost.name),
                new SQLiteParameter("@ip",           tHost.ip),
                new SQLiteParameter("@war",          tHost.war),
                new SQLiteParameter("@username",     tHost.username),
                new SQLiteParameter("@password",     tHost.password),
                new SQLiteParameter("@instructions", tHost.instructions),
            };
            if (SQLiteHelper.ExecuteSql(sql, parameters) != 1)
            {
                b = false;
            }
            else
            {
                b = true;
            }

            return(b);
        }
示例#4
0
        private void butUpdate_Click(object sender, EventArgs e)
        {
            //MessageBox.Show(FrmMain.serverId);
            string warList = "";

            foreach (Control item in groupBoxWar.Controls)
            {
                if (((CheckBox)item).Checked)
                {
                    warList += (item.Text.Trim() + ",");
                }
            }

            THost tHost = new THost()
            {
                name         = this.txtName.Text.Trim(),
                ip           = this.txtIp.Text.Trim(),
                war          = warList,
                username     = this.txtUserName.Text.Trim(),
                password     = txtPassWord.Text.Trim(),
                instructions = txtInstructions.Text.Trim(),
                id           = Convert.ToInt32(FrmMain.serverId)
            };

            try
            {
                if (thostDal.UpdateServer(tHost) == true)
                {
                    MessageBox.Show("添加成功");
                    this.Close();
                }
                else
                {
                    MessageBox.Show("输入有误");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("添加失败" + ex.Message);
            }
        }