示例#1
0
        public OfferManager(
            ISteamHubConnections steamHubConnections,
            IOfferService offerService,
            RpcSteamListener steamListener,
            ILogServiceFactory logger,
            IGrpcServiceFactory factory,
            IUserService userService,
            IRepoServiceFactory repoServiceFactory
            )
        {
            _rakeItemRepoService = repoServiceFactory.RakeItemRepoService;
            _steamServiceClient  = factory.GetSteamServiceClient(new SteamInventoryCacheManager());
            _steamHubConnections = steamHubConnections;
            _offerService        = offerService;
            _userService         = userService;
            _logger = logger.CreateLogger <OfferManager>();

            steamListener.OnOfferStatusChanged += async(sender, offer) =>
            {
                _logger.Info($"Received statuscode {offer.StatusCode}");

                try
                {
                    await HandleOffer(offer);
                }
                catch (System.Exception e)
                {
                    _logger.Error(offer.SteamId, null, e, new Dictionary <string, object>
                    {
                        { "Offer", offer }
                    });
                }
            };
        }
示例#2
0
        public SteamServiceTest()
        {
            var host = "testHost";
            var port = 8080;

            _realUser    = new DatabaseModel.User("realUserSteamud", "realUser", "realImg", "myTradelink", DateTime.Now, DateTime.Now, false, null, 10);
            _scammerUser = new DatabaseModel.User("scammerUserSteamud", "scamerUser", "fakeImg", "myTradelink1", DateTime.Now, DateTime.Now, false,
                                                  null, 20);

            _realUsersItems    = new List <DatabaseModel.Item>();
            _scammerUsersItems = new List <DatabaseModel.Item>();

            _fakedGrpcServiceFactory = A.Fake <IGrpcServiceFactory>();
            _fakedBotService         = A.Fake <IBotService>();
            _fakeRepoServiceFacotry  = A.Fake <IRepoServiceFactory>();
            _fakedSteamServiceClient = A.Fake <ISteamServiceClientWrapper>();

            _fakedUserRepoService             = A.Fake <IUserRepoService>();
            _fakedItemRepoService             = A.Fake <IItemRepoService>();
            _fakedItemDescRepoService         = A.Fake <IItemDescriptionRepoService>();
            _fakedSettingsRepoService         = A.Fake <ISettingRepoService>();
            _fakedOfferTransactionRepoService = A.Fake <IOfferTranascrionRepoService>();


            _fakedOfferService = A.Fake <IOfferService>();

            A.CallTo(() => _fakeRepoServiceFacotry.UserRepoService).Returns(_fakedUserRepoService);
            A.CallTo(() => _fakeRepoServiceFacotry.ItemRepoService).Returns(_fakedItemRepoService);
            A.CallTo(() => _fakeRepoServiceFacotry.SettingRepoService).Returns(_fakedSettingsRepoService);
            A.CallTo(() => _fakeRepoServiceFacotry.ItemDescriptionRepoService).Returns(_fakedItemDescRepoService);
            A.CallTo(() => _fakeRepoServiceFacotry.OfferTranascrionRepoService).Returns(_fakedOfferTransactionRepoService);


            A.CallTo(() => _fakedUserRepoService.FindAsync("scammerUserSteamud")).Returns(_scammerUser);
            A.CallTo(() => _fakedUserRepoService.FindAsync("realUserSteamud")).Returns(_realUser);


            A.CallTo(() => _fakedItemRepoService.FindAsync(A <DatabaseModel.User> .That.Matches(user => user.Id == _realUser.Id)))
            .Returns(_realUsersItems);
            A.CallTo(() => _fakedItemRepoService.FindAsync(A <DatabaseModel.User> .That.Matches(user => user.Id == _scammerUser.Id)))
            .Returns(_scammerUsersItems);

            A.CallTo(() => _fakedGrpcServiceFactory.GetSteamServiceClient(A <ISteamInventoryCacheManager> ._)).Returns(_fakedSteamServiceClient);

            _steamService = new SteamService(
                _fakedGrpcServiceFactory,
                _fakeRepoServiceFacotry,
                _fakedBotService,
                A.Dummy <ILogServiceFactory>(),
                _fakedOfferService,
                A.Dummy <ISteamInventoryCacheManager>()
                );
        }
示例#3
0
 public SteamService
 (
     IGrpcServiceFactory grpcServiceFactory,
     IRepoServiceFactory repoServiceFactory,
     IBotService botService,
     ILogServiceFactory factory,
     IOfferService offerService,
     ISteamInventoryCacheManager cacheManager
 )
 {
     _logService = factory.CreateLogger<SteamService>();
     _repoServiceFactory = repoServiceFactory;
     _botService = botService;
     _offerService = offerService;
     _steamServiceClient = grpcServiceFactory.GetSteamServiceClient(cacheManager);
 }
示例#4
0
        public async Task <Dictionary <string, object> > CheckStatusOnGrpcServices()
        {
            var dict = new Dictionary <string, object>();

            var discordTimeTask = Ping(() => _grpcServiceFactory.GetDiscordSercviceClient().PingAsync());
            var historyTimeTask = Ping(() => _grpcServiceFactory.GetHistorySercviceClient().PingAsync());
            var chatTimeTask    = Ping(() => _grpcServiceFactory.GetChatSercviceClient().PingAsync());
            var steamTimeTask   = Ping(() => _grpcServiceFactory.GetSteamServiceClient(new SteamInventoryCacheManager()).PingAsync());
            var ticketTimeTask  = Ping(() => _grpcServiceFactory.GetTicketSercviceClient().PingAsync());

            await Task.WhenAll(chatTimeTask, discordTimeTask, historyTimeTask, steamTimeTask, ticketTimeTask);

            dict.Add("Discord", discordTimeTask.Result);
            dict.Add("History", historyTimeTask.Result);
            dict.Add("Chat", chatTimeTask.Result);
            dict.Add("steam", steamTimeTask.Result);
            dict.Add("ticket", ticketTimeTask.Result);

            return(dict);
        }
示例#5
0
        public OfferManagerTest()
        {
            _fakedSteamHubConnection = A.Fake <ISteamHubConnections>();
            _fakedOfferService       = A.Fake <IOfferService>();
            _fakedGrpcServiceFactory = A.Fake <IGrpcServiceFactory>();
            _fakedUserService        = A.Fake <IUserService>();
            _loggerDummy             = A.Dummy <ILogServiceFactory>();
            _fakedSteamServiceClient = A.Fake <ISteamServiceClientWrapper>();
            _fakedRepoServiceFactory = A.Fake <IRepoServiceFactory>();
            _fakedRakeItemRepo       = A.Fake <IRakeItemRepoService>();

            A.CallTo(() => _fakedRepoServiceFactory.RakeItemRepoService).Returns(_fakedRakeItemRepo);

            _offerMinmalInfo = new OfferStatusRequest
            {
                Bot = new Bot
                {
                    Username = "******",
                    SteamId  = "botSteamId"
                },
                SteamId       = "user Steamid",
                StatusCode    = int.MinValue,
                StatusMessage = "",
                OfferSend     = new OfferStatusOffer
                {
                    SteamOffer = new SteamOffer
                    {
                        ItemsToGive =
                        {
                            new Item {
                                AppId = 730, ContextId = "2", AssetId = "1"
                            },
                            new Item {
                                AppId = 730, ContextId = "2", AssetId = "2"
                            },
                            new Item {
                                AppId = 730, ContextId = "2", AssetId = "3"
                            },
                            new Item {
                                AppId = 730, ContextId = "2", AssetId = "4"
                            },
                            new Item {
                                AppId = 730, ContextId = "2", AssetId = "5"
                            },
                            new Item {
                                AppId = 730, ContextId = "2", AssetId = "6"
                            },
                        },
                        ItemsToReceive =
                        {
                            new Item {
                                AppId = 730, ContextId = "2", AssetId = "11"
                            },
                            new Item {
                                AppId = 730, ContextId = "2", AssetId = "12"
                            },
                            new Item {
                                AppId = 730, ContextId = "2", AssetId = "13"
                            },
                            new Item {
                                AppId = 730, ContextId = "2", AssetId = "14"
                            },
                            new Item {
                                AppId = 730, ContextId = "2", AssetId = "15"
                            },
                            new Item {
                                AppId = 730, ContextId = "2", AssetId = "16"
                            },
                        },
                    }
                }
            };

            var userFindRes =
                Task.FromResult(new DatabaseModel.User(_offerMinmalInfo.SteamId, null, null, null, DateTime.Today, DateTime.Today, false));

            A.CallTo(() => _fakedUserService.FindAsync(_offerMinmalInfo.SteamId)).Returns(userFindRes);
            A.CallTo(() => _fakedGrpcServiceFactory.GetSteamServiceClient(A <ISteamInventoryCacheManager> ._)).Returns(_fakedSteamServiceClient);

            A.CallTo(() => _fakedSteamServiceClient.GetPlayerInfoAsync(new GetPlayerInfoRequest
            {
                SteamId = _offerMinmalInfo.SteamId
            })).Returns(Task.FromResult(new GetPlayerInfoResponse
            {
                PlayerInfo = new PlayerInfo
                {
                    Avatar      = "",
                    PersonaName = ""
                }
            }));
        }