コード例 #1
0
        public HITView addHITtoList(string name, HITData data, int jobNumber)
        {
            HITView hs;

            if (name == ShortnJob.HIT_TYPE)
            {
                hs = new ShortnView(name, data as ShortnData, jobNumber);
            }
            else if (name == CrowdproofJob.HIT_TYPE)
            {
                hs = new CrowdproofView(name, data as CrowdproofData, jobNumber);
            }
            else if (name == HumanMacroJob.HIT_TYPE)
            {
                HumanMacroData hdata = data as HumanMacroData;
                hs = new HumanMacroView(name, hdata, jobNumber);
            }
            else
            {
                hs = new HITView(name, data, jobNumber);
            }
            jobMap[jobNumber] = data;

            return(hs);
        }
コード例 #2
0
        public HITView addHIT(string name, HITData data, int jobNumber)
        {
            HITView hs;

            if (name == ShortnJob.HIT_TYPE)
            {
                hs = new ShortnView(name, data as ShortnData, jobNumber);
            }
            else if (name == CrowdproofJob.HIT_TYPE)
            {
                hs = new CrowdproofView(name, data as CrowdproofData, jobNumber);
            }
            else if (name == HumanMacroJob.HIT_TYPE)
            {
                HumanMacroData hdata = data as HumanMacroData;
                hs = new HumanMacroView(name, hdata, jobNumber);
            }
            else
            {
                hs = new HITView(name, data, jobNumber);
            }
            jobMap[jobNumber] = data;

            // Assign the WPF UserControl to the ElementHost control's
            // Child property.
            sidebar.addHitView(jobNumber, hs);
            //host.Child = hs;

            // Add the ElementHost control to the form's
            // collection of child controls.
            //this.Controls.Add(host);
            return(hs);
        }
コード例 #3
0
        /// <summary>
        /// The view for a task in the sidebar
        /// </summary>
        /// <param name="workType">Job type</param>
        /// <param name="data">Data Model for this View</param>
        public HITViewStub(string workType, HITData data, HITView view)
        {
            InitializeComponent();

            hitType.Content = workType;
            this.view       = view;
            this.data       = data;
            //data.register(this);
            previewText.Text = data.originalText;
            stageList        = new Dictionary <HITData.ResultType, StageView>();
        }
コード例 #4
0
        /// <summary>
        /// The view for a task in the sidebar
        /// </summary>
        /// <param name="workType">Job type</param>
        /// <param name="data">Data Model for this View</param>
        public HITView(string workType, HITData data, int job)
        {
            InitializeComponent();

            hitType.Content = workType;

            this.data = data;
            data.register(this);
            previewText.Text = data.originalText;
            stageList        = new Dictionary <HITData.ResultType, StageView>();

            stub = new HITViewStub(workType, data, this);

            this.job            = job;
            cancelBtn.IsEnabled = true;
        }
コード例 #5
0
ファイル: HumanMacroStage.cs プロジェクト: tummykung/soylent
 public HumanMacroStage(HITData.ResultType type, int redundancy, int job)
     : base(type, job)
 {
     this.redundancy = redundancy;
 }
コード例 #6
0
ファイル: TurKitSocKit.cs プロジェクト: tummykung/soylent
        public static void HandleSocketMessage(string incomingString)
        {
            Regex  typeRegex   = new Regex("\"__type__\"\\s*:\\s*\"(?<messageType>.*)\"");
            Match  regexResult = typeRegex.Match(incomingString);
            string messageType = regexResult.Groups["messageType"].Value;

            Regex  jobtypeRegex   = new Regex("\"__jobType__\"\\s*:\\s*\"(?<jobType>.*)\"");
            Match  jobregexResult = jobtypeRegex.Match(incomingString);
            string jobType        = jobregexResult.Groups["jobType"].Value;


            JavaScriptSerializer serializer = new JavaScriptSerializer();

            if (messageType == "status")
            {
                TurKitStatus receivedObject = serializer.Deserialize <TurKitStatus>(incomingString);

                Microsoft.Office.Interop.Word.Document doc = Globals.Soylent.jobToDoc[receivedObject.job];
                HITData concernedHIT = Globals.Soylent.soylentMap[doc].jobMap[receivedObject.job];    //Globals.Soylent.soylentMap[Globals.Soylent.Application.ActiveDocument].jobMap[receivedObject.job];

                Debug.WriteLine(receivedObject.hitURL);

                //if (concernedHIT is ShortnData)
                if (jobType == "shortn")
                {
                    Debug.WriteLine("Status update for Shortn");
                    ShortnData shortenData = concernedHIT as ShortnData;
                    shortenData.updateStatus(receivedObject);
                }
                //else if (concernedHIT is CrowdproofData)
                else if (jobType == "crowdproof")
                {
                    CrowdproofData crowdproofData = concernedHIT as CrowdproofData;
                    crowdproofData.updateStatus(receivedObject);
                }
                if (jobType == "human-macro")
                {
                    Debug.WriteLine("Status update for human-macro");
                    HumanMacroData humanMacro = concernedHIT as HumanMacroData;
                    humanMacro.updateStatus(receivedObject);
                }
            }
            else if (messageType == "stageComplete")
            {
                Debug.WriteLine("Stage complete message");
                TurKitStageComplete receivedObject = serializer.Deserialize <TurKitStageComplete>(incomingString);

                if (jobType == "shortn")
                {
                    Microsoft.Office.Interop.Word.Document doc = Globals.Soylent.jobToDoc[receivedObject.job];
                    ShortnData shortenData = Globals.Soylent.soylentMap[doc].jobMap[receivedObject.job] as ShortnData;
                    //Globals.Soylent.soylentMap[Globals.Soylent.Application.ActiveDocument].jobMap[receivedObject.job] as ShortnData;
                    shortenData.stageCompleted(receivedObject);
                }
                else if (jobType == "crowdproof")
                {
                    Microsoft.Office.Interop.Word.Document doc = Globals.Soylent.jobToDoc[receivedObject.job];
                    CrowdproofData crowdproofData = Globals.Soylent.soylentMap[doc].jobMap[receivedObject.job] as CrowdproofData;
                    //CrowdproofData crowdproofData = fixthis;//Globals.Soylent.soylentMap[Globals.Soylent.Application.ActiveDocument].jobMap[receivedObject.job] as CrowdproofData;
                    crowdproofData.stageCompleted(receivedObject);
                }
            }
            else if (messageType == "complete")
            {
                if (jobType == "human-macro")
                {
                    TurKitHumanMacroResult receivedObject = serializer.Deserialize <TurKitHumanMacroResult>(incomingString);
                    Debug.WriteLine("\nHUMAN MACRO COMPLEEETE******");
                    Microsoft.Office.Interop.Word.Document doc = Globals.Soylent.jobToDoc[receivedObject.job];
                    HumanMacroData humanMacro = Globals.Soylent.soylentMap[doc].jobMap[receivedObject.job] as HumanMacroData;
                    //HumanMacroData humanMacro = fixthis;//Globals.Soylent.soylentMap[Globals.Soylent.Application.ActiveDocument].jobMap[receivedObject.job] as HumanMacroData;
                    humanMacro.processSocKitMessage(receivedObject);
                }
                else if (jobType == "shortn")
                {
                    TurKitFindFixVerify receivedObject         = serializer.Deserialize <TurKitFindFixVerify>(incomingString);
                    Microsoft.Office.Interop.Word.Document doc = Globals.Soylent.jobToDoc[receivedObject.job];
                    ShortnData shortenData = Globals.Soylent.soylentMap[doc].jobMap[receivedObject.job] as ShortnData;    //Globals.Soylent.soylentMap[Globals.Soylent.Application.ActiveDocument].jobMap[receivedObject.job] as ShortnData;
                    shortenData.processSocKitMessage(receivedObject);
                }
                else if (jobType == "crowdproof")
                {
                    TurKitFindFixVerify receivedObject         = serializer.Deserialize <TurKitFindFixVerify>(incomingString);
                    Microsoft.Office.Interop.Word.Document doc = Globals.Soylent.jobToDoc[receivedObject.job];
                    CrowdproofData crowdproofData = Globals.Soylent.soylentMap[doc].jobMap[receivedObject.job] as CrowdproofData;
                    //CrowdproofData crowdproofData = fixthis;//Globals.Soylent.soylentMap[Globals.Soylent.Application.ActiveDocument].jobMap[receivedObject.job] as CrowdproofData;
                    crowdproofData.processSocKitMessage(receivedObject);
                }
            }
            else if (messageType == "exception")
            {
                Debug.WriteLine("TurKit exception thrown:");
                TurKitException receivedObject = serializer.Deserialize <TurKitException>(incomingString);
                Debug.WriteLine(receivedObject.exceptionString);

                Microsoft.Office.Interop.Word.Document doc = Globals.Soylent.jobToDoc[receivedObject.job];
                SoylentPanel panel        = Globals.Soylent.soylentMap[doc];
                HITData      concernedHIT = panel.jobMap[receivedObject.job];

                panel.Invoke(new HITData.showErrorDelegate(concernedHIT.showError), new object[] { receivedObject.exceptionString });
                //concernedHIT.showError(receivedObject.exceptionCode);
            }
            //Debug.WriteLine("got it!");
        }
コード例 #7
0
 /// <summary>
 /// Creates a TurKit job for the selected task.
 /// </summary>
 /// <param name="hdata">The HITData representing the desired job</param>
 public TurKit(HITData hdata)
 {
     this.hdata = hdata;
 }