public void ParseExample1_Text() { CAttributes attributes = CHtmlParser.ParseAttributes(HtmlExamples.HtmlExample1); Assert.IsTrue(attributes["Y00T00250.Y00A02883"].Value == "LIANA.SANTOS"); Assert.IsTrue(attributes["Y00T00250.Y00A02883"].Description == "Engineer"); }
public void ParseExample1_Selection() { CAttributes attributes = CHtmlParser.ParseAttributes(HtmlExamples.HtmlExample1); CAttribute attribute = attributes["Y00T00250.Y00A01088"]; Assert.IsTrue(attribute.Description == "Status"); Assert.IsTrue(string.Compare(@"For information", attribute.Value) == 0); Assert.IsTrue(attribute.Options.Where(x => x.Key == "").Count() == 1); Assert.IsTrue(attribute.Options.Where(x => x.Key == "N/A").Count() == 1); Assert.IsTrue(attribute.Options.Where(x => x.Key == "New").Count() == 1); Assert.IsTrue(attribute.Options.Where(x => x.Key == "For information").Count() == 1); Assert.IsTrue(attribute.Options.Where(x => x.Key == "Confirmed").Count() == 1); Assert.IsTrue(attribute.Options.Where(x => x.Key == "Suspended").Count() == 1); Assert.IsTrue(attribute.Options.Where(x => x.Key == "Completed").Count() == 1); Assert.IsTrue(attribute.Options.Where(x => x.Key == "Delegated").Count() == 1); Assert.IsTrue(attribute.Options.Where(x => x.Value == "").Count() == 1); Assert.IsTrue(attribute.Options.Where(x => x.Value == "N/A").Count() == 1); Assert.IsTrue(attribute.Options.Where(x => x.Value == "New").Count() == 1); Assert.IsTrue(attribute.Options.Where(x => x.Value == "For information").Count() == 1); Assert.IsTrue(attribute.Options.Where(x => x.Value == "Confirmed").Count() == 1); Assert.IsTrue(attribute.Options.Where(x => x.Value == "Suspended").Count() == 1); Assert.IsTrue(attribute.Options.Where(x => x.Value == "Completed").Count() == 1); Assert.IsTrue(attribute.Options.Where(x => x.Value == "Delegated").Count() == 1); }
public void Parse_HtmlExample_TextArea() { CAttributes attributes = CHtmlParser.ParseAttributes(HtmlExamples.HtmlExample_TextArea); CAttribute attribute = attributes["Y00T00156.Y00A00171"]; Assert.IsTrue(attribute.Description == "Binding norms and standards"); Assert.IsTrue(attribute.Value == ""); }
public void ParseExample1_CheckBox() { CAttributes attributes = CHtmlParser.ParseAttributes(HtmlExamples.HtmlExample1); Assert.IsTrue(attributes["Y00T00250.Y00A00726"].Value == "False"); Assert.IsTrue(attributes["Y00T00250.Y00A00726"].Description == "Canceled"); Assert.IsTrue(attributes["Y00T00250.Y00A02847"].Value == "True"); Assert.IsTrue(attributes["Y00T00250.Y00A02847"].Description == "Activate automatic notification"); }
public void Parse_HtmlExample_OptionsDuplicate() { CAttributes attributes = CHtmlParser.ParseAttributes(HtmlExamples.HtmlExampleOptionsDuplicate); CAttribute attribute = attributes["Y00T00001.Y00A03066"]; Assert.IsTrue(attribute.Description == "Object class"); Assert.IsTrue(attribute.Value == "Boundary stream"); // Process stream is defined 2 times in this example of coos web. // Make sure it exists only once. Assert.IsTrue(attribute.Options.Where(x => x.Key == "Process stream").Count() == 1); Assert.IsTrue(attribute.Options["Process stream"] == "Process stream"); }
public void Parse_HtmlExampleUI() { var attributes = CHtmlParser.ParseAttributesForUI(HtmlExamples.HtmlExample1); Assert.IsTrue(attributes.Count() == 3); attributes = CHtmlParser.ParseAttributesForUI(HtmlExamples.HtmlExample2); Assert.IsTrue(attributes.Count() == 1); attributes = CHtmlParser.ParseAttributesForUI(HtmlExamples.HtmlExampleOptionsDuplicate); Assert.IsTrue(attributes.Count() == 1); attributes = CHtmlParser.ParseAttributesForUI(HtmlExamples.HtmlExample_TextArea); Assert.IsTrue(attributes.Count() == 3); attributes = CHtmlParser.ParseAttributesForUI(HtmlExamples.HtmlExample3); Assert.IsTrue(attributes.Count() == 2); }
public async Task UpdateAttributesUI(CSpecification spec, string objUID) { StackLayout stack = new StackLayout() { HorizontalOptions = LayoutOptions.FillAndExpand, VerticalOptions = LayoutOptions.FillAndExpand, Orientation = StackOrientation.Vertical, }; string html; try { html = await m_ComosWeb.GetObjectSpecificationAsHtml( this.ProjectData.SelectedDB.Key, spec.ProjectUID, spec.OverlayUID, ProjectData.SelectedLanguage.LCID, objUID, spec.Name); } catch (Exception ex) { await App.Current.MainPage.DisplayAlert("Error", "Error al cargar atributos: " + ex.Message, Services.TranslateExtension.TranslateText("OK")); return; } if (html == null) { return; } m_Attributes = CHtmlParser.ParseAttributesForUI(html); foreach (var attribute in m_Attributes) { var elm = await UpdateAttributesUI(attribute); if (elm == null) { continue; } stack.Children.Add(elm); } stack.Padding = new Thickness(0, 0, 0, 0); stack.HorizontalOptions = LayoutOptions.FillAndExpand; stack.VerticalOptions = LayoutOptions.FillAndExpand; this.m_Panel.Content = stack; }
public void ParseExample2_TextWithUnits() { CAttributes attributes = CHtmlParser.ParseAttributes(HtmlExamples.HtmlExample2); CAttribute attribute = attributes["Y00T00235.Y00A02875"]; Assert.IsTrue(attribute.Description == "Units/time"); Assert.IsTrue(attribute.Value == ""); Assert.IsTrue(attribute.Options.Where(x => x.Key == "ppm").Count() == 1); Assert.IsTrue(attribute.Options.Where(x => x.Key == "1/1").Count() == 1); Assert.IsTrue(attribute.Options.Where(x => x.Key == "%").Count() == 1); Assert.IsTrue(attribute.Options.Where(x => x.Key == "‰").Count() == 1); Assert.IsTrue(attribute.Options["ppm"] == "F25.AA100"); Assert.IsTrue(attribute.Options["1/1"] == "F25.AA110"); Assert.IsTrue(attribute.Options["%"] == "F25.AA120"); Assert.IsTrue(attribute.Options["‰"] == "F25.AA130"); Assert.IsTrue(attribute.Unit == "%"); }
public async Task UpdateAttributesUI(string html) { var rejectionFrame = "Rechazo"; var UltimoUsuarioFrame = "Última modificación"; StackLayout stack = new StackLayout() { HorizontalOptions = LayoutOptions.FillAndExpand, VerticalOptions = LayoutOptions.FillAndExpand, Orientation = StackOrientation.Vertical, }; var attributes = CHtmlParser.ParseAttributesForUI(html); var uiParser = new UI.HTMLToUIParser(); uiParser.MainObject = this.MainObject; uiParser.CachedDevice = this.cacheddevice; foreach (var attribute in attributes) { if ((attribute.Text != rejectionFrame) && ((attribute.Text != UltimoUsuarioFrame))) { var elm = uiParser.UpdateAttributesUI(attribute); if (elm != null) { elm.IsEnabled = true; stack.Children.Add(elm); //this.MobileTabFrame.Content = ((Frame)elm).Content; } } } stack.Padding = new Thickness(0, 0, 0, 0); stack.HorizontalOptions = LayoutOptions.FillAndExpand; stack.VerticalOptions = LayoutOptions.FillAndExpand; this.Values = uiParser.Values; this.m_Panel.Content = stack; addEquipmentButton(); }
public async Task UpdateAttributesUI(CSpecification spec, CObject obj, string language, bool render = true) { try { if (render) { ShowSpinner(Services.TranslateExtension.TranslateText("loading")); } //ShowStickSpinner("Loading values..."); StackLayout stack = new StackLayout() { HorizontalOptions = LayoutOptions.FillAndExpand, VerticalOptions = LayoutOptions.FillAndExpand, Orientation = StackOrientation.Vertical, }; string html; try { html = await m_ComosWeb.GetObjectSpecificationAsHtml( this.Database, spec.ProjectUID, spec.OverlayUID, language, obj.UID, spec.Name); } catch (TaskCanceledException) { return; } // If there is a Logout Request catch (Exception ex) { await App.Current.MainPage.DisplayAlert("Error", "Error al cargar atributos: " + ex.Message, Services.TranslateExtension.TranslateText("OK")); return; } if (html == null) { ShowToast("Error al cargar la información. Intente nuevamente."); this.HideSpinner(); return; } m_UIAttributes = CHtmlParser.ParseAttributesForUI(html); await ExecuteQueriesInAttributes(m_UIAttributes); //just download the jsons if (!render) { ShowToast("Error al cargar la información. Intente nuevamente."); this.HideSpinner(); return; } var uiParser = new UI.HTMLToUIParser(this); uiParser.MainObject = this.MainObject; foreach (var attribute in m_UIAttributes) { var elm = uiParser.UpdateAttributesUI(attribute); //convert attribute to xamarin element processDisplayElement(attribute); //parse xamarin element to extract info in selected attributes if (elm != null && isAttributeVisible(attribute)) //if elm is not null and is a visible attribute, then add to display stack { View myNewElement = postProcessDisplayElement(elm, attribute); if (isALoogBook) { Frame myNewElementFrame = (Frame)myNewElement; StackLayout myNewElementStackLayout = (StackLayout)myNewElementFrame.Children[0]; for (int i = 0; i < myNewElementStackLayout.Children.Count; i++) { var element = myNewElementStackLayout.Children[i]; if (element.GetType() == typeof(StackLayout)) { StackLayout elementStackLayout = (StackLayout)element; foreach (var elementChild in elementStackLayout.Children) { VisualElement visualElement = (VisualElement)elementChild; visualElement.IsEnabled = false; } } } } stack.Children.Add(myNewElement); } } stack.Padding = new Thickness(0, 0, 0, 0); stack.HorizontalOptions = LayoutOptions.FillAndExpand; stack.VerticalOptions = LayoutOptions.FillAndExpand; stack.Children.Add(new StackLayout() { HeightRequest = 65 }); if (isALoogBook) { this.ViewSave = false; floatingMenu.IsVisible = false; } else { this.ViewSave = (uiParser.EditableValues.Count > 0); floatingMenu.IsVisible = (uiParser.EditableValues.Count > 0); } this.Values = uiParser.Values; this.m_Panel.Content = stack; //if (this.IsActivity){//this.SetupForActivity();} if (this.AllowPictures) { this.SetupForPictures(); } this.HideSpinner(); //this.HideStickSpinner(); addEquipmentButton(); if (belongsToAnEquipment) { equipmentVerified.Text = Constants.OkIcon; equipmentVerified.BackgroundColor = Color.Green; } else if (equipmentVerified != null) { equipmentVerified.Text = Constants.CancelIcon; equipmentVerified.BackgroundColor = Color.Red; } } catch (Exception ex) { ShowToast($"Error al cargar atributos: {ex.Message}"); } finally { this.HideSpinner(); } }
///////////////////////////////////////////////////////////////////////////////// /// <summary> /// /// </summary> /// <param name="html"></param> public CHtmlDocument(string html) { System.Diagnostics.Debug.Assert(html != null); m_parser = new CHtmlParser(); LoadHtml(html); }
///////////////////////////////////////////////////////////////////////////////// #region 񃧯 ///////////////////////////////////////////////////////////////////////////////// /// <summary> /// /// </summary> public CHtmlDocument() { m_parser = new CHtmlParser(); }
public async Task <View> GetAttributesView(CSpecification spec, CObject obj, string language) { StackLayout layout = new StackLayout(); var html = await m_ComosWeb.GetObjectSpecificationAsHtml( m_Navigator, spec.ProjectUID, spec.OverlayUID, language, obj.UID, spec.Name); var attributes = CHtmlParser.ParseAttributes(html); foreach (var attribute in attributes.Items) { var lbl = new Label(); lbl.Text = attribute.Description + " = " + attribute.Value; if (attribute.HasUnits) { lbl.Text += " " + attribute.Unit; } layout.Children.Add(lbl); } return(layout); /* * StackLayout layout = new StackLayout(); * AbsoluteLayout stack = new AbsoluteLayout(); * var html = await m_ComosWeb.GetObjectSpecificationAsHtml( * m_Navigator.Database, spec.ProjectUID, spec.OverlayUID, language, obj.UID, spec.Name); * int maxheight = 0; * var attributes = CHtmlParser.ParseAttributes(html); * foreach (var attribute in attributes.Items) * { * if(attribute.Controls != null) * { * foreach (var ctrl in attribute.Controls) * { * System.Diagnostics.Debug.WriteLine( * string.Format("{0} {1} {2} {3}", * ctrl.X, ctrl.Y, ctrl.Width, ctrl.Height)); * if (maxheight < ctrl.Y) * maxheight = ctrl.Y; * switch (ctrl.UIType) * { * case UIType.SUICheckBox: * { * Switch c = new Switch() * { * IsToggled = bool.Parse(attribute.Value), * }; * AbsoluteLayout.SetLayoutBounds(c, new Rectangle( * ctrl.X, ctrl.Y, ctrl.Width, ctrl.Height)); * stack.Children.Add(c); * } * break; * case UIType.SUIText: * { * Label c = new Label() * { * Text = attribute.Description, * }; * AbsoluteLayout.SetLayoutBounds(c, new Rectangle( * ctrl.X, ctrl.Y, ctrl.Width, ctrl.Height)); * stack.Children.Add(c); * } * break; * case UIType.SUIOpenButton: * case UIType.SUITimeButton: * default: * break; * } * } * } * } * stack.MinimumHeightRequest = maxheight; * stack.HeightRequest = maxheight; * layout.Children.Add(stack); * return layout; */ }