Esempio n. 1
0
 public void AddConsole(console console)
 {
     try
     {
         using (db_consolesEntities db = new db_consolesEntities())
         {
             Validate(console);
             if (db.consoles.Any(x => x.Short_Name == console.Short_Name))
             {
                 throw new ArgumentException("The console's short name already exists");
             }
             db.consoles.Add(console);
             db.SaveChanges();
             ListUpdated?.Invoke();
         }
     }
     catch (ArgumentException)
     {
         throw;
     }
     catch (Exception)
     {
         throw new Exception("Something wrong happened while adding a new console");
     }
 }
Esempio n. 2
0
        private async Task UpdateList()
        {
            if (!_locallyLoaded)
            {
                ReloadLocalList();
            }

            var list = await DownloadAndParseList();

            if (list == null)
            {
                return;
            }

            foreach (var plugin in list)
            {
                if (plugin.IsObsolete || plugin.IsHidden && !SettingsHolder.Common.DeveloperMode)
                {
                    continue;
                }

                var local = GetById(plugin.Id);
                if (local != null)
                {
                    List.Remove(local);
                    plugin.InstalledVersion = local.InstalledVersion;
                }

                List.Add(plugin);
            }

            ListUpdated?.Invoke(this, EventArgs.Empty);
        }
Esempio n. 3
0
        public override async Task HandleItemNotification(ListUpdated <T> notification)
        {
            switch (notification.Type)
            {
            case ListItemChangeType.ItemUpdated:
            {
                await base.HandleItemNotification(notification);

                break;
            }

            case ListItemChangeType.ItemDeleted:
            case ListItemChangeType.ItemAdded:
            {
                // For these the only 100% working solution is to basically fetch the current page again
                // We could make a 99% working solution by comparing the current items on the client to determine
                // if the data is part of this page or not, before refreshing
                WantsToFetchDataAgain = true;

                Console.WriteLine(
                    "Refreshing current paginated page due to item add or remove. Delay to avoid too " +
                    $"many requests: {FetchTimerInterval}");
                break;
            }
            }
        }
Esempio n. 4
0
        private void OnListUpdated()
        {
            if (CurrentTrack == null)
            {
                MoveNext();
            }

            ListUpdated?.Invoke();
        }
Esempio n. 5
0
        public void UpdateNewList()
        {
            //adding items to a generic List<T>,code removed as not relevant to post
            //and raising the event afterwards

            if (ListUpdated != null)
            {
                ListUpdated.Invoke(this, EventArgs.Empty);
            }
        }
Esempio n. 6
0
 public void RemoveCompany(company company)
 {
     using (db_consolesEntities db = new db_consolesEntities())
     {
         if (db.companies.FirstOrDefault(x => x.ID == company.ID) != null)
         {
             db.Entry(company).State = System.Data.EntityState.Deleted;
             db.SaveChanges();
             ListUpdated?.Invoke();
         }
     }
 }
Esempio n. 7
0
        public HistoryTracePropertyJournalViewModel(IUnitOfWorkFactory unitOfWorkFactory, IInteractiveService interactiveService, INavigationManager navigation = null)
            : base(unitOfWorkFactory, interactiveService, navigation)
        {
            TabName = "Журнал полей объектов изменений";

            DataLoader = new AnyDataLoader <HistoryTracePropertyNode>(GetItems);

            DataLoader.ItemsListUpdated += (s, e) => { ListUpdated?.Invoke(this, EventArgs.Empty); };
            OnSelectResult += (s, e) => {
                OnEntitySelectedResult?.Invoke(this,
                                               new JournalSelectedNodesNodesEventArgs(e.SelectedObjects.OfType <JournalNodeBase>().ToArray())
                                               );
            };
        }
Esempio n. 8
0
 public void UpdateCompany(company company)
 {
     try
     {
         using (db_consolesEntities db = new db_consolesEntities())
         {
             Validate(company);
             db.Entry(company).State = System.Data.EntityState.Modified;
             db.SaveChanges();
             ListUpdated?.Invoke();
         }
     }
     catch (ArgumentException)
     { throw; }
     catch (Exception)
     {
         throw new Exception("Something wrong happened while updating the company's info.");
     }
 }
Esempio n. 9
0
 public void AddCompany(company company)
 {
     try
     {
         using (db_consolesEntities db = new db_consolesEntities())
         {
             Validate(company);
             db.companies.Add(company);
             db.SaveChanges();
             ListUpdated?.Invoke();
         }
     }
     catch (ArgumentException)
     { throw; }
     catch (Exception ex)
     {
         throw new Exception("Something wrong happened while adding a new company.");
     }
 }
Esempio n. 10
0
        protected SingleEntityJournalViewModelBase(IUnitOfWorkFactory unitOfWorkFactory, ICommonServices commonServices,
                                                   bool hideJournalForOpenDialog = false, bool hideJournalForCreateDialog = false) : base(unitOfWorkFactory, commonServices)
        {
            this.commonServices = commonServices ?? throw new ArgumentNullException(nameof(commonServices));

            EntityType = typeof(TEntity);
            var config = RegisterEntity(ItemsSourceQueryFunction);

            config.AddDocumentConfiguration("Добавить", CreateDialogFunction, OpenDialogFunction, (node) => node.EntityType == typeof(TEntity),
                                            new JournalParametersForDocument {
                HideJournalForCreateDialog = hideJournalForCreateDialog, HideJournalForOpenDialog = hideJournalForOpenDialog
            })
            .FinishConfiguration();
            FinishJournalConfiguration();

            if (!EntityConfigs[EntityType].PermissionResult.CanRead)
            {
                AbortOpening($"Нет прав для просмотра документов типа: {EntityType.GetSubjectName()}", "Невозможно открыть журнал");
            }
            DataLoader.ItemsListUpdated += (sender, e) => ListUpdated?.Invoke(sender, e);
        }
Esempio n. 11
0
        public SimpleEntityJournalViewModel(
            Expression <Func <TEntity, object> > titleExp,
            Func <TEntityTab> createDlgFunc,
            Func <CommonJournalNode, TEntityTab> openDlgFunc,
            IUnitOfWorkFactory unitOfWorkFactory,
            ICommonServices commonServices) : base(typeof(TEntity), unitOfWorkFactory, commonServices)
        {
            this.titleExp = titleExp ?? throw new ArgumentNullException(nameof(titleExp));

            if (createDlgFunc == null)
            {
                throw new ArgumentNullException(nameof(createDlgFunc));
            }

            if (openDlgFunc == null)
            {
                throw new ArgumentNullException(nameof(openDlgFunc));
            }

            Register <TEntity, TEntityTab>(ItemsSourceQueryFunction, createDlgFunc, openDlgFunc);
            ExternalNotifyChangedWith(typeof(TEntity));

            DataLoader.ItemsListUpdated += (sender, e) => ListUpdated?.Invoke(sender, e);
        }
Esempio n. 12
0
 private void OnListUpdated()
 {
     ListUpdated?.Invoke(this, EventArgs.Empty);
 }
Esempio n. 13
0
 public void OnListUpdated(EventArgs e) => ListUpdated?.Invoke(this, e);
 void onListUpdatedEventHandler(Latest latest) => ListUpdated?.Invoke(latest);
Esempio n. 15
0
 protected virtual void OnListUpdated()
 {
     ListUpdated?.Invoke(this, null);
 }