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")); } }
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); } } } } } }
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); }
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); }