コード例 #1
0
        private void SendPublicKey(byte[] requester, RouterSocket router)
        {
            var response = ResponseCreator.Create(new NoEncryption(), requester, MessageType.SendPublicKey,
                                                  JsonConvert.SerializeObject(_decryptor.PublicKey));

            router.SendMultipartMessage(response);
        }
コード例 #2
0
        public override HttpResponseMessage Post([FromBody] Order value)
        {
            try
            {
                if (value.IsClosed)
                {
                    throw new EntityIsClosedException();
                }
                //value.IsFinished = false;

                var doctor = get_current_doctor();
                if (doctor == null)
                {
                    throw new EntityNotFoundException();
                }
                value.Doctor = doctor;


                return(base.Post(value));
            }
            catch (EntityIsClosedException exp)
            {
                return(ResponseCreator.GenerateResponse(HttpStatusCode.Forbidden, exp));
            }
        }
コード例 #3
0
        public HttpResponseMessage Post(DoctorBindingModel value)
        {
            try
            {
                Doctor doctor = m_repository.GetById(value.Id);
                doctor.Image                 = value.Image;
                doctor.Text                  = value.Text;
                doctor.PersonInfo.Name       = value.Name;
                doctor.PersonInfo.Surname    = value.Surname;
                doctor.PersonInfo.Middlename = value.Middlename;

                m_repository.Update(doctor);

                return(new HttpResponseMessage(HttpStatusCode.OK));
            }
            catch (EntityAlreadyExistsException exp)
            {
                return(ResponseCreator.GenerateResponse(HttpStatusCode.BadRequest, exp));
            }
            catch (EntityNotFoundException exp)
            {
                return(ResponseCreator.GenerateResponse(HttpStatusCode.NotFound, exp));
            }
            catch (Exception exp)
            {
                return(ResponseCreator.GenerateResponse(HttpStatusCode.InternalServerError, exp));
            }
        }
コード例 #4
0
        public HttpResponseMessage Finish(int orderId)
        {
            try
            {
                var tech_id = System.Web.HttpContext.Current.User.Identity.GetUserId <int>();
                var tech    = technican_repository.Entities.First(x => x.ApplicationUserId == tech_id);

                var order = m_repository.GetById(orderId);
                if (order == null)
                {
                    throw new EntityNotFoundException();
                }

                order.IsFinished      = true;
                order.DentalTechnican = tech;
                order.FinishDate      = DateTime.Now;

                m_repository.Update(order);

                return(new HttpResponseMessage(HttpStatusCode.OK));
            }
            catch (EntityNotFoundException exp)
            {
                return(ResponseCreator.GenerateResponse(HttpStatusCode.NotFound, exp));
            }
            catch (Exception exp)
            {
                return(ResponseCreator.GenerateResponse(HttpStatusCode.InternalServerError, exp));
            }
        }
コード例 #5
0
        public HttpResponseMessage AddProcedure(int visitId, int procedureId)
        {
            try
            {
                var visit = m_repository.Entities.Include(x => x.Procedures).FirstOrDefault(x => x.Id == visitId);
                if (visit == null)
                {
                    throw new EntityNotFoundException();
                }
                if (visit.IsClosed)
                {
                    throw new EntityIsClosedException();
                }

                visit.Procedures.Add(procedure_repository.GetById(procedureId));
                m_repository.Update(visit);

                return(new HttpResponseMessage(HttpStatusCode.OK));
            }
            catch (EntityNotFoundException exp)
            {
                return(ResponseCreator.GenerateResponse(HttpStatusCode.NotFound, exp));
            }
            catch (EntityIsClosedException exp)
            {
                return(ResponseCreator.GenerateResponse(HttpStatusCode.Forbidden, exp));
            }
        }
コード例 #6
0
        public override SkillResponse HandleSyncRequest(AlexaRequestInformation <SkillRequest> information)
        {
            var game = (Game)information.Context;

            if (_intentName == BuiltInIntent.Yes)
            {
                // we should continue previous game
                game.Message         = game.RepeatMessage;
                game.RepromptMessage = "Awaiting your orders, captain. ";
                game.GameState       = game.LastGameState;
                game.SaveData();
            }
            else if (_intentName == BuiltInIntent.No)
            {
                // answer was No, go back to main menu
                game.IsGameInProgress = false;
                game.Welcome();
            }
            else
            {
                // invalid answer, ask the continue game prompt again
                return(ResponseCreator.Ask("I'm sorry, I didn't get that. Do you want to continue playing your last unfinished game? ", "To continue your last game, say yes. Otherwise, say no. ", information.SkillRequest.Session));
            }

            return(ResponseCreator.Ask(game.Message, game.RepromptMessage, information.SkillRequest.Session));
        }
コード例 #7
0
        public HttpResponseMessage AddTooth(int orderId, int toothNo, int procedureId)
        {
            try
            {
                var order = m_repository.GetById(orderId);
                if (order == null)
                {
                    throw new EntityNotFoundException();
                }
                if (order.IsClosed)
                {
                    throw new EntityIsClosedException();
                }

                order.Teeth.Add(new ToothWork()
                {
                    ToothNo = toothNo, ProcedureId = procedureId
                });
                m_repository.Update(order);

                return(new HttpResponseMessage(HttpStatusCode.OK));
            }
            catch (EntityNotFoundException exp)
            {
                return(ResponseCreator.GenerateResponse(HttpStatusCode.NotFound, exp));
            }
            catch (EntityIsClosedException exp)
            {
                return(ResponseCreator.GenerateResponse(HttpStatusCode.Forbidden, exp));
            }
        }
コード例 #8
0
        public override SkillResponse HandleSyncRequest(AlexaRequestInformation <SkillRequest> information)
        {
            var    game    = (Game)information.Context;
            string message = "";

            switch (game.GameState)
            {
            case Enums.GameState.MainMenu:
                message = "You are in the main menu. Say new game to begin, or say rules to learn how to play. ";
                break;

            case Enums.GameState.PlayerTurn:
                message = "Here's a reference for all commands: 1. End turn. 2. Transform. 3. Assign tactical crew to weapons. 4. Fire weapons. 5. Fire stasis beam. 6. Recharge Shields. 7. Heal Crew. 8. Remove Threat. 9. Repair Hull. 10. Send crew on a mission. 11. Return crew from a mission. 12. I need more  time. 13. Status. 14. Threat status. 15. Threat information. ";
                break;

            case Enums.GameState.FiringWeapons:
                message = "You have assigned tactical crew to your weapons. Say fire weapons to open fire. ";
                break;

            case Enums.GameState.ContinueGamePrompt:
                message = "Say yes to continue playing your last unfinished game. Say no to go to the main menu.";
                break;

            case Enums.GameState.Rules:
                message = "Say next to continue to the next rule, back to go back to the previous rule, or repeat to repeat the current rule. You can say new game at any point to start a new game. ";
                break;
            }


            return(ResponseCreator.Ask(message, game.RepromptMessage, information.SkillRequest.Session));
        }
コード例 #9
0
        private Location GetLocation(int index)
        {
            var location = GeobaseStorage.LocationData[GeobaseStorage.LocationIndexData[index].location_index / sizeLocationElement];
            var ipInfo   = GeobaseStorage.IpData[GeobaseStorage.LocationIndexData[index].location_index / sizeLocationElement];

            return(ResponseCreator.CreateLocationItem(ipInfo, location));
        }
コード例 #10
0
        public override async Task <SkillResponse> Handle(AlexaRequestInformation <SkillRequest> information)
        {
            var    game    = (Game)information.Context;
            string message = "I'm sorry Captain, that is not a valid command. Say help if you need assistance. ";

            return(ResponseCreator.Ask(message, game.RepromptMessage, information.SkillRequest.Session));
        }
コード例 #11
0
        public async Task InvokeAsync(HttpContext context)
        {
            //save original readable stream in order  to write response to it
            var originalBodyStream = context.Response.Body;

            try
            {
                using (var responseBody = new MemoryStream())
                {
                    //make the response.body stream readable and empty
                    context.Response.Body = responseBody;

                    await _next(context);

                    //write the response made to the stream
                    using (var streamWriter = new StreamWriter(originalBodyStream))
                    {
                        var response = await ResponseCreator.CreateSuccessResponseAsync(context.Response, (int)HttpStatusCode.OK);

                        streamWriter.Write(response);
                    }
                }
            }
            finally
            {
                context.Response.Body = originalBodyStream;
            }
        }
コード例 #12
0
        private async Task HandleExceptionAsync(HttpContext context, Exception ex)
        {
            string exceptionResponse;

            if (ex.GetType() == typeof(EntityNotFoundException))
            {
                exceptionResponse = ResponseCreator.CreateBadResponse((int)HttpStatusCode.BadRequest,
                                                                      (int)ErrorCodes.EntityNotFoundError,
                                                                      ex.Message);
            }
            else if (ex.GetType() == typeof(DatabaseException))
            {
                exceptionResponse = ResponseCreator.CreateBadResponse((int)HttpStatusCode.BadRequest,
                                                                      (int)ErrorCodes.DatabaseError,
                                                                      ex.Message);
            }
            else if (ex.GetType() == typeof(ValidationException))
            {
                exceptionResponse = ResponseCreator.CreateBadResponse((int)HttpStatusCode.BadRequest,
                                                                      (int)ErrorCodes.ValidationError,
                                                                      ex.Message);
            }
            else
            {
                exceptionResponse = ResponseCreator.CreateBadResponse((int)HttpStatusCode.InternalServerError,
                                                                      (int)ErrorCodes.ServerError,
                                                                      "server error");
            }
            await ErrorResponseWriter.WriteExceptionResponseAsync(context, exceptionResponse);
        }
コード例 #13
0
        public override SkillResponse HandleSyncRequest(AlexaRequestInformation <SkillRequest> information)
        {
            var game = (Game)information.Context;

            if (!game.IsGameInProgress)
            {
                return(ResponseCreator.Ask("To get information about the current active threats, you need to start a new game. Say new game to begin. ", "To start, say new game. ", information.SkillRequest.Session));
            }

            if (game.ThreatManager.ExternalThreats.Count < 1 && game.ThreatManager.InternalThreats.Count < 1)
            {
                return(ResponseCreator.Ask("There are no active threats at the moment. Use the threat information command when you need information about an active threat. ", game.RepromptMessage, information.SkillRequest.Session));
            }

            string message  = "";
            var    request  = (IntentRequest)information.SkillRequest.Request;
            string threatId = request.Intent.Slots["Threat"].GetSlotId();
            var    threat   = game.ThreatManager.GetActiveThreat(threatId);

            if (threat == null)
            {
                string threatName = request.Intent.Slots["Threat"].Value;
                return(ResponseCreator.Ask($"{threatName} is not a valid active threat. Try the threat information command again and provide one of the following: {game.ThreatManager.GetThreatsAsString()}. ", game.RepromptMessage, information.SkillRequest.Session));
            }

            // valid active threat let's grab the info message
            message += threat.GetInfoMessage();
            message += "What are your orders, captain? ";

            game.Message = message;

            return(ResponseCreator.Ask(game.Message, game.RepromptMessage, information.SkillRequest.Session));
        }
コード例 #14
0
        public override SkillResponse HandleSyncRequest(AlexaRequestInformation <SkillRequest> information)
        {
            var game = (Game)information.Context;

            if (!game.IsGameInProgress)
            {
                return(ResponseCreator.Ask("You need to start a new game before healing your crew. Say new game to begin. ", "To start, say new game. ", information.SkillRequest.Session));
            }

            var ship = game.Ship as HalcyonShip;

            if (ship == null)
            {
                return(ResponseCreator.Ask("You cannot heal the crew in this ship. ", game.RepromptMessage, information.SkillRequest.Session));
            }
            if (!ship.Crew.Any(c => c.Type == Enums.CrewType.Medical && c.State == CrewState.Available))
            {
                return(ResponseCreator.Ask($"We have no available medical crew to heal our units in the infirmary. We have {ship.GetAvailableCrewAsString()}. ", game.RepromptMessage, information.SkillRequest.Session));
            }

            if (ship.InfirmaryCrewCount < 1)
            {
                return(ResponseCreator.Ask("There are no crew members in the infirmary. Use this command when someone ends up in the infirmary. ", game.RepromptMessage, information.SkillRequest.Session));
            }

            // we are good to go, heal the units in t he infirmary
            ship.HealCrew();

            game.Message        += "Awaiting further orders, captain. ";
            game.RepeatMessage   = game.Message;
            game.RepromptMessage = "Waiting for further orders, captain. ";
            game.SaveData();
            return(ResponseCreator.Ask(game.Message, game.RepromptMessage, information.SkillRequest.Session));
        }
コード例 #15
0
ファイル: ErrorMessageSender.cs プロジェクト: QResurgence/sst
        public static void SendError(byte[] destination, NetMQSocket socket, ErrorCode errorCode)
        {
            var response = ResponseCreator.Create(new NoEncryption(), destination, MessageType.Error,
                                                  JsonConvert.SerializeObject(errorCode));

            socket.SendMultipartMessage(response);
        }
コード例 #16
0
        public HttpResponseMessage Post(BaseBindingModel value)
        {
            try
            {
                DentalTechnican technican = m_repository.GetById(value.Id);
                technican.PersonInfo.Name       = value.Name;
                technican.PersonInfo.Surname    = value.Surname;
                technican.PersonInfo.Middlename = value.Middlename;
                m_repository.Update(technican);

                return(new HttpResponseMessage(HttpStatusCode.OK));
            }
            catch (EntityAlreadyExistsException exp)
            {
                return(ResponseCreator.GenerateResponse(HttpStatusCode.BadRequest, exp));
            }
            catch (EntityNotFoundException exp)
            {
                return(ResponseCreator.GenerateResponse(HttpStatusCode.NotFound, exp));
            }
            catch (Exception exp)
            {
                return(ResponseCreator.GenerateResponse(HttpStatusCode.InternalServerError, exp));
            }
        }
コード例 #17
0
        public override SkillResponse HandleSyncRequest(AlexaRequestInformation <SkillRequest> information)
        {
            var game = (Game)information.Context;

            if (!game.IsGameInProgress)
            {
                return(ResponseCreator.Ask("You need to start a new game before removing locked threats from your scanners. Say new game to begin. ", "To start, say new game. ", information.SkillRequest.Session));
            }

            var ship = game.Ship as HalcyonShip;

            if (ship == null)
            {
                return(ResponseCreator.Ask("You cannot remove the locked threats from  your scanners in this ship. ", game.RepromptMessage, information.SkillRequest.Session));
            }
            if (!ship.Crew.Any(c => c.Type == Enums.CrewType.Medical && c.State == CrewState.Available))
            {
                return(ResponseCreator.Ask($"We have no available medical crew to remove a locked threat from our scanners. We have {ship.GetAvailableCrewAsString()}. ", game.RepromptMessage, information.SkillRequest.Session));
            }

            if (ship.ScannerCount < 1)
            {
                return(ResponseCreator.Ask("There are no locked threats on our scannerse. Use this command when you roll a threat that gets locked on the scanners. ", game.RepromptMessage, information.SkillRequest.Session));
            }

            // we are good to go, remove a threat from the scanner
            ship.RemoveThreatFromScanner();

            game.Message        += "Awaiting further orders, captain. ";
            game.RepeatMessage   = game.Message;
            game.RepromptMessage = "Waiting for further orders, captain. ";
            game.SaveData();
            return(ResponseCreator.Ask(game.Message, game.RepromptMessage, information.SkillRequest.Session));
        }
コード例 #18
0
        public override SkillResponse HandleSyncRequest(AlexaRequestInformation <SkillRequest> information)
        {
            var    game    = (Game)information.Context;
            string message = "I'm sorry Captain, that is not a valid command. ";

            return(ResponseCreator.Ask(message, game.RepromptMessage, information.SkillRequest.Session));
        }
コード例 #19
0
        public async Task <string> FacebookResponse()
        {
            var result = await HttpContext.AuthenticateAsync(FacebookDefaults.AuthenticationScheme);


            var data = AuthResultParser.Parse(result);

            var user = await _service.CheckExistUser(data.Email);

            if (user == null)
            {
                user = await _service.Registration(new RegistrationViewModel
                {
                    Email     = data.Email,
                    FirstName = data.FirstName,
                    LastName  = data.LastName,
                    Password  = data.FirstName + data.LastName + data.UserName,
                    UserName  = data.UserName
                });
            }

            var token = Token.Create(user);

            var response = new
            {
                access_token = token,
                username     = user.UserName
            };

            return(ResponseCreator.Create(response));
        }
        private void HandleException(HttpContext context, Exception ex)
        {
            string exceptionResponse;

            if (ex.GetType() == typeof(NotFoundException))
            {
                exceptionResponse = ResponseCreator.CreateBadResponse((int)ErrorCode.NotFoundError,
                                                                      ex.Message);
            }
            else if (ex.GetType() == typeof(DBException))
            {
                exceptionResponse = ResponseCreator.CreateBadResponse((int)ErrorCode.DBError,
                                                                      ex.Message);
            }
            else if (ex.GetType() == typeof(PermissionException))
            {
                exceptionResponse = ResponseCreator.CreateBadResponse((int)ErrorCode.PermissionError,
                                                                      ex.Message);
            }
            else if (ex.GetType() == typeof(ValidationException))
            {
                exceptionResponse = ResponseCreator.CreateBadResponse((int)ErrorCode.ValidationError,
                                                                      ex.Message);
            }
            else
            {
                exceptionResponse = ResponseCreator.CreateBadResponse((int)ErrorCode.ServerError,
                                                                      "server error");
            }
            ErrorResposeWriter.WriteExceptionResponse(context, exceptionResponse);
        }
コード例 #21
0
        public HttpResponseMessage Post([FromBody] PatientBindingModel value)
        {
            try
            {
                Patient patient = m_repository.GetById(value.Id);
                patient.IsMen                 = value.IsMen;
                patient.MedicalCardNumber     = value.MedicalCardNumber;
                patient.PersonInfo.Name       = value.Name;
                patient.PersonInfo.Surname    = value.Surname;
                patient.PersonInfo.Middlename = value.Middlename;

                return(new HttpResponseMessage(HttpStatusCode.OK));
            }
            catch (EntityAlreadyExistsException exp)
            {
                return(ResponseCreator.GenerateResponse(HttpStatusCode.BadRequest, exp)); //new HttpResponseMessage(HttpStatusCode.BadRequest);
            }
            catch (EntityNotFoundException exp)
            {
                return(ResponseCreator.GenerateResponse(HttpStatusCode.NotFound, exp)); //new HttpResponseMessage(HttpStatusCode.BadRequest);
            }
            catch (Exception exp)
            {
                return(ResponseCreator.GenerateResponse(HttpStatusCode.InternalServerError, exp));//new HttpResponseMessage(HttpStatusCode.InternalServerError);
            }
        }
コード例 #22
0
        public IViewComponentResult Invoke(Endpoint endpoint, ResponseCreator responseCreator, int index)
        {
            ViewData["index"]        = index;
            ViewData["endpointName"] = endpoint.Name;

            if (responseCreator is FileResponse)
            {
                return(View("FileResponse", responseCreator as FileResponse));
            }
            else if (responseCreator is FileDynamicResponseCreator)
            {
                return(View("FileDynamicResponseCreator", responseCreator as FileDynamicResponseCreator));
            }
            else if (responseCreator is ForwardResponseCreator)
            {
                return(View("ForwardResponseCreator", responseCreator as ForwardResponseCreator));
            }
            else if (responseCreator is LiteralResponse)
            {
                return(View("LiteralResponse", responseCreator as LiteralResponse));
            }
            else
            {
                return(View(responseCreator));
            }
        }
コード例 #23
0
        async Task <TestableHttpResponse> GetResponseAsync(ResponseCreator responseCreator)
        {
            var request = new TestableHttpRequest(null, null);
            var retval  = new TestableHttpResponse();
            await responseCreator.CreateResponseAsync(request, new byte[0], retval, endpoint);

            return(retval);
        }
コード例 #24
0
        private void SendChallenge(byte[] requester, Guid requesterIdentity, RouterSocket router, Challenge challenge)
        {
            var challengeJson = JsonConvert.SerializeObject(challenge);
            var encryptor     = GetEncryptorFor(requesterIdentity);

            var response = ResponseCreator.Create(encryptor, requester, MessageType.SendChallenge, challengeJson);

            router.SendMultipartMessage(response);
        }
コード例 #25
0
ファイル: QueryMessage.cs プロジェクト: mrscylla/octotorrent
        protected QueryMessage(NodeId id, BEncodedString queryName, BEncodedDictionary queryArguments, ResponseCreator responseCreator)
            : base(QueryType)
        {
            Properties.Add(QueryNameKey, queryName);
            Properties.Add(QueryArgumentsKey, queryArguments);

            Parameters.Add(IdKey, id.BencodedString());
            ResponseCreator = responseCreator;
        }
コード例 #26
0
ファイル: BaseServer.cs プロジェクト: QResurgence/sst
        private void GrantCapability(Guid requesterIdentity, byte[] destination, CapabilityInfo info)
        {
            var infoJson  = JsonConvert.SerializeObject(info);
            var encryptor = _negotiator.GetEncryptorFor(requesterIdentity);

            var response = ResponseCreator.Create(encryptor, destination, MessageType.GrantCapability, infoJson);

            _router.SendMultipartMessage(response);
        }
コード例 #27
0
        protected QueryMessage(NodeId id, BEncodedString queryName, BEncodedDictionary queryArguments, ResponseCreator responseCreator)
            : base(QueryType)
        {
            properties.Add(QueryNameKey, queryName);
            properties.Add(QueryArgumentsKey, queryArguments);

            Parameters.Add(IdKey, id.BencodedString());
            ResponseCreator = responseCreator;
        }
コード例 #28
0
        public HttpResponseMessage CreateResponseMessage(HttpRequestMessage request)
        {
            HttpResponseMessage httpResponseMessage = ResponseCreator.CreateResponseFor(request, StatusCode);

            if (Headers != null && Headers.Count > 0)
            {
                Headers.ToList().ForEach(header => httpResponseMessage.Headers.Add(header.Key, header.Value));
            }

            httpResponseMessage.Headers.Location = Location;
            return(httpResponseMessage);
        }
コード例 #29
0
        public override SkillResponse HandleSyncRequest(AlexaRequestInformation <SkillRequest> information)
        {
            var game = (Game)information.Context;

            if (!game.IsGameInProgress)
            {
                return(ResponseCreator.Ask("You need to start a new game before firing the stasis beam. Say new game to begin. ", "To start, say new game. ", information.SkillRequest.Session));
            }

            var ship = game.Ship as HalcyonShip;

            if (ship == null)
            {
                return(ResponseCreator.Ask("Our ship does not have a stasis beam. ", game.RepromptMessage, information.SkillRequest.Session));
            }
            if (!ship.Crew.Any(c => c.Type == Enums.CrewType.Science && c.State == CrewState.Available))
            {
                return(ResponseCreator.Ask($"We have no available science crew to fire the stasis beam. We have {ship.GetAvailableCrewAsString()}. ", game.RepromptMessage, information.SkillRequest.Session));
            }

            if (game.ThreatManager.ExternalThreats.Count < 1 && game.ThreatManager.InternalThreats.Count < 1)
            {
                return(ResponseCreator.Ask("There are no threats to disable with the stasis beam. ", game.RepromptMessage, information.SkillRequest.Session));
            }

            if (ship.ShipSystems["ScienceUnavailable"])
            {
                return(ResponseCreator.Ask("Our science crew are having an existentialism crisis and are unavailable. Send a science crew on a mission to deal with cosmic existentialism to be able to use them again. ", game.RepromptMessage, information.SkillRequest.Session));
            }
            // check if enemy target is present
            var    request  = (IntentRequest)information.SkillRequest.Request;
            string threatId = request.Intent.Slots["Threat"].GetSlotId();
            var    threat   = game.ThreatManager.GetActiveThreat(threatId);

            if (threat == null)
            {
                string threatName = request.Intent.Slots["Threat"].Value;
                return(ResponseCreator.Ask($"{threatName} is not a valid target. Try firing the stasis beam again and provide one of the following: {game.ThreatManager.GetThreatsAsString()}. ", game.RepromptMessage, information.SkillRequest.Session));
            }
            // we have a valid target, let's check if it is already disabled
            if (threat.IsDisabled)
            {
                return(ResponseCreator.Ask($"{threat.Name} is already disabled. We can use the stasis beam on targets that are still active. ", game.RepromptMessage, information.SkillRequest.Session));
            }
            // we have a valid target, fire the stasis beam
            ship.FireStasisBeam(threat);

            game.Message        += "Awaiting further orders, captain. ";
            game.RepeatMessage   = game.Message;
            game.RepromptMessage = "Waiting for further orders, captain. ";
            game.SaveData();
            return(ResponseCreator.Ask(game.Message, game.RepromptMessage, information.SkillRequest.Session));
        }
コード例 #30
0
        //protected virtual ResponseDto PrepareCommonResponse<T1>(Action<T1> action, T1 param1)
        //{
        //    try
        //    {
        //        action.Invoke(param1);
        //        return ResponseCreator.CreateSuccessResponseDto();
        //    }
        //    catch (Exception e)
        //    {
        //        this.Log.Error(e);
        //        return ResponseCreator.CreateErrorResponseDto(EErrorCode.Unknow, e.Message);
        //    }
        //}

        //protected virtual ResponseDto PrepareCommonResponse<T1, T2>(Action<T1, T2> action, T1 param1, T2 param2)
        //{
        //    try
        //    {
        //        action.Invoke(param1, param2);
        //        return ResponseCreator.CreateSuccessResponseDto();
        //    }
        //    catch (Exception e)
        //    {
        //        this.Log.Error(e);
        //        return ResponseCreator.CreateErrorResponseDto(EErrorCode.Unknow, e.Message);
        //    }
        //}

        protected virtual ResponseWithDataDto <TResult> PrepareCommonResponseWithData <TResult>(Func <TResult> func)
        {
            try
            {
                TResult result = func.Invoke();
                return(ResponseCreator.CreateSuccessResponseWithDataDto(result));
            }
            catch (Exception e)
            {
                this.Log.Error(e);
                return(ResponseCreator.CreateErrorResponseWithDataDto <TResult>(EErrorCode.Unknow, e.Message));
            }
        }
コード例 #31
0
        public override SkillResponse HandleSyncRequest(AlexaRequestInformation <SkillRequest> information)
        {
            var game = (Game)information.Context;

            if (!game.IsGameInProgress)
            {
                return(ResponseCreator.Ask("You need to start a new game before ending your turn. Say new game to begin. ", "To start, say new game. ", information.SkillRequest.Session));
            }

            game.EndTurn();

            return(ResponseCreator.Ask(game.Message, game.RepromptMessage, information.SkillRequest.Session));
        }
コード例 #32
0
 protected QueryMessage(BEncodedDictionary d, ResponseCreator responseCreator)
     : base(d)
 {
     ResponseCreator = responseCreator;
 }
コード例 #33
0
 protected QueryMessage(NodeId id, BEncodedString queryName, ResponseCreator responseCreator)
     : this(id, queryName, new BEncodedDictionary(), responseCreator)
 {
 }
コード例 #34
0
 /// <summary>
 /// Allows for reponse creation on the request.
 /// </summary>
 /// <param name="responseCreator">The response creator.</param>
 public void AndRespond(ResponseCreator responseCreator)
 {
     ArgumentUtils.AssertNotNull(responseCreator, "responseCreator");
     this.responseCreator = responseCreator;
 }