private void Push(DbOperate operate) { var collection = new DbOperateCollection(); collection.Add(operate); Push(collection); }
/// <summary> /// 数据库测试 /// </summary> private void button_textsql_Click(object sender, EventArgs e) { IDbOperate dbt = new DbOperate(); //数据库连接 try { string result = string.Empty; bool fa = dbt.TestConnection(out result); if (fa) { MessageBox.Show("连接成功,可以进行下一步操作!"); } else { MessageBox.Show("连接失败,请检查数据库配置!" + result); } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } finally { dbt.Dispose(); } }
public object PutOnlineInfo([FromBody] Nb_User nb_User) { string strInsert = "merge into sc_onlinev1 t1 using (select '" + nb_User.BranchCode + "' branchcode from dual)t2 on(t1.branchcode = t2.branchcode) when matched then update set branchname = '" + nb_User.BranchName + "', agentcode = '" + nb_User.AgentCode + "', notsyncqty = " + nb_User.NotSyncQty + ", errsyncqty = " + nb_User.ErrSyncQty + ", lastonlinedate = to_date('" + nb_User.LastOnlineDate + "', 'yyyy/MM/dd HH24:mi:ss'), lastsyncqty = " + nb_User.LastSyncQty + ", lastelapsed = " + nb_User.LastElapsed + " when not matched then insert(branchcode, branchname, agentcode, notsyncqty, errsyncqty, lastonlinedate, lastsyncqty, lastelapsed) values('" + nb_User.BranchCode + "', '" + nb_User.BranchName + "', '" + nb_User.AgentCode + "', " + nb_User.NotSyncQty + ", " + nb_User.ErrSyncQty + ", to_date('" + nb_User.LastOnlineDate + "', 'yyyy/MM/dd HH24:mi:ss'), " + nb_User.LastSyncQty + ", " + nb_User.LastElapsed + ")"; string effectedRows = DbOperate.Insert(strInsert); return("插入成功:当前受影响行数为" + effectedRows); }
public object PutDownloadInfo([FromBody] Parameters parameters) { string strInsert = "merge into sc_downloadinfo t1 using (select '" + parameters.BranchCode + "' branchcode,'" + parameters.DBranchCode + "' dbranchcode,'" + parameters.TableName + "' tablename,'" + parameters.Category + "' category,'" + parameters.DataBaseId + "' databaseid from dual) t2 on(t1.branchcode = t2.branchcode and t1.dbranchcode = t2.dbranchcode and t1.tablename = t2.tablename and t1.category = t2.category and t1.databaseid = t2.databaseid) when matched then update set key = '" + parameters.Key + "', pageindex = " + parameters.PageIndex + ", begindate = to_date('" + parameters.BeginDate + "', 'yyyy/MM/dd HH24:mi:ss'), enddate = to_date('" + parameters.EndDate + "', 'yyyy/MM/dd HH24:mi:ss') when not matched then insert(branchcode, tablename, category, begindate, enddate, pageindex, key, databaseid, dbranchcode) values('" + parameters.BranchCode + "', '" + parameters.TableName + "', '" + parameters.Category + "', to_date('" + parameters.BeginDate + "', 'yyyy/MM/dd HH24:mi:ss'), to_date('" + parameters.EndDate + "', 'yyyy/MM/dd HH24:mi:ss'), " + parameters.PageIndex + ", '" + parameters.Key + "', '" + parameters.DataBaseId + "', '" + parameters.DBranchCode + "')"; string effectedRows = DbOperate.Insert(strInsert); //将数据插入数据库 return("data:" + parameters + " 插入成功;\n\n 当前受影响的行数:" + effectedRows + "行。"); }
private void BtnNew_Click(object sender, RoutedEventArgs e) { DbOperate.AddCollection(CollectionName.Text); _window.UpdateCollections(); Dispose(); _page?.RefreshList(); }
/// <summary> /// Update collections in the navigation bar. /// </summary> public void UpdateCollections() { var list = (List <Collection>)DbOperate.GetCollections(); list.Reverse(); ViewModel.Collection = list; }
private bool IsMapFavorite(MapInfo info) { var album = DbOperate.GetCollectionsByMap(info); bool isFavorite = album != null && album.Any(k => k.Locked); return(isFavorite); }
/// <summary> /// Update collections in the navigation bar. /// </summary> public void UpdateCollections() { var list = (List <Collection>)DbOperate.GetCollections(); list.Reverse(); ViewModel.Collection = new ObservableCollection <Collection>(list); }
/// <summary> /// Popup a dialog for adding music to a collection. /// </summary> private async void BtnLike_Click(object sender, RoutedEventArgs e) { var entry = BeatmapQuery.FilterByIdentity(InstanceManage.GetInstance <PlayerList>().CurrentIdentity); //var entry = App.PlayerList?.CurrentInfo.Beatmap; if (entry == null) { MsgBox.Show(this, "该图不存在于该osu!db中。", Title, MessageBoxButton.OK, MessageBoxImage.Exclamation); return; } if (!ViewModel.IsMiniMode) { FramePop.Navigate(new SelectCollectionPage(this, entry)); } else { var collection = DbOperate.GetCollections().First(k => k.Locked); if (InstanceManage.GetInstance <PlayerList>().CurrentInfo.IsFavorite) { DbOperate.RemoveMapFromCollection(entry, collection); InstanceManage.GetInstance <PlayerList>().CurrentInfo.IsFavorite = false; } else { await SelectCollectionPage.AddToCollectionAsync(collection, entry); InstanceManage.GetInstance <PlayerList>().CurrentInfo.IsFavorite = true; } } IsMapFavorite(InstanceManage.GetInstance <PlayerList>().CurrentInfo.Identity); }
private void BtnSave_Click(object sender, RoutedEventArgs e) { _collection.Name = ViewModel.Name; _collection.Description = ViewModel.Description; _collection.ImagePath = ViewModel.CoverPath; DbOperate.UpdateCollection(_collection); BtnClose_Click(sender, e); }
/// <summary> /// Offset Settings /// </summary> private void Offset_DragDelta(object sender, DragDeltaEventArgs e) { if (ComponentPlayer.Current == null) { return; } ComponentPlayer.Current.HitsoundOffset = (int)Offset.Value; DbOperate.UpdateMap(InstanceManage.GetInstance <PlayerList>().CurrentInfo.Identity, ComponentPlayer.Current.HitsoundOffset); }
private static void InitLocalDb() { var defCol = DbOperate.GetCollections().Where(k => k.Locked); if (!defCol.Any()) { DbOperate.AddCollection("最喜爱的", true); } }
private void BtnDelAll_Click(object sender, RoutedEventArgs e) { var result = MsgBox.Show(_mainWindow, "真的要删除全部吗?", _mainWindow.Title, MessageBoxButton.YesNo, MessageBoxImage.Question); if (result == MessageBoxResult.Yes) { DbOperate.ClearRecent(); UpdateList(); } }
public CollectionPage(MainWindow mainWindow, Collection collectionInfo) { InitializeComponent(); _mainWindow = mainWindow; ViewModel = (CollectionPageViewModel)this.DataContext; ViewModel.CollectionInfo = collectionInfo; var infos = (List <MapInfo>)DbOperate.GetMapsFromCollection(collectionInfo); _entries = infos.ToBeatmapEntries(InstanceManage.GetInstance <OsuDbInst>().Beatmaps, false); ViewModel.Beatmaps = new NumberableObservableCollection <BeatmapDataModel>(_entries.ToDataModels(false)); }
private void BtnDelCol_Click(object sender, RoutedEventArgs e) { var result = MsgBox.Show(_mainWindow, "确认删除收藏夹?", _mainWindow.Title, MessageBoxButton.YesNo, MessageBoxImage.Question); if (result == MessageBoxResult.Yes) { DbOperate.RemoveCollection(ViewModel.CollectionInfo); _mainWindow.MainFrame.Navigate(_mainWindow.Pages.RecentPlayPage); _mainWindow.UpdateCollections(); } }
public CollectionPage(MainWindow mainWindow, Collection collectionInfo) { InitializeComponent(); _mainWindow = mainWindow; ViewModel = (CollectionPageViewModel)this.DataContext; ViewModel.CollectionInfo = collectionInfo; var infos = (List <MapInfo>)DbOperate.GetMapsFromCollection(collectionInfo); _entries = BeatmapQuery.GetBeatmapsByIdentifiable(infos, false); ViewModel.Beatmaps = new NumberableObservableCollection <BeatmapDataModel>(_entries.ToDataModels(false)); }
private bool SetFaved(MapIdentity identity) { var map = DbOperate.GetMapFromDb(identity); var album = DbOperate.GetCollectionsByMap(map); bool faved = album != null && album.Any(k => k.Locked); BtnLike.Background = faved ? (ViewModel.IsMiniMode ? (Brush)ToolControl.FindResource("FavedS") : (Brush)ToolControl.FindResource("Faved")) : (ViewModel.IsMiniMode ? (Brush)ToolControl.FindResource("FavS") : (Brush)ToolControl.FindResource("Fav")); return(faved); }
private async void ItemDelete_Click(object sender, RoutedEventArgs e) { if (MapList.SelectedItem == null) { return; } var selected = MapList.SelectedItems; var entries = ConvertToEntries(selected.Cast <BeatmapDataModel>()); foreach (var entry in entries) { DbOperate.RemoveMapFromCollection(entry.GetIdentity(), ViewModel.CollectionInfo); } //var dataModel = (BeatmapDataModel)MapList.SelectedItem; UpdateList(); await InstanceManage.GetInstance <PlayerList>().RefreshPlayListAsync(PlayerList.FreshType.All, PlayListMode.Collection, _entries); }
private async void ItemDelete_Click(object sender, RoutedEventArgs e) { if (RecentList.SelectedItem == null) { return; } var selected = RecentList.SelectedItems; var entries = ConvertToEntries(selected.Cast <BeatmapDataModel>()); //var searchInfo = (BeatmapDataModel)RecentList.SelectedItem; foreach (var entry in entries) { DbOperate.RemoveFromRecent(entry.GetIdentity()); } UpdateList(); await InstanceManage.GetInstance <PlayerList>().RefreshPlayListAsync(PlayerList.FreshType.All, PlayListMode.RecentList); }
[HttpGet("GetDownloadInfo/{key}/{b}/{bd}/{t}/{c}")] /// public Parameters GetDownloadInfo(string key, string b, string bd, string t, string c) { OracleConnection cn = DbOperate.Conn(); DataTable dt = DbOperate.Execute("select * from sc_DownloadInfo where key = '" + key + "' AND branchcode = '" + b + "' AND dbranchcode = '" + bd + "' AND tablename = '" + t + "' AND category = '" + c + "'", cn); Parameters parameters = new Parameters(); parameters.BranchCode = dt.Rows[0][0].ToString(); parameters.TableName = dt.Rows[0][1].ToString(); parameters.Category = dt.Rows[0][2].ToString(); parameters.BeginDate = Convert.ToDateTime(dt.Rows[0][3]); parameters.EndDate = Convert.ToDateTime(dt.Rows[0][4]); parameters.PageIndex = Convert.ToInt32(dt.Rows[0][5]); parameters.Key = dt.Rows[0][7].ToString(); parameters.DataBaseId = dt.Rows[0][9].ToString();; parameters.DBranchCode = dt.Rows[0][10].ToString(); return(parameters); }
/// <summary> /// Navigate collection page. /// </summary> private void BtnCollection_Click(object sender, RoutedEventArgs e) { var btn = (ToggleButton)sender; var colId = (string)btn.Tag; if (MainFrame.Content?.GetType() != typeof(CollectionPage)) { MainFrame.Navigate(new CollectionPage(this, DbOperate.GetCollectionById(colId))); } if (MainFrame.Content?.GetType() == typeof(CollectionPage)) { var sb = (CollectionPage)MainFrame.Content; if (sb.Id != colId) { MainFrame.Navigate(new CollectionPage(this, DbOperate.GetCollectionById(colId))); } } }
public static async Task AddToCollectionAsync(Collection col, BeatmapEntry entry) { if (string.IsNullOrEmpty(col.ImagePath)) { var osuFile = await OsuFile.ReadFromFileAsync(Path.Combine(Domain.OsuSongPath, entry.FolderName, entry.BeatmapFileName)); if (osuFile.Events.BackgroundInfo != null) { var imgPath = Path.Combine(Domain.OsuSongPath, entry.FolderName, osuFile.Events.BackgroundInfo.Filename); if (File.Exists(imgPath)) { col.ImagePath = imgPath; DbOperate.UpdateCollection(col); } } } DbOperate.AddMapToCollection(entry, col); }
public void RefreshList() { ViewModel.Collections = new ObservableCollection <CollectionViewModel>( CollectionViewModel.CopyFrom(DbOperate.GetCollections().OrderByDescending(k => k.CreateTime))); }
private bool IsMapFavorite(MapIdentity identity) { var info = DbOperate.GetMapFromDb(identity); return(IsMapFavorite(info)); }
/// <summary> /// Play a new file by file path. /// </summary> private async Task PlayNewFile(string path, bool play) { var sw = Stopwatch.StartNew(); var playerInst = InstanceManage.GetInstance <PlayersInst>(); var dbInst = InstanceManage.GetInstance <OsuDbInst>(); ComponentPlayer audioPlayer = null; if (path == null) { return; } if (File.Exists(path)) { try { var osuFile = await OsuFile.ReadFromFileAsync(path); //50 ms var fi = new FileInfo(path); if (!fi.Exists) { throw new FileNotFoundException("Cannot locate.", fi.FullName); } var dir = fi.Directory.FullName; /* Clear */ ClearHitsoundPlayer(); /* Set new hitsound player*/ playerInst.SetAudioPlayer(path, osuFile); audioPlayer = playerInst.AudioPlayer; SignUpPlayerEvent(audioPlayer); await audioPlayer.InitializeAsync(); //700 ms /* Set Meta */ var nowIdentity = new MapIdentity(fi.Directory.Name, osuFile.Metadata.Version); MapInfo mapInfo = DbOperate.GetMapFromDb(nowIdentity); Beatmap beatmap = BeatmapQuery.FilterByIdentity(nowIdentity); bool isFavorite = IsMapFavorite(mapInfo); //50 ms audioPlayer.HitsoundOffset = mapInfo.Offset; Offset.Value = audioPlayer.HitsoundOffset; var currentInfo = new CurrentInfo( osuFile.Metadata.Artist, osuFile.Metadata.ArtistUnicode, osuFile.Metadata.Title, osuFile.Metadata.TitleUnicode, osuFile.Metadata.Creator, osuFile.Metadata.Source, osuFile.Metadata.TagList, osuFile.Metadata.BeatmapId, osuFile.Metadata.BeatmapSetId, beatmap?.DiffSrNoneStandard ?? 0, osuFile.Difficulty.HpDrainRate, osuFile.Difficulty.CircleSize, osuFile.Difficulty.ApproachRate, osuFile.Difficulty.OverallDifficulty, audioPlayer.Duration, nowIdentity, mapInfo, beatmap, isFavorite); // 20 ms InstanceManage.GetInstance <PlayerList>().CurrentInfo = currentInfo; ViewModel.Player.CurrentInfo = currentInfo; /*start of ui*/ LblTitle.Content = osuFile.Metadata.TitleMeta.ToUnicodeString(); LblArtist.Content = osuFile.Metadata.ArtistMeta.ToUnicodeString(); ((ToolTip)NotifyIcon.TrayToolTip).Content = (string)LblArtist.Content + " - " + (string)LblTitle.Content; /*end of ui*/ /* Set Lyric */ SetLyricSynchronously(); /* Set Progress */ PlayProgress.Maximum = audioPlayer.Duration; PlayProgress.Value = 0; PlayerViewModel.Current.Duration = InstanceManage.GetInstance <PlayersInst>().AudioPlayer.Duration; /* Set Storyboard */ if (true) { // Todo: Set Storyboard } /* Set Video */ bool showVideo = PlayerViewModel.Current.EnableVideo && !ViewModel.IsMiniMode; if (VideoElement != null) { await SafelyRecreateVideoElement(showVideo); if (showVideo) { var videoName = osuFile.Events.VideoInfo?.Filename; if (videoName == null) { VideoElement.Source = null; VideoElementBorder.Visibility = Visibility.Hidden; } else { var vPath = Path.Combine(dir, videoName); if (File.Exists(vPath)) { VideoElement.Source = new Uri(vPath); _videoOffset = -(osuFile.Events.VideoInfo.Offset); if (_videoOffset >= 0) { _waitAction = () => { }; _position = TimeSpan.FromMilliseconds(_videoOffset); } else { _waitAction = () => { Thread.Sleep(TimeSpan.FromMilliseconds(-_videoOffset)); }; } } else { VideoElement.Source = null; VideoElementBorder.Visibility = Visibility.Hidden; } } } } /* Set Background */ if (osuFile.Events.BackgroundInfo != null) { var bgPath = Path.Combine(dir, osuFile.Events.BackgroundInfo.Filename); BlurScene.Source = File.Exists(bgPath) ? new BitmapImage(new Uri(bgPath)) : null; Thumb.Source = File.Exists(bgPath) ? new BitmapImage(new Uri(bgPath)) : null; } else { BlurScene.Source = null; } /* Start Play */ switch (MainFrame.Content) { case RecentPlayPage recentPlayPage: var item = recentPlayPage.DataModels.FirstOrDefault(k => k.GetIdentity().Equals(nowIdentity)); recentPlayPage.RecentList.SelectedItem = item; break; case CollectionPage collectionPage: collectionPage.MapList.SelectedItem = collectionPage.ViewModel.Beatmaps.FirstOrDefault(k => k.GetIdentity().Equals(nowIdentity)); break; } _videoPlay = play; if (play) { if (showVideo && VideoElement?.Source != null) { // use event to control here. //VideoPlay(); //App.HitsoundPlayer.Play(); } else { audioPlayer.Play(); } } //if (!App.PlayerList.Entries.Any(k => k.GetIdentity().Equals(nowIdentity))) // App.PlayerList.Entries.Add(entry); PlayerConfig.Current.CurrentPath = path; PlayerConfig.SaveCurrent(); DbOperate.UpdateMap(nowIdentity); } catch (Exception ex) { var result = MsgBox.Show(this, @"发生未处理的异常问题:" + (ex.InnerException ?? ex), Title, MessageBoxButton.OK, MessageBoxImage.Error); if (result == MessageBoxResult.OK) { if (audioPlayer == null) { return; } if (audioPlayer.PlayerStatus != PlayerStatus.Playing) { await PlayNextAsync(false, true); } } Console.WriteLine(ex); } } else { MsgBox.Show(this, @"所选文件不存在,可能是db没有及时更新。请关闭此播放器或osu后重试。", Title, MessageBoxButton.OK, MessageBoxImage.Warning); } sw.Stop(); Console.WriteLine(sw.ElapsedMilliseconds); }
public ActionResult BackDB() { bool result = DbOperate.BackDB(Server.MapPath("/DB") + "/" + DateTime.Now.ToString("yyyyMMdd")); return(Content("<script>alert('备份成功')</script>")); }