Example #1
0
        private int MakeInstalledVms()
        {
            var vms = VocabularyQuery.NonCustom(Session)()
                      .Select(voc => Vocs
                              .Where(vm => vm.voc == voc)
                              .FirstOrDefault() ?? new VocabularyViewModel(voc))
                      .ToList();

            uiTaskFactory.StartNew(() =>
                                   Vocs.SyncWith(vms));

            return(vms.Count());
        }
Example #2
0
        public void AfterLoad(IEnumerable <Vocabulary> vocsToLoad)
        {
            var ids            = vocsToLoad.Select(x => x.Id).ToList();
            var selectedSynced = VocabularyQuery.ByIds(Session)(ids);

            new VocLoader(Session).LoadOrUpdateVocs(selectedSynced);

            MakeInstalledVms();
            MakeAvailableVms();
#if DEBUG
            AuthorityController.LoadVocsAfterLogin(); // загружаем словари не меняя пользователя
#endif
        }
Example #3
0
        /// <summary>
        /// Удаляем убранные, обновляем оставшиеся загруженные словари
        /// </summary>
        /// <param name="mustBeDeletedIdsPerType"></param>
        public void AfterSyncVocs(Dictionary <Type, IEnumerable <object> > mustBeDeletedIdsPerType)
        {
            Contract.Requires(mustBeDeletedIdsPerType != null);

            IEnumerable <object> ids;

            if (mustBeDeletedIdsPerType.TryGetValue(typeof(Vocabulary), out ids))
            {
                var vocsToDel = VocabularyQuery.ByIds(session)(ids.Cast <Guid>());
                DeleteVocs(vocsToDel);
            }
            var vocs = EntityQuery <Vocabulary> .All(session)();

            LoadOrUpdateVocs(vocs);
        }
Example #4
0
        public void LoadVocsAfterLogin()
        {
            if (CurrentDoctor == null)
            {
                return;
            }

            var session    = NHibernateHelper.Default.GetSession();
            var vocsForDoc = VocabularyQuery.NonCustom(session)();

            if (CurrentDoctor.Speciality != null)
            {
                vocsForDoc = CurrentDoctor.Speciality.Vocabularies;
            }
            CurrentDoctor.CacheSpecialityVocs(vocsForDoc);
        }
        public SpecialityEditorViewModel(Speciality spec)
        {
            Contract.Requires(spec != null);
            this.spec           = spec;
            spec.BlocksChanged += spec_BlocksChanged;
            spec.VocsChanged   += spec_VocsChanged;
            blocksBeforeEdit    = new List <IcdBlock>(spec.IcdBlocks);

            (spec as IEditableObject).BeginEdit();

            Chapters     = new AsyncObservableCollection <DiagnosisViewModel>();
            SpecChapters = new AsyncObservableCollection <DiagnosisViewModel>();
            AllVocs      = new ObservableCollection <VocabularyViewModel>();
            SpecVocs     = new ObservableCollection <VocabularyViewModel>();

            Speciality = new SpecialityViewModel(spec);
            tester     = new ExistanceTester <Speciality>(spec, Speciality, Session);
            tester.Test();

            CreateDiagnosisSearch();
            DiagnosisSearch.Filter.Clear();
            SpecDiagnosisSearch.Filter.Clear();

            VocabularyQuery.NonCustom(Session)()
            .ForAll(x =>
            {
                if (x.Specialities.Contains(spec))
                {
                    SpecVocs.Add(new VocabularyViewModel(x));
                }
                else
                {
                    AllVocs.Add(new VocabularyViewModel(x));
                }
            });

            Title          = "Редактор специальности";
            HelpTopic      = "editspeciality";
            WithHelpButton = false;
        }
Example #6
0
        private void TryGetAvailableVocs()
        {
            MakeInstalledVms();
            try
            {
                int available;
                using (var s = NHib.OpenSession())
                {
                    serverNonCustomVocs = VocabularyQuery.NonCustom(s)()
                                          .ToList();

                    available = MakeAvailableVms();
                }
                IsConnected     = true;
                NoAvailableVocs = available == 0;
            }
            catch (System.Exception)
            {
                serverNonCustomVocs.Clear();
                MakeAvailableVms();
                IsConnected     = false;
                NoAvailableVocs = false; // пока нет подключения, этого сообщения нет
            }
        }