コード例 #1
0
        public static async Task AcmeContextEntity(
            [EntityTrigger] IDurableEntityContext ctx,
            [ActorService(Name = "AcmeContext")] IActorService actorservice,
            [OrchestrationClient] IDurableOrchestrationClient starter)
        {
            switch (ctx.OperationName)
            {
            case "Initialize":
                await actorservice.ExecuteAsync <AcmeContextInitializeInput, object, AcmeContextState>(ctx);

                break;

            case "CreateOrder":
                await actorservice.ExecuteAsync <OrderInput, object, AcmeContextState>(ctx);

                break;

            case "FinalizeOrder":
                await actorservice.ExecuteAsync <FinalizeInput, FinalizeOutput, AcmeContextState>(ctx);

                break;

            case "ValidateAuthorization":
                await actorservice.ExecuteAsync <ValidateAuthorizationInput, object, AcmeContextState>(ctx);

                break;

            default:
                throw new InvalidOperationException(ctx.OperationName + " is not known");
            }
        }
コード例 #2
0
ファイル: MovieService.cs プロジェクト: Madaist/Moviepedia
 public MovieService(IMovieRepository movieRepository, IReviewRepository reviewRepository, IMovieInfoRepository movieInfoRepository, IActorService actorService)
 {
     _movieRepository     = movieRepository;
     _reviewRepository    = reviewRepository;
     _movieInfoRepository = movieInfoRepository;
     _actorService        = actorService;
 }
コード例 #3
0
        public static async Task AuthorizationEntity(
            [EntityTrigger] IDurableEntityContext ctx,
            [ActorService(Name = "Authorization")] IActorService actorservice,
            [OrchestrationClient] IDurableOrchestrationClient starter)
        {
            switch (ctx.OperationName)
            {
            case "AuthorizeHttp":
                await actorservice.ExecuteAsync <AuthorizeHttpInput, object, AuthorizationActorState>(ctx);

                break;

            case "AuthorizeDns":
                await actorservice.ExecuteAsync <AuthorizeDnsInput, object, AuthorizationActorState>(ctx);

                break;

            case "AuthorizationCompleted":
                await actorservice.ExecuteAsync <object, object, AuthorizationActorState>(ctx);

                break;

            default:
                throw new InvalidOperationException(ctx.OperationName + " is not known");
            }
        }
コード例 #4
0
        private async Task <long> GetCountAsync(string serviceName)
        {
            string serviceUri = _serviceContext.CodePackageActivationContext.ApplicationName + "/" + serviceName;

            ServicePartitionList partitions = await _fabricClient.QueryManager.GetPartitionListAsync(new Uri(serviceUri));

            long count = 0;

            foreach (Partition partition in partitions)
            {
                long          partitionKey      = ((Int64RangePartitionInformation)partition.PartitionInformation).LowKey;
                IActorService actorServiceProxy = ActorServiceProxy.Create(new Uri(serviceUri), partitionKey);

                ContinuationToken continuationToken = null;

                do
                {
                    PagedResult <ActorInformation> page = await actorServiceProxy.GetActorsAsync(continuationToken, CancellationToken.None);

                    count += page.Items.Where(x => x.IsActive).LongCount();

                    continuationToken = page.ContinuationToken;
                }while (continuationToken != null);
            }

            return(count);
        }
コード例 #5
0
 public ActorsController(IActorService service, IMapper mapper, ILogger <ActorsController> logger, IMovieService movieService)
 {
     _service      = service;
     _mapper       = mapper;
     _logger       = logger;
     _movieService = movieService;
 }
コード例 #6
0
        public void TestRemotingActors_NoSerializationError()
        {
            FabricClient         fabricClient  = new FabricClient("localhost:19000");
            ServicePartitionList partitionList = fabricClient.QueryManager.GetPartitionListAsync(new Uri("fabric:/Codit.Core.Application/DeviceActorService")).Result;

            ContinuationToken continuationToken  = null;
            var cancellationTokenSource          = new CancellationTokenSource();
            List <ActorInformation> activeActors = new List <ActorInformation>();

            foreach (var partition in partitionList)
            {
                var           key = partition.PartitionInformation as Int64RangePartitionInformation;
                IActorService actorServiceProxy = ActorServiceProxy.Create <IMyService>(new Uri("fabric:/Codit.Core.Application/DeviceActorService"), key.LowKey);

                do
                {
                    PagedResult <ActorInformation> page = actorServiceProxy.GetActorsAsync(continuationToken, cancellationTokenSource.Token).Result;
                    activeActors.AddRange(page.Items.Where(x => x.IsActive));
                    continuationToken = page.ContinuationToken;
                }while (continuationToken != null);
            }

            foreach (var actor in activeActors)
            {
                Assert.NotNull(actor.ActorId.ToString());
            }
        }
コード例 #7
0
        public async Task Delete(string actorId)
        {
            var           actorIdObj        = new ActorId(actorId);
            IActorService actorServiceProxy = null;

            try
            {
                actorServiceProxy = ActorServiceProxy.Create(
                    new Uri("fabric:/DataLossCheckApp/ConActorService"),
                    actorIdObj);
                await actorServiceProxy.DeleteActorAsync(actorIdObj, CancellationToken.None);

                // log message
                await Helper.LogMessage(actorId, $"DELETED");
            }
            catch (Exception ex)
            {
                // log message
                await Helper.LogMessage(actorId, $"DELETE ERROR - {ex.ToString()}");
            }
            finally
            {
                if (actorIdObj != null)
                {
                    actorIdObj = null;
                }
                if (actorServiceProxy != null)
                {
                    actorServiceProxy = null;
                }
            }
        }
コード例 #8
0
 public WalletController(IActorService actorService, IWalletService walletService, IVaultServiceClient vaultServiceClient, IUnitOfWork unitOfWork)
 {
     this.actorService       = actorService;
     this.walletService      = walletService;
     this.vaultServiceClient = vaultServiceClient;
     this.unitOfWork         = unitOfWork;
 }
コード例 #9
0
 public SMFController(AbstractBridgeService abstractBridgeService, IPendingService pendingService, IActorService actorService, IQuery <IList <Category> > categoryService)
 {
     _abstractBridgeService = abstractBridgeService;
     _pendingService        = pendingService;
     _actorService          = actorService;
     _categoryService       = categoryService;
 }
コード例 #10
0
        public async Task <IActionResult> GetAsync()
        {
            string serviceUri = this.serviceContext.CodePackageActivationContext.ApplicationName + "/" + this.configSettings.ActorBackendServiceName;

            ServicePartitionList partitions = await this.fabricClient.QueryManager.GetPartitionListAsync(new Uri(serviceUri));

            long count = 0;

            foreach (Partition partition in partitions)
            {
                long          partitionKey      = ((Int64RangePartitionInformation)partition.PartitionInformation).LowKey;
                IActorService actorServiceProxy = ActorServiceProxy.Create(new Uri(serviceUri), partitionKey);

                ContinuationToken continuationToken = null;

                do
                {
                    PagedResult <ActorInformation> page = await actorServiceProxy.GetActorsAsync(continuationToken, CancellationToken.None);

                    count += page.Items.Where(x => x.IsActive).LongCount();

                    continuationToken = page.ContinuationToken;
                }while (continuationToken != null);
            }

            return(this.Json(new { Count = count, Date = DateTime.Now }));
        }
コード例 #11
0
        public async Task <IActionResult> GetAsync()
        {
            string serviceUri = this.serviceContext.CodePackageActivationContext.ApplicationName + "/" + this.configSettings.ActorBackendServiceName;

            ServicePartitionList partitions = await this.fabricClient.QueryManager.GetPartitionListAsync(new Uri(serviceUri));

            long count = 0;

            foreach (Partition partition in partitions)
            {
                long          partitionKey      = ((Int64RangePartitionInformation)partition.PartitionInformation).LowKey;
                IActorService actorServiceProxy = ActorServiceProxy.Create(new Uri(serviceUri), partitionKey);

                // https://docs.microsoft.com/it-it/azure/service-fabric/service-fabric-reliable-actors-enumerate
                // Gli Actors sono ranged partitioned stateful service, quindi l'enumeration è fatta per partizione.
                // Ogni partizione contiene più attori, e il risultato è un loop su un elenco di "pagine".
                ContinuationToken continuationToken = null;

                do
                {
                    PagedResult <ActorInformation> page = await actorServiceProxy.GetActorsAsync(continuationToken, CancellationToken.None);

                    count += page.Items.Where(x => x.IsActive).LongCount();

                    continuationToken = page.ContinuationToken;
                }while (continuationToken != null);
            }

            return(this.Json(new CountViewModel()
            {
                Count = count
            }));
        }
コード例 #12
0
        static void Main(string[] args)
        {
            FabricClient         fabricClient  = new FabricClient("localhost:19000");
            ServicePartitionList partitionList = fabricClient.QueryManager.GetPartitionListAsync(new Uri("fabric:/Codit.Core.Application/DeviceActorService")).Result;

            ContinuationToken continuationToken  = null;
            var cancellationTokenSource          = new CancellationTokenSource();
            List <ActorInformation> activeActors = new List <ActorInformation>();

            foreach (var partition in partitionList)
            {
                var           key = partition.PartitionInformation as Int64RangePartitionInformation;
                IActorService actorServiceProxy = ActorServiceProxy.Create(new Uri("fabric:/Codit.Core.Application/DeviceActorService"), key.LowKey);

                do
                {
                    PagedResult <ActorInformation> page = actorServiceProxy.GetActorsAsync(continuationToken, cancellationTokenSource.Token).Result;
                    activeActors.AddRange(page.Items.Where(x => x.IsActive));
                    continuationToken = page.ContinuationToken;
                }while (continuationToken != null);
            }

            foreach (var actor in activeActors)
            {
                Console.WriteLine($"Active Actor: {actor.ActorId.ToString()}");
            }

            Console.WriteLine("Press any key to exit...");
            Console.ReadLine();
        }
コード例 #13
0
 public ProducerController(IMovieService movies, IActorService actors, IProducerService producers, IGenderService genders)
 {
     _movieDbService    = movies;
     _actorDbService    = actors;
     _producerDbService = producers;
     _genderDbService   = genders;
 }
コード例 #14
0
 public MovieController(IGenreService genreService, IActorService actorService,
                        IMovieService movieService, IMapper mapper) : base(mapper)
 {
     _genreService = genreService;
     _actorService = actorService;
     _movieService = movieService;
 }
コード例 #15
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="kpuIdSearchFor"></param>
        /// <returns></returns>
        public Task <IToHActor> GetActorFromKpuId(string kpuIdSearchFor)
        {
            CancellationTokenSource source            = new CancellationTokenSource();
            CancellationToken       cancellationToken = source.Token;

            int partitionKey = 0;

            IActorService actorServiceProxy = ActorServiceProxy.Create(new Uri("fabric:/CWF.Fabric.Services/ToHActorService"), 0);

            ContinuationToken       continuationToken = null;
            List <ActorInformation> activeActors      = new List <ActorInformation>();

            do
            {
                Task <PagedResult <ActorInformation> > pageTask = actorServiceProxy.GetActorsAsync(continuationToken, cancellationToken);

                PagedResult <ActorInformation> page = pageTask.Result;
                activeActors.AddRange(page.Items.Where(x => x.IsActive));

                continuationToken = page.ContinuationToken;
            }while (continuationToken != null);

            foreach (ActorInformation info in activeActors)
            {
                var           proxy = ActorProxy.Create <IToHActor>(info.ActorId, "fabric:/CWF.Fabric.Services");
                Task <string> kpuId = proxy.GetKpuId();
                var           kpuid = kpuId.Result;
                if (kpuid.CompareTo(kpuIdSearchFor) == 0)
                {
                    return(Task.FromResult <IToHActor>(proxy));
                }
            }
            return(null);
        }
コード例 #16
0
        //RETURN VALUE??
        /// <summary>
        /// Deletes a game session on the server (SQL register)
        /// </summary>
        /// <param name="i_gameId">Game session ID</param>
        public async Task DeleteGameAsync(string i_gameId, string i_uri)
        {
            try
            {
                IActorService actor = ActorServiceProxy.Create(new Uri(i_uri), new ActorId(i_gameId));
                await actor.DeleteActorAsync(new ActorId(i_gameId), new CancellationToken());

                //Connects to the SQL Server and close when exiting
                using (SqlConnection connection = new SqlConnection(builder.ConnectionString))
                {
                    //Opens SQL connection
                    connection.Open();
                    //Creates query string
                    string query = "DELETE FROM Games WHERE Id ='" + i_gameId + "'";
                    //Creates SQL Command using query and connection
                    using (SqlCommand command = new SqlCommand(query, connection))
                    {
                        //Executes command
                        command.ExecuteNonQuery();
                    }
                };
            }
            catch (Exception e)
            {
                Console.Write(e.ToString());
            }
        }
コード例 #17
0
 public void SetUp()
 {
     _mockActorRepo = new Mock <IActorRepository>()
     {
         CallBase = true
     };
     _actorService = new BusinessLogic.Services.ActorCrudService.ActorService(_mockActorRepo.Object);
 }
コード例 #18
0
 public MoviesController(ILogger <HomeController> logger,
                         IActorService actorService,
                         IMovieService movieService) : base(logger)
 {
     _logger       = logger;
     _actorService = actorService;
     _movieService = movieService;
 }
コード例 #19
0
        public WalletTransferCommand(IServiceProvider serviceProvider)
        {
            actorService = serviceProvider.GetService <IActorService>();
            console      = serviceProvider.GetService <IConsole>();
            logger       = serviceProvider.GetService <ILogger>();

            actorService.MessagePump += ActorService_MessagePump;
        }
コード例 #20
0
 public SMFController(AbstractBridgeService abstractService, IPendingService pendingService, IBridgeService bridgeService, IActorService actorService, IMapper mapper)
 {
     _abstractService = abstractService;
     _pendingService  = pendingService;
     _bridgeService   = bridgeService;
     _actorService    = actorService;
     _mapper          = mapper;
 }
コード例 #21
0
 public ActorsController(IActorService actorService,
                         IViewModelMapper <Actor, ActorViewModel> actorMapper,
                         IViewModelMapper <Movie, MovieViewModel> movieMapper)
 {
     this.actorService = actorService ?? throw new ArgumentNullException(nameof(actorService));
     this.actorMapper  = actorMapper ?? throw new ArgumentNullException(nameof(actorMapper));
     this.movieMapper  = movieMapper ?? throw new ArgumentNullException(nameof(movieMapper));
 }
コード例 #22
0
ファイル: CrawlingService.cs プロジェクト: mrtcn/mpapi12x
 public CrawlingService(
     IActorService actorService,
     IMovieService movieService,
     ICategoryService categoryService)
 {
     _actorService    = actorService;
     _movieService    = movieService;
     _categoryService = categoryService;
 }
コード例 #23
0
        public WalletReceivePaymentCommand(IServiceProvider serviceProvider)
        {
            actorService  = serviceProvider.GetService <IActorService>();
            console       = serviceProvider.GetService <IConsole>();
            vaultService  = serviceProvider.GetService <IVaultService>();
            walletService = serviceProvider.GetService <IWalletService>();

            actorService.MessagePump += ActorService_MessagePump;
        }
コード例 #24
0
 public MovieCrawlerController(
     IMovieService movieService,
     IGenreService genreService,
     IActorService actorService)
 {
     _movieService = movieService;
     _actorService = actorService;
     _genreService = genreService;
 }
コード例 #25
0
ファイル: CrawlingService.cs プロジェクト: mrtcn/mpapi12x
 public CrawlingService(
     IActorService actorService,
     IMovieService movieService,
     IGenreService genreService)
 {
     _actorService = actorService;
     _movieService = movieService;
     _genreService = genreService;
 }
        private async Task <KeyValuePair <string, string> > GetRandomIdsAsync()
        {
            ServiceUriBuilder serviceUri = new ServiceUriBuilder(this.GetSetting(DeviceServiceName));
            Uri fabricServiceName        = serviceUri.ToUri();

            CancellationTokenSource cts        = new CancellationTokenSource(TimeSpan.FromMinutes(5));
            CancellationToken       token      = cts.Token;
            FabricClient            fc         = new FabricClient();
            ServicePartitionList    partitions = await fc.QueryManager.GetPartitionListAsync(fabricServiceName);

            string doctorId = null;

            while (!token.IsCancellationRequested && doctorId == null)
            {
                try
                {
                    foreach (Partition p in partitions)
                    {
                        long partitionKey = ((Int64RangePartitionInformation)p.PartitionInformation).LowKey;
                        token.ThrowIfCancellationRequested();
                        ContinuationToken queryContinuationToken = null;
                        IActorService     proxy = ActorServiceProxy.Create(fabricServiceName, partitionKey);
                        PagedResult <ActorInformation> result = await proxy.GetActorsAsync(queryContinuationToken, token);

                        foreach (ActorInformation info in result.Items)
                        {
                            token.ThrowIfCancellationRequested();

                            ActorId      deviceActorId = info.ActorId;
                            IDeviceActor deviceActor   = ActorProxy.Create <IDeviceActor>(deviceActorId, fabricServiceName);

                            try
                            {
                                doctorId = (await deviceActor.GetAssociatedDoctorAsync()).ToString();

                                return(new KeyValuePair <string, string>(deviceActorId.ToString(), doctorId));
                            }
                            catch (Exception e)
                            {
                                ServiceEventSource.Current.Message("Exception when obtaining actor ID. No State? " + e.ToString());
                                continue;
                            }
                        }
                        //otherwise we will bounce around other partitions until we find an actor
                    }
                }
                catch (Exception e)
                {
                    ServiceEventSource.Current.Message("Exception when obtaining actor ID: " + e.ToString());
                    continue;
                }
            }

            throw new InvalidOperationException("Couldn't find actor within timeout");
        }
コード例 #27
0
        public ActorsListViewModel(RegionManager regionManager, TheMovieDBDataService dataService, ActorService actorService)
        {
            _regionManager = regionManager;
            _dataService   = dataService;
            _actorService  = actorService;
            _logger        = LogManager.GetCurrentClassLogger();

            NotificationRequest            = new InteractionRequest <INotification>();
            NotificationRequestNull        = new InteractionRequest <INotification>();
            NavigateCommandShowDirectActor = new DelegateCommand <int?>(ShowDirectActor);
        }
コード例 #28
0
 public MovieActorViewComponent(
     IPictureService pictureService, IMovieActorService movieActorService,
     IMemoryCache cacheManager,
     IActorService actorService)
 {
     _actorService      = actorService;
     _movieActorService = movieActorService;
     //_categoryService = categoryService;
     _pictureService = pictureService;
     _cacheManager   = cacheManager;
 }
コード例 #29
0
 public ActivityService(IRequestBuilder requestBuilder, IRestClient restClient,
                        IResponseValidator responseValidator,
                        IActivityConvertor activityConvertor, IActionService actionService, IActionConvertor actionConvertor,
                        IAddActivityValidator addActivityValidator, IActorService actorService)
     : base(requestBuilder, restClient, responseValidator)
 {
     _activityConvertor    = activityConvertor;
     _actionService        = actionService;
     _actionConvertor      = actionConvertor;
     _addActivityValidator = addActivityValidator;
     _actorService         = actorService;
 }
コード例 #30
0
 public SettingController(AbstractBridgeService abstractService, ISummaryService summaryService, IRecordService recordService, IQuery <IList <Constraint> > constraintService, IOrganizationService organizationService, IActorService actorService, IQuery <IList <Category> > categoryService, IBridgeService bridgeService, IMapper mapper)
 {
     _abstractService     = abstractService;
     _constraintService   = constraintService;
     _organizationService = organizationService;
     _actorService        = actorService;
     _categoryService     = categoryService;
     _bridgeService       = bridgeService;
     _recordService       = recordService;
     _summaryService      = summaryService;
     _mapper = mapper;
 }
コード例 #31
0
 public PreferenceController(IPreferenceService service, IActorService actService)
 {
     this.preferenceService = service;
     this.actorService = actService;
 }
コード例 #32
0
 public ActorController(IActorService service)
 {
     this.actorService = service;
 }