예제 #1
0
        protected static bool UpdateVocabulary(VocModel Voc)
        {
            var    oldVoc          = Vocabularies.First(c => c.Id == Voc.Id).ToModel();
            int    field           = 0;
            string ColumnsToUpdate = string.Empty;

            CheckFieldUpdate("Words", Voc.Text, oldVoc.Text, ref field, ref ColumnsToUpdate);
            CheckFieldUpdate("Answer", Voc.Answer, oldVoc.Answer, ref field, ref ColumnsToUpdate);
            CheckFieldUpdate("Definition", Voc.Definition, oldVoc.Definition, ref field, ref ColumnsToUpdate);
            CheckFieldUpdate("PtBr", Voc.PtBr, oldVoc.PtBr, ref field, ref ColumnsToUpdate);

            CheckQuestionChanges(Voc, oldVoc, ref field, ref ColumnsToUpdate);

            if (ColumnsToUpdate.IsEmpty())
            {
                return(Errors.ThrowErrorMsg(ErrorType.NullOrEmpty, ColumnsToUpdate));
            }

            string query = string.Format(UpdateSQL, Model.Voc.ToDesc(), ColumnsToUpdate, Voc.Id);

            if (!SendQuery(query))
            {
                return(false);
            }

            return(true);
        }
예제 #2
0
        private void AddVocabularyCommandHandler()
        {
            int    weekOfYear  = DateTimeFormatInfo.CurrentInfo.Calendar.GetWeekOfYear(DateTime.Now, System.Globalization.CalendarWeekRule.FirstDay, DayOfWeek.Monday);
            string defaultName = string.Format("{0:MMdd}.Vocabulary{0:yyyy}.{1:0#}", DateTime.Now, weekOfYear);

            var strVocabularyName = InputBox.ShowDialog("Please, insert name of new Vocabulary", defaultName);

            if (string.IsNullOrEmpty(strVocabularyName))
            {
                return;
            }

            if (Vocabularies.Any(v => string.Compare(v.FileName, strVocabularyName, true) == 0))
            {
                MessageBox.ShowDialog(string.Format("Vocabulary '{0}' already exists.", strVocabularyName), "Warning");
            }
            else
            {
                Vocabularies.Add(new VocabularyListViewModel(dataService, dialogService)
                {
                    FileName = strVocabularyName
                });
                dataService.Set(new VocabularyRecord[0], strVocabularyName);
            }

            AddVocabularyCommand.RaiseCanExecuteChanged();
        }
        public async Task GetVocabularyWordsIncludesQueryParameters()
        {
            var vocabularyId = Guid.NewGuid();
            await target.Vocabularies.Get(Vocabularies.For(vocabularyId, page: new PagingInfo(1, 1), type: WordType.StopWord));

            Assert.Equal(HttpMethod.Get, handler.Request.Method);
            Assert.Equal(new Uri(baseUri, $"vocabulary/{vocabularyId}?type=StopWord&page=1&pageSize=1"), handler.Request.RequestUri);
        }
        public async Task GetVocabularyWordsWithDefaultParmetersUsesCorrectUrl()
        {
            var vocabularyId = Guid.NewGuid();
            await target.Vocabularies.Get(Vocabularies.For(vocabularyId));

            Assert.Equal(HttpMethod.Get, handler.Request.Method);
            Assert.Equal(new Uri(baseUri, $"vocabulary/{vocabularyId}?pageSize=50"), handler.Request.RequestUri);
        }
예제 #5
0
파일: Word.cs 프로젝트: sm-g/diagnosis
 /// <summary>
 /// Вызвать перед удалением слова.
 /// </summary>
 public virtual void OnDelete()
 {
     Vocabularies.ForEach(x => x.RemoveWord(this));
     HealthRecords
     .Select(x => x.Doctor)
     .Distinct()
     .ForEach(x => x.RemoveWordFromCache(this));
 }
        /// <summary>
        /// Will inverse selection icon of selected vocabs. If methods is used for initialization of UI,
        /// Only the "not visible" items will be colors, no inversion will take place.
        /// </summary>
        /// <param name="inItem">The item to retrieve vocabularies property from</param>
        /// <param name="inContainer">The item container in which the background will be changed</param>
        /// <param name="forInit">Bool value for intiliasation or interaction</param>
        public void setPicklistValueIcon(SymbolIcon inIcon, object inItem, bool forInit)
        {
            #region Set

            if (inItem != null && inIcon != null)
            {
                //Build a color brush for rejected picklist values
                SolidColorBrush  rejectedColorBrush = new SolidColorBrush();
                Windows.UI.Color rejectedColor      = Windows.UI.Colors.Red;
                rejectedColorBrush.Color = rejectedColor;

                SolidColorBrush  selectedColorBrush = new SolidColorBrush();
                Windows.UI.Color selectedColor      = Windows.UI.Colors.LawnGreen;
                selectedColorBrush.Color = selectedColor;

                //Find if current item is rejected and modify background accordingly
                Vocabularies valueVoc          = inItem as Vocabularies;
                string       currentVisibility = valueVoc.Visibility;

                if (forInit)
                {
                    if (currentVisibility == Dictionaries.DatabaseLiterals.boolNo)
                    {
                        inIcon.Symbol     = Symbol.Cancel;
                        inIcon.Foreground = rejectedColorBrush;
                    }
                    else
                    {
                        inIcon.Symbol     = Symbol.Accept;
                        inIcon.Foreground = selectedColorBrush;
                    }
                }
                else
                {
                    if (currentVisibility == Dictionaries.DatabaseLiterals.boolNo)
                    {
                        valueVoc.Visibility = Dictionaries.DatabaseLiterals.boolYes;


                        inIcon.Symbol     = Symbol.Accept;
                        inIcon.Foreground = selectedColorBrush;
                    }
                    else
                    {
                        valueVoc.Visibility = Dictionaries.DatabaseLiterals.boolNo;

                        inIcon.Symbol     = Symbol.Cancel;
                        inIcon.Foreground = rejectedColorBrush;
                    }
                }
            }

            #endregion
        }
예제 #7
0
        protected static bool RemoveVocabulary(VocVM Voc)
        {
            string query = string.Format(RemoveSQL, Model.Voc.ToDesc(), Voc.Id);

            if (!SendQuery(query))
            {
                return(false);
            }

            Vocabularies.Remove(Voc);

            return(true);
        }
예제 #8
0
        public virtual Vocabulary AddVoc(Vocabulary voc)
        {
            if (!Vocabularies.Contains(voc))
            {
                var sv = new SpecialityVocabularies(this, voc);
                SvHelper.Add(sv);

                voc.AddSpecVoc(sv);

                OnVocsChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Add, voc));
            }
            return(voc);
        }
예제 #9
0
        private void Refresh()
        {
            var files = dataService.GetFiles();

            Vocabularies.Clear();
            foreach (var file in files)
            {
                Vocabularies.Add(new VocabularyListViewModel(dataService, dialogService)
                {
                    FileName = file
                });
            }
            ;
        }
예제 #10
0
        private void CreateVocabularyList(string fileName)
        {
            if (string.IsNullOrEmpty(fileName))
            {
                return;
            }
            if (Vocabularies.Any(v => string.Compare(v.FileName, fileName, true) == 0))
            {
                return;
            }

            var vocabularyList = new VocabularyListViewModel(dataService, dialogService)
            {
                FileName = fileName
            };

            Vocabularies.Add(vocabularyList);
            vocabularyList.SaveCommand.Execute(null);
        }
예제 #11
0
        protected static bool InsertVocabulary(VocModel Voc)
        {
            string query = string.Format(InsertSQL + "'{1}', '{2}', {3}, '{4}', '{5}', {6})",
                                         Model.Voc.ToDesc(),
                                         Voc.Text, Voc.Answer,
                                         Null, Null, Voc.Importance, Voc.IsActive);

            if (!SendQuery(query))
            {
                return(false);
            }

            var inserted = GetLast(Model.Voc.ToDesc());

            Vocabularies.Add(inserted.Tables[0].AsEnumerable().
                             Select(GetDatarowVocabulary()).First().ToVM());

            return(true);
        }
        private List <string> CreateSuggestionList()
        {
            Vocabularies vocabularyModel    = new Vocabularies();
            string       vocQuerySelect     = "SELECT * FROM " + Dictionaries.DatabaseLiterals.TableDictionary;
            string       vocQueryWhere      = " WHERE CODETHEME = 'LITHDETAIL'";
            string       vocQueryVisibility = " AND " + Dictionaries.DatabaseLiterals.TableDictionary + "." + Dictionaries.DatabaseLiterals.FieldDictionaryVisible + " = '" + Dictionaries.DatabaseLiterals.boolYes + "'";
            string       vocFinalQuery      = vocQuerySelect + vocQueryWhere + vocQueryVisibility;

            List <object> vocResults = accessData.ReadTable(vocabularyModel.GetType(), vocFinalQuery);

            var outResults = new List <string>();

            foreach (Vocabularies tmp in vocResults)
            {
                outResults.Add(tmp.RelatedTo.ToString() + " ; " + tmp.Code.ToString());
            }

            return(outResults);
        }
예제 #13
0
        /// <summary>
        /// Will push back textbox values into the list view of picklist terms
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        public void PicklistValueAddIcon_Tapped(object sender, TappedRoutedEventArgs e)
        {
            if (_picklistEditEnableDisable)
            {
                //Get current vocab in text box
                Vocabularies currentVocab = _addModifyObject as Vocabularies;

                //Refresh list view with vocab
                bool vocabInList = false;
                for (int i = 0; i < _picklistValues.Count; i++)
                {
                    //For existing vocab in list
                    if (_picklistValues[i].Code == currentVocab.Code)
                    {
                        _picklistValues[i] = currentVocab;
                        vocabInList        = true;
                        break;
                    }
                }

                //If vocab is new
                if (!vocabInList)
                {
                    _picklistValues.Add(currentVocab);
                    _picklistValueCodes.Add(currentVocab.Code);
                    _picklistValueCodesNew.Add(currentVocab.Code);
                }

                _picklistValues.Sort(); //Sort using a custom extension
                RaisePropertyChanged("PicklistValues");

                //Refresh text box
                _addModifyTerm   = string.Empty;
                _addModifyObject = new Vocabularies();
                RaisePropertyChanged("AddModifyTerm");
                RaisePropertyChanged("AddModifyObject");
            }
        }
예제 #14
0
        /// <summary>
        /// Will manager user term selection and process it in the textbox control
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        public void picklistValues_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            ListViewBase senderBase = sender as ListViewBase;

            if (senderBase.SelectedItems.Count == 1)
            {
                Vocabularies selectedTerm = senderBase.SelectedItem as Vocabularies;

                if (selectedTerm.Editable == Dictionaries.DatabaseLiterals.boolYes || selectedTerm.Editable == null)
                {
                    _addModifyTerm   = selectedTerm.Description;
                    _addModifyObject = selectedTerm;

                    RaisePropertyChanged("AddModifyObject");
                    RaisePropertyChanged("AddModifyTerm");
                    _picklistEditEnableDisable = true;
                    RaisePropertyChanged("PicklistEditEnableDisable");
                }
                else
                {
                    //Clear tag
                    _addModifyObject = new Vocabularies();
                    RaisePropertyChanged("AddModifyObject");
                    _picklistEditEnableDisable = false;
                    RaisePropertyChanged("PicklistEditEnableDisable");
                }
            }
            else if (senderBase.SelectedItems.Count == 0 || senderBase.SelectedItems.Count > 1)
            {
                //Clear tag
                _addModifyObject = new Vocabularies();
                RaisePropertyChanged("AddModifyObject");
                _picklistEditEnableDisable = true;
                RaisePropertyChanged("PicklistEditEnableDisable");
            }
        }