Exemplo n.º 1
0
 public async Task CreateSocialLoginAccountAsync(StoreAgent storeAgent, string account)
 {
     var client    = storeAgent.StorageAccount.CreateCloudTableClient();
     var tablename = StoreManager.UserInfoHistoryTableName + account;
     var table     = client.GetTableReference(tablename);
     await table.CreateIfNotExistsAsync();
 }
Exemplo n.º 2
0
        public async Task CreateSocialLoginHistoryRecordAsync(StoreAgent storeAgent, string account, string channel, string channelId, string platform, string action, DateTime timeStart)
        {
            var entity = new SocialLoginHistoryTableEntity(account, channel, channelId, platform, action, timeStart);

            var client = storeAgent.StorageAccount.CreateCloudTableClient();

            // Tablename change with account
            var tablename = StoreManager.UserInfoHistoryTableName + account;
            var table     = client.GetTableReference(tablename);
            await SocialLoginHistoryTableEntity.InsertSocialLoginHistoryTableEntity(table, entity);
        }
Exemplo n.º 3
0
        public async Task DeleteSocialLoginHistoryDataAsync(StoreAgent storeAgent)
        {
            var client = storeAgent.StorageAccount.CreateCloudTableClient();

            // Delete history data 6 months ago
            int monthCount = 6;
            var startTime  = new DateTime(DateTime.UtcNow.Year, DateTime.UtcNow.Month - monthCount, 1).Ticks.ToString();

            try
            {
                var tableList = client.ListTables(StoreManager.UserInfoHistoryTableName);
                if (tableList != null)
                {
                    foreach (var table in tableList.ToList())
                    {
                        if (await table.ExistsAsync())
                        {
                            var projectionQuery = new TableQuery()
                                                  .Where(TableQuery.GenerateFilterCondition("PartitionKey", QueryComparisons.LessThan, startTime))
                                                  .Select(new[] { "RowKey" });

                            var entities = table.ExecuteQuery(projectionQuery).ToList();
                            var offset   = 0;
                            while (offset < entities.Count)
                            {
                                var batch = new TableBatchOperation();
                                var rows  = entities.Skip(offset).Take(100).ToList();
                                foreach (var row in rows)
                                {
                                    batch.Delete(row);
                                }

                                await table.ExecuteBatchAsync(batch);

                                offset += rows.Count;
                            }
                        }
                    }
                }

                SocialProviderEventSource.Current.Info(SocialProviderEventSource.EmptyTrackingId, this, nameof(this.DeleteSocialLoginHistoryDataAsync), OperationStates.Succeeded, string.Empty);
            }
            catch (Exception ex)
            {
                SocialProviderEventSource.Current.ErrorException(SocialProviderEventSource.EmptyTrackingId, this, nameof(this.DeleteSocialLoginHistoryDataAsync), OperationStates.Failed, "Failed to delete history data in storage table", ex);
            }
        }
Exemplo n.º 4
0
        public void Start()
        {
            log.Debug("Site Processor starting...");
            if (isRunning)
            {
                log.Warn("Site Processor is already running");
                return;
            }
            isRunning = true;
            crawler   = new CrawlerAgent();
            crawler.Init(this, site.Id);

            matcher = new Matcher();
            matcher.Init(crawler, this);
            foreach (var cat in site.Categories)
            {
                var agent = new StoreAgent();
                agent.Init(cat.Id, site.OutputFolder);
                storeAgents.Add(cat.Name, agent);
            }
            crawler.Start();
            log.Debug("Site Processor started");
        }