public TestCase(
            IEnumerable <IRequest> requests,
            IEnumerable <IRequest> cleanupRequests,
            string name,
            string description,
            string category)
        {
            if (requests == null)
            {
                throw new ArgumentNullException("requests");
            }
            Requests = requests.ToArray();
            if (!Requests.Any())
            {
                throw new ArgumentException("TestCase has to have at least one request.", "requests");
            }

            if (cleanupRequests == null)
            {
                cleanupRequests = Enumerable.Empty <IRequest>();
            }
            CleanupRequests = cleanupRequests.ToArray();

            if (string.IsNullOrEmpty(name))
            {
                throw new ArgumentException("Name cannot be empty.", "name");
            }
            Name = name;

            Description       = description;
            UiScreenShot      = String.Empty;
            DocumentationLink = String.Empty;
            FailMessage       = String.Empty;
            Category          = category;
        }
        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);
        }
Exemple #3
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);
            }
        }
        /// <summary>
        /// Allows cancelling of a previously requested variable, if it is no-longer needed
        /// </summary>
        /// <param name="request">SimVar Request to cancel</param>
        public static bool CancelRequest(SimConnectVariable request)
        {
            WriteLog("Start CancelRequest(SimConnectVariable)");
            var result = false;

            if (simConnect != null && IsConnected && Requests.Any(x => x.Value.Name == request.Name && x.Value.Unit == request.Unit))
            {
                lock (Requests)
                {
                    try
                    {
                        var submittedRequest = Requests.First(x => x.Value.Name == request.Name && x.Value.Unit == request.Unit);
                        var requestId        = submittedRequest.Key;
                        if (requestId > -1)
                        {
                            //simConnect.ClearDataDefinition((SIMVARDEFINITION)requestId);
                            simConnect.ClearClientDataDefinition((SIMVARDEFINITION)requestId);
                            Requests.Remove(requestId);
                            RemoveTimer(requestId);
                            result = true;
                        }
                    }
                    catch (Exception ex)
                    {
                        WriteLog(string.Format("Cancellation Error: {0}", ex.Message), EventLogEntryType.Error);
                    }
                }
            }
            WriteLog("End CancelRequest(SimConnectVariable)");
            return(result);
        }
        public EvaluationRequestListViewModel(IEvlRequestService evlRequestService, IUserDialogs userDialogs, IPageDialogService dialogService, IEventAggregator eventAggregator)
        {
            _evlRequestService = evlRequestService;
            _userDialogs       = userDialogs;
            _dialogService     = dialogService;
            _eventAggregator   = eventAggregator;

            ShowRequestProgress = new BitDelegateCommand <EvlRequestListItemSource>(async(request) =>
            {
                await NavigationService.NavigateAsync(nameof(EvlRequestProgressView), new NavigationParameters
                {
                    { nameof(EvlRequestListItemSource), request }
                });
            });

            OpenInquiryBox = new BitDelegateCommand(async() =>
            {
                eventAggregator.GetEvent <OpenInquiryPopupEvent>().Publish(new OpenInquiryPopupEvent());
            });

            Inquiry = new BitDelegateCommand(async() =>
            {
                inquiryCancellationTokenSource?.Cancel();
                inquiryCancellationTokenSource = new CancellationTokenSource();
                using (_userDialogs.Loading(ConstantStrings.Loading, cancelText: ConstantStrings.Loading_Cancel, onCancel: inquiryCancellationTokenSource.Cancel))
                {
                    if (string.IsNullOrEmpty(DocumentNumber) || !Requests.Any(r => r.Code == int.Parse(DocumentNumber)))
                    {
                        await dialogService.DisplayAlertAsync(ConstantStrings.Error, ConstantStrings.DocumentNumberIsInvalid, ConstantStrings.Ok);
                        DocumentNumber = null;
                        return;
                    }

                    EvlRequestDto requestDto = await evlRequestService.SearchByCode(int.Parse(DocumentNumber));

                    if (requestDto == null)
                    {
                        await dialogService.DisplayAlertAsync(ConstantStrings.Error, ConstantStrings.RequestDosentExist, ConstantStrings.Ok);
                        DocumentNumber = null;
                        return;
                    }
                    else
                    {
                        DocumentNumber = null;

                        eventAggregator.GetEvent <OpenInquiryPopupEvent>().Publish(new OpenInquiryPopupEvent());

                        INavigationParameters parameter = new NavigationParameters();
                        parameter.Add(nameof(EvlRequestListItemSource), new EvlRequestListItemSource
                        {
                            Code            = requestDto.Code,
                            RequestId       = requestDto.Id,
                            RequestTypeName = EnumHelper <EvlRequestType> .GetDisplayValue(requestDto.EvlRequestType)
                        });

                        await NavigationService.NavigateAsync(nameof(EvlRequestProgressView), parameter);
                    }
                }
            });
        }
 /// <summary>
 /// When SimConnect sends an updated object, the data is captured here
 /// </summary>
 /// <param name="sender">SimConnect</param>
 /// <param name="data">Object Data</param>
 private static void SimConnect_OnRecvSimobjectDataByType(SimConnect sender, SIMCONNECT_RECV_SIMOBJECT_DATA_BYTYPE data)
 {
     //WriteLog("Start SimConnect_OnRecvSimobjectDataByType(SimConnect, SIMCONNECT_RECV_SIMOBJECT_DATA_BYTYPE)");
     if (SimData != null)
     {
         try
         {
             var value = data?.dwData;
             if (value != null && value.Length == 1 && value[0].GetType() == typeof(SimVarString))
             {
                 value = new object[] { ((SimVarString)value[0]).Value }
             }
             ;
             // May receive a value for a recently deleted request, ignore it
             if (Requests.Any(x => x.Key == (int)data.dwRequestID))
             {
                 var request   = Requests.First(x => x.Key == (int)data.dwRequestID).Value;
                 var simVarVal = new SimConnectVariableValue
                 {
                     Request = request,
                     Value   = value
                 };
                 new Task(new Action(() => SimData.DynamicInvoke(simConnect, simVarVal))).Start();
             }
         }
         catch (Exception ex)
         {
             WriteLog(string.Format("SimConnect_OnRecvSimobjectDataByType Error: {0}", ex.Message), EventLogEntryType.Error);
         }
     }
     //WriteLog("End SimConnect_OnRecvSimobjectDataByType(SimConnect, SIMCONNECT_RECV_SIMOBJECT_DATA_BYTYPE)");
 }
        private void DeleteRequest(object o)
        {
            var download = o as BackgroundDownload;

            if (download == null)
            {
                return;
            }

            try
            {
                BackgroundTransferRequest transferToRemove = BackgroundTransferService.Find(download.Id);
                if (transferToRemove == null)
                {
                    return;
                }

                // Try to remove the transfer from the background transfer service.
                BackgroundTransferService.Remove(transferToRemove);

                // Remove the request from the UI
                Requests.Remove(download);
                TxtNothingToDownload.Visibility = Requests.Any() ? Visibility.Collapsed : Visibility.Visible;
            }
            catch (Exception ex)
            {
                App.TrackException(ex);
            }
        }
Exemple #8
0
 /// <summary>
 /// Cleans up after a task was successfully executed.
 /// </summary>
 public override void Finish()
 {
     if (Requests.Any())
     {
         throw new InvalidOperationException("An unfinished request cannot be marked as finished!");
     }
     OutputStation.UnregisterInboundPod(ReservedPod);
     OutputStation.UnregisterExtractTask(this);
 }
 private static int GetRequestId(SimConnectVariable request)
 {
     WriteLog("Start GetRequestId(SimConnectVariable);\r\nEnd GetRequestId(SimConnectVariable)");
     return(Requests.Any(x =>
                         x.Value.Name.Equals(request.Name, StringComparison.InvariantCultureIgnoreCase) &&
                         x.Value.Unit.Equals(request.Unit, StringComparison.InvariantCultureIgnoreCase)) ?
            Requests.FirstOrDefault(x =>
                                    x.Value.Name.Equals(request.Name, StringComparison.InvariantCultureIgnoreCase) &&
                                    x.Value.Unit.Equals(request.Unit, StringComparison.InvariantCultureIgnoreCase)).Key
         : -1);
 }
    public async Task StubIntegration_HealthcheckOnRootUrl_NotRootUrlCalled_ShouldExecuteStubs()
    {
        // Arrange
        var url = $"{BaseAddress}some-url";

        // Act
        using var response = await Client.GetAsync(url);

        // Assert
        Assert.AreEqual(HttpStatusCode.NotImplemented, response.StatusCode);
        Assert.IsTrue(Requests.Any());
    }
Exemple #11
0
        async void GetPersonnelVacantAsync()
        {
            var token = cancellationTokenSource.Token;

            try
            {
                await Task.Factory.StartNew(async() =>
                {
                    while (true)
                    {
                        try
                        {
                            personnel = rivERWebService.GetPersonnelReadRequest(Helpers.Settings.PersonnelID).Result;

                            foreach (var request in personnel.Requests)
                            {
                                if (!Requests.Any(r => r.RequestID == request.RequestID))
                                {
                                    Requests.Add(request);
                                }
                                else
                                {
                                    var alarmRequest = Requests.FirstOrDefault(r => r.RequestID == request.RequestID);

                                    alarmRequest.Alarm = request.Alarm;
                                }
                            }

                            foreach (var request in Requests)
                            {
                                if (!personnel.Requests.Any(r => r.RequestID == request.RequestID))
                                {
                                    Requests.Remove(request);
                                }
                            }

                            await Task.Delay(3000);
                        }
                        catch (Exception e)
                        {
                            System.Diagnostics.Debug.WriteLine("Trying to read personnel: {0}", e.Message);
                            await Task.Delay(7000);
                        }
                    }
                }, token, TaskCreationOptions.LongRunning, TaskScheduler.Default);
            }
            catch (OperationCanceledException e)
            {
                System.Diagnostics.Debug.WriteLine("Cancel GetPersonnelVacantAsync ex {0}", e.Message);
            }
        }
    public async Task StubIntegration_HealthcheckOnRootUrl_RootUrlCalled_ShouldNotExecuteStubs()
    {
        // Arrange
        var url = BaseAddress;

        // Act
        using var response = await Client.GetAsync(url);

        // Assert
        response.EnsureSuccessStatusCode();

        var content = await response.Content.ReadAsStringAsync();

        Assert.AreEqual("OK", content);
        Assert.IsFalse(Requests.Any());
    }
Exemple #13
0
        public TestCase(
            string resourceId,
            IEnumerable <IRequest> requests,
            IEnumerable <IRequest> cleanupRequests,
            string name,
            string description,
            bool uploadDocumentOnSetup,
            bool deleteDocumentOnTearDown,
            string category)
        {
            DeleteDocumentOnTearDown = deleteDocumentOnTearDown;
            UploadDocumentOnSetup    = uploadDocumentOnSetup;

            if (requests == null)
            {
                throw new ArgumentNullException("requests");
            }
            Requests = requests.ToArray();
            if (!Requests.Any())
            {
                throw new ArgumentException("TestCase has to have at least one request.", "requests");
            }

            if (cleanupRequests == null)
            {
                cleanupRequests = Enumerable.Empty <IRequest>();
            }
            CleanupRequests = cleanupRequests.ToArray();

            if (string.IsNullOrEmpty(resourceId))
            {
                throw new ArgumentException("ResourceId cannot be empty.", "resourceId");
            }
            ResourceId = resourceId;

            if (string.IsNullOrEmpty(name))
            {
                throw new ArgumentException("Name cannot be empty.", "name");
            }
            Name = name;

            Description       = description;
            UiScreenShot      = String.Empty;
            DocumentationLink = String.Empty;
            FailMessage       = String.Empty;
            Category          = category;
        }
 public bool CheckActive(string driverId)
 {
     return(Requests.Any(x => x.DriverId == driverId && x.Status != "Delivered"));
 }