Exemple #1
0
 static public void Main(string[] args)
 {
     if ((args.Length == 1 && (args[0] == "?" || args[0] == "/?" || args[0] == "-?" || args[0].ToLower() == "help")))
     {
         Console.WriteLine(usage);
     }
     else
     {
         string user = "******", pw = "";
         if (AuthenticationForm.GetCredentials(ref user, ref pw, "Proxy Authentication"))
         {
             Console.Error.WriteLine("{0}:{1}", user, pw);
         }
     }
 }
Exemple #2
0
 static public bool GetCredentials(ref string userName, ref string password, string title)
 {
     using (AuthenticationForm dlg = new AuthenticationForm(userName, password, title))
     {
         if (DialogResult.OK == dlg.ShowDialog())
         {
             userName = dlg.userName;
             password = dlg.password;
             return(true);
         }
         else
         {
             return(false);
         }
     }
 }
Exemple #3
0
 public static bool GetCredentials(ref string userName, ref string password, string title)
 {
     using(AuthenticationForm dlg = new AuthenticationForm(userName, password, title))
     {
         if (DialogResult.OK == dlg.ShowDialog())
         {
             userName = dlg.userName;
             password = dlg.password;
             return true;
         }
         else
         {
             return false;
         }
     }
 }
Exemple #4
0
        static public void Main(string[] args)
        {
            if (args.Length == 1 && (args[0] == "?" || args[0] == "/?" || args[0] == "-?" || args[0].ToLower() == "help"))
            {
                Console.WriteLine("Usage: cscscript update ...\n" +
                                  "Checks for available update on CS-Script home page.\n");
            }
            else
            {
                bool useProxyAuthentication = false;
                while (true)
                {
                    try
                    {
                        string user = null, pw = null;
                        if (useProxyAuthentication)
                        {
                            if (!AuthenticationForm.GetCredentials(ref user, ref pw, "Proxy Authentication"))
                            {
                                return;
                            }
                        }

                        CheckForUpdate(user, pw);
                        return;
                    }
                    catch (Exception e)
                    {
                        if (e is System.Net.WebException && e.Message == "The remote server returned an error: (407) Proxy Authentication Required.")
                        {
                            if (useProxyAuthentication)
                            {
                                Console.WriteLine(e.Message);
                            }

                            useProxyAuthentication = true;
                            continue;
                        }

                        Console.WriteLine(e.Message);
                        return;
                    }
                }
            }
        }
Exemple #5
0
        static public void Main(string[] args)
        {
            if (args.Length == 1 && (args[0] == "?" || args[0] == "/?" || args[0] == "-?" || args[0].ToLower() == "help"))
            {
                Console.WriteLine(usage);
            }
            else
            {
                string userName = Environment.UserName, password = "";
                if (AuthenticationForm.GetCredentials(ref userName, ref password, "Proxy Authentication"))
                {
                    GlobalProxySelection.Select.Credentials = new NetworkCredential(userName, password);
                }

                Console.Write("Please enter string to search google for: ");
                string searchString = HttpUtility.UrlEncode(Console.ReadLine());

                Console.WriteLine();
                Console.Write("Please wait...\r");

                // Query google.
                WebClient webClient = new WebClient();
                byte[]    response  = webClient.DownloadData("http://www.google.com/search?&num=5&q=" + searchString);

                // Check response for results
                string          regex   = "class=r><a\\shref=\"?(?<URL>[^\">]*)[^>]*>(?<Name>.*?)</a>";
                MatchCollection matches = Regex.Matches(Encoding.ASCII.GetString(response), regex);

                // Output results
                Console.WriteLine("===== Results =====");
                if (matches.Count > 0)
                {
                    foreach (Match match in matches)
                    {
                        Console.WriteLine(HttpUtility.HtmlDecode(match.Groups["Name"].Value) + " - " + match.Groups["URL"].Value);
                    }
                }
                else
                {
                    Console.WriteLine("0 results found");
                }
            }
        }
Exemple #6
0
        static public void Main(string[] args)
        {
            System.Net.ServicePointManager.ServerCertificateValidationCallback += (sender, certificate, chain, sslPolicyErrors) => true;
            System.Net.ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3 | SecurityProtocolType.Tls | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12;

            //Debug.Assert(false);
            if (args.Length == 0 || args[0].ToLower() == "-?" || args[0].ToLower() == "/?")
            {
                Console.WriteLine("Usage: cscscript wsdl url file [/opt: [wsdl_option_1]...[wsdl_option_N]] [/new] ...\n" +
                                  "Generates C# code for WebServiceClient.\n  " +
                                  "  url  - Url of a WSDL contract.\n  " +
                                  "  file - The filename for the generated proxy code.\n  " +
                                  "  /opt - list of 'row' wsdl.exe command line options.\n" +
                                  "  /new - Generate C# file only if it does not exist yet.");
            }
            else
            {
                string wsdlExe  = Environment.ExpandEnvironmentVariables(@"%CSSCRIPT_DIR%\lib\tools\wsdl.exe");
                string url      = args[0];
                string csModule = (args[1].EndsWith(".cs") ? args[1] : (args[1] + ".cs"));
                string options  = "";

                foreach (var arg in args)
                {
                    if (arg.ToLower() == "/new" && File.Exists(csModule))
                    {
                        return; //no need to generate proxy file as it already exists
                    }
                    if (arg.StartsWith("/opt:"))
                    {
                        options = arg.Substring("/opt:".Length).Trim();
                    }
                }

                bool useProxyAuthentication = false;

                while (true)
                {
                    try
                    {
                        if (!File.Exists(wsdlExe))
                        {
                            throw new FileNotFoundException("Cannot find " + wsdlExe + " utility.");
                        }

                        string user = null, pw = null;

                        if (useProxyAuthentication)
                        {
                            if (!AuthenticationForm.GetCredentials(ref user, ref pw, "Proxy Authentication"))
                            {
                                return;
                            }
                        }

                        string output = "";

                        if (TestURL(url, user, pw))
                        {
                            csModule = ResolveOutputLocation(csModule);

                            string cmdLine = string.Empty;

                            if (user != null)
                            {
                                cmdLine = "\"/proxyusername:"******"\" \"/proxypassword:"******"\" \"/o:" + csModule + "\" " + url;
                            }

                            else
                            {
                                cmdLine = "\"/o:" + csModule + "\" " + url;
                            }

                            if (options != "")
                            {
                                cmdLine += " \"" + options + "\"";
                            }

                            output = RunApp(wsdlExe, cmdLine);
                        }
                        if (!File.Exists(csModule))
                        {
                            throw new FileNotFoundException("Cannot create " + csModule + " file.");
                        }
                        return;
                    }
                    catch (Exception e)
                    {
                        if (e is System.Net.WebException && e.Message == "The remote server returned an error: (407) Proxy Authentication Required.")
                        {
                            if (useProxyAuthentication)
                            {
                                Console.WriteLine(e.Message);
                            }

                            useProxyAuthentication = true;
                            continue;
                        }
                        throw e;
                    }
                }
            }
        }
Exemple #7
0
        static public void Main(string[] args)
        {
            if (args.Length == 0 || args[0].ToLower() == "-?" || args[0].ToLower() == "/?")
            {
                Console.WriteLine("Usage: cscscript soapsuds url file [/new] ...\nGenerates C# code for WebServiceClient.\n  /new - generate C# file only if it does not exist yet.\n\n" +
                                  "The following sample creates proxy.dll assembly for MyRemotingClass type." +
                                  "  Sample: cscscript soapsuds http://localhost:8080/MyRemotingApp/MyRemotingClass?WSDL proxy " +
                                  "Always check if the remoting service is available with the IE: <url>\n");
            }
            else
            {
                string wsdlExe   = Environment.ExpandEnvironmentVariables(@"%CSSCRIPT_DIR%\lib\tools\soapsuds.exe");
                string url       = args[0];
                string dllModule = (args[1].EndsWith(".dll") ? args[1] : (args[1] + ".dll"));
                dllModule = ResolveAsmLocation(dllModule);

                if (args.Length == 3 && (args[2].ToLower() == "/new" || args[2].ToLower() == "-new" || args[2].ToLower() == "new") && File.Exists(dllModule))
                {
                    return;
                }

                bool useProxyAuthentication = false;
                while (true)
                {
                    try
                    {
                        if (!File.Exists(wsdlExe))
                        {
                            throw new FileNotFoundException("Cannot find " + wsdlExe + " utility.");
                        }

                        string user = null, pw = null;
                        if (useProxyAuthentication)
                        {
                            if (!AuthenticationForm.GetCredentials(ref user, ref pw, "Proxy Authentication"))
                            {
                                return;
                            }
                        }
                        string test = "";
                        if (TestURL(url, user, pw))
                        {
                            if (user != null)
                            {
                                test = RunApp(wsdlExe, "-url:" + url + " \"-oa:" + dllModule + "\" \"-hpn:" + user + "\" \"-hpp:" + pw + "\" \"");
                            }
                            else
                            {
                                test = RunApp(wsdlExe, "-url:" + url + " \"-oa:" + dllModule + "\"");
                            }
                        }
                        if (!File.Exists(dllModule))
                        {
                            throw new FileNotFoundException("Cannot create " + dllModule + " file.");
                        }
                        return;
                    }
                    catch (Exception e)
                    {
                        if (e is System.Net.WebException && e.Message == "The remote server returned an error: (407) Proxy Authentication Required.")
                        {
                            if (useProxyAuthentication)
                            {
                                Console.WriteLine(e.Message);
                            }

                            useProxyAuthentication = true;
                            continue;
                        }
                        throw e;
                    }
                }
            }
        }