private void RemoveList(String code) { IList <ScrappingStruct> list = (from item in scraplist where String.Equals(item.scrapcode, code) select item).ToList(); if (list.Count < 1) { return; } //First, It remove the object in the scrappingClass ScrapState state = AdapterScrapping.Instance().StateScrapping(code); if (object.Equals(state, ScrapState.COMPLETE)) { AdapterScrapping.Instance().RemoveScrapping(code); } //Second of all, It remove the object in list of variable. foreach (ScrappingStruct item in list) { scraplist.Remove(item); } //Third of all, It remove the object in the data_grid_view IList <DataGridViewRow> removelist = new List <DataGridViewRow>(); foreach (DataGridViewRow row in this.dataGridView1.Rows) { if (String.Equals(code, (string)row.Cells["SCRAP_CODE"].Value)) { removelist.Add(row); } } foreach (DataGridViewRow row in removelist) { this.dataGridView1.Rows.Remove(row); } }
protected void SetEventHandler(ScrapState state) { if (eventhandler != null) { eventhandler(state); } }
public void Run() { ThreadPool.QueueUserWorkItem((c) => { try { state = ScrapState.RUNNING; Initialize(); using (IScrapping scrap = new Scrapping((url) => { Navigated(url); })) { try { Execute(scrap); } finally { scrap.Move("about:blank"); } } Finish(); state = ScrapState.COMPLETE; } catch (Exception e) { state = ScrapState.ERROR; Error(e); } }); }
private void OnTriggerEnter(Collider other) { if (other.CompareTag(tagToCheck)) { targetTransform = other.transform; scrapState = ScrapState.MovingTowardsPlayer; } }
public bool RemoveScrapping(String code) { ScrapState state = StateScrapping(code); if (Object.Equals(ScrapState.COMPLETE, state)) { memory.Remove(code); return(true); } return(false); }
public IScrappingProcess CompleteScrapping(String code) { ScrapState state = StateScrapping(code); if (Object.Equals(ScrapState.COMPLETE, state)) { IScrappingProcess ret = memory[code]; return(ret); } return(null); }
public ApplicationContext Run() { if (this.scrap != null) { throw new ScrappingException("The instance is already existed"); } this.scrap = new Scrapping((url) => { Navigated(url); }); ThreadPool.QueueUserWorkItem((c) => { try { state = ScrapState.RUNNING; Initialize(); using (scrap) { try { Execute(scrap); } finally { scrap.Move("about:blank"); } } Finish(); state = ScrapState.COMPLETE; } catch (Exception e) { state = ScrapState.ERROR; Error(e); } }); return(scrap.Connection); }
private void button1_Click(object sender, EventArgs e) { String port = textBox1.Text; int portNumber = 10000; try { portNumber = Convert.ToInt32(port); } catch (FormatException) { WriteLog("This port setting is wrong.Select to number between 10000 to 20000,please."); this.textBox1.Text = "10000"; return; } try { webServer = new HttpServer(portNumber); } catch (Exception) { WriteLog("This port setting is wrong.Do not overlapped the other port."); WriteLog("The step of confirmation) This order press prompt on commander; netstat -an |find \"LISTEN\" . Then the port check at. Finally, The port set that is not overlapped."); this.textBox1.Text = "10000"; return; } button1.Enabled = false; textBox1.Enabled = false; this.textBox2.Text = "Processing"; this.textBox2.BackColor = Color.Blue; webServer.Start((header) => { if (String.IsNullOrEmpty(header["TYPE"])) { return("PARAMETER_ERROR"); } if (String.IsNullOrEmpty(header["CODE"])) { return("PARAMETER_ERROR"); } // It check code type that is defined the scrap code. if (!ScrapKindDic.ContainsKey(header["CODE"])) { return("PARAMETER_ERROR"); } switch ((header["TYPE"])) { case "scrap_request": { if (String.IsNullOrEmpty(header["ID"])) { return("PARAMETER_ERROR"); } if (String.IsNullOrEmpty(header["PW"])) { return("PARAMETER_ERROR"); } if (String.IsNullOrEmpty(header["APPLY"])) { return("PARAMETER_ERROR"); } String scrapcode = AdapterScrapping.Instance().RunScrapping((scrap_code, _code, _id, _pw, _param) => { int gridIndex = (int)this.Invoke(new Func <int>(() => { String[] gridData = { _code, _id, _pw, scrap_code, DateTime.Now.ToString(), ScrapState.RUNNING.ToString() }; return(this.dataGridView1.Rows.Add(gridData)); })); ICommonScrap scrap = FactoryScrapClass(_code, _id, _pw, _param); ScrappingStruct item; item.code = _code; item.id = _id; item.pw = _pw; item.scrapcode = scrap_code; scraplist.Insert(0, item); //It enroll data of scrap to datagridview. scrap.SetHandler((state) => { this.Invoke(new Action(() => { this.dataGridView1.Rows[gridIndex].Cells[5].Value = state.ToString(); })); }); return(scrap); }, header["CODE"], header["ID"], header["PW"], header["APPLY"]); return(scrapcode); } case "scrap_state": { return(AdapterScrapping.Instance().StateScrapping(header["CODE"]).ToString()); } case "scrap_get": { ScrapState state = AdapterScrapping.Instance().StateScrapping(header["CODE"]); if (object.Equals(state, ScrapState.COMPLETE)) { IScrappingProcess scrap = AdapterScrapping.Instance().CompleteScrapping(header["CODE"]); return(scrap.ToString()); } return(state.ToString()); } case "scrap_codesearch": { foreach (ScrappingStruct item in scraplist) { if (object.Equals(item.code, header["CODE"]) && object.Equals(item.id, header["ID"]) && object.Equals(item.pw, header["PW"])) { return(item.scrapcode); } } return("NOTHING"); } default: return("TYPE_PARAMETER_ERROR"); } }); }