protected override IEnumerable <PageLayout> RetrieveDataObjects()
        {
            List <PageLayout> layouts = new List <PageLayout>();

            SPWeb web = null;

            if (Web != null)
            {
                web = Web.Read();

                if (!PublishingWeb.IsPublishingWeb(web))
                {
                    throw new ArgumentException("The specified web is not a publishing web.");
                }

                AssignmentCollection.Add(web);
                AssignmentCollection.Add(web.Site);
            }

            switch (ParameterSetName)
            {
            case "PageLayout":
                foreach (SPPageLayoutPipeBind pipeBind in PageLayout)
                {
                    PageLayout    layout = pipeBind.Read(web);
                    SPContentType ct1    = null;
                    if (AssociatedContentType != null)
                    {
                        ct1 = AssociatedContentType.Read(layout.ListItem.Web);
                    }
                    if (ct1 == null || ct1.Id == layout.AssociatedContentType.Id)
                    {
                        WriteResult(layout);
                    }
                }
                break;

            case "SPWeb":
                PublishingWeb pubWeb = PublishingWeb.GetPublishingWeb(web);
                SPContentType ct2    = null;
                if (AssociatedContentType != null)
                {
                    ct2 = AssociatedContentType.Read(web);
                }
                if (ct2 == null)
                {
                    WriteResult(pubWeb.GetAvailablePageLayouts());
                }
                else
                {
                    WriteResult(pubWeb.GetAvailablePageLayouts(ct2.Id));
                }
                break;

            default:
                break;
            }

            return(null);
        }
        protected override IEnumerable <SPFile> RetrieveDataObjects()
        {
            foreach (SPFilePipeBind filePipe in Identity)
            {
                SPFile file = filePipe.Read();
                AssignmentCollection.Add(file.Web);
                AssignmentCollection.Add(file.Web.Site);
                WriteResult(file);
            }

            return(null);
        }
        protected override IEnumerable <SPLimitedWebPartManager> RetrieveDataObjects()
        {
            List <SPLimitedWebPartManager> managers = new List <SPLimitedWebPartManager>();

            if (base.DataObject != null)
            {
                managers.Add(base.DataObject);
                AssignmentCollection.Add(base.DataObject.Web);
                AssignmentCollection.Add(base.DataObject.Web.Site);

                return(managers);
            }

            return(managers);
        }
示例#4
0
        protected override IEnumerable <object> RetrieveDataObjects()
        {
            List <object> customizedPages = new List <object>();

            switch (ParameterSetName)
            {
            case "SPWeb":
                foreach (SPWebPipeBind webPipe in Web)
                {
                    SPWeb web = webPipe.Read();

                    if (Recurse.IsPresent)
                    {
                        Common.Pages.EnumUnGhostedFiles.RecurseSubWebs(web, ref customizedPages, AsString.IsPresent);
                    }
                    else
                    {
                        Common.Pages.EnumUnGhostedFiles.CheckFoldersForUnghostedFiles(web.RootFolder, ref customizedPages, AsString.IsPresent);
                    }
                }
                break;

            case "SPSite":
                foreach (SPSitePipeBind sitePipe in Site)
                {
                    SPSite site = sitePipe.Read();
                    Common.Pages.EnumUnGhostedFiles.RecurseSubWebs(site.RootWeb, ref customizedPages, AsString.IsPresent);
                }
                break;
            }

            foreach (object page in customizedPages)
            {
                if (!AsString.IsPresent)
                {
                    AssignmentCollection.Add(((SPFile)page).Web);
                    AssignmentCollection.Add(((SPFile)page).Web.Site);
                }
                WriteResult(page);
            }

            return(null);
        }
示例#5
0
        protected override IEnumerable <SPList> RetrieveDataObjects()
        {
            List <SPList> lists = new List <SPList>();
            SPWeb         web   = null;

            if (this.Web != null)
            {
                web = this.Web.Read();
            }

            if (Identity == null && ParameterSetName != "AllListsByType")
            {
                foreach (SPList list in web.Lists)
                {
                    lists.Add(list);
                }
            }
            else if (Identity == null && ParameterSetName == "AllListsByType")
            {
                foreach (SPList list in web.GetListsOfType(ListType))
                {
                    lists.Add(list);
                }
            }
            else
            {
                SPList list = this.Identity.Read(web);
                if (list != null)
                {
                    lists.Add(list);
                }
            }

            AssignmentCollection.Add(web);
            foreach (SPList list1 in lists)
            {
                AssignmentCollection.Add(list1.ParentWeb);
                AssignmentCollection.Add(list1.ParentWeb.Site);
            }

            return(lists);
        }
        public void GetAssignmentsByUserTest()
        {
            AssignmentCollection tempAssignmentCol = new AssignmentCollection();

            //Create a new assignment, insert it into the database, and then insert it into the Assignment Collection.
            for (int x = 0; x < 10; x++)
            {
                Assignment temp = NewAssignment();
                temp.AssignedTo = "testing";
                InsertAssignmentIntoDatabase(temp);
                tempAssignmentCol.Add(temp);
            }

            //Get all Assignments by that Ticket Id...
            AssignmentCollection tempAssignmentCol2 = HelpdeskService.GetAssignmentsByUser("testing");

            foreach (Assignment temp in tempAssignmentCol)
            {
                Assert.IsTrue(tempAssignmentCol2.Contains(temp), "The new assignment collection did not contain the same data as the original");
            }
            Assert.IsTrue(tempAssignmentCol2.Count >= tempAssignmentCol.Count);
        }
        public void GetAssignmentsByTicketIdTest()
        {
            AssignmentCollection tempAssignmentCol = new AssignmentCollection();

            //Create a new assignment, insert it into the database, and then insert it into the Assignment Collection.
            for (int x = 0; x < 10; x++)
            {
                Assignment temp = NewAssignment();
                temp.TicketId = 0;
                InsertAssignmentIntoDatabase(temp);
                tempAssignmentCol.Add(temp);
            }

            //Get all Assignments by that Ticket Id...
            AssignmentCollection tempAssignmentCol2 = HelpdeskService.GetAssignmentsByTicketId(0);
            foreach (Assignment temp in tempAssignmentCol)
            {
                Assert.IsTrue(tempAssignmentCol2.Contains(temp));
            }

            Assert.IsTrue(tempAssignmentCol2.Count == tempAssignmentCol.Count);
        }
        public void GetAssignmentsByTicketIdTest()
        {
            AssignmentCollection tempAssignmentCol = new AssignmentCollection();

            //Create a new assignment, insert it into the database, and then insert it into the Assignment Collection.
            for (int x = 0; x < 10; x++)
            {
                Assignment temp = NewAssignment();
                temp.TicketId = 0;
                InsertAssignmentIntoDatabase(temp);
                tempAssignmentCol.Add(temp);
            }

            //Get all Assignments by that Ticket Id...
            AssignmentCollection tempAssignmentCol2 = HelpdeskService.GetAssignmentsByTicketId(0);

            foreach (Assignment temp in tempAssignmentCol)
            {
                Assert.IsTrue(tempAssignmentCol2.Contains(temp));
            }

            Assert.IsTrue(tempAssignmentCol2.Count == tempAssignmentCol.Count);
        }
        public void GetAssignmentsByUserAndActiveTest()
        {
            AssignmentCollection tempAssignmentCol = new AssignmentCollection();

            //Create a new assignment, insert it into the database, and then insert it into the Assignment Collection.
            for (int x = 0; x < 10; x++)
            {
                Assignment temp = NewAssignment();
                temp.AssignedTo = "testing";
                temp.IsActive = true;
                InsertAssignmentIntoDatabase(temp);
                tempAssignmentCol.Add(temp);
            }

            //Get all Assignments by that Ticket Id...
            AssignmentCollection tempAssignmentCol2 = HelpdeskService.GetAssignmentByUserAndActive("testing", true);

            foreach (Assignment temp in tempAssignmentCol)
            {
                Assert.IsTrue(tempAssignmentCol2.Contains(temp), "The new assignment collection did not contain the same data as the original");
            }
            Assert.IsTrue(tempAssignmentCol2.Count >= tempAssignmentCol.Count);
        }
        protected override IEnumerable <PublishingPage> RetrieveDataObjects()
        {
            List <PublishingPage> publishingPages = new List <PublishingPage>();

            switch (ParameterSetName)
            {
            case "SPWeb":
                foreach (SPWebPipeBind webPipe in Web)
                {
                    SPWeb web = webPipe.Read();

                    WriteVerbose("Getting publishing page from " + web.Url);
                    if (!PublishingWeb.IsPublishingWeb(web))
                    {
                        WriteWarning(string.Format("Web \"{0}\" is not a publishing web and will be skipped.", web.Url));
                        continue;
                    }
                    PublishingWeb pubWeb = PublishingWeb.GetPublishingWeb(web);


                    if (PageName == null || PageName.Length == 0)
                    {
                        foreach (PublishingPage page in pubWeb.GetPublishingPages())
                        {
                            publishingPages.Add(page);
                        }
                    }
                    else
                    {
                        foreach (string pageName in PageName)
                        {
                            string pageUrl = string.Format("{0}/{1}/{2}", web.Url.TrimEnd('/'), pubWeb.PagesListName, pageName.Trim('/'));

                            try
                            {
                                PublishingPage page = pubWeb.GetPublishingPage(pageUrl);
                                if (page != null)
                                {
                                    publishingPages.Add(page);
                                }
                                else
                                {
                                    WriteWarning("Could not locate the specified page: " + pageUrl);
                                }
                            }
                            catch (ArgumentException)
                            {
                                WriteWarning("Could not locate the specified page: " + pageUrl);
                            }
                        }
                    }
                }
                break;

            case "SPFile":
                foreach (SPFilePipeBind filePipe in Identity)
                {
                    SPFile file = filePipe.Read();
                    if (!PublishingWeb.IsPublishingWeb(file.Web))
                    {
                        WriteWarning(string.Format("Web \"{0}\" is not a publishing web and will be skipped.", file.Web.Url));
                        continue;
                    }

                    WriteVerbose("Getting publishing page from " + file.Url);
                    try
                    {
                        PublishingPage page = null;
                        if (file.Exists)
                        {
                            page = PublishingPage.GetPublishingPage(file.Item);
                        }

                        if (page != null)
                        {
                            publishingPages.Add(page);
                        }
                        else
                        {
                            WriteWarning("Could not locate the specified page: " + file.Url);
                        }
                    }
                    catch (ArgumentException)
                    {
                        WriteWarning("Could not locate the specified page: " + file.Url);
                    }
                }
                break;
            }

            foreach (PublishingPage page in publishingPages)
            {
                AssignmentCollection.Add(page.PublishingWeb.Web);
                AssignmentCollection.Add(page.PublishingWeb.Web.Site);
                WriteResult(page);
            }

            return(null);
        }