public async Task <ExecutionResult> Execute(string yaml, IParametersCollection parameters)
        {
            await _parameters.ReadStateAsync();

            var state = _parameters.State as IParametersCollection;


            var executionResult = new ExecutionResult(ref parameters) as IExecutionResult;

            var controller = new YamlScriptController();

            controller.QuestionCallback = (sender, args) =>
            {
                executionResult.Questions = args;
            };
            var result = controller.Parse(yaml);

            executionResult = new ExecutionResult(ref parameters);
            try
            {
                controller.ExecuteWorkflow(ref state, ref executionResult);
            }
            catch (UnresolvedException) { }
            _parameters.State = executionResult.Parameters as ParametersCollection;
            await _parameters.WriteStateAsync();

            return(executionResult as ExecutionResult);
        }
Пример #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="x"></param>
        /// <param name="y"></param>
        /// <param name="z"></param>
        /// <returns></returns>
        async Task <Stream> IWMS.GetTileImagePNG(int x, int y, int z)
        {
            await _tileCache.ReadStateAsync();

            TileCache cache = _tileCache.State.TILECACHE.Find(p => p.x == x && p.y == y && p.z == z);
            Stream    sm    = await Helper.QueryBitmap(cache?.pngId);

            return(sm);
        }
        public override async Task OnActivateAsync()
        {
            await state.ReadStateAsync();

            if (state.State == null)
            {
                state.State = new FeedSubscriberGrainState();
            }
            if (state.State.Translation == null)
            {
                state.State.Translation
                    = new TranslationState()
                    {
                    }
            }
            ;

            // Save state timer
            RegisterTimer(SaveStateTimer, null, TimeSpan.FromSeconds(60), TimeSpan.FromSeconds(60));

            // Subscribe translation
            await feedSubscriber.SubscribeAsync(
                new MessageContext <TranslationSubscriptionRequest <TranslationState> >(
                    new TranslationSubscriptionRequest <TranslationState>()
            {
                Id = GrainReference.GrainIdentity.PrimaryKeyLong,
                State = state.State.Translation
            }
                    ),
                () => needSaveState = true,
                CancellationToken.None
                );
        }
        public async Task <PlayerDetailsState> ReadPlayerDetailAsync()
        {
            //this is to refresh the state from the underlying persistence storage.
            await _playerState.ReadStateAsync();

            return(_playerState.State);
        }
Пример #5
0
        public async Task <Model> RetrieveInformationAsync()
        {
            DeactivateOnIdle();
            await _state.ReadStateAsync();

            return(_state.State);
        }
Пример #6
0
        public async Task <IEnumerable <string> > ShowHistory()
        {
            DeactivateOnIdle();
            await _conversationState.ReadStateAsync();

            return(_conversationState.State.Phrases
                   .OrderBy(x => x.DateTime)
                   .Select(x => $"{x.DateTime} - {x.Phrase}").ToList());
        }
        public async Task <string> SayAsync(string message)
        {
            await _helloState.ReadStateAsync();

            Console.WriteLine($"{nameof(CustomProfileHelloGrain)}: ETag: {_helloState.Etag}");
            Console.WriteLine($"{nameof(CustomProfileHelloGrain)}: State.Message: {_helloState.State.Message}");

            var newMessage = "Hello " + message;

            _helloState.State.Message = newMessage;
            await _helloState.WriteStateAsync();

            Console.WriteLine($"{nameof(CustomProfileHelloGrain)}: {newMessage}");
            return(newMessage);
        }
Пример #8
0
        public async Task CheckAsync()
        {
            try
            {
                state.State = Guid.NewGuid();
                await state.WriteStateAsync();

                await state.ReadStateAsync();

                await state.ClearStateAsync();
            }
            finally
            {
                DeactivateOnIdle();
            }
        }
Пример #9
0
        public async Task CheckAsync()
        {
            try
            {
                State.State = new StorageHealthCheckState {
                    Id = Guid.NewGuid().ToString()
                };
                await State.WriteStateAsync();

                await State.ReadStateAsync();

                await State.ClearStateAsync();
            }
            finally
            {
                DeactivateOnIdle();
            }
        }
Пример #10
0
        /// <summary>
        /// 获取楼宇信息geojson
        /// </summary>
        /// <returns>GeoJson</returns>
        async Task <string> IBMSHY.AccessLYXXGeoData()
        {
            await _lyxx.ReadStateAsync();

            //FeatureCollectionConverter target = new FeatureCollectionConverter();
            //StringBuilder sb = new StringBuilder();
            //using (JsonTextWriter writer = new JsonTextWriter(new StringWriter(sb)))
            //{
            //    JsonSerializer serializer = NetTopologySuite.IO.GeoJsonSerializer.Create(
            //        new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore },
            //        GeometryFactory.Default);
            //    target.WriteJson(writer, _lyxx.State, serializer);
            //    writer.Flush();
            //    writer.Close();
            //}
            //if (sb.Length == 0) return new FailResponse("土地信息数据空").ToString();

            return(new OkResponse(_lyxx.State.GEOJSON).ToString());
        }
Пример #11
0
        /// <summary>
        /// 系统初始化校验
        /// </summary>
        /// <returns></returns>
        async Task <bool> ICustomer.InitialCheck()
        {
            try
            {
                await _groupManager.ReadStateAsync();

                //内部初始化最高级管理组
                if (!_groupManager.State.GropuCollection.Any())
                {
                    _groupManager.State.GropuCollection = new List <Group>()
                    {
                        new Group()
                        {
                            groupName   = "系统管理员",
                            description = "系统自动初始化新建的管理员,具有最高权限",
                            level       = 99,
                            apiList     = new List <string>()
                        }
                    };
                    await _groupManager.WriteStateAsync();
                }
                await _customerManager.ReadStateAsync();

                //内部初始化最高级管理员
                if (!_customerManager.State.CustomerCollection.Any())
                {
                    _customerManager.State.CustomerCollection = new List <Customer>()
                    {
                        new Customer()
                        {
                            userName      = "******",
                            userPwd       = "admin1",
                            groupObjectId = _groupManager.State.GropuCollection.Find(p => p.level == 99)?.objectId
                        }
                    };
                    await _customerManager.WriteStateAsync();
                }
                return(true);
            }
            catch
            {
                return(false);
            }
        }
Пример #12
0
 public override Task OnActivateAsync()
 {
     _curUserId.ReadStateAsync();
     return(base.OnActivateAsync());
 }
Пример #13
0
        async Task <string> IAtmGrain.GetAtmName()
        {
            await _atmState.ReadStateAsync();

            return(_atmState.State.Name);
        }