Exemplo n.º 1
0
        public void HandlePublishedSearchRequestsEvent(CriteriaUsageEventPayload eventPayload)
        {
            if (eventPayload == null)
            {
                throw new ArgumentNullException("eventPayload");
            }

            if (log.IsDebugEnabled)
            {
                log.Debug("Received published search requests event => " + eventPayload);
            }

            ISearch search = new SearchImpl();

            if (eventPayload.Criteria != null)
            {
                foreach (var criterion in eventPayload.Criteria)
                {
                    search.Criteria.Add(new SearchCriterionImpl {
                        ControlName = criterion.Key, ControlValue = criterion.Value
                    });
                }
            }

            Requests.Clear();
            Requests.AddRange(optionRequestPersistanceManager.GetRequestMatchingAdhocCriteria(search, false));
            NotifyPropertyChanged("Requests");

            if (!Requests.Any())
            {
                MessageBox.Show("No RFQs matching the search criteria were found!\nPlease broaden your search criteria.",
                                "No Search Results Returned.", MessageBoxButton.OK, MessageBoxImage.Exclamation);
            }
        }
Exemplo n.º 2
0
        public void HandlePublishedFilterRequestsEvent(CriteriaUsageEventPayload eventPayload)
        {
            if (eventPayload == null)
            {
                throw new ArgumentNullException("eventPayload");
            }

            if (log.IsDebugEnabled)
            {
                log.Debug("Received published filter requests event => " + eventPayload);
            }

            if (eventPayload.Criteria != null && eventPayload.Criteria.Count > 0)
            {
                var view = CollectionViewSource.GetDefaultView(Requests);
                view.Filter = (request) => ((IRequestForQuote)request).DoesRequestMatchFilter(eventPayload.Criteria);
            }
            else
            {
                Requests.Clear();
                Requests.AddRange(TodaysRequests);
                NotifyPropertyChanged("Requests");
                var view = CollectionViewSource.GetDefaultView(Requests);
                view.Filter = null;
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Start system
        /// </summary>
        public void Start()
        {
            Requests.Clear();
            ProbabilityStatesInfos.Clear();

            UpdateStates(GetCurrentStateOfSystem());

            for (Tact = 1; Tact < ExecutionTime; Tact++)
            {
                foreach (IComponent component in Components)
                {
                    component.Process();
                }

                foreach (Request request in Requests)
                {
                    request.TactsPassed();

                    if (request.State == RequestState.Pending || request.State == RequestState.Processing)
                    {
                        _requestsInSystem++;
                    }
                }

                UpdateStates(GetCurrentStateOfSystem());
            }

            CalculateStatistics();
        }
Exemplo n.º 4
0
        /// <summary>
        /// Возобновляет работу загрузчика, если он был приостановлен.
        ///
        /// Если на момент возобновления отсутствует интернет подключение,
        /// будет выброшено <see cref="NoNetworkDownloaderException"/>,
        /// а все выполняющиеся загрузки будут отменены
        /// </summary>
        public void Resume()
        {
            if (State != DownloaderState.Suspended)
            {
                return;
            }

            if (!NetworkInterface.GetIsNetworkAvailable())
            {
                foreach (var request in Requests.Values)
                {
                    request.Cancel();
                }

                Requests.Clear();

                throw new NoNetworkDownloaderException("При возобновлении загрузчика не обнаружился интернет! Все загрузки отменены!");
            }

            foreach (var request in Requests.Values)
            {
                if (request.State == RequestState.Default)
                {
                    request.Execute();
                }
                else
                {
                    request.Resume();
                }
            }
        }
Exemplo n.º 5
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();
                        }
                    }
                }
            });
        }
Exemplo n.º 6
0
        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));
        }
Exemplo n.º 7
0
        public void LoadJRIntoListbox()
        {
            var requests = _dataservice.getAllRequests();

            Requests.Clear();
            foreach (var request in requests)
            {
                Requests.Add(request);
            }
        }
Exemplo n.º 8
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);
                }
            }
Exemplo n.º 9
0
        public static void GenerateStartingQuests()
        {
            Requests.Clear();

            int requestCount = Random.Range(4, 6);

            for (int i = 0; i < requestCount; i++)
            {
                QuestInstance newQuest = QuestGenerator.GenerateQuestInstance();
                Requests.Add(newQuest);
            }
        }
Exemplo n.º 10
0
 public void ClearView()
 {
     Selected.Clear();
     Focused       = null;
     Hovered       = null;
     _spatialIndex = null;
     Markers       = null;
     Requests.Clear();
     this.Size     = Size.Zero;
     this.Location = Point.Zero;
     this._shape   = null;
 }
Exemplo n.º 11
0
        public object DeSerialize(BinaryReader reader)
        {
            int version = reader.ReadInt32();

            Enabled  = reader.ReadBoolean();
            SiteName = reader.ReadNullableString();
            lock (Requests.Locker)
            {
                Requests.Clear();
                if (version <= 1)
                {
                    var urls = reader.ReadNullableString();
                    foreach (var url in urls.Split("\r\n".ToCharArray(), StringSplitOptions.RemoveEmptyEntries))
                    {
                        Requests.Add(new Request {
                            Url = url
                        });
                    }
                }
                else
                {
                    reader.ReadCollection(Requests, r => (Request) new Request().DeSerialize(r));
                }
            }
            EntryRegEx             = reader.ReadNullableString();
            EntryRegExResult       = reader.ReadNullableString();
            UrlRegEx               = reader.ReadNullableString();
            UrlRegExResult         = reader.ReadNullableString();
            DateRegEx              = reader.ReadNullableString();
            DateRegExResult        = reader.ReadNullableString();
            CompanyRegEx           = reader.ReadNullableString();
            CompanyRegExResult     = reader.ReadNullableString();
            EntryNameRegEx         = reader.ReadNullableString();
            EntryNameRegExResult   = reader.ReadNullableString();
            DescriptionRegEx       = reader.ReadNullableString();
            DescriptionRegExResult = reader.ReadNullableString();
            Encoding               = reader.ReadNullableString();
            if (version > 0)
            {
                CostRegEx       = reader.ReadNullableString();
                CostRegExResult = reader.ReadNullableString();
            }
            if (version > 2)
            {
                AnswersRegEx       = reader.ReadNullableString();
                AnswersRegExResult = reader.ReadNullableString();
            }
            return(this);
        }
Exemplo n.º 12
0
        public void ClearMethodShouldDeleteAllRecordsInRequests()
        {
            Pixel    pixel    = new Pixel(1, 1, Color.Black);
            Requests requests = new Requests();

            for (int i = 0; i < 5; i++)
            {
                requests.Add(pixel);
            }

            requests.Clear();
            int result = requests.GetCapacity();

            Assert.AreEqual(0, result);
        }
Exemplo n.º 13
0
        protected void Read()
        {
            Requests.Clear();

            if (System.IO.File.Exists(FilePath))
            {
                using (var f = System.IO.File.OpenText(FilePath))
                {
                    using (var reader = new JsonTextReader(f))
                    {
                        var serializer = new JsonSerializer();
                        Requests.AddRange(serializer.Deserialize <List <EndorsementRequest> >(reader));
                    }
                }
            }
        }
Exemplo n.º 14
0
        public void HandlePublishedNewRequestEvent(NewRequestForQuoteEventPayload eventPayload)
        {
            if (eventPayload == null)
            {
                throw new ArgumentNullException("eventPayload");
            }

            IRequestForQuote request = new RequestForQuoteImpl();

            request.Legs       = optionRequestParser.ParseRequest(eventPayload.NewRequestText.ToUpper(), request);
            request.Request    = eventPayload.NewRequestText;
            request.Status     = StatusEnum.PENDING;
            request.Identifier = -1;
            request.Client     = eventPayload.NewRequestClient;
            request.TradeDate  = DateTime.Today;
            if (request.Legs != null)
            {
                request.ExpiryDate = request.Legs[0].MaturityDate;
            }
            request.LotSize                 = 100;
            request.Multiplier              = 10;
            request.Contracts               = 100;
            request.NotionalFXRate          = 1;
            request.NotionalMillions        = 1;
            request.BookCode                = eventPayload.NewRequestBookCode;
            request.DayCountConvention      = 250.0;
            request.PremiumSettlementFXRate = 1;
            request.SalesCreditFXRate       = 1;
            request.IsOTC = true;
            request.SalesCreditPercentage         = 2;
            request.PremiumSettlementDaysOverride = 1;
            request.PremiumSettlementDate         = DateTime.Today.AddDays(request.PremiumSettlementDaysOverride);
            request.CalculatePricing(optionRequestPricer);

            TodaysRequests.Add(request);
            Requests.Clear();
            Requests.AddRange(TodaysRequests);
            NotifyPropertyChanged("Requests");

            // TODO - add all fields with their defaults.

            if (log.IsDebugEnabled)
            {
                log.Debug("Received and prcoessed published new request for quote => " + request);
            }
        }
Exemplo n.º 15
0
        public void HandleGetTodaysRequestsEvent(EmptyEventPayload emptyPayload)
        {
            if (emptyPayload == null)
            {
                throw new ArgumentNullException("emptyPayload");
            }

            if (log.IsDebugEnabled)
            {
                log.Debug("Received request to reset grid to today's requests.");
            }

            var view = CollectionViewSource.GetDefaultView(Requests);

            view.Filter = null;

            Requests.Clear();
            Requests.AddRange(TodaysRequests);
            NotifyPropertyChanged("Requests");
        }
        async Task Get()
        {
            IsRefreshing = true;
            Requests.Clear();
            Config.Init(AccountManager.Instance().GetActiveAccount());
            var relationship_manager = new Service(Config.Instance().Web3Instance);

            for (int i = 0; i < 3; i++)
            {
                var address = await relationship_manager.GetDocQueryAsync(i);

                if (address.IsZero())
                {
                    continue;
                }
                Requests.Add(new Request()
                {
                    AddCommand    = addCommand,
                    RejectCommand = rejectCommand,
                    Address       = address.ToLower()
                });
            }
            IsRefreshing = false;
        }
Exemplo n.º 17
0
 public virtual void Reset()
 {
     Requests.Clear();
 }
Exemplo n.º 18
0
 public static void ClearRequests(this IWebBrowser webBrowser)
 {
     Requests.Clear();
 }
Exemplo n.º 19
0
 internal void Disconnect()
 {
     _requestsRef.Clear();
     Requests.Clear();
 }
Exemplo n.º 20
0
        /// <summary>
        /// Start system
        /// </summary>
        public void Start()
        {
            Requests.Clear();
            Channels.Clear();
            Queue.Clear();

            for (int i = 0; i < ChannelsCount; i++)
            {
                Channels.Add(new Channel());
            }

            // First request creation
            int     currentMinute    = 0;
            Request generatedRequest = GenerateRequest(currentMinute);

            // Stepping by minutes
            while (currentMinute < Hours * 60)
            {
                // Find channel that will first finish processing request
                Channel nextFreeChannel = GetNextFreeChannel();

                if (generatedRequest.ArrivalTime > nextFreeChannel.FinishProcessingTime)
                {
                    // if channel finish sooner than request will arrive
                    // than we move to channel's finish processing time
                    currentMinute = nextFreeChannel.FinishProcessingTime.Value;
                    nextFreeChannel.FinishProcessing();

                    // if there are something in queue
                    if (Queue.Count > 0)
                    {
                        // add this to freed channel
                        nextFreeChannel.ProcessRequest(Queue.Dequeue(), currentMinute);
                    }
                }
                else
                {
                    // other possibillity is request will arrive sooner
                    // than channel finish processing in that  case
                    // 1. move to request arrival time

                    currentMinute = generatedRequest.ArrivalTime;
                    Channel freeChannel = GetFreeChannel();

                    // 2. check if any channel is free
                    if (freeChannel != null)
                    {
                        // if there are free channels and queue is empty
                        if (Queue.Count == 0)
                        {
                            // move request to channel
                            freeChannel.ProcessRequest(generatedRequest, currentMinute);
                        }
                        else
                        {
                            // move request from queue to channel
                            // and
                            // move arrived request to queue
                            freeChannel.ProcessRequest(Queue.Dequeue(), currentMinute);
                            TryEnqueue(generatedRequest);
                        }
                    }
                    else
                    {
                        // no free channel = try add to queue
                        TryEnqueue(generatedRequest);
                    }

                    generatedRequest = GenerateRequest(currentMinute);
                }
            }

            // Calc statistics
            double queueFee    = QueueFee * QueueSize * Hours;
            double channelsFee = ChannelFee * ChannelsCount * Hours;

            PureProfit = Channels.Sum(channel => channel.Profit) - queueFee - channelsFee;
        }
Exemplo n.º 21
0
 public void Clear()
 {
     Requests.Clear();
 }
Exemplo n.º 22
0
 public void Dispose()
 {
     Requests?.Clear();
 }
Exemplo n.º 23
0
 public override void Reset()
 {
     // Though if you reset an EndGamePicker it really means that you should be using a regular picker now
     Requests.Clear();
 }
Exemplo n.º 24
0
 /// <summary>
 /// Clear and set the requests to process
 /// </summary>
 /// <param name="requests"></param>
 /// <throws>When request is not of the same existing type</throws>
 /// <returns>MultiCallOperation</returns>
 public MultiCallOperation SetRequests(List <Request> requests)
 {
     Requests.Clear();
     AddRequests(requests);
     return(this);
 }