Exemplo n.º 1
0
        private async void ListViewObjects_ItemTapped(object sender, ItemTappedEventArgs e)
        {
            //ComosWebSDK.Data.CObject cached = (ComosWebSDK.Data.CObject)e.Item;
            Services.IPlatformSystem   plataform = Services.XServices.Instance.GetService <Services.IPlatformSystem>();
            ComosWebSDK.Data.CDocument doc       = e.Item as ComosWebSDK.Data.CDocument;

            await plataform.OpenFile(doc.FileName, doc.MimeType);
        }
Exemplo n.º 2
0
        private async void ViewCell_DocumentTapped(object sender, EventArgs e)
        {
            var viewcell = sender as StackLayout;
            var row      = viewcell.BindingContext as CRow;

            await viewcell.ScaleTo(1.2, 50, Easing.Linear);

            await viewcell.ScaleTo(1, 50, Easing.Linear);

            if ((bool)docconverter.Convert(row.Items[0].UID, null, null, null))
            {
                if (plataform.IsOnline)
                {
                    plataform.ShowProgressMessage(Services.TranslateExtension.TranslateText("downloading_documents"), true);
                    //string[] filename_andtype = await DownloadDocument(row.Items[0].UID);
                    CDocument filename_andtype = await DownloadDocument(row.Items[0].UID);

                    if (filename_andtype != null && !string.IsNullOrEmpty(filename_andtype.FileName))
                    {
                        cachedb.CacheDocumentFilePath(filename_andtype.FileName, filename_andtype.MimeType, row.Items[0].UID, ProjectData.SelectedProject.UID, ProjectData.SelectedLayer.UID, filename_andtype.Name, filename_andtype.Description, filename_andtype.Picture);
                    }
                    if (filename_andtype == null)
                    {
                        plataform.ShowToast(Services.TranslateExtension.TranslateText("document_not_found"));
                    }
                    if (string.IsNullOrEmpty(filename_andtype.FileName))
                    {
                        // Can happen in emulator. When folder /SDCard/Storage/Download not exists.
                        plataform.ShowToast(Services.TranslateExtension.TranslateText("save_not_possible"));
                    }

                    plataform.HideProgressMessage();
                }
                else
                {
                    string[] path = cachedb.GetDocumentFilePath(row.Items[0].UID, ProjectData.SelectedProject.UID, ProjectData.SelectedLayer.UID);
                    if (path != null && path[0] != "")
                    {
                        bool result = await plataform.OpenFile(path[0], path[1]);
                    }
                    //else doc not found in cache
                }
            }
            else if ((bool)devconverter.Convert(row.Items[0].UID, null, null, null))
            {
                // open device properties

                if (m_Page != null)
                {
                    CSystemObject sysobj;
                    try
                    {
                        sysobj = await m_ComosWeb.GetObject(ProjectData.SelectedLayer, row.Items[0].UID, ProjectData.SelectedLanguage.LCID);
                    }
                    catch (Exception ex)
                    {
                        await App.Current.MainPage.DisplayAlert("Error", "Error al cargar objetos de Comos Web: " + ex.Message, Services.TranslateExtension.TranslateText("OK"));

                        return;
                    }

                    if (sysobj != 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.ProjectUID,
                            SystemFullName  = sysobj.Name,
                        };
                        PageSpecifications page = new PageSpecifications(ProjectData.SelectedDB.Key, o, ProjectData.SelectedLanguage.LCID);

                        await m_Page.Navigation.PushAsync(page);
                    }
                }
            }
        }