Beispiel #1
0
        public async Task <CreateHITResponse> createHit(Survey survey, string reward, int maxSurveys)
        {
            CreateHITResponse response = new CreateHITResponse();

            try
            {
                this._survey = survey;
                AmazonMTurkClient client      = this.getMTurkClient();
                string            questionXML = "";
                CreateHITRequest  hitRequest  = new CreateHITRequest();
                hitRequest.Title       = this._survey.SurveyName;
                hitRequest.Reward      = reward;
                hitRequest.Question    = this.getExternalForm();
                hitRequest.Description = this._survey.Notes;
                hitRequest.AssignmentDurationInSeconds = 7200;
                hitRequest.LifetimeInSeconds           = 7200;
                hitRequest.MaxAssignments = maxSurveys;
                Qualification qualification = new Qualification();
                qualification.QualificationTypeId = "00000000000000000071";
                QualificationType qType = new QualificationType();
                System.Threading.CancellationToken token = new System.Threading.CancellationToken();
                response = await client.CreateHITAsync(hitRequest, token);

                return(response);
            }
            catch (Exception e)
            {
                Console.Write(e);
                return(response);
            }
        }
        protected IAmazonMTurk CreateClient(AWSCredentials credentials, RegionEndpoint region)
        {
            var config = new AmazonMTurkConfig {
                RegionEndpoint = region
            };

            Amazon.PowerShell.Utils.Common.PopulateConfig(this, config);
            this.CustomizeClientConfig(config);
            var client = new AmazonMTurkClient(credentials, config);

            client.BeforeRequestEvent += RequestEventHandler;
            client.AfterResponseEvent += ResponseEventHandler;
            return(client);
        }
Beispiel #3
0
        public AmazonMTurkClient getMTurkClient()
        {
            try
            {
                AmazonMTurkConfig config = new AmazonMTurkConfig();
                config.ServiceURL = _appSettings.awsTurkEndpoint;
                AmazonMTurkClient client = new AmazonMTurkClient(_appSettings.awsAccessKey, _appSettings.awsSecret, config);
                return(client);
            }catch (Exception e)
            {
            }

            throw new Exception("Could not load Mturk Credentials");
        }
Beispiel #4
0
        public async Task <string> getBalance()
        {
            AmazonMTurkClient        client         = this.getMTurkClient();
            GetAccountBalanceRequest BalanceRequest = new GetAccountBalanceRequest();

            try
            {
                GetAccountBalanceResponse response = await client.GetAccountBalanceAsync(BalanceRequest);

                return(response.AvailableBalance);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
            throw new Exception("Uh OH! Something went wrong!");
        }