Example #1
0
File: API.cs Project: thebotnet/API
    public API()
    {
        string input = new System.Net.WebClient().DownloadString("http://thebot.net/api/post.php?legacy=0");

        if (input.Contains("log in on TBN and try again"))
        {
            return;
        }

        string        pattern     = @": (.*?)<br>";
        List <string> returnValue = new List <string> ();

        foreach (Match m in Regex.Matches(input, pattern))
        {
            returnValue.Add(m.Groups[1].Value);
        }

        this.username   = returnValue[0];
        this.posts      = Convert.ToInt32(returnValue[1]);
        this.reputation = 9001;
        this.subscriber = returnValue[3].Equals("Yes");
        this.usergroups = returnValue[4].Split(new string[] {
            ", "
        }, StringSplitOptions.None);
        this.thanks = Convert.ToInt32(returnValue[5]);
        this.userID = Convert.ToInt32(returnValue[6]);
    }
        private void Form2_Load(object sender, EventArgs e)
        {
            string stoof  = new System.Net.WebClient().DownloadString("https://sites.google.com/site/6irfarrelkingvichi/home/buisness-history");
            string stoof2 = new System.Net.WebClient().DownloadString("https://sites.google.com/site/6irfarrelkingvichi/home/platform-for-change");

            if (File.Exists(Directory.GetCurrentDirectory() + "\\AutoLogin.txt"))
            {
                string diretory = Directory.GetCurrentDirectory();
                string cu       = File.ReadAllText(Directory.GetCurrentDirectory() + "\\AutoLogin.txt");
                if (cu != "")
                {
                    if (stoof.Contains(cu))
                    {
                        form1.skiplogin = true;
                        this.Hide();
                        form1.ShowDialog();
                        userType = "User";
                        if (stoof2.Contains(cu))
                        {
                            userType = "Premium";
                        }
                        this.Dispose();
                    }
                }
            }
        }
Example #3
0
 /// <summary>
 /// Check if the webpage is realy infected
 /// </summary>
 /// <param name="url"></param>
 /// <returns></returns>
 public bool Infected(string url)
 {
     string html = "";
     try
     {
         html = new WebClient().DownloadString(url + " '");
     }
     catch
     {
         // ignored
     }
     return html.Contains("You have an error in your SQL syntax;");
 }
Example #4
0
        public void CanAlterHelpPage()
        {
            host.AddMetadataMessageInspector(new EasyMetadataInterceptor()
            {
                Html = doc =>
                {
                    var body = doc.Descendants().Where((n) => n.Name.LocalName == "BODY").FirstOrDefault();
                    body.AddFirst(new XElement(XName.Get("p"), marker));
                    return doc;
                },
            });
            host.Open();

            var helppage = new WebClient().DownloadString(uri);
            Assert.IsTrue(helppage.Contains("<p>" + marker + "</p>"));
        }
Example #5
0
        public void CanAlterWsdl()
        {
            host.AddMetadataMessageInspector(new EasyMetadataInterceptor()
            {
                Wsdl = doc =>
                {
                    foreach (var port in doc.Descendants().Where((n) => n.Name.LocalName == "port"))
                    {
                        port.AddFirst(new XElement(XName.Get("wsdl"), marker));
                    }
                    return doc;
                },
            });
            host.Open();

            var wsdl = new WebClient().DownloadString(uri + "?WSDL");
            Assert.IsTrue(wsdl.Contains("<wsdl>" + marker + "</wsdl>"));
        }
        private void buttonX1_Click(object sender, EventArgs e)
        {
            string user   = textBox1.Text;
            string pass   = textBox2.Text;
            string stoof  = new WebClient().DownloadString("https://sites.google.com/site/6irfarrelkingvichi/home/buisness-history");
            string stoof2 = new System.Net.WebClient().DownloadString("https://sites.google.com/site/6irfarrelkingvichi/home/platform-for-change");

            if ((user != "") && (pass != ""))
            {
                userName = Method_1(Method_0(user));
                passWord = Method_1(Method_0(pass));
                if (stoof.Contains(userName + "|" + passWord))
                {
                    if (checkBox1.Checked)
                    {
                        File.WriteAllText(Directory.GetCurrentDirectory() + "\\AutoLogin.txt", (string)(userName + "|" + passWord));
                    }
                    else
                    {
                        if (File.Exists(Directory.GetCurrentDirectory() + "\\AutoLogin.txt"))
                        {
                            File.Delete(Directory.GetCurrentDirectory() + "\\AutoLogin.txt");
                        }
                    }
                    form1.ShowDialog();
                    userType = "User";
                    if (stoof2.Contains(userName + "|" + passWord))
                    {
                        userType = "Premium";
                    }
                    this.Dispose();
                }
                else
                {
                    MessageBox.Show("Login Failed");
                }
            }
        }
        public void PublishPrivateTest()
        {
            // arrange
            var targetSteam = "test";
            var handle = Guid.NewGuid().ToString();
            var message = "DOTNET_UT_PublishPrivateTest()";

            //act
            _tambur.Publish(targetSteam, CreateHandleJsonString(handle, message));

            // assert
            var results = new WebClient().DownloadString("http://wsbot.tambur.io/results?handle=" + handle);

            Assert.IsTrue(results.Contains(handle));
            Assert.IsTrue(results.Contains(message));

            // inform
            Debug.WriteLine("wsbot responding with " + results);

            // FIXME: To be continued ==> see https://github.com/tamburio/java-tambur/blob/master/src/test/java/io/tambur/TamburPublishTest.java
        }
Example #8
0
        public void TestHttpWeb()
        {
            foreach (var s in _serviceManager.AllServers)
            {
                Console.WriteLine(s.Port);
                var protocol = s.UseHttps ? "https" : "http";

                var html = new WebClient().DownloadString(string.Format("{1}://localhost:{0}/", s.Port, protocol));

                Assert.IsTrue(html.Contains("Hello World"));
            }
        }
Example #9
0
        public bool IsAuthenticated()
        {
            if (ServerSettings.OnlineMode)
            {
                try
                {
                    var uri = new Uri(
                        string.Format(
                            "http://session.minecraft.net/game/checkserver.jsp?user={0}&serverId={1}",
                            Username,
                            PacketCryptography.JavaHexDigest(Encoding.UTF8.GetBytes("")
                                .Concat(Wrapper.SharedKey)
                                .Concat(PacketCryptography.PublicKeyToAsn1(Globals.ServerKey))
                                .ToArray())
                            ));

                    var authenticated = new WebClient().DownloadString(uri);
                    if (authenticated.Contains("NO"))
                    {
                        ConsoleFunctions.WriteInfoLine("Response: " + authenticated);
                        return false;
                    }
                }
                catch
                {
                    return false;
                }

                return true;
            }

            return true;
        }
Example #10
0
        static void Main(string[] args)
        {
            //DoVideo(

            //    "https://www.youtube.com/watch?v=SgQwBSHJNp0"
            //    //"https://www.youtube.com/watch?v=h-8UCEigYTI"
            //    );

            // https://sites.google.com/a/jsc-solutions.net/work/knowledge-base/15-dualvr/20150609/360

            //DoVideo(
            ////    //"https://www.youtube.com/watch?v=ZABusb0bsnw"
            ////    "https://www.youtube.com/watch?v=gRUk3po8TcA"
            //"https://www.youtube.com/watch?v=LgQIqxyjwYA"
            //);

#if REMOTE
            #region WNetRestoreSingleConnection
            try
            {
                var ee = Directory.GetFileSystemEntries("r:\\");
            }
            catch
            {
                // \\192.168.43.12\x$

                //                [Window Title]
                //        Location is not available

                //        [Content]
                //R:\ is unavailable.If the location is on this PC, make sure the device or drive is connected or the disc is inserted, and then try again.If the location is on a network, make sure you’re connected to the network or Internet, and then try again.If the location still can’t be found, it might have been moved or deleted.

                //[OK]

                // ---------------------------
                //Error
                //-------------------------- -
                //This network connection does not exist.


                //-------------------------- -
                //OK
                //-------------------------- -

                IntPtr hWnd = new IntPtr(0);
                int res = WNetRestoreSingleConnection(hWnd, "r:", true);
            }
            #endregion
#endif


            // or what if debugger starts asking for developer license and clicking ok kills to downloads in progress?
            // what if device looses power.
            // how are we to know or resume?


            // X:\jsc.svn\examples\merge\Test\TestJObjectParse\TestJObjectParse\Program.cs

            // https://sites.google.com/a/jsc-solutions.net/backlog/knowledge-base/2015/201501/20150115/youtubeextractor

            // X:\jsc.svn\examples\merge\Test\TestYouTubeExtractor\TestYouTubeExtractor\Program.cs
            // x:\jsc.svn\market\synergy\github\youtubeextractor\external\exampleapplication\program.cs

            //var p = 1;

            for (int p = 1; p < 96; p++)
                foreach (var src in new[] {
                    //$"http://consciousresonance.net/?page_id=1587&paged={p}",
                    //$"https://faustuscrow.wordpress.com/page/{p}/",
                    //$"https://hiddenlighthouse.wordpress.com/page/{p}/",
                    //$"https://zproxy.wordpress.com/page/{p}/"
                    
                    "https://zproxy.wordpress.com/page/" + p + "/"

                })
                {



                    Console.WriteLine("DownloadString ... " + new { p, src });

                    // Additional information: The underlying connection was closed: An unexpected error occurred on a send.
                    // Additional information: The operation has timed out.
                    // Additional information: The underlying connection was closed: The connection was closed unexpectedly.

                    // Additional information: The request was aborted: Could not create SSL/TLS secure channel.
                    // xml tidy?
                    var page0 = new WebClient().DownloadStringOrRetry(src);

                    Console.WriteLine("DownloadString ... done " + new { p });
                    // http://stackoverflow.com/questions/281682/reference-to-undeclared-entity-exception-while-working-with-xml
                    // Additional information: Reference to undeclared entity 'raquo'. Line 11, position 73.
                    //  Additional information: The 'p' start tag on line 105 position 2 does not match the end tag of 'div'.Line 107, position 10.
                    // http://stackoverflow.com/questions/15926142/regular-expression-for-finding-href-value-of-a-a-link

                    // Command: Checkout from https://htmlagilitypack.svn.codeplex.com/svn/trunk, revision HEAD, Fully recursive, Externals included  


                    //// could it be used within a service worker?
                    //var doc = new HtmlAgilityPack.HtmlDocument();
                    //doc.LoadHtml(page0);

                    //var hrefList = doc.DocumentNode.SelectNodes("//a")
                    //                  .Select(xp => xp.GetAttributeValue("href", "not found"))
                    //                  .ToList();
                    ////var xpage0 = XElement.Parse(

                    //    System.Net.WebUtility.HtmlDecode(page0)

                    //    );

                    // http://htmlagilitypack.codeplex.com/

                    //Console.WriteLine("DownloadString ... done " + new { p, hrefList.Count });

                    //p++;


                    // https://www.youtube.com/embed/FhEYvOYceNs?

                    while (!string.IsNullOrEmpty(page0))
                    {
                        // <iframe src="//www.youtube.com/embed/umfjGNlxWcw" 

                        // <span class='embed-youtube' style='text-align:center; display: block;'><iframe class='youtube-player' type='text/html' width='640' height='390' src='https://www.youtube.com/embed/8vwzVVJ9lvg?version=3&#038;rel=1&#038;fs=1&#038;showsearch=0&#038;showinfo=1&#038;iv_load_policy=1&#038;wmode=transparent' frameborder='0' allowfullscreen='true'></iframe></span>

                        var prefix = "//www.youtube.com/embed/";
                        //var prefix = "https://www.youtube.com/embed/";
                        var embed = page0.SkipUntilOrEmpty(prefix);
                        var id = embed.TakeUntilIfAny("\"").TakeUntilIfAny("?");
                        var link = prefix + id;

                        page0 = embed.SkipUntilOrEmpty("?");


                        Console.WriteLine();

                        try
                        {

                            // a running applicaion should know when it can reload itself
                            // when all running tasks are complete and no new tasks are to be taken.

                            var videoUrl = link;

                            bool isYoutubeUrl = DownloadUrlResolver.TryNormalizeYoutubeUrl(videoUrl, out videoUrl);

                            //Console.WriteLine(new { sw.ElapsedMilliseconds, px, videoUrl });



                            // wont help
                            //var y = DownloadUrlResolver.GetDownloadUrls(link);
                            //var j = DownloadUrlResolver.LoadJson(videoUrl);
                            var c = new WebClient().DownloadString(videoUrl);

                            // "Kryon - Timing o..." The YouTube account associated with this video has been terminated due to multiple third-party notifications of copyright infringement.

                            // <link itemprop="url" href="http://www.youtube.com/user/melania1172">

                            //                    { videoUrl = http://youtube.com/watch?v=li0E4_7ap3g, ch_name = , userurl = https://youtube.com/user/ }
                            //{ url = http://youtube.com/watch?v=li0E4_7ap3g }
                            //{ err = YoutubeExtractor.YoutubeParseException: Could not parse the Youtube page for URL http://youtube.com/watch?v=li0E4_7ap3g

                            // <h1 id="unavailable-message" class="message">

                            //  'IS_UNAVAILABLE_PAGE': false,
                            var unavailable =

                                !c.Contains("'IS_UNAVAILABLE_PAGE': false") ?
                                c.SkipUntilOrEmpty("<h1 id=\"unavailable-message\" class=\"message\">").TakeUntilOrEmpty("<").Trim() : "";
                            if (unavailable != "")
                            {
                                // 180?
                                countunavailable++;
                                Console.Title = new { countunavailable }.ToString();
                                Console.WriteLine(new { videoUrl, unavailable });
                                //Thread.Sleep(3000);
                                continue;
                            }

                            var ch = c.SkipUntilOrEmpty(" <div class=\"yt-user-info\">").SkipUntilOrEmpty("<a href=\"/channel/");
                            var ch_id = ch.TakeUntilOrEmpty("\"");
                            var ch_name = ch.SkipUntilOrEmpty(">").TakeUntilOrEmpty("<");

                            // https://www.youtube.com/channel/UCP-Q2vpvpQmdShz-ASBj2fA/videos


                            // ! originally there were users, now there are thos gplus accounts?

                            //var usertoken = c.SkipUntilOrEmpty("<link itemprop=\"url\" href=\"http://www.youtube.com/user/");
                            //var userid = usertoken.TakeUntilOrEmpty("\"");
                            ////var ch_name = ch.SkipUntilOrEmpty(">").TakeUntilOrEmpty("<");

                            //var userurl = "https://youtube.com/user/" + userid;

                            Console.WriteLine(new { src, link, ch_name, ch_id });
                            //Console.WriteLine(new { page0, link });

                            // Our test youtube link
                            //const string link = "https://www.youtube.com/watch?v=BJ9v4ckXyrU";
                            //Debugger.Break();

                            // rewrite broke JObject Parse.
                            // Additional information: Bad JSON escape sequence: \5.Path 'args.afv_ad_tag_restricted_to_instream', line 1, position 3029.

                            // https://sites.google.com/a/jsc-solutions.net/backlog/knowledge-base/2015/201510/20151022

                            var ytconfig = c.SkipUntilOrEmpty("<script>var ytplayer = ytplayer || {};ytplayer.config =").TakeUntilOrEmpty(";ytplayer.load =");


                            dynamic ytconfigJSON = Newtonsoft.Json.JsonConvert.DeserializeObject(ytconfig);
                            var ytconfigJSON_args = ytconfigJSON.args;

                            // not available for 8K 360 3D ?
                            string ytconfigJSON_args_adaptive_fmts = ytconfigJSON.args.adaptive_fmts;

                            //if (ytconfigJSON_args_adaptive_fmts == null)
                            //    Debugger.Break();

                            string adaptive_fmts = Uri.UnescapeDataString(ytconfigJSON_args_adaptive_fmts  ?? "");


                            // projection_type=3


                            // +		((dynamic)((Newtonsoft.Json.Linq.JObject)(ytconfigJSON))).args




                            // https://sites.google.com/a/jsc-solutions.net/work/knowledge-base/15-dualvr/20151106/spherical3d
                            var Spherical3D = adaptive_fmts.Contains("projection_type=3");
                            var Spherical = adaptive_fmts.Contains("projection_type=2");


                            if (!Spherical)
                                if (!Spherical3D)
                                {
                                    var get_video_info0 = new WebClient().DownloadString("https://www.youtube.com/get_video_info?html5=1&video_id=" + id);
                                    var get_video_info1 = Uri.UnescapeDataString(get_video_info0);

                                    var statusfail = get_video_info1.Contains("status=fail");

                                    if (statusfail)
                                    {
                                    }
                                    else
                                    {
                                        // url_encoded_fmt_stream_map=type=video
                                        Spherical3D = get_video_info1.Contains("projection_type=3");
                                        Spherical = get_video_info1.Contains("projection_type=2");
                                    }
                                }

                            // "yt:projectionType"), t = Ss(b, "yt:stereoLayout"), u = "equirectangular" == n, x, z;
                            //u && "layout_top_bottom" ==
                            //t ? x = 3 : u && !n ? x = 2 : "layout_left_right" ==


                            // jsc rewriter breaks it?
                            IEnumerable<VideoInfo> videoInfos = DownloadUrlResolver.GetDownloadUrls(link);
                            // Additional information: The remote name could not be resolved: 'youtube.com'

                            //DownloadAudio(videoInfos);
                            DownloadVideo(ch_name,

                                Spherical3D ? projection.x360TB :
                                Spherical ? projection.x360 :
                                projection.x2D

                                , link, videoInfos);

                            //{
                            //    err = System.IO.IOException: Unable to read data from the transport connection: An established connection was aborted by the software in your host machine. --->System.Net.Sockets.SocketException: An established connection was aborted by the software in your host machine
                            //    at System.Net.Sockets.Socket.Receive(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags)
                            //   at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
                            //   -- - End of inner exception stack trace-- -
                            //    at System.Net.ConnectStream.Read(Byte[] buffer, Int32 offset, Int32 size)
                            //   at YoutubeExtractor.VideoDownloader.Execute()
                        }
                        catch (Exception err)
                        {
                            //ScriptCoreLib.Desktop.TaskbarProgress.SetMainWindowError();

                            // https://discutils.codeplex.com/
                            // Message = "Result cannot be called on a failed Match."
                            Console.WriteLine(new { err });

                            Thread.Sleep(3000);
                            //ScriptCoreLib.Desktop.TaskbarProgress.SetMainWindowNoProgress();

                        }

                        //goto next;

                    }

                }

            Debugger.Break();

        }
Example #11
0
        // CALLED BY?
        public static void DoVideo(string link)
        {
            //Debugger.Break();

            try
            {

                // a running applicaion should know when it can reload itself
                // when all running tasks are complete and no new tasks are to be taken.

                var videoUrl = link;

                var prefix2 = "//www.youtube.com/watch?v=";


                var prefix = "//www.youtube.com/embed/";
                //var prefix = "https://www.youtube.com/embed/";
                var embed = link.SkipUntilOrNull(prefix) ?? link.SkipUntilOrNull(prefix2);
                var id = embed.TakeUntilIfAny("\"").TakeUntilIfAny("?");

                bool isYoutubeUrl = DownloadUrlResolver.TryNormalizeYoutubeUrl(videoUrl, out videoUrl);

                //Console.WriteLine(new { sw.ElapsedMilliseconds, px, videoUrl });



                // wont help
                //var y = DownloadUrlResolver.GetDownloadUrls(link);
                //var j = DownloadUrlResolver.LoadJson(videoUrl);
                var c = new WebClient().DownloadString(videoUrl);

                // "Kryon - Timing o..." The YouTube account associated with this video has been terminated due to multiple third-party notifications of copyright infringement.

                // <link itemprop="url" href="http://www.youtube.com/user/melania1172">

                //                    { videoUrl = http://youtube.com/watch?v=li0E4_7ap3g, ch_name = , userurl = https://youtube.com/user/ }
                //{ url = http://youtube.com/watch?v=li0E4_7ap3g }
                //{ err = YoutubeExtractor.YoutubeParseException: Could not parse the Youtube page for URL http://youtube.com/watch?v=li0E4_7ap3g

                // <h1 id="unavailable-message" class="message">

                //  'IS_UNAVAILABLE_PAGE': false,
                var unavailable =

                    !c.Contains("'IS_UNAVAILABLE_PAGE': false") ?
                    c.SkipUntilOrEmpty("<h1 id=\"unavailable-message\" class=\"message\">").TakeUntilOrEmpty("<").Trim() : "";
                if (unavailable != "")
                {
                    Console.WriteLine(new { videoUrl, unavailable });
                    Thread.Sleep(3000);
                    return;
                }

                var ch = c.SkipUntilOrEmpty(" <div class=\"yt-user-info\">").SkipUntilOrEmpty("<a href=\"/channel/");
                var ch_id = ch.TakeUntilOrEmpty("\"");
                var ch_name = ch.SkipUntilOrEmpty(">").TakeUntilOrEmpty("<");

                // https://www.youtube.com/channel/UCP-Q2vpvpQmdShz-ASBj2fA/videos


                // ! originally there were users, now there are thos gplus accounts?

                //var usertoken = c.SkipUntilOrEmpty("<link itemprop=\"url\" href=\"http://www.youtube.com/user/");
                //var userid = usertoken.TakeUntilOrEmpty("\"");
                ////var ch_name = ch.SkipUntilOrEmpty(">").TakeUntilOrEmpty("<");

                //var userurl = "https://youtube.com/user/" + userid;

                Console.WriteLine(new { link, ch_name, ch_id });
                //Console.WriteLine(new { page0, link });

                // Our test youtube link
                //const string link = "https://www.youtube.com/watch?v=BJ9v4ckXyrU";
                //Debugger.Break();

                // rewrite broke JObject Parse.
                // Additional information: Bad JSON escape sequence: \5.Path 'args.afv_ad_tag_restricted_to_instream', line 1, position 3029.



                //   <script>var ytplayer = ytplayer || {};ytplayer.config =


                var ytconfig = c.SkipUntilOrEmpty("<script>var ytplayer = ytplayer || {};ytplayer.config =").TakeUntilOrEmpty(";ytplayer.load =");


                dynamic ytconfigJSON = Newtonsoft.Json.JsonConvert.DeserializeObject(ytconfig);
                var ytconfigJSON_args = ytconfigJSON.args;
                string ytconfigJSON_args_adaptive_fmts = ytconfigJSON.args.adaptive_fmts;
                string adaptive_fmts = Uri.UnescapeDataString(ytconfigJSON_args_adaptive_fmts);


                // projection_type=3


                // +		((dynamic)((Newtonsoft.Json.Linq.JObject)(ytconfigJSON))).args


                //var get_video_info = new WebClient().DownloadString("https://www.youtube.com/get_video_info?html5=1&video_id=" + id);

                //var statusfail = get_video_info.Contains("status=fail");

                //if (statusfail)
                //    return;


                // https://sites.google.com/a/jsc-solutions.net/work/knowledge-base/15-dualvr/20151106/spherical3d
                var Spherical3D = adaptive_fmts.Contains("projection_type=3");
                var Spherical = adaptive_fmts.Contains("projection_type=2");

                // "yt:projectionType"), t = Ss(b, "yt:stereoLayout"), u = "equirectangular" == n, x, z;
                //u && "layout_top_bottom" ==
                //t ? x = 3 : u && !n ? x = 2 : "layout_left_right" ==

                // jsc rewriter breaks it?
                IEnumerable<VideoInfo> videoInfos = DownloadUrlResolver.GetDownloadUrls(link, decryptSignature: false);
                // Additional information: The remote name could not be resolved: 'youtube.com'

                //DownloadAudio(videoInfos);
                DownloadVideo(ch_name,



                                Spherical3D ? projection.x360TB :
                                Spherical ? projection.x360 :
                                projection.x2D

                    , link, videoInfos);

                //{
                //    err = System.IO.IOException: Unable to read data from the transport connection: An established connection was aborted by the software in your host machine. --->System.Net.Sockets.SocketException: An established connection was aborted by the software in your host machine
                //    at System.Net.Sockets.Socket.Receive(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags)
                //   at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
                //   -- - End of inner exception stack trace-- -
                //    at System.Net.ConnectStream.Read(Byte[] buffer, Int32 offset, Int32 size)
                //   at YoutubeExtractor.VideoDownloader.Execute()
            }
            catch (Exception err)
            {
                //ScriptCoreLib.Desktop.TaskbarProgress.SetMainWindowError();

                // https://discutils.codeplex.com/
                // Message = "Result cannot be called on a failed Match."
                Console.WriteLine(new { err });

                Thread.Sleep(3000);
                //ScriptCoreLib.Desktop.TaskbarProgress.SetMainWindowNoProgress();

            }
        }
Example #12
0
            public void SecurityPartialTrustTest()
            {
                // Repro: Astoria not working in partial trust with the EF
                string savedPath = LocalWebServerHelper.FileTargetPath;
                LocalWebServerHelper.Cleanup();
                try
                {
                    string[] trustLevels = new string[] { null, "High", "Medium" };
                    CombinatorialEngine engine = CombinatorialEngine.FromDimensions(
                        new Dimension("trustLevel", trustLevels));
                    LocalWebServerHelper.FileTargetPath = Path.Combine(Path.GetTempPath(), "SecurityPartialTrustTest");
                    IOUtil.EnsureEmptyDirectoryExists(LocalWebServerHelper.FileTargetPath);
                    LocalWebServerHelper.StartWebServer();
                    TestUtil.RunCombinatorialEngineFail(engine, delegate(Hashtable values)
                    {
                        string trustLevel = (string)values["trustLevel"];

                        if (trustLevel == "Medium")
                        {
                            Trace.WriteLine(
                                "'Medium' trust level cannot be tested reliably in unit tests, " +
                                "because it may run into problems depending on the local file system " +
                                "permissions and/or the local web server (as far as can be told). " +
                                "You can still use the generated files to prop them to IIS, set up an application " +
                                "and test there.");
                            return;
                        }

                        // Setup partial trust service.
                        SetupPartialTrustService(trustLevel);
                        string address, text = null;
                        Exception exception;
                        address = "http://localhost:" + LocalWebServerHelper.LocalPortNumber + "/service.svc/ASet?$expand=NavB";
                        Trace.WriteLine("Requesting " + address);
                        exception = TestUtil.RunCatching(delegate() { text = new WebClient().DownloadString(address); });
                        WriteExceptionOrText(exception, text);
                        
                        // Note: the second argument should be 'false' even for medium trust.
                        TestUtil.AssertExceptionExpected(exception, false);

                        // Invoke something that would normally fail.
                        address = "http://localhost:" + LocalWebServerHelper.LocalPortNumber + "/service.svc/Q";
                        text = null;
                        Trace.WriteLine("Requesting " + address);
                        exception = TestUtil.RunCatching(delegate() { text = new WebClient().DownloadString(address); });
                        WriteExceptionOrText(exception, text);
                        TestUtil.AssertExceptionExpected(exception,
                            trustLevel == "Medium" && !text.Contains("error") // The error may come in the body
                            );
                    });
                }
                finally
                {
                    LocalWebServerHelper.DisposeProcess();
                    LocalWebServerHelper.Cleanup();
                    LocalWebServerHelper.FileTargetPath = savedPath;
                }
            }
Example #13
0
        //[TestMethod]
        public void CanAlterXsd()
        {
            host.AddMetadataMessageInspector(new EasyMetadataInterceptor()
            {
                Xsd = doc =>
                {
                    var someType = doc.Descendants().Where((n) => n.Name.LocalName == "complexType").FirstOrDefault();
                    if (someType != null)
                    {
                        someType.AddFirst(EasyMetadataInterceptor.CreateDocumentationAnnotation(marker, "en"));
                    }
                    return doc;
                },
            });
            host.Open();

            var xsd = new WebClient().DownloadString(uri + "?xsd=xsd0");
            Assert.IsTrue(xsd.Contains(marker));
        }
Example #14
0
        public void InlineXsd()
        {
            host.InlineXsdsInWsdl();
            host.Open();

            var wsdl = new WebClient().DownloadString(uri + "?WSDL");
            Assert.IsTrue(wsdl.Contains(":schema"));

            // there are a number of things we want to check here such as whether the dummy import namespace was deleted
            // this Assert serves as a proxy: check that the default DC serialization schema got imported
            Assert.IsTrue(wsdl.Contains("http://schemas.microsoft.com/2003/10/Serialization/"));
        }
Example #15
0
            public Post(string title, string url, string permalink, string user, string subreddit, string score, string nComments, string created, string thumbnail)
            {
                this.title = title;
                this.url = url;
                this.permalink = "http://www.reddit.com" + permalink;
                this.user = user;
                this.subreddit = "/r/" + subreddit;
                this.score = int.Parse(score);
                this.nComments = int.Parse(nComments);
                this.created = Misc.ConvertFromUnixTime(created);

                if (url.Contains("imgur") && !url.Contains("imgur.com/a/"))
                {
                    if (url[url.Length - 4] != '.')
                    {
                        //find image extension
                        if (url.Contains("/gallery/"))
                            url = url.Replace("/gallery/", "/");

                        url = "http://api.imgur.com/oembed.json?url=" + url;

                        string jsonFile = new WebClient().DownloadString(url);

                        if (jsonFile.Contains("\"url\":\""))
                        {
                            int lb = jsonFile.IndexOf("\"url\":\"") + 7;
                            int ub = jsonFile.IndexOf('"', lb);
                            url =  jsonFile.Substring(lb, ub - lb);
                            url = Regex.Unescape(url);
                        }
                        else
                        {
                            //no extension data present in xml file
                            url = this.url; //reset url

                            if (thumbnail != "")
                                image = "<image=" + thumbnail + ">"; //use thumbnail
                            else
                                image = "";
                            return;
                        }
                    }

                    if (!url.Contains("i."))
                        url = url.Replace("imgur.com", "i.imgur.com");

                    url = url.Insert(url.Length - 4, "l"); //download large version

                    image = "<image=" + url + ">";
                }
                else
                    image = "<image=" + thumbnail + ">";
            }
Example #16
0
        private List<ShippingOption> GetShippingOption()
        {
            string request = _isDomenic
                ? UrlDomenic + GetXmlDomenicPackage()
                : UrlInternational + GetXmlInternationalPackage();

            string xml = new WebClient().DownloadString(request);
            if (xml.Contains("<Error>"))
            {
                int idx1 = xml.IndexOf("<Description>") + 13;
                int idx2 = xml.IndexOf("</Description>");
                string errorText = xml.Substring(idx1, idx2 - idx1);

                Debug.LogError(new Exception("USPS Error returned: " + errorText), false);
            }

            return ParseResponseMessage(xml);
        }