public bool CheckEditTermName(TermItem editingTermItem) { var query = from t in Data where t.Term.ToLower() == editingTermItem.Term.ToLower() && t.ID != editingTermItem.ID select t; return(query.Count() > 0); }
private TermItem getSubstTermItem() { TermItem tbeTerm = new TermItem(); tbeTerm.Text = substText; tbeTerm.Id = -1; tbeTerm.CaseSense = caseSens; tbeTerm.PartialMatch = matching; return(tbeTerm); }
protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e) { if (!NavigationContext.QueryString.ContainsKey("action")) {//Should never happen ToastPromptHelper.ShowToastPromptOnUIThreadAtEndOfQueue("Sorry, We have a technical issue, please try later.", 3000); NavigationService.GoBack(); } string action = NavigationContext.QueryString["action"]; if (action == "add") { PageTitle.Text = "add term"; detailAction = DetailAction.Add; } else { PageTitle.Text = "edit term"; detailAction = DetailAction.Edit; if (!PhoneApplicationService.Current.State.ContainsKey("termItem")) { //Should never happen ToastPromptHelper.ShowToastPromptOnUIThreadAtEndOfQueue( "Sorry, We have a technical issue, please try later.", 3000); NavigationService.GoBack(); } editingTermItem = PhoneApplicationService.Current.State["termItem"] as TermItem; TermTextBox.Text = editingTermItem.Term; DescriptionTextBox.Text = editingTermItem.Description; } if (app.Activated) { if (PhoneApplicationService.Current.State.ContainsKey("editingTermItem")) { editingTermItem = PhoneApplicationService.Current.State["editingTermItem"] as TermItem; PhoneApplicationService.Current.State.Remove("editingTermItem"); TermTextBox.Text = editingTermItem.Term; DescriptionTextBox.Text = editingTermItem.Description; } if (PhoneApplicationService.Current.State.ContainsKey("detailAction")) { detailAction = (DetailAction)PhoneApplicationService.Current.State["detailAction"]; PhoneApplicationService.Current.State.Remove("detailAction"); } app.Activated = false; } base.OnNavigatedTo(e); }
protected override void OnNavigatedFrom(System.Windows.Navigation.NavigationEventArgs e) { if (detailAction == DetailAction.Add) { editingTermItem = new TermItem(); } editingTermItem.Term = TermTextBox.Text; editingTermItem.Description = DescriptionTextBox.Text; PhoneApplicationService.Current.State["editingTermItem"] = editingTermItem; PhoneApplicationService.Current.State["detailAction"] = detailAction; base.OnNavigatedFrom(e); }
public override bool IsEmpty() { bool result = true; for (TermItem term = _firstTerm; term != null; term = term.NextItem) { term.IsEmpty = term.Term.IsEmpty(); if (!term.IsEmpty) { result = false; } } return(result); }
public bool AppendTermText(StringBuilder query, string keyword, bool newLine) { if (keyword != null && IsEmpty()) // IsEmpty() заполняет TermItem.IsEmpty { return(false); } if (newLine) { query.AppendLine(); } if (keyword != null) { query.Append(' ').Append(keyword).Append(' '); } if (_not) { query.Append("NOT "); } if ((keyword == null && _firstTerm.NextItem != null) || _not) { query.Append('('); } for (TermItem term = _firstTerm; term != null; term = term.NextItem) { if (term.IsEmpty) { continue; } if (term != _firstTerm) { query.Append(_operatorNames[(int)term.Operator]); } term.Term.AppendTermText(query); } if ((keyword == null && _firstTerm.NextItem != null) || _not) { query.Append(')'); } return(true); }
private void AddTerm(Term term, TermOperator @operator) { TermItem item = new TermItem() { Operator = @operator, Term = term }; if (_firstTerm == null) { _firstTerm = _lastTerm = item; } else { _lastTerm.NextItem = item; _lastTerm = _lastTerm.NextItem; } }
public void Edit(TermItem termItem) { Remove(termItem.ID); Data = Data.Add(termItem); }
private bool CheckEntry(ref TBEntry tbEntry) { bool result = false; foreach (string tbLang in tbLanguages) { bool isLangInEntry = false; ResourcesAPI_TBEntry.Language entryLangMatching = new ResourcesAPI_TBEntry.Language(); foreach (ResourcesAPI_TBEntry.Language entryLang in tbEntry.Languages) { if (entryLang.language == tbLang) { isLangInEntry = true; entryLangMatching = entryLang; break; } } if (isLangInEntry) { if (entryLangMatching.TermItems == null) { entryLangMatching.TermItems = new List <TermItem>(); } if (entryLangMatching.TermItems.Count == 0) { TermItem tbeTerm = getSubstTermItem(); entryLangMatching.TermItems.Add(tbeTerm); missingTerms[tbLang]++; RAPI_Session.UpdateTBEntry(tbID.ToString(), tbEntry.Id, tbEntry); // This line is to work around the bug that we cannot add multiple terms RAPI_Session.getTBEntry(tbID.ToString(), tbEntry.Id, out tbEntry); // This line is to work around the bug that we cannot add multiple terms result = true; } else if (entryLangMatching.TermItems.Count == 1) { if (entryLangMatching.TermItems[0].Text == searchText) { entryLangMatching.TermItems[0].Text = substText; missingTerms[tbLang]++; result = true; } } } else { ResourcesAPI_TBEntry.Language tbeLang = new ResourcesAPI_TBEntry.Language(); tbeLang.language = tbLang; tbeLang.Id = -1; tbeLang.TermItems = new List <TermItem>(); TermItem tbeTerm = getSubstTermItem(); tbeLang.TermItems.Add(tbeTerm); tbEntry.Languages.Add(tbeLang); missingTerms[tbLang]++; RAPI_Session.UpdateTBEntry(tbID.ToString(), tbEntry.Id, tbEntry); // This line is to work around the bug that we cannot add multiple terms RAPI_Session.getTBEntry(tbID.ToString(), tbEntry.Id, out tbEntry); // This line is to work around the bug that we cannot add multiple terms result = true; } } return(result); }
public void Clear() { _firstTerm = null; _lastTerm = null; }