Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            Console.Title = "Umbraco Console";

            //Initialize the application
            var application = new ConsoleApplicationBase();

            application.Start(application, new EventArgs());
            Console.WriteLine("Application Started");

            Console.WriteLine("--------------------");
            //Write status for ApplicationContext
            var context = ApplicationContext.Current;

            Console.WriteLine("ApplicationContext is available: " + (context != null).ToString());
            //Write status for DatabaseContext
            var databaseContext = context.DatabaseContext;

            Console.WriteLine("DatabaseContext is available: " + (databaseContext != null).ToString());
            //Write status for Database object
            var database = databaseContext.Database;

            Console.WriteLine("Database is available: " + (database != null).ToString());
            Console.WriteLine("--------------------");

            //Get the ServiceContext and the two services we are going to use
            var serviceContext     = context.Services;
            var contentService     = serviceContext.ContentService;
            var contentTypeService = serviceContext.ContentTypeService;

            //Exit the application?
            var waitOrBreak = true;

            while (waitOrBreak)
            {
                //List options
                Console.WriteLine("-- Options --");
                Console.WriteLine("List content nodes: l");
                Console.WriteLine("Create new content: c");
                Console.WriteLine("Create Umbraco database schema in empty db: d");
                Console.WriteLine("Quit application: q");

                var input = Console.ReadLine();
                if (string.IsNullOrEmpty(input) == false && input.ToLowerInvariant().Equals("q"))
                {
                    waitOrBreak = false;//Quit the application
                }
                else if (string.IsNullOrEmpty(input) == false && input.ToLowerInvariant().Equals("l"))
                {
                    ListContentNodes(contentService);//Call the method that lists all the content nodes
                }
                else if (string.IsNullOrEmpty(input) == false && input.ToLowerInvariant().Equals("c"))
                {
                    CreateNewContent(contentService, contentTypeService);//Call the method that does the actual creation and saving of the Content object
                }
                else if (string.IsNullOrEmpty(input) == false && input.ToLowerInvariant().Equals("d"))
                {
                    CreateDatabaseSchema(database);
                }
            }
        }
Ejemplo n.º 2
0
        private static void RunUmbraco()
        {
            Console.Title = "Umbraco Console";

            //Initialize the application
            var application = new ConsoleApplicationBase();

            application.Start(application, new EventArgs());
            Console.WriteLine("Application Started");

            Console.WriteLine("--------------------");
            //Write status for ApplicationContext
            var context = ApplicationContext.Current;

            Console.WriteLine("ApplicationContext is available: " + (context != null).ToString());
            //Write status for DatabaseContext
            var databaseContext = context.DatabaseContext;

            Console.WriteLine("DatabaseContext is available: " + (databaseContext != null).ToString());
            //Write status for Database object
            var database = databaseContext.Database;

            Console.WriteLine("Database is available: " + (database != null).ToString());
            Console.WriteLine("--------------------");

            //Get the ServiceContext and the two services we are going to use
            var serviceContext     = context.Services;
            var contentService     = serviceContext.ContentService;
            var contentTypeService = serviceContext.ContentTypeService;


            var args            = AppDomain.CurrentDomain.GetData("args") as string[];
            var executeTypeName = "";

            if (args != null && args.Length > 0)
            {
                executeTypeName = args[0];
            }
            if (!String.IsNullOrWhiteSpace(executeTypeName))
            {
                ExecuteType(context, executeTypeName);
                return;
            }

            //Exit the application?
            var waitOrBreak = true;

            while (waitOrBreak)
            {
                //List options
                Console.WriteLine("-- Options --");
                Console.WriteLine("List content nodes: l");
                Console.WriteLine("Create new content: c");
                Console.WriteLine("Create Umbraco database schema in empty db: d");
                Console.WriteLine("Execute type :e");
                Console.WriteLine("Quit application: q");

                var input = Console.ReadLine();
                if (string.IsNullOrEmpty(input) == false && input.ToLowerInvariant().Equals("q"))
                {
                    waitOrBreak = false; //Quit the application
                }
                else if (string.IsNullOrEmpty(input) == false && input.ToLowerInvariant().Equals("l"))
                {
                    ListContentNodes(contentService); //Call the method that lists all the content nodes
                }
                else if (string.IsNullOrEmpty(input) == false && input.ToLowerInvariant().Equals("c"))
                {
                    CreateNewContent(contentService, contentTypeService);
                }
                //Call the method that does the actual creation and saving of the Content object
                else if (string.IsNullOrEmpty(input) == false && input.ToLowerInvariant().Equals("d"))
                {
                    CreateDatabaseSchema(database, databaseContext.DatabaseProvider, application.DataDirectory);
                }
                else if (string.IsNullOrEmpty(input) == false && input.ToLowerInvariant().Equals("e"))
                {
                    ExecuteType(context);
                }
            }
        }
Ejemplo n.º 3
0
        static void Main(string[] args)
        {
            Console.Title = "Umbraco Console";

            //Initialize the application
            var application = new ConsoleApplicationBase();
            application.Start(application, new EventArgs());
            Console.WriteLine("Application Started");

            Console.WriteLine("--------------------");
            //Write status for ApplicationContext
            var context = ApplicationContext.Current;
            Console.WriteLine("ApplicationContext is available: " + (context != null).ToString());
            //Write status for DatabaseContext
            var databaseContext = context.DatabaseContext;
            Console.WriteLine("DatabaseContext is available: " + (databaseContext != null).ToString());
            //Write status for Database object
            var database = databaseContext.Database;
            Console.WriteLine("Database is available: " + (database != null).ToString());
            Console.WriteLine("--------------------");

            //Get the ServiceContext and the two services we are going to use
            var serviceContext = context.Services;
            var contentService = serviceContext.ContentService;
            var contentTypeService = serviceContext.ContentTypeService;

            //Exit the application?
            var waitOrBreak = true;
            while (waitOrBreak)
            {
                //List options
                Console.WriteLine("-- Options --");
                Console.WriteLine("List content nodes: l");
                Console.WriteLine("Create new content: c");
                Console.WriteLine("Create Umbraco database schema in empty db: d");
                Console.WriteLine("Quit application: q");

                var input = Console.ReadLine();
                if (string.IsNullOrEmpty(input) == false && input.ToLowerInvariant().Equals("q"))
                    waitOrBreak = false;//Quit the application
                else if (string.IsNullOrEmpty(input) == false && input.ToLowerInvariant().Equals("l"))
                    ListContentNodes(contentService);//Call the method that lists all the content nodes
                else if (string.IsNullOrEmpty(input) == false && input.ToLowerInvariant().Equals("c"))
                    CreateNewContent(contentService, contentTypeService);//Call the method that does the actual creation and saving of the Content object
                else if (string.IsNullOrEmpty(input) == false && input.ToLowerInvariant().Equals("d"))
                    CreateDatabaseSchema(database);
            }
        }