예제 #1
0
        private async void LoadTasksQuery()
        {
            m_Query.nav = this.NavigationBarControl;

            ViewModels.ProjectData projectdata = Services.XServices.Instance.GetService <ViewModels.ProjectData>();
            IComosWeb m_ComosWeb = Services.XServices.Instance.GetService <IComosWeb>();
            CObject   o          = await m_ComosWeb.GetObjectBySystemFullName(projectdata.SelectedLayer, "@Q|@M|MyTasks");

            //ToolbarItems.Add(new ToolbarItem("Lista", "", async () =>
            //{
            //    m_Query.ViewMode = controls.QueryControl.QueryViewMode.Accordion;
            //    await m_Query.ShowListQuery();
            //}));

            //ToolbarItems.Add(new ToolbarItem("Tabela", "", async () =>
            //{
            //    m_Query.ViewMode = controls.QueryControl.QueryViewMode.List;
            //    await m_Query.ShowTableQuery();
            //}));


            m_Query.StartQuery(projectdata.SelectedDB.Key, o);

            this.NavigationBarControl.OnFiltered += m_Query.Nav_OnFiltered;
        }
예제 #2
0
        private async void returnToWorkpackagePage()
        {
            try
            {
                IComosWeb m_ComosWeb = Services.XServices.Instance.GetService <IComosWeb>();
                ViewModels.ProjectData projectdata = Services.XServices.Instance.GetService <ViewModels.ProjectData>();

                var Specifications = await m_ComosWeb.GetObjectSpecification(projectdata.SelectedDB.Key, projectdata.SelectedProject.UID, projectdata.SelectedLayer.UID, projectdata.SelectedLanguage.LCID, wp.UID);

                foreach (var item in Specifications)
                {
                    if (item.Name.Equals(Constants.MobileTabName))
                    {
                        //Get OT Number
                        string myOTNumber = "";
                        var    objects    = await m_ComosWeb.GetNavigatorNodes_Children(projectdata.SelectedLayer.Database, projectdata.SelectedProject.UID, projectdata.SelectedLayer.UID, projectdata.SelectedLanguage.LCID, this.wp.UID, "U");

                        CObject[] devices = objects.ToArray();
                        foreach (var device in devices)
                        {
                            if (device.Description.Equals(Constants.WP_OTCode_Description))
                            {
                                myOTNumber = device.Name;
                            }
                        }
                        await App.Navigation.PushAsync(new PageAttributes(projectdata.SelectedDB.Key, projectdata.SelectedLanguage.LCID, item, wp, "wp", myOTNumber));
                    }
                }
            }
            catch (Exception ex)
            {
                await App.Current.MainPage.DisplayAlert("Error", "Error al obtener atributos: " + ex.Message, Services.TranslateExtension.TranslateText("OK"));
            }
        }
예제 #3
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);
                            }
                        }
                    }
                }
            }
        }
예제 #4
0
        public static async Task <CObject> GetObjectBySystemFullName(this IComosWeb comosweb, CWorkingLayer layer, string systemfullname)
        {
            CObject current = null;

            try
            {
                string[] names  = systemfullname.Split('|');
                string   target = layer.ProjectUID;
                bool     found  = false;

                var nodes = await comosweb.GetNavigatorNodes_TreeNodes(layer, "1033", target, "U");

                if (nodes == null)
                {
                    return(null);
                }
                var currentnode = nodes.FirstOrDefault();
                if (currentnode != null)
                {
                    List <CObject> items = currentnode.Items;
                    for (int i = 0; i < names.Length; i++)
                    {
                        foreach (var node in items)
                        {
                            if (string.Compare(node.Name, names[i]) == 0)
                            {
                                found   = true;
                                current = node;
                                target  = current.UID;
                                items   = await comosweb.GetNavigatorNodes_Children(layer.Database, layer.ProjectUID, layer.UID, "1033", target, "U");

                                break;
                            }
                        }
                        if (!found)
                        {
                            return(null);
                        }
                        found = false;
                    }
                }
            }
            catch (Exception e)
            {
            }

            return(current);
        }
예제 #5
0
        public override StartCommandResult OnStartCommand(Intent intent, StartCommandFlags flags, int startId)
        {
            CheckAndDownloadAditionalContent downloader = new CheckAndDownloadAditionalContent();
            IComosWeb m_ComosWeb = Services.XServices.Instance.GetService <IComosWeb>();
            var       platform   = Services.XServices.Instance.GetService <Services.IPlatformSystem>();

            platform.SendNotification("COMOS MRO", Services.TranslateExtension.TranslateText("downloading_tasks"));

            Task.Run(async() =>
            {
                string[] uids = intent.GetStringArrayExtra("uids");

                m_ComosWeb.Lock();
                int i = 0;
                foreach (var item in uids)
                {
                    i++;
                    platform.SendNotification("COMOS MRO", Services.TranslateExtension.TranslateText("downloading_tasks"), false, true, uids.Length, i);

                    try
                    {
                        var page = await downloader.DownloadDeviceContent(item, false);

                        if (page == null)
                        {
                            platform.SendNotification("COMOS MRO", TranslateExtension.TranslateText("download_failed") + ": " + TranslateExtension.TranslateText("task_not_found"), true, true, uids.Length, 0, 0);
                            m_ComosWeb.UnLock();
                            return(StartCommandResult.NotSticky);
                        }
                    }
                    catch (Exception ex)
                    {
                        platform.SendNotification("COMOS MRO", TranslateExtension.TranslateText("download_failed") + ": " + ex.Message, true, true, uids.Length, 0, 0);
                        m_ComosWeb.UnLock();
                        return(StartCommandResult.NotSticky);
                    }
                }

                m_ComosWeb.UnLock();
                platform.SendNotification("COMOS MRO", Services.TranslateExtension.TranslateText("download_tasks_done"), true, true, uids.Length, 0, 0);

                return(StartCommandResult.NotSticky);
            });

            return(StartCommandResult.NotSticky);
        }
예제 #6
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);
        }
예제 #7
0
        private async Task <bool> GetTaskInfoByUID(string UID, bool push = false)
        {
            IComosWeb m_ComosWeb = Services.XServices.Instance.GetService <IComosWeb>();

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

            List <CSpecification> Specifications;

            try
            {
                Specifications = await m_ComosWeb.GetObjectSpecification(
                    projectdata.SelectedDB.Key,
                    projectdata.SelectedProject.UID,
                    projectdata.SelectedLayer.UID,
                    projectdata.SelectedLanguage.LCID,
                    UID);
            }
            catch (Exception e)
            {
                await App.Current.MainPage.DisplayAlert("Error", "Error al obtener atributos: " + e.Message, Services.TranslateExtension.TranslateText("OK"));

                return(false);
            }

            foreach (var item in Specifications)
            {
                if (item.Name.Equals(Constants.MobileTabName))
                {
                    CSystemObject sysobj;
                    try
                    {
                        sysobj = await m_ComosWeb.GetObject(projectdata.SelectedLayer, UID, projectdata.SelectedLanguage.LCID);
                    }
                    catch (Exception ex)
                    {
                        await App.Current.MainPage.DisplayAlert("Error", "Error al cargar OT´s: " + ex.Message, Services.TranslateExtension.TranslateText("OK"));

                        return(false);
                    }

                    if (sysobj == null)
                    {
                        return(false);
                    }

                    CObject o = new CObject()
                    {
                        ClassType       = sysobj.SystemType,
                        Description     = sysobj.Description,
                        IsClientPicture = sysobj.IsClientPicture,
                        Name            = sysobj.Name,
                        UID             = sysobj.UID,
                        OverlayUID      = projectdata.SelectedLayer.UID,
                        Picture         = sysobj.Picture,
                        ProjectUID      = projectdata.SelectedProject.ProjectUID,
                        SystemFullName  = sysobj.Name,
                    };

                    //Get OT Number
                    string otNumber = "";
                    var    objects  = await m_ComosWeb.GetNavigatorNodes_Children(projectdata.SelectedLayer.Database, projectdata.SelectedProject.UID, projectdata.SelectedLayer.UID, projectdata.SelectedLanguage.LCID, sysobj.UID, "U");

                    CObject[] devices = objects.ToArray();
                    foreach (var device in devices)
                    {
                        if (device.Description.Equals(Constants.WP_OTCode_Description))
                        {
                            otNumber = device.Name;
                        }
                    }

                    PageAttributes page = new PageAttributes(projectdata.SelectedDB.Key, projectdata.SelectedLanguage.LCID, item, o, "wp", otNumber);
                    //WorkPackageDetail page = new WorkPackageDetail(item,UID);
                    if (push)
                    {
                        await this.Navigation.PushAsync(page);
                    }

                    return(true);
                }
            }

            this.ShowToast(Services.TranslateExtension.TranslateText("mobile_tab_not_found"));

            return(false);
        }
예제 #8
0
        public async Task <PageAttributes> DownloadDeviceContent(string UID, bool push, bool onlymobile = true, bool recursive = true)
        {
            PageAttributes mobilepage = null;
            bool           download   = false;
            IComosWeb      m_ComosWeb = Services.XServices.Instance.GetService <IComosWeb>();

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


            List <CSpecification> Specifications;

            try
            {
                Specifications = await m_ComosWeb.GetObjectSpecification(
                    projectdata.SelectedDB.Key,
                    projectdata.SelectedProject.UID,
                    projectdata.SelectedLayer.UID,
                    projectdata.SelectedLanguage.LCID,
                    UID);
            }
            catch (TaskCanceledException) { return(null); } // 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(null);
            }

            if (Specifications == null || Specifications.Count == 0)
            {
                return(null);
            }

            foreach (var item in Specifications)
            {
                //TO DO DOWNLOAD EVERYTHING???

                if (item.Name.Equals(Constants.MobileTabName) || !onlymobile)
                {
                    download = true;
                }

                if (download)
                {
                    CSystemObject sysobj;
                    try
                    {
                        sysobj = await m_ComosWeb.GetObject(projectdata.SelectedLayer, UID, projectdata.SelectedLanguage.LCID);
                    }
                    catch (TaskCanceledException) { return(null); } // If there is a Logout Request
                    catch (Exception ex)
                    {
                        await App.Current.MainPage.DisplayAlert("Error", "Error al cargar objetos de Comos Web: " + ex.Message, Services.TranslateExtension.TranslateText("OK"));

                        return(null);
                    }

                    if (sysobj == null)
                    {
                        return(null);
                    }

                    CObject o = new CObject()
                    {
                        ClassType       = sysobj.SystemType,
                        Description     = sysobj.Description,
                        IsClientPicture = sysobj.IsClientPicture,
                        Name            = sysobj.Name,
                        UID             = sysobj.UID,
                        OverlayUID      = projectdata.SelectedLayer.UID,
                        Picture         = sysobj.Picture,
                        ProjectUID      = projectdata.SelectedProject.UID,
                        SystemFullName  = sysobj.Name,
                    };

                    //check if its download only

                    PageAttributes page = null;
                    if (!push)
                    {
                        page = new PageAttributes();
                        await page.Init(projectdata.SelectedDB.Key, projectdata.SelectedLanguage.LCID, item, o);
                    }
                    else
                    {
                        page = new PageAttributes(projectdata.SelectedDB.Key, projectdata.SelectedLanguage.LCID, item, o);
                    }

                    //download all documents if not pushing to page
                    if (!push)
                    {
                        List <string> uids_docs = await page.DownloadDocuments();

                        foreach (var doc in uids_docs)
                        {
                            // string[] filename_mime = await DownloadDocument(doc, false);
                            CDocument filename_mime = await DownloadDocument(doc, false);

                            if (filename_mime != null && filename_mime.FileName != null)
                            {
                                db.CacheDocumentFilePath(filename_mime.FileName, filename_mime.MimeType, doc, projectdata.SelectedProject.UID, projectdata.SelectedLayer.UID, filename_mime.Name, filename_mime.Description, filename_mime.Picture);
                            }
                            else
                            {
                                if (recursive)
                                {
                                    await DownloadDeviceContent(doc, false, true, false);
                                }
                            }
                        }
                    }

                    if (item.Name.Equals(Constants.MobileTabName))
                    {
                        mobilepage = page;
                    }

                    download = false;
                }
            }

            return(mobilepage);
        }
예제 #9
0
        public async Task <CDocument> DownloadDocument(string UID, bool open)
        {
            IComosWeb m_ComosWeb = Services.XServices.Instance.GetService <ComosWebSDK.IComosWeb>();

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

            // Need to Lock to wait big files (on sleep will logout comosweb)
            m_ComosWeb.Lock();
            CSystemObject o;

            try
            {
                o = await m_ComosWeb.GetObject(
                    ProjectData.SelectedDB.Key,
                    ProjectData.SelectedProject.UID,
                    ProjectData.SelectedLayer.UID,
                    UID, ProjectData.SelectedLanguage.LCID);
            }
            catch (TaskCanceledException) { return(await Task.FromResult <CDocument>(null)); } // If there is a Logout Request
            catch (Exception e)
            {
                await App.Current.MainPage.DisplayAlert("Error", "Error al descargar documento: " + e.Message, Services.TranslateExtension.TranslateText("OK"));

                return(await Task.FromResult <CDocument>(null));
            }

            if (o == null)
            {
                return(await Task.FromResult <CDocument>(null));
            }
            if (o.DocumentType != null)
            {
                bool exportpdf = string.Compare(o.DocumentType.Name, "ComosReport", StringComparison.CurrentCultureIgnoreCase) == 0;
                if (!exportpdf)
                {
                    exportpdf = string.Compare(o.DocumentType.Name, "ComosIReport", StringComparison.CurrentCultureIgnoreCase) == 0;
                }
                // Is a comos report.
                CDocument result = await Task.Run <CDocument>(async() =>
                {
                    HttpResponseMessage response;
                    try
                    {
                        response = await m_ComosWeb.ComosWeb.GetDocumentStream(
                            ProjectData.SelectedDB.Key,
                            ProjectData.SelectedProject.UID,
                            ProjectData.SelectedLayer.UID,
                            UID, exportpdf);
                    }
                    catch (TaskCanceledException) { return(null); } // If there is a Logout Request
                    catch (Exception ex)
                    {
                        await App.Current.MainPage.DisplayAlert("Error", "Error al cargar documento: " + ex.Message, Services.TranslateExtension.TranslateText("OK"));
                        return(null);
                    }

                    if (response.StatusCode == System.Net.HttpStatusCode.OK)
                    {
                        string filename = response.Content.Headers.ContentDisposition.FileName;
                        System.Diagnostics.Debug.WriteLine(response.Content.Headers.ContentDisposition.DispositionType);
                        filename              = filename.Trim(new char[] { '"' });
                        filename              = filename.Replace("/", "-");
                        var stream            = await response.Content.ReadAsStreamAsync();
                        var platform          = Services.XServices.Instance.GetService <Services.IPlatformSystem>();
                        string filename_saved = await platform.SaveAndOpenDocument(filename, stream, response.Content.Headers.ContentType.MediaType, open);
                        return(new CDocument()
                        {
                            Description = o.Description,
                            Name = o.Name,
                            UID = o.UID,
                            FileName = filename_saved,
                            Picture = o.Picture,
                            MimeType = response.Content.Headers.ContentType.MediaType
                        });
                    }
                    else if (response.StatusCode == System.Net.HttpStatusCode.NotFound)
                    {
                        return(await Task.FromResult <CDocument>(null));
                    }
                    else
                    {
                        var platform = Services.XServices.Instance.GetService <Services.IPlatformSystem>();
                        platform.ShowToast("Error:" + response.ReasonPhrase);
                        return(await Task.FromResult <CDocument>(null));
                        //throw new Exception(response.ReasonPhrase);
                    }
                });

                return(result);
            }

            m_ComosWeb.UnLock();

            return(await Task.FromResult <CDocument>(null));
        }
예제 #10
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);
        }
예제 #11
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);
            }
        }
예제 #12
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);
        }