Ejemplo n.º 1
0
        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);
            }
        }
Ejemplo n.º 2
0
            static void Main(string[] args)
            {
                ScriptHook hook      = new ScriptHook();
                String     scrapcode = AdapterScrapping.Instance().RunScrapping((scrapcode1, code, id, pw, arg) =>
                {
                    Console.WriteLine("adap  " + code);
                    return(new Domekuk(id, pw, arg));
                    //}, "002", "storehouse", "hana0911!","test");
                }, "001", "wogjsl0213", "dhwogjs02!", "test");

                Console.WriteLine(scrapcode);
                Console.WriteLine("Press Any Key...");
                Console.ReadLine();
                hook.Dispose();
            }
Ejemplo n.º 3
0
        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");
                }
            });
        }