private void ShowDebug(SourceLocation srcLoc)
 {
     DispatcherService.Dispatch(() =>
     {
         this.workflowDesigner.DebugManagerView.CurrentLocation = srcLoc;
     });
 }
        public void DispatcherServiceTest() {
#endif
            TestVM vm = new TestVM();
            UserControl control = new UserControl() { DataContext = vm };
            DispatcherService service = new DispatcherService();
            Interactivity.Interaction.GetBehaviors(control).Add(service);
            Window.Content = control;
#if NETFX_CORE
            await EnqueueShowWindow();
#else
            EnqueueShowWindow();
#endif
            EnqueueCallback(() => {
                Assert.IsFalse(vm.IsProgress);
                vm.Calculate();
                Assert.IsTrue(vm.IsProgress);
            });
#if NETFX_CORE
            await WaitConditional(() => vm.Task.IsCompleted);
#else
            EnqueueWait(() => vm.Task.IsCompleted);
#endif
            EnqueueWindowUpdateLayout();
            EnqueueCallback(() => {
#if !NETFX_CORE
                DispatcherHelper.DoEvents();
#endif
                Assert.IsFalse(vm.IsProgress);
                Assert.IsTrue(vm.IsCompleted);
            });
            EnqueueTestComplete();
        }
        public async Task AssignToDispatcher(int orderId, int dispatcherId)
        {
            var order = await OrderService.Get(orderId);

            if (order == null)
            {
                throw new EntityNotFoundException($"OrderId:{orderId} not found", "Order");
            }

            if (!await DispatcherService.IsExist(dispatcherId))
            {
                throw new EntityNotFoundException($"DispatcherId:{dispatcherId} not found", "Dispatcher");
            }

            var currentState = await GetCurrentState(orderId);

            if ((currentState.Status != OrderStatus.Accepted) && (currentState.Status != OrderStatus.SentToTrading))
            {
                throw new OrderStatusException("Only accepted or traded orders can be assigned to dispatcher");
            }

            await SetCurrentStatus(orderId, OrderStatus.AssignedDispatcher);

            await OrderService.AssignDispatcher(orderId, dispatcherId);
        }
Exemplo n.º 4
0
 public void Calculate()
 {
     IsProgress = true;
     Task       = Task.Factory.StartNew(CalcCore).ContinueWith(x => {
         DispatcherService.BeginInvoke(new Action(() => IsProgress = false));
     });
 }
        public async void Execute_OnSearchClick()
        {
            if (Searching)
            {
                return;
            }

            Searching = true;
            DispatcherService.InvokeIfRequired(() => _tweets.Clear());
            if (_tweetSearchService != null && !string.IsNullOrEmpty(SearchString))
            {
                await _tweetSearchService.GetMeSomeTweets <LinqTweet>(newTweets =>
                {
                    if (newTweets != null)
                    {
                        DispatcherService.InvokeIfRequired(() => _tweets.AddRange(newTweets));
                    }
                    Searching = false;
                    if (OnSearchComplete != null)
                    {
                        OnSearchComplete();
                    }
                }, SearchString);
            }
        }
Exemplo n.º 6
0
        void InitBindings()
        {
            mvvmContext1.RegisterService(DialogService.CreateXtraDialogService(this, "Details"));
            mvvmContext1.RegisterService(DispatcherService.Create());

            var mvvm = mvvmContext1.OfType <TrackListViewModel>();

            mvvm.SetBinding(gridView1, x => x.LoadingPanelVisible, x => x.IsLoading);

            mvvm.WithEvent <EventArgs>(this, "Load").EventToCommand(x => x.LoadTracks());

            mvvm.WithEvent <ColumnView, FocusedRowObjectChangedEventArgs>(gridView1, "FocusedRowObjectChanged")
            .SetBinding(x => x.CurrentItem,
                        args => args.Row as TrackViewModel,
                        (gView, track) => gView.FocusedRowHandle = gView.FindRow(track));

            mvvm.WithEvent <RowClickEventArgs>(gridView1, "RowClick")
            .EventToCommand(
                x => x.EditItem(null), x => x.CurrentItem,
                args => (args.Clicks == 2) && (args.Button == MouseButtons.Left));

            mvvmContext1.RegisterService(new CustomReportService(gridView1));
            mvvm.BindCommand(barButtonItem1, x => x.ShowReport());



            mvvm.SetBinding(repositoryItemLookUpEditAlbum, e => e.DataSource, x => x.CurrentItem.AlbumLookupData);
        }
Exemplo n.º 7
0
        public WorkflowViewModel(bool disableDebugViewOutput)
        {
            this.workflowDesigner = new WorkflowDesigner();
            this.id = ++designerCount;
            this.validationErrors       = new List <ValidationErrorInfo>();
            this.validationErrorService = new ValidationErrorService(this.validationErrors);
            this.workflowDesigner.Context.Services.Publish <IValidationErrorService>(this.validationErrorService);

            this.workflowDesigner.ModelChanged += delegate(object sender, EventArgs args)
            {
                this.modelChanged = true;
                this.OnPropertyChanged("DisplayNameWithModifiedIndicator");
            };

            this.validationErrorsView = new ValidationErrorsUserControl();

            this.outputTextBox          = new TextBox();
            this.output                 = new TextBoxStreamWriter(this.outputTextBox, this.DisplayName);
            this.disableDebugViewOutput = disableDebugViewOutput;

            this.workflowDesigner.Context.Services.GetService <DesignerConfigurationService>().TargetFrameworkName = new System.Runtime.Versioning.FrameworkName(".NETFramework", new Version(4, 5));
            this.workflowDesigner.Context.Services.GetService <DesignerConfigurationService>().LoadingFromUntrustedSourceEnabled = bool.Parse(ConfigurationManager.AppSettings["LoadingFromUntrustedSourceEnabled"]);

            this.validationErrorService.ErrorsChangedEvent += delegate(object sender, EventArgs args)
            {
                DispatcherService.Dispatch(() =>
                {
                    this.validationErrorsView.ErrorsDataGrid.ItemsSource = this.validationErrors;
                    this.validationErrorsView.ErrorsDataGrid.Items.Refresh();
                });
            };
        }
Exemplo n.º 8
0
        public async Task Dispatch_Command_ReplyReturned()
        {
            var serverCallContext = TestServerCallContextFactory.Create();

            serverCallContext.UserState["__HttpContext"] = httpContextFactory();
            var dispatcher = new DispatcherService();

            var cmd = new TestCommand
            {
                Value = Guid.NewGuid().ToString()
            };

            var request = new RequestEnvelope()
            {
                Type = cmd.GetType().AssemblyQualifiedName,
                Data = UnsafeByteOperations.UnsafeWrap(JsonSerializer.SerializeToUtf8Bytes(cmd))
            };

            var response = await dispatcher.Dispatch(request, serverCallContext);

            response.ShouldNotBeNull().Data.ShouldNotBeNull().ShouldNotBeEmpty();
            var responseType = System.Type.GetType(response.Type, an => Assembly.Load(an.Name ?? null !), null, true, true).ShouldNotBeNull();

            using var ms = new MemoryStream(response.Data.ToByteArray());
            JsonSerializer.Deserialize(ms, responseType).ShouldBeOfType <string>().ShouldBe(cmd.Value);
        }
        public async Task AssignToDriver(int orderId, int dispatcherId, int driverId)
        {
            var order = await OrderService.Get(orderId);

            if (order == null)
            {
                throw new EntityNotFoundException($"OrderId:{orderId} not found", "Order");
            }

            if (!await DispatcherService.IsExist(dispatcherId))
            {
                throw new EntityNotFoundException($"DispatcherId:{dispatcherId} not found", "Dispatcher");
            }

            if (order.DispatcherId != dispatcherId)
            {
                throw new AccessViolationException("Only a order dispatcher can assign a order to driver");
            }

            if (!await DriverService.IsExist(driverId))
            {
                throw new EntityNotFoundException($"DriverId:{driverId} not found", "Driver");
            }

            if ((await GetCurrentState(orderId)).Status != OrderStatus.AssignedDispatcher)
            {
                throw new OrderStatusException("Only assigned to dispatcher orders can be assigned to driver");
            }

            await SetCurrentStatus(orderId, OrderStatus.AssignedDriver);

            await OrderService.AssignDriver(orderId, driverId);
        }
Exemplo n.º 10
0
        public async Task Dispatch_Command_ReplyReturned()
        {
            var serverCallContext = TestServerCallContextFactory.Create();

            serverCallContext.UserState["__HttpContext"] = httpContextFactory();
            var dispatcher = new DispatcherService();

            var cmd = new TestCommand
            {
                Value = Guid.NewGuid().ToString()
            };

            var request = new RequestEnvelope()
            {
                Type    = cmd.GetType().AssemblyQualifiedName,
                Content = Value.Parser.ParseJson(JsonSerializer.Serialize(cmd))
            };

            var response = await dispatcher.Dispatch(request, serverCallContext);

            response.ShouldNotBeNull().Content.ShouldNotBeNull();
            var responseType = System.Type.GetType(response.Type, an => Assembly.Load(an.Name ?? null !), null, true, true).ShouldNotBeNull();

            JsonSerializer.Deserialize(JsonFormatter.Default.Format(response.Content), responseType).ShouldBeOfType <string>().ShouldBe(cmd.Value);
        }
Exemplo n.º 11
0
        public void DispatcherServiceTest()
        {
            TestVM      vm      = new TestVM();
            UserControl control = new UserControl()
            {
                DataContext = vm
            };
            DispatcherService service = new DispatcherService();

            Interactivity.Interaction.GetBehaviors(control).Add(service);
            Window.Content = control;
            EnqueueShowWindow();
            EnqueueCallback(() => {
                Assert.IsFalse(vm.IsProgress);
                vm.Calculate();
                Assert.IsTrue(vm.IsProgress);
            });
            EnqueueWait(() => vm.Task.IsCompleted);
            EnqueueWindowUpdateLayout();
            EnqueueCallback(() => {
                DispatcherHelper.DoEvents();
                Assert.IsFalse(vm.IsProgress);
                Assert.IsTrue(vm.IsCompleted);
            });
            EnqueueTestComplete();
        }
Exemplo n.º 12
0
        public void UpdateCPS()
        {
            //DispatcherService.BeginInvoke(() =>
            //{
            //    //UpdataCP(CPS.First());
            //    UpdataCP(CP);
            //});

            //CP = new ControlParameter();
            //UpdataCP(CP);
            DI.Param1 = new Random(Guid.NewGuid().GetHashCode()).Next(0, 100).ToString();
            DI.Param2 = new Random(Guid.NewGuid().GetHashCode()).Next(0, 100).ToString();
            DI.Param3 = new Random(Guid.NewGuid().GetHashCode()).Next(0, 100).ToString();
            DispatcherService.BeginInvoke(() =>
            {
                CP.Param1 = 100;
                CP.Param2 = 76;
                CP.Param3 = 60;
                CP.Param4 = 23;

                DI.Param1 = new Random(Guid.NewGuid().GetHashCode()).Next(0, 100).ToString();
                DI.Param2 = new Random(Guid.NewGuid().GetHashCode()).Next(0, 100).ToString();
                DI.Param3 = new Random(Guid.NewGuid().GetHashCode()).Next(0, 100).ToString();
            });
        }
Exemplo n.º 13
0
 // 프로그레스 바 리셋
 private void resetProgressBar()
 {
     DispatcherService.Invoke((System.Action)(() =>
     {
         runButton.Background = Brushes.LightGray;
         runButton.Foreground = Brushes.Black;
     }));
 }
Exemplo n.º 14
0
        public void Invoke_Test00()
        {
            var  service = new DispatcherService();
            bool val1    = false;

            service.Invoke(() => val1 = true);
            Assert.IsTrue(val1);
        }
Exemplo n.º 15
0
 private void Timer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
 {
     DispatcherService.BeginInvoke(() =>
     {
         this.MachineTime = this.watch.Elapsed;
         this.RaisePropertiesChanged();
     });
 }
        public DispatcherServiceTestSuite()
        {
            DispatcherRepositoryMock = new Mock <IDispatcherRepository>();
            CompanyServiceMock       = new Mock <ICompanyService>();
            IdentityUserServiceMock  = new Mock <IIdentityUserService>();

            DispatcherService = new DispatcherService(DispatcherRepositoryMock.Object, IdentityUserServiceMock.Object, CompanyServiceMock.Object);
        }
Exemplo n.º 17
0
        public async Task <ActionResult> PostMessage(
            [FromForm] MessageModel message,
            [FromServices] DispatcherService dispatcherService)
        {
            await dispatcherService.SendMessage(message);

            return(Accepted());
        }
        internal void Initialize(NugetStore store, string defaultLogText = null)
        {
            var dispatcherService = new DispatcherService(Dispatcher);
            var dialogService     = new DialogService(dispatcherService, Launcher.ApplicationName);
            var serviceProvider   = new ViewModelServiceProvider(new object[] { dispatcherService, dialogService });

            DataContext = new LauncherViewModel(serviceProvider, store);
        }
 private void InitFinishCollection()
 {
     DispatcherService.ExecuteTimerAction(() => {
         BackgroundService.Execute(() => {
             LoaderCompletion.FinishCollectionLoadProcess(PlayListCollection, null);
         }, "Getting playlist metadata...", () => { });
     }, 5000);
 }
Exemplo n.º 20
0
 public ViewService(Window window)
 {
     Window             = window;
     DispatcherService  = new DispatcherService(window.Dispatcher);
     DisplayInformation = Windows.Graphics.Display.DisplayInformation.GetForCurrentView();
     ApplicationView    = Windows.UI.ViewManagement.ApplicationView.GetForCurrentView();
     UIViewSettings     = Windows.UI.ViewManagement.UIViewSettings.GetForCurrentView();
     ActiveWindows.Add(this);
 }
Exemplo n.º 21
0
        public ScriptNameWindow(string defaultClassName, string defaultNamespace)
        {
            var dispatcher = new DispatcherService(Dispatcher);

            services = new ViewModelServiceProvider(new object[] { dispatcher, new DialogService(dispatcher, EditorViewModel.Instance.EditorName) });
            InitializeComponent();
            ClassNameTextBox.Text = defaultClassName;
            NamespaceTextBox.Text = defaultNamespace;
        }
Exemplo n.º 22
0
        public void InvokeAsync_Test02()
        {
            var  service   = new DispatcherService();
            bool isStopped = false;

            service.BeginInvoke(() => { isStopped = true; });
            Assert.IsFalse(isStopped);
            DispatcherHelper.DoEvents();
            Assert.IsTrue(isStopped);
        }
Exemplo n.º 23
0
        public void InvokeAsync_Test03()
        {
            var  service   = new DispatcherService();
            bool isStopped = false;

            Task.Factory.StartNew(() => service.BeginInvoke(() => { isStopped = true; }));
            Assert.IsFalse(isStopped);
            EnqueueWait(() => isStopped);
            Assert.IsTrue(isStopped);
        }
 public override void execute(BRemote __byps__remote, BAsyncResultIF <Object> __byps__asyncResult)
 {
     // checkpoint byps.gen.cs.GenApiClass:406
     try {
         DispatcherService __byps__remoteT = (DispatcherService)__byps__remote;
         BAsyncResultSendMethod <FileSystemNotify> __byps__outerResult = new BAsyncResultSendMethod <FileSystemNotify>(__byps__asyncResult, new BResult_1816639285());
         __byps__remoteT.GetNotifyService(tokenValue, onlyHereValue, BAsyncResultHelper.ToDelegate(__byps__outerResult));
     } catch (Exception e) {
         __byps__asyncResult.setAsyncResult(null, e);
     }
 }
Exemplo n.º 25
0
 public void get4()
 {
     DispatcherService.Invoke((System.Action)(() =>
     {
         D_Data_Main.Clear();
         for (int i = 0; i < D_Data.Count(); i++)
         {
             D_Data_Main.Add(D_Data[i]);
         }
     }));
 }
Exemplo n.º 26
0
        public void InvokeAsync_Test01()
        {
            var service = new DispatcherService();

            service.Delay = TimeSpan.FromMilliseconds(200);
            var sw = System.Diagnostics.Stopwatch.StartNew();

            Task.Factory.StartNew(() => service.BeginInvoke(() => sw.Stop()));
            EnqueueWait(() => !sw.IsRunning);
            Assert.IsTrue(sw.Elapsed.TotalMilliseconds >= 180, sw.ElapsedMilliseconds.ToString());
        }
Exemplo n.º 27
0
 public void get3()
 {
     DispatcherService.Invoke((System.Action)(() =>
     {
         L_Data3_Main.Clear();
         for (int i = 0; i < L_Data3.Count(); i++)
         {
             L_Data3_Main.Add(L_Data3[i]);
         }
     }));
 }
Exemplo n.º 28
0
 private void AutoDispatchIfRequired(Action action)
 {
     if (AutomaticallyDispatchEvents)
     {
         DispatcherService.BeginInvokeIfRequired(action);
     }
     else
     {
         action();
     }
 }
 public override void execute(BRemote __byps__remote, BAsyncResultIF <Object> __byps__asyncResult)
 {
     // checkpoint byps.gen.cs.GenApiClass:406
     try {
         DispatcherService __byps__remoteT = (DispatcherService)__byps__remote;
         BAsyncResultSendMethod <Object> __byps__outerResult = new BAsyncResultSendMethod <Object>(__byps__asyncResult, new BResult_19());
         __byps__remoteT.KeepAlive(tokenValue, BAsyncResultHelper.ToDelegate(__byps__outerResult));
     } catch (Exception e) {
         __byps__asyncResult.setAsyncResult(null, e);
     }
 }
Exemplo n.º 30
0
        private bool ValidateProperties()
        {
            string error;

            if (!Templates.ValidateProperties(out error))
            {
                DialogHelper.BlockingMessageBox(DispatcherService.Create(), error, EditorPath.EditorTitle, MessageBoxButton.OK, MessageBoxImage.Error);
                return(false);
            }
            return(true);
        }
Exemplo n.º 31
0
        /// <summary>
        ///   If this ViewModel's View houses other injectable View's, this method will be useful
        /// </summary>
        /// <param name="type"></param>
        /// <param name="region"></param>
        /// <returns></returns>
        /// <remarks>Only call this for a nested control once the parent has been loaded</remarks>
        protected virtual TView RegisterAndActivateView <TView>(string region = null) where TView : class
        {
            if (!string.IsNullOrWhiteSpace(region))
            {
                Logger.Default.Debug("Activating view {0}", typeof(TView).Name);

                TView view = null;
                DispatcherService.InvokeIfRequired(() => SwitchView(region, out view));
                return(view);
            }
            return(null);
        }
Exemplo n.º 32
0
		private void initStubs(BTransport transport) {
			dispatcherServiceVal = new BStub_DispatcherService(transport);
			fileSystemNotifyVal = new BStub_FileSystemNotify(transport);
			fileSystemServiceVal = new BStub_FileSystemService(transport);
		}
Exemplo n.º 33
0
        private void InitServices()
        {
            _dispatchService = IocContainer.GetContainer().Resolve<IDispatcherService>() as DispatcherService;

            _navigationService = IocContainer.GetContainer().Resolve<IExtendedNavigationService>() as ExtendedNavigationService;

            _dialogService = IocContainer.GetContainer().Resolve<IExtendedDialogService>() as ExtendedDialogService;

            _hudService = IocContainer.GetContainer().Resolve<IHudService>() as HudService;

            _browserService = IocContainer.GetContainer().Resolve<IBrowserService>() as BrowserService;

            _geoLocator = IocContainer.GetContainer().Resolve<IGeolocator>() as Geolocator;

            _connectivityService = IocContainer.GetContainer().Resolve<IConnectivityService>() as ConnectivityService;

            _phoneService = IocContainer.GetContainer().Resolve<IPhoneService>() as PhoneService;

            _mapService = IocContainer.GetContainer().Resolve<IMapService>() as MapService;

            _emailService = IocContainer.GetContainer().Resolve<IEmailService>() as EmailService;

            _twitterHelper = IocContainer.GetContainer().Resolve<ITwitterHelper>() as AndroidTwitterHelper;

            _facebookHelper = IocContainer.GetContainer().Resolve<IFacebookHelper>() as AndroidFacebookHelper;
        }