Ejemplo n.º 1
0
        //protected void Page_Unload(object sender, EventArgs e)
        //{
        //    if (!DoneFlag)
        //    {
        //        SatyamTaskTableEntry taskEntry = JSonUtils.ConvertJSonToObject<SatyamTaskTableEntry>(Hidden_TaskEntryString.Value);
        //        if (taskEntry == null) return;
        //        // Decrement the DoneScore, releasing token after latest results are saved.
        //        SatyamTaskTableAccess taskTableDB = new SatyamTaskTableAccess();
        //        taskTableDB.DecrementDoneScore(taskEntry.ID);
        //        taskTableDB.close();
        //    }
        //}

        protected void SubmitButton_Click(object sender, EventArgs e)
        {
            DateTime SubmitTime   = DateTime.Now;
            DateTime PageLoadTime = Convert.ToDateTime(Hidden_PageLoadTime.Value);

            SatyamTaskTableEntry taskEntry = JSonUtils.ConvertJSonToObject <SatyamTaskTableEntry>(Hidden_TaskEntryString.Value);

            SatyamResult result = new SatyamResult();

            result.TaskParametersString = taskEntry.TaskParametersString;
            result.TaskStartTime        = PageLoadTime;
            result.TaskEndTime          = SubmitTime;
            result.TaskTableEntryID     = taskEntry.ID;

            AmazonTaskResultInfo amazonInfo = new AmazonTaskResultInfo();

            amazonInfo.AssignmentID = "";
            amazonInfo.WorkerID     = "";
            amazonInfo.HITID        = "";

            result.amazonInfo   = amazonInfo;
            result.TaskResult   = Hidden_Result.Value;
            result.PrevResultID = Convert.ToInt32(Hidden_PrevResultID.Value);

            string resultString = JSonUtils.ConvertObjectToJSon <SatyamResult>(result);

            SatyamResultsTableAccess resultdb = new SatyamResultsTableAccess();

            resultdb.AddEntry(taskEntry.JobTemplateType, taskEntry.UserID, taskEntry.JobGUID, resultString, taskEntry.ID, PageLoadTime, SubmitTime);
            resultdb.close();

            SatyamTaskTableManagement.UpdateResultNumber(taskEntry.ID);

            // Decrement the DoneScore, releasing token after latest results are saved.
            SatyamTaskTableAccess taskTableDB = new SatyamTaskTableAccess();

            //taskTableDB.DecrementDoneScore(taskEntry.ID);
            taskTableDB.UpdateDoneScore(taskEntry.ID, 0);
            taskTableDB.close();

            //DoneFlag = true;

            //bool NotDone = getNewRandomJob();
            //if (NotDone == false)
            //{
            Response.Redirect("AllJobsDone.aspx");
            //}
        }
        protected void SubmitButton_Click(object sender, EventArgs e)
        {
            DateTime SubmitTime   = DateTime.Now;
            DateTime PageLoadTime = Convert.ToDateTime(Hidden_PageLoadTime.Value);

            SatyamTaskTableEntry taskEntry = JSonUtils.ConvertJSonToObject <SatyamTaskTableEntry>(Hidden_TaskEntryString.Value);

            SatyamResult result = new SatyamResult();

            result.TaskParametersString = taskEntry.TaskParametersString;
            result.TaskStartTime        = PageLoadTime;
            result.TaskEndTime          = SubmitTime;
            result.TaskTableEntryID     = taskEntry.ID;

            AmazonTaskResultInfo amazonInfo = new AmazonTaskResultInfo();

            amazonInfo.AssignmentID = Hidden_AmazonAssignmentID.Value;
            amazonInfo.WorkerID     = Hidden_AmazonWorkerID.Value;
            amazonInfo.HITID        = Hidden_HITID.Value;
            amazonInfo.PricePerHIT  = Convert.ToDouble(Hidden_Price.Value);

            result.amazonInfo   = amazonInfo;
            result.TaskResult   = Hidden_Result.Value;
            result.PrevResultID = Convert.ToInt32(Hidden_PrevResultID.Value);

            string resultString = JSonUtils.ConvertObjectToJSon <SatyamResult>(result);

            SatyamResultsTableAccess resultdb = new SatyamResultsTableAccess();

            resultdb.AddEntry(taskEntry.JobTemplateType, taskEntry.UserID, taskEntry.JobGUID, resultString, taskEntry.ID, PageLoadTime, SubmitTime);
            resultdb.close();

            SatyamTaskTableManagement.UpdateResultNumber(taskEntry.ID);

            // Decrement the DoneScore, releasing token after latest results are saved.
            SatyamTaskTableAccess taskTableDB = new SatyamTaskTableAccess();

            //taskTableDB.DecrementDoneScore(taskEntry.ID);
            taskTableDB.UpdateDoneScore(taskEntry.ID, 0);
            taskTableDB.close();

            int noDone = Convert.ToInt32(Hidden_NoImagesDone.Value);

            noDone++;
            Hidden_NoImagesDone.Value = noDone.ToString();

            int noTasksPerJob = Convert.ToInt32(Hidden_TasksPerJob.Value);

            bool NotDone = false;

            //if (noDone < noTasksPerJob)
            //{
            //    NotDone = getNewRandomJob();
            //}
            if (NotDone == false)
            {
                if (!Testing)
                {
                    SatyamAmazonHITTableAccess HITdb = new SatyamAmazonHITTableAccess();
                    string HITID = result.amazonInfo.HITID;
                    HITdb.UpdateStatusByHITID(HITID, HitStatus.submitted);
                    HITdb.close();
                    AmazonMTurkNotification.submitAmazonTurkHit(result.amazonInfo.AssignmentID, result.amazonInfo.WorkerID, false);
                }

                Response.Redirect("MTurkTaskDonePage.aspx");
            }
        }