public static void CreateDemoJob_OBJECT_COUNTING_IN_VIDEO() { SatyamJob job = new SatyamJob(); AzureInformation AzureInfo = new AzureInformation(); AzureInfo.AzureBlobStorageConnectionString = SatyamJobStorageAccountAccess.connection_string; AzureInfo.AzureBlobStorageContainerName = "demo"; AzureInfo.AzureBlobStorageContainerDirectoryName = "PedestrianCountingDemo"; AmazonMTurkHITInformation AmazonInfo = new AmazonMTurkHITInformation(); ObjectCountingSubmittedJob template = new ObjectCountingSubmittedJob(); template.ObjectName = "pedestrian"; template.Description = "By pedestrians we mean people walking or on wheel chairs not cyclists."; job.JobGUIDString = "OBJECT_COUNTING_IN_VIDEO_DEMO"; job.amazonHITInformation = AmazonInfo; job.azureInformation = AzureInfo; job.JobSubmitTime = DateTime.Now; job.JobTemplateType = "OBJECT_COUNTING_IN_VIDEO_DEMO"; job.UserID = TaskConstants.AdminName; job.JobParameters = JSonUtils.ConvertObjectToJSon <ObjectCountingSubmittedJob>(template); string JobParametersString = JSonUtils.ConvertObjectToJSon <SatyamJob>(job); SatyamJobSubmissionsTableAccess jobDB = new SatyamJobSubmissionsTableAccess(); jobDB.AddEntry(job.JobTemplateType, job.UserID, job.JobGUIDString, JobParametersString, job.JobSubmitTime); jobDB.close(); }
private bool getNewRandomJob() { double price = 0; bool success = Double.TryParse(Hidden_Price.Value, out price); if (!success) { price = 0; } SatyamTaskTableAccess taskTableDB = new SatyamTaskTableAccess(); SatyamTaskTableEntry entry = null; if (SubmitButton.Enabled == true) { //entry = taskTableDB.getMinimumTriedEntryByTemplateAndPrice(TaskConstants.Counting_Image_MTurk, price); entry = taskTableDB.getMinimumTriedNewEntryForWorkerIDByTemplateAndPrice(Hidden_AmazonWorkerID.Value, TaskConstants.Counting_Image_MTurk, price); } else { entry = taskTableDB.getMinimumTriedEntryByTemplate(TaskConstants.Counting_Image_MTurk); } if (entry != null) { taskTableDB.IncrementDoneScore(entry.ID); SatyamTask task = JSonUtils.ConvertJSonToObject <SatyamTask>(entry.TaskParametersString); string uri = task.SatyamURI; DisplayImage.ImageUrl = uri; SatyamJob jobDefinitionEntry = task.jobEntry; ObjectCountingSubmittedJob job = JSonUtils.ConvertJSonToObject <ObjectCountingSubmittedJob>(jobDefinitionEntry.JobParameters); ObjectNameLabel.Text = job.ObjectName; ObjectNameLabel1.Text = job.ObjectName; Hidden_TasksPerJob.Value = jobDefinitionEntry.TasksPerJob.ToString(); if (job.Description != "") { DescriptionPanel.Visible = true; DescriptionTextPanel.Controls.Add(new LiteralControl(job.Description)); } Hidden_TaskEntryString.Value = JSonUtils.ConvertObjectToJSon <SatyamTaskTableEntry>(entry); Hidden_PageLoadTime.Value = DateTime.Now.ToString(); NoLabeled.Text = Hidden_NoImagesDone.Value; taskTableDB.close(); return(true); } else { taskTableDB.close(); return(false); } }
private bool getNewRandomJob() { SatyamTaskTableAccess taskTableDB = new SatyamTaskTableAccess(); SatyamTaskTableEntry entry = taskTableDB.getMinimumTriedEntryByTemplate(TaskConstants.Counting_Video); if (entry != null) { taskTableDB.IncrementDoneScore(entry.ID); SatyamTask task = JSonUtils.ConvertJSonToObject <SatyamTask>(entry.TaskParametersString); string uri = task.SatyamURI; Hidden_VideoURL.Value = uri; SatyamJob jobDefinitionEntry = task.jobEntry; ObjectCountingSubmittedJob job = JSonUtils.ConvertJSonToObject <ObjectCountingSubmittedJob>(jobDefinitionEntry.JobParameters); ObjectNameLabel.Text = job.ObjectName; ObjectNameLabel1.Text = job.ObjectName; if (job.Description != "") { DescriptionPanel.Visible = true; DescriptionTextPanel.Controls.Add(new LiteralControl(job.Description)); } CountTextBox.Text = ""; Hidden_TaskEntryString.Value = JSonUtils.ConvertObjectToJSon <SatyamTaskTableEntry>(entry); Hidden_PageLoadTime.Value = DateTime.Now.ToString(); taskTableDB.close(); return(true); } else { taskTableDB.close(); return(false); } }
public static void CreateDemoJob_OBJECT_COUNTING_IN_IMAGE() { SatyamJob job = new SatyamJob(); Console.WriteLine("here 1"); AzureInformation AzureInfo = new AzureInformation(); AzureInfo.AzureBlobStorageConnectionString = SatyamJobStorageAccountAccess.connection_string; AzureInfo.AzureBlobStorageContainerName = "demo"; AzureInfo.AzureBlobStorageContainerDirectoryName = "catsCount"; AmazonMTurkHITInformation AmazonInfo = new AmazonMTurkHITInformation(); ObjectCountingSubmittedJob template = new ObjectCountingSubmittedJob(); template.ObjectName = "cat"; template.Description = "By cat we mean house cat and not the general category of cat family like lions or tigers."; job.JobGUIDString = "OBJECT_COUNTING_IN_IMAGE_DEMO"; job.amazonHITInformation = AmazonInfo; job.azureInformation = AzureInfo; job.JobSubmitTime = DateTime.Now; job.JobTemplateType = "OBJECT_COUNTING_IN_IMAGE_DEMO"; job.UserID = TaskConstants.AdminName; job.JobParameters = JSonUtils.ConvertObjectToJSon <ObjectCountingSubmittedJob>(template); string JobParametersString = JSonUtils.ConvertObjectToJSon <SatyamJob>(job); SatyamJobSubmissionsTableAccess jobDB = new SatyamJobSubmissionsTableAccess(); jobDB.AddEntry(job.JobTemplateType, job.UserID, job.JobGUIDString, JobParametersString, job.JobSubmitTime); jobDB.close(); }
protected void Object_Counting_JobSubmitButton_Click(object sender, EventArgs e) { string AzureBlobStorageConnectionString = AzureBlobStorageConnectionStringTextBox.Text; string AzureContainer = AzureBlobStorageContainerNameTextBox.Text; string AzureContainerDirectory = AzureBlobStorageContainerDirectoryNameTextBox.Text; string AmazonAccessKeyIDValue = AmazonAccessKeyID.Text; string AmazonSecretAccessKeyIDValue = AmazonSecretAccessKeyID.Text; string Description = CategoryDescription.Text; double pricePerImage = 0; double price = 0; string jobGuid = NewJobGUID.Text; string AmazonTaskTitle = AmazonTaskTitleTextBox.Text; string AmazonTaskDescription = AmazonTaskDescriptionTextBox.Text; string AmazonTaskKeywords = AmazonTaskKeywordsTextBox.Text; if (AzureBlobStorageConnectionString == "" || AzureContainer == "") { Template_ErrorMessageLabel.Text = "Error : Azure Connection String and Container are mandatory fields."; Template_ErrorMessageLabel.ForeColor = System.Drawing.Color.Red; Template_ErrorMessageLabel.Font.Bold = true; return; } AzureConnectionInfo connectionInfo = new AzureConnectionInfo(AzureBlobStorageConnectionString, AzureContainer, AzureContainerDirectory); int noFiles = connectionInfo.getNoFiles(); if (noFiles == -1) { Template_ErrorMessageLabel.Text = "Error : Invalid Azure Location"; Template_ErrorMessageLabel.ForeColor = System.Drawing.Color.Red; Template_ErrorMessageLabel.Font.Bold = true; return; } else if (noFiles == 0) { Template_ErrorMessageLabel.Text = "Error : There are 0 files at the Azure Location"; Template_ErrorMessageLabel.ForeColor = System.Drawing.Color.Red; Template_ErrorMessageLabel.Font.Bold = true; return; } if (Hidden_MechanicalTurk.Value == "true") { bool success = Double.TryParse(PriceTextBox.Text, out pricePerImage); if (!success) { Template_ErrorMessageLabel.Text = "Error : Non-numerical price entered"; Template_ErrorMessageLabel.ForeColor = System.Drawing.Color.Red; Template_ErrorMessageLabel.Font.Bold = true; return; } pricePerImage = pricePerImage / 100; //convert to dollars price = pricePerImage * TaskConstants.OBJECT_COUNTING_MTURK_MAX_VIDEOS_PER_TASK; //need to round to cents price = Math.Floor(price * 100) / 100; if (price <= 0.0) { Template_ErrorMessageLabel.Text = "Error : The Price is Zero"; Template_ErrorMessageLabel.ForeColor = System.Drawing.Color.Red; Template_ErrorMessageLabel.Font.Bold = true; return; } AmazonMTurkHIT hit = new AmazonMTurkHIT(); success = hit.setAccount(AmazonAccessKeyIDValue, AmazonSecretAccessKeyIDValue, false); if (!success) { Template_ErrorMessageLabel.Text = "Error : Invalid Amazon Turk Account"; Template_ErrorMessageLabel.ForeColor = System.Drawing.Color.Red; Template_ErrorMessageLabel.Font.Bold = true; return; } double balance = hit.getAccountBalance(); if (balance < 0) { Template_ErrorMessageLabel.Text = "Error : Invalid Amazon Turk Account"; Template_ErrorMessageLabel.ForeColor = System.Drawing.Color.Red; Template_ErrorMessageLabel.Font.Bold = true; return; } double moneyNeeded = 4 * price * noFiles / TaskConstants.OBJECT_COUNTING_MTURK_MAX_VIDEOS_PER_TASK; if (balance < moneyNeeded) { Template_ErrorMessageLabel.Text = "Error : Insufficient money in Amazon Turk Account. You will need at least " + moneyNeeded + "$."; Template_ErrorMessageLabel.ForeColor = System.Drawing.Color.Red; Template_ErrorMessageLabel.Font.Bold = true; return; } if (AmazonTaskTitle == "") { Template_ErrorMessageLabel.Text = "Counting Objects in an Image"; } if (AmazonTaskTitle == "") { Template_ErrorMessageLabel.Text = "Earn money quickly by simply counting the number of objects of interest in an image!"; } if (AmazonTaskKeywords == "Object Counting") { Template_ErrorMessageLabel.Text = ""; } } string objectName = ObjectNameTextBox.Text; if (objectName == "") { Template_ErrorMessageLabel.Text = "Error : No Object Name Entered"; Template_ErrorMessageLabel.ForeColor = System.Drawing.Color.Red; Template_ErrorMessageLabel.Font.Bold = true; return; } AzureInformation AzureInfo = new AzureInformation(); AzureInfo.AzureBlobStorageConnectionString = AzureBlobStorageConnectionString; AzureInfo.AzureBlobStorageContainerName = AzureContainer; AzureInfo.AzureBlobStorageContainerDirectoryName = AzureContainerDirectory; AmazonMTurkHITInformation AmazonInfo = new AmazonMTurkHITInformation(); if (Hidden_MechanicalTurk.Value == "true") { AmazonInfo.AmazonAccessKeyID = AmazonAccessKeyIDValue; AmazonInfo.AmazonSecretAccessKeyID = AmazonSecretAccessKeyIDValue; AmazonInfo.Price = price; //in dollars AmazonInfo.AmazonMTurkTaskTitle = AmazonTaskTitle; AmazonInfo.AmazonMTurkTaskDescription = AmazonTaskDescription; AmazonInfo.AmazonMTurkTaskKeywords = AmazonTaskKeywords; } else { AmazonInfo.AmazonAccessKeyID = ""; AmazonInfo.AmazonSecretAccessKeyID = ""; AmazonInfo.Price = 0; AmazonInfo.AmazonMTurkTaskTitle = ""; AmazonInfo.AmazonMTurkTaskDescription = ""; AmazonInfo.AmazonMTurkTaskKeywords = ""; } ObjectCountingSubmittedJob jobParameters = new ObjectCountingSubmittedJob(); jobParameters.ObjectName = objectName; jobParameters.Description = Description; SatyamJob job = new SatyamJob(); job.UserID = userName; job.amazonHITInformation = AmazonInfo; job.azureInformation = AzureInfo; job.JobGUIDString = jobGuid; if (Hidden_MechanicalTurk.Value == "true") { job.JobTemplateType = TaskConstants.Counting_Video_MTurk; job.TasksPerJob = TaskConstants.OBJECT_COUNTING_MTURK_MAX_VIDEOS_PER_TASK; } else { job.JobTemplateType = TaskConstants.Counting_Video; job.TasksPerJob = 0; } job.JobSubmitTime = DateTime.Now; job.JobParameters = JSonUtils.ConvertObjectToJSon <ObjectCountingSubmittedJob>(jobParameters); string jobDefinition = JSonUtils.ConvertObjectToJSon <SatyamJob>(job); SatyamJobSubmissionsTableAccess dbAccess = new SatyamJobSubmissionsTableAccess(); dbAccess.AddEntry(job.JobTemplateType, job.UserID, job.JobGUIDString, jobDefinition, job.JobSubmitTime); dbAccess.close(); Response.Redirect("NewJobSubmitted.aspx"); }