Пример #1
0
        static void Main(string[] args)
        {
            var url      = args[0];
            var user     = args[1];
            var password = args[2];

            var authData = new PasswordAuthentication(user, password);
            var login    = new ServerLogin()
            {
                Address = new Uri(url), AuthData = authData
            };

            using (var session = SessionBuilder.CreateOrReplaceOldestSession(login))
            {
                var project = session.ServerManager.Projects["nav_demo"];
                var search  = project.Pages.CreateSearch();
                search.PageType = PageType.Unlinked;
                var unlinkedPages = search.Execute();

                IEnumerable <IPage> processedPages = new List <IPage>();

                while (unlinkedPages.Any())
                {
                    foreach (var curPage in unlinkedPages)
                    {
                        Console.WriteLine("Deleting " + curPage);
                        //curPage.Delete();
                    }
                    processedPages = processedPages.Union(unlinkedPages);
                    unlinkedPages  = search.Execute().Where(page => !processedPages.Contains(page));
                }

                Console.WriteLine("Done");
            }
        }
Пример #2
0
        static void Main(string[] args)
        {
            // RedDot Login with (user/password)
            var authData = new PasswordAuthentication("user", "password");

            var login = new ServerLogin()
            {
                Address = new Uri("http://localhost/cms"), AuthData = authData
            };

            // Session is the entry point to interact with the RedDot server.
            // Creating the session object automatically creates a connection.
            // Dispose() closes the connection in a a clean way (this is done
            // automatically at the end of the using block).
            using (var session = SessionBuilder.CreateOrReplaceOldestSession(login))
            {
                // Select a project based on the name
                var project = session.ServerManager.Projects.GetByName("MyProjekt");

                // Find all pages based on the Content Class "MyContentClass"
                var pageSearch = project.Pages.CreateSearch();
                pageSearch.ContentClass = project.ContentClasses.GetByName("MyContentClass");

                var pages = pageSearch.Execute();

                // Attach suffix ".php" to all filenames of the pages found
                foreach (var curPage in pages)
                {
                    curPage.Filename = curPage.Filename + ".php";

                    // Commit changes to the server
                    curPage.Commit();
                }
            }
        }
Пример #3
0
    static void Main(string[] args)
    {
        var authData = new PasswordAuthentication("admin", "123456");
        var url      = "http://localhost/cms";

        var login = new ServerLogin(url, authData);

        using (var session = SessionBuilder.CreateOrReplaceOldestSession(login))
        {
            //this is the currently active project in the session
            var selectedProject = session.SelectedProject;

            var serverManager = session.ServerManager;

            //these are all projects, the active user is assigned to
            var currentUsersProjects = serverManager.Projects.ForCurrentUser;

            //these are all projects for the user xy, you need to be server manager to do this
            var user             = serverManager.Users["some username"];
            var projectsOfUserXy = serverManager.Projects.ForUser(user.Guid);

            //these are all projects on the server, you need to be server manager to access projects you are not assigned to
            var allProjects = serverManager.Projects;

            //you can access a single project by name
            //var myProject = serverManager.Projects.ForCurrentUser["myproject"];
            //this is the short for
            //var myProjectToo = serverManager.Projects.ForCurrentUser.GetByName("myproject");

            //if you do not know whether a specific project exists, you can use
            IProject unknownProject;
            if (serverManager.Projects.ForCurrentUser.TryGetByName("nav_demo", out unknownProject))
            {
                Console.WriteLine($"Found project with guid: {unknownProject.Guid}");
            }
            else
            {
                Console.WriteLine("No project with name myproject assigned to user");
            }

            //you can also get a project by guid
            var projectGuid   = new Guid("...");
            var projectByGuid = serverManager.Projects.ForCurrentUser.GetByGuid(projectGuid);
            // a TryGetByGuid method is available, too

            //print all project names and guids
            Console.WriteLine("Projects:");
            foreach (var curProject in serverManager.Projects)
            {
                Console.WriteLine(curProject);
            }
        }
    }
Пример #4
0
    protected void Page_Load(object sender, EventArgs e)
    {
        var authData = new PasswordAuthentication("", "");
        var url = "";
        var login = new ServerLogin(url, authData);
        using (var session = SessionBuilder.CreateOrReplaceOldestSession(login))
        {

            var selectedProject = session.SelectedProject;
            var serverManager = session.ServerManager;

            var languageVariant = selectedProject.LanguageVariants.Current;
            var pageGuid = new Guid("");
            var elementGuid = new Guid("");

            var getElement = (ITextHtml)erminas.SmartAPI.CMS.Project.Pages.Elements.PageElementFactory.Instance.CreateElement(selectedProject, elementGuid, languageVariant);
            getElement.Value = "<p>my new text</p>";
            getElement.Commit();

    }
}