private void LoadData(SessionObjects sos, bool ignoreFieldsAndEvents) { _formData = ExtractForm(sos.FormManager.GetCustomForm(_formInfo.FormID)); if (string.IsNullOrEmpty(_formData)) { return; } try { var htmlDoc = GetHtmlDocument(_formData); List <HtmlElement> elements = new List <HtmlElement>(); foreach (HtmlElement item in htmlDoc.Body.Children) { elements.Add(item); if (item.CanHaveChildren) { var collectionElemetns = GetHtmlElements(item.Children); elements.AddRange(collectionElemetns); } } var codebase = elements .FirstOrDefault(x => !string.IsNullOrEmpty(x.GetAttribute("assembly"))); if (codebase != null) { Codebase = new InputFormCodebase() { AssemblyName = codebase.GetAttribute("assembly"), Version = codebase.GetAttribute("version"), ClassName = codebase.GetAttribute("typeName") }; } if (ignoreFieldsAndEvents == false) { foreach (var item in elements) { //if (Codebase == null) //{ // var codebase = item.GetAttribute("assembly"); // if (string.IsNullOrEmpty(codebase) == false) // { // Codebase = new InputFormCodebase() // { // AssemblyName = item.GetAttribute("assembly"), // Version = item.GetAttribute("version"), // ClassName = item.GetAttribute("typeName") // }; // } //} string encompassFieldID = item.GetAttribute("emid"); if (string.IsNullOrEmpty(encompassFieldID) == false) { string controlID = item.GetAttribute("fieldId"); string controlType = item.GetAttribute("type"); FormControls.Add( new InputFormControl() { EncompassFormName = this.FormName, LoanFieldID = encompassFieldID, ObjectControlID = controlID, ObjectControlType = controlType });; } string eventType = item.GetAttribute("event"); if (string.IsNullOrEmpty(eventType) == false) { string eventLocation = item.GetAttribute("for"); string code = item.InnerHtml; if (string.IsNullOrEmpty(code) == false) { FormEvents.Add( new InputFormEvent() { EncompassFormName = this.FormName, EventType = eventType, EventLocationId = eventLocation, CustomCode = code }); } } } } } catch (Exception ex) { throw ex; } }
public void GetHtmlDocument(string html) { WebBrowser browser = new WebBrowser(); browser.ScriptErrorsSuppressed = true; browser.DocumentText = html; browser.Document.OpenNew(true); browser.Document.Write(html); browser.Refresh(); CurrentDocument = browser.Document; if (CurrentDocument == null) { return; } List <HtmlElement> elements = new List <HtmlElement>(); foreach (HtmlElement item in CurrentDocument.Body.Children) { elements.Add(item); if (item.CanHaveChildren) { var collectionElemetns = GetHtmlElements(item.Children); elements.AddRange(collectionElemetns); } } foreach (var item in elements) { string encompassFieldID = item.GetAttribute("emid"); if (string.IsNullOrEmpty(encompassFieldID) == false) { string controlID = item.GetAttribute("fieldId"); string controlType = item.GetAttribute("type"); FormControls.Add( new InputFormControl() { EncompassFormName = this.FormName, LoanFieldID = encompassFieldID, ObjectControlID = controlID, ObjectControlType = controlType });; } string eventType = item.GetAttribute("event"); if (string.IsNullOrEmpty(eventType) == false) { string eventLocation = item.GetAttribute("for"); string code = item.InnerHtml; if (string.IsNullOrEmpty(code) == false) { FormEvents.Add( new InputFormEvent() { EncompassFormName = this.FormName, EventType = eventType, EventLocationId = eventLocation, CustomCode = code }); } } } }
private void LoadData(SessionObjects sos) { _formData = ExtractForm(sos.FormManager.GetCustomForm(_formInfo.FormID)); if (string.IsNullOrEmpty(_formData)) { return; } try { var htmlDoc = GetHtmlDocument(_formData); List <HtmlElement> elements = new List <HtmlElement>(); foreach (HtmlElement item in htmlDoc.Body.Children) { elements.Add(item); if (item.CanHaveChildren) { var collectionElemetns = GetHtmlElements(item.Children); elements.AddRange(collectionElemetns); } } foreach (var item in elements) { string encompassFieldID = item.GetAttribute("emid"); if (string.IsNullOrEmpty(encompassFieldID) == false) { string controlID = item.GetAttribute("fieldId"); string controlType = item.GetAttribute("type"); FormControls.Add( new InputFormControl() { EncompassFormName = this.FormName, LoanFieldID = encompassFieldID, ObjectControlID = controlID, ObjectControlType = controlType });; } string eventType = item.GetAttribute("event"); if (string.IsNullOrEmpty(eventType) == false) { string eventLocation = item.GetAttribute("for"); string code = item.InnerHtml; if (string.IsNullOrEmpty(code) == false) { FormEvents.Add( new InputFormEvent() { EncompassFormName = this.FormName, EventType = eventType, EventLocationId = eventLocation, CustomCode = code }); } } } } catch (Exception ex) { } }