Exemplo n.º 1
0
        public static ContentPanelDTO GetContentPanel(int nodeTypeID)
        {
            var cp = new ContentPanelDTO();

            try
            {
                using (_certonaService = new CertonaServiceClient())
                {
                    try
                    {
                        var request = new GetContentPanelRequest
                        {
                            NodeTypeID = nodeTypeID,
                            User       = FormsAuthenticationWrapper.User
                        };

                        var response = _certonaService.GetContentPanel(request);

                        if (response.Success)
                        {
                            cp = response.ContentPanel;
                        }
                        else
                        {
                            cp = new ContentPanelDTO
                            {
                                Name                 = "Sample Panel",
                                PartialViewName      = "~/Views/Shared/_ContentTemplate.cshtml",
                                ContentPanelSections = new List <ContentPanelSectionDTO>()
                            };

                            var cpsList = new List <ContentPanelSectionDTO>();
                            cp.ContentPanelSections = cpsList;

                            cp.ContentPanelSections.Add(new ContentPanelSectionDTO
                            {
                                Name            = "Details1",
                                PartialViewName = "~/Views/Sample/Details.cshtml",
                                Expanded        = true
                            });

                            cp.ContentPanelSections.Add(new ContentPanelSectionDTO
                            {
                                Name            = "Details2",
                                PartialViewName = "~/Views/Sample/Details.cshtml",
                                Expanded        = true
                            });

                            cp.ContentPanelSections.Add(new ContentPanelSectionDTO
                            {
                                Name            = "Details3",
                                PartialViewName = "~/Views/Sample/Details.cshtml",
                                Expanded        = true
                            });
                        }
                    }
                    catch (TimeoutException exception)
                    {
                        _certonaService.Abort();
                        throw;
                    }
                    catch (CommunicationException exception)
                    {
                        _certonaService.Abort();
                        throw;
                    }
                }
            }
            catch (Exception ex)
            {
                cp = new ContentPanelDTO
                {
                    Name                 = "Sample Panel",
                    PartialViewName      = "~/Views/Shared/_ContentTemplate.cshtml",
                    ContentPanelSections = new List <ContentPanelSectionDTO>()
                };

                var cpsList = new List <ContentPanelSectionDTO>();
                cp.ContentPanelSections = cpsList;

                cp.ContentPanelSections.Add(new ContentPanelSectionDTO
                {
                    Name            = "Details1",
                    PartialViewName = "~/Views/Sample/Details.cshtml",
                    Expanded        = true
                });

                cp.ContentPanelSections.Add(new ContentPanelSectionDTO
                {
                    Name            = "Details2",
                    PartialViewName = "~/Views/Sample/Details.cshtml",
                    Expanded        = true
                });

                cp.ContentPanelSections.Add(new ContentPanelSectionDTO
                {
                    Name            = "Details3",
                    PartialViewName = "~/Views/Sample/Details.cshtml",
                    Expanded        = true
                });
            }

            return(cp);
        }