예제 #1
0
        /// <summary>
        /// Defines the entry point of the application.
        /// </summary>
        /// <param name="args">The arguments.</param>
        static void Main(string[] args)
        {
            IAsyncLogger logger               = O365GroupsFactory.GetLogger(new string[] { Constants.AppSettings.LoggerInstanceKey }) as IAsyncLogger;
            var          siteMapFileName      = ConfigurationManager.AppSettings[Constants.AppSettings.SiteMapKey];
            var          siteMapSheetName     = ConfigurationManager.AppSettings[Constants.AppSettings.SiteMapSheetKey];
            var          userMappingFileName  = ConfigurationManager.AppSettings[Constants.AppSettings.UserMappingKey];
            var          userMappingSheetName = ConfigurationManager.AppSettings[Constants.AppSettings.UserMappingSheetKey];
            var          retryCount           = int.Parse(ConfigurationManager.AppSettings[Constants.AppSettings.RetryCountKey]);
            var          delay     = int.Parse(ConfigurationManager.AppSettings[Constants.AppSettings.DelayKey]);
            var          userAgent = ConfigurationManager.AppSettings[Constants.AppSettings.UserAgentKey];

            logger.Log("Reading Files...");
            var csvOperation   = new CSVOperations();
            var siteMapDetails = csvOperation.ReadFile(Constants.SiteMapSheet, siteMapFileName, siteMapSheetName).Cast <SiteMapReport>().ToList();

            SecurityPrincipal.UserMappingList = csvOperation.ReadFile(Constants.UserMappingSheet, userMappingFileName, userMappingSheetName).Cast <UserMappingReport>().ToList();

            if (siteMapDetails != null)
            {
                SecureString sourcePassword = GetSecureString(Constants.PasswordMessageSource);
                SecureString targetPassword = GetSecureString(Constants.PasswordMessageTarget);
                Object       lockObj        = new Object();

                //Stopwatch watch = new Stopwatch();
                //watch.Start();

                List <ModernWeb> websList = new List <ModernWeb>();
                logger.Log("Processing read sites from CSV");

                foreach (var siteMap in siteMapDetails)
                {
                    logger.Log("Reading " + siteMap.SourceSiteUrl);


                    var modernWeb = new ModernWeb
                    {
                        SourceSiteUrl  = siteMap.SourceSiteUrl,
                        TargetSiteUrl  = siteMap.TargetSiteUrl,
                        SourceUserName = siteMap.SourceUser,
                        TargetUserName = siteMap.TargetUser,
                        SourcePassword = sourcePassword,
                        TargetPassword = targetPassword
                    };

                    WebsOperation websOperation = new WebsOperation(logger, retryCount, delay, userAgent);
                    websOperation.ModernWeb = modernWeb;
                    websOperation.MigrateWebs();
                }

                //watch.Stop();
                logger.Log("Processing complete");
                Console.WriteLine("Processing Complete");
                //Console.WriteLine("Elapsed Time " + watch.Elapsed.ToString());
            }

            Console.ReadLine();
        }
예제 #2
0
        /// <summary>
        /// Defines the entry point of the application.
        /// </summary>
        /// <param name="args">The arguments.</param>
        static void Main(string[] args)
        {
            Console.WriteLine("Please enter the user name.");
            string userName = Console.ReadLine(); //ConfigurationManager.AppSettings["UserName"];

            Console.WriteLine("Please enter the password.");
            string txtPassword = Console.ReadLine(); //ConfigurationManager.AppSettings["Password"];

            string webUrl               = ConfigurationManager.AppSettings["WebUrl"];
            string groupExportPath      = ConfigurationManager.AppSettings["GroupExportPath"];
            string groupExportSheetName = ConfigurationManager.AppSettings["GroupExportSheetName"];

            var csvOperation = new CSVOperations();
            var groupDetails = csvOperation.ReadFile("GroupExport", groupExportPath, groupExportSheetName).Cast <GroupExportReport>().ToList();

            if (groupDetails != null)
            {
                foreach (var group in groupDetails)
                {
                    if (!string.IsNullOrEmpty(group.Id))
                    {
                        Console.WriteLine("Processing " + group.DisplayName);
                        var             Id = group.Id.Substring(group.DisplayName.Length + 1);
                        ClaimsWebClient wc = new ClaimsWebClient(new Uri(webUrl), userName, txtPassword);
                        var             fileRelativeUrl = Constants.GROUP_STATUS_URL + $"?id={Id}&target=site"; //https://tenantname.sharepoint.com/_layouts/groupstatus.aspx?id=567da1b0-8a75-4405-9553-12e8c30c1234&target=site

                        byte[] response = wc.DownloadData(webUrl + fileRelativeUrl);
                        Console.WriteLine("Processed " + group.DisplayName);
                    }
                }
            }

            Console.WriteLine("Operation Completed Successfully!");

            Console.Read();
        }
예제 #3
0
        static void Main(string[] args)
        {
            IAsyncLogger  logger             = O365GroupsFactory.GetLogger(new string[] { Constants.AppSettings.LoggerInstanceKey }) as IAsyncLogger;
            var           siteMapFileName    = ConfigurationManager.AppSettings[Constants.AppSettings.UserExportSiteMapKey];
            var           siteMapSheetName   = ConfigurationManager.AppSettings[Constants.AppSettings.SiteMapSheetKey];
            var           retryCount         = int.Parse(ConfigurationManager.AppSettings[Constants.AppSettings.RetryCountKey]);
            var           delay              = int.Parse(ConfigurationManager.AppSettings[Constants.AppSettings.DelayKey]);
            var           userAgent          = ConfigurationManager.AppSettings[Constants.AppSettings.UserAgentKey];
            List <string> completedSitesList = new List <string>();
            List <string> erroredSitesList   = new List <string>();

            ConsoleOperations.WriteToConsole("Reading Files...", ConsoleColor.White);
            var csvOperation   = new CSVOperations();
            var siteMapDetails = csvOperation.ReadFile(Constants.AppSettings.UserExportSiteMapKey, siteMapFileName, siteMapSheetName).Cast <UserExportSiteMapReport>().ToList();

            if (siteMapDetails != null)
            {
                SecureString sourcePassword = GetSecureString(Constants.PasswordMessageSource);
                //Stopwatch watch = new Stopwatch();
                //watch.Start();

                List <WebSite> websList = new List <WebSite>();
                ConsoleOperations.WriteToConsole("Processing read sites from CSV", ConsoleColor.White);

                foreach (var siteMap in siteMapDetails)
                {
                    logger.Log("Reading " + siteMap.SourceSiteUrl);


                    var website = new WebSite
                    {
                        SourceSiteUrl  = siteMap.SourceSiteUrl.Trim(),
                        SourceUserName = siteMap.SourceUser.Trim(),
                        SourcePassword = sourcePassword,
                        Delay          = delay,
                        RetryCount     = retryCount,
                        UserAgent      = userAgent
                    };
                    websList.Add(website);
                }

                try
                {
                    WebsUtility websOperation = new WebsUtility(retryCount, delay, userAgent);
                    websOperation.WebSiteList = websList;
                    (completedSitesList, erroredSitesList) = websOperation.ExportUsersList();
                }
                catch (Exception ex)
                {
                    ConsoleOperations.WriteToConsole("Error ocurred: " + ex.Message, ConsoleColor.Red);
                }

                //watch.Stop();
                logger.Log("Processing complete");
                ConsoleOperations.WriteToConsole($"Processing Complete; Total successful site count: {completedSitesList.Count}. The completed list is as follows:", ConsoleColor.Green);
                completedSitesList.ForEach(site =>
                {
                    ConsoleOperations.WriteToConsole(site, ConsoleColor.DarkCyan);
                });

                ConsoleOperations.WriteToConsole("Total Errored sites: " + erroredSitesList.Count, ConsoleColor.Red);
                if (erroredSitesList.Count > 0)
                {
                    ConsoleOperations.WriteToConsole("List: ", ConsoleColor.Red);
                    erroredSitesList.ForEach(site =>
                    {
                        ConsoleOperations.WriteToConsole(site, ConsoleColor.Red);
                    });
                }

                Console.ReadLine();
                //Console.WriteLine("Elapsed Time " + watch.Elapsed.ToString());
            }
        }