Exemplo n.º 1
0
        private async Task ExecuteQueriesInAttributes(UIBase[] attributes)
        {
            foreach (var attribute in attributes)
            {
                var uiframe = attribute as ComosWebSDK.UI.UIFrame;
                if (uiframe != null)
                {
                    await ExecuteQueriesInAttributes(uiframe.Children);

                    continue;
                }

                var uiquery = attribute as ComosWebSDK.UI.UIQuery;
                if (uiquery != null)
                {
                    try
                    {
                        uiquery.Result = await m_ComosWeb.GetqueriesResult(
                            ProjectData.SelectedDB.Key,
                            ProjectData.SelectedProject.ProjectUID,
                            ProjectData.SelectedLayer.UID,
                            ProjectData.SelectedLanguage.LCID,
                            uiquery.QueryUID,
                            uiquery.Owner);
                    }
                    catch (TaskCanceledException) { return; } // If there is a Logout Request
                    catch (Exception ex)
                    {
                        await App.Current.MainPage.DisplayAlert("Error", "Error al cargar query: " + ex.Message, Services.TranslateExtension.TranslateText("OK"));

                        return;
                    }

                    continue;
                }
            }
        }
Exemplo n.º 2
0
        private async Task <bool> LoadWorkPackages()
        {
            bool result = true;

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

                IComosWeb m_ComosWeb = Services.XServices.Instance.GetService <IComosWeb>();
                IDatabase db         = Services.XServices.Instance.GetService <IDatabase>();
                //this.ShowToast($"Finding CObject on DB");
                CObject o = db.GetCObjectByFullName(projectdata.SelectedLayer.UID, Constants.QueryWorkPackagesAnFailureSystemFullName);

                if (o == null)
                {
                    try
                    {
                        o = await m_ComosWeb.GetObjectBySystemFullName(projectdata.SelectedLayer, Constants.QueryWorkPackagesAnFailureSystemFullName);
                    }
                    catch (Exception ex)
                    {
                        await App.Current.MainPage.DisplayAlert("Error", "Error al cargar query: " + ex.Message, Services.TranslateExtension.TranslateText("OK"));

                        return(false);
                    }
                    db.InsertCObject(o, projectdata.SelectedLayer.UID);
                }

                if (o == null)
                {
                    await App.Current.MainPage.DisplayAlert(Services.TranslateExtension.TranslateText("error"), Services.TranslateExtension.TranslateText("my_wp_not_found"), "OK");

                    return(false);
                }

                if (!keepElements)
                {
                    try
                    {
                        m_QueryResult = await m_ComosWeb.GetqueriesResult(
                            projectdata.SelectedDB.Key, o.ProjectUID, o.OverlayUID, projectdata.SelectedLanguage.LCID, o.UID, null);
                    }
                    catch (Exception ex)
                    {
                        await App.Current.MainPage.DisplayAlert("Error", "Error al cargar query: " + ex.Message, Services.TranslateExtension.TranslateText("OK"));

                        return(false);
                    }
                }
                else
                {
                    keepElements = false;
                }

                if (m_QueryResult != null)
                {
                    if (m_QueryResult.Rows.Count() > 0)
                    {
                        List <WorkPackageViewModel> tasks = new List <WorkPackageViewModel>();
                        foreach (var row in m_QueryResult.Rows)
                        {
                            tasks.Add(new WorkPackageViewModel(m_QueryResult.Columns, row));
                        }

                        this.TasksCollection = tasks.ToArray();

                        OnPropertyChanged("TasksCollection");
                        OnPropertyChanged("TasksAttributeNames");
                        UpdateSortingAndGrouping();
                        OnPropertyChanged("SelectedIndex");
                    }
                    else
                    {
                        ShowToast(Services.TranslateExtension.TranslateText("no_wp_found"));
                    }

                    ListViewTasks.EndRefresh();
                }
                else
                {
                    //page not loaded at comosweboffline
                    ShowToast(Services.TranslateExtension.TranslateText("no_wp_found"));
                    ListViewTasks.EndRefresh();
                }
            }
            catch (Exception e)
            {
                await App.Current.MainPage.DisplayAlert(Services.TranslateExtension.TranslateText("error"), e.Message, "OK");

                return(false);
            }
            return(result);
        }
Exemplo n.º 3
0
        public static async Task <bool> LoadLogBookForm()
        {
            CQuerieResult m_QueryResult;

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

                IComosWeb m_ComosWeb = Services.XServices.Instance.GetService <IComosWeb>();
                IDatabase db         = Services.XServices.Instance.GetService <IDatabase>();

                CObject o = db.GetCObjectByFullName(projectdata.SelectedLayer.UID, Constants.QueryLogBookTypesFullName);

                if (o == null)
                {
                    try
                    {
                        o = await m_ComosWeb.GetObjectBySystemFullName(projectdata.SelectedLayer, Constants.QueryLogBookTypesFullName);
                    }
                    catch (TaskCanceledException) { return(false); } // If there is a Logout Request
                    catch (Exception ex)
                    {
                        await App.Current.MainPage.DisplayAlert("Error", "Error al cargar query: " + ex.Message, Services.TranslateExtension.TranslateText("OK"));

                        return(false);
                    }
                    db.InsertCObject(o, projectdata.SelectedLayer.UID);
                }

                if (o == null)
                {
                    await App.Current.MainPage.DisplayAlert(Services.TranslateExtension.TranslateText("error"), Services.TranslateExtension.TranslateText("no_logbook_types_found"), "OK");

                    return(false);
                }

                try
                {
                    m_QueryResult = await m_ComosWeb.GetqueriesResult(
                        projectdata.SelectedDB.Key, o.ProjectUID, o.OverlayUID, projectdata.SelectedLanguage.LCID, o.UID, null);
                }
                catch (TaskCanceledException) { return(false); } // If there is a Logout Request
                catch (Exception ex)
                {
                    await App.Current.MainPage.DisplayAlert("Error", "Error al cargar query: " + ex.Message, Services.TranslateExtension.TranslateText("OK"));

                    return(false);
                }

                if (m_QueryResult != null)
                {
                    Converters.IsQueryCachedValue cachehandler = new Converters.IsQueryCachedValue();
                    cachehandler.GetQueryCachedValues(m_QueryResult);

                    if (m_QueryResult.Rows.Length > 0)
                    {
                        logBook = new ViewModel(m_QueryResult.Columns, m_QueryResult.Rows[0]);
                        return(true);
                    }
                    else
                    {
                        await App.Current.MainPage.DisplayAlert(Services.TranslateExtension.TranslateText("error"), Services.TranslateExtension.TranslateText("no_logbook_types_found"), "OK");

                        return(false);
                    }
                }
                else
                {
                    await App.Current.MainPage.DisplayAlert(Services.TranslateExtension.TranslateText("error"), Services.TranslateExtension.TranslateText("no_logbook_types_found"), "OK");

                    return(false);
                }
            }
            catch (Exception e)
            {
                await App.Current.MainPage.DisplayAlert(Services.TranslateExtension.TranslateText("error"), e.Message, "OK");

                return(false);
            }
        }
Exemplo n.º 4
0
        private async Task <bool> LoadDevices()
        {
            bool result = false;

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

                IComosWeb m_ComosWeb = Services.XServices.Instance.GetService <IComosWeb>();
                IDatabase db         = Services.XServices.Instance.GetService <IDatabase>();

                CObject o = db.GetCObjectByFullName(projectdata.SelectedLayer.UID, GetQueryFullName());

                if (o == null)
                {
                    try
                    {
                        o = await m_ComosWeb.GetObjectBySystemFullName(projectdata.SelectedLayer, GetQueryFullName());
                    }
                    catch (Exception ex)
                    {
                        await App.Current.MainPage.DisplayAlert("Error", "Error al cargar query: " + ex.Message, Services.TranslateExtension.TranslateText("OK"));

                        return(false);
                    }
                    db.InsertCObject(o, projectdata.SelectedLayer.UID);
                }

                if (o == null)
                {
                    await App.Current.MainPage.DisplayAlert(Services.TranslateExtension.TranslateText("error"), Services.TranslateExtension.TranslateText("event_container_not_found"), "OK");

                    return(false);
                }

                try
                {
                    m_QueryResult = await m_ComosWeb.GetqueriesResult(
                        projectdata.SelectedDB.Key, o.ProjectUID, o.OverlayUID, projectdata.SelectedLanguage.LCID, o.UID, null);
                }
                catch (Exception ex)
                {
                    await App.Current.MainPage.DisplayAlert("Error", "Error al cargar query: " + ex.Message, Services.TranslateExtension.TranslateText("OK"));

                    return(false);
                }

                if (m_QueryResult != null)
                {
                    Converters.IsQueryCachedValue cachehandler = new Converters.IsQueryCachedValue();
                    cachehandler.GetQueryCachedValues(m_QueryResult);

                    if (m_QueryResult.Rows.Length > 0)
                    {
                        List <ViewModel> unassignedEventsList = new List <ViewModel>();
                        foreach (var row in m_QueryResult.Rows)
                        {
                            unassignedEventsList.Add(new ViewModel(m_QueryResult.Columns, row));
                        }

                        this.DeviceContainerCollection = unassignedEventsList.ToArray();

                        OnPropertyChanged("EventContainerCollection");

                        /*OnPropertyChanged("TasksAttributeNames");
                         *          UpdateSortingAndGrouping();*/
                        result = true;
                    }
                    else
                    {
                        ShowToast("No hay resultados");
                        result = false;
                    }
                }
                else
                {
                    //page not loaded at comosweboffline
                    ShowToast("No hay resultados");
                }

                ((ListView)ListViewDevices_).EndRefresh();
            }
            catch (Exception e)
            {
                await App.Current.MainPage.DisplayAlert(Services.TranslateExtension.TranslateText("error"), e.Message,
                                                        "OK");

                return(false);
            }

            return(result);
        }
Exemplo n.º 5
0
        public async Task <bool> LoadIncidentTypes()
        {
            bool result = false;

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

                IComosWeb m_ComosWeb = Services.XServices.Instance.GetService <IComosWeb>();
                IDatabase db         = Services.XServices.Instance.GetService <IDatabase>();
                //this.ShowToast($"Finding CObject on DB");
                CObject o = db.GetCObjectByFullName(projectdata.SelectedLayer.UID, Constants.QueryIncidentTypesFullName);

                if (o == null)
                {
                    try
                    {
                        o = await m_ComosWeb.GetObjectBySystemFullName(projectdata.SelectedLayer, Constants.QueryIncidentTypesFullName);
                    }
                    catch (TaskCanceledException) { return(false); } // If there is a Logout Request
                    catch (Exception ex)
                    {
                        await App.Current.MainPage.DisplayAlert("Error", "Error al cargar query: " + ex.Message, Services.TranslateExtension.TranslateText("OK"));

                        return(false);
                    }
                    db.InsertCObject(o, projectdata.SelectedLayer.UID);
                }

                if (o == null)
                {
                    await App.Current.MainPage.DisplayAlert(Services.TranslateExtension.TranslateText("error"), Services.TranslateExtension.TranslateText("my_incidents_not_found"), "OK");

                    return(false);
                }

                try
                {
                    m_QueryResult = await m_ComosWeb.GetqueriesResult(
                        projectdata.SelectedDB.Key, o.ProjectUID, o.OverlayUID, projectdata.SelectedLanguage.LCID, o.UID, null);
                }
                catch (TaskCanceledException) { return(false); } // If there is a Logout Request
                catch (Exception ex)
                {
                    await App.Current.MainPage.DisplayAlert("Error", "Error al cargar query: " + ex.Message, Services.TranslateExtension.TranslateText("OK"));

                    return(false);
                }

                if (m_QueryResult != null)
                {
                    Converters.IsQueryCachedValue cachehandler = new Converters.IsQueryCachedValue();
                    cachehandler.GetQueryCachedValues(m_QueryResult);

                    if (m_QueryResult.Rows.Length > 0)
                    {
                        List <ViewModel> incidentTypes = new List <ViewModel>();
                        foreach (var row in m_QueryResult.Rows)
                        {
                            incidentTypes.Add(new ViewModel(m_QueryResult.Columns, row));
                        }
                        this.IncidentTypesCollection = incidentTypes.ToArray();

                        OnPropertyChanged("IncidentTypesCollection");

                        /*OnPropertyChanged("TasksAttributeNames");
                         * UpdateSortingAndGrouping();*/
                    }
                    else
                    {
                        ShowToast(Services.TranslateExtension.TranslateText("no_incidents_types_found"));
                    }

                    result = true;
                }
                else
                {
                    //page not loaded at comosweboffline
                    ShowToast(Services.TranslateExtension.TranslateText("no_incidents_types_found"));
                }

                ListViewIncidents.EndRefresh();
            }
            catch (Exception e)
            {
                await App.Current.MainPage.DisplayAlert(Services.TranslateExtension.TranslateText("error"), e.Message, "OK");

                return(false);
            }

            return(result);
        }