Exemplo n.º 1
0
    /// <summary>
    /// Sets the application connection string and initializes the application.
    /// </summary>
    private void SetAppConnectionString()
    {
        ConnectionHelper.ConnectionString = ConnectionString;

        // Init core
        CMSApplication.Init();
    }
Exemplo n.º 2
0
        /// <summary>
        /// Initializes CMS context.
        /// </summary>
        public static void CMSInit()
        {
            // Initialize path of application
            SystemContext.WebApplicationPhysicalPath = Application.StartupPath;

            CMSApplication.Init();
        }
Exemplo n.º 3
0
        public static void UnitTest()
        {
            CurrentContainer = new IoCContainer();
            IO.Container     = CurrentContainer;
            SettingsService.InclVat();
            VatCalculationStrategy.OverParts();

            Logger.Mock();

            UwebshopConfiguration.UseType <UwebshopConfiguration>();            // todo no UseType? (slow)
            UwebshopRequestService.Use(MockConstructors.CreateMockUwebshopRequestService());

            OrderDiscountRepository.SetupFake();
            CategoryService.Use(MockConstructors.CreateMockEntityService <ICategoryService, Category>());
            ProductVariantService.Use(MockConstructors.CreateMockEntityService <IProductVariantService, ProductVariant>());
            CouponCodeService.Mock();

            StoreRepository.Use(new TestStoreRepository());
            CMSEntityRepository.Use(new TestCMSEntityRepository());
            CountryRepository.Use(new TestCountryRepository());
            VATCountryRepository.Use(new TestVATCountryRepository());
            OrderRepository.Mock();
            ProductDiscountRepository.Mock();
            ProductRepository.Mock();
            ProductVariantGroupRepository.Mock();
            CategoryRepository.Mock();
            ProductVariantRepository.Mock();

            CMSApplication.Use(new StubCMSApplicationNotInBackend());
            HttpContextWrapper.Mock();

            DiscountService.UseType <FakeDiscountService>();

            StoreService.Use(new TestStoreService());
            OrderService.Use(new TestOrderService());
            ProductService.Use(new TestProductService());
            CMSDocumentTypeService.Use(new StubCMSDocumentTypeService());

            OrderUpdatingService.Mock();
            OrderNumberService.Mock();
            CatalogUrlResolvingService.Mock();
            PaymentProviderService.Mock();
            StoreFromUrlDeterminationService.Mock();
            StockService.Mock();
            ApplicationCacheService.Mock();

            UwebshopRequestService.Use(new StubUwebshopRequestService());

            CurrentContainer.SetDefaultServiceFactory(new MockServiceFactory());

            ModuleFunctionality.Register(CurrentContainer);
            CurrentContainer.RegisterType <IContentTypeAliassesXmlService, StubContentTypeAliassesXmlService>();
            CurrentContainer.RegisterType <IProductVariantGroupService, ProductVariantGroupService>();

            InitializeServiceLocators();
        }
Exemplo n.º 4
0
        /// <summary>
        /// Runs the bootstrapper process.
        /// </summary>
        public static void Run()
        {
            // Discover routes to Kentico HTTP handlers before the MVC application starts to allow adding them to the route table.
            // It is not possible to completely initialize Kentico yet as it requires access to the current HTTP request that is not available in this phase of application life-cycle.
            SystemContext.IsWebSite = true;
            CMSApplication.PreInit();

            // Register the module that provider Kentico ASP.NET MVC integration.
            HttpApplication.RegisterModule(typeof(ApplicationHttpModule));
        }
        public override void Configure(IFunctionsHostBuilder builder)
        {
            builder.Services.AddLogging();
            var _loggerFactory = new LoggerFactory();
            var logger         = _loggerFactory.CreateLogger("Startup");

            try
            {
                // Loads kentico libraries into the app domain
                RegisterCmsAssemblies();

                // Loads custom libraries into the app domain
                RegisterCustomAssemblies();

                // Prinit types
                CMSApplication.PreInit();

                // Declare any Interfaces here, note you do not need to add any interfaces that are automatically implemented through Xperience's IoC attributes such as ProviderInterface
                //builder.Services.AddTransient<ICustomRepository, CustomRepository>();

                // Merge kentico services into the builder services
                Service.MergeDescriptors(builder.Services);

                var    Config          = builder.GetContext().Configuration;
                string EnvironmentName = builder.GetContext().EnvironmentName;

                // Wait for database to be ready since this is a external service
                CMSApplication.WaitForDatabaseAvailable.Value = true;

                string ConnectionString;
                if (EnvironmentName.Equals("Development", StringComparison.InvariantCultureIgnoreCase))
                {
                    // Setup connection string (manually or read frOm key/vault, settings file etc.)  This will read from local.settings.json -> ConnectionStrings.CMSConnectionString
                    ConnectionString = Config.GetSection("ConnectionStrings").GetSection("CMSConnectionString").Value;
                }
                else
                {
                    // In Azure Functions, will be grabbing just the CMSConnectionString from the Azure Functio -> Configuration -> Application Settings
                    ConnectionString = Environment.GetEnvironmentVariable("CMSConnectionString", EnvironmentVariableTarget.Process);
                }

                // Set connection string
                ConnectionHelper.ConnectionString = ConnectionString;

                // Init database
                CMSApplication.Init();
            }
            catch (Exception ex)
            {
                logger.LogError(ex, "An error occurred during startup");
            }
        }
Exemplo n.º 6
0
        protected override void ApplicationStartup(TinyIoCContainer container, IPipelines pipelines)
        {
            base.ApplicationStartup(container, pipelines);
            CMSApplication.Init();
            TypeAdapterConfig <DataClassInfo, BridgeClassInfo> .NewConfig()
            .Ignore(dest => dest.AssignedSites)
            .Ignore(dest => dest.AllowedChildTypes)
            ;

            var userValidator = container.Resolve <IUserValidator>();

            pipelines.EnableBasicAuthentication(new BasicAuthenticationConfiguration(userValidator, "BridgeRealm"));
        }
        static void Main(string[] args)
        {
            CMSApplication.Init();

            new ObjectQuery <UserSettingsInfo>()
            .From(new QuerySource(new QuerySourceTable("CMS_UserSettings", "US")))
            .DebugQuery("From")
            .Source(s => s.Join(new QuerySourceTable(
                                    "CMS_User", "U"),
                                "US.UserSettingsUserID",
                                "U.UserID"))
            .DebugQuery("Join")
            .WhereLike("Email", "*****@*****.**")
            .DebugQuery("Like Email")
            .WhereTrue("UserEnabled")
            .DebugQuery("User Enabled");
        }
Exemplo n.º 8
0
        public static async Task <int> Main(string[] args)
        {
            CMSApplication.PreInit(true);

            // Connect to external database
            var connString = Environment.GetEnvironmentVariable("CMSConnectionString");

            ConnectionHelper.ConnectionString = connString;

            CMSApplication.Init();
            return(await Bootstrapper
                   .Factory
                   .CreateDefault(args)
                   .AddPipeline <RatingPipeline>()
                   .AddPipeline <BookPipeline>()
                   .AddPipeline <AuthorPipeline>()
                   .AddPipeline <ContactPipeline>()
                   .AddPipeline("Assets", outputModules: new IModule[] { new CopyFiles("assets/**") })
                   .RunAsync());
        }
        /// <summary>
        /// Initialize Kentico CMS Application using the supplied parameters.
        /// </summary>
        /// <param name="siteLocation">The directory where the Kentico site resides.</param>
        /// <param name="connectionString">The connection string to use for initializing the CMS Application.</param>
        /// <param name="writeDebug">A delegate for writing to the debug stream.</param>
        /// <param name="writeVerbose">A delegate for writing to the verbose stream.</param>
        public void Initialize(DirectoryInfo siteLocation, string connectionString, Action <string> writeDebug = null, Action <string> writeVerbose = null)
        {
            // We don't need to do anything if the application is already initialized.
            if (this.InitializationState != InitializationState.Uninitialized)
            {
                return;
            }

            DataConnectionFactory.ConnectionString = connectionString;

            // This is how Kentico recommends working with their API.
#pragma warning disable CS0618 // Type or member is obsolete
            AppDomain.CurrentDomain.AppendPrivatePath(Path.GetDirectoryName(typeof(KenticoCmsApplicationService).Assembly.Location));
#pragma warning restore CS0618 // Type or member is obsolete

            SystemContext.WebApplicationPhysicalPath = siteLocation.FullName;

            if (!CMSApplication.Init())
            {
                throw new Exception("CMS Application initialization failed.");
            }
        }
        private void HandleBeginRequest(object sender, EventArgs e)
        {
            CMSApplication.Init();

            var application      = (HttpApplication)sender;
            var context          = application.Context;
            var relativeFilePath = context.Request.AppRelativeCurrentExecutionFilePath.TrimStart('~');

            // Check whether the current request URL contains information about a preview mode
            if (VirtualContext.HandleVirtualContext(ref relativeFilePath))
            {
                // Validate integrity of preview information (including the unique identifier generated by Kentico) in the current request URL
                if (!VirtualContext.ValidatePreviewHash(relativeFilePath) || !ValidatePreviewGuid(VirtualContext.GetItem(VirtualContext.PARAM_WF_GUID)))
                {
                    VirtualContext.Reset();
                    throw new HttpException(404, "The preview link is not valid.");
                }

                // Disable same origin policy for a preview mode as Kentico displays preview in a frame
                AntiForgeryConfig.SuppressXFrameOptionsHeader = true;

                // Do not cache response in a preview mode, it has to contain current data
                context.Response.Cache.SetNoServerCaching();
                context.Response.Cache.SetNoStore();

                // Remove preview mode information from the request URL
                context.RewritePath("~" + relativeFilePath, context.Request.PathInfo, context.Request.Url.Query.TrimStart('?'));
            }
            else
            {
                // Add validation callback for the output cache item to ignore it in a preview mode
                context.Response.Cache.AddValidationCallback(ValidateCacheItem, null);
            }

            var previewFeature = new PreviewFeature();

            context.Kentico().SetFeature <IPreviewFeature>(previewFeature);
        }
Exemplo n.º 11
0
        static void Main(string[] args)
        {
            string packagePath     = args[0] ?? "";
            string userName        = args[1] ?? "";
            string applicationPath = args[2] ?? "";
            bool   moduleExport    = false;
            string moduleName      = "";

            if (string.IsNullOrEmpty(packagePath))
            {
                Console.Error.WriteLine("No package path provided");
                return;
            }

            if (string.IsNullOrEmpty(applicationPath))
            {
                Console.Error.WriteLine("No main application path provided");
                return;
            }

            //Initialize Kentico API for external application
            CMSApplication.Init();

            SystemContext.WebApplicationPhysicalPath = applicationPath;

            ImportModule(packagePath, userName);

            ImportObject(packagePath, userName);

            string objectType = "";
            int    objectID   = 0;

            SiteExportSettings siteExportSettings = new SiteExportSettings(UserInfoProvider.GetUserInfo(userName))
            {
                WebsitePath        = SystemContext.WebApplicationPhysicalPath,
                TargetPath         = packagePath + "Export",
                CreatePackage      = true,
                TargetFileName     = $"ExportPackage_{DateTime.Now.ToString()}",
                TemporaryFilesPath = "/path",
            };
            //switch on one object vs global object selection
            var selectedObjects = ObjectSelections(objectType);

            if (objectID > 0)
            {
                var singleObject = SingleObjectSelection(objectID, selectedObjects);
                siteExportSettings.Select(singleObject.TypeInfo.ObjectType, singleObject.TypeInfo.ObjectClassName, singleObject.TypeInfo.IsSiteObject);
            }

            if (moduleExport)
            {
                siteExportSettings.SetInfo(ImportExportHelper.MODULE_NAME, moduleName);
            }

            siteExportSettings.Select(selectedObjects.TypeInfo.ObjectType, selectedObjects.TypeInfo.ObjectClassName, selectedObjects.TypeInfo.IsSiteObject);

            //Preset for global object selection
            siteExportSettings.SelectGlobalObjects(new List <string>(), "");

            // Make sure no data is in temp folder (possibly from previous unsuccessful export)
            ExportProvider.DeleteTemporaryFiles(siteExportSettings, true);
            ExportManager exportManager = new ExportManager(siteExportSettings);

            exportManager.Export(null);

            //Cleanup
            ExportProvider.DeleteTemporaryFiles(siteExportSettings, true);

            return;
        }
Exemplo n.º 12
0
 private void HandleBeginRequest(object sender, EventArgs e)
 {
     CMSApplication.Init();
 }
        private void Extract(IConsole console, ExtractorSettings settings)
        {
            var redirects = new List <(string, string)>();

            // Create the output directories if needed
            if (!DryRun)
            {
                PrepareObjectDirectory(settings);
            }

            //Doc to save the actual content as xml
            var xmlDocument = new XmlDocument();
            var parentElem  = xmlDocument.CreateNode("element", settings.PageType.Replace(".", "-") + "s", "");

            //Fire up our Kentico Xperience instance
            ConnectionHelper.ConnectionString = settings.ConnectionString;
            ValidationHelper.HashStringSalt   = settings.HashStringSalt;
            CMSApplication.Init();

            // Gets an object representing a specific Kentico user
            UserInfo user = UserInfoProvider.GetUserInfo(settings.XperienceUser);

            // Sets the context of the user
            using (new CMSActionContext(user))
            {
                var wc = new WebClient();

                //Get me all published pages of the specified page type on the site
                var posts = DocumentHelper.GetDocuments(settings.PageType)
                            .Columns(settings.PageTypeColumns)
                            .Path(settings.RootNodeAliasPath, PathTypeEnum.Children)
                            .PublishedVersion()
                            .Published()
                            .TopN(settings.TopN)
                            .OrderBy(settings.OrderByColumns);

                console.WriteLine($"{posts.Count} nodes found.");
                console.WriteLine("Exporting node data...");

                int nodeOrder = 1;
                foreach (TreeNode post in posts)
                {
                    //Create a new AgilityPack doc for working with the page
                    HtmlDocument doc = new HtmlDocument();
                    doc.OptionOutputAsXml = false; //if true adds a weird span tag

                    doc.DocumentNode.AppendChild(HtmlNode.CreateNode("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"));
                    doc.DocumentNode.AppendChild(HtmlNode.CreateNode(Environment.NewLine));

                    string nodeAliasPath = post.NodeAliasPath;

                    nodeAliasPath = nodeAliasPath.Split('/').Last();   //clean it up to just the slug

                    // Add redirect to the list
                    redirects.Add((post.NodeAliasPath, nodeAliasPath));

                    // TODO: use FormInfo to determine "DocumentName" field
                    string nodeTitle = post.DocumentName;

                    //Create a parent folder path in the data directory to store all xml about this node in a structured way on the file system
                    string nodeDirPath = Path.Combine(settings.ObjectDirectory, settings.PageType, nodeAliasPath.Replace("/", "-"));
                    if (!Directory.Exists(nodeDirPath))
                    {
                        Directory.CreateDirectory(nodeDirPath);
                    }

                    //Create root xml Element of the pageTypeName ex. <cms-blogpost>
                    // and start saving fields as attributes and child elements in this xml structure
                    var rootNode = HtmlNode.CreateNode($"<{settings.PageType.Replace( ".", "-" )} />");
                    rootNode.Attributes.Append("originalAliasPath");
                    rootNode.SetAttributeValue("originalAliasPath", post.NodeAliasPath);
                    rootNode.AppendChild(HtmlNode.CreateNode(Environment.NewLine));

                    var aliasNode = HtmlNode.CreateNode($"<newaliaspath/>");
                    aliasNode.InnerHtml = nodeAliasPath;
                    rootNode.AppendChild(aliasNode);

                    var orderNode = HtmlNode.CreateNode($"<newnodeorder/>");
                    orderNode.InnerHtml = nodeOrder.ToString();
                    rootNode.AppendChild(orderNode);
                    nodeOrder++;

                    //Kentico dynamic properties or "With the Coupled Columns of the page type"
                    //Iterate through all of the fields of a document in order to serialize them to xml
                    foreach (var dprop in post.Properties)
                    {
                        if (Array.IndexOf(settings.PageTypeColumns, dprop) > 0)
                        {
                            //Create xml Element that represents each field ex. <blogpostsummary>data</blogpostsummary>
                            var node = HtmlNode.CreateNode($"<{dprop} />");
                            var data = post.GetValue(dprop, "");

                            //Special stuff for Mcbeev Blog Post Summary (can be ignored for others)
                            if (dprop.ToLower().Contains("summary"))
                            {
                                //Remove wrapped p tag on Mcbeev Blog Post Summary
                                HtmlDocument docSummary = new HtmlDocument();
                                docSummary.LoadHtml(data);
                                var newSummaryNode = HtmlNode.CreateNode($"<newblogpostsummary/>");
                                try
                                {
                                    if (docSummary.DocumentNode.SelectSingleNode("//p") != null)
                                    {
                                        newSummaryNode.InnerHtml = docSummary.DocumentNode.SelectSingleNode("//p").InnerText;
                                    }
                                    else
                                    {
                                        newSummaryNode.InnerHtml = docSummary.DocumentNode.InnerText;
                                    }
                                }
                                catch (Exception ex)
                                {
                                    //todo
                                    console.WriteLine(ex.Message);
                                }

                                rootNode.AppendChild(newSummaryNode);
                                rootNode.AppendChild(HtmlNode.CreateNode(Environment.NewLine));
                            }


                            //This is WYSIWYG content field most likely so try to resolve things as Kentico would
                            if (dprop.ToLower().Contains("title") || dprop.ToLower().Contains("body") || dprop.ToLower().Contains("content") || dprop.ToLower().Contains("summary"))
                            {
                                //Macro resolve inside of the content (handle K# macros in the text)
                                data = MacroResolver.Resolve(data);

                                //Url resolve inside of the content (handle relative urls into absolute urls) important!

                                data = HTMLHelper.ResolveUrls(data, settings.AbsoluteSiteName, true);

                                //Widget identifier (try to save a list of all Portal Inline Widgets that no longer work in MVC)
                                if (data.Contains("CMSInlineControl"))
                                {
                                    console.WriteLine("Found a widget in this content.");
                                    // TODO Make this a real log
                                    // //Render the value as html to HP NodedataRootDirectoryName
                                    // HtmlDocument docWidget = new HtmlDocument();
                                    // docWidget.LoadHtml(data);
                                    // var widgets = docWidget.DocumentNode.SelectNodes("//object[contains(@type, 'Widget')]");

                                    // foreach (var w in widgets)
                                    // {
                                    //     console.WriteLine(w.OuterHtml);
                                    // }
                                }

                                //Media library identifier
                                if (data.Contains("<img "))
                                {
                                    HtmlDocument docImg = new HtmlDocument();
                                    docImg.LoadHtml(data);
                                    var ImageURLs = docImg.DocumentNode.Descendants("img")
                                                    .Select(e => e.GetAttributeValue("src", null))
                                                    .Where(s => !String.IsNullOrEmpty(s));

                                    foreach (var oldImageURL in ImageURLs)
                                    {
                                        //Skip mp3s for now
                                        if (oldImageURL.EndsWith(".mp3") || oldImageURL.Contains(".mp3?"))
                                        {
                                            continue;
                                        }

                                        console.WriteLine($"trying to save {oldImageURL} ...");
                                        var safeName = oldImageURL.Split(new char[] { '?' })[0];
                                        safeName = safeName.Replace(".aspx", "");

                                        //Save the images locally if we can download from the "real" running site
                                        try
                                        {
                                            wc.DownloadFile(oldImageURL, Path.Combine(nodeDirPath, Path.GetFileName(safeName)));
                                        }
                                        catch (Exception ex)
                                        {
                                            console.WriteLine(ex.Message);
                                        }

                                        //rewrite the image path back in the data node
                                        // TODO - make this a config parameter and not hard coded to Mcbeev.com
                                        data = data.Replace(oldImageURL, "/MBV/media/blog/" + nodeAliasPath.Replace("/", "-") + "/" + oldImageURL.Split(new char[] { '/' }).Last());

                                        //replace the odd .png.aspx thing
                                        data = data.Replace(".png.aspx", ".png");
                                    }
                                }

                                //Use HTMLAgility Pack to fix non closed image tags
                                HtmlNode.ElementsFlags["img"] = HtmlElementFlag.Closed;
                                HtmlDocument docContent = new HtmlDocument();
                                docContent.LoadHtml(data);

                                data = $"<![CDATA[{docContent.DocumentNode.OuterHtml}]]>";
                            }

                            //Most likely image only field and not a WYSIWYG field
                            // TODO - is there a better way to check for this?
                            if ((data.Length > 2) && (data.StartsWith("~/")))
                            {
                                data = data.Replace("~/", settings.AbsoluteSiteName);

                                console.WriteLine($"trying to save {data} ...");
                                var safeName = data.Split(new char[] { '?' })[0];
                                safeName = safeName.Replace(".aspx", "");
                                wc.DownloadFile(data, Path.Combine(nodeDirPath, Path.GetFileName(safeName)));

                                //rewrite the image path back in the data node
                                safeName = "/MBV/media/blog/" + nodeAliasPath.Replace("/", "-") + "/" + safeName.Split(new char[] { '/' }).Last();

                                data = $"<![CDATA[{safeName}]]>";
                            }

                            node.AppendChild(doc.CreateTextNode(data));
                            rootNode.AppendChild(node);
                            rootNode.AppendChild(HtmlNode.CreateNode("\r\n"));
                        }
                    }
                    doc.DocumentNode.AppendChild(rootNode);

                    //Save the single node to its own XML document in its directory
                    doc.Save($@"{nodeDirPath}\{nodeAliasPath.Replace( "/", "-" )}.xml");

                    //Chop off the header to prepare for bundling
                    doc.DocumentNode.ChildNodes[0].Remove();

                    //add this node to all nodes in main XML doc
                    parentElem.InnerXml += doc.DocumentNode.OuterHtml;
                    xmlDocument.AppendChild(parentElem);
                }

                if (!DryRun)
                {
                    WriteRedirects(redirects, settings);
                    xmlDocument.Save(Path.Combine(settings.ObjectDirectory, settings.PageType, settings.AllNodesFilename));

                    console.WriteLine($"Extraction to {settings.ObjectDirectory} succeeded");
                }
                else
                {
                    console.WriteLine("Dry run succeeded");
                }
            }
        }
Exemplo n.º 14
0
        private static void Main(string[] args)
        {
            string profileName = string.Empty;

            // Create new instance of AD provider
            ImportProfile.OnDirectoryControllerChanged += () => PrincipalProvider.ClearContext();

            // If there are some arguments specified
            if (args.Length != 0)
            {
                // Try to attach console
                if (!AttachConsole(-1))
                {
                    // Create new console
                    AllocConsole();
                }

                // For each argument
                for (int i = 0; i < args.Length; i++)
                {
                    string arg = args[i];

                    // If argument specifies profile
                    if ((arg == "/profile") || (arg == "-profile"))
                    {
                        // Get profile name
                        if ((i + 1) < args.Length)
                        {
                            if (profileName == string.Empty)
                            {
                                profileName = args[i + 1].Trim();
                            }
                        }
                    }
                    if ((arg == "/h") || (arg == "-h") || (arg == "--help") || (arg == "-?") || (arg == "/?"))
                    {
                        // Write help
                        Console.Write(ResHelper.GetString("Console_Help").Replace("\\n", "\n").Replace("\\r", "\r"));
                        return;
                    }
                }

                // If there was profile specified
                if (profileName != string.Empty)
                {
                    // If there is no such file
                    if (!File.Exists(profileName))
                    {
                        Console.WriteLine(ResHelper.GetString("Error_ProfileDoesNotExist", profileName));
                    }
                    else
                    {
                        // Try to get file info
                        FileInfo fi = FileInfo.New(profileName);

                        Console.WriteLine(ResHelper.GetString("Console_SelectedImportProfile", fi.FullName));

                        // Initialize import profile
                        string validationError = ImportProfile.InitializeImportProfile(profileName);
                        if (!String.IsNullOrEmpty(validationError))
                        {
                            Console.WriteLine(ResHelper.GetString("Error_ProfileIsNotValid"));
                            Console.WriteLine(validationError);
                        }
                        else
                        {
                            // Application is in console mode
                            ImportProfile.UsesConsole = true;

                            // Check permissions
                            string permissionsCheckResult = PrincipalProvider.CheckPermissions();
                            if (!string.IsNullOrEmpty(permissionsCheckResult))
                            {
                                Console.WriteLine(permissionsCheckResult);
                            }
                            else
                            {
                                // Initialize principal provider
                                bool providerInitialized = ValidatePrincipalProvider(PrincipalProvider);
                                bool databaseValid       = ValidateDatabase();

                                if (providerInitialized && databaseValid)
                                {
                                    // Initialize CMS connection
                                    CMSImport.ConfigureApplicationSettings();

                                    // Perform CMS import
                                    CMSImport.Import(PrincipalProvider, MessageLog);
                                }
                            }
                        }
                    }
                }
                else
                {
                    // Write message
                    Console.WriteLine(ResHelper.GetString("Console_SpecifyProfile"));
                }
            }
            // Launch windows form application
            else
            {
                // Preinitialize CMS context
                CMSApplication.PreInit();

                // Initialize application
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                Application.Run(new ADWizard(PrincipalProvider));
            }
        }