コード例 #1
0
            public override async Task ExecuteAsync(
                IActivityContext <TestRequest5> activityContext,
                CancellationToken cancellationToken)
            {
                var request = activityContext.Request;

                try {
                    await Task.Delay(TimeSpan.FromSeconds(50), cancellationToken);
                } catch {
                    var response = new TestResponse5()
                    {
                        R = request.A * request.B - 2
                    };
                    await this.SetResponseAsync(activityContext, response);

                    return;
                }
                {
                    var response = new TestResponse5()
                    {
                        R = request.A * request.B + 2
                    };
                    await this.SetResponseAsync(activityContext, response);

                    return;
                }
            }
コード例 #2
0
        public async Task Execute(IActivityContext context)
        {
            var url      = context.SagaProperties.Get <string>("Url");
            var response = await httpClient.GetAsync(url);

            logger.LogInformation($"Retrieved {response.Content.Headers.ContentLength} bytes from '{url}'.");
        }
コード例 #3
0
        protected void Execute<TTask>(NativeActivityContext context, CancellationTokenSource cts, TTask resultTask,
                Action<NativeActivityContext> postExecute)
            where TTask : Task
        {
            if (resultTask.IsCompleted)
                postExecute(context);
            else
            {
                IActivityContext activityContext = context.GetActivityContext();

                taskCompletionNoPersistHandle.Get(context).Enter(context);

                cancellationTokenSource.Set(context, cts);

                Bookmark bookmark = context.CreateBookmark(BookmarkResumptionCallback);
                // continuations don't use cts, the main task is already completed, we can't cancel it 
                resultTask
                    .ContinueWith((_resultTask) => activityContext.ResumeBookmarkThroughHostAsync(bookmark, postExecute, TimeSpan.MaxValue),
                        TaskContinuationOptions.ExecuteSynchronously).Unwrap()
                    // TODO how to handle exception properly?
                    // AsyncCodeActivity has an AsyncOperationContext and it can call Abort on that context directly, but we are left alone now,
                    // we must schedule an Abort through the host, because NativeActivityContext is already disposed now
                    .ContinueWith((_resumeBookmarkTask) => activityContext.AbortThroughHostAsync(_resumeBookmarkTask.Exception.InnerException),
                        TaskContinuationOptions.OnlyOnFaulted | TaskContinuationOptions.ExecuteSynchronously).Unwrap()
                    .ContinueWith((_abortWorkflowInstanceTask) => { var ignored = _abortWorkflowInstanceTask.Exception; },
                        TaskContinuationOptions.OnlyOnFaulted | TaskContinuationOptions.ExecuteSynchronously);
            }
        }
コード例 #4
0
        public async Task <TResponse> ExecuteAsync(
            IActivityContext <TRequest> activityContext,
            ActivityId activityId,
            TRequest request,
            ActivityExecutionConfiguration activityExecutionConfiguration,
            CancellationToken cancellationToken)
        {
            using var connectedClient = await activityContext.ConnectAndSendAsync(
                      activityId,
                      request,
                      activityExecutionConfiguration,
                      cancellationToken);

            var response = await connectedClient.WaitForAsync(activityExecutionConfiguration, cancellationToken);

            if (response is IOkResultActivityResponse resultActivityResponse)
            {
                var success = resultActivityResponse.TryGetResult(out var result);
                if (result is TResponse resultTyped)
                {
                    return(resultTyped);
                }
                else
                {
                }
            }
            //response.GetAsActivityEvent
            //if (response is OkResultActivityResponse<TResponse> okResult) {
            //    if (response.TryGetResult<TResponse>(out var result)) {
            //    return result;
            //} else {
            //}
            throw new NotImplementedException();
        }
コード例 #5
0
        private async Task WaitAsync(IActivityContext context, [CallerMemberName] string operation = null)
        {
            var waitTimeSeconds = context.SagaProperties.Get <int>("WaitTimeSeconds");

            logger.LogInformation($"{operation.TrimEnd('e')}ing for {waitTimeSeconds} seconds...");
            await Task.Delay(waitTimeSeconds * 1000);
        }
コード例 #6
0
        public async Task Compensate(IActivityContext context)
        {
            var account = context.SagaProperties.Get <int>("Account");

            var sourceAccount = context.GrainFactory.GetGrain <IBankAccountGrain>(account);

            await sourceAccount.RevertBalanceModification(context.SagaId);
        }
コード例 #7
0
        public Task Execute(IActivityContext context)
        {
            var numSuitcases = context.SagaProperties.Get <int>("NumSuitcases");

            // comment in to test compensation.
            //throw new SeatUnavailableException();
            return(Task.CompletedTask);
        }
コード例 #8
0
        /// <summary>
        /// 事务回滚事务
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        public async Task Compensate(IActivityContext context)
        {
            var grainId = context.SagaProperties.Get <string>("GrainId");
            var data    = context.SagaProperties.Get <SubmitDTO <XsLadeRimpactDTO> >("Data");

            var sourceGrain = context.GrainFactory.GetGrain <IXsLadeRimpactStateGrain>(grainId);
            await sourceGrain.RevertAsync(context.SagaId, data.Data.IsDel, data.UserId, data.UserName);
        }
コード例 #9
0
        public async Task Execute(IActivityContext context)
        {
            var account = context.SagaProperties.Get <int>("Account");
            var amount  = context.SagaProperties.Get <int>("Amount");

            var sourceAccount = context.GrainFactory.GetGrain <IBankAccountGrain>(account);

            await sourceAccount.ModifyBalance(context.SagaId, amount);
        }
コード例 #10
0
 /// <summary>
 /// Save the entity to the database.
 /// This method requires a valid Activity to track this database commit
 /// </summary>
 /// <param name="activity">Activity tracking this record</param>
 public CustomerInfo Save(IActivityContext activity)
 {
     base.ActivityContextID = activity.ActivityContextID;
     // Ensure data does not contain cross site scripting injection HTML/Js/SQL
     FirstName  = new HtmlUnsafeCleanser(FirstName).Cleanse();
     MiddleName = new HtmlUnsafeCleanser(MiddleName).Cleanse();
     LastName   = new HtmlUnsafeCleanser(LastName).Cleanse();
     return(base.Update());
 }
コード例 #11
0
 public IActivityEvent GetAsActivityEvent(IActivityContext activityContext)
 {
     return(new ActivityEventStateChange(
                activityContext.ActivityId,
                -1,
                System.DateTime.UtcNow,
                ActivityStatus.Completed,
                null));
 }
コード例 #12
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="context"></param>
 /// <param name="detection"></param>
 /// <param name="userManager"></param>
 /// <param name="urlHelper"></param>
 /// <param name="mapper"></param>
 /// <param name="accessor"></param>
 public UserActivityService(IActivityContext context, IDetection detection, IUserManager <GearUser> userManager, IUrlHelper urlHelper, IMapper mapper, IHttpContextAccessor accessor)
 {
     _context     = context;
     _detection   = detection;
     _userManager = userManager;
     _urlHelper   = urlHelper;
     _mapper      = mapper;
     _accessor    = accessor;
 }
コード例 #13
0
        /// <summary>
        /// Creates this object in the database
        ///  ActivityContext record is supplied as parameter
        /// </summary>
        /// <param name="activity">Activity Context of this operation, used to track DB commits</param>
        /// <returns>Fresh TEntity pulled from the database, as DB might change some data automatically</returns>
        public virtual TEntity Create(IActivityContext activity)
        {
            var returnValue = new TEntity();
            var db          = SaveableDatabase <TEntity> .Construct();

            this.ActivityContextID = activity.ActivityContextID;
            returnValue            = db.Save(this.ToEntity(), forceInsert: true);

            return(returnValue);
        }
コード例 #14
0
ファイル: XsLadeBaseActivity.cs プロジェクト: zhrjin/Kaneko
        /// <summary>
        /// 事务回滚事务
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        public async Task Compensate(IActivityContext context)
        {
            var grainId  = context.SagaProperties.Get <string>("GrainId");
            var status   = context.SagaProperties.Get <string>("XLB_Status");
            var userId   = context.SagaProperties.Get <string>("UserId");
            var userName = context.SagaProperties.Get <string>("UserName");

            var sourceGrain = context.GrainFactory.GetGrain <IXsLadeBaseStateGrain>(grainId);
            await sourceGrain.RevertStatusAsync(context.SagaId, status, userId, userName);
        }
コード例 #15
0
        public Task Execute(IActivityContext context)
        {
            var hireCarModel = context.SagaProperties.Get <int>("HireCarModel");

            context.SagaProperties.Add("NumSuitcases", 3);
            context.SagaProperties.Add(nameof(CarInfo), new CarInfo {
                Make = "Nissan", Model = "Pathfinder"
            });

            return(Task.CompletedTask);
        }
コード例 #16
0
        public static Task SetFailureResponseAsync <TRequest, TResponse>(
            this IActivityHandler <TRequest, TResponse> that,
            IActivityContext <TRequest> activityContext,
            System.Exception error)
            where TRequest : IRequest <TResponse>, IRequestBase
            where TResponse : IResponseBase
        {
            var failureResponse = new FailureActivityResponse(error);

            return(activityContext.SetActivityResponseAsync(failureResponse));
        }
コード例 #17
0
        /// <summary>
        /// Deletes this object from the database
        ///  ActivityContext record is supplied as parameter
        /// </summary>
        /// <param name="activity">Activity Context of this operation, used to track DB commits</param>
        /// <returns>Fresh TEntity pulled from the database, as DB might change some data automatically</returns>
        public virtual bool Delete(IActivityContext activity)
        {
            var db = SaveableDatabase <TEntity> .Construct();

            var returnValue = TypeExtension.DefaultBoolean;

            this.ActivityContextID = activity.ActivityContextID;
            returnValue            = db.Delete(this.ToEntity());

            return(returnValue);
        }
コード例 #18
0
        public static Task SetResponseAsync <TRequest, TResponse>(
            this IActivityHandler <TRequest, TResponse> that,
            IActivityContext <TRequest> activityContext,
            TResponse response)
            where TRequest : IRequest <TResponse>, IRequestBase
            where TResponse : IResponseBase
        {
            var okResponse = new OkResultActivityResponse <TResponse>(response);

            return(activityContext.SetActivityResponseAsync(okResponse));
        }
コード例 #19
0
        /// <summary>
        /// 事务回滚事务
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        public async Task Compensate(IActivityContext context)
        {
            var grainId   = context.SagaProperties.Get <string>("GrainId");
            var eventType = context.SagaProperties.Get <string>("EventType");
            int isDel     = "ADD" == eventType ? 1 : 0;
            var userId    = context.SagaProperties.Get <string>("UserId");
            var userName  = context.SagaProperties.Get <string>("UserName");

            var sourceGrain = context.GrainFactory.GetGrain <IXsReceReceivableStateGrain>(grainId);
            await sourceGrain.RevertAsync(context.SagaId, isDel, userId, userName);
        }
コード例 #20
0
 public BaseGeneratorTests()
 {
     _smartAppPath = Path.Combine(Directory.GetCurrentDirectory(), "Manifest");
     _context      = new ActivityContext(new ExpandoObject(), null, null);
     _context.DynamicContext.Manifest        = JadeEngine.Parse(_smartAppPath);
     _context.DynamicContext.GeneratorPath   = Directory.GetCurrentDirectory();
     _context.DynamicContext.Theme           = "light";
     _context.DynamicContext.ViewModelSuffix = "ViewModel";
     _context.DynamicContext.ApiSuffix       = "Service";
     TransformSuffixes();
 }
コード例 #21
0
 public override async Task ExecuteAsync(
     IActivityContext <GetConfigurationRequest> activityContext,
     CancellationToken cancellationToken)
 {
     try {
         var result = new GetConfigurationResponse();
         result.Result = new string[] { "A", "B" };
         await this.SetResponseAsync(activityContext, result);
     } catch (System.Exception error) {
         await this.SetFailureResponseAsync(activityContext, error);
     }
 }
コード例 #22
0
        public IActivityHandler <TRequest, TResponse> CreateHandler <TRequest, TResponse>(
            RequestRelatedType?requestRelatedType,
            IActivityContext <TRequest> activityContext
            )
            where TRequest : IRequest <TResponse>, IRequestBase
            where TResponse : IResponseBase
        {
            if (requestRelatedType is null)
            {
                if (!this._MediatorService.TryRequestRelatedType(typeof(TRequest), out requestRelatedType) ||
                    (requestRelatedType is null))
                {
                    throw new NotSupportedException($"Unknown RequestType: {typeof(TRequest).FullName}");
                }
            }

            if (activityContext is null)
            {
                throw new ArgumentNullException(nameof(activityContext));
            }

            IActivityHandler <TRequest, TResponse>?result = null;

            if (requestRelatedType.DispatcherType is object)
            {
                var dispatchActivityHandler = (IDispatchActivityHandler <TRequest, TResponse>) this._ServiceProvider.GetService(requestRelatedType.DispatcherType);
                if (dispatchActivityHandler is null)
                {
                    throw new NotSupportedException($"Unknown IDispatchActivityHandler { requestRelatedType.DispatcherType.FullName } RequestType: {typeof(TRequest).FullName} ResponseType: {typeof(TResponse).FullName}");
                }
                result = dispatchActivityHandler.GetActivityHandler(
                    requestRelatedType.HandlerTypes,
                    activityContext,
                    (Type activityHandlerType) => (IActivityHandler <TRequest, TResponse>) this._ServiceProvider.GetService(activityHandlerType)
                    );
            }
            else if (requestRelatedType.HandlerTypes.Length == 1)
            {
                result = (IActivityHandler <TRequest, TResponse>) this._ServiceProvider.GetRequiredService(requestRelatedType.HandlerTypes[0]);
            }
            else
            {
                result = this._ServiceProvider.GetService <IActivityHandler <TRequest, TResponse> >();
            }
            if (result is null)
            {
                throw new NotSupportedException($"Unknown IActivityHandler RequestType: {typeof(TRequest).FullName} ResponseType: {typeof(TResponse).FullName}");
            }
            else
            {
                return(result);
            }
        }
コード例 #23
0
        // This will start/schedule the OnOperationAsync task, but won't wait for it, the task will be an implicit (single threaded reentrant) parallel activity.
        // The Scope is responsible to handle the outstanding task in case of Abort, Cancellation or Termination.
        protected override void Execute(NativeActivityContext context)
        {
            SendRequestReceiveResponseScopeExecutionProperty executionProperty = context.GetSendRequestReceiveResponseScopeExecutionProperty();
            IActivityContext activityContext = context.GetActivityContext();

            executionProperty.StartOnOperationAsync(activityContext, OperationName);

            if (activityContext.TrackingEnabled)
            {
                context.Track(new SendRequestRecord(OperationName));
            }
        }
コード例 #24
0
        /// <summary>
        /// Save the entity to the database.
        /// This method requires a valid Activity to track this database commit
        /// </summary>
        /// <param name="activity">Activity tracking this record</param>
        public CustomerInfo Save(IActivityContext activity)
        {
            var writer = new StoredProcedureWriter <CustomerInfo>();

            ActivityContextId = activity.ActivityContextId;
            // Ensure data does not contain cross site scripting injection HTML/Js/SQL
            FirstName  = new HtmlUnsafeCleanser(FirstName).Cleanse();
            MiddleName = new HtmlUnsafeCleanser(MiddleName).Cleanse();
            LastName   = new HtmlUnsafeCleanser(LastName).Cleanse();
            this.Fill(writer.Save(this));
            return(this);
        }
コード例 #25
0
        // old
        public static ActionResult <T> ReturnAsActionResult <T>(
            this IActivityContext activityContext
            )
        {
            if (activityContext is null)
            {
                throw new ArgumentNullException(nameof(activityContext));
            }

            //activityContext.GetResult();
            throw new NotImplementedException();
        }
コード例 #26
0
        public AppSettingsView(IActivityContext <Unit> context)
        {
            this.context      = context;
            LocalesCollection = new ObservableCollection <odm.localization.Language>();

            this.CommandBindings.Add(
                new CommandBinding(
                    AppSettingsView.ApplyCommand,
                    (s, a) => {
                odm.localization.Language.Current = (localization.Language)langValue.SelectedItem;
                odm.ui.Properties.Settings.Default.DefaultLocaleIso3 = odm.localization.Language.Current.iso3;
                odm.ui.Properties.Settings.Default.Save();

                var vs = AppDefaults.visualSettings;

                vs.Events_IsEnabled            = enableEventValue.IsChecked.Value;
                vs.EventsCollect_IsEnabled     = collectEventsValue.IsChecked.Value;
                vs.Snapshot_IsEnabled          = enableSnapshotValue.IsChecked.Value;
                vs.CustomAnalytics_IsEnabled   = enableCustomAnalyticsValuse.IsChecked.Value;
                vs.ui_video_rendering_fps      = videoRenderingFpsValue.Value ?? 30;
                vs.Event_Subscription_Type     = ((KeyValuePair <VisualSettings.EventType, string>)eventType.SelectedValue).Key;
                vs.Base_Subscription_Port      = basePortValue.Value.Value;
                vs.ShowVideoPlaybackStatistics = showVideoPlaybackStatisticsValue.IsChecked == true;
                vs.Transport_Type           = ((KeyValuePair <TransportProtocol, string>)transportTypes.SelectedValue).Key;
                vs.OpenInExternalWebBrowser = webValue.IsChecked.Value;
                vs.EnableGraphicAnnotation  = enableGraphicAnnotationValue.IsChecked.Value;

                vs.UseOnlyCommonFilterView = enableOnlyDefValue.IsChecked.Value;

                AppDefaults.UpdateVisualSettings(vs);


                Success();
            }
                    )
                );

            this.CommandBindings.Add(
                new CommandBinding(
                    AppSettingsView.CancelCommand,
                    (s, a) => {
                Success();
            }
                    )
                );

            InitializeComponent();

            BindData();
            LocaLization();
        }
コード例 #27
0
		public AppSettingsView(IActivityContext<Unit> context) {
			this.context = context;
			LocalesCollection = new ObservableCollection<odm.localization.Language>();

			this.CommandBindings.Add(
				new CommandBinding(
					AppSettingsView.ApplyCommand,
					(s, a) => {
						odm.localization.Language.Current = (localization.Language)langValue.SelectedItem;
						odm.ui.Properties.Settings.Default.DefaultLocaleIso3 = odm.localization.Language.Current.iso3;
						odm.ui.Properties.Settings.Default.Save();

						var vs = AppDefaults.visualSettings;

						vs.Events_IsEnabled = enableEventValue.IsChecked.Value;
						vs.EventsCollect_IsEnabled = collectEventsValue.IsChecked.Value;
						vs.Snapshot_IsEnabled = enableSnapshotValue.IsChecked.Value;
						vs.CustomAnalytics_IsEnabled = enableCustomAnalyticsValuse.IsChecked.Value;
						vs.ui_video_rendering_fps = videoRenderingFpsValue.Value ?? 30;
						vs.Event_Subscription_Type = ((KeyValuePair<VisualSettings.EventType, string>)eventType.SelectedValue).Key;
						vs.Base_Subscription_Port = basePortValue.Value.Value;
						vs.ShowVideoPlaybackStatistics = showVideoPlaybackStatisticsValue.IsChecked == true;
						vs.Transport_Type = ((KeyValuePair<TransportProtocol, string>)transportTypes.SelectedValue).Key;
						vs.OpenInExternalWebBrowser = webValue.IsChecked.Value;
                        vs.EnableGraphicAnnotation = enableGraphicAnnotationValue.IsChecked.Value;

						vs.UseOnlyCommonFilterView = enableOnlyDefValue.IsChecked.Value;

						AppDefaults.UpdateVisualSettings(vs);


						Success();
					}
				)
			);

			this.CommandBindings.Add(
				new CommandBinding(
					AppSettingsView.CancelCommand,
					(s, a) => {

						Success();
					}
				)
			);

			InitializeComponent();

			BindData();
			LocaLization();
		}
コード例 #28
0
            public override Task ExecuteAsync(
                IActivityContext <TestRequest2> activityContext,
                CancellationToken cancellationToken)
            {
                var request = activityContext.Request;
                //activityContext.
                var response = new TestResponse2()
                {
                    R = request.A * request.B
                };

                //activityContext.SetResponseAsync(response);
                return(this.SetResponseAsync(activityContext, response));
            }
コード例 #29
0
            // We behave like an UnhandledException.
            protected override async Task <UnhandledExceptionAction> ExecuteAsync(NativeActivityContext context)
            {
                Exception                propagatedException      = PropagatedException.Get(context);
                IActivityContext         activityContext          = context.GetActivityContext();
                UnhandledExceptionAction unhandledExceptionAction = activityContext.Parameters.UnhandledExceptionAction;

                if (unhandledExceptionAction != UnhandledExceptionAction.Abort &&
                    !await activityContext.NotifyHostOnUnhandledExceptionAsync(propagatedException, null))
                {
                    // If the host can't handle it, the instance will abort, independently from the configuration.
                    unhandledExceptionAction = UnhandledExceptionAction.Abort;
                }
                return(unhandledExceptionAction);
            }
コード例 #30
0
            public override Task ExecuteAsync(
                IActivityContext <TestRequestXXX, TestResponseXXX> activityContext,
                CancellationToken cancellationToken)
            {
                var request = activityContext.Request;
                //activityContext.
                var response = new TestResponseXXX()
                {
                    R = request.A * request.B
                };

                activityContext.SetResponse(response);
                return(Task.CompletedTask);
            }
コード例 #31
0
        public UpgradeBatchTaskView(IActivityContext <Unit> context)
        {
            this.context = context;

            items         = new ObservableCollection <BatchItem>();
            manufacturers = new ObservableCollection <string>();
            models        = new ObservableCollection <string>();

            CommonList = new List <BatchItem>();
            BatchTaskEventArgs evargs = context.container.Resolve <BatchTaskEventArgs>();

            nvtSession = evargs.session;;

            evargs.Devices.ForEach(dev => {
                BatchItem bitem        = new BatchItem(dev);
                bitem.PropertyChanged += new PropertyChangedEventHandler((object sender, PropertyChangedEventArgs e) => {
                    CanUpgrade();
                });
                CommonList.Add(bitem);
            });

            this.CommandBindings.Add(
                new CommandBinding(
                    UpgradeBatchTaskView.UpgradeCommand,
                    (s, a) => {
                OnUpgrade();
            }
                    )
                );

            this.CommandBindings.Add(
                new CommandBinding(
                    UpgradeBatchTaskView.CancelCommand,
                    (s, a) => {
                Success();
            }
                    )
                );

            InitializeComponent();

            BindData();
            Localization();
        }
コード例 #32
0
		public AboutView(IActivityContext<Unit> context) {
			this.context = context;
			InitializeComponent();

			closeButton.CreateBinding(Button.ContentProperty, buttons, x => x.close);
			groupBox1.CreateBinding(GroupBox.HeaderProperty, strings, x => x.contactInfo);
			commonCaption.CreateBinding(TextBlock.TextProperty, strings, x => x.aboutCommon);
			russCaption.CreateBinding(TextBlock.TextProperty, strings, x => x.aboutRus);
			belarusCaption.CreateBinding(TextBlock.TextProperty, strings, x => x.aboutBelarus);
			russCaptionPhone.CreateBinding(TextBlock.TextProperty, strings, x => x.aboutRusPhone);
			belarusCaptionPhone.CreateBinding(TextBlock.TextProperty, strings, x => x.aboutBelarusPhone);
			this.CreateBinding(NavigationContext.TitleProperty, Titles, x => x.about);

			closeButton.Command = new DelegateCommand(
				() => Success(),
				() => true
			);

		}
コード例 #33
0
 public DurableReminderExtension(IActivityContext instance)
 {
     reminderTable = new ReminderTable(instance);
 }
コード例 #34
0
ファイル: Rule.cs プロジェクト: ByteCarrot/Masslog
 public abstract bool Apply(IActivityContext context);
コード例 #35
0
		public FrameworkElement CreateView(VideoSettingsView.Model model, IActivityContext<VideoSettingsView.Result> context) {
			return new VideoSettingsView(model, context);
		}
コード例 #36
0
 public ActivityContextExtension(IActivityContext activityContext)
 {
     ActivityContext = activityContext;
 }
コード例 #37
0
		public BackgroundTasksView(IActivityContext<Unit> context) {
			this.context = context;
			InitializeComponent();

			Localization();
			IEventAggregator eventAggregator = null;
			try {
				eventAggregator = context.container.Resolve<IEventAggregator>();
			} catch (Exception err) {
				dbg.Error(err);
			}

			CommandBindings.Add(
				new CommandBinding(
					CloseCommand,
					(s, a) => {
						//view.Dispose();
						Success();
					}
				)
			);
			CommandBindings.Add(
				new CommandBinding(
					RemoveTaskCommand,
					(s, a) => {
						var backgroundTask = a.Parameter as IBackgroundTask;
						if (backgroundTask != null) {
							BackgroundTaskManager.tasks.Remove(backgroundTask);
							backgroundTask.Dispose();
						}
					}
				)
			);
			CommandBindings.Add(
				new CommandBinding(
					CancelTaskCommand,
					(s, a) => {
						var backgroundTask = a.Parameter as IBackgroundTask;
						if (backgroundTask != null) {
							backgroundTask.Dispose();
						}
					}
				)
			);
			CommandBindings.Add(
				new CommandBinding(
					AddUpgradeBatchCommand,
					(s, a) => {
						var evarg = new DeviceLinkEventArgs();
						evarg.currentAccount = AccountManager.Instance.CurrentAccount;
						evarg.session = null;
						eventAggregator.GetEvent<UpgradeButchClick>().Publish(true);
					}
				)
			);
			CommandBindings.Add(
				new CommandBinding(
					AddRestoreBatchCommand,
					(s, a) => {
						var evarg = new DeviceLinkEventArgs();
						evarg.currentAccount = AccountManager.Instance.CurrentAccount;
						evarg.session = null;
						eventAggregator.GetEvent<RestoreButchClick>().Publish(true);
					}
				)
			);
			CommandBindings.Add(
				new CommandBinding(
					CancelAllRunningTasksCommand,
					(s, a) => {
						foreach (var t in BackgroundTaskManager.tasks) {
							t.Dispose();
						}
					}
				)
			);
			CommandBindings.Add(
				new CommandBinding(
					RemoveAllFinishedTasksCommand,
					(s, a) => {
						var tasks = BackgroundTaskManager.tasks.Where(t => t.state != BackgroundTaskState.InProgress).ToList();
						foreach (var t in tasks) {
							try {
								BackgroundTaskManager.tasks.Remove(t);
								t.Dispose();
							} catch (Exception err) {
								dbg.Error(err);
							}
						}
					}
				)
			);

		}
コード例 #38
0
 public ReminderTable(IActivityContext instance)
 {
     this.instance = instance;
     this.reminders = new Dictionary<string, ReminderInfo>();
     //this.hasReactivationReminder = false;
 }