示例#1
0
        // GET: Monitoring
        public async Task <ActionResult> Index()
        {
            var model = new MonitoringViewModel();
            TwitterApiResponse <Dictionary <string, RateLimit> > response = await TwitterApiManager.GetRateLimits();

            model.RateLimits = response.Content;
            try
            {
                model.LastNameChecks = await NameCheckDataService.GetCollectionAsync();

                model.LastNameCheckBatches = await NameCheckBatchDataService.GetCollectionAsync();
            }
            catch (Exception ex)
            {
                model.Error = ex;
            }

            model.Configuration = ReadConfiguration();
            return(View(model));
        }
示例#2
0
        public async Task <NameCheckModel> NameCheckAsync(string name, EndpointType endpointType = EndpointType.NotSet, string userIp = null)
        {
            Guard.ArgumentNotNullOrWhiteSpace(name, "name");
            Stopwatch timer = new Stopwatch();

            timer.Start();

            var key    = NameCheckHelper.FormatKey(name);
            var result = Cache.GetItem(key);

            if (result != null)
            {
                return(result);
            }

            result              = new NameCheckModel();
            result.Id           = DescendingSortedGuid.NewSortedGuid();
            result.Key          = key;
            result.DateUtc      = DateTime.UtcNow;
            result.EndpointType = endpointType;
            result.Name         = NameCheckHelper.FormatName(name);
            result.Query        = NameCheckHelper.FormatQuery(name);
            result.UserIp       = userIp;

            var twitterResult = await TwitterApiManager.IsNameAvailable(result.Query);

            var gandiResult = GandiApiManager.CheckDomains(result.Query, new string[] { "com", "net", "org" });

            result.SocialNetworks = new Dictionary <string, bool>();
            result.SocialNetworks.Add("twitter", twitterResult.Content);
            result.Domains = gandiResult;

            timer.Stop();
            result.QueryDurationMs = timer.ElapsedMilliseconds;
            Cache.AddItem(key, result);
            return(result);
        }