public int insert_Form(Form_elements newform) { using (ElementDBEntities db = new ElementDBEntities()) { try { int isExist = db.Form_elements.Where(p => p.id_form == newform.id_form && p.id_url == newform.id_url).Count(); if (isExist == 0) { db.Form_elements.Add(newform); db.SaveChanges(); return(0); } else { return(1); } } catch { return(-1); } } }
public static int insert_Form(Form_elements newForm) { return(Url.insert_Form(newForm)); }
public int GetElements() { int flag = 0; try { //Url newurl = new Url(); //newurl.name = Url.Substring(8); //newurl.url1 = Url; //int id_Url = UrlBUL.insertURL(newurl); //int id_Url = 3; //For example //if (id_Url == -1) //{ // return -1; //} SetUpDriver(Url); var form = chromedriver.FindElementsByXPath("//form"); if (form != null)// have at least one form { listForm = new List <Form_elements>(); for (int i = 0; i < form.Count; i++) { Form_elements form_ = new Form_elements(); form_.id_form = form[i].GetAttribute("id"); //form_.id_url = id_Url; try { form_.name = form[i].GetAttribute("name"); } catch { } try { form_.xpath = getAbsoluteXPath(chromedriver, form[i]); } catch { } //BUL.FormBUL.insert_Form(form_);//save into database listForm.Add(form_); } foreach (string tag in tag_elts) { GetElements(chromedriver, tag, "", listForm); } //GetElements(chromedriver, id_Url, "a", "", listForm); } else //no form found { foreach (string tag in tag_elts) { GetElements(chromedriver, tag, ""); } } flag = 1; } catch { flag = -1; } CloseDriver(); return(flag); }