public RecepientEditorViewModel(ICachedService cachedService, IMapper mapper)
        {
            CanClose           = false;
            this.cachedService = cachedService;
            this.mapper        = mapper;
            validator          = new RecepientGroupEditorValidator();

            IsValid = true;

            var canSave = this.WhenAnyValue(tvm => tvm.IsDirty,
                                            isd => isd == true);

            SaveChangesCommand = ReactiveCommand.Create(Save, canSave);

            CancelCommand = ReactiveCommand.Create(Close);

            this.WhenAnyObservable(s => s.AllErrors.CountChanged)
            .Subscribe(_ => IsValid = !AllErrors.Items.Any());


            void Changed(object sender, PropertyChangedEventArgs e)
            {
                if (IsDirty || e.PropertyName == "IsDirty")
                {
                    return;
                }
                IsDirty = true;
            }

            PropertyChanged += Changed;
        }
Esempio n. 2
0
        public ScheduleManagerViewModel(ICachedService cachedService, IShell shell)
        {
            CanClose           = false;
            this.cachedService = cachedService;
            Shell = shell as CachedServiceShell;

            EditScheduleCommand = ReactiveCommand.Create(() =>
            {
                if (SelectedSchedule == null)
                {
                    return;
                }

                var fullName = $"Schedule {SelectedSchedule.Id} editor";

                Shell.ShowView <CronEditorView>(new CronEditorRequest
                {
                    Schedule = SelectedSchedule, ViewId = fullName
                },
                                                new UiShowOptions {
                    Title = fullName
                });
            }, Shell.CanEdit);

            DeleteCommand = ReactiveCommand.CreateFromTask(async() =>
                                                           await Delete(), Shell.CanEdit);
        }
Esempio n. 3
0
        public OperTemplatesManagerViewModel(ICachedService cachedService, IShell shell)
        {
            CanClose           = false;
            this.cachedService = cachedService;
            Shell = shell as CachedServiceShell;

            EditOperCommand = ReactiveCommand.Create(() =>
            {
                if (SelectedOperTemplate == null)
                {
                    return;
                }

                var fullName = $"Oper template {SelectedOperTemplate.Id} editor";

                Shell.ShowView <OperEditorView>(new OperEditorRequest
                {
                    Oper = SelectedOperTemplate, ViewId = fullName
                },
                                                new UiShowOptions {
                    Title = fullName
                });
            });

            DeleteCommand = ReactiveCommand.CreateFromTask(async() =>
                                                           await Delete(), Shell.CanEdit);
        }
 public WizardShellViewModel(IDatabase database, IConfigurationManager configuration, ICachedService cashedService, IEventAggregator eventAggregator)
 {
     Database        = database;
     Configuration   = configuration;
     EventAggregator = eventAggregator;
     CachedService   = cashedService;
 }
        public CashFlowTypesViewModel(IShellViewModel shell, IDatabase database, IConfigurationManager configuration, ICachedService cashedService, IEventAggregator eventAggregator)
            : base(shell, database, configuration, cashedService, eventAggregator)
        {
            SuppressEvent = false;
            _cashFlows = new BindableCollectionExt<CashFlow>();
            _cashFlows.PropertyChanged += (s, e) =>
            {
                OnPropertyChanged(s, e);
                CachedService.Clear(CachedServiceKeys.AllCashFlows);
            };

            _cashFlowGroups = new BindableCollectionExt<CashFlowGroup>();
            _cashFlowGroups.PropertyChanged += (s, e) =>
            {
                if (SuppressEvent == true)
                {
                    return;
                }
                OnPropertyChanged(s, e);

                CachedService.Clear(CachedServiceKeys.AllCashFlowGroups);
                CachedService.Clear(CachedServiceKeys.AllCashFlows);
                var cashFlowGroup = s as CashFlowGroup;
                _cashFlows.Where(x => x.CashFlowGroupId == cashFlowGroup.Id)
                    .ForEach(x => x.Group = cashFlowGroup);
                NewCashFlowGroup = null;
                NewCashFlowGroup = CashFlowGroups.First();
            };
        }
 public DownloadAndUpgradeViewModel(IShellViewModel shell, IDatabase database, IConfigurationManager configuration, ICachedService cashedService, IEventAggregator eventAggregator)
     : base(shell, database, configuration, cashedService, eventAggregator)
 {
     _webClient = new WebClient();
     _webClient.DownloadFileCompleted += OnDownloadFileCompleted;
     _webClient.DownloadProgressChanged += OnDownloadProgressChanged;
 }
Esempio n. 7
0
        public RecepientManagerViewModel(ICachedService cachedService, IShell shell)
        {
            CanClose           = false;
            this.cachedService = cachedService;
            Shell = shell as CachedServiceShell;

            var editorOptions = new UiShowChildWindowOptions
            {
                IsModal      = true,
                AllowMove    = true,
                CanClose     = true,
                ShowTitleBar = true,
                Title        = "Recepient group editing"
            };

            CreateGroupCommand = ReactiveCommand.CreateFromTask(async() =>
            {
                await Shell.ShowChildWindowView <RecepientEditorView, Unit>(
                    new RecepientEditorRequest
                {
                    Group = new ApiRecepientGroup()
                },
                    editorOptions);
            }, Shell.CanEdit);

            EditGroupCommand = ReactiveCommand.CreateFromTask(async() =>
            {
                await Shell.ShowChildWindowView <RecepientEditorView, Unit>(
                    new RecepientEditorRequest
                {
                    Group = SelectedGroup
                },
                    editorOptions);
            }, Shell.CanEdit);
        }
        public OperTemplatesListViewModel(ICachedService service)
        {
            cachedService = service;

            this.ObservableForProperty(s => s.OperationsSearchString)
            .Subscribe(sstr =>
            {
                OperTemplates.Clear();

                cachedService.OperTemplates.Connect().Filter(oper =>
                                                             oper.Name.IndexOf(sstr.Value, StringComparison.OrdinalIgnoreCase) >=
                                                             0)
                .Bind(OperTemplates).Subscribe();
            });

            CancelCommand = ReactiveCommand.Create(Close);

            SelectTemplateCommand = ReactiveCommand.Create <ApiOperTemplate>(templ =>
            {
                taskEditor.ParseTemplate(templ);
                Close();
            });

            AddFullTemplateCommand = ReactiveCommand.Create <ApiOperTemplate>(templ =>
            {
                taskEditor.AddFullTemplate(templ);
                Close();
            });
        }
 public BudgetViewModel(IShellViewModel shell, IDatabase database, IConfigurationManager configuration, ICachedService cashedService, IEventAggregator eventAggregator)
     : base(shell, database, configuration, cashedService, eventAggregator)
 {
     ExpensesViewModel   = IoC.Get<ExpensesViewModel>();
     RevenuesViewModel   = IoC.Get<RevenuesViewModel>();
     BudgetPlanViewModel = IoC.Get<BudgetPlanViewModel>();
     BudgetCalculatorViewModel = IoC.Get<BudgetCalculationsViewModel>();
 }
 public ServiceBrokerService(IServiceRepository serviceRepository, IDynamicService dynamicService,
                             ICachedService cachedService, IStaticService staticService, ITaskScheduler taskScheduler, ICache cache)
 {
     _serviceRepository = serviceRepository;
     _dynamicService    = dynamicService;
     _cachedService     = cachedService;
     _taskScheduler     = taskScheduler;
     _cache             = cache;
     _staticService     = staticService;
 }
Esempio n. 11
0
        public BaseViewModel(IShellViewModel shell, IDatabase database, IConfigurationManager configuration, ICachedService cashedService, IEventAggregator eventAggregator)
        {
            Initialize();

            Shell           = shell;
            Database        = database;
            Configuration   = configuration;
            EventAggregator = eventAggregator;
            CachedService   = cashedService;

            EventAggregator.Subscribe(this);
        }
Esempio n. 12
0
        public CachedServiceShell(ICachedService cachedService, IAuthenticationContext context)
        {
            this.cachedService = cachedService;
            authContext        = context;



            RefreshCommand = ReactiveCommand.Create(this.cachedService.RefreshData);

            CanEdit = this.WhenAnyValue(shl => shl.Role, role => role == ServiceUserRole.Editor);

            CanStopRun = this.WhenAnyValue(shl => shl.Role, role => role == ServiceUserRole.Editor ||
                                           role == ServiceUserRole.StopRunner);

            CreateTaskCommand = ReactiveCommand.Create(() =>
                                                       ShowView <TaskEditorView>(new TaskEditorRequest
            {
                ViewId = "Creating new Task",
                Task   = new ApiTask {
                    Id = 0
                }
            },
                                                                                 new UiShowOptions {
                Title = "Creating new Task"
            }), CanEdit);

            CreateScheduleCommand = ReactiveCommand.Create(() =>
                                                           ShowView <CronEditorView>(new CronEditorRequest
            {
                ViewId   = "Creating new Schedule",
                Schedule = new ApiSchedule {
                    Id = 0
                }
            },
                                                                                     new UiShowOptions {
                Title = "Creating new Schedule"
            }), CanEdit);

            CreateOperTemplateCommand = ReactiveCommand.Create(() =>
                                                               ShowView <OperEditorView>(new OperEditorRequest
            {
                Oper = new ApiOperTemplate {
                    Id = 0
                },
                ViewId = "Creating new operation template"
            },
                                                                                         new UiShowOptions {
                Title = "Creating new operation template"
            }), CanEdit);
        }
Esempio n. 13
0
        public ShellViewModel(IDatabase database, IEventAggregator eventAggregator, IConfigurationManager configurationManager, ICachedService cachedService)
        {
            SQLiteHelper.CreateDefaultDatabase();

            Database             = database;
            CachedService        = cachedService;
            EventAggregator      = eventAggregator;
            ConfigurationManager = configurationManager;
            CurrentBudgetDate    = DateTime.Now;
            DisplayName          = "Budżet Domowy";
            EventAggregator.Subscribe(this);
            _timer          = new Timer();
            _timer.Elapsed += delegate
            {
                CheckForUpdates(false);
            };
            CanCheckForUpdates = true;
        }
Esempio n. 14
0
        public CronEditorViewModel(ICachedService cachedService, IShell shell)
        {
            this.shell         = shell as CachedServiceShell;
            this.cachedService = cachedService;
            categories         = new SourceList <CronCategory>();
            IsValid            = true;
            validator          = new CronEditorValidator();

            var canSave = this.WhenAnyValue(tvm => tvm.IsDirty,
                                            isd => isd == true);

            SaveChangesCommand = ReactiveCommand.CreateFromTask(async() => await Save(),
                                                                canSave);

            CancelCommand = ReactiveCommand.CreateFromTask(async() =>
            {
                if (IsDirty)
                {
                    if (!await this.shell.ShowWarningAffirmativeDialogAsync
                            ("All unsaved changes will be lost. Close window?"))
                    {
                        return;
                    }
                }

                Close();
            });

            for (int i = 0; i < 5; i++)
            {
                categories.Add(new CronCategory(i));
            }

            this.WhenAnyValue(conncr => conncr.FullExpression)
            .Where(value => !string.IsNullOrEmpty(value))
            .Subscribe(_ => UpdateCategories());
        }
        public TaskEditorViewModel(ICachedService service, IMapper mapper, IShell shell)
        {
            cachedService = service;
            this.mapper   = mapper;
            validator     = new TaskEditorValidator();
            IsValid       = true;
            Shell         = shell as CachedServiceShell;

            taskParameters   = new SourceList <TaskParameter>();
            taskDependencies = new SourceList <DesktopTaskDependence>();
            bindedOpers      = new SourceList <DesktopOperation>();
            incomingPackages = new SourceList <string>();
            tasks            = new SourceList <DesktopTaskNameId>();

            DataImporters       = cachedService.DataImporters;
            DataExporters       = cachedService.DataExporters;
            implementationTypes = new SourceList <string>();

            var canSave = this.WhenAnyValue(tvm => tvm.IsDirty, tvm => tvm.IsValid,
                                            (isd, isv) => isd && isv).Concat(Shell.CanEdit);

            SaveChangesCommand = ReactiveCommand.CreateFromTask(async() => await Save(),
                                                                canSave);

            CancelCommand = ReactiveCommand.CreateFromTask(Cancel);

            ClipBoardFillCommand = ReactiveCommand.Create <string>(Clipboard.SetText);

            OpenCurrentTaskViewCommand = ReactiveCommand //todo: make without interface blocking
                                         .CreateFromTask(async() =>
                                                         cachedService.OpenPageInBrowser(
                                                             await cachedService.GetCurrentTaskViewById(Id)));

            RemoveOperationCommand = ReactiveCommand.Create <DesktopOperation>(to =>
            {
                if (SelectedOperation?.Id == to.Id)
                {
                    ClearSelections();
                }
                bindedOpers.Remove(to);
            }, Shell.CanEdit);

            RemoveParameterCommand = ReactiveCommand
                                     .Create <TaskParameter>(par => taskParameters.Remove(par), Shell.CanEdit);

            RemoveDependenceCommand = ReactiveCommand
                                      .Create <DesktopTaskDependence>(dep => taskDependencies.Remove(dep), Shell.CanEdit);

            AddParameterCommand = ReactiveCommand.Create(() => taskParameters.Add(new TaskParameter
            {
                Name = "@RepPar"
            }), Shell.CanEdit);

            AddDependenceCommand = ReactiveCommand.CreateFromTask(async() =>
            {
                if (tasks.Count == 0)
                {
                    await Shell.ShowMessageAsync("No any existing tasks in service");
                    return;
                }

                tasks
                .Connect()
                .Bind(out var cachedTasks)
                .Subscribe();

                var dependence = new DesktopTaskDependence {
                    Tasks = cachedTasks, TaskId = cachedTasks.First().Id
                };
                taskDependencies.Add(dependence);
            }, Shell.CanEdit);

            AddOperationCommand = ReactiveCommand.CreateFromTask(AddOperation, Shell.CanEdit);


            CreateOperConfigCommand = ReactiveCommand.CreateFromTask(CreateOperConfig, Shell.CanEdit);

            OpenTemplatesListCommand = ReactiveCommand.CreateFromTask(async() =>
            {
                if (SelectedOperationConfig != null && Shell.Role == ServiceUserRole.Editor)
                {
                    if (!await Shell.ShowWarningAffirmativeDialogAsync
                            ("All unsaved operation configuration changes will be lost. Close window?"))
                    {
                        return;
                    }
                }

                await SelectOperFromTemplates();
            }, Shell.CanEdit);

            SelectOperationCommand = ReactiveCommand.CreateFromTask <DesktopOperation>
                                         (SelectOperation);

            this.ObservableForProperty(s => s.Mode)
            .Subscribe(mode =>
            {
                var templates = mode?.Value == OperMode.Exporter
                        ? DataExporters.Select(pair => pair.Key)
                        : DataImporters.Select(pair => pair.Key);

                implementationTypes.ClearAndAddRange(templates);
                Type = implementationTypes.Items.FirstOrDefault();
            });

            this.ObservableForProperty(s => s.Type)
            .Where(type => type.Value != null)
            .Subscribe(type =>
            {
                var operType = Mode == OperMode.Exporter
                        ? DataExporters[type.Value]
                        : DataImporters[type.Value];
                if (operType == null)
                {
                    return;
                }

                SelectedOperationConfig = Activator.CreateInstance(operType);
                mapper.Map(cachedService, SelectedOperationConfig);
            });

            this.WhenAnyValue(tvm => tvm.SelectedOperationConfig)
            .Where(selop => selop != null)
            .Subscribe(conf =>
                       IncomingPackages = incomingPackages.SpawnCollection());
        }
 public RevenuesViewModel(IShellViewModel shell, IDatabase database, IConfigurationManager configuration, ICachedService cashedService, IEventAggregator eventAggregator)
     : base(shell, database, configuration, cashedService, eventAggregator)
 {
     AvailableIncomes = new BindableCollectionExt<Income>();
     AvailableSavings = new BindableCollectionExt<Saving>();
 }
Esempio n. 17
0
 public IncomesViewModel(IShellViewModel shell, IDatabase database, IConfigurationManager configuration, ICachedService cashedService, IEventAggregator eventAggregator)
     : base(shell, database, configuration, cashedService, eventAggregator)
 {
     _incomes = new BindableCollectionExt <Income>();
 }
        public TaskManagerViewModel(ICachedService cachedService, IMapper mapper, IShell shell)
        {
            CanClose           = false;
            this.cachedService = cachedService;
            this.mapper        = mapper;
            Shell = shell as CachedServiceShell;
            var packageBuilder = new ProtoPackageBuilder();

            selectedTaskInstances = new SourceList <DesktopTaskInstance>();
            operInstances         = new SourceList <DesktopOperInstance>();

            IObservable <bool> canOpenInstancePage = this //todo:some check for is viewdataset?"
                                                     .WhenAnyValue(t => t.SelectedInstanceData,
                                                                   si => !string.IsNullOrEmpty(si?.DataSet));

            OpenPage = ReactiveCommand.Create <string>
                           (cachedService.OpenPageInBrowser, canOpenInstancePage);

            EditTaskCommand = ReactiveCommand.CreateFromTask(async() =>
            {
                if (SelectedTask == null)
                {
                    return;
                }
                var id = SelectedTask.Id;

                cachedService.RefreshData();
                if (cachedService
                    .Tasks.Items.FirstOrDefault(task => task.Id == id) == null)
                {
                    await Shell.ShowMessageAsync("Task not longer exists");
                    return;
                }

                var name = $"Task {id} editor";
                Shell.ShowView <TaskEditorView>(new TaskEditorRequest
                {
                    ViewId = name,
                    Task   = cachedService
                             .Tasks.Items.FirstOrDefault(task => task.Id == id),
                    TaskOpers = cachedService.Operations.Items.Where(to => to.TaskId == id).ToList()
                },
                                                new UiShowOptions {
                    Title = name
                });
            });

            DeleteCommand = ReactiveCommand.CreateFromTask(async() =>
                                                           await Delete(), Shell.CanEdit);


            StopTaskCommand = ReactiveCommand.CreateFromTask <int, string>(async par =>
            {
                if (!await Shell.ShowWarningAffirmativeDialogAsync("Сancel task execution?"))
                {
                    return("False");
                }

                var t = await this.cachedService.StopTaskByInstanceId(par);
                LoadInstanceCompactsByTaskId(SelectedTask.Id);
                return(t);
            }, Shell.CanStopRun);

            RunTaskCommand = ReactiveCommand.CreateFromTask <DesktopTask>(async par =>
            {
                var workingInstances = await cachedService.GetWorkingTaskInstancesById(par.Id);
                if (workingInstances.Count > 0)
                {
                    await Shell.ShowMessageAsync(
                        $"This task already has working instances ({string.Join(", ", workingInstances)}). " +
                        "You can try to execute it later");
                }
                else
                {
                    if (!await Shell.ShowWarningAffirmativeDialogAsync($"Do you want to execute task {par.Name}?"))
                    {
                        return;
                    }

                    var res = await cachedService.StartTaskById(par.Id);
                    LoadInstanceCompactsByTaskId(SelectedTask.Id);
                    await Shell.ShowMessageAsync(res, "Task execution");
                }
            }, Shell.CanStopRun);

            this.WhenAnyValue(s => s.SelectedTask)
            .Where(x => x != null)
            .Subscribe(x => LoadInstanceCompactsByTaskId(x.Id));

            this.WhenAnyValue(s => s.SelectedTaskInstance)
            .Subscribe(x =>
            {
                if (x == null)
                {
                    operInstances.Clear();
                }
                else
                {
                    operInstances.ClearAndAddRange(
                        cachedService.GetOperInstancesByTaskInstanceId(x.Id)
                        .Select(mapper.Map <DesktopOperInstance>));
                }
            });

            this.WhenAnyValue(s => s.SelectedOperInstance)
            .Subscribe(async x =>
            {
                var data = new DesktopOperInstance();

                if (x != null)
                {
                    var fullInstance = cachedService
                                       .GetFullOperInstanceById(SelectedOperInstance.Id);

                    data = mapper.Map <DesktopOperInstance>(fullInstance);

                    if (fullInstance.DataSet != null)
                    {
                        try
                        {
                            data.DataSet = JsonConvert.SerializeObject(packageBuilder.GetPackageValues(
                                                                           OperationPackage.Parser.ParseFrom(fullInstance.DataSet)));
                        }
                        catch
                        {
                            await Shell.ShowMessageAsync("Exception occured during dataset decoding");
                        }
                    }
                }

                SelectedInstanceData = x == null
                        ? null
                        : data;
            });
        }
 public ExpensesFilteringViewModel(IShellViewModel shell, IDatabase database, IConfigurationManager configuration, ICachedService cashedService, IEventAggregator eventAggregator)
     : base(shell, database, configuration, cashedService, eventAggregator)
 {
     Filter = IoC.Get <ExpensesFilterVM>();
 }
 public BudgetEquationWizardShellViewModel(IDatabase database, IConfigurationManager configuration, ICachedService cashedService, IEventAggregator eventAggregator)
     : base(database, configuration, cashedService, eventAggregator)
 {
 }
Esempio n. 21
0
 public SavingsViewModel(IShellViewModel shell, IDatabase database, IConfigurationManager configuration, ICachedService cashedService, IEventAggregator eventAggregator)
     : base(shell, database, configuration, cashedService, eventAggregator)
 {
     _savings = new BindableCollectionExt<Saving>();
     _savings.PropertyChanged += OnSavingPropertyChanged;
 }
Esempio n. 22
0
        //static MemcachedMamager iCacheProvider;

        static CacheCurrentInfoMgr()
        {
            //iCacheProvider = new MemcachedService("MOVOGatewayService");
            iCacheProvider = new CachedService();
        }
 public BaseDailogViewModel(IShellViewModel shell, IDatabase database, IConfigurationManager configuration, ICachedService cashedService, IEventAggregator eventAggregator)
     : base(shell, database, configuration, cashedService, eventAggregator)
 {
     State = DialogState.None;
 }
 public BudgetCalculatorEvaluator(ICachedService cashedService)
 {
     CachedService = cashedService;
     _calculator = new CalcContext<decimal>();
 }
 public ExpensesFilteringViewModel(IShellViewModel shell, IDatabase database, IConfigurationManager configuration, ICachedService cashedService, IEventAggregator eventAggregator)
     : base(shell, database, configuration, cashedService, eventAggregator)
 {
     Filter = IoC.Get<ExpensesFilterVM>();
 }
Esempio n. 26
0
 public SavingsViewModel(IShellViewModel shell, IDatabase database, IConfigurationManager configuration, ICachedService cashedService, IEventAggregator eventAggregator)
     : base(shell, database, configuration, cashedService, eventAggregator)
 {
     _savings = new BindableCollectionExt <Saving>();
     _savings.PropertyChanged += OnSavingPropertyChanged;
 }
 public CashFlowGroupDeleteConfirmationViewModel(IShellViewModel shell, IDatabase database, IConfigurationManager configuration, ICachedService cashedService, IEventAggregator eventAggregator)
     : base(shell, database, configuration, cashedService, eventAggregator)
 {
     CashFlowGroups = new BindableCollectionExt <CashFlowGroup>();
 }
Esempio n. 28
0
 public BudgetCalculatorEvaluator(ICachedService cashedService)
 {
     CachedService = cashedService;
     _calculator   = new CalcContext <decimal>();
 }
Esempio n. 29
0
        public CashFlowTypesViewModel(IShellViewModel shell, IDatabase database, IConfigurationManager configuration, ICachedService cashedService, IEventAggregator eventAggregator)
            : base(shell, database, configuration, cashedService, eventAggregator)
        {
            SuppressEvent = false;
            _cashFlows    = new BindableCollectionExt <CashFlow>();
            _cashFlows.PropertyChanged += (s, e) =>
            {
                OnPropertyChanged(s, e);
                CachedService.Clear(CachedServiceKeys.AllCashFlows);
            };

            _cashFlowGroups = new BindableCollectionExt <CashFlowGroup>();
            _cashFlowGroups.PropertyChanged += (s, e) =>
            {
                if (SuppressEvent == true)
                {
                    return;
                }
                OnPropertyChanged(s, e);

                CachedService.Clear(CachedServiceKeys.AllCashFlowGroups);
                CachedService.Clear(CachedServiceKeys.AllCashFlows);
                var cashFlowGroup = s as CashFlowGroup;
                _cashFlows.Where(x => x.CashFlowGroupId == cashFlowGroup.Id)
                .ForEach(x => x.Group = cashFlowGroup);
                NewCashFlowGroup      = null;
                NewCashFlowGroup      = CashFlowGroups.First();
            };
        }
 public CashFlowGroupDeleteConfirmationViewModel(IShellViewModel shell, IDatabase database, IConfigurationManager configuration, ICachedService cashedService, IEventAggregator eventAggregator)
     : base(shell, database, configuration, cashedService, eventAggregator)
 {
     CashFlowGroups = new BindableCollectionExt<CashFlowGroup>();
 }
Esempio n. 31
0
 public ExpensesViewModel(IShellViewModel shell, IDatabase database, IConfigurationManager configuration, ICachedService cashedService, IEventAggregator eventAggregator)
     : base(shell, database, configuration, cashedService, eventAggregator)
 {
     _filteredBudgetExpenses = new List <Expense>();
     ExpensesGridCashFlows   = new BindableCollectionExt <CashFlow>();
     CashFlows                  = new BindableCollectionExt <CashFlow>();
     Filter                     = new ExpensesFilterVM(EventAggregator);
     IsFilteringEnabled         = true;
     ExpensesFilteringViewModel = IoC.Get <ExpensesFilteringViewModel>();
 }
Esempio n. 32
0
        public OperEditorViewModel(ICachedService cachedService, IMapper mapper, IShell shell)
        {
            Shell = shell as CachedServiceShell;
            this.cachedService = cachedService;
            this.mapper        = mapper;
            IsValid            = true;
            validator          = new OperEditorValidator();

            var operTemplates = new SourceList <string>();

            var canSave = this.WhenAnyValue(tvm => tvm.IsDirty,
                                            isd => isd == true).Concat(Shell.CanEdit);

            SaveChangesCommand = ReactiveCommand.CreateFromTask(async() => await Save(),
                                                                canSave);

            CancelCommand = ReactiveCommand.CreateFromTask(async() =>
            {
                if (IsDirty)
                {
                    if (!await Shell.ShowWarningAffirmativeDialogAsync
                            ("All unsaved changes will be lost. Close window?"))
                    {
                        return;
                    }
                }

                Close();
            });

            this.ObservableForProperty(s => s.Mode)
            .Subscribe(mode =>
            {
                var templates = mode.Value == OperMode.Exporter
                        ? DataExporters.Select(pair => pair.Key)
                        : DataImporters.Select(pair => pair.Key);

                operTemplates.ClearAndAddRange(templates);

                OperTemplates = operTemplates.SpawnCollection();

                ImplementationType = operTemplates.First();
            });

            this.ObservableForProperty(s => s.ImplementationType)
            .Where(type => type.Value != null)
            .Subscribe(type =>
            {
                var operType = Mode == OperMode.Exporter
                        ? DataExporters[type.Value]
                        : DataImporters[type.Value];
                if (operType == null)
                {
                    return;
                }

                Configuration = Activator.CreateInstance(operType);
                mapper.Map(cachedService, Configuration);
            });

            this.WhenAnyObservable(s => s.AllErrors.CountChanged)
            .Subscribe(_ => IsValid = !AllErrors.Items.Any());
        }
Esempio n. 33
0
 public DownloadAndUpgradeViewModel(IShellViewModel shell, IDatabase database, IConfigurationManager configuration, ICachedService cashedService, IEventAggregator eventAggregator)
     : base(shell, database, configuration, cashedService, eventAggregator)
 {
     _webClient = new WebClient();
     _webClient.DownloadFileCompleted   += OnDownloadFileCompleted;
     _webClient.DownloadProgressChanged += OnDownloadProgressChanged;
 }
Esempio n. 34
0
 public NotepadViewModel(IShellViewModel shell, IDatabase database, IConfigurationManager configuration, ICachedService cashedService, IEventAggregator eventAggregator)
     : base(shell, database, configuration, cashedService, eventAggregator)
 {
 }
Esempio n. 35
0
 public BudgetViewModel(IShellViewModel shell, IDatabase database, IConfigurationManager configuration, ICachedService cashedService, IEventAggregator eventAggregator)
     : base(shell, database, configuration, cashedService, eventAggregator)
 {
     ExpensesViewModel         = IoC.Get <ExpensesViewModel>();
     RevenuesViewModel         = IoC.Get <RevenuesViewModel>();
     BudgetPlanViewModel       = IoC.Get <BudgetPlanViewModel>();
     BudgetCalculatorViewModel = IoC.Get <BudgetCalculationsViewModel>();
 }
 public BudgetPlanViewModel(IShellViewModel shell, IDatabase database, IConfigurationManager configuration, ICachedService cashedService, IEventAggregator eventAggregator)
     : base(shell, database, configuration, cashedService, eventAggregator)
 {
     AllBudgetPlanList     = new BindableCollectionExt <BudgetPlanItemVM>();
     BudgetPlanListGrouped = new BindableCollectionExt <BudgetPlanGroupItemVM>();
 }
 public BudgetPlanViewModel(IShellViewModel shell, IDatabase database, IConfigurationManager configuration, ICachedService cashedService, IEventAggregator eventAggregator)
     : base(shell, database, configuration, cashedService, eventAggregator)
 {
     AllBudgetPlanList = new BindableCollectionExt<BudgetPlanItemVM>();
     BudgetPlanListGrouped = new BindableCollectionExt<BudgetPlanGroupItemVM>();
 }
Esempio n. 38
0
 public BudgetCalculationsViewModel(IShellViewModel shell, IDatabase database, IConfigurationManager configuration, ICachedService cashedService, IEventAggregator eventAggregator)
     : base(shell, database, configuration, cashedService, eventAggregator)
 {
     SuppressEvent              = false;
     Equations                  = new BindableCollectionExt <BudgetCalculatorEquation>();
     BudgetCalculatorEvaluator  = IoC.Get <BudgetCalculatorEvaluator>();
     Equations.PropertyChanged += (s, e) => { if (!SuppressEvent)
                                              {
                                                  Save(s as Entity);
                                              }
     };
     EventAggregator.Subscribe(this);
 }
Esempio n. 39
0
 public NotepadViewModel(IShellViewModel shell, IDatabase database, IConfigurationManager configuration, ICachedService cashedService, IEventAggregator eventAggregator)
     : base(shell, database, configuration, cashedService, eventAggregator)
 {
 }