示例#1
0
 public VotingRepository(StateCache state, TimeCache time, AccountsCache accounts, ProposalMetadataService proposalMetadata, IConfiguration config) : base(config)
 {
     State            = state;
     Time             = time;
     Accounts         = accounts;
     ProposalMetadata = proposalMetadata;
 }
示例#2
0
 public BalanceHistoryRepository(StateCache state, AccountsCache accounts, QuotesCache quotes, TimeCache time, IConfiguration config) : base(config)
 {
     State    = state;
     Accounts = accounts;
     Quotes   = quotes;
     Time     = time;
 }
示例#3
0
 public BakingRightsRepository(AccountsCache accounts, ProtocolsCache protocols, TimeCache time, StateCache state, IConfiguration config) : base(config)
 {
     Accounts  = accounts;
     Protocols = protocols;
     Time      = time;
     State     = state;
 }
示例#4
0
 public BlockRepository(AccountsCache accounts, OperationRepository operations, QuotesCache quotes, StateCache state, SoftwareCache software, IConfiguration config) : base(config)
 {
     Accounts   = accounts;
     Operations = operations;
     Quotes     = quotes;
     State      = state;
     Software   = software;
 }
示例#5
0
 public SyncWorker(AccountsCache accounts, StateCache state, TimeCache times, IConfiguration config, ILogger <SyncWorker> logger)
 {
     Config           = config.GetSyncConfig();
     ConnectionString = config.GetConnectionString("DefaultConnection");
     Accounts         = accounts;
     State            = state;
     Times            = times;
     Logger           = logger;
 }
示例#6
0
 public CacheService(TzktContext db)
 {
     AppState     = new AppStateCache(db);
     BakerCycles  = new BakerCyclesCache(db);
     BakingRights = new BakingRightsCache(db);
     Accounts     = new AccountsCache(this, db);
     Blocks       = new BlocksCache(this, db);
     Periods      = new PeriodsCache(db);
     Proposals    = new ProposalsCache(db);
     Protocols    = new ProtocolsCache(db);
 }
示例#7
0
 public CacheService(TzktContext db)
 {
     AppState     = new AppStateCache(db);
     BakerCycles  = new BakerCyclesCache(db);
     BakingRights = new BakingRightsCache(db);
     Accounts     = new AccountsCache(this, db);
     Blocks       = new BlocksCache(this, db);
     Periods      = new PeriodsCache(db);
     Proposals    = new ProposalsCache(db);
     Protocols    = new ProtocolsCache(db);
     Statistics   = new StatisticsCache(db);
     Software     = new SoftwareCache(db);
     Schemas      = new SchemasCache(db);
     Storages     = new StoragesCache(db);
 }
示例#8
0
        public void CreateNewAccountTest()
        {
            var accountsCache  = new AccountsCache(Enumerable.Empty <Account>());
            var userStateCache = new UsersCache(Enumerable.Empty <TimeWarpUser>());
            var persistence    = new FakeEntityPersistence <Account>();
            var calc           = FakeTimeCalculatorFactory.GetTimeWarpStateCalculator();
            AccountController accountController = new AccountController(accountsCache, persistence, userStateCache, calc);

            var result = accountController.Post("new user", "eamil@sdaisd", "newPassword");

            var stored = persistence.SavedItems.Single();

            Assert.AreEqual(0, result);
            Assert.AreEqual("new user", stored.Name);
            Assert.AreEqual("eamil@sdaisd", stored.Email);
        }
        public void SetupController()
        {
            //arrange
            var testRoom1   = new Room(1, "testRoom1", new DateTime(2000, 12, 12));
            var testRoom2   = new Room(2, "testRoom2", new DateTime(2001, 12, 12));
            var testAccount = new Account(1, "ashley", "*****@*****.**", "beanland");

            _roomsCache    = new RoomsCache(new[] { testRoom1, testRoom2 });
            _accountsCache = new AccountsCache(new[] { testAccount });

            _entityPersistence = new FakeEntityPersistence <Room>();
            _nowProvider       = new FakeNowProvider();

            var roomsController = new RoomInfoController(_roomsCache, _accountsCache, _entityPersistence,
                                                         _nowProvider);

            _roomInfoController = roomsController;
        }
示例#10
0
 static Factory()
 {
     accountCache = new AccountsCache();
     chatCache    = new RoomCache();
 }
示例#11
0
 public AnyOfBinder(AccountsCache accounts)
 {
     Accounts = accounts;
 }
示例#12
0
 public AccountBinder(AccountsCache accounts)
 {
     Accounts = accounts;
 }
示例#13
0
 public CommitmentRepository(AccountsCache accounts, TimeCache time, IConfiguration config) : base(config)
 {
     Accounts = accounts;
     Time     = time;
 }
示例#14
0
 public VotingRepository(AccountsCache accounts, ProposalMetadataService proposalMetadata, IConfiguration config) : base(config)
 {
     Accounts         = accounts;
     ProposalMetadata = proposalMetadata;
 }
示例#15
0
 public BalanceHistoryRepository(AccountsCache accounts, TimeCache time, IConfiguration config) : base(config)
 {
     Accounts = accounts;
     Time     = time;
 }
示例#16
0
 public VotingRepository(StateCache state, TimeCache time, AccountsCache accounts, IConfiguration config) : base(config)
 {
     State    = state;
     Time     = time;
     Accounts = accounts;
 }
示例#17
0
 public ReportRepository(AccountsCache accounts, QuotesCache quotes, IConfiguration config) : base(config)
 {
     Accounts = accounts;
     Quotes   = quotes;
 }
        public async Task <IActionResult> Login([FromServices] IGoogleAuthProvider auth)
        {
            var cred = await auth.GetCredentialAsync();

            var service = new AnalyticsService(new BaseClientService.Initializer
            {
                HttpClientInitializer = cred
            });

            // var accessToken = await cred.UnderlyingCredential.GetAccessTokenForRequestAsync();
            // WebRequest request = WebRequest.Create($"https://www.googleapis.com/oauth2/v1/userinfo?access_token={accessToken}");
            // HttpWebResponse response = (HttpWebResponse)request.GetResponse();
            // Stream dataStream = response.GetResponseStream();
            // StreamReader reader = new StreamReader(dataStream);
            // string responseFromServer = reader.ReadToEnd();
            // var data = JsonConvert.DeserializeObject<GoogleUser>(responseFromServer);

            // cleaned up above a little bit
            var accessToken = await cred.UnderlyingCredential.GetAccessTokenForRequestAsync();

            WebRequest      request    = WebRequest.Create($"https://www.googleapis.com/oauth2/v1/userinfo?access_token={accessToken}");
            HttpWebResponse response   = (HttpWebResponse)request.GetResponse();
            Stream          dataStream = response.GetResponseStream();
            StreamReader    reader     = new StreamReader(dataStream);
            var             json       = new JsonTextReader(reader);
            var             data       = (new JsonSerializer()).Deserialize <GoogleUser>(json);

            var user = await context.User.FirstOrDefaultAsync(u => u.GoogleId == data.id);

            if (user == null)
            {
                user = new User(data);
                await context.User.AddAsync(user);
            }
            user.Token = accessToken;
            await context.SaveChangesAsync();

            // clear the "cache"
            // MATCHING USER ID && ACCOUNT ID
            var accountsToDelete = context.AccountsCache.Where(w => w.UserId == user.Id);

            foreach (var account in accountsToDelete)
            {
                var filtersToDelete = context.FiltersCache.Where(w => w.AccountsCacheId == account.Id);
                context.FiltersCache.RemoveRange(filtersToDelete);
            }
            context.AccountsCache.RemoveRange(accountsToDelete);
            await context.SaveChangesAsync();

            var accounts = await service.Management.Accounts.List().ExecuteAsync();

            foreach (var account in accounts.Items)
            {
                var _account = new AccountsCache {
                    GoogleAccountId = account.Id, Name = account.Name, UserId = user.Id
                };
                // save the account
                await context.AccountsCache.AddAsync(_account);

                // get the filters
                var filters = await service.Management.Filters.List(account.Id).ExecuteAsync();

                // save the filters
                var excludeFilters = filters.Items.Where(w => w.ExcludeDetails != null);
                foreach (var filter in excludeFilters)
                {
                    var _filter = new FiltersCache {
                        Name = filter.Name, GoogleFilterId = filter.Id, FilterValue = filter.ExcludeDetails.ExpressionValue, AccountsCacheId = _account.Id
                    };
                    await context.FiltersCache.AddAsync(_filter);
                }
            }
            await context.SaveChangesAsync();


            return(Redirect("/app"));
        }
     process : async(AccountsCache cache, Guid id) =>
 {
     if (cache.TryGetValue(id, out AccountProcess account))
示例#20
0
 public BlockRepository(AccountsCache accounts, OperationRepository operations, StateCache state, IConfiguration config) : base(config)
 {
     Accounts   = accounts;
     Operations = operations;
     State      = state;
 }