Esempio n. 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);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Unmarshaller the response from the service to the response class.
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        public override AmazonWebServiceResponse Unmarshall(JsonUnmarshallerContext context)
        {
            CreateHITResponse response = new CreateHITResponse();

            context.Read();
            int targetDepth = context.CurrentDepth;

            while (context.ReadAtDepth(targetDepth))
            {
                if (context.TestExpression("HIT", targetDepth))
                {
                    var unmarshaller = HITUnmarshaller.Instance;
                    response.HIT = unmarshaller.Unmarshall(context);
                    continue;
                }
            }

            return(response);
        }