Ejemplo n.º 1
0
        private ClientContext GetClientContext(DeploymentSite site)
        {
            var context = new ClientContext(site.Url);

            if (_credentialConfiguration == null || !_credentialConfiguration.FromChromeCookies)
            {
                var username = string.IsNullOrEmpty(_credentialConfiguration?.Username) ? site.Username : _credentialConfiguration?.Username;
                var password = string.IsNullOrEmpty(_credentialConfiguration?.Password) ? site.Password : _credentialConfiguration?.Password;

                if (string.IsNullOrEmpty(username))
                {
                    Console.ResetColor();
                    Console.WriteLine("Please enter username for {0}", site.Url);
                    username = Console.ReadLine();
                }
                if (string.IsNullOrEmpty(password))
                {
                    Console.ResetColor();
                    Console.WriteLine("Please enter password for user {0} and site {1}", username, site.Url);
                    ConsoleKeyInfo key;
                    string         pw = "";
                    do
                    {
                        key = Console.ReadKey(true);
                        if (key.Key != ConsoleKey.Enter)
                        {
                            pw += key.KeyChar;
                        }
                        Console.Write("*");
                    }while (key.Key != ConsoleKey.Enter);
                    Console.WriteLine();
                    password = pw;
                }

                if (site.Url.ToUpper().Contains("SHAREPOINT.COM"))
                {
                    var securePassword = new SecureString();
                    foreach (char c in password)
                    {
                        securePassword.AppendChar(c);
                    }
                    context.Credentials = new SharePointOnlineCredentials(username, securePassword);
                }
                else
                {
                    context.Credentials = new System.Net.NetworkCredential(username, password);
                }
            }
            context.ExecutingWebRequest += (sender, e) =>
            {
                if (_credentialConfiguration != null && _credentialConfiguration.FromChromeCookies)
                {
                    e.WebRequestExecutor.WebRequest.CookieContainer = CookieStore.GetCookieContainer(new Uri(site.Url));
                }
                e.WebRequestExecutor.WebRequest.PreAuthenticate = true;
            };
            return(context);
        }
Ejemplo n.º 2
0
        private void RegisterWatchTask(DeploymentSite site)
        {
            var fsWatcher = new List <FileSystemWatcher>();

            foreach (var fileConfig in site.Files)
            {
                var fs = new FileSystemWatcher(fileConfig.Source);
                fs.IncludeSubdirectories = true;
                fs.NotifyFilter          = NotifyFilters.LastWrite | NotifyFilters.FileName;
                fs.Changed            += fs_Changed;
                fs.Renamed            += fs_Changed; // Visual Studio creates a temp file and then rename it on save
                fs.EnableRaisingEvents = true;
                _watcherCache.Add(fs);

                var fullDirName = new DirectoryInfo(fileConfig.Source).FullName.ToUpperInvariant();
                _registeredSources.Add(fullDirName, new Tuple <DeploymentSite, DeploymentFile>(site, fileConfig));
            }
        }
Ejemplo n.º 3
0
 private ClientContext GetClientContext(DeploymentSite site)
 {
     var context = new ClientContext(site.Url);
     if (string.IsNullOrEmpty(site.Username))
     {
         Console.ResetColor();
         Console.WriteLine("Please enter username for {0}", site.Url);
         site.Username = Console.ReadLine();
     }
     if (string.IsNullOrEmpty(site.Password))
     {
         Console.ResetColor();
         Console.WriteLine("Please enter password for user {0} and site {1}", site.Username, site.Url);
         ConsoleKeyInfo key;
         string password = "";
         do
         {
             key = Console.ReadKey(true);
             if (key.Key != ConsoleKey.Enter)
                 password += key.KeyChar;
             Console.Write("*");
         }
         while (key.Key != ConsoleKey.Enter);
         Console.WriteLine();
         site.Password = password;
     }
     if (site.Url.ToUpper().Contains("SHAREPOINT.COM"))
     {
         var securePassword = new SecureString();
         foreach (char c in site.Password) securePassword.AppendChar(c);
         context.Credentials = new SharePointOnlineCredentials(site.Username, securePassword);
     }
     else
     {
         context.Credentials = new System.Net.NetworkCredential(site.Username, site.Password);
     }
     context.ExecutingWebRequest += (sender, e) => { e.WebRequestExecutor.WebRequest.PreAuthenticate = true; };
     return context;
 }
Ejemplo n.º 4
0
        private void RegisterWatchTask(DeploymentSite site)
        {
            var fsWatcher = new List<FileSystemWatcher>();
            foreach (var fileConfig in site.Files)
            {
                var fs = new FileSystemWatcher(fileConfig.Source);
                fs.IncludeSubdirectories = true;
                fs.NotifyFilter = NotifyFilters.LastWrite | NotifyFilters.FileName;
                fs.Changed += fs_Changed;
                fs.Renamed += fs_Changed; // Visual Studio creates a temp file and then rename it on save
                fs.EnableRaisingEvents = true;
                _watcherCache.Add(fs);

                var fullDirName = new DirectoryInfo(fileConfig.Source).FullName.ToUpperInvariant();
                _registeredSources.Add(fullDirName, new Tuple<DeploymentSite, DeploymentFile>(site, fileConfig));
            }
        }