Exemplo n.º 1
0
        private void AddSourceTask(ICaptchaHarvesterTask harvesterTask = null, bool isAuto = true)
        {
            RecaptchaParameter taskParameter = harvesterTask?.Parameter as RecaptchaParameter;

            RecaptchaParameter parameter = new RecaptchaParameter()
            {
                SiteKey  = taskParameter?.SiteKey ?? SiteKey,
                SitePath = taskParameter?.SitePath ?? SitePath
            };

            ICaptchaSolutionSourceTask sourceTask = null;

            if (isAuto)
            {
                sourceTask = GetSolutionSource()?.GetSolution(parameter);
            }
            else
            {
                sourceTask = m_manualSource.GetSolution(parameter);
            }

            if (sourceTask != null)
            {
                sourceTask.SolutionReleased += SolutionReleaseEventHanlder;

                m_sourceTasks[sourceTask] = taskParameter != null ? harvesterTask : null;
            }
        }
Exemplo n.º 2
0
        private void ProcessSourceTask(ICaptchaSolutionSourceTask sourceTask)
        {
            if (sourceTask.Solution != null)
            {
                ICaptchaHarvesterTask harvesterTask     = null;
                RecaptchaSolution     recaptchaSolution = null;

                lock (m_lock)
                {
                    harvesterTask = m_sourceTasks[sourceTask] != null ? m_sourceTasks[sourceTask] : m_tasks.FirstOrDefault(t => !m_sourceTasks.ContainsValue(t));

                    m_tasks.Remove(harvesterTask);

                    recaptchaSolution = new RecaptchaSolution(sourceTask.Solution as string);
                }

                AddSolution(recaptchaSolution, harvesterTask);
            }

            lock (m_lock)
            {
                sourceTask.SolutionReleased -= SolutionReleaseEventHanlder;
                m_sourceTasks.Remove(sourceTask);
            }

            RestoreBalance();

            lock (m_lock)
            {
                if (m_manualSource.CurrentTask == null)
                {
                    AddSourceTask(m_tasks.FirstOrDefault(), false);
                }
            }
        }
Exemplo n.º 3
0
        private void SolutionReleaseEventHanlder(object sender, EventArgs args)
        {
            ICaptchaSolutionSourceTask sourceTask = sender as ICaptchaSolutionSourceTask;

            ProcessSourceTask(sourceTask);
        }