コード例 #1
0
ファイル: service.aspx.cs プロジェクト: radtek/ClearView
        protected void Page_Load(object sender, EventArgs e)
        {
            Services oService = new Services(intProfile, dsn);
            Requests oRequest = new Requests(intProfile, dsn);

            if (Int32.TryParse(Request.Cookies["profileid"].Value, out intProfile) == true)
            {
                int intService = 0;
                if (Int32.TryParse(Request.Cookies["sid"].Value, out intService) == true)
                {
                    int intProject = 0;
                    Int32.TryParse(Request.Cookies["pid"].Value, out intProject);

                    int intRequest = 0;
                    Int32.TryParse(Request.Cookies["rid"].Value, out intRequest);

                    int intNewRequest = 0;
                    if (intRequest == 0)
                    {
                        if (oService.Get(intService, "project") == "1" && intProject == 0)
                        {
                            Response.Write("Service " + oService.GetName(intService).ToUpper() + " requires a project. Please specify a projectid (pid=) or a requestid (rid=)");
                        }
                        else
                        {
                            intNewRequest = oRequest.Add((intProject == 0 ? -1 : intProject), intProfile);
                        }
                    }
                    else
                    {
                        DataSet dsR = oRequest.Get(intRequest);
                        if (dsR.Tables[0].Rows.Count > 0)
                        {
                            intProject    = Int32.Parse(dsR.Tables[0].Rows[0]["projectid"].ToString());
                            intNewRequest = oRequest.Add(intProject, intProfile);
                        }
                    }

                    if (intNewRequest > 0)
                    {
                        string          strQ            = Request.QueryString["q"];
                        ServiceRequests oServiceRequest = new ServiceRequests(intProfile, dsn);
                        RequestItems    oRequestItem    = new RequestItems(intProfile, dsn);
                        Pages           oPage           = new Pages(intProfile, dsn);
                        oServiceRequest.Add(intNewRequest, 1, 0);
                        oService.AddSelected(intNewRequest, intService, 1);
                        int intItem = oService.GetItemId(intService);
                        oRequestItem.AddForm(intNewRequest, intItem, intService, 1);
                        Response.Redirect(oPage.GetFullLink(intResourceRequest) + "?rid=" + intNewRequest.ToString() + "&q=" + strQ);
                    }
                }
            }
            else
            {
                Response.Redirect("/redirect.aspx?referrer=" + Request.Url.PathAndQuery);
            }
        }
コード例 #2
0
        protected async override Task <HttpResponseMessage> SendAsync(
            HttpRequestMessage request,
            CancellationToken cancellationToken)
        {
            string content = request.Content == null
                ? null
                : await request.Content.ReadAsStringAsync().ConfigureAwait(false);

            RequestContents.Add(content);

            if (OnSendingRequest != null)
            {
                Requests.Add(await OnSendingRequest(request).ConfigureAwait(false));
            }
            else
            {
                Requests.Add(request);
            }

            if (_responseIndex < Responses.Count)
            {
                return(Responses[_responseIndex++]);
            }

            return(_nullResponse);
        }
コード例 #3
0
        /// <summary>
        /// Request to join a room
        /// </summary>
        /// <param name="roomID">Requested room ID</param>
        /// <param name="player">Player who request it</param>
        private void JoinRequest(int roomID, Player player)
        {
            Room r = Room.Search(roomID, rooms);

            if (r != null)
            {
                if (r.Player2 == null)
                {
                    if (!Requests.ContainsKey(r.Player1))
                    {
                        Requests.Add(r.Player1, new System.Collections.Generic.Queue <Player>());
                        Requests[r.Player1].Enqueue(player);
                    }
                    else
                    {
                        Requests[r.Player1].Enqueue(player);
                    }
                    string s = "request;" + player.Name;
                    Send(Connections[r.Player1], s);
                }
                else
                {
                    string s = "sorry;";
                    Send(Connections[player], s);
                }
            }
        }
コード例 #4
0
        private async Task ProcessCore(HttpMessage message)
        {
            if (!(message.Request is MockRequest request))
            {
                throw new InvalidOperationException("the request is not compatible with the transport");
            }

            lock (_syncObj)
            {
                Requests.Add(request);
            }

            if (RequestGate != null)
            {
                message.Response = await RequestGate.WaitForRelease(request);
            }
            else
            {
                message.Response = _responseFactory(request);
            }

            message.Response.ClientRequestId = request.ClientRequestId;

            if (message.Response.ContentStream != null && ExpectSyncPipeline != null)
            {
                message.Response.ContentStream = new AsyncValidatingStream(!ExpectSyncPipeline.Value, message.Response.ContentStream);
            }
        }
コード例 #5
0
        public void RefreshServerRequests(ServerRequest[] serverRequests)
        {
            var bytesSentMap = new Dictionary <string, long>();

            foreach (var serverRequest in serverRequests)
            {
                var remoteAddress        = serverRequest.RemoteAddress ?? "";
                var bytesSentToOtherPort = 0L;
                if (!bytesSentMap.TryGetValue(remoteAddress, out bytesSentToOtherPort))
                {
                    bytesSentMap.Add(remoteAddress, 0L);
                }
                var bytesSent = bytesSentToOtherPort + serverRequest.BytesSent;
                bytesSentMap[remoteAddress] = bytesSent;

                var model = Requests.FirstOrDefault(r => r.RemoteAddr == remoteAddress);
                if (model == null)
                {
                    model = new ServerRequestModel(serverRequest);
                    Requests.Add(model);
                }
                else
                {
                    model.RefreshFromServerRequest(serverRequest);
                    model.Bytes = bytesSent;
                }
            }

            foreach (var deletedRequest in Requests.Where(r => !bytesSentMap.ContainsKey(r.RemoteAddr)).ToArray())
            {
                Requests.Remove(deletedRequest);
            }

            Requests.Sort((lhs, rhs) => String.Compare(lhs.RemoteAddr, rhs.RemoteAddr));
        }
コード例 #6
0
            public void Close()
            {
                Cycle c;

                foreach (var n in InternalNodes)
                {
                    foreach (var ep in n.Requests)
                    {
                        if (Owner.cycleMap.TryFindValue((Node)ep.Target, out c) && c == this)
                        {
                            InternalEnds.Add(ep);
                        }
                        else
                        {
                            Requests.Add(ep);
                        }
                    }

                    foreach (var ep in n.Provides)
                    {
                        if (!Owner.cycleMap.TryFindValue((Node)ep.Target, out c) || c != this)
                        {
                            Provides.Add(ep);
                        }
                    }
                }
            }
コード例 #7
0
        /// <summary>
        /// Запускает выполнение указанного запроса.
        /// Если загрузчик приостановлен, то просто добавляет в коллекцию запросов
        /// до тех пор, пока загрузчик не будет возобновлен.
        ///
        /// Выбрасывает <see cref="RequestAlreadyExistsDownloaderException"/>,
        /// если запрос с таким же идентификатором уже выполняется.
        ///
        /// Выбрасывает <see cref="NoNetworkDownloaderException"/>
        /// при отсутствии подключения к интернету
        /// </summary>
        /// <param name="request"></param>
        public void ExecuteRequest(DownloadRequest request)
        {
            if (!NetworkInterface.GetIsNetworkAvailable())
            {
                throw new NoNetworkDownloaderException();
            }

            if (ContainsRequest(request.ID))
            {
                throw new RequestAlreadyExistsDownloaderException($"Запрос с идентификатором '{request.ID.GetID()}' уже выполняется");
            }

            request.Completed += OnRequestCompleted;

            Requests.Add(request.ID, request);

            if (State == DownloaderState.Sleep)
            {
                State = DownloaderState.Active;
            }
            if (State == DownloaderState.Active)
            {
                request.Execute();
            }
        }
コード例 #8
0
        internal static SimVarRequest AddRequest(SimConnectVariable request)
        {
            SimVarRequest simReq;

            lock (Requests)
            {
                if (Requests.Any(x => x.Value.Name.Equals(request.Name, StringComparison.InvariantCultureIgnoreCase) &&
                                 x.Value.Unit.Equals(request.Unit, StringComparison.InvariantCultureIgnoreCase)))
                {
                    // Re-use a previously requested variable for retransmission to SimConnect
                    var reqId = GetRequestId(request);
                    simReq = new SimVarRequest
                    {
                        ID      = reqId,
                        Request = request
                    };
                }
                else
                {
                    // Fetch the values suitable for transmission to SimConnect
                    simReq = new SimVarRequest
                    {
                        ID      = RequestID++,
                        Request = request
                    };
                    // New SimVar requested - add it to our list
                    Requests.Add((int)simReq.ReqID, simReq.Request);
                }
            }
            return(simReq);
        }
コード例 #9
0
        protected override Task <HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
        {
            Requests.Add(request);
            if (!RequestHandlers.Any())
            {
                return(Task.FromResult <HttpResponseMessage>(null));
            }

            var count = Responses.Count();

            if (RequestHandlers.Count() > count)
            {
                var response = RequestHandlers.Skip(count).First().Invoke(request);
                Responses.Add(response);
                return(Task.FromResult(response));
            }

            if (RepeatLastHandler)
            {
                var response = RequestHandlers.Last().Invoke(request);
                Responses.Add(response);
                return(Task.FromResult(response));
            }


            Assert.Fail("Not enough handlers defined for this test and RepeatLastHandler set to false.");
            return(Task.FromResult <HttpResponseMessage>(null));
        }
コード例 #10
0
        /// <summary>
        /// Adds a new resolve request to the chain of requests being made in the graph. Resolve
        /// requests can be nested.
        /// </summary>
        /// <param name="service">
        /// The <see cref="Service"/> being resolved in the operation.
        /// </param>
        /// <param name="component">
        /// The display name of the component that should fulfill the service.
        /// </param>
        /// <param name="decoratorTarget">
        /// If this is a request where the result service is being decorated, this is the thing
        /// that's being decorated in this request. This value will be <see langword="null"/>
        /// if this isn't a decorator operation.
        /// </param>
        public void OnRequestStart(Service service, string component, string?decoratorTarget)
        {
            var request = new ResolveRequestNode(component);

            request.Services.Add(service, Guid.NewGuid());
            Requests.Add(request);
            if (decoratorTarget is object)
            {
                request.DecoratorTarget = decoratorTarget;
            }

            if (CurrentRequest.Count != 0)
            {
                // We're already in a request, so add an edge from
                // the parent to this new request/service.
                var parent = Requests[CurrentRequest.Peek()];
                parent.Edges.Add(new GraphEdge(request.Id, service));
            }
            else
            {
                // The initiating request will be the first request we see.
                OriginatingRequest = request.Id;
            }

            // The inbound request is the new current.
            CurrentRequest.Push(request.Id);
        }
コード例 #11
0
        /// <summary>
        /// Create new empty request in list.
        /// </summary>
        public Request CreateNewRequest()
        {
            // Get max ID
            int _requestId = 1, _position = 1;

            // There are some members of request in list (get Max)
            if (Requests.Count > 0)
            {
                _requestId = Requests.Max(x => x.Id) + 1;
                _position  = Requests.Max(x => x.Position) + 1;
            }

            // Create request
            Request ret = new Request(_requestId, _position, Director.Properties.Resources.NewRequestName)
            {
                ParentScenario = this,
                Url            = ParentServer.GetUrl()
            };

            // Copy Server Headers
            foreach (var h in ParentServer.DefaultHeaders)
            {
                ret.Headers.Add(new Header(h));
            }

            // Add new request
            Requests.Add(ret);

            // Return request
            return(ret);
        }
コード例 #12
0
 void Write(string Method, params string[] Params)
 {
     if (Client.Connected)
     {
         try
         {
             string s = reqID + ":" + Method + ":";
             foreach (string p in Params)
             {
                 s += p + ":";
             }
             string hash = computehash(s + challenge + ":" + apikey);
             s = s + hash + "\n";
             byte[] bytes = new byte[s.Length];
             for (int i = 0; i < s.Length; i++)
             {
                 bytes[i] = (byte)s[i];
             }
             Requests.Add(reqID++, Method);
             Client.GetStream().Write(bytes, 0, bytes.Length);
         }
         catch
         {
             Parent.updateStatus("It seems an error has occured!");
         }
     }
 }
コード例 #13
0
        internal Request CreateQuarantinedRequest(Ranking ranking, DateTimeOffset creationTime, Quarantine quarantine)
        {
            var request = new Request(ranking, creationTime, quarantine);

            Requests.Add(request);
            return(request);
        }
コード例 #14
0
        internal Request CreateRequest(Ranking ranking, DateTimeOffset?newRequestExpiry, DateTimeOffset newRequestCreationTime, bool isTerminalRequest = false)
        {
            var request = new Request(ranking, newRequestExpiry, newRequestCreationTime, isTerminalRequest);

            Requests.Add(request);
            return(request);
        }
コード例 #15
0
        public Client(int port)
        {
            this.port = port;

            socket         = new Socket(SocketType.Stream, ProtocolType.Tcp);
            bufferedClient = new BufferedTcpClient(socket, request => Requests.Add(Encoding.UTF8.GetString(request.ToArray())));
        }
コード例 #16
0
        protected void btnFavorite_Click(Object Sender, EventArgs e)
        {
            int intRequest = 0;

            if (intRequest == 0)
            {
                intRequest = oRequest.Add(-1, intProfile);
                oServiceRequest.Add(intRequest, 1, -2);
            }
            string strHidden = Request.Form[hdnService.UniqueID];

            while (strHidden != "")
            {
                string strField = strHidden.Substring(0, strHidden.IndexOf("&"));
                strHidden = strHidden.Substring(strHidden.IndexOf("&") + 1);
                string strFlag = strField.Substring(strField.IndexOf("_") + 1);
                strField = strField.Substring(0, strField.IndexOf("_"));
                if (strFlag == "1")
                {
                    oService.AddSelected(intRequest, Int32.Parse(strField), 1);
                }
            }
            oServiceRequest.Update(intRequest, -1);
            Response.Redirect(oPage.GetFullLink(intViewRequest) + "?rid=" + intRequest.ToString());
        }
コード例 #17
0
        public Task <HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
        {
            Requests.Add(request);
            HttpResponseMessage responseMessage = new HttpResponseMessage(StatusCode);

            responseMessage.Content = new StreamContent(ResponseContent);
            return(Task.FromResult(responseMessage));
        }
コード例 #18
0
        public override IMirthConnectRequest Create(string path)
        {
            var request = new MockMirthConnectRequest(HttpWebRequestFactory, string.Concat(BaseUrl, path));

            Requests.Add(request);

            return(request);
        }
コード例 #19
0
 public static void AddRequest(this IWebBrowser webBrowser, IRequest request)
 {
     if (Requests == null)
     {
         Requests = new List <IRequest>();
     }
     Requests.Add(request);
 }
コード例 #20
0
        /// <summary>
        /// Add an operation to be processed
        /// </summary>
        /// <param name="operation"></param>
        /// <returns>MultiCallRequest</returns>
        public MultiCallRequest AddOperation(MultiCallOperation operation)
        {
            if (operation != null)
            {
                Requests.Add(operation);
            }

            return(this);
        }
コード例 #21
0
ファイル: NitrogenSports.cs プロジェクト: zsux/DiceBot
        void GetStats()
        {
            Thread.Sleep(1);
            string t = CreateRandomString();
            string s = "[2,\"0." + t + "\",\"game\",{}]";

            Requests.Add(t, 1);
            NSSocket.Send(s);
        }
コード例 #22
0
        public async Task AddRequest(MessengerRequest request, int targetId)
        {
            if (!Requests.ContainsKey(request.Id))
            {
                await _dao.AddPlayerFriendRequestAsync(request.Id, targetId);

                Requests.Add(request.Id, request);
            }
        }
コード例 #23
0
        /// <summary>
        /// Add a request to be processed
        /// </summary>
        /// <param name="request"></param>
        /// <returns>MultiCallRequest</returns>
        public MultiCallRequest AddRequest(Request request)
        {
            if (request != null)
            {
                Requests.Add(request);
            }

            return(this);
        }
コード例 #24
0
        private void StartApiStub()
        {
            CallsMade = 0;
            Requests.Clear();
            ReceivedCorrelationIds.Clear();

            Task.Run(() =>
            {
                _httpListener = new HttpListener();
                _httpListener.Prefixes.Add(ApiRoute);
                _httpListener.Start();

                // GetContext method blocks while waiting for a request.
                while (true)
                {
                    HttpListenerContext context = _httpListener.GetContext();
                    CallsMade++;
                    Requests.Add(context.Request);
                    HttpListenerResponse response = context.Response;

                    var passedToken = context.Request.Headers["Authorization"] ?? context.Request.Headers["x-api-key"];
                    if (!string.IsNullOrEmpty(ApiToken) && passedToken != ApiToken)
                    {
                        response.StatusCode = (int)HttpStatusCode.Unauthorized;
                        throw new UnauthorizedAccessException("Request headers do not contain `Authorization` or `x-api-key` keys");
                    }
                    else
                    {
                        ReceivedCorrelationIds.Add(context.Request.Headers["x-correlation-id"]);
                        var thisResponse = ResponseObject;
                        if (Responses.Any())
                        {
                            var requestedId = context.Request.Url.Segments.Last();
                            thisResponse    = Responses.ContainsKey(requestedId) ? Responses[requestedId] : null;
                        }

                        response.StatusCode = (int)((thisResponse is null) ? HttpStatusCode.NotFound : HttpStatusCode.OK);
                        string responseBody = string.Empty;
                        if (thisResponse is null)
                        {
                            responseBody = context.Request.Url.Segments.Last();
                        }
                        else
                        {
                            responseBody = JsonSerializer.Serialize(thisResponse, _jsonOptions);
                        }
                        Stream stream = response.OutputStream;
                        using (var writer = new StreamWriter(stream))
                        {
                            writer.Write(responseBody);
                            writer.Close();
                        }
                    }
                }
            });
        }
コード例 #25
0
        public void LoadJRIntoListbox()
        {
            var requests = _dataservice.getAllRequests();

            Requests.Clear();
            foreach (var request in requests)
            {
                Requests.Add(request);
            }
        }
コード例 #26
0
 /// <summary>
 /// Adds another request to this task on-the-fly.
 /// </summary>
 /// <param name="request">The request that shall also be completed by this task.</param>
 public void AddRequest(InsertRequest request)
 {
     Instance.ResourceManager.RemoveStoreRequest(request);
     if (!ReservedPod.Fits(request.Bundle))
     {
         throw new InvalidOperationException("Cannot add a request for a bundle not fitting the pod!");
     }
     Requests.Add(request);
     request.StatInjected = true;
 }
コード例 #27
0
        /// <summary>
        /// Generate request
        /// AKA
        /// Calc next request arrival time
        /// </summary>
        /// <param name="currentMinute">System current minute</param>
        /// <returns>Generated request</returns>
        private Request GenerateRequest(int currentMinute)
        {
            int     minutesToProcess = CalculateProcessingTime();
            int     timeOfArrival    = CalculteArrivingTime() + currentMinute;
            Request request          = new Request(timeOfArrival, minutesToProcess, RequestWorth);

            Requests.Add(request);

            return(request);
        }
コード例 #28
0
ファイル: ToneBanks.cs プロジェクト: X-Lars/IntegraXL
        private GM2ToneBank(Integra device) : base(device)
        {
            Name = "GM2 Tones";

            Requests.Clear();

            Requests.Add(new IntegraRequest(0x7900007F));
            Requests.Add(new IntegraRequest(0x79013B7F));
            Requests.Add(new IntegraRequest(0x79027F02));
        }
コード例 #29
0
            // Carmelo
            private async Task GetRequestApplicationPoolAsync()
            {
                var appPool    = Current.Settings.WebServer.AppPool;
                var timeElaped = Current.Settings.WebServer.TimeElapsed;

                try
                {
                    if (Category.Name == "Web Servers Recuper@")
                    {
                        Requests.Clear();

                        var proc = new Process
                        {
                            StartInfo = new ProcessStartInfo
                            {
                                FileName               = Path.Combine(Current.Settings.Path, "..", @"Request\RequestAppPool.exe"),
                                Arguments              = $"-i {Ip} -p {appPool} -t {timeElaped}",
                                UseShellExecute        = false,
                                RedirectStandardOutput = true,
                                CreateNoWindow         = true
                            }
                        };

                        proc.Start();

                        proc.WaitForExit();

                        while (!proc.StandardOutput.EndOfStream)
                        {
                            string line = proc.StandardOutput.ReadLine();

                            if (proc.ExitCode == 0)
                            {
                                var request = line.Split('\t');

                                Requests.Add(new Request()
                                {
                                    Server      = PrettyName,
                                    ClientIp    = request[0],
                                    TimeElapsed = Convert.ToInt32(request[1]),
                                    Url         = request[2]
                                });
                            }
                            else
                            {
                                new ArgumentException(line);
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    Current.LogException(ex);
                }
            }
コード例 #30
0
            protected override async Task <HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
            {
                string content = await request.Content.ReadAsStringAsync();

                Requests.Add(content);

                return(new HttpResponseMessage
                {
                    Content = new StringContent(string.Empty)
                });
            }