Exemplo n.º 1
0
        /// <summary>
        /// Processes the property information
        /// </summary>
        /// <param name="propertyData">The property data.</param>
        /// <param name="value">The value.</param>
        /// <param name="action">The action being executed.</param>
        /// <returns>
        /// The parsed property value
        /// </returns>
        public override object Process(object propertyData, string value, BaseAction action)
        {
            var data = propertyData as PropertyData;

            if (data != null)
            {
                data.IsValueChanged = true;
                data.Values = new ValueData[1];
                data.Values[0] = new ValueData();
                data.Values[0].Value = value;

                return data;
            }

            return value;
        }
Exemplo n.º 2
0
        /// <summary>
        /// Executes the business logic
        /// </summary>
        /// <param name="logger">The logger.</param>
        public override void Run(BaseAction parentAction, DateTime CurrentTime, LogHelper logger)
        {
            if (parentAction != null)
            {
                this.Properties = parentAction.Properties;
            }

            CsvProcessor csvProcessor = new CsvProcessor();

            string[] csvFiles = Directory.GetFiles(this.CSVDirectoryLocation, "*.csv", SearchOption.TopDirectoryOnly);

            logger.LogVerbose(string.Format("Attempting to get files from directory 'location' {0}. Number of files found {1}", this.CSVDirectoryLocation, csvFiles.Length));

            foreach (string csvFile in csvFiles)
            {
                logger.LogVerbose(string.Format("Attempting to read CSV file '{0}' from location {1}", csvFile, this.CSVDirectoryLocation));

                logger.LogVerbose(string.Format("Pausing the utility for '{0}' seconds so ASMX service is not overloaded", this.SleepPeriod));

                Thread.Sleep(this.SleepPeriod * 1000);

                using (StreamReader reader = new StreamReader(csvFile))
                {
                    logger.LogVerbose(string.Format("Establishing connection with tenant at '{0}'", this.TenantSiteUrl));

                    using (ClientContext context = new ClientContext(this.TenantSiteUrl))
                    {
                        Uri site = new Uri(this.TenantSiteUrl);

                        try
                        {
                            UserProfileService.UserProfileService profileService = new UserProfileService.UserProfileService(site.ToString() + ProfileService);
                            this.profileService = profileService;
                            profileService.UseDefaultCredentials = false;

                            using (SecureString password = new SecureString())
                            {
                                foreach (char c in this.TenantAdminPassword.ToCharArray())
                                {
                                    password.AppendChar(c);
                                }

                                logger.LogVerbose(string.Format("Attempting to authenticate against tenant with user name '{1}'", this.TenantSiteUrl, this.TenantAdminUserName));

                                var crudentials = new SharePointOnlineCredentials(this.TenantAdminUserName, password);

                                string cookie = crudentials.GetAuthenticationCookie(site);

                                profileService.CookieContainer = new CookieContainer();
                                profileService.CookieContainer.Add(new Cookie(FedAuthCookieName, cookie.TrimStart(SPOIDCookieValue.ToCharArray()), string.Empty, site.Authority));
                                csvProcessor.Execute(reader, (entries, y) => { IterateCollection(context, entries, logger); }, logger);
                            }
                        }
                        finally
                        {
                            if (this.profileService != null)
                            {
                                this.profileService.Dispose();
                            }
                        }
                    }
                }

                // Clean up current CSV file
                System.IO.File.Delete(csvFile);
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Executes the business logic
        /// </summary>
        /// <param name="logger">The logger.</param>
        public override void Run(BaseAction parentAction, DateTime CurrentTime, LogHelper logger)
        {
            CsvProcessor csvProcessor = new CsvProcessor();

            logger.LogVerbose(string.Format("Attempting to read mapping CSV file '{0}'", this.UserMappingCSVFile));

            using (StreamReader reader = new StreamReader(this.UserMappingCSVFile))
            {
                csvProcessor.Execute(reader, (entries, y) => { IterateCollection(entries, logger); }, logger);
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Executes the business logic
        /// </summary>
        /// <param name="logger">The logger.</param>
        public virtual void Run(BaseAction parentAction, DateTime CurrentTime, LogHelper logger = null)
        {
            CsvProcessor csvProcessor = new CsvProcessor();

            string[] csvFiles = Directory.GetFiles(this.CSVDirectoryLocation, "*.csv", SearchOption.TopDirectoryOnly);

            foreach (string csvFile in csvFiles)
            {
                using (StreamReader reader = new StreamReader(csvFile))
                {
                    using (ClientContext context = new ClientContext(this.TenantSiteUrl))
                    {
                        using (SecureString password = new SecureString())
                        {
                            foreach (char c in this.TenantAdminPassword.ToCharArray())
                            {
                                password.AppendChar(c);
                            }

                            context.Credentials = new SharePointOnlineCredentials(this.TenantAdminUserName, password);
                        }

                        csvProcessor.Execute(reader, (entries, y) => { IterateCollection(context, entries, logger); }, logger);
                    }
                }
            }
        }
Exemplo n.º 5
0
 /// <summary>
 /// Executes the business logic
 /// </summary>
 /// <param name="logger">The logger.</param>
 public virtual void Run(BaseAction parentAction, DateTime CurrentTime, LogHelper logger = null)
 {
     
 }
Exemplo n.º 6
0
 /// <summary>
 /// Processes the property information
 /// </summary>
 /// <param name="propertyData">The property data.</param>
 /// <param name="value">The value.</param>
 /// <param name="action">The action being executed.</param>
 /// <returns>The parsed property value</returns>
 public virtual object Process(object propertyData, string value, BaseAction action)
 {
     return value;
 }