Beispiel #1
0
        private async void CheckContent()
        {
            var       db         = Services.XServices.Instance.GetService <Services.XDatabase>();
            IComosWeb m_ComosWeb = Services.XServices.Instance.GetService <IComosWeb>();

            ViewModels.ProjectData ProjectData = Services.XServices.Instance.GetService <ViewModels.ProjectData>();


            foreach (string uid in UIDsToDownload)
            {
                //if (db.GetCachedScreen(uid) == null)
                if (1 == 1)
                {
                    List <CSpecification> specs = null;
                    try
                    {
                        specs = await m_ComosWeb.GetObjectSpecification(
                            ProjectData.SelectedDB.Key, ProjectData.SelectedProject.UID, ProjectData.SelectedLayer.UID, ProjectData.SelectedLanguage.LCID, uid);
                    }
                    catch (TaskCanceledException) { return; } // If there is a Logout Request
                    catch (Exception e)
                    {
                        await App.Current.MainPage.DisplayAlert("Error", "Error al obtener atributos: " + e.Message, Services.TranslateExtension.TranslateText("OK"));

                        return;
                    }

                    if (specs != null)
                    {
                        foreach (var item in specs)
                        {
                            //cache mobile
                            //if (item.Name.Equals("Z10T00002"))
                            if (item.Name.Equals(Pages.comos.Constants.MobileTabName))
                            {
                                string html;
                                try
                                {
                                    html = await m_ComosWeb.GetObjectSpecificationAsHtml(ProjectData.SelectedDB.Key, ProjectData.SelectedProject.UID,
                                                                                         ProjectData.SelectedLayer.UID, ProjectData.SelectedLanguage.LCID, uid, item.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;
                                }

                                db.CacheScreen(uid, html);
                            }
                        }
                    }
                }
            }
        }
Beispiel #2
0
        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();
            }
        }