Exemplo n.º 1
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"));
            }
        }
Exemplo n.º 2
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);
        }
Exemplo n.º 3
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);
        }