示例#1
0
        private void AddStockCode(SecurityInfo si, string policyname, string programName)
        {
            DateTime        fromdate = this.dateTimePicker1.Value.Date;
            DateTime        todate   = this.dateTimePicker2.Value.Date;
            PolicyParameter pp       = new PolicyParameter();

            pp.EndDate   = todate;
            pp.StartDate = fromdate;
            pp.Inteval   = 0;
            pp.IsReal    = false;
            try
            {
                string   dllname         = programName.Substring(0, programName.Length - 4);
                Assembly assembly        = Assembly.Load(PolicyProgram.getProgram(programName));
                Type     ClassParamter   = assembly.GetType(string.Format("{0}.Parameter", dllname));
                Object   ObjectParameter = assembly.CreateInstance(ClassParamter.FullName, true, BindingFlags.CreateInstance, null, new object[] { si, pp, string.Empty }, null, null);
                int      i = grid_stocks.Rows.Add();
                grid_stocks.Rows[i].Cells[0].Value = si.Code;
                grid_stocks.Rows[i].Cells[1].Value = si.Name;
                grid_stocks.Rows[i].Cells[2].Value = si.Market;
                grid_stocks.Rows[i].Cells[3].Value = policyname;
                grid_stocks.Rows[i].Cells[4].Value = "删除";
                grid_stocks.Rows[i].Cells[5].Value = programName;
                grid_stocks.Rows[i].Tag            = new GridRowTag(assembly, ObjectParameter);
                this.com_type.Text = string.Empty;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
 public Parameter(SecurityInfo si, PolicyParameter pp, string account)
     : this(si, account, "Parameter.xml")
 {
     this.startDate = pp.StartDate;
     this.endDate   = pp.EndDate;
     this.inteval   = 0;
     this.isReal    = false;
 }
示例#3
0
        /// <summary>
        /// Creates a HIT that uses the Plurality hit review policy. This example will auto-approve assignments where the answer agrees with the majority and reject otherwise.
        /// </summary>
        public void CreateHITWithReviewPolicy()
        {
            string hitTypeId = client.RegisterHITType("Answer a plurality question", "This is a HIT created by the Mechanical Turk .Net SDK", 60, 60, 0.01m, ".net test", null);

            ReviewPolicy policy = new ReviewPolicy();
            PolicyParameter[] parameters = new PolicyParameter[4];
            PolicyParameter questionIds = new PolicyParameter();
            questionIds.Key = "QuestionIds";
            questionIds.Value = new string[1] { "1" };
            parameters[0] = questionIds;
            PolicyParameter agreementThreshold = new PolicyParameter();
            agreementThreshold.Key = "QuestionAgreementThreshold";
            agreementThreshold.Value = new string[1] { "50" };
            parameters[1] = agreementThreshold;
            PolicyParameter approveThreshold = new PolicyParameter();
            approveThreshold.Key = "ApproveIfWorkerAgreementScoreIsAtLeast";
            approveThreshold.Value = new string[1] { "100" };
            parameters[2] = approveThreshold;
            PolicyParameter rejectThreshold = new PolicyParameter();
            rejectThreshold.Key = "RejectIfWorkerAgreementScoreIsLessThan";
            rejectThreshold.Value = new string[1] { "100" };
            parameters[3] = rejectThreshold;
            policy.PolicyName = "SimplePlurality/2011-09-01";
            policy.Parameter = parameters;

            CreateHITRequest req = new CreateHITRequest();
            req.HITTypeId = hitTypeId;
            req.Description = "Plurality test hit created by Mechanical Turk .Net SDK";
            req.HITReviewPolicy = policy;
            req.MaxAssignments = 3;
            req.Question = QuestionUtil.ConvertSingleFreeTextQuestionToXML("Hello");
            req.Reward = new Price();
            req.Reward.Amount = 2;
            req.Reward.CurrencyCode = "USD";
            req.Title = "Hello <something>";
            req.AssignmentDurationInSeconds = 60;
            req.LifetimeInSeconds = 3600;

            HIT hit = client.Proxy.CreateHIT(req);

            // output ID and Url of new HIT (URL where HIT is available on the Mechanical Turk worker website)
            Console.WriteLine("Reward: {0}", req.Reward.Amount);
            Console.WriteLine("Created HIT: {0} ({1})", hit.HITId, client.GetPreviewURL(hit.HITTypeId));
        }