private void btDownload_Click() { try{ var activesheet = (Excel.Worksheet)_excelapp.ActiveSheet; if (!_parser.checkTablePresent(activesheet)) { return; } using (var lForm = new FrmDownload(_excelapp.Hwnd)) { lForm.Reports = _parser.GetReportsList(activesheet.ListObjects[1]); lForm.Directory = _settings.GetWorksheetParam("Directory", @"C:\"); lForm.AssociatedInstance = _settings.GetWorksheetParam("DownInstance", "SPECIFIED"); lForm.Format = _settings.GetWorksheetParam("DownFormat", "DEFAULT"); if (lForm.ShowDialog() != DialogResult.OK) { return; } var reports = _parser.ParseListObjectToReports(activesheet.ListObjects[1], false); _settings.SetWorksheetParam("Directory", lForm.Directory); _settings.SetWorksheetParam("DownInstance", lForm.AssociatedInstance); _settings.SetWorksheetParam("DownFormat", lForm.Format); var scheduler = new SchedulerManager(_session); var runner = new FrmRunner(_session.Logger, scheduler.Cancel); var exitcode = runner.Execute(() => scheduler.DownloadReportsFile(ref reports, lForm.Directory, lForm.AssociatedInstance, lForm.Format) ); if (exitcode == ExitCode.FAILED || exitcode == ExitCode.CANCELED) { return; } _parser.UpdateListObjectStatus(activesheet.ListObjects[1], reports); } } catch (Exception ex) { new BusinessObjectsUtils.FrmException(_excelapp.Hwnd, ex).ShowDialog(); } }
private void BtnDownload_Click(object sender, RoutedEventArgs e) { frmDownload = new FrmDownload(mediaPlayer); frmMain.Content = frmDownload; currentPlaylist = frmDownload.GetPlaylist(); HideGridBtn(); }
private void btnNewMusic_Click(object sender, RoutedEventArgs e) { JavaScriptSerializer SoundsJsonSerizlizer = new JavaScriptSerializer(); var sounds = SoundsJsonSerizlizer.Deserialize<Dictionary<string, Dictionary<string, object>>>(_soundsJsonString); Hashtable DownloadFile = new Hashtable(); int FileCount=0; int DuplicateFileCount=0; int JsonDuplicateFileCount = 0; foreach (KeyValuePair<string, Dictionary<string, object>> SoundEntity in sounds) { switch (SoundEntity.Value["category"] as string) { case "ambient": case "weather": case "player": case "neutral": case "hostile": case "block": case "master": //arraylist var SoundFile = SoundEntity.Value["sounds"] as ArrayList; if (SoundFile==null) goto case "music"; foreach (string FileName in SoundFile) { FileCount++; string Url = UrlResourceBase + "sounds/" + FileName + ".ogg"; string SoundName = AppDomain.CurrentDomain.BaseDirectory + @"\.minecraft\assets\sounds\" + FileName + ".ogg"; DataRow[] result = _dt.Select("FileName = " + "'sounds/" + FileName + ".ogg'"); if (result.Count() != 0) { DuplicateFileCount++; continue; } if (DownloadFile.ContainsKey(Url)) { JsonDuplicateFileCount++; continue; } DownloadFile.Add(Url, SoundName); } break; case "music": var MusicFile = SoundEntity.Value["sounds"] as ArrayList; foreach (Dictionary<string,object> music in MusicFile) { if (!music.ContainsKey("stream")) continue; if ((bool)music["stream"] == false) continue; FileCount++; string Url = UrlResourceBase + "sounds/" + music["name"] + ".ogg"; string SoundName = AppDomain.CurrentDomain.BaseDirectory + @"\.minecraft\assets\sounds\" + music["name"] + ".ogg"; DataRow[] result = _dt.Select("FileName = " + "'sounds/" + music["name"] as string + ".ogg'"); if (result.Count() != 0) { DuplicateFileCount++; continue; } if (DownloadFile.ContainsKey(Url)) { JsonDuplicateFileCount++; continue; } DownloadFile.Add(Url, SoundName); } break; case "record": var RecordFile = SoundEntity.Value["sounds"] as ArrayList; if (RecordFile[0] is string) goto case "master"; else goto case "music"; } } Logger.log(string.Format("共计{0}个文件,{1}个文件重复,{2}个文件json内部重复,{3}个文件待下载",FileCount,DuplicateFileCount,JsonDuplicateFileCount,DownloadFile.Count)); FrmDownload frmDownload = new FrmDownload(DownloadFile); frmDownload.Show(); }
private void btnNewMusic_Click(object sender, RoutedEventArgs e) { JavaScriptSerializer SoundsJsonSerizlizer = new JavaScriptSerializer(); var sounds = SoundsJsonSerizlizer.Deserialize <Dictionary <string, Dictionary <string, object> > >(_soundsJsonString); Hashtable DownloadFile = new Hashtable(); int FileCount = 0; int DuplicateFileCount = 0; int JsonDuplicateFileCount = 0; foreach (KeyValuePair <string, Dictionary <string, object> > SoundEntity in sounds) { switch (SoundEntity.Value["category"] as string) { case "ambient": case "weather": case "player": case "neutral": case "hostile": case "block": case "master": //arraylist var SoundFile = SoundEntity.Value["sounds"] as ArrayList; if (SoundFile == null) { goto case "music"; } foreach (string FileName in SoundFile) { FileCount++; string Url = UrlResourceBase + "sounds/" + FileName + ".ogg"; string SoundName = AppDomain.CurrentDomain.BaseDirectory + @"\.minecraft\assets\sounds\" + FileName + ".ogg"; DataRow[] result = _dt.Select("FileName = " + "'sounds/" + FileName + ".ogg'"); if (result.Count() != 0) { DuplicateFileCount++; continue; } if (DownloadFile.ContainsKey(Url)) { JsonDuplicateFileCount++; continue; } DownloadFile.Add(Url, SoundName); } break; case "music": var MusicFile = SoundEntity.Value["sounds"] as ArrayList; foreach (Dictionary <string, object> music in MusicFile) { if (!music.ContainsKey("stream")) { continue; } if ((bool)music["stream"] == false) { continue; } FileCount++; string Url = UrlResourceBase + "sounds/" + music["name"] + ".ogg"; string SoundName = AppDomain.CurrentDomain.BaseDirectory + @"\.minecraft\assets\sounds\" + music["name"] + ".ogg"; DataRow[] result = _dt.Select("FileName = " + "'sounds/" + music["name"] as string + ".ogg'"); if (result.Count() != 0) { DuplicateFileCount++; continue; } if (DownloadFile.ContainsKey(Url)) { JsonDuplicateFileCount++; continue; } DownloadFile.Add(Url, SoundName); } break; case "record": var RecordFile = SoundEntity.Value["sounds"] as ArrayList; if (RecordFile[0] is string) { goto case "master"; } else { goto case "music"; } } } Logger.Log(string.Format("共计{0}个文件,{1}个文件重复,{2}个文件json内部重复,{3}个文件待下载", FileCount, DuplicateFileCount, JsonDuplicateFileCount, DownloadFile.Count)); FrmDownload frmDownload = new FrmDownload(DownloadFile); frmDownload.Show(); }