示例#1
0
        private async Task <List <XinFa> > DoLoadXinFaList()
        {
            var xinFaList       = new List <XinFa>();
            var mySqlConnection = _mainWindowViewModel.MySqlConnection;
            var sql             = "SELECT * FROM t_xinfa WHERE charguid=" + _charguid
                                  + " ORDER BY aid ASC";
            var mySqlCommand = new MySqlCommand(sql, mySqlConnection);
            await Task.Run(async() =>
            {
                var gameDbName = _mainWindowViewModel.SelectedServer.GameDbName;
                if (mySqlConnection.Database != gameDbName)
                {
                    // 切换数据库
                    await mySqlConnection.ChangeDataBaseAsync(gameDbName);
                }

                using (var rd = await mySqlCommand.ExecuteReaderAsync() as MySqlDataReader)
                {
                    while (await rd.ReadAsync())
                    {
                        var xinFaInfo = new XinFa()
                        {
                            Aid      = rd.GetInt32("aid"),
                            Charguid = rd.GetInt32("charguid"),
                            Xinfaid  = rd.GetInt32("xinfaid"),
                            Xinfalvl = rd.GetInt32("xinfalvl")
                        };
                        xinFaList.Add(xinFaInfo);
                    }
                }
            });

            return(xinFaList);
        }
 public void InitData(MainWindowViewModel mainWindowViewModel, XinFa xinFaInfo,
                      EditXinFaWindow editXinFaWindow)
 {
     _mainWindowViewModel = mainWindowViewModel;
     _xinFaInfo           = xinFaInfo;
     _editXinFaWindow     = editXinFaWindow;
     //初始化属性
     Aid      = xinFaInfo.Aid;
     Charguid = xinFaInfo.Charguid;
     Xinfaid  = xinFaInfo.Xinfaid;
     Xinfalvl = xinFaInfo.Xinfalvl;
 }
 public EditXinFaWindow(MainWindowViewModel mainWindowViewModel, XinFa xinFaInfo)
 {
     InitializeComponent();
     GetViewModel().InitData(mainWindowViewModel, xinFaInfo, this);
 }