Esempio n. 1
0
        static async Task MainAsync()
        {
            const int numberOfMessages = 10;
            const int numberOfSessions = 2;
            const int numberOfMessagesToReceiveInBatch = 5;

            messageSender        = new MessageSender(sbConnString, sbQueueName);
            messageSessionClient = new SessionClient(sbConnString, sbQueueName);


            // Send Messages
            await SendMessagesWithSessionAsync(numberOfMessages, numberOfSessions);

            // Receive Messages
            await ReceiveMessagesWithSessionAsync(numberOfMessagesToReceiveInBatch, "1");

            Console.WriteLine("=========================================================");
            Console.WriteLine("Completed Receiving all messages... Press any key to exit");
            Console.WriteLine("=========================================================");
            Console.ReadKey();

            await messageSender.CloseAsync();

            await messageSessionClient.CloseAsync();
        }
Esempio n. 2
0
        static async Task MainAsync()
        {
            const int numberOfSessions           = 1;
            const int numberOfMessagesPerSession = 7;

            messageSender   = new MessageSender(ServiceBusConnectionString, QueueName);
            messageReceiver = new MessageReceiver(ServiceBusConnectionString, QueueName);
            sessionClient   = new SessionClient(ServiceBusConnectionString, QueueName);

            // Send messages with sessionId set
            //await SendSessionMessagesAsync(numberOfSessions, numberOfMessagesPerSession);

            // Receive all Session based messages using SessionClient
            //await ReceiveSessionMessagesAsync(numberOfSessions, numberOfMessagesPerSession);
            //await ReceiveMessagesAsync();
            await ReceiveSessionMessagesAsync();

            Console.WriteLine("=========================================================");
            Console.WriteLine("Completed Receiving all messages... Press any key to exit");
            Console.WriteLine("=========================================================");

            Console.ReadKey();

            await messageSender.CloseAsync();

            await sessionClient.CloseAsync();
        }
Esempio n. 3
0
        //public bool IsCompleteInfo 
        //    => UserSession?.AuthFile?.IsCompleteInfo ?? false;



        public MainWindowVM(ISessionClient d7Client, LogScrollerVM logScroller, UserSessionVM userSessionVM)
            : base(userSessionVM)
        {
            DisplayName   = "ErrH Uploader (2nd attempt)";
            OtherTabs.Add(logScroller.ListenTo(this));

            CompletelyLoaded += (src, ea) =>
            {
                UserSession.SetClient(d7Client);

                var foldrsTab = ForwardLogs(IoC.Resolve<FoldersTabVM>());

                foldrsTab.MainList.ItemPicked += (s, e) =>
                    { ShowSingleton<FilesTabVM2>(e.Value, IoC); };

                NaviTabs.Add(foldrsTab);
                NaviTabs.SelectOne(0);
                foldrsTab.Refresh();

                //OtherTabs.Add(BatRunner());
                //OtherTabs.SelectOne(1);
                //RaisePropertyChanged(nameof(IsCompleteInfo));
                //UserSession.ra
            };
        }
Esempio n. 4
0
            public void Init()
            {
                _cosmosSettings = Options.Create(new CosmosSettings()
                {
                    ApiUrl                 = "https://test-account-not-real.documents.azure.com:443/",
                    ApiKey                 = "VGhpcyBpcyBteSB0ZXN0",
                    DatabaseName           = "DatabaseName",
                    UserSessionsCollection = "UserSessions"
                });
                var dummySession = new DfcUserSession()
                {
                    SessionId = "partitionkey-sessionid"
                };

                _client        = Substitute.For <CosmosClient>();
                _cosmosService = Substitute.For <ICosmosService>();
                _sessionClient = Substitute.For <ISessionClient>();
                _sessionConfig = Options.Create(new SessionConfig()
                {
                    Salt            = "ThisIsASalt",
                    ApplicationName = "matchskills"
                });

                _sessionClient.NewSession().Returns(dummySession);
            }
        private static void ReceiveMessages(ISessionClient sessionClient)
        {
            IMessageSession messageSession = sessionClient.AcceptMessageSessionAsync("Test1").GetAwaiter().GetResult();
            Program         c = new Program();

            try
            {
                Message messageReceived = null;

                do
                {
                    log.Info("Receiver listening");
                    messageReceived = messageSession.ReceiveAsync().GetAwaiter().GetResult();

                    if (messageReceived != null)
                    {
                        Console.WriteLine($"Received message: SequenceNumber:{messageReceived.SystemProperties.SequenceNumber} Body:{Encoding.UTF8.GetString(messageReceived.Body)}");

                        //this command permit to delete messages from the Cloud service, if the connection lost the application retry to download datas
                        messageSession.CompleteAsync(messageReceived.SystemProperties.LockToken).GetAwaiter().GetResult();
                    }

                    //call of method to move files from a directory to anothe
                    c.ConfigurationSourceDestinationPath("sourcePath", "destinationPath", $"{Encoding.UTF8.GetString(messageReceived.Body)}");
                } while (!messageSession.IsClosedOrClosing);

                Console.WriteLine("Press any key to exit");
                Console.ReadKey();
            }
            finally
            {
                messageSession.CloseAsync().GetAwaiter().GetResult();
                Console.ReadKey();
            }
        }
Esempio n. 6
0
        //public bool IsCompleteInfo
        //    => UserSession?.AuthFile?.IsCompleteInfo ?? false;



        public MainWindowVM(ISessionClient d7Client, LogScrollerVM logScroller, UserSessionVM userSessionVM)
            : base(userSessionVM)
        {
            DisplayName = "ErrH Uploader (2nd attempt)";
            OtherTabs.Add(logScroller.ListenTo(this));

            CompletelyLoaded += (src, ea) =>
            {
                UserSession.SetClient(d7Client);

                var foldrsTab = ForwardLogs(IoC.Resolve <FoldersTabVM>());

                foldrsTab.MainList.ItemPicked += (s, e) =>
                { ShowSingleton <FilesTabVM2>(e.Value, IoC); };

                NaviTabs.Add(foldrsTab);
                NaviTabs.SelectOne(0);
                foldrsTab.Refresh();

                //OtherTabs.Add(BatRunner());
                //OtherTabs.SelectOne(1);
                //RaisePropertyChanged(nameof(IsCompleteInfo));
                //UserSession.ra
            };
        }
Esempio n. 7
0
 public LobbyViewModel(ISessionClient client)
 {
     this.repository        = client;
     this.Users             = new ObservableCollection <UserDTO>();
     this.Items             = new ObservableCollection <ItemDTO>();
     this.GetUsersCommand   = new RelayCommand(_ => this.ExecuteGetUsersCommand());
     this.StopFetchingUsers = new RelayCommand(_ => this.ExecuteKillThread());
 }
 public SessionPumpHost(string clientId, ReceiveMode receiveMode, ISessionClient sessionClient, Uri endpoint)
 {
     this.syncLock      = new object();
     this.ClientId      = clientId;
     this.ReceiveMode   = receiveMode;
     this.SessionClient = sessionClient;
     this.endpoint      = endpoint;
 }
 public Functions(IConfiguration configuration)
 {
     _tclient = new TelemetryClient();
     _tclient.Context.Operation.Id   = Guid.NewGuid().ToString();
     _tclient.Context.Operation.Name = "PocWebJob9090";
     _serviceBusSettings             = Options.Create(configuration.GetSection("ServiceBusSettings").Get <ServiceBusSettings>());
     _commonSettings = Options.Create(configuration.GetSection("CommonSettings").Get <CommonSettings>());
     _sessionClient  = new SessionClient(_serviceBusSettings.Value.Connection, _serviceBusSettings.Value.PullQueueName);
 }
 public NewAssessmentFunctions(ILogService logService, IResponseWithCorrelation responseWithCorrelation, IQuestionSetRepository questionSetRepository, IUserSessionRepository userSessionRepository, ISessionClient sessionClient, ICorrelationIdProvider correlationIdProvider)
 {
     this.logService = logService;
     this.responseWithCorrelation = responseWithCorrelation;
     this.questionSetRepository   = questionSetRepository;
     this.sessionClient           = sessionClient;
     this.correlationIdProvider   = correlationIdProvider;
     this.userSessionRepository   = userSessionRepository;
 }
Esempio n. 11
0
 public void Init()
 {
     _cosmosService = Substitute.For <ICosmosService>();
     _sessionConfig = Options.Create(new SessionConfig()
     {
         Salt = "ThisIsASalt"
     });
     _sessionClient = Substitute.For <ISessionClient>();
 }
Esempio n. 12
0
 public void SetClient(ISessionClient sessionClient)
 {
     _client = sessionClient;
     RaisePropertyChanged(nameof(BaseUrl));
     RaisePropertyChanged(nameof(UserName));
     RaisePropertyChanged(nameof(Password));
     RaisePropertyChanged(nameof(AskForInput));
     SetEventHandlers();
 }
Esempio n. 13
0
 public void SetClient(ISessionClient sessionClient)
 {
     _client = sessionClient;
     RaisePropertyChanged(nameof(BaseUrl));
     RaisePropertyChanged(nameof(UserName));
     RaisePropertyChanged(nameof(Password));
     RaisePropertyChanged(nameof(AskForInput));
     SetEventHandlers();
 }
Esempio n. 14
0
 public ApplicationClient(ApiTypes apiType, byte sessionId, ISessionClient sc, IFrameClient fc, ITransportClient tc)
 {
     ApiType         = apiType;
     SessionId       = sessionId;
     SessionClient   = sc;
     FrameClient     = fc;
     TransportClient = tc;
     BindLayers();
 }
Esempio n. 15
0
 public DysacService(ILogger <DysacService> log, IRestClient restClient, IOptions <DysacSettings> dysacSettings, IOptions <OldDysacSettings> oldDysacSettings, ISessionClient sessionClient)
 {
     Throw.IfNull(dysacSettings, nameof(dysacSettings));
     _logger           = log;
     _dysacSettings    = dysacSettings;
     _oldDysacSettings = oldDysacSettings;
     _restClient       = restClient ?? new RestClient();
     _sessionClient    = sessionClient;
 }
 public SessionService(ICosmosService cosmosService, IOptions <SessionConfig> sessionConfig,
                       ISessionClient sessionClient)
 {
     Throw.IfNull(cosmosService, nameof(cosmosService));
     Throw.IfNull(sessionConfig, nameof(sessionConfig));
     Throw.IfNullOrWhiteSpace(sessionConfig.Value.Salt, nameof(sessionConfig.Value.Salt));
     _cosmosService = cosmosService;
     _sessionConfig = sessionConfig;
     _sessionClient = sessionClient;
 }
Esempio n. 17
0
 public WelcomeViewModel(IPublicClientApplication publicClientApplication, ISettings settings, ISessionClient client)
 {
     this.publicClientApplication = publicClientApplication;
     this.client       = client;
     this.settings     = settings;
     this.BaseTitle    = "Login";
     this.LoginCommand = new Command(async() => await this.ExecuteLoginCommand());
     this.User         = this.CreateGuestUserDTO();
     this.Join         = new RelayCommand(async _ => await this.ExecuteJoinCommand());
 }
Esempio n. 18
0
 public void Start(ISessionClient sessionClient)
 {
     _sessionClient = sessionClient;
     if (_timer == null)
     {
         _timer = new Timer(TimerCallback, null, TICK, Timeout.Infinite);
     }
     else
     {
         _timer.Change(TICK, Timeout.Infinite);
     }
 }
Esempio n. 19
0
 public SessionWorker(
     ISessionService sessionService,
     ISessionClient sessionClient,
     IGpioService gpioService,
     ILogService logService,
     ILoggerService <SessionWorker> logger)
 {
     _sessionService = sessionService;
     _sessionClient  = sessionClient;
     _gpioService    = gpioService;
     _logService     = logService;
     _logger         = logger;
 }
Esempio n. 20
0
        public SessionCreateViewModel(ISessionClient client, ISettings settings)
        {
            this.client = client;

            this.settings = settings;

            this.BaseTitle = "Items";

            this.Items = new ObservableCollection <ItemCreateUpdateDTO>();

            this.AddItemCommand = new RelayCommand(_ => this.ExecuteAddItemCommand());
            this.LoadCommand    = new Command(() => this.ExecuteLoadCommand());
        }
Esempio n. 21
0
 public SeedService(
     IUnitOfWorkManager unitOfWorkManager,
     ISessionClient sessionClient,
     IGeneralClient generalClient,
     IMapper <GeneralItemsClientModel, ItemModel> itemMapper,
     IMapper <GeneralChampionsClientModel, ChampionModel> championMapper,
     IMapper <GeneralChampionsSkinsClientModel, SkinModel[]> skinMapper
     )
 {
     _unitOfWorkManager = unitOfWorkManager;
     _sessionClient     = sessionClient;
     _generalClient     = generalClient;
     _itemMapper        = itemMapper;
     _championMapper    = championMapper;
     _skinMapper        = skinMapper;
 }
        public RequestReplyHandler()
        {
            _settings = new ASBSettings();

            /* We could use the samplesend SAS Policy from the above settings for the reply channel as well. But that would mean that the SAS token created for the Provider would be valid for
             * more queues than just the one we want to use as the reply queue. That is undesirable for a Provider that may be outside of our own organisation for example.
             * So we created a new SAS Policy names SessionQueueSend scoped just to the sessionqueue. */
            _receiveKeyName = "SessionQueueSend";
            _receiveKey     = "<SessionQueueSend key>";

            var sendBuilder    = new ServiceBusConnectionStringBuilder(_settings[ASBSettings.ServicebusFqdnEndpoint], ASBSettings.BasicQueueName, ASBSettings.SendKeyName, _settings[ASBSettings.ServicebusSendKey]);
            var receiveBuilder = new ServiceBusConnectionStringBuilder(_settings[ASBSettings.ServicebusFqdnEndpoint], ASBSettings.SessionQueueName, ASBSettings.ReceiveKeyName, _settings[ASBSettings.ServicebusListenKey]);

            _sendClient    = new QueueClient(sendBuilder);
            _receiveClient = new SessionClient(receiveBuilder);
        }
        public SessionClientTests()
        {
            this.partitionKeyGenerator      = A.Fake <IPartitionKeyGenerator>();
            this.sessionIdGenerator         = A.Fake <ISessionIdGenerator>();
            this.httpContextAccessor        = A.Fake <IHttpContextAccessor>();
            httpContextAccessor.HttpContext = new DefaultHttpContext();

            this.config = new SessionConfig
            {
                ApplicationName = "UnitTestAppName",
                Salt            = "TestSalt",
            };
            this.logger = A.Fake <ILogger <SessionClient> >();

            this.sessionClient = new SessionClient(sessionIdGenerator, partitionKeyGenerator, httpContextAccessor, config, logger);
        }
Esempio n. 24
0
 public void Init()
 {
     _cosmosSettings = Options.Create(new CosmosSettings()
     {
         ApiUrl                 = "https://test-account-not-real.documents.azure.com:443/",
         ApiKey                 = "VGhpcyBpcyBteSB0ZXN0",
         DatabaseName           = "DatabaseName",
         UserSessionsCollection = "UserSessions"
     });
     _client        = Substitute.For <CosmosClient>();
     _cosmosService = Substitute.For <ICosmosService>();
     _sessionClient = Substitute.For <ISessionClient>();
     _sessionConfig = Options.Create(new SessionConfig()
     {
         Salt = "ThisIsASalt"
     });
 }
        public CreateNewSkillsAssessmentTests()
        {
            httpRequest = A.Fake <HttpRequest>();
            var httpContextAccessor = A.Fake <IHttpContextAccessor>();

            questionSetRepository = A.Fake <IQuestionSetRepository>();
            userSessionRepository = A.Fake <IUserSessionRepository>();
            sessionClient         = A.Fake <ISessionClient>();
            var correlationProvider = new RequestHeaderCorrelationIdProvider(httpContextAccessor);

            using var telemetryConfig = new TelemetryConfiguration();
            var telemetryClient     = new TelemetryClient(telemetryConfig);
            var logger              = new LogService(correlationProvider, telemetryClient);
            var correlationResponse = new ResponseWithCorrelation(correlationProvider, httpContextAccessor);

            functionApp = new NewAssessmentFunctions(logger, correlationResponse, questionSetRepository, userSessionRepository, sessionClient, correlationProvider);
        }
Esempio n. 26
0
 public Repo1ClientBase1(string configKey, int checkIntervalMins)
 {
     _cfgKey                    = configKey;
     _cfg                       = ParseDownloaderCfg(configKey);
     _intervalMins              = checkIntervalMins;
     _validr                    = GetClientValidator();
     _postr                     = GetPosterClient();
     _updatr                    = GetLocalFileUpdater(configKey);
     _sessionr                  = GetSessionClient(checkIntervalMins);
     _downloadr                 = GetDownloadClient();
     _sessionr.PropertyChanged += (s, e) =>
     {
         if (e.PropertyName == nameof(_sessionr.Status))
         {
             Status = _sessionr.Status;
         }
     };
 }
 public void Init()
 {
     _oldDysacServiceSetings = Options.Create(new OldDysacSettings()
     {
         ApiKey           = "9238dfjsjdsidfs83fds",
         AssessmentApiUrl = "https://this.is.anApi.org.uk",
         DysacResultsUrl  = "https://this.is.anApi.org.uk",
     });
     _dysacServiceSetings = Options.Create(new DysacSettings());
     _dysacServiceSetings.Value.ApiUrl     = "https://dev.api.nationalcareersservice.org.uk/something";
     _dysacServiceSetings.Value.ApiKey     = "mykeydoesnotmatterasitwillbemocked";
     _dysacServiceSetings.Value.DysacUrl   = "http://dysacurl";
     _dysacServiceSetings.Value.ApiVersion = "v1";
     _dysacService  = Substitute.For <IDysacSessionReader>();
     _log           = Substitute.For <ILogger <DysacService> >();
     _sessionClient = Substitute.For <ISessionClient>();
     _restClient    = Substitute.For <IRestClient>();
 }
Esempio n. 28
0
        public SessionClientTests()
        {
            var configuration = new ConfigurationBuilder()
                                .AddJsonFile("appsettings.json", optional: false, reloadOnChange: true)
                                .Build();

            sessionConfig = configuration.GetSection(nameof(SessionConfig)).Get <SessionConfig>();

            var serviceProvider = new ServiceCollection().AddSessionServices(sessionConfig);

            serviceProvider.AddLogging();
            serviceProvider.AddHttpContextAccessor();

            var services = serviceProvider.BuildServiceProvider();

            sessionClient   = services.GetService <ISessionClient>();
            contextAccessor = services.GetService <IHttpContextAccessor>();
        }
Esempio n. 29
0
 public SessionReceivePump(string clientId,
                           ISessionClient client,
                           ReceiveMode receiveMode,
                           SessionHandlerOptions sessionHandlerOptions,
                           Func <IMessageSession, Message, CancellationToken, Task> callback,
                           string endpoint,
                           CancellationToken token)
 {
     this.client                = client ?? throw new ArgumentException(nameof(client));
     this.clientId              = clientId;
     this.ReceiveMode           = receiveMode;
     this.sessionHandlerOptions = sessionHandlerOptions;
     this.userOnSessionCallback = callback;
     this.endpoint              = endpoint;
     this.entityPath            = client.EntityPath;
     this.pumpCancellationToken = token;
     this.maxConcurrentSessionsSemaphoreSlim    = new SemaphoreSlim(this.sessionHandlerOptions.MaxConcurrentSessions);
     this.maxPendingAcceptSessionsSemaphoreSlim = new SemaphoreSlim(this.sessionHandlerOptions.MaxConcurrentAcceptSessionCalls);
 }
        static void Main(string[] args)
        {
            ISessionClient sessionClient = null;
            Program        c             = new Program();


            try
            {
                //settings of session with ConnectionString and Name of queue for cloud side
                sessionClient = new SessionClient(ServiceBusConnectionString, QueueName);
                ReceiveMessages(sessionClient);
                Console.ReadKey();
            }
            catch (Exception e)
            {
                Console.WriteLine(e.ToString());
                ReceiveMessages(sessionClient);
                Console.ReadKey();
            }
        }
 public SessionReceivePump(string clientId,
                           ISessionClient client,
                           ReceiveMode receiveMode,
                           SessionHandlerOptions sessionHandlerOptions,
                           Func <IMessageSession, Message, CancellationToken, Task> callback,
                           Uri endpoint,
                           CancellationToken pumpToken,
                           CancellationToken runningTaskToken)
 {
     this.client                                = client ?? throw new ArgumentException(nameof(client));
     this.clientId                              = clientId;
     this.ReceiveMode                           = receiveMode;
     this.sessionHandlerOptions                 = sessionHandlerOptions;
     this.userOnSessionCallback                 = callback;
     this.endpoint                              = endpoint.Authority;
     this.entityPath                            = client.EntityPath;
     this.pumpCancellationToken                 = pumpToken;
     this.runningTaskCancellationToken          = runningTaskToken;
     this.maxConcurrentSessionsSemaphoreSlim    = new SemaphoreSlim(this.sessionHandlerOptions.MaxConcurrentSessions);
     this.maxPendingAcceptSessionsSemaphoreSlim = new SemaphoreSlim(this.sessionHandlerOptions.MaxConcurrentAcceptSessionCalls);
     this.diagnosticSource                      = new ServiceBusDiagnosticSource(client.EntityPath, endpoint);
 }
        public void Init()
        {
            _logger        = Substitute.For <ILogger <DysacService> >();
            _client        = Substitute.For <IRestClient>();
            _sessionClient = Substitute.For <ISessionClient>();
            _settings      = Options.Create(new DysacSettings()
            {
                ApiKey         = "9238dfjsjdsidfs83fds",
                ApiUrl         = "https://this.is.anApi.org.uk",
                ApiVersion     = "v1",
                DysacReturnUrl = "SomeURL",
                DysacSaveUrl   = "SaveURL",
                DysacUrl       = "DysacURL"
            });
            _oldDysacSettings = Options.Create(new OldDysacSettings()
            {
                ApiKey           = "9238dfjsjdsidfs83fds",
                AssessmentApiUrl = "https://this.is.anApi.org.uk",
                DysacResultsUrl  = "https://this.is.anApi.org.uk",
            });

            _service = new DysacService(_logger, _client, _settings, _oldDysacSettings, _sessionClient);
        }