コード例 #1
0
        private void SubmitRequest_Click(object sender, RoutedEventArgs e)
        {
            if (!string.IsNullOrWhiteSpace(RequestName.Text) && !string.IsNullOrWhiteSpace(RequestQuan.Text) && int.Parse(RequestQuan.Text) != 0)
            {
                try
                {
                    connection.Open();
                    MySqlCommand cmd = new MySqlCommand();
                    cmd.CommandText = "insert into requests(REQUEST_NAME,REQUEST_QUANTATY,REQUEST_STATUS) values(@requestname,@requestquan,@requeststs)";
                    cmd.Parameters.AddWithValue("@requestname", RequestName.Text);
                    cmd.Parameters.AddWithValue("@requestquan", int.Parse(RequestQuan.Text));
                    cmd.Parameters.AddWithValue("@requeststs", "notchecked");

                    cmd.Connection = connection;
                    cmd.ExecuteNonQuery();
                }
                catch (MySqlException ex)
                {
                    MessageBox.Show(ex.ToString());
                }
                finally
                {
                    connection.Close();
                    MessageBox.Show("Request Submited", "Success");
                    RequestName.Clear();
                    RequestQuan.Clear();
                }
            }
            else
            {
                MessageBox.Show("Please Provide Valid Inputs", "ERROR");
            }
        }
コード例 #2
0
        public void ReqRename(MsgPack pack)
        {
            RequestName data = pack.Msg.RequestName;
            NetMsg      msg  = new NetMsg
            {
                cmd = (int)Command.ResponseName
            };

            if (_cacheSvc.IsNameExist(data.Name))
            {
                //名字是否已经存在
                //存在:返回错误码
                msg.err = (int)ErrorCode.NameIsExist;
            }
            else
            {
                //不存在:更新缓存,以及数据库,再返回给客户端
                PlayerData playerData = _cacheSvc.GetPlayerDataBySession(pack.Session);
                playerData.Name = data.Name;
                if (!_cacheSvc.UpdatePlayerData(playerData.Id, playerData))
                {
                    msg.err = (int)ErrorCode.UpdateDbError;
                }
                else
                {
                    msg.ResponseName = new ResponseName
                    {
                        Name = data.Name
                    };
                }
            }
            pack.Session.SendMsg(msg);
        }
コード例 #3
0
 private void TabRequestClear()
 {
     // RequestRequestId.Clear();
     RequestName.Clear();
     RequestCreditType.Clear();
     RequestAmount.Clear();
     RequestCreditTypeIsAvailable.Clear();
 }
コード例 #4
0
        public string Request(RequestName requestName)
        {
            _logger.Info($"Request {requestName}");

            string response;

            switch (requestName)
            {
            case RequestName.Trips:
                response = @"<Trips>
                        <Trip>
                            <Supplier>SU</Supplier>
                            <Fligth>10</Fligth>
                        </Trip>
                        <Trip>
                            <Supplier>S7</Supplier>
                            <Fligth>11</Fligth>
                        </Trip>
                        <Trip>
                            <Supplier>N4</Supplier>
                            <Fligth>15</Fligth>
                        </Trip>
                        <Trip>
                            <Supplier>XX</Supplier>
                            <Fligth>20</Fligth>
                            <variants>
                                <variant>
                                    <segment operating_supplier='SU' marketing_supplier='S7'></segment>
                                    <segment operating_supplier='SU' marketing_supplier='S7'></segment>
                                </variant>
                                <variant>
                                    <segment operating_supplier='AA' marketing_supplier='BB'></segment>
                                    <segment operating_supplier='AA' marketing_supplier='BB'></segment>
                                </variant>
                            </variants>
                        </Trip>
                    </Trips>";
                break;

            case RequestName.FareRules:
                response = @"<fareremark>
                        <remark new_fare='true'>some text 1</remark>
                        <remark new_fare='true'>some text 2</remark>
                        <remark new_fare='true'>some text 3</remark>
                        <remark new_fare='true'>some text 4</remark>
                    </fareremark>";
                break;

            default:
                throw new Exception($"Unknown request name {requestName}");
            }

            _logger.Info($"Response {response}");

            return(response);
        }
 /// <summary>Snippet for Method1</summary>
 /// <remarks>
 /// This snippet has been automatically generated for illustrative purposes only.
 /// It may require modifications to work in your environment.
 /// </remarks>
 public void Method1ResourceNames()
 {
     // Create client
     ResourceNameSeparatorClient resourceNameSeparatorClient = ResourceNameSeparatorClient.Create();
     // Initialize request argument(s)
     RequestName name = RequestName.FromItemAItemBDetailsADetailsBDetailsCExtra("[ITEM_A_ID]", "[ITEM_B_ID]", "[DETAILS_A_ID]", "[DETAILS_B_ID]", "[DETAILS_C_ID]", "[EXTRA_ID]");
     RequestName @ref = RequestName.FromItemAItemBDetailsADetailsBDetailsCExtra("[ITEM_A_ID]", "[ITEM_B_ID]", "[DETAILS_A_ID]", "[DETAILS_B_ID]", "[DETAILS_C_ID]", "[EXTRA_ID]");
     // Make the request
     Response response = resourceNameSeparatorClient.Method1(name, @ref);
 }
コード例 #6
0
        /// <summary>
        /// Request name change event handler.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void RequestName_Changed(object sender, EventArgs e)
        {
            ActiveRequest.Name = RequestName.Text;
            bool invalid = RequestName.Text.Length == 0;

            InvalidRequestName.Visible = invalid;
            if (invalid)
            {
                RequestName.SetFocus();
            }
            CurrentMainWindow.UpdateTreeStoreText(ActualPosition, ActiveRequest.Name);
        }
 /// <summary>Snippet for Method1</summary>
 /// <remarks>
 /// This snippet has been automatically generated for illustrative purposes only.
 /// It may require modifications to work in your environment.
 /// </remarks>
 public void Method1RequestObject()
 {
     // Create client
     ResourceNameSeparatorClient resourceNameSeparatorClient = ResourceNameSeparatorClient.Create();
     // Initialize request argument(s)
     Request request = new Request
     {
         RequestName      = RequestName.FromItemAItemBDetailsADetailsBDetailsCExtra("[ITEM_A_ID]", "[ITEM_B_ID]", "[DETAILS_A_ID]", "[DETAILS_B_ID]", "[DETAILS_C_ID]", "[EXTRA_ID]"),
         RefAsRequestName = RequestName.FromItemAItemBDetailsADetailsBDetailsCExtra("[ITEM_A_ID]", "[ITEM_B_ID]", "[DETAILS_A_ID]", "[DETAILS_B_ID]", "[DETAILS_C_ID]", "[EXTRA_ID]"),
     };
     // Make the request
     Response response = resourceNameSeparatorClient.Method1(request);
 }
        /// <summary>Snippet for Method1Async</summary>
        public async Task Method1ResourceNamesAsync()
        {
            // Snippet: Method1Async(RequestName, RequestName, CallSettings)
            // Additional: Method1Async(RequestName, RequestName, CancellationToken)
            // Create client
            ResourceNameSeparatorClient resourceNameSeparatorClient = await ResourceNameSeparatorClient.CreateAsync();

            // Initialize request argument(s)
            RequestName name = RequestName.FromItemAItemBDetailsADetailsBDetailsCExtra("[ITEM_A_ID]", "[ITEM_B_ID]", "[DETAILS_A_ID]", "[DETAILS_B_ID]", "[DETAILS_C_ID]", "[EXTRA_ID]");
            RequestName @ref = RequestName.FromItemAItemBDetailsADetailsBDetailsCExtra("[ITEM_A_ID]", "[ITEM_B_ID]", "[DETAILS_A_ID]", "[DETAILS_B_ID]", "[DETAILS_C_ID]", "[EXTRA_ID]");
            // Make the request
            Response response = await resourceNameSeparatorClient.Method1Async(name, @ref);

            // End snippet
        }
コード例 #9
0
        public void RequestSimData(RequestName requestName, DataStructName dataStructName)
        {
            #region HELP
            // RequestID: Specifies the ID of the client defined request. This is used later by the client to identify which data has been received. This value should be unique for each request, re-using a RequestID will overwrite any previous request using the same ID.

            // DefineID: Specifies the ID of the client defined data definition.

            // dwRadiusMeters: Double word containing the radius in meters.If this is set to zero only information on the user aircraft will be returned, although this value is ignored if type is set to SIMCONNECT_SIMOBJECT_TYPE_USER.The error SIMCONNECT_EXCEPTION_OUT_OF_BOUNDS will be returned if a radius is given and it exceeds the maximum allowed(200000 meters, or 200 Km).

            // type: Specifies the type of object to receive information on.One member of the SIMCONNECT_SIMOBJECT_TYPE enumeration type.

            // user example: simConnect.RequestDataOnSimObjectType(requestType, dataType, 0, SIMCONNECT_SIMOBJECT_TYPE.USER);
            #endregion

            switch (dataStructName)             // which DataStructName data struct is being requested?
            {
            case DataStructName.SimDataAircraft:
            {
                switch (requestName)                                 // which RequestName request is being requested?
                {
                case RequestName.User:
                {
                    // must abort if we hit a return rate limit, as the SimConnect API will just overwrite duplicates which would hang the REST API
                    if (awaitSimConnectRequests[(int)requestName])
                    {
                        return;                                                                                                // abort
                    }
                    simConnect.RequestDataOnSimObjectType(requestName, dataStructName, 0, SIMCONNECT_SIMOBJECT_TYPE.USER);
                    awaitSimConnectRequests[(int)requestName] = true;
                    break;
                }

                default:
                {
                    // unknown request name, ignore
                    break;
                }
                }
                break;
            }

            default:
            {
                // unknown data type, ignore
                break;
            }
            }
        }
コード例 #10
0
        public virtual Task Middleware(Microsoft.AspNetCore.Http.HttpContext context, Func <Task> next)
        {
            var operationName = context.Request.GetOperationName().UrlDecode() ?? "Home";

            var httpReq = context.ToRequest(operationName);
            var httpRes = httpReq.Response;

            if (!RequestName.IsNullOrEmpty())
            {
                operationName = RequestName;
            }

            var task = ProcessRequestAsync(httpReq, httpRes, operationName);

            HostContext.Async.ContinueWith(httpReq, task, x => httpRes.Close(), TaskContinuationOptions.OnlyOnRanToCompletion | TaskContinuationOptions.AttachedToParent);
            return(task);
        }
コード例 #11
0
        public void Method1()
        {
            moq::Mock <ResourceNameSeparator.ResourceNameSeparatorClient> mockGrpcClient = new moq::Mock <ResourceNameSeparator.ResourceNameSeparatorClient>(moq::MockBehavior.Strict);
            Request request = new Request
            {
                RequestName      = RequestName.FromItemAItemBDetailsADetailsBDetailsCExtra("[ITEM_A_ID]", "[ITEM_B_ID]", "[DETAILS_A_ID]", "[DETAILS_B_ID]", "[DETAILS_C_ID]", "[EXTRA_ID]"),
                RefAsRequestName = RequestName.FromItemAItemBDetailsADetailsBDetailsCExtra("[ITEM_A_ID]", "[ITEM_B_ID]", "[DETAILS_A_ID]", "[DETAILS_B_ID]", "[DETAILS_C_ID]", "[EXTRA_ID]"),
            };
            Response expectedResponse = new Response {
            };

            mockGrpcClient.Setup(x => x.Method1(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse);
            ResourceNameSeparatorClient client = new ResourceNameSeparatorClientImpl(mockGrpcClient.Object, null, null);
            Response response = client.Method1(request.Name, request.Ref);

            xunit::Assert.Same(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
コード例 #12
0
        public async stt::Task Method1Async()
        {
            moq::Mock <ResourceNameSeparator.ResourceNameSeparatorClient> mockGrpcClient = new moq::Mock <ResourceNameSeparator.ResourceNameSeparatorClient>(moq::MockBehavior.Strict);
            Request request = new Request
            {
                RequestName      = RequestName.FromItemAItemBDetailsADetailsBDetailsCExtra("[ITEM_A_ID]", "[ITEM_B_ID]", "[DETAILS_A_ID]", "[DETAILS_B_ID]", "[DETAILS_C_ID]", "[EXTRA_ID]"),
                RefAsRequestName = RequestName.FromItemAItemBDetailsADetailsBDetailsCExtra("[ITEM_A_ID]", "[ITEM_B_ID]", "[DETAILS_A_ID]", "[DETAILS_B_ID]", "[DETAILS_C_ID]", "[EXTRA_ID]"),
            };
            Response expectedResponse = new Response {
            };

            mockGrpcClient.Setup(x => x.Method1Async(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <Response>(stt::Task.FromResult(expectedResponse), null, null, null, null));
            ResourceNameSeparatorClient client = new ResourceNameSeparatorClientImpl(mockGrpcClient.Object, null, null);
            Response responseCallSettings      = await client.Method1Async(request.Name, request.Ref, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None));

            xunit::Assert.Same(expectedResponse, responseCallSettings);
            Response responseCancellationToken = await client.Method1Async(request.Name, request.Ref, st::CancellationToken.None);

            xunit::Assert.Same(expectedResponse, responseCancellationToken);
            mockGrpcClient.VerifyAll();
        }
コード例 #13
0
        public string Request(RequestName requestName)
        {
            _logger.Info($"Request {requestName}");

            string response;

            switch (requestName)
            {
            case RequestName.Flights:
                response = @"{
                        ""flights"":[
                            {
                                ""segments"":[
                                    {
                                        ""operating_supplier"":""SU"",
                                        ""marketing_supplier"":""SU""
                                    }
                                ]
                            }
                        ]
                    }";
                break;

            case RequestName.FareConditions:
                response = @"{
                        ""fare_conditions"": [
                            ""text_1"",
                            ""text_2""
                        ]
                    }";
                break;

            default:
                throw new Exception($"Unknown request name {requestName}");
            }

            _logger.Info($"Response {response}");

            return(response);
        }
コード例 #14
0
        public IAsyncResult BeginProcessRequest(HttpContext context, AsyncCallback cb, Object extraData)
        {
            Debug.Assert(!string.IsNullOrEmpty(this.RequestName));

            AsyncOperation asyncOp = new AsyncOperation(cb, context, extraData, this, ServicePath, RequestName.ToLower());

            if (!asyncOp.IsAsync)
            {
                // Continue tracing if traceId & spanId are provided in request header
                var traceIdString = context.Request.Headers[ServiceUtils.TRACE_ID_HTTP_HEADER] ?? context.Request.Headers[ServiceUtils.ESB_TRACE_ID_HTTP_HEADER];
                if (!string.IsNullOrWhiteSpace(traceIdString))
                {
                    context.Response.AddHeader(ServiceUtils.TRACE_ID_HTTP_HEADER, traceIdString);
                }
                var parentSpanIdString = context.Request.Headers[ServiceUtils.SPAN_ID_HTTP_HEADER] ?? context.Request.Headers[ServiceUtils.ESB_SPAN_ID_HTTP_HEADER];
                if (traceIdString != null && parentSpanIdString != null)
                {
                    try
                    {
                        var traceId      = long.Parse(traceIdString);
                        var parentSpanId = long.Parse(parentSpanIdString);
                    }
                    catch (Exception)
                    {
                        // no tracing
                    }
                }

                asyncOp.ContinueCatTransaction();
            }
            else
            {
                HostContext.Instance.Request.Items[ServiceCatConstants.SOA2AsyncServiceStartTimeKey] = DateTime.Now;
            }

            try
            {
                //检查单个IP的连接数是否超标
                CheckConnectionMaxRequestCount(context);
                //电容保护针对每个方法
                var hystrixCommand = EndpointHost.Config.MetadataMap[ServicePath].GetHystrixCommandByOpName(this.RequestName);
                var hystrixMetrics = hystrixCommand.Metrics;

                var hystrixCircuitBreaker = hystrixCommand.CircuitBreaker;
                // We fallback if circuit is open
                if (!hystrixCircuitBreaker.AllowRequest())
                {
                    hystrixMetrics.MarkShortCircuited();
                    //设置_slaErrorSent
                    asyncOp.SendSyncSLAErrorResponse(HystrixEventType.ShortCircuited);
                    if (asyncOp.IsAsync)
                    {
                        // var message = "Circuit Breaker is open. Server entered into self-protecting mode";
                    }
                    return(asyncOp);
                }

                if (asyncOp.IsAsync)
                {
                    // The circuit is healthy, We can start async work
                    hystrixMetrics.IncrementConcurrentExecutionCount();
                    EndpointHost.Config.MetadataMap[ServicePath].IncrementConcurrentExecutionCount();
                    asyncOp.StartAsyncWork();
                }
                else // sync mode
                {
                    asyncOp.StartSyncWork();
                }

                return(asyncOp);
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
            }
        }