public void testTimestampSerialization() { // There is a kryo which after serialize/deserialize, // Timestamp becomes Date. We get around this issue in // SearchArgumentImpl.getLiteral. Once kryo fixed the issue // We can simplify SearchArgumentImpl.getLiteral Timestamp now = new Timestamp(new java.util.Date().getTime()); SearchArgument sarg = SearchArgumentFactory.newBuilder() .startAnd() .lessThan("x", PredicateLeaf.Type.TIMESTAMP, now) .end() .build(); string serializedSarg = TestInputOutputFormat.toKryo(sarg); SearchArgument sarg2 = ConvertAstToSearchArg.create(serializedSarg); Field literalField = typeof(PredicateLeafImpl).getDeclaredField("literal"); literalField.setAccessible(true); assertTrue(literalField.get(sarg2.getLeaves()[0]) is java.util.Date); Timestamp ts = (Timestamp)sarg2.getLeaves()[0].getLiteral(); Assert.Equal(ts, now); }
public void testBuilder() { SearchArgument sarg = SearchArgumentFactory.newBuilder() .startAnd() .lessThan("x", PredicateLeaf.Type.LONG, 10L) .lessThanEquals("y", PredicateLeaf.Type.STRING, "hi") .equals("z", PredicateLeaf.Type.FLOAT, 1.0) .end() .build(); Assert.Equal("leaf-0 = (LESS_THAN x 10), " + "leaf-1 = (LESS_THAN_EQUALS y hi), " + "leaf-2 = (EQUALS z 1), " + "expr = (and leaf-0 leaf-1 leaf-2)", sarg.ToString()); sarg = SearchArgumentFactory.newBuilder() .startNot() .startOr() .isNull("x", PredicateLeaf.Type.LONG) .between("y", PredicateLeaf.Type.LONG, 10L, 20L) .@in("z", PredicateLeaf.Type.LONG, 1L, 2L, 3L) .nullSafeEquals("a", PredicateLeaf.Type.STRING, "stinger") .end() .end() .build(); Assert.Equal("leaf-0 = (IS_NULL x), " + "leaf-1 = (BETWEEN y 10 20), " + "leaf-2 = (IN z 1 2 3), " + "leaf-3 = (NULL_SAFE_EQUALS a stinger), " + "expr = (and (not leaf-0) (not leaf-1) (not leaf-2) (not leaf-3))", sarg.ToString()); }
protected override Expression <Func <Person, bool> > GetPredicateForContains(SearchArgument arg) { if (arg is null) { throw new ArgumentNullException(nameof(arg)); } else { Expression <Func <Person, bool> > returnValue; if (arg.PropertyName == "FirstName") { returnValue = (p) => p.FirstName.Contains(arg.SearchValue); } else if (arg.PropertyName == "LastName") { returnValue = (p) => p.LastName.Contains(arg.SearchValue); } else if (arg.PropertyName == "NoteText") { returnValue = (p) => p.Notes.Any(n => n.NoteText.Contains(arg.SearchValue)); } else { throw new InvalidOperationException( String.Format("Unknown argument '{0}'.", arg.PropertyName)); } return(returnValue); } }
public void testBuilderComplexTypes2() { SearchArgument sarg = SearchArgumentFactory.newBuilder() .startAnd() .lessThan("x", PredicateLeaf.Type.DATE, Date.Parse("2005-3-12")) .lessThanEquals("y", PredicateLeaf.Type.STRING, "hi") .equals("z", PredicateLeaf.Type.DECIMAL, HiveDecimal.Parse("1.0")) .end() .build(); Assert.Equal("leaf-0 = (LESS_THAN x 2005-03-12), " + "leaf-1 = (LESS_THAN_EQUALS y hi), " + "leaf-2 = (EQUALS z 1.0), " + "expr = (and leaf-0 leaf-1 leaf-2)", sarg.ToString()); sarg = SearchArgumentFactory.newBuilder() .startNot() .startOr() .isNull("x", PredicateLeaf.Type.LONG) .between("y", PredicateLeaf.Type.DECIMAL, HiveDecimal.Parse("10"), HiveDecimal.Parse("20.0")) .@in("z", PredicateLeaf.Type.LONG, 1L, 2L, 3L) .nullSafeEquals("a", PredicateLeaf.Type.STRING, "stinger") .end() .end() .build(); Assert.Equal("leaf-0 = (IS_NULL x), " + "leaf-1 = (BETWEEN y 10 20.0), " + "leaf-2 = (IN z 1 2 3), " + "leaf-3 = (NULL_SAFE_EQUALS a stinger), " + "expr = (and (not leaf-0) (not leaf-1) (not leaf-2) (not leaf-3))", sarg.ToString()); }
public static IQueryable <RollBackDistributionCompanyInfo> SelectSearch(SearchArgument sArgument, string orderBy, int startRowIndex, int maximumRows) { if (startRowIndex == -1) { return(null); } return(SelectDynamicSearch(sArgument, orderBy).Skip(startRowIndex).Take(maximumRows)); }
protected override Expression <Func <PersonEntity, bool> > GetPredicateForEndsWith( SearchArgument arg) { if (arg is null) { throw new ArgumentNullException(nameof(arg)); } else { if (arg.PropertyName == nameof(PersonEntity.FirstName)) { return(q => q.FirstName.EndsWith(arg.SearchValue)); } else if (arg.PropertyName == nameof(PersonEntity.LastName)) { return(q => q.LastName.EndsWith(arg.SearchValue)); } else if (arg.PropertyName == nameof(PersonEntity.PhoneNumber)) { return(q => q.PhoneNumber.EndsWith(arg.SearchValue)); } else if (arg.PropertyName == nameof(PersonEntity.EmailAddress)) { return(q => q.EmailAddress.EndsWith(arg.SearchValue)); } else if (arg.PropertyName == nameof(PersonEntity.Status)) { return(q => q.Status.EndsWith(arg.SearchValue)); } else if (arg.PropertyName == nameof(PersonEntity.CreatedBy)) { return(q => q.CreatedBy.EndsWith(arg.SearchValue)); } else if (arg.PropertyName == nameof(PersonEntity.LastModifiedBy)) { return(q => q.LastModifiedBy.EndsWith(arg.SearchValue)); } else { throw new InvalidOperationException( String.Format("Unknown argument '{0}'.", arg.PropertyName)); } } }
public void GetSongs_ForApocalypseNow_ExpectedArtist(string title, string styles, string moods, string expect) { TermList styleTerms = new TermList(); foreach (string s in styles.Split(',')) { styleTerms.Add(s); } TermList moodTerms = new TermList(); foreach (string s in moods.Split(',')) { moodTerms.Add(s); } SearchArgument searchArgument = new SearchArgument { Mode = "0", /* minor */ Sort = "artist_familiarity-desc", Results = 10 }; searchArgument.Styles.AddRange(styleTerms); searchArgument.Moods.AddRange(moodTerms); using (var session = new EchoNestSession(ApiKey)) { SearchResponse searchResponse = session.Query <Search>().Execute(searchArgument); Assert.IsNotNull(searchResponse); Assert.IsNotNull(searchResponse.Songs); var matches = (from s in searchResponse.Songs where s.ArtistName.ToLower().Contains(expect) select s).ToList(); Assert.IsNotNull(matches, "Failed to find songs where artist name contains: {0}", expect); System.Diagnostics.Debug.WriteLine("Tracks for '{0}'", title); foreach (SongBucketItem song in searchResponse.Songs) { System.Diagnostics.Debug.WriteLine("\t{0} ({1})", song.Title, song.ArtistName); } } }
protected override Expression <Func <LookupEntity, bool> > GetPredicateForEndsWith( SearchArgument arg) { if (arg is null) { throw new ArgumentNullException(nameof(arg)); } else { if (arg.PropertyName == nameof(LookupEntity.LookupType)) { return(q => q.LookupType.EndsWith(arg.SearchValue)); } else if (arg.PropertyName == nameof(LookupEntity.LookupKey)) { return(q => q.LookupKey.EndsWith(arg.SearchValue)); } else if (arg.PropertyName == nameof(LookupEntity.LookupValue)) { return(q => q.LookupValue.EndsWith(arg.SearchValue)); } else if (arg.PropertyName == nameof(LookupEntity.Status)) { return(q => q.Status.EndsWith(arg.SearchValue)); } else if (arg.PropertyName == nameof(LookupEntity.CreatedBy)) { return(q => q.CreatedBy.EndsWith(arg.SearchValue)); } else if (arg.PropertyName == nameof(LookupEntity.LastModifiedBy)) { return(q => q.LastModifiedBy.EndsWith(arg.SearchValue)); } else { throw new InvalidOperationException( String.Format("Unknown argument '{0}'.", arg.PropertyName)); } } }
public string GetSongId(string title) { SearchArgument searchArgument = new SearchArgument { Title = title }; using (var session = new EchoNestSession(ApiKey)) { SearchResponse searchResponse = session.Query <Search>().Execute(searchArgument); Assert.IsNotNull(searchResponse); Assert.IsNotNull(searchResponse.Songs); Assert.IsTrue(searchResponse.Songs.Count > 0); return(searchResponse.Songs.First().ID); } }
public static int SelectSearchCountCached(SearchArgument sArgument) { int n = sArgument.SearchArguments.Count; string key = GetCacheKey("Count"); for (int i = 0; i < n; i++) { key += sArgument.SearchArguments[i].PropertyField + sArgument.SearchArguments[i].Comparator + sArgument.SearchArguments[i].FValue.ToString(); } int?count = (int?)HttpContext.Current.Cache[key]; if (count == null) { count = SelectSearchCount(sArgument); AddCache(key, count); } return(count.Value); }
public void testBuilderFloat() { SearchArgument sarg = SearchArgumentFactory.newBuilder() .startAnd() .lessThan("x", PredicateLeaf.Type.LONG, 22L) .lessThan("x1", PredicateLeaf.Type.LONG, 22L) .lessThanEquals("y", PredicateLeaf.Type.STRING, "hi") .equals("z", PredicateLeaf.Type.FLOAT, 0.22) .equals("z1", PredicateLeaf.Type.FLOAT, 0.22) .end() .build(); Assert.Equal("leaf-0 = (LESS_THAN x 22), " + "leaf-1 = (LESS_THAN x1 22), " + "leaf-2 = (LESS_THAN_EQUALS y hi), " + "leaf-3 = (EQUALS z 0.22), " + "leaf-4 = (EQUALS z1 0.22), " + "expr = (and leaf-0 leaf-1 leaf-2 leaf-3 leaf-4)", sarg.ToString()); }
private void RecordView_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e) { SearchArgument args = (SearchArgument)RecordView.Tag; if (args.MergeRows) { // merged if (e.ColumnIndex == RecordView_Header.Index || e.ColumnIndex == RecordView_RankS.Index || e.ColumnIndex == RecordView_RankA.Index || e.ColumnIndex == RecordView_RankB.Index) { if (RecordView[e.ColumnIndex, e.RowIndex].Tag is double) { e.Value = string.Format("{0} ({1:p1})", e.Value, (double)RecordView[e.ColumnIndex, e.RowIndex].Tag); } else { int max = (int)RecordView[e.ColumnIndex, e.RowIndex].Tag; e.Value = string.Format("{0}/{1} ({2:p1})", e.Value, max, (double)((int)e.Value) / Math.Max(max, 1)); } e.FormattingApplied = true; } } else { //not merged if (e.ColumnIndex == RecordView_Date.Index) { e.Value = DateTimeHelper.TimeToCSVString((DateTime)e.Value); e.FormattingApplied = true; } else if (e.ColumnIndex == RecordView_Rank.Index) { e.Value = Constants.GetWinRank((int)e.Value); e.FormattingApplied = true; } } }
private void RecordView_CellDoubleClick(object sender, DataGridViewCellEventArgs e) { SearchArgument args = (SearchArgument)RecordView.Tag; if (args == null || args.MergeRows) { return; } try { DateTime time = Convert.ToDateTime(RecordView[RecordView_Date.Index, e.RowIndex].Value); if (!Directory.Exists(Data.Battle.BattleManager.BattleLogPath)) { StatusInfo.Text = "Battle history was not found."; return; } StatusInfo.Text = "Searching battle history..."; string battleLogFile = Directory.EnumerateFiles(Data.Battle.BattleManager.BattleLogPath, time.ToString("yyyyMMdd_HHmmss", System.Globalization.CultureInfo.InvariantCulture) + "*.txt", SearchOption.TopDirectoryOnly) .FirstOrDefault(); if (battleLogFile == null) { StatusInfo.Text = "Battle history could not be found."; return; } StatusInfo.Text = string.Format("Open battle history {0}.", Path.GetFileName(battleLogFile)); System.Diagnostics.Process.Start(battleLogFile); } catch (Exception) { StatusInfo.Text = "Could not open battle history."; } }
private void FetchPreview() { using (var session = new EchoNestSession(EchoNestModule.ApiKey)) { SearchArgument arg = new SearchArgument(); FillTermList(SelectedMoods, arg.Moods); FillTermList(SelectedStyles, arg.Styles); arg.MinFamiliarity = ArtistFamiliarity.Minimum; arg.MinHotttnesss = ArtistHotness.Minimum; SearchResponse response = session.Query <Search>().Execute(arg); if (response != null && response.Status.Code == ResponseCode.Success) { PreviewArtistList = response.Artists; } else { PreviewArtistList = null; } } }
public void GetSongs_WhereDescription_Christmas_IsNotNull() { const string description = "christmas"; using (var session = new EchoNestSession(ApiKey)) { SearchArgument searchArgument = new SearchArgument { Results = 10, Bucket = SongBucket.ArtistHotttness, Sort = "artist_familiarity-desc" }; searchArgument.Description.AddRange(new TermList { description }); SearchResponse searchResponse = session.Query <Search>().Execute(searchArgument); Assert.IsNotNull(searchResponse); foreach (EchoNest.Song.SongBucketItem song in searchResponse.Songs) { System.Diagnostics.Debug.WriteLine("\t{0} ({1})", song.Title, song.ArtistName); } } }
private void ButtonRun_Click(object sender, EventArgs e) { if (Searcher.IsBusy) { if (MessageBox.Show("検索を中止しますか?", "検索中です", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button2) == System.Windows.Forms.DialogResult.Yes) { Searcher.CancelAsync(); } return; } RecordView.Rows.Clear(); var row = new DataGridViewRow(); row.CreateCells(RecordView); var args = new SearchArgument(); args.ShipName = (string)ShipName.SelectedItem; args.ItemName = (string)ItemName.SelectedItem; args.EquipmentName = (string)EquipmentName.SelectedItem; args.DateBegin = DateBegin.Value; args.DateEnd = DateEnd.Value; args.MapAreaID = (int)MapAreaID.SelectedValue; args.MapInfoID = (int)MapInfoID.SelectedValue; args.MapCellID = (int)MapCellID.SelectedValue; args.MapDifficulty = (int)MapDifficulty.SelectedValue; args.IsBossOnly = IsBossOnly.CheckState; args.RankS = RankS.Checked; args.RankA = RankA.Checked; args.RankB = RankB.Checked; args.RankX = RankX.Checked; args.MergeRows = MergeRows.Checked; args.BaseRow = row; RecordView.Tag = args; // column initialize if (MergeRows.Checked) { RecordView_Name.DisplayIndex = 0; RecordView_Header.HeaderText = "回数"; RecordView_Header.Width = 100; RecordView_Header.DisplayIndex = 1; RecordView_RankS.Width = 100; RecordView_RankS.Visible = true; RecordView_RankA.Width = 100; RecordView_RankA.Visible = true; RecordView_RankB.Width = 100; RecordView_RankB.Visible = true; RecordView_Date.Visible = false; RecordView_Map.Visible = false; RecordView_Rank.Visible = false; } else { RecordView_Header.HeaderText = ""; RecordView_Header.Width = 50; RecordView_Header.DisplayIndex = 0; RecordView_Date.Width = 150; RecordView_Date.Visible = true; RecordView_Map.Width = 240; RecordView_Map.Visible = true; RecordView_Rank.Width = 40; RecordView_Rank.Visible = true; RecordView_RankS.Visible = false; RecordView_RankA.Visible = false; RecordView_RankB.Visible = false; } RecordView.ColumnHeadersVisible = true; StatusInfo.Text = "検索中です..."; StatusInfo.Tag = DateTime.Now; Searcher.RunWorkerAsync(args); }
private void ButtonRun_Click( object sender, EventArgs e ) { if ( Searcher.IsBusy ) { if ( MessageBox.Show( "検索を中止しますか?", "検索中です", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button2 ) == System.Windows.Forms.DialogResult.Yes ) { Searcher.CancelAsync(); } return; } RecordView.Rows.Clear(); var row = new DataGridViewRow(); row.CreateCells( RecordView ); var args = new SearchArgument(); args.EquipmentCategory = (int)EquipmentCategory.SelectedValue; args.EquipmentName = (string)EquipmentName.SelectedItem; args.SecretaryCategory = (int)SecretaryCategory.SelectedValue; args.SecretaryName = (string)SecretaryName.SelectedItem; args.DateBegin = DateBegin.Value; args.DateEnd = DateEnd.Value; args.Recipe = (string)Recipe.SelectedItem; args.MergeRows = MergeRows.Checked; args.BaseRow = row; if ( !MergeRows.Checked ) { RecordView_Header.Width = 50; RecordView_Header.HeaderText = ""; RecordView_Name.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; RecordView_Name.HeaderText = "装備"; RecordView_Date.Width = 140; RecordView_Date.Visible = true; RecordView_Recipe.Width = 120; RecordView_Recipe.Visible = true; RecordView_FlagshipType.Width = 60; RecordView_FlagshipType.Visible = true; RecordView_Flagship.Width = 60; RecordView_Flagship.Visible = true; RecordView_Detail.Visible = false; } else { RecordView_Header.Width = 150; RecordView_Header.HeaderText = "回数"; RecordView_Name.AutoSizeMode = DataGridViewAutoSizeColumnMode.NotSet; RecordView_Name.Width = 160; RecordView_Name.HeaderText = ( ( EquipmentName.Text != NameAny && EquipmentName.Text != NameExist ) || (int)EquipmentCategory.SelectedValue != -1 ) ? "レシピ" : "装備"; RecordView_Date.Visible = false; RecordView_Recipe.Visible = false; RecordView_FlagshipType.Visible = false; RecordView_Flagship.Visible = false; RecordView_Detail.HeaderText = ( SecretaryName.Text != NameAny || (int)SecretaryCategory.SelectedValue != -1 ) ? "レシピ別回数" : "艦種別回数"; RecordView_Detail.Visible = true; } RecordView.ColumnHeadersVisible = true; StatusInfo.Text = "検索中です..."; StatusInfo.Tag = DateTime.Now; Searcher.RunWorkerAsync( args ); }
public List<IResultModel> getPatientInfo(SearchArgument argument) { throw new NotImplementedException(); }
private void ButtonRun_Click( object sender, EventArgs e ) { if ( Searcher.IsBusy ) { if ( MessageBox.Show( "検索を中止しますか?", "検索中です", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button2 ) == System.Windows.Forms.DialogResult.Yes ) { Searcher.CancelAsync(); } return; } RecordView.Rows.Clear(); var row = new DataGridViewRow(); row.CreateCells( RecordView ); var args = new SearchArgument(); args.ShipCategory = (int)ShipCategory.SelectedValue; args.ShipName = (string)ShipName.SelectedItem; args.SecretaryCategory = (int)SecretaryCategory.SelectedValue; args.SecretaryName = (string)SecretaryName.SelectedItem; args.DateBegin = DateBegin.Value; args.DateEnd = DateEnd.Value; args.Recipe = (string)Recipe.Text; args.DevelopmentMaterial = (int)DevelopmentMaterial.SelectedValue; args.EmptyDock = (int)EmptyDock.SelectedValue; args.IsLargeConstruction = IsLargeConstruction.CheckState; args.MergeRows = MergeRows.Checked; args.BaseRow = row; RecordView.Tag = args; // column initialize if ( !args.MergeRows ) { RecordView_Header.DisplayIndex = 0; RecordView_Header.Width = 50; RecordView_Header.HeaderText = ""; RecordView_Name.DisplayIndex = 1; RecordView_Name.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; RecordView_Name.HeaderText = "艦名"; RecordView_Name.Visible = true; RecordView_Date.DisplayIndex = 2; RecordView_Date.Width = 140; RecordView_Date.HeaderText = "日付"; RecordView_Date.Visible = true; RecordView_Recipe.DisplayIndex = 3; RecordView_Recipe.AutoSizeMode = DataGridViewAutoSizeColumnMode.NotSet; RecordView_Recipe.Width = 200; RecordView_Recipe.HeaderText = "レシピ"; RecordView_Recipe.Visible = true; RecordView_SecretaryShip.DisplayIndex = 4; RecordView_SecretaryShip.Width = 60; RecordView_SecretaryShip.HeaderText = "旗艦"; RecordView_SecretaryShip.Visible = true; RecordView_Material100.Visible = false; RecordView_Material20.Visible = false; RecordView_Material1.Visible = false; } else { if ( args.ShipName != NameAny ) { RecordView_Recipe.DisplayIndex = 0; RecordView_Recipe.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; RecordView_Recipe.HeaderText = "レシピ"; RecordView_Recipe.Visible = true; RecordView_Name.Visible = false; } else { RecordView_Name.DisplayIndex = 0; RecordView_Name.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; RecordView_Name.HeaderText = "艦名"; RecordView_Name.Visible = true; RecordView_Recipe.Visible = false; } RecordView_Header.DisplayIndex = 1; RecordView_Header.Width = 120; RecordView_Header.HeaderText = "回数"; RecordView_Material100.DisplayIndex = 2; RecordView_Material100.Width = 120; RecordView_Material100.HeaderText = "開発資材x100"; RecordView_Material20.DisplayIndex = 3; RecordView_Material20.Width = 120; RecordView_Material20.HeaderText = "開発資材x20"; RecordView_Material1.DisplayIndex = 4; RecordView_Material1.Width = 120; RecordView_Material1.HeaderText = "開発資材x1"; if ( args.IsLargeConstruction == CheckState.Unchecked || ( args.Recipe != NameAny && args.Recipe.IndexOf( "/" ) < 4 ) || args.DevelopmentMaterial != -1 ) { RecordView_Material100.Visible = false; RecordView_Material20.Visible = false; RecordView_Material1.Visible = false; } else { RecordView_Material100.Visible = true; RecordView_Material20.Visible = true; RecordView_Material1.Visible = true; } RecordView_Date.Visible = false; RecordView_SecretaryShip.Visible = false; } RecordView.ColumnHeadersVisible = true; StatusInfo.Text = "検索中です..."; StatusInfo.Tag = DateTime.Now; Searcher.RunWorkerAsync( args ); }
public static String toKryo(SearchArgument sarg) { Output out = new Output(4 * 1024, 10 * 1024 * 1024); new Kryo().writeObject(out, sarg); out.close(); return Base64.encodeBase64String(out.toBytes()); }
private void ButtonRun_Click(object sender, EventArgs e) { if (Searcher.IsBusy) { if (MessageBox.Show(EncycloRes.InterruptSearch, EncycloRes.Searching, MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button2) == System.Windows.Forms.DialogResult.Yes) { Searcher.CancelAsync(); } return; } RecordView.Rows.Clear(); var row = new DataGridViewRow(); row.CreateCells(RecordView); var args = new SearchArgument { ShipCategory = (int)ShipCategory.SelectedValue, ShipName = (string)ShipName.SelectedItem, SecretaryCategory = (int)SecretaryCategory.SelectedValue, SecretaryName = (string)SecretaryName.SelectedItem, DateBegin = DateBegin.Value, DateEnd = DateEnd.Value, Recipe = Recipe.Text, DevelopmentMaterial = (int)DevelopmentMaterial.SelectedValue, EmptyDock = (int)EmptyDock.SelectedValue, IsLargeConstruction = IsLargeConstruction.CheckState, MergeRows = MergeRows.Checked, BaseRow = row }; RecordView.Tag = args; // column initialize if (!args.MergeRows) { RecordView_Header.DisplayIndex = 0; RecordView_Header.Width = 50; RecordView_Header.HeaderText = ""; RecordView_Name.DisplayIndex = 1; RecordView_Name.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; RecordView_Name.HeaderText = EncycloRes.ShipName; RecordView_Name.Visible = true; RecordView_Date.DisplayIndex = 2; RecordView_Date.Width = 140; RecordView_Date.HeaderText = EncycloRes.Date; RecordView_Date.Visible = true; RecordView_Recipe.DisplayIndex = 3; RecordView_Recipe.AutoSizeMode = DataGridViewAutoSizeColumnMode.NotSet; RecordView_Recipe.Width = 200; RecordView_Recipe.HeaderText = EncycloRes.Recipe; RecordView_Recipe.Visible = true; RecordView_SecretaryShip.DisplayIndex = 4; RecordView_SecretaryShip.Width = 60; RecordView_SecretaryShip.HeaderText = EncycloRes.Flagship; RecordView_SecretaryShip.Visible = true; RecordView_Material100.Visible = false; RecordView_Material20.Visible = false; RecordView_Material1.Visible = false; } else { if (args.ShipName != NameAny) { RecordView_Recipe.DisplayIndex = 0; RecordView_Recipe.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; RecordView_Recipe.HeaderText = EncycloRes.Recipe; RecordView_Recipe.Visible = true; RecordView_Name.Visible = false; } else { RecordView_Name.DisplayIndex = 0; RecordView_Name.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; RecordView_Name.HeaderText = EncycloRes.ShipName; RecordView_Name.Visible = true; RecordView_Recipe.Visible = false; } RecordView_Header.DisplayIndex = 1; RecordView_Header.Width = 120; RecordView_Header.HeaderText = EncycloRes.Times; RecordView_Material100.DisplayIndex = 2; RecordView_Material100.Width = 120; RecordView_Material100.HeaderText = GeneralRes.DevMat + "x100"; RecordView_Material20.DisplayIndex = 3; RecordView_Material20.Width = 120; RecordView_Material20.HeaderText = GeneralRes.DevMat + "x20"; RecordView_Material1.DisplayIndex = 4; RecordView_Material1.Width = 120; RecordView_Material1.HeaderText = GeneralRes.DevMat + "x1"; if (args.IsLargeConstruction == CheckState.Unchecked || (args.Recipe != NameAny && args.Recipe.IndexOf("/") < 4) || args.DevelopmentMaterial != -1) { RecordView_Material100.Visible = false; RecordView_Material20.Visible = false; RecordView_Material1.Visible = false; } else { RecordView_Material100.Visible = true; RecordView_Material20.Visible = true; RecordView_Material1.Visible = true; } RecordView_Date.Visible = false; RecordView_SecretaryShip.Visible = false; } RecordView.ColumnHeadersVisible = true; StatusInfo.Text = EncycloRes.Searching + "..."; StatusInfo.Tag = DateTime.Now; Searcher.RunWorkerAsync(args); }
protected abstract Expression <Func <TEntity, bool> > GetPredicateForIsNotEqualTo( SearchArgument arg);
public List <IResultModel> getPatientInfo(SearchArgument argument) { throw new NotImplementedException(); }
private static IQueryable <RollBackDistributionCompanyInfo> SelectDynamicSearch(SearchArgument sArgument, string orderBy) { int n = sArgument.SearchArguments.Count; ParameterExpression e = Expression.Parameter(typeof(RollBackDistributionCompanyInfo), "e"); Expression <Func <RollBackDistributionCompanyInfo, bool> > lambda = null; Expression be = null; int i; for (i = 0; i < n; i++) { string pField = sArgument.SearchArguments[i].PropertyField; string comparator = sArgument.SearchArguments[i].Comparator; object fvalue = sArgument.SearchArguments[i].FValue; PropertyInfo prop = typeof(RollBackDistributionCompanyInfo).GetProperty(pField); Type myType; bool nullable = false; if (IsNullableType(prop.PropertyType)) { NullableConverter nc = new NullableConverter(prop.PropertyType); myType = nc.UnderlyingType; nullable = true; } else { myType = prop.PropertyType; } Expression next = null; if (!nullable) { switch (Type.GetTypeCode(myType)) { case TypeCode.Boolean: next = GetDynamicSearchExpression <bool>(pField, comparator, Convert.ToBoolean(fvalue), e, myType); break; case TypeCode.Byte: next = GetDynamicSearchExpression <byte>(pField, comparator, Convert.ToByte(fvalue), e, myType); break; case TypeCode.Char: next = GetDynamicSearchExpression <char>(pField, comparator, Convert.ToChar(fvalue), e, myType); break; case TypeCode.DateTime: next = GetDynamicSearchExpression <DateTime>(pField, comparator, Convert.ToDateTime(fvalue), e, myType); break; case TypeCode.Decimal: next = GetDynamicSearchExpression <Decimal>(pField, comparator, Convert.ToDecimal(fvalue), e, myType); break; case TypeCode.Double: next = GetDynamicSearchExpression <double>(pField, comparator, Convert.ToDouble(fvalue), e, myType); break; case TypeCode.Int16: next = GetDynamicSearchExpression <Int16>(pField, comparator, Convert.ToInt16(fvalue), e, myType); break; case TypeCode.Int32: next = GetDynamicSearchExpression <Int32>(pField, comparator, Convert.ToInt32(fvalue), e, myType); break; case TypeCode.Int64: next = GetDynamicSearchExpression <Int64>(pField, comparator, Convert.ToInt64(fvalue), e, myType); break; case TypeCode.Single: next = GetDynamicSearchExpression <Single>(pField, comparator, Convert.ToSingle(fvalue), e, myType); break; case TypeCode.String: next = GetDynamicSearchExpression <String>(pField, comparator, Convert.ToString(fvalue), e, myType); break; default: throw new Exception("Cannot search by column " + pField + " because of its type"); } } else { switch (Type.GetTypeCode(myType)) { case TypeCode.Boolean: next = GetDynamicSearchExpression <System.Nullable <bool> >(pField, comparator, Convert.ToBoolean(fvalue), e, myType); break; case TypeCode.Byte: next = GetDynamicSearchExpression <System.Nullable <byte> >(pField, comparator, Convert.ToByte(fvalue), e, myType); break; case TypeCode.Char: next = GetDynamicSearchExpression <System.Nullable <char> >(pField, comparator, Convert.ToChar(fvalue), e, myType); break; case TypeCode.DateTime: next = GetDynamicSearchExpression <System.Nullable <DateTime> >(pField, comparator, Convert.ToDateTime(fvalue), e, myType); break; case TypeCode.Decimal: next = GetDynamicSearchExpression <System.Nullable <Decimal> >(pField, comparator, Convert.ToDecimal(fvalue), e, myType); break; case TypeCode.Double: next = GetDynamicSearchExpression <System.Nullable <double> >(pField, comparator, Convert.ToDouble(fvalue), e, myType); break; case TypeCode.Int16: next = GetDynamicSearchExpression <System.Nullable <Int16> >(pField, comparator, Convert.ToInt16(fvalue), e, myType); break; case TypeCode.Int32: next = GetDynamicSearchExpression <System.Nullable <Int32> >(pField, comparator, Convert.ToInt32(fvalue), e, myType); break; case TypeCode.Int64: next = GetDynamicSearchExpression <System.Nullable <Int64> >(pField, comparator, Convert.ToInt64(fvalue), e, myType); break; case TypeCode.Single: next = GetDynamicSearchExpression <System.Nullable <Single> >(pField, comparator, Convert.ToSingle(fvalue), e, myType); break; case TypeCode.String: next = GetDynamicSearchExpression <String>(pField, comparator, Convert.ToString(fvalue), e, myType); break; default: throw new Exception("Cannot filter by column " + pField + " because of its type"); } } if (i == 0) { be = next; } else { be = Expression.And(be, next); } } lambda = Expression.Lambda <Func <RollBackDistributionCompanyInfo, bool> >(be, e); return(Select(orderBy).AsQueryable().Where(lambda)); }
private void ButtonRun_Click( object sender, EventArgs e ) { if ( Searcher.IsBusy ) { if ( MessageBox.Show( "検索を中止しますか?", "検索中です", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button2 ) == System.Windows.Forms.DialogResult.Yes ) { Searcher.CancelAsync(); } return; } RecordView.Rows.Clear(); var row = new DataGridViewRow(); row.CreateCells( RecordView ); var args = new SearchArgument(); args.ShipName = (string)ShipName.SelectedItem; args.ItemName = (string)ItemName.SelectedItem; args.EquipmentName = (string)EquipmentName.SelectedItem; args.DateBegin = DateBegin.Value; args.DateEnd = DateEnd.Value; args.MapAreaID = (int)MapAreaID.SelectedValue; args.MapInfoID = (int)MapInfoID.SelectedValue; args.MapCellID = (int)MapCellID.SelectedValue; args.MapDifficulty = (int)MapDifficulty.SelectedValue; args.IsBossOnly = IsBossOnly.CheckState; args.RankS = RankS.Checked; args.RankA = RankA.Checked; args.RankB = RankB.Checked; args.RankX = RankX.Checked; args.MergeRows = MergeRows.Checked; args.BaseRow = row; RecordView.Tag = args; // column initialize if ( MergeRows.Checked ) { RecordView_Name.DisplayIndex = 0; RecordView_Header.HeaderText = "回数"; RecordView_Header.Width = 100; RecordView_Header.DisplayIndex = 1; RecordView_RankS.Width = 100; RecordView_RankS.Visible = true; RecordView_RankA.Width = 100; RecordView_RankA.Visible = true; RecordView_RankB.Width = 100; RecordView_RankB.Visible = true; RecordView_Date.Visible = false; RecordView_Map.Visible = false; RecordView_Rank.Visible = false; } else { RecordView_Header.HeaderText = ""; RecordView_Header.Width = 50; RecordView_Header.DisplayIndex = 0; RecordView_Date.Width = 150; RecordView_Date.Visible = true; RecordView_Map.Width = 240; RecordView_Map.Visible = true; RecordView_Rank.Width = 40; RecordView_Rank.Visible = true; RecordView_RankS.Visible = false; RecordView_RankA.Visible = false; RecordView_RankB.Visible = false; } RecordView.ColumnHeadersVisible = true; StatusInfo.Text = "検索中です..."; StatusInfo.Tag = DateTime.Now; Searcher.RunWorkerAsync( args ); }
public static int SelectSearchCount(SearchArgument sArgument) { string orderBy = ""; return(SelectDynamicSearch(sArgument, orderBy).Count()); }
protected abstract Expression <Func <TEntity, bool> > GetPredicateForContains( SearchArgument arg);
private void Searcher_DoWork(object sender, DoWorkEventArgs e) { SearchArgument args = (SearchArgument)e.Argument; int priorityShip = args.ShipName == NameAny ? 0 : args.ShipName == NameExist ? 1 : 2; int priorityItem = args.ItemName == NameAny ? 0 : args.ItemName == NameExist ? 1 : 2; int priorityContent = Math.Max(priorityShip, priorityItem); var records = RecordManager.Instance.ShipDrop.Record; var rows = new LinkedList <DataGridViewRow>(); //lock ( records ) { int i = 0; var counts = new Dictionary <string, int[]>(); var allcounts = new Dictionary <string, int[]>(); foreach (var r in records) { #region Filtering if (r.Date < args.DateBegin || args.DateEnd < r.Date) { continue; } if (((r.Rank == "SS" || r.Rank == "S") && !args.RankS) || ((r.Rank == "A") && !args.RankA) || ((r.Rank == "B") && !args.RankB) || ((Constants.GetWinRank(r.Rank) <= 3) && !args.RankX)) { continue; } if (args.MapAreaID != -1 && args.MapAreaID != r.MapAreaID) { continue; } if (args.MapInfoID != -1 && args.MapInfoID != r.MapInfoID) { continue; } if (args.MapCellID != -1 && args.MapCellID != r.CellID) { continue; } switch (args.IsBossOnly) { case CheckState.Unchecked: if (r.IsBossNode) { continue; } break; case CheckState.Checked: if (!r.IsBossNode) { continue; } break; } if (args.MapDifficulty != 0 && args.MapDifficulty != r.Difficulty) { continue; } if (args.MergeRows) { string key; if (priorityContent == 2) { key = GetMapSerialID(r.MapAreaID, r.MapInfoID, r.CellID, r.IsBossNode, args.MapDifficulty == 0 ? -1 : r.Difficulty).ToString("X8"); } else { key = GetContentString(r, priorityShip < priorityItem && priorityShip < 2, priorityShip >= priorityItem && priorityItem < 2); } if (!allcounts.ContainsKey(key)) { allcounts.Add(key, new int[4]); } switch (r.Rank) { case "B": allcounts[key][3]++; break; case "A": allcounts[key][2]++; break; case "S": case "SS": allcounts[key][1]++; break; } allcounts[key][0]++; } switch (args.ShipName) { case NameAny: break; case NameExist: if (r.ShipID < 0) { continue; } break; case NameNotExist: if (r.ShipID != -1) { continue; } break; case NameFullPort: if (r.ShipID != -2) { continue; } break; default: if (r.ShipName != args.ShipName) { continue; } break; } switch (args.ItemName) { case NameAny: break; case NameExist: if (r.ItemID < 0) { continue; } break; case NameNotExist: if (r.ItemID != -1) { continue; } break; default: if (r.ItemName != args.ItemName) { continue; } break; } #endregion if (!args.MergeRows) { var row = (DataGridViewRow)args.BaseRow.Clone(); row.SetValues( i + 1, GetContentString(r), r.Date, GetMapString(r.MapAreaID, r.MapInfoID, r.CellID, r.IsBossNode, r.Difficulty), Constants.GetWinRank(r.Rank), null, null, null ); row.Cells[1].Tag = GetContentStringForSorting(r); row.Cells[3].Tag = GetMapSerialID(r.MapAreaID, r.MapInfoID, r.CellID, r.IsBossNode, r.Difficulty); rows.AddLast(row); } else { //merged string key; if (priorityContent == 2) { key = GetMapSerialID(r.MapAreaID, r.MapInfoID, r.CellID, r.IsBossNode, args.MapDifficulty == 0 ? -1 : r.Difficulty).ToString("X8"); } else { key = GetContentStringForSorting(r, priorityShip < priorityItem && priorityShip < 2, priorityShip >= priorityItem && priorityItem < 2); } if (!counts.ContainsKey(key)) { counts.Add(key, new int[4]); } switch (r.Rank) { case "B": counts[key][3]++; break; case "A": counts[key][2]++; break; case "S": case "SS": counts[key][1]++; break; } counts[key][0]++; } if (Searcher.CancellationPending) { break; } i++; } if (args.MergeRows) { int[] allcountssum = Enumerable.Range(0, 4).Select(k => allcounts.Values.Sum(a => a[k])).ToArray(); foreach (var c in counts) { var row = (DataGridViewRow)args.BaseRow.Clone(); string name = c.Key; int serialID = 0; if (int.TryParse(name, System.Globalization.NumberStyles.HexNumber, System.Globalization.CultureInfo.InvariantCulture, out serialID)) { name = GetMapString(serialID); } // fixme: name != map だった時にソートキーが入れられない row.SetValues( c.Value[0], serialID != 0 ? name : ConvertContentString(name), null, null, null, c.Value[1], c.Value[2], c.Value[3] ); if (priorityContent == 2) { row.Cells[0].Tag = allcounts[c.Key][0]; if (serialID != 0) { row.Cells[1].Tag = serialID; } else { row.Cells[1].Tag = name; } row.Cells[5].Tag = allcounts[c.Key][1]; row.Cells[6].Tag = allcounts[c.Key][2]; row.Cells[7].Tag = allcounts[c.Key][3]; } else { row.Cells[0].Tag = ((double)c.Value[0] / Math.Max(allcountssum[0], 1)); if (serialID != 0) { row.Cells[1].Tag = serialID; } else { row.Cells[1].Tag = name; } row.Cells[5].Tag = ((double)c.Value[1] / Math.Max(allcountssum[1], 1)); row.Cells[6].Tag = ((double)c.Value[2] / Math.Max(allcountssum[2], 1)); row.Cells[7].Tag = ((double)c.Value[3] / Math.Max(allcountssum[3], 1)); } rows.AddLast(row); } } } e.Result = rows.ToArray(); }
public static IQueryable <RollBackDistributionCompanyInfo> SelectDynamicSearchByFK(string foreignKeyName, int id, SearchArgument sArgument, string orderBy) { ParameterExpression e = Expression.Parameter(typeof(RollBackDistributionCompanyInfo), "e"); PropertyInfo propInfo = typeof(RollBackDistributionCompanyInfo).GetProperty(foreignKeyName); MemberExpression m = Expression.MakeMemberAccess(e, propInfo); ConstantExpression c = Expression.Constant(id, typeof(int)); BinaryExpression b = Expression.Equal(m, c); Expression <Func <RollBackDistributionCompanyInfo, bool> > lambda = Expression.Lambda <Func <RollBackDistributionCompanyInfo, bool> >(b, e); return(SelectSearch(sArgument, orderBy).Where(lambda)); }
public static int SelectSearchByFKCount(string foreignKeyName, int id, SearchArgument sArgument) { string orderBy = ""; return(SelectDynamicSearchByFK(foreignKeyName, id, sArgument, orderBy).Count()); }
public static IQueryable <RollBackDistributionCompanyInfo> SelectReport(ReportArgument rArgument, SearchArgument sArgument, string orderBy, string companyName, string branchName, string foreignKeyName, int id, string UserName) { SelectDynamicReport(rArgument, sArgument, orderBy, companyName, branchName, foreignKeyName, id, UserName); return(null); }
protected abstract Expression <Func <TEntity, bool> > GetPredicateForStartsWith( SearchArgument arg);
private static void SelectDynamicReport(ReportArgument rArgument, SearchArgument sArgument, string orderBy, string companyName, string branchName, string foreignKeyName, int id, string UserName) { // IEnumerable<T> data; List <RollBackDistributionCompanyInfo> data; int count; if (!String.IsNullOrEmpty(foreignKeyName)) { if (sArgument != null) { data = SelectDynamicSearchByFK(foreignKeyName, id, sArgument, orderBy).ToList <RollBackDistributionCompanyInfo>(); count = SelectSearchByFKCountCached(foreignKeyName, id, sArgument); } else { data = SelectDynamicByFK(foreignKeyName, id, orderBy).ToList <RollBackDistributionCompanyInfo>(); count = SelectByFKCountCached(foreignKeyName, id); } } else { if (sArgument != null) { data = SelectSearch(sArgument, orderBy).ToList <RollBackDistributionCompanyInfo>(); count = data.Count; //count = SelectSearchCountCached(sArgument); } else { data = Select(orderBy).ToList <RollBackDistributionCompanyInfo>(); count = data.Count; //count = SelectCountCached(); } } int n = count; int m = rArgument.ReportArguments.Count; TypeCode[] codes = new TypeCode[m]; PropertyInfo[] infos = new PropertyInfo[m]; bool first = true; if (rArgument.Format == "PDF") { PDFCreators creator = new PDFCreators(rArgument.Orientation, rArgument.MarginLeft, rArgument.MarginRight, rArgument.MarginTop, rArgument.MarginBottom); creator.SetDocumentHeaderFooter(companyName); creator.OpenPDF(); creator.SetTitle(rArgument.ReportName); string[] headers = new string[m]; for (int i = 0; i < m; i++) { headers[i] = rArgument.ReportArguments[i].HeaderText; } creator.CreateTable(m, true, headers, branchName); for (int i = 0; i < n; i++) { object[] values = new object[m]; for (int j = 0; j < m; j++) { if (first) { infos[j] = typeof(RollBackDistributionCompanyInfo).GetProperty(rArgument.ReportArguments[j].PropertyField); if (IsNullableType(infos[j].PropertyType)) { NullableConverter nc = new NullableConverter(infos[j].PropertyType); codes[j] = Type.GetTypeCode(nc.UnderlyingType); } else { codes[j] = Type.GetTypeCode(infos[j].PropertyType); } } values[j] = infos[j].GetValue(data[i], null); if (codes[j] == TypeCode.DateTime) { DateTime date = (DateTime)values[j]; values[j] = date.ToShortDateString(); } if (codes[j] == TypeCode.Decimal) { decimal dec = (decimal)values[j]; values[j] = String.Format("{0:#,0.00}", dec); } if (codes[j] == TypeCode.Boolean) { bool temp = (bool)values[j]; if (temp == true) { values[j] = "Да"; } else { values[j] = "Не"; } } } first = false; if (creator.AddDataRow(values, m, codes)) { i--; } } creator.AddTable(); creator.FinishPDF(); } //Creating Excel document else if (rArgument.Format == "XLS") { ExcelFileWriter <RollBackDistributionCompanyInfo> myExcel = new ExcelFileWriter <RollBackDistributionCompanyInfo>(); string[] headers = new string[m]; for (int i = 0; i < m; i++) { headers[i] = rArgument.ReportArguments[i].HeaderText; } myExcel.Headers = headers; int temp_num = ('A') + m - 1; char lastCol = Convert.ToChar(temp_num); string finalColumn = lastCol + "1"; myExcel.ColumnCount = m - 1; myExcel.RowCount = n; myExcel.ActivateExcel(); myExcel.FillHeaderColumn(headers, "A1", finalColumn); for (int i = 0; i < n; i++) { object[] values = new object[m]; for (int j = 0; j < m; j++) { if (first) { infos[j] = typeof(RollBackDistributionCompanyInfo).GetProperty(rArgument.ReportArguments[j].PropertyField); if (IsNullableType(infos[j].PropertyType)) { NullableConverter nc = new NullableConverter(infos[j].PropertyType); codes[j] = Type.GetTypeCode(nc.UnderlyingType); } else { codes[j] = Type.GetTypeCode(infos[j].PropertyType); } } values[j] = infos[j].GetValue(data[i], null); if (codes[j] == TypeCode.DateTime) { DateTime date = (DateTime)values[j]; values[j] = date.ToShortDateString(); } if (codes[j] == TypeCode.Boolean) { bool temp = (bool)values[j]; if (temp == true) { values[j] = "Да"; } else { values[j] = "Не"; } } } first = false; string fColumn = "A" + (i + 2).ToString(); string lColumn = lastCol + (i + 2).ToString(); myExcel.FillRowData_Mine(values, fColumn, lColumn); } string fileName = UserName + "_" + rArgument.ReportName + ".xls"; myExcel.SaveExcel(fileName); myExcel.FinishExcel(fileName); } //Create Word document else if (rArgument.Format == "DOC") { WordFileWriter <RollBackDistributionCompanyInfo> myWord = new WordFileWriter <RollBackDistributionCompanyInfo>(); myWord.Orientation = rArgument.Orientation; myWord.ActivateWord(); //myWord.InsertingText(rArgument.ReportName); //myWord.InsertingText("Датум на извештај: " + DateTime.Now.ToShortDateString()); string[] headers = new string[m]; for (int i = 0; i < m; i++) { headers[i] = rArgument.ReportArguments[i].HeaderText; } myWord.Headers = headers; object[,] tempFillValues = new object[n, m]; CultureInfo oldCI = System.Threading.Thread.CurrentThread.CurrentCulture; CultureInfo oldUICI = System.Threading.Thread.CurrentThread.CurrentUICulture; System.Threading.Thread.CurrentThread.CurrentCulture = new CultureInfo("mk-MK"); System.Threading.Thread.CurrentThread.CurrentUICulture = new CultureInfo("mk-MK"); for (int i = 0; i < n; i++) { object[] values = new object[m]; for (int j = 0; j < m; j++) { if (first) { infos[j] = typeof(RollBackDistributionCompanyInfo).GetProperty(rArgument.ReportArguments[j].PropertyField); if (IsNullableType(infos[j].PropertyType)) { NullableConverter nc = new NullableConverter(infos[j].PropertyType); codes[j] = Type.GetTypeCode(nc.UnderlyingType); } else { codes[j] = Type.GetTypeCode(infos[j].PropertyType); } } values[j] = infos[j].GetValue(data[i], null); if (codes[j] == TypeCode.DateTime) { DateTime date = (DateTime)values[j]; values[j] = date.ToShortDateString(); } if (codes[j] == TypeCode.Boolean) { bool temp = (bool)values[j]; if (temp == true) { values[j] = "Да"; } else { values[j] = "Не"; } } tempFillValues[i, j] = values[j]; } first = false; } System.Threading.Thread.CurrentThread.CurrentCulture = oldCI; System.Threading.Thread.CurrentThread.CurrentUICulture = oldUICI; myWord.FillValues = tempFillValues; myWord.CreateTable(n, m); myWord.InsertFooter(); myWord.InsertHeader(rArgument.BranchName); string fileName = UserName + "_" + rArgument.ReportName + ".doc"; myWord.SaveDOC(fileName); myWord.FinishDOC(fileName); } }
private void ButtonRun_Click(object sender, EventArgs e) { if (Searcher.IsBusy) { if (MessageBox.Show(EncycloRes.InterruptSearch, EncycloRes.Searching, MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button2) == System.Windows.Forms.DialogResult.Yes) { Searcher.CancelAsync(); } return; } RecordView.Rows.Clear(); var row = new DataGridViewRow(); row.CreateCells(RecordView); var args = new SearchArgument { EquipmentCategory = (int)EquipmentCategory.SelectedValue, EquipmentName = (string)EquipmentName.SelectedItem, SecretaryCategory = (int)SecretaryCategory.SelectedValue, SecretaryName = (string)SecretaryName.SelectedItem, DateBegin = DateBegin.Value, DateEnd = DateEnd.Value, Recipe = (string)Recipe.SelectedItem, MergeRows = MergeRows.Checked, BaseRow = row }; RecordView.Tag = args; if (!MergeRows.Checked) { RecordView_Header.Width = 50; RecordView_Header.HeaderText = ""; RecordView_Name.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; RecordView_Name.HeaderText = "Equipment"; RecordView_Date.Width = 140; RecordView_Date.Visible = true; RecordView_Recipe.Width = 95; RecordView_Recipe.Visible = true; RecordView_FlagshipType.Width = 40; RecordView_FlagshipType.Visible = true; RecordView_Flagship.Width = 105; RecordView_Flagship.Visible = true; RecordView_Detail.Visible = false; } else { RecordView_Header.Width = 150; RecordView_Header.HeaderText = EncycloRes.Tries; RecordView_Name.AutoSizeMode = DataGridViewAutoSizeColumnMode.NotSet; RecordView_Name.Width = 160; RecordView_Name.HeaderText = ((EquipmentName.Text != NameAny && EquipmentName.Text != NameExist) || (int)EquipmentCategory.SelectedValue != -1) ? "Recipe" : "Equipment"; RecordView_Date.Visible = false; RecordView_Recipe.Visible = false; RecordView_FlagshipType.Visible = false; RecordView_Flagship.Visible = false; RecordView_Detail.HeaderText = (SecretaryName.Text != NameAny || (int)SecretaryCategory.SelectedValue != -1) ? "Recipe Tries" : "Ship Type"; RecordView_Detail.Visible = true; } RecordView.ColumnHeadersVisible = true; StatusInfo.Text = EncycloRes.Searching + "..."; StatusInfo.Tag = DateTime.Now; Searcher.RunWorkerAsync(args); }
private void ButtonRun_Click(object sender, EventArgs e) { if (Searcher.IsBusy) { if (MessageBox.Show("要中断搜索吗?", "正在搜索中", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button2) == System.Windows.Forms.DialogResult.Yes) { Searcher.CancelAsync(); } return; } RecordView.Rows.Clear(); RecordView.Font = Utility.Configuration.Config.UI.JapFont; var row = new DataGridViewRow(); row.CreateCells(RecordView); var args = new SearchArgument { EquipmentCategory = (int)EquipmentCategory.SelectedValue, EquipmentName = (string)EquipmentName.SelectedItem, SecretaryCategory = (int)SecretaryCategory.SelectedValue, SecretaryName = (string)SecretaryName.SelectedItem, DateBegin = DateBegin.Value, DateEnd = DateEnd.Value, Recipe = (string)Recipe.SelectedItem, MergeRows = MergeRows.Checked, BaseRow = row }; if (!MergeRows.Checked) { RecordView_Header.Width = 50; RecordView_Header.HeaderText = ""; RecordView_Name.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; RecordView_Name.HeaderText = "装备"; RecordView_Date.Width = 140; RecordView_Date.Visible = true; RecordView_Recipe.Width = 120; RecordView_Recipe.Visible = true; RecordView_FlagshipType.Width = 60; RecordView_FlagshipType.Visible = true; RecordView_Flagship.Width = 60; RecordView_Flagship.Visible = true; RecordView_Detail.Visible = false; } else { RecordView_Header.Width = 150; RecordView_Header.HeaderText = "次数"; RecordView_Name.AutoSizeMode = DataGridViewAutoSizeColumnMode.NotSet; RecordView_Name.Width = 160; RecordView_Name.HeaderText = ((EquipmentName.Text != NameAny && EquipmentName.Text != NameExist) || (int)EquipmentCategory.SelectedValue != -1) ? "配方" : "装备"; RecordView_Date.Visible = false; RecordView_Recipe.Visible = false; RecordView_FlagshipType.Visible = false; RecordView_Flagship.Visible = false; RecordView_Detail.HeaderText = (SecretaryName.Text != NameAny || (int)SecretaryCategory.SelectedValue != -1) ? "各配方次数" : "各舰种次数"; RecordView_Detail.Visible = true; } RecordView.ColumnHeadersVisible = true; StatusInfo.Text = "搜索中 ..."; StatusInfo.Tag = DateTime.Now; Searcher.RunWorkerAsync(args); }