Example #1
0
 protected override void Context()
 {
     _workspace      = A.Fake <ICoreWorkspace>();
     _historyManager = A.Fake <IHistoryManager>();
     A.CallTo(() => _workspace.HistoryManager).Returns(_historyManager);
     sut = new UndoCommand(_workspace);
 }
Example #2
0
        static void ForwardFillBars(IHistoryManager cache, string symbol, Periodicity periodicity, FxPriceType priceType, DateTime startTime, DateTime endTime, ICollection <HistoryBar> bars)
        {
            try
            {
                for (var current = startTime; current < endTime;)
                {
                    var report = cache.QueryBarHistory(current, -RequestedBarsNumber, symbol, periodicity.ToString(), priceType);
                    var items  = report.Items;

                    foreach (var element in report.Items)
                    {
                        if (element.Time >= endTime)
                        {
                            return;
                        }
                        bars.Add(element);
                    }
                    if (items.Count == 0)
                    {
                        return;
                    }
                    current = items.Last().Time;
                    current = current + periodicity;
                }
            }
            catch (StorageHistoryNotFoundException)
            {
            }
        }
Example #3
0
        public void CreateReport(IHistoryManager historyManager, ReportOptions reportOptions)
        {
            var dataTable = historyManager.ToDataTable();

            using (var workBook = new WorkBook())
            {
                //add new sheet where the report will be written
                workBook.insertSheets(SheetIndex.Report, 1);

                workBook.ImportDataTable(dataTable, true, 0, 0, dataTable.Rows.Count, dataTable.Columns.Count);

                for (int colIndex = 0; colIndex < dataTable.Columns.Count; colIndex++)
                {
                    workBook.setColWidthAutoSize(colIndex, true);
                }

                workBook.setSheetName(SheetIndex.Report, reportOptions.SheetName);

                ExportToExcelTask.SaveWorkbook(reportOptions.ReportFullPath, workBook);

                if (reportOptions.OpenReport)
                {
                    FileHelper.TryOpenFile(reportOptions.ReportFullPath);
                }
            }
        }
Example #4
0
        protected override void Context()
        {
            _projectPersistor         = A.Fake <IProjectPersistor>();
            _historyManagerPersistor  = A.Fake <IHistoryManagerPersistor>();
            _progressManager          = A.Fake <IProgressManager>();
            _workspaceLayoutPersistor = A.Fake <IWorkspaceLayoutPersistor>();
            _historyManager           = A.Fake <IHistoryManager>();
            _projectFileCompressor    = A.Fake <IProjectFileCompressor>();
            _databaseSchemaMigrator   = A.Fake <IDatabaseSchemaMigrator>();
            _journalLoader            = A.Fake <IJournalLoader>();
            _projectClassifiableUpdaterAfterDeserialization = A.Fake <IProjectClassifiableUpdaterAfterDeserialization>();
            _command1 = A.Fake <IPKSimCommand>();
            _command2 = A.Fake <IPKSimCommand>();
            var history1 = A.Fake <IHistoryItem>();

            A.CallTo(() => history1.Command).Returns(_command1);
            var history2 = A.Fake <IHistoryItem>();

            A.CallTo(() => history2.Command).Returns(_command2);

            A.CallTo(() => _progressManager.Create()).Returns(A.Fake <IProgressUpdater>());
            A.CallTo(() => _historyManager.History).Returns(new[] { history1, history2 });
            _workspace = A.Fake <IWorkspace>();
            _workspace.HistoryManager = _historyManager;
            _session     = A.Fake <ISession>();
            _transaction = A.Fake <ITransaction>();
            A.CallTo(() => _session.BeginTransaction()).Returns(_transaction);
            _sessionManager = A.Fake <ISessionManager>();
            A.CallTo(() => _sessionManager.OpenSession()).Returns(_session);
            _fileName = "c:\\toto.txt";
            sut       = new WorkspacePersistor(_projectPersistor, _historyManagerPersistor, _workspaceLayoutPersistor, _sessionManager, _progressManager,
                                               _projectFileCompressor, _databaseSchemaMigrator, _journalLoader, _projectClassifiableUpdaterAfterDeserialization);
        }
Example #5
0
 public Region(Location location, IHistoryManager<Region> historyManager = null)
 {
     Location = location;
     HistoryManager = historyManager;
     AfterAddBizEntity += new EventHandler<BizEntityEventArg>(DefaultAddBizEntityHandler);
     AfterRemoveBizEntity += new EventHandler<BizEntityEventArg>(DefaultRemoveBizEntityHandler);
 }
Example #6
0
        public Layout(IHistoryManagerFactory historyManagerFactory, bool required = true)
            : base(GridLength.Auto)
        {
            mHistoryManager = historyManagerFactory.CreatePatternsHistoryManager();

            if (required)
            {
                Layouts = new[]
                {
                    LayoutDescriptor.Simple,
                    LayoutDescriptor.Pattern
                };

                SelectedLayout = LayoutDescriptor.Simple;
            }
            else
            {
                Layouts = new[]
                {
                    LayoutDescriptor.None,
                    LayoutDescriptor.Simple,
                    LayoutDescriptor.Pattern
                };

                SelectedLayout = LayoutDescriptor.None;
            }

            HistoricalLayouts = mHistoryManager.Get();
        }
 public MultiFeature edit(IHistoryManager history)
 {
     features1.HistoryManager = history;
     history?.MakeHistory(null);
     ShowDialog();
     return(bf);
 }
Example #8
0
		public void Dispose()
		{
			var provider = this.Provider;
			this.Provider = null;
			if (provider != null)
				provider.Dispose();
		}
Example #9
0
        public StaticCommandList()
        {
            InitializeComponent();
            _myContext = new MyContext();

            var historyBrowserConfiguation = IoC.Resolve <IHistoryBrowserConfiguration>();
            var historyManagerRetriever    = IoC.Resolve <IHistoryManagerRetriever>();

            historyBrowserConfiguation.AddDynamicColumn("p1", "A wonderful p1");
            historyBrowserConfiguation.AddDynamicColumn("p2", "A great p2");

            HistoryColumns.ColumnByName("p1").Position = 0;
            HistoryColumns.User.Position               = 1;
            HistoryColumns.Description.Position        = 2;
            HistoryColumns.ColumnByName("p2").Position = 3;
            HistoryColumns.Description.Position        = 4;
            HistoryColumns.State.Position              = 5;

            _historyManager = historyManagerRetriever.Current;

            _historyBrowserPresenter = IoC.Resolve <IHistoryBrowserPresenter>();
            _historyBrowserPresenter.Initialize();

            var control = _historyBrowserPresenter.View as Control;

            control.Dock = DockStyle.Fill;
            panelControl1.Controls.Add(control);

            _historyBrowserPresenter.HistoryManager = _historyManager;
            _historyBrowserPresenter.UpdateHistory();
        }
Example #10
0
        public Layout(ReadOnlyCollection <IProperty> container, IHistoryManager historyManager, bool required = true)
            : base(container, GridLength.Auto)
        {
            mHistoryManager = historyManager;

            if (required)
            {
                Layouts = new[]
                {
                    LayoutDescriptor.Simple,
                    LayoutDescriptor.Pattern
                };

                SelectedLayout = LayoutDescriptor.Simple;
            }
            else
            {
                Layouts = new[]
                {
                    LayoutDescriptor.None,
                    LayoutDescriptor.Simple,
                    LayoutDescriptor.Pattern
                };

                SelectedLayout = LayoutDescriptor.None;
            }

            HistoricalLayouts = mHistoryManager.Get();
        }
Example #11
0
        protected void CreateExistingItemAndMetaDataItem()
        {
            _existingItem = new HistoryItem("user", new DateTime(), A.Fake <ICommand>())
            {
                Id = "id"
            };
            _existingMetaDataItem = new HistoryItemMetaData {
                User = _existingItem.User, Id = "id", Command = new CommandMetaData {
                    Comment = "there"
                }
            };
            _existingItem.Command.Comment = "hi";
            _history = new List <IHistoryItem>
            {
                _existingItem
            };

            _existingHistoryItemMetaData = new List <HistoryItemMetaData>
            {
                _existingMetaDataItem
            };

            _historyManager = A.Fake <IHistoryManager>();

            A.CallTo(() => _historyManager.History).Returns(_history);
            A.CallTo(() => _historyItemMetaDataRepository.All(A <ISession> ._)).Returns(_existingHistoryItemMetaData);
            A.CallTo(() => _historyItemToHistoryItemMetaDataMapper.MapFrom(_existingItem)).Returns(_existingMetaDataItem);
        }
Example #12
0
 public ChoiceFeature edit(IHistoryManager history)
 {
     history?.MakeHistory(null);
     features1.HistoryManager = history;
     ShowDialog();
     return(bf);
 }
Example #13
0
        public void Disconnect()
        {
            if (_historyManager != null)
            {
                _historyManager.Flush();
                _historyManager.Dispose();
                _historyManager = null;
            }

            if (_historyStore != null)
            {
                _historyStore.Dispose();
                _historyStore = null;
            }

            if (_historyServiceClient != null)
            {
                _historyServiceClient = new HistoryServiceClient(Address);
            }

            if (_historySource == null)
            {
                _historySource = _historyServiceClient.ChannelFactory.CreateChannel();
            }
        }
Example #14
0
        public void CreateReport(IHistoryManager historyManager, ReportOptions reportOptions)
        {
            var dataTable = historyManager.ToDataTable();

            dataTable.TableName = reportOptions.SheetName;

            ExportToExcelTask.ExportDataTableToExcel(dataTable, reportOptions.ReportFullPath, true);
        }
Example #15
0
 public File(IMessageBoxService messageBoxService, IHistoryManagerFactory historyManagerFactory)
     : base(GridLength.Auto)
 {
     Open = new Command(OpenFile);
     mMessageBoxService = messageBoxService;
     mHistoryManager    = historyManagerFactory.CreateFilePathHistoryManager();
     HistoricalFiles    = mHistoryManager.Get();
 }
Example #16
0
 protected override void Context()
 {
     _historyManager        = A.Fake <IHistoryManager>();
     _labelPresenter        = A.Fake <ILabelPresenter>();
     _applicationController = A.Fake <IApplicationController>();
     A.CallTo(() => _applicationController.Start <ILabelPresenter>()).Returns(_labelPresenter);
     sut = new LabelTask(_applicationController);
 }
        public SessionServiceViewModel(ISessionService sessionService,
                                       IInputBoxService inputBoxService,
                                       IMessageBoxService messageBoxService,
                                       IWindowManager windowManager,
                                       Lazy <IDocumentManager> documentManager,
                                       ITextDocumentService textDocumentService,
                                       IHistoryManager historyManager)
        {
            this.SessionService    = sessionService;
            this.inputBoxService   = inputBoxService;
            this.messageBoxService = messageBoxService;
            this.windowManager     = windowManager;
            this.History           = historyManager;
            History.AddHandler(this);

            Undo = new DelegateCommand(() => History.Undo(), () => History.CanUndo).ObservesProperty(() =>
                                                                                                     History.CanUndo);
            Redo = new DelegateCommand(() => History.Redo(), () => History.CanRedo).ObservesProperty(() =>
                                                                                                     History.CanRedo);

            NewSessionCommand = new AsyncAutoCommand(NewSession);

            var save = new AsyncAutoCommand(SaveCurrent, _ => sessionService.IsNonEmpty);

            SaveCurrentCurrent = save;

            var forget = new AsyncAutoCommand(ForgetCurrent, _ => sessionService.IsOpened);

            ForgetCurrentCurrent = forget;

            DeleteItem = new DelegateCommand <ISolutionItem>(sessionService.RemoveItem, _ => sessionService.IsOpened).ObservesProperty(() => this.SessionService.IsOpened);

            var preview = new DelegateCommand(() =>
            {
                var sql = sessionService.GenerateCurrentQuery();
                if (sql == null)
                {
                    return;
                }
                documentManager.Value.OpenDocument(textDocumentService.CreateDocument($"Preview of " + sessionService.CurrentSession !.Name, sql, "sql"));
            }, () => sessionService.IsNonEmpty);

            PreviewCurrentCommand = preview;

            sessionService.ToObservable(o => o.IsNonEmpty)
            .SubscribeAction(_ =>
            {
                preview.RaiseCanExecuteChanged();
                forget.RaiseCanExecuteChanged();
                save.RaiseCanExecuteChanged();
            });

            History.ToObservable(h => h.IsSaved)
            .SubscribeAction(_ =>
            {
                PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(IsModified)));
            });
        }
Example #18
0
        public CommandControl(IDbgConsole console, IHistoryManager historyManager, string content)
        {
            _console        = console;
            _historyManager = historyManager;

            InitializeComponent();

            AppendDmlOutput(content);
        }
Example #19
0
        static void ForwardFillTicks(IHistoryManager cache, string symbol, bool includeLevel2, DateTime startTime, DateTime endTime, ICollection <TickValue> ticks)
        {
            try
            {
                for (var current = startTime; current <= endTime;)
                {
                    var report = cache.QueryTickHistory(current, -RequestedTicksNumber, symbol, includeLevel2);
                    var items  = report.Items;
                    var count  = items.Count - 1;

                    if (items.Count == RequestedTicksNumber)
                    {
                        for (; count > 0; --count)
                        {
                            var first  = items[count - 1];
                            var second = items[count];
                            if (first.Time != second.Time)
                            {
                                current = first.Time;
                                break;
                            }
                        }

                        if (count == 0)
                        {
                            var time    = items[0].Time;
                            var message = string.Format("Internal error: cache contains more than {0} ticks for the same time = {1}; symbol = {2}.", RequestedTicksNumber, time, symbol);
                            throw new Exception(message);
                        }
                    }
                    else
                    {
                        current = DateTime.MaxValue;
                        ++count;
                    }

                    for (var index = 0; index < count; ++index)
                    {
                        var value = items[index];
                        if (value.Time > endTime)
                        {
                            return;
                        }
                        ticks.Add(value);
                    }

                    if (current < DateTime.MaxValue)
                    {
                        current = current.AddMilliseconds(1);
                    }
                }
            }
            catch (StorageHistoryNotFoundException)
            {
            }
        }
Example #20
0
        static void ForwardFillTicks(IHistoryManager cache, string symbol, bool includeLevel2, DateTime startTime, DateTime endTime, ICollection<TickValue> ticks)
        {
            try
            {
                for (var current = startTime; current <= endTime; )
                {
                    var report = cache.QueryTickHistory(current, -RequestedTicksNumber, symbol, includeLevel2);
                    var items = report.Items;
                    var count = items.Count - 1;

                    if (items.Count == RequestedTicksNumber)
                    {
                        for (; count > 0; --count)
                        {
                            var first = items[count - 1];
                            var second = items[count];
                            if (first.Time != second.Time)
                            {
                                current = first.Time;
                                break;
                            }
                        }

                        if (count == 0)
                        {
                            var time = items[0].Time;
                            var message = string.Format("Internal error: cache contains more than {0} ticks for the same time = {1}; symbol = {2}.", RequestedTicksNumber, time, symbol);
                            throw new Exception(message);
                        }
                    }
                    else
                    {
                        current = DateTime.MaxValue;
                        ++count;
                    }

                    for (var index = 0; index < count; ++index)
                    {
                        var value = items[index];
                        if (value.Time > endTime)
                        {
                            return;
                        }
                        ticks.Add(value);
                    }

                    if (current < DateTime.MaxValue)
                    {
                        current = current.AddMilliseconds(1);
                    }
                }
            }
            catch (StorageHistoryNotFoundException)
            {
            }
        }
        protected ViewModelBase(IHistoryManager history,
                                DatabaseTableSolutionItem solutionItem,
                                ISolutionItemNameRegistry solutionItemName,
                                ISolutionManager solutionManager,
                                ISolutionTasksService solutionTasksService,
                                IEventAggregator eventAggregator,
                                IQueryGenerator queryGenerator,
                                IDatabaseTableDataProvider databaseTableDataProvider,
                                IMessageBoxService messageBoxService,
                                ITaskRunner taskRunner,
                                IParameterFactory parameterFactory,
                                ITableDefinitionProvider tableDefinitionProvider,
                                IItemFromListProvider itemFromListProvider,
                                ISolutionItemIconRegistry iconRegistry,
                                ISessionService sessionService,
                                IDatabaseTableCommandService commandService,
                                IParameterPickerService parameterPickerService,
                                IStatusBar statusBar,
                                IMySqlExecutor mySqlExecutor)
        {
            this.solutionItemName          = solutionItemName;
            this.solutionManager           = solutionManager;
            this.solutionTasksService      = solutionTasksService;
            this.queryGenerator            = queryGenerator;
            this.databaseTableDataProvider = databaseTableDataProvider;
            this.messageBoxService         = messageBoxService;
            this.taskRunner              = taskRunner;
            this.parameterFactory        = parameterFactory;
            this.tableDefinitionProvider = tableDefinitionProvider;
            this.itemFromListProvider    = itemFromListProvider;
            this.sessionService          = sessionService;
            this.commandService          = commandService;
            this.parameterPickerService  = parameterPickerService;
            this.statusBar     = statusBar;
            this.mySqlExecutor = mySqlExecutor;
            this.solutionItem  = solutionItem;
            History            = history;

            undoCommand            = new DelegateCommand(History.Undo, CanUndo);
            redoCommand            = new DelegateCommand(History.Redo, CanRedo);
            Save                   = new AsyncAutoCommand(SaveSolutionItem);
            title                  = solutionItemName.GetName(solutionItem);
            Icon                   = iconRegistry.GetIcon(solutionItem);
            nameGeneratorParameter = parameterFactory.Factory("Parameter");

            History.PropertyChanged += (_, _) =>
            {
                undoCommand.RaiseCanExecuteChanged();
                redoCommand.RaiseCanExecuteChanged();
                RaisePropertyChanged(nameof(IsModified));
            };

            tableDefinition = tableDefinitionProvider.GetDefinition(solutionItem.DefinitionId) !;
            LoadAndCreateCommands();
            nameGeneratorParameter = parameterFactory.Factory(tableDefinition.Picker);
        }
Example #22
0
        public void Dispose()
        {
            var provider = this.Provider;

            this.Provider = null;
            if (provider != null)
            {
                provider.Dispose();
            }
        }
Example #23
0
        public FormMain()
        {
            InitializeComponent();
            _screenBinder   = new ScreenBinder <Parameter>();
            _historyManager = IoC.Resolve <IHistoryManager>();

            InitializeBinding();
            _parameter = new Parameter();
            _screenBinder.BindToSource(_parameter);
        }
Example #24
0
 protected override void Context()
 {
     _projectRetriever          = A.Fake <IProjectRetriever>();
     _historyManagerRetriever   = A.Fake <IHistoryManagerRetriever>();
     _dialogCreator             = A.Fake <IDialogCreator>();
     _commandExecuter           = A.Fake <SQLiteProjectCommandExecuter>();
     _eventPublisher            = A.Fake <IEventPublisher>();
     _historyManager            = A.Fake <IHistoryManager>();
     _commandMetaDataRepository = A.Fake <ICommandMetaDataRepository>();
     sut = new HistoryTask(_projectRetriever, _historyManagerRetriever, _dialogCreator, _commandExecuter, _eventPublisher, _commandMetaDataRepository);
 }
		public FolderReactionMonitorModel(DirectoryInfo saveFolder, IHistoryManager historyManager)
		{
			HistoryManager = historyManager;
			_RunningReactions = new Dictionary<Guid, ReactionMonitor>();

			ReactionSaveFolder = saveFolder;

			DefaultInterval = TimeSpan.FromMinutes(15);

			InitializeReactions();
		}
Example #26
0
        public CommandWindow(IDbgConsole console, IHistoryManager historyManager, string content)
        {
            _console        = console;
            _historyManager = historyManager;

            InitializeComponent();

            SetTabTitle(this, new ToolWindowTitle("Window " + Interlocked.Increment(ref _index)));

            AppendDmlOutput(content);
        }
Example #27
0
 public HistoryController(
     IHistoryManager historyTestManager,
     IReportElementManager reportElementManager,
     IMapper mapper,
     UserManager <AppUser> userManager)
 {
     _historyManager       = historyTestManager;
     _reportElementManager = reportElementManager;
     _mapper      = mapper;
     _userManager = userManager;
 }
Example #28
0
 public GameService(ICardManager cardManager, IHistoryManager historyManager,
                    IPlayerManager playerManager, IGameSessionManager sessionManager,
                    IGameManager gameManager, IGameViewManager gameViewManager)
 {
     _cardManager     = cardManager;
     _historyManager  = historyManager;
     _playerManager   = playerManager;
     _sessionManager  = sessionManager;
     _gameManager     = gameManager;
     _gameViewManager = gameViewManager;
 }
Example #29
0
 public static Description dispatch(Description d, IHistoryManager h)
 {
     if (d is ListDescription)
     {
         return(new ListDescriptionForm(d as ListDescription).edit(h));
     }
     if (d is TableDescription)
     {
         return(new TableDescriptionForm(d as TableDescription).edit(h));
     }
     return(new DescriptionForm(d).edit(h));
 }
		public InstantActionPageViewModel(PageManager pageManager, IEventAggregator ea, IAppPolicyManager appPolicyManager, IInstantActionManager instantActionManager, IFolderReactionMonitorModel monitor, IHistoryManager historyManager)
			: base(pageManager)
		{
			_EventAggregator = ea;
			AppPolicyManger = appPolicyManager;
			InstantActionManager = instantActionManager;
			Monitor = monitor;
			HistoryManager = historyManager;

			InstantActionVM = new ReactiveProperty<InstantActionStepViewModel>();
				
		}
Example #31
0
 protected override void Context()
 {
     _eventPublisher        = A.Fake <IEventPublisher>();
     _mruProvider           = A.Fake <IMRUProvider>();
     _workspacePersistor    = A.Fake <IWorkspacePersistor>();
     _registrationTask      = A.Fake <IRegistrationTask>();
     _historyManagerFactory = A.Fake <IHistoryManagerFactory>();
     _historyManager        = A.Fake <IHistoryManager>();
     _fileLocker            = A.Fake <IFileLocker>();
     _journalSession        = A.Fake <IJournalSession>();
     A.CallTo(() => _historyManagerFactory.Create()).Returns(_historyManager);
     sut = new Workspace(_eventPublisher, _journalSession, _fileLocker, _registrationTask, _workspacePersistor, _mruProvider, _historyManagerFactory);
 }
        public static ICommand UndoCommand(this IHistoryManager historyManager)
        {
            var cmd = new DelegateCommand(historyManager.Undo, () => historyManager.CanUndo);

            historyManager.PropertyChanged += (sender, args) =>
            {
                if (args.PropertyName == nameof(historyManager.CanUndo))
                {
                    cmd.RaiseCanExecuteChanged();
                }
            };
            return(cmd);
        }
        public HistoryWindowViewModel(IHistoryManager historyManager)
        {
            _historyManager = historyManager;

            FileActions        = new ObservableCollection <HistoryElementViewModel>();
            _bindingLockObject = new object();
            BindingOperations.EnableCollectionSynchronization(FileActions, _bindingLockObject);

            foreach (var historyObjectModel in _historyManager.HistoryObjectModels)
            {
                FileActions.Add(new HistoryElementViewModel(historyObjectModel));
            }

            _historyManager.ObjectAddedEvent += HistoryManagerOnObjectAddedEvent;
        }
        /// <summary>
        ///    Create a DataTable containing all visible commands defined in the history
        /// </summary>
        public static DataTable ToDataTable(this IHistoryManager historyManager)
        {
            var dataTable           = new DataTable();
            var commandExpander     = new CommandsExpander();
            int nextAvailableColumn = ReportColumn.LastColumnIndex + 1;

            //cache containg the column index of a dynamic property . The key is the name of the property
            var dynamicColumnMap = new Cache <string, int>();

            dataTable.Columns.Add("State", typeof(string));
            dataTable.Columns.Add("User", typeof(string));
            dataTable.Columns.Add("Time", typeof(string));
            dataTable.Columns.Add("Command Type", typeof(string));
            dataTable.Columns.Add("Object Type", typeof(string));
            dataTable.Columns.Add("Description", typeof(string));
            dataTable.Columns.Add("Extended Description", typeof(string));
            dataTable.Columns.Add("Comment", typeof(string));

            foreach (var history in historyManager.History)
            {
                var allCommands = commandExpander.ExpandsAndKeep(history.Command).Where(c => c.Visible);
                foreach (var command in allCommands)
                {
                    var row = dataTable.NewRow();
                    row[ReportColumn.State]               = history.State;
                    row[ReportColumn.User]                = history.User;
                    row[ReportColumn.Time]                = history.DateTime.ToString(CultureInfo.InvariantCulture);
                    row[ReportColumn.CommandType]         = command.CommandType;
                    row[ReportColumn.ObjectType]          = command.ObjectType;
                    row[ReportColumn.Description]         = command.Description;
                    row[ReportColumn.ExtendedDescription] = command.ExtendedDescription;
                    row[ReportColumn.Comment]             = command.Comment;

                    foreach (var extendedProperty in command.AllExtendedProperties)
                    {
                        if (!dynamicColumnMap.Contains(extendedProperty))
                        {
                            dynamicColumnMap.Add(extendedProperty, nextAvailableColumn++);
                            dataTable.Columns.Add(extendedProperty, typeof(string));
                        }
                        row[dynamicColumnMap[extendedProperty]] = command.ExtendedPropertyValueFor(extendedProperty);
                    }
                    dataTable.Rows.Add(row);
                }
            }

            return(dataTable);
        }
        public SmartScriptEditorViewModel(SmartScriptSolutionItem item, IHistoryManager history, IDatabaseProvider database, IEventAggregator eventAggregator, ISmartDataManager smartDataManager, ISmartFactory smartFactory, IItemFromListProvider itemFromListProvider, ISmartTypeListProvider smartTypeListProvider, ISolutionItemNameRegistry itemNameRegistry)
        {
            _item                      = item;
            _history                   = history;
            this.database              = database;
            this.smartDataManager      = smartDataManager;
            this.smartFactory          = smartFactory;
            this.itemFromListProvider  = itemFromListProvider;
            this.smartTypeListProvider = smartTypeListProvider;
            this.itemNameRegistry      = itemNameRegistry;
            var lines = database.GetScriptFor(_item.Entry, _item.SmartType);

            script = new SmartScript(_item, smartFactory);
            script.Load(lines);

            EditEvent  = new DelegateCommand(EditEventCommand);
            EditAction = new DelegateCommand <SmartAction>(EditActionCommand);
            AddEvent   = new DelegateCommand(AddEventCommand);
            AddAction  = new DelegateCommand <SmartEvent>(AddActionCommand);

            SaveCommand = new DelegateCommand(SaveAllToDb);

            DeleteAction = new DelegateCommand <SmartAction>(DeleteActionCommand);
            DeleteEvent  = new DelegateCommand(DeleteEventCommand);

            _history.AddHandler(new SaiHistoryHandler(script));

            UndoCommand = new DelegateCommand(history.Undo, () => history.CanUndo);
            RedoCommand = new DelegateCommand(history.Redo, () => history.CanRedo);

            _history.PropertyChanged += (sender, args) =>
            {
                UndoCommand.RaiseCanExecuteChanged();
                RedoCommand.RaiseCanExecuteChanged();
            };

            eventAggregator.GetEvent <EventRequestGenerateSql>().Subscribe((args) =>
            {
                if (args.Item is SmartScriptSolutionItem)
                {
                    var itemm = args.Item as SmartScriptSolutionItem;
                    if (itemm.Entry == _item.Entry && itemm.SmartType == _item.SmartType)
                    {
                        args.Sql = new SmartScriptExporter(script, smartFactory).GetSql();
                    }
                }
            });
        }
		public ReactionEditPageViewModel(PageManager pageManager, IFolderReactionMonitorModel monitor, IAppPolicyManager appPolicyManager, IHistoryManager historyManager)
			: base(pageManager)
		{
			Monitor = monitor;
			_AppPolicyManager = appPolicyManager;
			HistoryManager = historyManager;

			_CompositeDisposable = new CompositeDisposable();

			ReactionVM = new ReactiveProperty<ReactionViewModel>()
				.AddTo(_CompositeDisposable);

			SaveCommand = new ReactiveCommand();

			SaveCommand.Subscribe(_ => Save())
				.AddTo(_CompositeDisposable);

		}
		public HistoryPageViewModel(IHistoryManager histroyManager, PageManager pageManager, IFolderReactionMonitorModel monitor, IInstantActionManager instantActionManager)
			: base(pageManager)
		{
			HistoryManager = histroyManager;
			Monitor = monitor;
			InstantActionManager = instantActionManager;

			ShowHistoryVMs = new ObservableCollection<HistoryDataViewModel>();

			HistoryFileInfoList = new List<FileInfo>();

			CanIncrementalLoad = ShowHistoryVMs.CollectionChangedAsObservable()
				.Select(_ => HistoryFileInfoList.Count > ShowHistoryVMs.Count)
				.ToReactiveProperty();

			IncrementalLoadHistoryCommand = CanIncrementalLoad
				.ToReactiveCommand();

			IncrementalLoadHistoryCommand.Subscribe(_ => IncrementalLoadHistoryItems());
		}
		public FolderReactionManagePageViewModel(PageManager pageManager, IFolderReactionMonitorModel monitor, IEventAggregator ea, IAppPolicyManager appPolicyManager, IHistoryManager historyManager, IReactiveFolderSettings settings)
			: base(pageManager)
		{
			Monitor = monitor;
			_EventAggregator = ea;
			AppPolicyManager = appPolicyManager;
			HistoryManager = historyManager;
			Settings = settings;



			CurrentFolder = new ReactiveProperty<ReactionManageFolderViewModel>();
			FolderStack = new ObservableCollection<ReactionManageFolderViewModel>();

			FolderStack.CollectionChangedAsObservable()
				.Subscribe(x => 
				{
					CurrentFolder.Value = FolderStack.Last();
				});

			FolderStack.Add(new ReactionManageFolderViewModel(this, Monitor.RootFolder));
		}
		static FolderReactionMonitorModel InitializeMonitorModel(string monitorSaveFolderPath, IHistoryManager historyManager)
		{
			return new FolderReactionMonitorModel(new DirectoryInfo(monitorSaveFolderPath), historyManager);
		}
Example #40
0
        public HistoryBar GetHistory(string symbol, DateTime dateTime)
        {
            HistoryBar historyBar = new HistoryBar();

            if (!IsConnected)
            {
                if (!Connect())
                {
                    return historyBar;
                }
            }

            if (string.IsNullOrEmpty(StorageFolderName))
            {
                return historyBar;
            }

            List<string> symbolNames = GetSymbols();
            if (symbolNames == null || symbolNames.Count == 0)
            {
                _logger.Debug("QuotesHistoryConnector.GetHistory(): Failed to get symbols.");
                return historyBar;
            }

            try
            {
                if (_historyStore == null)
                {
                    string assemblyFileName = GetType().Assembly.Location;
                    FileInfo fileInfo = new FileInfo(assemblyFileName);

                    int historySourceVersion = _historySource.GetHistoryVersion();
                    _historyStore = new NtfsHistoryStore(Path.Combine(fileInfo.DirectoryName, "DCQuotesStorage", StorageFolderName + "_v" + historySourceVersion), new NullMonitoringService());
                    StoreStatus storeStatus = _historyStore.OpenOrCreate(historySourceVersion, false);

                    if (storeStatus != StoreStatus.Ok)
                    {
                        _logger.Debug("QuotesHistoryConnector.GetHistory(): Failed to open or create quotes storage. Store status: {0}", storeStatus);
                        return historyBar;
                    }
                }

                if (_historyManager == null)
                {
                    Dictionary<Periodicity, TimeInterval> periodicityMap = new Dictionary<Periodicity, TimeInterval>();
                    periodicityMap.Add(new Periodicity(TimeInterval.Second), TimeInterval.Hour);
                    periodicityMap.Add(new Periodicity(TimeInterval.Second, 10), TimeInterval.Day);
                    periodicityMap.Add(new Periodicity(TimeInterval.Minute), TimeInterval.Day);
                    periodicityMap.Add(new Periodicity(TimeInterval.Minute, 5), TimeInterval.Day);
                    periodicityMap.Add(new Periodicity(TimeInterval.Minute, 15), TimeInterval.Day);
                    periodicityMap.Add(new Periodicity(TimeInterval.Minute, 30), TimeInterval.Day);
                    periodicityMap.Add(new Periodicity(TimeInterval.Hour), TimeInterval.Month);
                    periodicityMap.Add(new Periodicity(TimeInterval.Hour, 4), TimeInterval.Month);
                    periodicityMap.Add(new Periodicity(TimeInterval.Day), TimeInterval.Year);
                    periodicityMap.Add(new Periodicity(TimeInterval.Week), TimeInterval.Year);
                    periodicityMap.Add(new Periodicity(TimeInterval.Month), TimeInterval.Year);

                    _historyManager = HistoryManager.Create(_historyStore, new SortedSet<string>(symbolNames),
                        periodicityMap, true,
                        Cache.ClientInstance("CacheInstance"), true, true, new NullMonitoringService(), null);
                }

                if (!_historyManager.BarsAreSynchronized(_historySource, symbol, new Periodicity(TimeInterval.Minute),
                        TickTrader.Common.Business.FxPriceType.Bid,
                        new DateTime(dateTime.Year, dateTime.Month, dateTime.Day, dateTime.Hour, 0, 0),
                        new DateTime(dateTime.Year, dateTime.Month, dateTime.Day, dateTime.Hour + 1, 0, 0), true))
                {
                    _historyManager.SynchronizeBars(_historySource, symbol, new Periodicity(TimeInterval.Minute),
                        TickTrader.Common.Business.FxPriceType.Bid,
                        new DateTime(dateTime.Year, dateTime.Month, dateTime.Day, dateTime.Hour, 0, 0),
                        new DateTime(dateTime.Year, dateTime.Month, dateTime.Day, dateTime.Hour + 1, 0, 0), true,
                        delegate (int completed, int total, DateTime start, TimeSpan length) { });
                }

                MarketHistoryItemsReport<HistoryBar> report = _historyManager.QueryBarHistory(dateTime, 1, symbol,
                    new Periodicity(TimeInterval.Minute).ToString(), TickTrader.Common.Business.FxPriceType.Bid);

                if (report.Items.Count > 0)
                {
                    historyBar = report.Items[0];
                }
                else
                {
                    _logger.Debug("QuotesHistoryConnector.GetHistory(): Failed to query bar history (empry collection returned).");
                }
            }
            catch (Exception ex)
            {
                _logger.Debug(ex, "QuotesHistoryConnector.GetHistory(): Failed to query bar history (exception): {0}", ex.Message);
            }

            return historyBar;
        }
Example #41
0
        public void Disconnect()
        {
            if (_historyManager != null)
            {
                _historyManager.Flush();
                _historyManager.Dispose();
                _historyManager = null;
            }

            if (_historyStore != null)
            {
                _historyStore.Dispose();
                _historyStore = null;
            }

            if (_historyServiceClient != null)
			{
				_historyServiceClient = new HistoryServiceClient(Address);
            }

            if (_historySource == null)
			{
				_historySource = _historyServiceClient.ChannelFactory.CreateChannel();
            }
        }
		public ReactionMonitor(FolderReactionModel reaction, IFolderReactionMonitorModel monitor, IHistoryManager history)
		{
			Reaction = reaction;
			Monitor = monitor;
			HistoryManager = history;

			NowProcessing = false;
			IsTerminated = false;

			Start();
		}
Example #43
0
 static void BackwardFillBars(IHistoryManager cache, string symbol, Periodicity periodicity, FxPriceType priceType, DateTime startTime, DateTime endTime, List<HistoryBar> bars)
 {
     ForwardFillBars(cache, symbol, periodicity, priceType, endTime, startTime, bars);
     bars.Reverse();
 }
Example #44
0
		public HistoryManagerAdapter(IHistoryManager provider)
		{
            this.converter = new StorageConvert();
			this.Provider = provider;
		}
Example #45
0
 static void BackwardFillTicks(IHistoryManager cache, string symbol, bool includeLevel2, DateTime startTime, DateTime endTime, List<TickValue> ticks)
 {
     ForwardFillTicks(cache, symbol, includeLevel2, endTime, startTime, ticks);
     ticks.Reverse();
 }
Example #46
0
        static void ForwardFillBars(IHistoryManager cache, string symbol, Periodicity periodicity, FxPriceType priceType, DateTime startTime, DateTime endTime, ICollection<HistoryBar> bars)
        {
            try
            {
                for (var current = startTime; current < endTime; )
                {
                    var report = cache.QueryBarHistory(current, -RequestedBarsNumber, symbol, periodicity.ToString(), priceType);
                    var items = report.Items;

                    foreach (var element in report.Items)
                    {
                        if (element.Time >= endTime)
                        {
                            return;
                        }
                        bars.Add(element);
                    }
                    if (items.Count == 0)
                    {
                        return;
                    }
                    current = items.Last().Time;
                    current = current + periodicity;
                }
            }
            catch (StorageHistoryNotFoundException)
            {
            }
        }