コード例 #1
0
        public void Links(string ip, string page, string source, string destination, int type)
        {
            var spyService = new SpyService();
            var sessionId  = CheckSession(ip);

            spyService.Links(ip, page, source, destination, type, sessionId);
        }
コード例 #2
0
        public void CookieAgree(string ip)
        {
            var spyService = new SpyService();
            var sessionId  = CheckSession(ip);

            spyService.CookieAgree(ip, sessionId);
        }
コード例 #3
0
        public void Pics(string ip, string name)
        {
            var spyService = new SpyService();
            var sessionId  = CheckSession(ip);

            spyService.Pics(ip, name, sessionId);
        }
コード例 #4
0
        public void FocusLost(string ip, string page)
        {
            var spyService = new SpyService();
            var sessionId  = CheckSession(ip);

            spyService.WriteFocusLost(page, ip, sessionId);
        }
コード例 #5
0
        public void GetReferer(string referer, string ip)
        {
            var spyService = new SpyService();
            var sessionId  = CheckSession(ip);

            spyService.WriteReferer(referer, ip, sessionId);
        }
コード例 #6
0
        public async Task CreateAsyncShouldFailForDuplicateSpyDataTest()
        {
            var mockRepository = GetMockRepository();
            var service        = new SpyService(mockRepository.Object, new SpyDetector());

            //Execute test
            var result = await Record.ExceptionAsync(async() => await service.CreateAsync(new ApiModel.SpyModel
            {
                Name = "James Bond",
                Code = new[] { 1 }
            }));

            // Verify test result
            result.Should().NotBeNull();
            result.Should().BeOfType <ArgumentException>();

            result = await Record.ExceptionAsync(async() => await service.CreateAsync(new ApiModel.SpyModel
            {
                Name = "New Bond",
                Code = new[] { 0, 0, 7 }
            }));

            // Verify test result
            result.Should().NotBeNull();
            result.Should().BeOfType <ArgumentException>();
        }
コード例 #7
0
        public void ExitLog(int time, string page, string ip)
        {
            var spyService = new SpyService();
            var sessionId  = CheckSession(ip);

            spyService.WriteExit(time, page, ip, sessionId);
        }
コード例 #8
0
        public void LoadTime(string ip, int time, string page)
        {
            var spyService = new SpyService();
            var sessionId  = CheckSession(ip);

            spyService.WriteLoad(time, page, ip, sessionId);
        }
コード例 #9
0
        public void GetBrowser(string browser, string ip)
        {
            var spyService = new SpyService();
            var sessionId  = CheckSession(ip);

            spyService.WriteBrowser(browser, ip, sessionId);
        }
コード例 #10
0
        public void GetGeo(string geo, string ip)
        {
            var spyService = new SpyService();
            var sessionId  = CheckSession(ip);

            spyService.WriteGeo(geo, ip, sessionId);
        }
コード例 #11
0
        public void GetIp(string ip)
        {
            var spyService = new SpyService();
            var sessionId  = CheckSession(ip);

            spyService.CheckIp(ip);
        }
コード例 #12
0
ファイル: JobsBootstrapper.cs プロジェクト: DoctorSoft/fbkBot
        public static void SetUpJobs()
        {
            //todo: uncomment it back
            var homeService   = new HomeService(new JobService(), new BackgroundJobService());
            var accountModels = homeService.GetAccounts();

            var groupService = new GroupService(new NoticeService());

            new JobService().AddOrUpdateGeneralJobs();

            foreach (var account in accountModels)
            {
                var settings = account.GroupSettingsId != null?groupService.GetSettings((long)account.GroupSettingsId) : null;

                var model = new AddOrUpdateAccountModel
                {
                    Account     = account,
                    NewSettings = settings,
                    OldSettings = null
                };

                new BackgroundJobService().AddOrUpdateAccountJobs(model);

                new JobService().AddOrUpdateAccountJobs(model);
            }

            var spyAccounts = new SpyService(new JobService()).GetSpyAccounts();

            foreach (var spyAccount in spyAccounts)
            {
                var model = new AddOrUpdateAccountModel
                {
                    Account = new AccountViewModel
                    {
                        Id                        = spyAccount.Id,
                        FacebookId                = spyAccount.FacebookId,
                        Login                     = spyAccount.Login,
                        Name                      = spyAccount.Name,
                        Proxy                     = spyAccount.Proxy,
                        ProxyLogin                = spyAccount.ProxyLogin,
                        ProxyPassword             = spyAccount.ProxyPassword,
                        Password                  = spyAccount.Password,
                        PageUrl                   = spyAccount.PageUrl,
                        Cookie                    = spyAccount.Cookie,
                        ConformationDataIsFailed  = spyAccount.ConformationIsFailed,
                        AuthorizationDataIsFailed = spyAccount.AuthorizationDataIsFailed,
                        ProxyDataIsFailed         = spyAccount.ProxyDataIsFailed
                    },
                    IsForSpy = true
                };

                //new BackgroundJobService().AddOrUpdateAccountJobs(model);

                new JobService().AddOrUpdateSpyAccountJobs(model);
            }
        }
コード例 #13
0
        public async Task GetAllSpyTest()
        {
            var mockRepository = GetMockRepository();
            var service        = new SpyService(mockRepository.Object, new SpyDetector());

            //Execute test
            var result = await service.GetAllAsync();

            // Verify test result
            result.Should().NotBeNull();
            result.Should().Match(r => r.Any());
        }
コード例 #14
0
        private bool CheckSession()
        {
            var  spyService = new SpyService();
            Guid sessionId  = new Guid();

            if (HttpContext.Session.Keys.Contains("ipAddress"))
            {
                var ip = HttpContext.Session.GetString("ipAddress");
                if (!HttpContext.Session.Keys.Contains("sessionId"))
                {
                    sessionId = Guid.Parse(HttpContext.Session.Id);
                    HttpContext.Session.SetString("sessionId", HttpContext.Session.Id);
                    spyService.CreateSession(ip, sessionId);
                }
            }
            else
            {
                return(false);
            }

            return(true);
        }
コード例 #15
0
        public IActionResult Result(int degreeSelect, int degreeRouteSelect, string organizationText, int innerRouteSelect)
        {
            string ip          = "non defined ip";
            Guid   sessionId   = new Guid();
            var    testService = new TestService();
            var    spyService  = new SpyService();

            if (HttpContext.Session.Keys.Contains("ipAddress"))
            {
                ip = HttpContext.Session.GetString("ipAddress");
                if (!HttpContext.Session.Keys.Contains("sessionId"))
                {
                    HttpContext.Session.SetString("sessionId", HttpContext.Session.Id);
                    spyService.CreateSession(ip, sessionId);
                }
                else
                {
                    sessionId = Guid.Parse(HttpContext.Session.Id);
                }
            }

            ViewBag.Results = testService.TestResults(ip, sessionId, degreeSelect, degreeRouteSelect, organizationText, innerRouteSelect);
            return(View());
        }
コード例 #16
0
        private Guid CheckSession(string ip)
        {
            var  spyService = new SpyService();
            Guid sessionId  = new Guid();

            if (!HttpContext.Session.Keys.Contains("sessionId"))
            {
                sessionId = Guid.Parse(HttpContext.Session.Id);
                HttpContext.Session.SetString("sessionId", HttpContext.Session.Id);
                spyService.CreateSession(ip, sessionId);
            }
            else
            {
                sessionId = Guid.Parse(HttpContext.Session.GetString("sessionId"));
            }

            if (!HttpContext.Session.Keys.Contains("ipAddress") &&
                ip != null)
            {
                HttpContext.Session.SetString("ipAddress", ip);
            }

            return(sessionId);
        }
コード例 #17
0
 public SpyController(ISpyRepository repository, SpyDetector spyDetector, SpyService spyService)
 {
     _spyDetector = spyDetector;
     _repository  = repository;
     _spyService  = spyService;
 }
コード例 #18
0
        public static void Main(string[] args)
        {
            _queueService            = new JobQueueService();
            _runnerService           = new RunnerService();
            _runnerPermissionService = new RunnerPermissionService();

            var i = 1;

            AddRunnerInfo();

            while (true)
            {
                if (!_runnerPermissionService.HasPermissions(_runnerId))
                {
                    Console.WriteLine(string.Format("Запуск запрещён"));
                    Thread.Sleep(Delay);
                    continue;
                }
                try
                {
                    Console.WriteLine(string.Format("{0} запуск", i));

                    var accounts    = new HomeService(new JobService(), new BackgroundJobService()).GetAccounts();
                    var spyAccounts = new SpyService(new JobService()).GetSpyAccounts();

                    var overdueQueues = _queueService.RemoveOverdueQueue(OverdueMin);
                    if (overdueQueues != 0)
                    {
                        Console.WriteLine(string.Format("Из очереди исключено {0} задач с превышением времени выполнения ({1} min.)", overdueQueues, OverdueMin));
                    }

                    var queues = _queueService.GetGroupedQueue();

                    Console.WriteLine(string.Format("{0} аккаунтов в очереди", queues.Count));
                    foreach (var queue in queues)
                    {
                        var firstElement = queue.FirstOrDefault();
                        if (firstElement == null)
                        {
                            continue;
                        }

                        Console.WriteLine(string.Format("{0} задач в очереди для аккаунта {1}", queue.Count,
                                                        firstElement.AccountId));

                        AccountViewModel account;
                        if (firstElement.IsForSpy)
                        {
                            var spyAccount = spyAccounts.FirstOrDefault(model => model.Id == firstElement.AccountId);
                            if (spyAccount == null)
                            {
                                continue;
                            }

                            account = new AccountViewModel
                            {
                                Id                        = spyAccount.Id,
                                Login                     = spyAccount.Login,
                                Proxy                     = spyAccount.Proxy,
                                FacebookId                = spyAccount.FacebookId,
                                ProxyLogin                = spyAccount.ProxyLogin,
                                Name                      = spyAccount.Name,
                                ProxyPassword             = spyAccount.ProxyPassword,
                                ConformationDataIsFailed  = spyAccount.ConformationIsFailed,
                                AuthorizationDataIsFailed = spyAccount.AuthorizationDataIsFailed,
                                ProxyDataIsFailed         = spyAccount.ProxyDataIsFailed,
                                Cookie                    = spyAccount.Cookie,
                                PageUrl                   = spyAccount.PageUrl,
                                Password                  = spyAccount.Password
                            };
                        }
                        else
                        {
                            account = accounts.FirstOrDefault(model => model.Id == firstElement.AccountId);
                        }

                        foreach (var currentQueue in queue)
                        {
                            _queueService.MarkIsProcessedQueue(currentQueue); // помечаем задачу как "в процессе"
                        }

                        var queueData  = queue;
                        var runnerTask = new Task(() => RunnerTask(queueData, account));

                        runnerTask.Start();
                    }

                    Console.WriteLine($"ждем {Delay / 1000} сек. для следующего запуска");
                    Thread.Sleep(Delay);
                    i++;

                    _runnerService.UpdateRunnerActivityDate(_runnerId);
                }
                catch (Exception ex)
                {
                    LogWriter.LogWriter.AddToLog(string.Format("{0} ({1})", ex.Message, ex.InnerException));
                }
            }
        }
コード例 #19
0
 public SpyCookiesController()
 {
     this.spyService = new SpyService(new JobService());
 }
コード例 #20
0
 public SpyOptionsController()
 {
     this.spyService         = new SpyService(new JobService());
     this.spySettingsService = new SpySettingsService(new JobService());
 }
コード例 #21
0
 public SpyEditorController()
 {
     this.spyService = new SpyService(new JobService());
 }