Exemplo n.º 1
0
        /// <summary>
        /// Delete matter center home page, settings page and document details page
        /// </summary>
        /// <param name="configVal">Values in Config sheet</param>
        /// <param name="pageType">Page to be deleted</param>
        internal static void DeleteSitePages(Dictionary<string, string> configVal, MatterCenterPage pageType)
        {
            try
            {
                string login = configVal["Username"]; // Get the user name
                string password = configVal["Password"]; // Get the password
                bool isDeployedOnAzure = Convert.ToBoolean(configVal["IsDeployedOnAzure"].ToUpperInvariant(), CultureInfo.InvariantCulture);
                List<string> files = new List<string>();
                string tenantUrl = configVal["TenantURL"];
                string tenantDashboardFileName, oldWebdashboard, catalogSiteURL, FileName = string.Empty;
                ClientContext siteClientContext = ConfigureSharePointContext.ConfigureClientContext(tenantUrl, login, password, isDeployedOnAzure);
                switch (Convert.ToString(pageType, CultureInfo.InvariantCulture).ToUpperInvariant())
                {
                    case Constants.MatterCenterHome:
                        {
                            tenantDashboardFileName = tenantUrl + ConfigurationManager.AppSettings["spWebDashboardPage"];
                            oldWebdashboard = ConfigurationManager.AppSettings["oldWebdashboardPage"];
                            FileName = tenantDashboardFileName.Substring(tenantDashboardFileName.LastIndexOf('/') + 1);
                            files.Add(oldWebdashboard);
                            Console.WriteLine(string.Concat(Constants.DeletePageSuccessMessage, tenantUrl));
                            break;
                        }
                    case Constants.Settings:
                        {
                            FileName = ConfigurationManager.AppSettings["SettingsPageName"];
                            Console.WriteLine(string.Concat(Constants.DeletePageSuccessMessage, tenantUrl));
                            break;
                        }
                    case Constants.DocumentDetails:
                        {
                            catalogSiteURL = configVal["CatalogSiteURL"];
                            siteClientContext = ConfigureSharePointContext.ConfigureClientContext(catalogSiteURL, login, password, isDeployedOnAzure);
                            FileName = ConfigurationManager.AppSettings["DocumentLandingPageName"];
                            Console.WriteLine(string.Concat(Constants.DeletePageSuccessMessage + catalogSiteURL));
                            break;
                        }
                }
                files.Add(FileName);
                DeletePages(siteClientContext, files);

                if (string.Equals(Constants.Settings, Convert.ToString(pageType, CultureInfo.InvariantCulture).ToUpperInvariant()))
                {
                    string groupName = ConfigurationManager.AppSettings["PracticeGroupName"],
                        termSetName = ConfigurationManager.AppSettings["TermSetName"],
                        clientIdProperty = ConfigurationManager.AppSettings["ClientIDProperty"],
                        clientUrlProperty = ConfigurationManager.AppSettings["ClientUrlProperty"];
                    try
                    {
                        ClientTermSets clients = TermStoreOperations.GetClientDetails(siteClientContext, groupName, termSetName, clientIdProperty, clientUrlProperty);
                        foreach (Client client in clients.ClientTerms)
                        {
                            try
                            {
                                string clientUrl = client.ClientUrl;
                                ClientContext clientContext = ConfigureSharePointContext.ConfigureClientContext(clientUrl, login, password, isDeployedOnAzure);
                                Console.WriteLine(string.Concat(Constants.DeletePageSuccessMessage, clientUrl));
                                DeletePages(clientContext, files);
                                DeleteList(clientContext);
                            }
                            catch (Exception exception)
                            {
                                ErrorLogger.DisplayErrorMessage(string.Format(CultureInfo.InvariantCulture, Constants.ProvisioningPageExceptionMessage, exception.Message, exception.StackTrace));
                            }
                        }
                    }
                    catch (Exception exception)
                    {
                        ErrorLogger.DisplayErrorMessage(string.Format(CultureInfo.InvariantCulture, Constants.ProvisioningPageExceptionMessage, exception.Message, exception.StackTrace));
                    }
                }
            }
            catch (Exception exception)
            {
                ErrorLogger.DisplayErrorMessage(string.Format(CultureInfo.InvariantCulture, Constants.ProvisioningPageExceptionMessage, exception.Message, exception.StackTrace));
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Delete matter center home page, settings page and document details page
        /// </summary>
        /// <param name="configVal">Values in Config sheet</param>
        /// <param name="pageType">Page to be deleted</param>
        internal static void DeleteSitePages(Dictionary <string, string> configVal, MatterCenterPage pageType)
        {
            try
            {
                string        login = configVal["Username"];    // Get the user name
                string        password = configVal["Password"]; // Get the password
                List <string> files = new List <string>();
                string        tenantUrl = configVal["TenantURL"];
                string        tenantDashboardFileName, oldWebdashboard, catalogSiteURL, FileName = string.Empty;
                ClientContext siteClientContext = ConfigureSharePointContext.ConfigureClientContext(tenantUrl, login, password);
                switch (Convert.ToString(pageType, CultureInfo.InvariantCulture).ToUpperInvariant())
                {
                case Constants.MatterCenterHome:
                {
                    tenantDashboardFileName = tenantUrl + ConfigurationManager.AppSettings["spWebDashboardPage"];
                    oldWebdashboard         = ConfigurationManager.AppSettings["oldWebdashboardPage"];
                    FileName = tenantDashboardFileName.Substring(tenantDashboardFileName.LastIndexOf('/') + 1);
                    files.Add(oldWebdashboard);
                    Console.WriteLine(string.Concat(Constants.DeletePageSuccessMessage, tenantUrl));
                    break;
                }

                case Constants.Settings:
                {
                    FileName = ConfigurationManager.AppSettings["SettingsPageName"];
                    Console.WriteLine(string.Concat(Constants.DeletePageSuccessMessage, tenantUrl));
                    break;
                }

                case Constants.DocumentDetails:
                {
                    catalogSiteURL    = configVal["CatalogSiteURL"];
                    siteClientContext = ConfigureSharePointContext.ConfigureClientContext(catalogSiteURL, login, password);
                    FileName          = ConfigurationManager.AppSettings["DocumentLandingPageName"];
                    Console.WriteLine(string.Concat(Constants.DeletePageSuccessMessage + catalogSiteURL));
                    break;
                }
                }
                files.Add(FileName);
                DeletePages(siteClientContext, files);

                if (string.Equals(Constants.Settings, Convert.ToString(pageType, CultureInfo.InvariantCulture).ToUpperInvariant()))
                {
                    string groupName         = ConfigurationManager.AppSettings["PracticeGroupName"],
                           termSetName       = ConfigurationManager.AppSettings["TermSetName"],
                           clientIdProperty  = ConfigurationManager.AppSettings["ClientIDProperty"],
                           clientUrlProperty = ConfigurationManager.AppSettings["ClientUrlProperty"];
                    try
                    {
                        ClientTermSets clients = TermStoreOperations.GetClientDetails(siteClientContext, groupName, termSetName, clientIdProperty, clientUrlProperty);
                        foreach (Client client in clients.ClientTerms)
                        {
                            try
                            {
                                string        clientUrl     = client.ClientUrl;
                                ClientContext clientContext = ConfigureSharePointContext.ConfigureClientContext(clientUrl, login, password);
                                Console.WriteLine(string.Concat(Constants.DeletePageSuccessMessage, clientUrl));
                                DeletePages(clientContext, files);
                                DeleteList(clientContext);
                            }
                            catch (Exception exception)
                            {
                                ErrorLogger.DisplayErrorMessage(string.Format(CultureInfo.InvariantCulture, Constants.ProvisioningPageExceptionMessage, exception.Message, exception.StackTrace));
                            }
                        }
                    }
                    catch (Exception exception)
                    {
                        ErrorLogger.DisplayErrorMessage(string.Format(CultureInfo.InvariantCulture, Constants.ProvisioningPageExceptionMessage, exception.Message, exception.StackTrace));
                    }
                }
            }
            catch (Exception exception)
            {
                ErrorLogger.DisplayErrorMessage(string.Format(CultureInfo.InvariantCulture, Constants.ProvisioningPageExceptionMessage, exception.Message, exception.StackTrace));
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// To create Provision matter pages
        /// </summary>
        /// <param name="configVal">values in the config sheet</param>
        /// <param name="urlConstantName">To get constant name of page</param>
        /// <param name="sourceFileTemplate">To get source file path</param>
        /// <param name="pageUrlName">To get page Url name</param>
        /// <param name="pageType">Page to be deleted</param>
        internal static void CreateProvisionPages(Dictionary<string, string> configVal, string urlConstantName, string sourceFileTemplate, string pageUrlName, MatterCenterPage pageType)
        {
            try
            {
                string login = configVal["Username"]; // Get the user name
                string password = configVal["Password"]; // Get the password
                bool isDeployedOnAzure = Convert.ToBoolean(configVal["IsDeployedOnAzure"].ToUpperInvariant(), CultureInfo.InvariantCulture);
                string tenantUrl = configVal["TenantURL"];
                List<string> files = new List<string>();
                string FileName = string.Empty;
                string pageFileName = string.Empty;
                string pageContent = string.Empty;
                string catalogSiteURL = configVal["CatalogSiteURL"]; // Get the URL for catalog site collection
                string catalogSiteConstant = ConfigurationManager.AppSettings["catalogSiteConstant"];
                string tenantSettingsFileName = string.Empty;
                string destinationFileName = string.Empty;
                ClientContext ClientContext = ConfigureSharePointContext.ConfigureClientContext(tenantUrl, login, password, isDeployedOnAzure);

                string pageUrlConstant = urlConstantName;
                string sourceFileTemplatePath = string.Concat(Directory.GetParent(Directory.GetCurrentDirectory()).Parent.FullName, Constants.Backslash, ConfigurationManager.AppSettings["staticContentFolder"], Constants.Backslash, ConfigurationManager.AppSettings["htmlFolder"], Constants.Backslash, sourceFileTemplate);
                string pageUrl = string.Concat(configVal["UISiteURL"], pageUrlName);
                // Read the content of helper file
                pageContent = System.IO.File.ReadAllText(sourceFileTemplatePath);
                // Set the Catalog site collection URL in the content of webdashboard helper page
                pageContent = pageContent.Replace(catalogSiteConstant, new Uri(catalogSiteURL).AbsolutePath);

                FileName = string.Concat(tenantUrl, ConfigurationManager.AppSettings["spWebDashboardPage"]);
                bool value = false;
                // App web part content
                switch (Convert.ToString(pageType, CultureInfo.InvariantCulture).ToUpperInvariant())
                {
                    case Constants.MatterCenterHome:
                        {
                            pageContent = pageContent.Trim();
                            pageContent = pageContent.Replace(pageUrlConstant, pageUrl);
                            pageFileName = FileName.Substring(FileName.LastIndexOf('/') + 1);
                            Console.WriteLine(string.Concat(Constants.DeletePageMessage, tenantUrl));
                            destinationFileName = FileName;
                            break;
                        }
                    case Constants.Settings:
                        {
                            pageContent = pageContent.Replace(pageUrlConstant, pageUrl);
                            tenantSettingsFileName = string.Concat(tenantUrl, ConfigurationManager.AppSettings["spSettingsPage"]);
                            pageFileName = ConfigurationManager.AppSettings["SettingsPageName"];
                            Console.WriteLine(string.Concat(Constants.DeletePageMessage, tenantUrl));
                            destinationFileName = tenantSettingsFileName;
                            value = true;
                            break;
                        }
                    case Constants.DocumentDetails:
                        {
                            pageFileName = ConfigurationManager.AppSettings["DocumentLandingPageName"];
                            ClientContext = ConfigureSharePointContext.ConfigureClientContext(catalogSiteURL, login, password, isDeployedOnAzure);
                            FileName = string.Concat(catalogSiteURL, ConfigurationManager.AppSettings["spDocumentLanding"]);
                            Console.WriteLine(string.Concat(Constants.DeletePageSuccessMessage, catalogSiteURL));
                            destinationFileName = pageFileName;
                            break;
                        }
                }

                files.Add(pageFileName);
                DeletePages(ClientContext, files);
                Folder DestinationFolder = CreateHelperPage(ClientContext, FileName);
                CreateMatterCenterPage(ClientContext, DestinationFolder, destinationFileName, pageContent, value);

                if (string.Equals(Constants.Settings, Convert.ToString(pageType, CultureInfo.InvariantCulture).ToUpperInvariant()))
                {
                    string groupName = ConfigurationManager.AppSettings["PracticeGroupName"],
                        termSetName = ConfigurationManager.AppSettings["TermSetName"],
                        clientIdProperty = ConfigurationManager.AppSettings["ClientIDProperty"],
                        clientUrlProperty = ConfigurationManager.AppSettings["ClientUrlProperty"];
                    ClientTermSets clients = TermStoreOperations.GetClientDetails(ClientContext, groupName, termSetName, clientIdProperty, clientUrlProperty); // Read client details from term store
                    // As Client level web dashboard will not be created, commenting code for provisioning client web dashboard page
                    foreach (Client client in clients.ClientTerms)
                    {
                        try
                        {
                            string clientUrl = client.ClientUrl;
                            // string fileName = clientUrl + ConfigurationManager.AppSettings["spWebDashboardPage"];
                            string settingsFileName = string.Concat(clientUrl, ConfigurationManager.AppSettings["spSettingsPage"]);
                            ClientContext clientContext = ConfigureSharePointContext.ConfigureClientContext(clientUrl, login, password, isDeployedOnAzure);
                            // Deleting client web dashboard pages
                            Console.WriteLine(string.Concat(Constants.DeletePageMessage, clientUrl));
                            DeletePages(clientContext, files);
                            // Create helper file for site collections
                            // Folder destinationFolder = CreateHelperPage(clientContext, fileName);
                            Folder destinationFolder = CreateHelperPage(clientContext, settingsFileName);

                            // Upload web dashboard page
                            // CreateMatterCenterPage(clientContext, destinationFolder, fileName, helperFileContent, false);

                            // Upload settings page
                            CreateMatterCenterPage(clientContext, destinationFolder, settingsFileName, pageContent, true);
                            // Create list
                            CreateList(clientContext);
                        }
                        catch (Exception exception)
                        {
                            ErrorLogger.DisplayErrorMessage(string.Format(CultureInfo.InvariantCulture, Constants.ProvisioningPageExceptionMessage, exception.Message, exception.StackTrace));
                        }
                    }
                }
            }
            catch (Exception exception)
            {
                ErrorLogger.DisplayErrorMessage(string.Format(CultureInfo.InvariantCulture, Constants.ProvisioningPageExceptionMessage, exception.Message, exception.StackTrace));
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// To create Provision matter pages
        /// </summary>
        /// <param name="configVal">values in the config sheet</param>
        /// <param name="urlConstantName">To get constant name of page</param>
        /// <param name="sourceFileTemplate">To get source file path</param>
        /// <param name="pageUrlName">To get page Url name</param>
        /// <param name="pageType">Page to be deleted</param>
        internal static void CreateProvisionPages(Dictionary <string, string> configVal, string urlConstantName, string sourceFileTemplate, string pageUrlName, MatterCenterPage pageType)
        {
            try
            {
                string        login                  = configVal["Username"]; // Get the user name
                string        password               = configVal["Password"]; // Get the password
                string        tenantUrl              = configVal["TenantURL"];
                List <string> files                  = new List <string>();
                string        FileName               = string.Empty;
                string        pageFileName           = string.Empty;
                string        pageContent            = string.Empty;
                string        catalogSiteURL         = configVal["CatalogSiteURL"]; // Get the URL for catalog site collection
                string        catalogSiteConstant    = ConfigurationManager.AppSettings["catalogSiteConstant"];
                string        tenantSettingsFileName = string.Empty;
                string        destinationFileName    = string.Empty;
                ClientContext ClientContext          = ConfigureSharePointContext.ConfigureClientContext(tenantUrl, login, password);

                string pageUrlConstant        = urlConstantName;
                string sourceFileTemplatePath = string.Concat(Directory.GetParent(Directory.GetCurrentDirectory()).Parent.FullName, Constants.Backslash, ConfigurationManager.AppSettings["staticContentFolder"], Constants.Backslash, ConfigurationManager.AppSettings["htmlFolder"], Constants.Backslash, sourceFileTemplate);
                string pageUrl = configVal["UISiteURL"];
                // Read the content of helper file
                pageContent = System.IO.File.ReadAllText(sourceFileTemplatePath);
                // Set the Catalog site collection URL in the content of webdashboard helper page
                pageContent = pageContent.Replace(catalogSiteConstant, new Uri(catalogSiteURL).AbsolutePath);

                FileName = string.Concat(tenantUrl, ConfigurationManager.AppSettings["spWebDashboardPage"]);
                bool value = false;
                // App web part content
                switch (Convert.ToString(pageType, CultureInfo.InvariantCulture).ToUpperInvariant())
                {
                case Constants.MatterCenterHome:
                {
                    pageContent  = pageContent.Trim();
                    pageContent  = pageContent.Replace(pageUrlConstant, pageUrl);
                    pageFileName = FileName.Substring(FileName.LastIndexOf('/') + 1);
                    Console.WriteLine(string.Concat(Constants.DeletePageMessage, tenantUrl));
                    destinationFileName = FileName;
                    break;
                }

                case Constants.Settings:
                {
                    pageContent            = pageContent.Replace(pageUrlConstant, pageUrl);
                    tenantSettingsFileName = string.Concat(tenantUrl, ConfigurationManager.AppSettings["spSettingsPage"]);
                    pageFileName           = ConfigurationManager.AppSettings["SettingsPageName"];
                    Console.WriteLine(string.Concat(Constants.DeletePageMessage, tenantUrl));
                    destinationFileName = tenantSettingsFileName;
                    value = true;
                    break;
                }

                case Constants.DocumentDetails:
                {
                    pageFileName  = ConfigurationManager.AppSettings["DocumentLandingPageName"];
                    ClientContext = ConfigureSharePointContext.ConfigureClientContext(catalogSiteURL, login, password);
                    FileName      = string.Concat(catalogSiteURL, ConfigurationManager.AppSettings["spDocumentLanding"]);
                    Console.WriteLine(string.Concat(Constants.DeletePageSuccessMessage, catalogSiteURL));
                    destinationFileName = pageFileName;
                    break;
                }
                }

                files.Add(pageFileName);
                DeletePages(ClientContext, files);
                Folder DestinationFolder = CreateHelperPage(ClientContext, FileName);
                CreateMatterCenterPage(ClientContext, DestinationFolder, destinationFileName, pageContent, value);

                if (string.Equals(Constants.Settings, Convert.ToString(pageType, CultureInfo.InvariantCulture).ToUpperInvariant()))
                {
                    string groupName         = ConfigurationManager.AppSettings["PracticeGroupName"],
                           termSetName       = ConfigurationManager.AppSettings["TermSetName"],
                           clientIdProperty  = ConfigurationManager.AppSettings["ClientIDProperty"],
                           clientUrlProperty = ConfigurationManager.AppSettings["ClientUrlProperty"];
                    ClientTermSets clients   = TermStoreOperations.GetClientDetails(ClientContext, groupName, termSetName, clientIdProperty, clientUrlProperty); // Read client details from term store
                    // As Client level web dashboard will not be created, commenting code for provisioning client web dashboard page
                    foreach (Client client in clients.ClientTerms)
                    {
                        try
                        {
                            string clientUrl = client.ClientUrl;
                            // string fileName = clientUrl + ConfigurationManager.AppSettings["spWebDashboardPage"];
                            string        settingsFileName = string.Concat(clientUrl, ConfigurationManager.AppSettings["spSettingsPage"]);
                            ClientContext clientContext    = ConfigureSharePointContext.ConfigureClientContext(clientUrl, login, password);
                            // Deleting client web dashboard pages
                            Console.WriteLine(string.Concat(Constants.DeletePageMessage, clientUrl));
                            DeletePages(clientContext, files);
                            // Create helper file for site collections
                            // Folder destinationFolder = CreateHelperPage(clientContext, fileName);
                            Folder destinationFolder = CreateHelperPage(clientContext, settingsFileName);

                            // Upload web dashboard page
                            // CreateMatterCenterPage(clientContext, destinationFolder, fileName, helperFileContent, false);

                            // Upload settings page
                            CreateMatterCenterPage(clientContext, destinationFolder, settingsFileName, pageContent, true);
                            // Create list
                            CreateList(clientContext);
                        }
                        catch (Exception exception)
                        {
                            ErrorLogger.DisplayErrorMessage(string.Format(CultureInfo.InvariantCulture, Constants.ProvisioningPageExceptionMessage, exception.Message, exception.StackTrace));
                        }
                    }
                }
            }
            catch (Exception exception)
            {
                ErrorLogger.DisplayErrorMessage(string.Format(CultureInfo.InvariantCulture, Constants.ProvisioningPageExceptionMessage, exception.Message, exception.StackTrace));
            }
        }