<?xml version="1.0" encoding="UTF-8"?><!-- generator="wordpress.com" -->
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	>

<channel>
	<title>webclient &amp;laquo; WordPress.com Tag Feed</title>
	<link>http://en.wordpress.com/tag/webclient/</link>
	<description>Feed of posts on WordPress.com tagged "webclient"</description>
	<pubDate>Mon, 28 Dec 2009 16:54:53 +0000</pubDate>

	<generator>http://en.wordpress.com/tags/</generator>
	<language>en</language>

<item>
<title><![CDATA[Download a file in C#]]></title>
<link>http://tibileo.wordpress.com/2009/10/26/download-a-file-in-c/</link>
<pubDate>Mon, 26 Oct 2009 14:33:45 +0000</pubDate>
<dc:creator>tibileo</dc:creator>
<guid>http://tibileo.wordpress.com/2009/10/26/download-a-file-in-c/</guid>
<description><![CDATA[Easy task ! Import the System.Net namespace and after that use the DownloadFile method of the WebCli]]></description>
<content:encoded><![CDATA[Easy task ! Import the System.Net namespace and after that use the DownloadFile method of the WebCli]]></content:encoded>
</item>
<item>
<title><![CDATA[C# Asynchronous WebClient Requests]]></title>
<link>http://logicbomblabs.wordpress.com/2009/10/07/asynchronous-webclient-requests/</link>
<pubDate>Wed, 07 Oct 2009 19:21:52 +0000</pubDate>
<dc:creator>erzr</dc:creator>
<guid>http://logicbomblabs.wordpress.com/2009/10/07/asynchronous-webclient-requests/</guid>
<description><![CDATA[I think that anyone who has ever done any GUI programming for a day-to-day application that empowers]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>I think that anyone who has ever done any GUI programming for a day-to-day application that empowers people to do their job, regardless of the language or environment, will fully agree with me when I say: &#8220;end-users are never satisfied.&#8221; End-users do not want to click a button and have their GUI freeze up because your application is crunching data on your main program thread. Enter multi-threading. I do not claim to be anything close to an authority on threading (check out <a title="http://www.albahari.com/threading/" href="http://www.albahari.com/threading/" target="_blank">http://www.albahari.com/threading/</a> for everything you&#8217;ll ever need to know about C# threading), but I wanted to at least introduce asynchronous web requests because they definitely enhance the end-user experience. Yeah&#8230; that&#8217;s the story I&#8217;m going with anyway, Elliot has been harassing me to actually post here too.</p>
<p>Asynchronous web requests are terribly easy within the .NET framework, someone at Microsoft has already done all of the footwork for us. They wrapped it all up in a WebClient (<a title="http://msdn.microsoft.com/en-us/library/system.net.webclient(VS.80).aspx" href="http://msdn.microsoft.com/en-us/library/system.net.webclient(VS.80).aspx" target="_blank">http://msdn.microsoft.com/en-us/library/system.net.webclient(VS.80).aspx</a>) object, as well.</p>
<p>Lets get started, only minimal code is required to actually implement an asynchronous call. My intention is just to show how to pull down the HTML of a web page, it can be adapted for a lot of other things. Check out the MSDN link (or just mess around with the AutoComplete within Visual Studio)  to see what else the WebClient object has to offer.</p>
<p>First, you have to instantiate our WebClient object and setup our event handler for when the DownloadDataAsync call is completed. This is different then the Generic DownloadData call which blocks the main thread until the download is completed. Our call will be better because it will allow the user, for example, to click a button and have their data download on a different thread and be able to do things on main gui thread. Waiting sucks. Code for this is:</p>
<pre class="brush: csharp;">
            using (WebClient asyncWebRequest = new WebClient())
            {
                asyncWebRequest.DownloadDataCompleted += asyncWebRequest_DownloadDataCompleted;
                Uri urlToRequest = new Uri(&#34;http://www.google.com/&#34;);
                asyncWebRequest.DownloadDataAsync(urlToRequest);
            }
</pre>
<p>The only thing left is actually the code in the method that the data/error will return to, and handle any exceptional cases.</p>
<pre class="brush: csharp;">
void asyncWebRequest_DownloadDataCompleted(object sender, DownloadDataCompletedEventArgs e)
 {
 if (e.Error != null)
 {
 MessageBox.Show(e.Error.Message);
 return;
 }

 if (e.Result != null &#38;&#38; e.Result.Length &#62; 0)
 {
 string downloadedData = Encoding.Default.GetString(e.Result);
 // do things with data here
 }
 else
 {
 MessageBox.Show(&#34;No data was downloaded.&#34;);
 }

 }
</pre>
<p>In the end, this functionality enhances the end user experience by not locking up their application while doing background work, and also provides you (the programmer) an easy way to download data in the background without dealing with your own thread. Other considerations may be actually promoting the WebClient to a private variable so you can give the user the option to cancel the request or cancel when the form is closing. This method is meant to be a demonstration of the syntax of a asynchronous call.</p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Haciendo Screen Scrapping]]></title>
<link>http://escarbandocodigo.wordpress.com/2009/09/28/haciendo-screen-scrapping/</link>
<pubDate>Mon, 28 Sep 2009 21:13:48 +0000</pubDate>
<dc:creator>Martin Reina</dc:creator>
<guid>http://escarbandocodigo.wordpress.com/2009/09/28/haciendo-screen-scrapping/</guid>
<description><![CDATA[  El Screen Scrapping o “respaldo de pantalla”, es una técnica usada para extraer automáticamente in]]></description>
<content:encoded><![CDATA[  El Screen Scrapping o “respaldo de pantalla”, es una técnica usada para extraer automáticamente in]]></content:encoded>
</item>
<item>
<title><![CDATA[Aplicación Login de Twitter WPF – Manejando la API de Twitter]]></title>
<link>http://escarbandocodigo.wordpress.com/2009/09/27/aplicacion-login-de-twitter-wpf-%e2%80%93-manejando-la-api-de-twitter/</link>
<pubDate>Sun, 27 Sep 2009 23:45:31 +0000</pubDate>
<dc:creator>Martin Reina</dc:creator>
<guid>http://escarbandocodigo.wordpress.com/2009/09/27/aplicacion-login-de-twitter-wpf-%e2%80%93-manejando-la-api-de-twitter/</guid>
<description><![CDATA[Twitter proporciona una API para que las personas puedan extender las características de Twitter y n]]></description>
<content:encoded><![CDATA[Twitter proporciona una API para que las personas puedan extender las características de Twitter y n]]></content:encoded>
</item>
<item>
<title><![CDATA[Silverlight &amp; PHP]]></title>
<link>http://vertoda.wordpress.com/2009/07/23/silverlight-php/</link>
<pubDate>Thu, 23 Jul 2009 11:33:12 +0000</pubDate>
<dc:creator>martcon</dc:creator>
<guid>http://vertoda.wordpress.com/2009/07/23/silverlight-php/</guid>
<description><![CDATA[PHP is a very popular language for accessing databases for Websites. It is only natural, therefore, ]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p><span style="font-family:Book Antiqua;color:#999999;">PHP is  a very popular language for accessing databases for Websites. It is only  natural, therefore, that developers may wish to use Microsoft Silverlight to  send data to a PHP script, perhaps for database addition, deletion or retrieval.  You can use the C# WebClient class to connect to a PHP script for this purpose  as follows:</span></p>
<p><span style="font-family:Book Antiqua;color:#000080;">//  Test Variables for username and password.</span></p>
<p><span style="font-family:Book Antiqua;color:#000080;">string  username=&#8221;test&#8221;;</span></p>
<p><span style="font-family:Book Antiqua;color:#000080;">string  password = &#8220;mypassword&#8221;;</span></p>
<p><span style="font-family:Book Antiqua;color:#000080;">// Set  the Parameters for the PHP Script.</span></p>
<p><span style="font-family:Book Antiqua;color:#000080;">string  parameters =  String.Format(&#8220;?username={0}&#38;password={1}&#8221;,username,password);</span></p>
<p><span style="font-family:Book Antiqua;color:#000080;">//  Create a Web Client for contacting the PHP Script.</span></p>
<p><span style="font-family:Book Antiqua;color:#000080;">WebClient client = new WebClient();</span></p>
<p><span style="font-family:Book Antiqua;color:#000080;">//  Call the PHP Script.</span></p>
<p><span style="font-family:Book Antiqua;color:#000080;">// Add  the appropriate header.</span></p>
<p><span style="font-family:Book Antiqua;color:#000080;">client.Headers["Content-Type"] =  &#8220;application/x-www-form-urlencoded&#8221;;</span></p>
<p><span style="font-family:Book Antiqua;color:#000080;">// Add  a callback handle for when the Save operation is completed.</span></p>
<p><span style="font-family:Book Antiqua;color:#000080;">client.UploadStringCompleted += new  UploadStringCompletedEventHandler(LogonCompleted);</span></p>
<p><span style="font-family:Book Antiqua;color:#000080;">//  Invoke the script and its parameters.</span></p>
<p><span style="font-family:Book Antiqua;color:#000080;">client.UploadStringAsync(new  Uri(&#8220;http://localhost/logonscript.php&#8221;+parameters,UriKind.Absolute),&#8221;POST&#8221;);</span></p>
<p><span style="font-family:Book Antiqua;color:#999999;">In the  above code we are calling a sample logon script called &#8216;logonscript.php&#8217;. This  dummy script takes a username and password as a parameter. In the sample code  above, we first create variables for storing a username and password (&#8216;test&#8217; and  &#8216;mypassword&#8217;) respectively. We then format these variables as parameters that  the PHP script can read so they will appear to the PHP script as  &#8216;?username=test&#38;password=mypassword&#8217;. </span></p>
<p><span style="font-family:Book Antiqua;color:#999999;">We  then create a Web Client, set a URL Encoded Header for this client and add an  UploadStringCompletedEventHandler (as we are sending parameters to the script).  We then invoke the UploadStringAsync method to call the script with its  parameters. In our example we are using an absolute path (UriKind.Absolute) and  we are posting data to the script as denoted by the &#8220;POST&#8221; parameter. </span></p>
<p><span style="font-family:Book Antiqua;color:#999999;">In the  example the full path is  &#8216;http://localhost/logonscript.php?username=test&#38;password=mypassword&#8217; where  the dummy script name is &#8216;logonscript.php&#8217;. This script would reside on a Web  Server such as Apache or Microsoft IIS (Internet Information  Services).</span></p>
<p><span style="font-family:Book Antiqua;color:#999999;">We  referred to a callback handler above. Once the script has run this function is  invoked to notify the Silverlight application that it is completed. An example  implementation of this callback function is shown below:</span></p>
<p><span style="font-family:Book Antiqua;color:#000080;">private void LogonCompleted(Object sender,  UploadStringCompletedEventArgs e)</span></p>
<p><span style="font-family:Book Antiqua;color:#000080;">{</span></p>
<p><span style="font-family:Book Antiqua;color:#000080;"> // We assume here that the script prints out &#8220;Success&#8221;  or &#8220;Failure&#8221;.</span></p>
<p><span style="font-family:Book Antiqua;color:#000080;"> if(e.Result.Equals(&#8220;Success&#8221;))</span></p>
<p><span style="font-family:Book Antiqua;color:#000080;"> {</span></p>
<p><span style="font-family:Book Antiqua;color:#000080;"> MessageBox.Show(&#8220;Logon Succeeded&#8221;);</span></p>
<p><span style="font-family:Book Antiqua;color:#000080;"> }</span></p>
<p><span style="font-family:Book Antiqua;color:#000080;"> else if(e.Result.Equals(&#8220;Failure&#8221;))</span></p>
<p><span style="font-family:Book Antiqua;color:#000080;"> {</span></p>
<p><span style="font-family:Book Antiqua;color:#000080;"> MessageBox.Show(&#8220;Logon Failed&#8221;);</span></p>
<p><span style="font-family:Book Antiqua;color:#000080;"> }</span></p>
<p><span style="font-family:Book Antiqua;color:#000080;">}</span></p>
<p><span style="font-family:Book Antiqua;color:#999999;">In  this sample function the PHP script prints &#8220;Success&#8221; if the logon succeeded or  &#8220;Failure&#8221; if the logon failed. This print out is stored in the Result member of  event arguments parameter &#8216;e&#8217;. We then check for these strings and display an  appropriate message box.</span></p>
<p><span style="font-family:Book Antiqua;color:#999999;">The  above example is for sending data to a PHP script. However, we can also retrieve  data from a PHP script by print out the results and reading from the Result  member of the events argument parameter &#8216;e&#8217; in our callback function.  Alternatively, if we are not sending parameters to the PHP script, we can use  WebClient&#8217;s DownloadStringAsync() method, set up a DownloadStringCompleted event  and define a callback function with a signature similar to the  following:</span></p>
<p><span style="font-family:Book Antiqua;color:#000080;">private void DownloadCompleted(Object sender,  DownloadStringCompletedEventArgs e)</span></p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[[Post-T&eacute;cnico]: SAP CRM - Relacionando a data de cabe&ccedil;alho a partir da SLA do item. ]]></title>
<link>http://progressiveinfo.wordpress.com/2009/07/15/sap_crm_relacionando_sla_header_e_item/</link>
<pubDate>Wed, 15 Jul 2009 06:07:06 +0000</pubDate>
<dc:creator>Carlos Henrique Martineli</dc:creator>
<guid>http://progressiveinfo.wordpress.com/2009/07/15/sap_crm_relacionando_sla_header_e_item/</guid>
<description><![CDATA[Atualizando a data de vencimento de um Service Ticket a partir da data do item. Ap&oacute;s alguns m]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><br />
<h2>Atualizando a data de vencimento de um <i>Service Ticket</i> a partir da data do item.</h2>
<div align="justify">
<p>Ap&#243;s alguns meses ausente devido ao trabalho, volto ao meu blog tratando de um assunto n&#227;o muito comum no mercado SAP: <strong>IC WebClient</strong>.</p>
<p>Confesso que n&#227;o tinha conhecimento sobre este <i>framework</i> at&#233;, claro, aparecer uma demanda para manuten&#231;&#227;o neste sistema. A principio, uma percepç&#227;o da complexidade, posteriormente, a certeza! <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Bom, para iniciar, algumas coisas t&#234;m que estar claras para um melhor entendimento. SAP CRM 5.0, ICWC e BSP s&#227;o os assuntos que trataremos aqui.</p>
<p><strong>SAP CRM</strong><br />
CRM  &#8211; <i>Customer Relationship Management</i> &#8211;  como o pr&#243;prio nome sugere, CRM  é um sistema de gestão de relacionamento com o cliente. As &#225;reas de atua&#231;&#227;o deste sistema é voltado para maximizar a experi&#234;ncia e produtividade do cliente, atendendo as &#225;reas de <i>service center, call center</i>, vendas, <i>marketing</i>, canais web, canais de parceiros, <i>suppliers</i>, etc. </p>
<p><strong>ICWC</strong><br />
<i>Interaction Center WebClient</i> &#8211; é uma aplicação <i>client-side</i> executada via web browser. Os dados transmitidos para o CRM WebClient s&#227;o emitidos pelo SAP NetWeaver AS. O SAP NW <i>Application Server</i> possui dois ambientes: <strong>J2EE</strong> e <strong>ABAP</strong>; possui conex&#245;es para diversos protocolos, como: SOAP/XML, HTTP/HTTPS, SMTP, RFC, etc.</p>
<p>A camada de UI (<i>user interface</i>) &#233; baseada em BSP e para o AS realizar a comunica&#231;&#227;o com o browser o mesmo possui um camada chamada <strong>ICM</strong> (<i>Internet Communication Manager</i>) que faz a interface (HTTP) entre o WebClient e o BSP runtime.<br />
A aplicação WebClient é divida em tr&#234;s camadas: <strong><i>Presentation Layer, Business Layer</i></strong> e <strong><i>Business Engine</i></strong>.</p>
<p>Na camada de apresentação se concentram os c&#243;digos <strong>HTMLB</strong> e <strong>JavaScript</strong>.<br />
A camada de negócio consiste de duas sub-camadas: BOL (<i>Business Objet Layer</i>) e GenIL (<i>Generic Interaction Layer</i>). Na sub-camada BOL est&#227;o concentradas os objetos de neg&#243;cio, como: parceiro de neg&#243;cio, ordens de servi&#231;o, ordens de venda, etc. GenIL &#233; usada para a transfer&#234;ncia de informa&#231;&#245;es (ou dar sustenta&#231;&#227;o) entre a BOL e as APIs da camada de business engine.<br />
Na camada de <i>Business Engine</i> est&#225; concentrada toda a base de dados, isto &#233;, o SAP CRM .</p>
<div id="attachment_41" class="wp-caption aligncenter" style="width: 510px"><img src="http://progressiveinfo.wordpress.com/files/2009/07/ic_webclient.png" alt="Tela da inbox do IC WebClient" title="IC_WebClient" width="500" height="269" class="size-full wp-image-41" /><p class="wp-caption-text">Tela da inbox do IC WebClient</p></div>
<p><strong>BSP</strong><br />
<i>Business Server Pages</i> &#8211; a grosso modo é uma mistura de código ABAP <i>Objects</i>, HTMLB (HTML-<i>Business</i>, se preferirem) e JavaScript. Atualmente, BSP implementa o <i>design pattern</i> MVC (<i>Model View Controller</i>).</p>
<p>Assim como o JSP (<i>Java ServerPages</i>), PHP e ASP (<i>Active ServerPages</i>); o BSP é uma aplicação <i>server-side</i> utilizada para o desenvolvimento de aplica&#231;&#245;es para Web permitindo acesso ao conteúdo do servidor de aplica&#231;&#227;o.</p>
<p><strong>O PROBLEMA</strong><br />
Para determinados perfis de usu&#225;rio (como diretores, gerentes e presidente), sempre que a data de <abbr title="Service Level Agreement">SLA</abbr> do item de uma determinada ordem de serviço for alterada, a mesma deverá automaticamente ser refletida na data de SLA do cabe&#231;alho e, consequentemente, o flag de sinaliza&#231;&#227;o da proximidade da data de vencimento dever&#225; ser atualizado. Pois, atualmente, as datas de SLA do item est&#227;o sendo alteradas, mas a mesma n&#227;o &#233; refletida no cabe&#231;alho (campo de vencimento).</p>
<p>A solu&#231;&#227;o encontrada para este problema foi, primeiramente, criar uma <i>view</i> &#34;Z&#34; (qual ABAPer que nunca fez uma c&#243;pia do <i>standard</i>? Rs! Neste caso, isto é <i>SAP recommendation</i>), no meu caso, <strong>ZSrvTHead</strong>.</p>
<div id="attachment_47" class="wp-caption aligncenter" style="width: 439px"><img src="http://progressiveinfo.wordpress.com/files/2009/07/view_srvthead.png" alt="&#60;i&#62;View&#60;/i&#62; ZSrvTHead" title="View_SrvTHead" width="429" height="263" class="size-full wp-image-47" /><p class="wp-caption-text"><i>View</i> ZSrvTHead</p></div>
<div id="attachment_48" class="wp-caption aligncenter" style="width: 440px"><img src="http://progressiveinfo.wordpress.com/files/2009/07/view_srvtsla.png" alt="&#60;i&#62;View&#60;/i&#62; de SLA do item." title="View_SrvTSLA" width="430" height="258" class="size-full wp-image-48" /><p class="wp-caption-text"><i>View</i> de SLA do item.</p></div>
<p>Depois de criados, é necessário criar os atributos necess&#225;rios para carregar dentro do mesmo contexto as datas de item e cabe&#231;alho.<br />
Lembrando que os campos no CRM são do tipo timestamp.</p>
<p>Com os atributos e setters e getters criados, é necessário instanciarmos os objetos do cotrollers e models, como: <i><strong>CuCoBT, Collection Wrapper </strong></i>e<i><strong> BOL Entity</strong></i>.<br />
Isto ser&#225; necessário para a implementa&#231;&#227;o dos m&#233;todos que ser&#227;o respons&#225;veis por buscar os dados do item dentro do contexto (<i>runtime</i>).</p>
<p>Em runtime temos acesso ao conte&#250;do do cabe&#231;alho do service ticket, ent&#227;o, para obtermos os dados do item será necessário a navega&#231;&#227;o por entre os elementos BOL. Isto &#233;, os dados do item est&#227;o dentro do componente BTDate e, como temos acesso ao cabeçalho (BTAdminH), criar-se a navega&#231;&#227;o da seguinte forma:</p>
<p>Usaremos o controler para executar o CuCoBT para termos acesso ao item (BTAdminI).</p>
<p>   <code> CuCoBT = ClassController-&#62;get_custom_controller( controller_id = 'CuCoBT' ). </code></p>
<p>Posteriormente, chegaremos até o BTDate:</p>
<p>   <code> BTAdminI -&#62; (rel) BTItemDatesSet -&#62; BTDatesSet -&#62; (rel) BTDatesAll -&#62; BTDate </code></p>
<p>Com o objeto BTDate localizado, basta buscar o campo timestamp do item.</p>
<p>Ap&#243;s concluir os m&#233;todos para buscar a data do item, ser&#225; necess&#225;rio programarmos os m&#233;todos de atualiza&#231;&#227;o da data/hora do cabe&#231;alho.</p>
<p>Para isso, usando a mesma linha de racioc&#237;nio para navegarmos até o BTDate do item, devemos encontrar o objeto BTDate do cabe&#231;alho. </p>
<p><u>Dica</u>:</p>
<p>   <code> BTAdminH -&#62; (rel) BTHeaderDatesSet -&#62; BTDatesSet -&#62; (rel) BTDatesAll -&#62; BTDate </code></p>
<p>Mas, uma aviso importante, para alterarmos a data de vencimento &#233; necess&#225;rio localizar o BTDate cujo campo <strong>APPT_TYPE</strong> do registro seja igual a <strong>SRV_CUST_END</strong>, pois a tabela tamb&#233;m possui registros com valores iguais a <strong>SRV_CUST_BEG, ORDERACTUAL</strong>, etc. Meu caso!</p>
<p>Ap&#243;s localizar o BTDate correto, converter a nova data/hora em formato adequado, comparar com a data antiga e, caso sejam diferentes, atualiz&#225;-la (&#243;bvio). </p>
<p>   <code>object = entity_col-&#62;set_property( ‘TIMESTAMP_FIELD’ ).</code></p>
<p>Esta implementa&#231;&#227; será feita para os campos FROM e TO do objeto BTDate.</p>
<p>Com os <i>getters/setters</i> implementados, temos que escolher o ponto onde o processo ser&#225; iniciado.<br />
Ent&#227;o, crie uma redefini&#231;&#227;o do evento do bot&#227;o da GRAVAR da view &#34;Z&#34;, <strong>EH_ONSAVE</strong>.</p>
<p>Instancie um objeto da classe do n&#243; de contexto respons&#225;vel pelos atributos e m&#233;todos criados anteriormente. E, neste objeto foi carregado os dados do cabe&#231;alho (BTAdminH).</p>
<p>Depois de carregados os dados do cabe&#231;alho no objeto, chamar o m&#233;todo <strong>GET</strong> do item do service ticket.<br />
Posteriormente, chamar o método <strong>SET</strong> para a atualização da data do cabeçalho.</p>
<p>Depois de atualizados os dados do cabe&#231;alho, chamar o método SAVE do controlador CuCoBT.</p>
<p>Fim do problema.</p>
<p>Espero ter ajudado seja na resolu&#231;&#227;o do problema ou na agrega&#231;&#227;o de conhecimento.</p>
<p>At&#233; a pr&#243;xima&#8230;</p>
</p></div>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[HttpWebRequest Timeout in HTTP Get]]></title>
<link>http://fravelgue.wordpress.com/2009/06/30/httpwebrequest-timeout-in-http-get/</link>
<pubDate>Tue, 30 Jun 2009 13:17:07 +0000</pubDate>
<dc:creator>fravelgue</dc:creator>
<guid>http://fravelgue.wordpress.com/2009/06/30/httpwebrequest-timeout-in-http-get/</guid>
<description><![CDATA[En estos últimos días he tenido un problema bastante curioso. Era una aplicación multi-hilo (50 hilo]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>En estos últimos días he tenido un <a href="http://stackoverflow.com/questions/1043234/strange-timeout-webexception-in-http-get-using-webclient">problema</a> bastante curioso. Era una aplicación multi-hilo (50 hilos simultáneos de ejecución) que realizaba peticiones HTTP Get a distintos servidores. El problema es que se presentaban bastante timeouts en las peticiones HTTP y sin embargo el servidor estaba en un correcto funcionamiento.</p>
<p>El código era algo como esto:</p>
<pre class="brush: csharp;">
public static string Get2(string uri)
{
    string responseData = string.Empty;
    WebRequest request = WebRequest.Create(uri) as HttpWebRequest;
    request.Method = &#34;GET&#34;;
    request.Timeout = 35000;
    using(HttpWebResponse response = (HttpWebResponse)request.GetResponse() as HttpWebResponse)
    {
        using(Stream dataStream = response.GetResponseStream ())
        {
            using(StreamReader reader = new StreamReader (dataStream))
            {
                responseData = reader.ReadToEnd();
            }
        }
    }
    return responseData;
}
</pre>
<p>Tras buscar, <a href="http://www.cnblogs.com/anders06/archive/2007/01/23/627698.html">encontré</a> <a href="http://stackoverflow.com/questions/958436/c-multithreaded-httpwebrequest-timeouts-help">bastantes</a> links y <a href="http://stackoverflow.com/questions/388908/improving-performance-of-multithreaded-httpwebrequests-in-net">este</a> bastante interesante.</p>
<p>El problema era que .NET sólo permite 2 conexiones HTTP a cada sitio, tal y como establece el el protocolo HTTP1.1. Para aumentar este número, lo único que hace falta es incluir esta configuración en el app.config o web.config.</p>
<pre class="brush: xml;">
&#60;connectionManagement&#62;
&#60;addaddress=&#34;*&#34;maxconnection=&#34;40&#34;/&#62;
&#60;/connectionManagement&#62;
</pre>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Carregando Dll de um Usercontrol dinamicamente]]></title>
<link>http://flamoreira.wordpress.com/2009/03/10/carregando-dll-de-um-usercontrol-dinamicamente/</link>
<pubDate>Tue, 10 Mar 2009 15:03:58 +0000</pubDate>
<dc:creator>Flavia Moreira</dc:creator>
<guid>http://flamoreira.wordpress.com/2009/03/10/carregando-dll-de-um-usercontrol-dinamicamente/</guid>
<description><![CDATA[Neste artigo será mostrado como carregar uma dll de usercontrol dinamicamente em Silverlight. Pois b]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p class="MsoNormal" style="line-height:150%;text-align:justify;margin:0;"><span style="font-size:10pt;line-height:150%;"><span style="font-family:Times New Roman;">Neste artigo será mostrado como carregar uma dll de usercontrol dinamicamente em Silverlight. Pois bem, o motivo que me inspirou a fazer este exemplo foi um amigo meu do MSN que insistiu para ajudá-lo a carregar animações dinâmicas vindo externamente. Além disso, percebi um big fator, às vezes podemos ter uma aplicação grande, e como sabemos, o Silverlight cria o arquivo XAP, que é um Zip disfarçado, e fazemos o download deste santo arquivo. Neste ponto, você pode imaginar que, se seu arquivo Xap for grande o usuário irá ficar extremamente zangado e desistir de ver sua aplicação, não é mesmo?. Então o que devemos fazer ? </span></span></p>
<p class="MsoNormal" style="line-height:150%;text-align:justify;margin:0;"><span style="font-size:10pt;line-height:150%;"><span style="font-family:Times New Roman;"><span>                </span>Simplesmente devemos é quebrar nossa aplicação em partes, ou seja, criar class Library e usar algumas classes importantes para isso.<span>  </span>Vamos ver então:</span></span></p>
<p class="MsoNormal" style="line-height:150%;text-align:justify;margin:0;"> </p>
<div></div>
<p><span style="font-size:10pt;line-height:150%;"></p>
<p class="MsoNormal" style="margin:0;"><strong><span style="font-size:small;"><span style="font-family:Times New Roman;">Passo 1.</span></span></strong></p>
<p class="MsoNormal" style="margin:0;"><strong><span style="font-size:small;font-family:Times New Roman;"> </span></strong></p>
<p class="MsoNormal" style="line-height:150%;text-align:justify;margin:0;"><span style="font-family:Times New Roman;"><strong><span style="font-size:10pt;line-height:150%;"><span>                </span></span></strong><span style="font-size:10pt;line-height:150%;">Crie uma class Library, indo em VS: File -&#62; New-&#62;Project. Em Project types escolha silverlight e em Templates Silverlight Class Library. Forneça um nome, tal como: Bola e pressione ok.</span></span></p>
<p class="MsoNormal" style="line-height:150%;text-align:justify;margin:0;"><span style="font-size:10pt;line-height:150%;"><span style="font-family:Times New Roman;"><span>                </span>Na solution Explorer, botão direito e adicione um novo item, selecione Silverlight User Control, forneça o nome de Bola.Xaml<span>  </span>e pressione Ok.<span>    </span></span></span></p>
<p class="MsoNormal" style="line-height:150%;text-align:justify;margin:0;"><span style="font-size:10pt;line-height:150%;"><span style="font-family:Times New Roman;"><span>                </span>Para este demo eu criei uma animação, e chamei no meu construtor, como segue: </span></span></p>
<p class="MsoNormal" style="line-height:150%;text-align:justify;margin:0;"> </p>
<p> </p>
<p> </p>
<p> </p>
<p></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-family:Times New Roman;"><span style="font-size:9pt;color:blue;" lang="EN-US">&#60;</span><span style="font-size:9pt;color:#a31515;" lang="EN-US">UserControl</span><span style="font-size:9pt;color:red;" lang="EN-US"> x</span><span style="font-size:9pt;color:blue;" lang="EN-US">:</span><span style="font-size:9pt;color:red;" lang="EN-US">Class</span><span style="font-size:9pt;color:blue;" lang="EN-US">=&#8221;Bola.Bola&#8221;</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:9pt;" lang="EN-US"><span style="font-family:Times New Roman;"><span>   </span><span style="color:red;"><span> </span>xmlns</span><span style="color:blue;">=&#8221;http://schemas.microsoft.com/winfx/2006/xaml/presentation&#8221;</span> </span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:9pt;" lang="EN-US"><span style="font-family:Times New Roman;"><span>   </span><span style="color:red;"><span> </span>xmlns</span><span style="color:blue;">:</span><span style="color:red;">x</span><span style="color:blue;">=&#8221;http://schemas.microsoft.com/winfx/2006/xaml&#8221;</span> </span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:9pt;" lang="EN-US"><span style="font-family:Times New Roman;"><span>   </span><span style="color:red;"><span> </span>Width</span><span style="color:blue;">=&#8221;400&#8243;</span><span style="color:red;"> Height</span><span style="color:blue;">=&#8221;300&#8243;&#62;</span></span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-family:Times New Roman;"><span style="font-size:9pt;color:#a31515;" lang="EN-US"><span>                </span></span><span style="font-size:9pt;color:blue;" lang="EN-US">&#60;</span><span style="font-size:9pt;color:#a31515;" lang="EN-US">UserControl.Resources</span><span style="font-size:9pt;color:blue;" lang="EN-US">&#62;</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-family:Times New Roman;"><span style="font-size:9pt;color:#a31515;" lang="EN-US"><span>                               </span></span><span style="font-size:9pt;color:blue;" lang="EN-US">&#60;</span><span style="font-size:9pt;color:#a31515;" lang="EN-US">Storyboard</span><span style="font-size:9pt;color:red;" lang="EN-US"> x</span><span style="font-size:9pt;color:blue;" lang="EN-US">:</span><span style="font-size:9pt;color:red;" lang="EN-US">Name</span><span style="font-size:9pt;color:blue;" lang="EN-US">=&#8221;SbBola&#8221;&#62;</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-family:Times New Roman;"><span style="font-size:9pt;color:#a31515;" lang="EN-US"><span>                                               </span></span><span style="font-size:9pt;color:blue;" lang="EN-US">&#60;</span><span style="font-size:9pt;color:#a31515;" lang="EN-US">DoubleAnimationUsingKeyFrames</span><span style="font-size:9pt;color:red;" lang="EN-US"> BeginTime</span><span style="font-size:9pt;color:blue;" lang="EN-US">=&#8221;</span><span style="font-size:9pt;color:blue;" lang="EN-US">00:00:00</span><span style="font-size:9pt;color:blue;" lang="EN-US">&#8220;</span><span style="font-size:9pt;color:red;" lang="EN-US"> Storyboard.TargetName</span><span style="font-size:9pt;color:blue;" lang="EN-US">=&#8221;ellipse&#8221;</span><span style="font-size:9pt;color:red;" lang="EN-US"> Storyboard.TargetProperty</span><span style="font-size:9pt;color:blue;" lang="EN-US">=&#8221;(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.X)&#8221;&#62;</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-family:Times New Roman;"><span style="font-size:9pt;color:#a31515;" lang="EN-US"><span>                                                               </span></span><span style="font-size:9pt;color:blue;" lang="EN-US">&#60;</span><span style="font-size:9pt;color:#a31515;" lang="EN-US">SplineDoubleKeyFrame</span><span style="font-size:9pt;color:red;" lang="EN-US"> KeyTime</span><span style="font-size:9pt;color:blue;" lang="EN-US">=&#8221;00:00:01.2000000&#8243;</span><span style="font-size:9pt;color:red;" lang="EN-US"> Value</span><span style="font-size:9pt;color:blue;" lang="EN-US">=&#8221;64&#8243;/&#62;</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-family:Times New Roman;"><span style="font-size:9pt;color:#a31515;" lang="EN-US"><span>                                               </span></span><span style="font-size:9pt;color:blue;" lang="EN-US">&#60;/</span><span style="font-size:9pt;color:#a31515;" lang="EN-US">DoubleAnimationUsingKeyFrames</span><span style="font-size:9pt;color:blue;" lang="EN-US">&#62;</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-family:Times New Roman;"><span style="font-size:9pt;color:#a31515;" lang="EN-US"><span>                                               </span></span><span style="font-size:9pt;color:blue;" lang="EN-US">&#60;</span><span style="font-size:9pt;color:#a31515;" lang="EN-US">DoubleAnimationUsingKeyFrames</span><span style="font-size:9pt;color:red;" lang="EN-US"> BeginTime</span><span style="font-size:9pt;color:blue;" lang="EN-US">=&#8221;</span><span style="font-size:9pt;color:blue;" lang="EN-US">00:00:00</span><span style="font-size:9pt;color:blue;" lang="EN-US">&#8220;</span><span style="font-size:9pt;color:red;" lang="EN-US"> Storyboard.TargetName</span><span style="font-size:9pt;color:blue;" lang="EN-US">=&#8221;ellipse&#8221;</span><span style="font-size:9pt;color:red;" lang="EN-US"> Storyboard.TargetProperty</span><span style="font-size:9pt;color:blue;" lang="EN-US">=&#8221;(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.Y)&#8221;&#62;</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-family:Times New Roman;"><span style="font-size:9pt;color:#a31515;" lang="EN-US"><span>                                                               </span></span><span style="font-size:9pt;color:blue;">&#60;</span><span style="font-size:9pt;color:#a31515;">SplineDoubleKeyFrame</span><span style="font-size:9pt;color:red;"> KeyTime</span><span style="font-size:9pt;color:blue;">=&#8221;00:00:01.2000000&#8243;</span><span style="font-size:9pt;color:red;"> Value</span><span style="font-size:9pt;color:blue;">=&#8221;160&#8243;/&#62;</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-family:Times New Roman;"><span style="font-size:9pt;color:#a31515;"><span>                                               </span></span><span style="font-size:9pt;color:blue;">&#60;/</span><span style="font-size:9pt;color:#a31515;">DoubleAnimationUsingKeyFrames</span><span style="font-size:9pt;color:blue;">&#62;</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-family:Times New Roman;"><span style="font-size:9pt;color:#a31515;"><span>                               </span></span><span style="font-size:9pt;color:blue;" lang="EN-US">&#60;/</span><span style="font-size:9pt;color:#a31515;" lang="EN-US">Storyboard</span><span style="font-size:9pt;color:blue;" lang="EN-US">&#62;</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-family:Times New Roman;"><span style="font-size:9pt;color:#a31515;" lang="EN-US"><span>                </span></span><span style="font-size:9pt;color:blue;" lang="EN-US">&#60;/</span><span style="font-size:9pt;color:#a31515;" lang="EN-US">UserControl.Resources</span><span style="font-size:9pt;color:blue;" lang="EN-US">&#62;</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-family:Times New Roman;"><span style="font-size:9pt;color:#a31515;" lang="EN-US"><span>    </span></span><span style="font-size:9pt;color:blue;" lang="EN-US">&#60;</span><span style="font-size:9pt;color:#a31515;" lang="EN-US">Grid</span><span style="font-size:9pt;color:red;" lang="EN-US"> x</span><span style="font-size:9pt;color:blue;" lang="EN-US">:</span><span style="font-size:9pt;color:red;" lang="EN-US">Name</span><span style="font-size:9pt;color:blue;" lang="EN-US">=&#8221;LayoutRoot&#8221;</span><span style="font-size:9pt;color:red;" lang="EN-US"> Background</span><span style="font-size:9pt;color:blue;" lang="EN-US">=&#8221;White&#8221;&#62;</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-family:Times New Roman;"><span style="font-size:9pt;color:#a31515;" lang="EN-US"><span>    </span><span>            </span></span><span style="font-size:9pt;color:blue;" lang="EN-US">&#60;</span><span style="font-size:9pt;color:#a31515;" lang="EN-US">Ellipse</span><span style="font-size:9pt;color:red;" lang="EN-US"> Height</span><span style="font-size:9pt;color:blue;" lang="EN-US">=&#8221;80&#8243;</span><span style="font-size:9pt;color:red;" lang="EN-US"> HorizontalAlignment</span><span style="font-size:9pt;color:blue;" lang="EN-US">=&#8221;Left&#8221;</span><span style="font-size:9pt;color:red;" lang="EN-US"> Margin</span><span style="font-size:9pt;color:blue;" lang="EN-US">=&#8221;24,48,0,0&#8243;</span><span style="font-size:9pt;color:red;" lang="EN-US"> VerticalAlignment</span><span style="font-size:9pt;color:blue;" lang="EN-US">=&#8221;Top&#8221;</span><span style="font-size:9pt;color:red;" lang="EN-US"> Width</span><span style="font-size:9pt;color:blue;" lang="EN-US">=&#8221;80&#8243;</span><span style="font-size:9pt;color:red;" lang="EN-US"> Fill</span><span style="font-size:9pt;color:blue;" lang="EN-US">=&#8221;#FF9B2B2B&#8221;</span><span style="font-size:9pt;color:red;" lang="EN-US"> Stroke</span><span style="font-size:9pt;color:blue;" lang="EN-US">=&#8221;#FF000000&#8243;</span><span style="font-size:9pt;color:red;" lang="EN-US"> RenderTransformOrigin</span><span style="font-size:9pt;color:blue;" lang="EN-US">=&#8221;0.5,0.5&#8243;</span><span style="font-size:9pt;color:red;" lang="EN-US"> x</span><span style="font-size:9pt;color:blue;" lang="EN-US">:</span><span style="font-size:9pt;color:red;" lang="EN-US">Name</span><span style="font-size:9pt;color:blue;" lang="EN-US">=&#8221;ellipse&#8221;&#62;</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-family:Times New Roman;"><span style="font-size:9pt;color:#a31515;" lang="EN-US"><span>    </span><span>                           </span></span><span style="font-size:9pt;color:blue;" lang="EN-US">&#60;</span><span style="font-size:9pt;color:#a31515;" lang="EN-US">Ellipse.RenderTransform</span><span style="font-size:9pt;color:blue;" lang="EN-US">&#62;</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-family:Times New Roman;"><span style="font-size:9pt;color:#a31515;" lang="EN-US"><span>    </span><span>                                           </span></span><span style="font-size:9pt;color:blue;" lang="EN-US">&#60;</span><span style="font-size:9pt;color:#a31515;" lang="EN-US">TransformGroup</span><span style="font-size:9pt;color:blue;" lang="EN-US">&#62;</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-family:Times New Roman;"><span style="font-size:9pt;color:#a31515;" lang="EN-US"><span>    </span><span>                                                           </span></span><span style="font-size:9pt;color:blue;" lang="EN-US">&#60;</span><span style="font-size:9pt;color:#a31515;" lang="EN-US">ScaleTransform</span><span style="font-size:9pt;color:blue;" lang="EN-US">/&#62;</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-family:Times New Roman;"><span style="font-size:9pt;color:#a31515;" lang="EN-US"><span>    </span><span>                                                           </span></span><span style="font-size:9pt;color:blue;" lang="EN-US">&#60;</span><span style="font-size:9pt;color:#a31515;" lang="EN-US">SkewTransform</span><span style="font-size:9pt;color:blue;" lang="EN-US">/&#62;</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-family:Times New Roman;"><span style="font-size:9pt;color:#a31515;" lang="EN-US"><span>    </span><span>                                                           </span></span><span style="font-size:9pt;color:blue;" lang="EN-US">&#60;</span><span style="font-size:9pt;color:#a31515;" lang="EN-US">RotateTransform</span><span style="font-size:9pt;color:blue;" lang="EN-US">/&#62;</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-family:Times New Roman;"><span style="font-size:9pt;color:#a31515;" lang="EN-US"><span>    </span><span>                                                           </span></span><span style="font-size:9pt;color:blue;" lang="EN-US">&#60;</span><span style="font-size:9pt;color:#a31515;" lang="EN-US">TranslateTransform</span><span style="font-size:9pt;color:blue;" lang="EN-US">/&#62;</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-family:Times New Roman;"><span style="font-size:9pt;color:#a31515;" lang="EN-US"><span>    </span><span>                                           </span></span><span style="font-size:9pt;color:blue;" lang="EN-US">&#60;/</span><span style="font-size:9pt;color:#a31515;" lang="EN-US">TransformGroup</span><span style="font-size:9pt;color:blue;" lang="EN-US">&#62;</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-family:Times New Roman;"><span style="font-size:9pt;color:#a31515;" lang="EN-US"><span>    </span><span>                           </span></span><span style="font-size:9pt;color:blue;" lang="EN-US">&#60;/</span><span style="font-size:9pt;color:#a31515;" lang="EN-US">Ellipse.RenderTransform</span><span style="font-size:9pt;color:blue;" lang="EN-US">&#62;</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-family:Times New Roman;"><span style="font-size:9pt;color:#a31515;" lang="EN-US"><span>    </span><span>            </span></span><span style="font-size:9pt;color:blue;" lang="EN-US">&#60;/</span><span style="font-size:9pt;color:#a31515;" lang="EN-US">Ellipse</span><span style="font-size:9pt;color:blue;" lang="EN-US">&#62;</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:9pt;color:blue;" lang="EN-US"><span style="font-family:Times New Roman;"> </span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-family:Times New Roman;"><span style="font-size:9pt;color:#a31515;" lang="EN-US"><span>    </span></span><span style="font-size:9pt;color:blue;" lang="EN-US">&#60;/</span><span style="font-size:9pt;color:#a31515;" lang="EN-US">Grid</span><span style="font-size:9pt;color:blue;" lang="EN-US">&#62;</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-family:Times New Roman;"><span style="font-size:9pt;color:blue;" lang="EN-US">&#60;/</span><span style="font-size:9pt;color:#a31515;" lang="EN-US">UserControl</span><span style="font-size:9pt;color:blue;" lang="EN-US">&#62;</span></span></p>
<p class="MsoNormal" style="line-height:150%;text-align:justify;margin:0;"><span style="font-size:10pt;line-height:150%;" lang="EN-US"><span style="font-family:Times New Roman;"> </span></span></p>
<p class="MsoNormal" style="line-height:150%;text-align:justify;margin:0;"><span style="font-size:10pt;line-height:150%;" lang="EN-US"><span style="font-family:Times New Roman;">Na parte do CodeBehind : </span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-family:Times New Roman;"><span style="font-size:10pt;color:blue;" lang="EN-US">namespace</span><span style="font-size:10pt;" lang="EN-US"> Bola</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;" lang="EN-US"><span style="font-family:Times New Roman;">{</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;" lang="EN-US"><span style="font-family:Times New Roman;"><span>    </span><span style="color:blue;">public</span> <span style="color:blue;">partial</span> <span style="color:blue;">class</span> <span style="color:#2b91af;">Bola</span> : <span style="color:#2b91af;">UserControl</span></span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;" lang="EN-US"><span style="font-family:Times New Roman;"><span>    </span>{</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;" lang="EN-US"><span style="font-family:Times New Roman;"><span>        </span><span style="color:blue;">public</span> Bola()</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;" lang="EN-US"><span style="font-family:Times New Roman;"><span>        </span>{</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;" lang="EN-US"><span style="font-family:Times New Roman;"><span>            </span>InitializeComponent();</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;" lang="EN-US"><span style="font-family:Times New Roman;"><span>            </span>SbBola.Begin();</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-family:Times New Roman;"><span style="font-size:10pt;" lang="EN-US"><span>        </span></span><span style="font-size:10pt;">}</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;"><span style="font-family:Times New Roman;"><span>    </span>}</span></span></p>
<p class="MsoNormal" style="line-height:150%;text-align:justify;margin:0;"><span style="font-size:10pt;line-height:150%;"><span style="font-family:Times New Roman;">}</span></span></p>
<p class="MsoNormal" style="line-height:150%;text-align:justify;margin:0;"> </p>
<p class="MsoNormal" style="line-height:150%;text-align:justify;margin:0;"><span style="font-size:10pt;line-height:150%;"><span style="font-family:Times New Roman;">Bem até ai nada demais.<span>  </span></span></span></p>
<p class="MsoNormal" style="line-height:150%;text-align:justify;margin:0;"><span style="font-size:10pt;line-height:150%;"><span style="font-family:Times New Roman;"> </span></span></p>
<p class="MsoNormal" style="line-height:150%;text-align:justify;margin:0;"><span style="font-size:10pt;line-height:150%;"><span style="font-family:Times New Roman;">Agora compile para gerar a dll. </span></span></p>
<p class="MsoNormal" style="line-height:150%;text-align:justify;margin:0;">
<p class="MsoNormal" style="line-height:150%;text-align:justify;margin:0;"> </p>
<div></div>
<p><span style="font-size:10pt;line-height:150%;"></p>
<p class="MsoNormal" style="line-height:150%;text-align:justify;margin:0;"><strong><span style="font-size:small;"><span style="font-family:Times New Roman;">Passo 2</span></span></strong></p>
<p class="MsoNormal" style="line-height:150%;text-align:justify;margin:0;"><span style="font-size:10pt;line-height:150%;"><span style="font-family:Times New Roman;">Agora, o que precisamos fazer é criar um projeto Silverlight e adicionar a dll, tal como “Bola.dll” dentro da Aplicação Asp.Net, conforme Figura 1. Eu forneci o nome para o meu projeto de LoadAnimation.<span>  </span></span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;"><span style="font-family:Times New Roman;"> </span></span></p>
<p class="MsoNormal" style="margin:0;"><strong><span style="font-size:11pt;"><span style="font-family:Times New Roman;">Passo 3</span></span></strong></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;"><span style="font-family:Times New Roman;"> </span></span></p>
<p class="MsoNormal" style="margin:0;"><span lang="EN"><span style="font-size:small;font-family:Times New Roman;"> </span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:small;font-family:Times New Roman;">O código seguinte mostra como carregar e mostrar o controle silverlight, ou seja, a dll. </span></p>
<p class="MsoNormal" style="margin:0;"><span><span style="font-size:small;font-family:Times New Roman;">            </span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:small;"><span style="font-family:Times New Roman;">Algumas explicações do código:</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;"><span style="font-family:Times New Roman;"> </span></span></p>
<ul style="margin-top:0;" type="disc">
<li class="MsoNormal"><span style="font-family:Times New Roman;"><span style="font-size:small;">Adicione o seguinte<strong> namespace, </strong></span><span style="font-size:10pt;color:blue;">using</span><span style="font-size:10pt;"> System.Reflection, que irá permitir pegar o Assembly do objeto. </span><strong></strong></span></li>
<li class="MsoNormal"><span style="font-size:small;"><span style="font-family:Times New Roman;">Usar<strong> WebClient<span>  </span></strong>para abrir uma leitura assíncrona da dll.<strong></strong></span></span></li>
<li class="MsoNormal"><span style="font-size:small;"><span style="font-family:Times New Roman;">Pegar o caminho absoluto da dll.<strong></strong></span></span></li>
<li class="MsoNormal"><span style="font-size:small;"><span style="font-family:Times New Roman;">Quando o download é terminado, o assembly é carregado e uma instancia do controle é criada.<strong></strong></span></span></li>
<li class="MsoNormal"><span style="font-size:small;"><span style="font-family:Times New Roman;">Finalmente, é adicionado dentro do Layoutroot.<strong></strong></span></span></li>
</ul>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;"><span style="font-family:Times New Roman;">[Code] </span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;"><span style="font-family:Times New Roman;"> </span></span><span style="font-family:Times New Roman;"><span style="font-size:10pt;color:blue;" lang="EN-US">namespace</span><span style="font-size:10pt;" lang="EN-US"> LoadAnimation</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;" lang="EN-US"><span style="font-family:Times New Roman;">{</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;" lang="EN-US"><span style="font-family:Times New Roman;"><span>    </span><span style="color:blue;">public</span> <span style="color:blue;">partial</span> <span style="color:blue;">class</span> <span style="color:#2b91af;">Page</span> : <span style="color:#2b91af;">UserControl</span></span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;" lang="EN-US"><span style="font-family:Times New Roman;"><span>    </span>{</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;" lang="EN-US"><span style="font-family:Times New Roman;"><span>        </span></span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;" lang="EN-US"><span style="font-family:Times New Roman;"><span>        </span><span style="color:green;">//assembly para ler a dll </span></span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;color:green;" lang="EN-US"><span style="font-family:Times New Roman;"> </span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;" lang="EN-US"><span style="font-family:Times New Roman;"><span>        </span><span style="color:blue;">private</span> <span style="color:#2b91af;">Assembly</span> _assembly;</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;" lang="EN-US"><span style="font-family:Times New Roman;"><span>        </span><span style="color:blue;">public</span> Page()</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;" lang="EN-US"><span style="font-family:Times New Roman;"><span>        </span>{</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;" lang="EN-US"><span style="font-family:Times New Roman;"><span>            </span>InitializeComponent();</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;" lang="EN-US"><span style="font-family:Times New Roman;"><span>            </span>Load();</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;" lang="EN-US"><span style="font-family:Times New Roman;"><span>        </span>}</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;" lang="EN-US"><span style="font-family:Times New Roman;"> </span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;" lang="EN-US"><span style="font-family:Times New Roman;"><span>        </span><span style="color:blue;">private</span> <span style="color:blue;">void</span> Load()</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-family:Times New Roman;"><span style="font-size:10pt;" lang="EN-US"><span>        </span></span><span style="font-size:10pt;">{</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;"><span style="font-family:Times New Roman;"><span>            </span><span style="color:green;">//puxar o arquivo da Aplicacao Asp.Net, precisa ser assincrono </span></span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;color:green;"><span style="font-family:Times New Roman;"> </span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-family:Times New Roman;"><span style="font-size:10pt;"><span>            </span></span><span style="font-size:10pt;color:#2b91af;" lang="EN-US">WebClient</span><span style="font-size:10pt;" lang="EN-US"> down = <span style="color:blue;">new</span> <span style="color:#2b91af;">WebClient</span>();</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;" lang="EN-US"><span style="font-family:Times New Roman;"><span>            </span>down.OpenReadCompleted += <span style="color:blue;">new</span> <span style="color:#2b91af;">OpenReadCompletedEventHandler</span>(download_OpenReadCompleted);</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;" lang="EN-US"><span style="font-family:Times New Roman;"><span>            </span><span style="color:blue;">string</span> classe = <span style="color:#a31515;">&#8220;Bola.dll&#8221;</span>;</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;" lang="EN-US"><span style="font-family:Times New Roman;"><span>            </span><span style="color:blue;">string</span> absoluteUri = System.Windows.<span style="color:#2b91af;">Application</span>.Current.Host.Source.AbsoluteUri;</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;" lang="EN-US"><span style="font-family:Times New Roman;"><span>            </span><span style="color:blue;">string</span> caminho = absoluteUri.Substring(0, absoluteUri.IndexOf(<span style="color:#a31515;">&#8220;ClientBin&#8221;</span>)) + classe;</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;" lang="EN-US"><span style="font-family:Times New Roman;"> </span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;" lang="EN-US"><span style="font-family:Times New Roman;"><span>            </span><span style="color:green;">//assincrono </span></span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;" lang="EN-US"><span style="font-family:Times New Roman;"><span>            </span>down.OpenReadAsync(<span style="color:blue;">new</span> <span style="color:#2b91af;">Uri</span>(caminho, <span style="color:#2b91af;">UriKind</span>.Absolute)); </span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;" lang="EN-US"><span style="font-family:Times New Roman;"><span>        </span>}</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;" lang="EN-US"><span style="font-family:Times New Roman;"> </span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-family:Times New Roman;"><span style="font-size:10pt;" lang="EN-US"><span>        </span></span><span style="font-size:10pt;color:green;">//Ao terminar de ler é carregada na aplicacao</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-family:Times New Roman;"><span style="font-size:10pt;"><span>        </span></span><span style="font-size:10pt;color:blue;" lang="EN-US">void</span><span style="font-size:10pt;" lang="EN-US"> download_OpenReadCompleted(<span style="color:blue;">object</span> sender, <span style="color:#2b91af;">OpenReadCompletedEventArgs</span> e)</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;" lang="EN-US"><span style="font-family:Times New Roman;"><span>        </span>{</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;" lang="EN-US"><span style="font-family:Times New Roman;"><span>            </span><span style="color:#2b91af;">AssemblyPart</span> assemblyPart = <span style="color:blue;">new</span> <span style="color:#2b91af;">AssemblyPart</span>();</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;" lang="EN-US"><span style="font-family:Times New Roman;"><span>            </span>_assembly = assemblyPart.Load(e.Result); </span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;" lang="EN-US"><span style="font-family:Times New Roman;"><span>          </span></span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-family:Times New Roman;"><span style="font-size:10pt;" lang="EN-US"><span>            </span></span><span style="font-size:10pt;color:green;">//Bola.Bola, esta é minha classe </span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-family:Times New Roman;"><span style="font-size:10pt;"><span>            </span></span><span style="font-size:10pt;color:#2b91af;" lang="EN-US">UserControl</span><span style="font-size:10pt;" lang="EN-US"> control = (<span style="color:#2b91af;">UserControl</span>)_assembly.CreateInstance(<span style="color:#a31515;">&#8220;Bola.Bola&#8221;</span>);</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;" lang="EN-US"><span style="font-family:Times New Roman;"><span>      </span></span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;" lang="EN-US"><span style="font-family:Times New Roman;"><span>            </span>LayoutRoot.Children.Add(control); </span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;" lang="EN-US"><span style="font-family:Times New Roman;"><span>         </span></span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-family:Times New Roman;"><span style="font-size:10pt;" lang="EN-US"><span>        </span></span><span style="font-size:10pt;">}</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;"><span style="font-family:Times New Roman;"><span>    </span>}</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;"><span style="font-family:Times New Roman;">}</span></span><strong></strong></p>
<p class="MsoNormal" style="line-height:150%;text-align:justify;margin:0;"> </p>
<p> </p>
<p> </p>
<p> </p>
<p></span></p>
<p class="MsoNormal" style="line-height:150%;text-align:justify;margin:0;">Muito obrigada,</p>
<p class="MsoNormal" style="line-height:150%;text-align:justify;margin:0;"><span style="font-size:x-small;">Flávia Moreira </span></p>
<p class="MsoNormal" style="line-height:150%;text-align:justify;margin:0;"> </p>
<p class="MsoNormal" style="line-height:150%;text-align:justify;margin:0;"> </p>
<p class="MsoNormal" style="line-height:150%;text-align:justify;margin:0;"> </p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[WebDAV amb Windows 2008 (el famós WebClient)]]></title>
<link>http://ssinyol.wordpress.com/2008/12/08/webdav-amb-windows-2008-el-famos-webclient/</link>
<pubDate>Sun, 07 Dec 2008 23:54:07 +0000</pubDate>
<dc:creator>Sergi Sinyol</dc:creator>
<guid>http://ssinyol.wordpress.com/2008/12/08/webdav-amb-windows-2008-el-famos-webclient/</guid>
<description><![CDATA[He estat instal·lant un nou servidor del flamant XenApp 5.0 sobre Windows 2008. He tingut alguns pro]]></description>
<content:encoded><![CDATA[He estat instal·lant un nou servidor del flamant XenApp 5.0 sobre Windows 2008. He tingut alguns pro]]></content:encoded>
</item>
<item>
<title><![CDATA[Unable to save .pdf files to Sharepoint document library]]></title>
<link>http://prequest01.wordpress.com/2008/11/20/unable-to-save-pdf-files-to-sharepoint-document-library/</link>
<pubDate>Thu, 20 Nov 2008 00:05:05 +0000</pubDate>
<dc:creator>Abhishek Bhowmick</dc:creator>
<guid>http://prequest01.wordpress.com/2008/11/20/unable-to-save-pdf-files-to-sharepoint-document-library/</guid>
<description><![CDATA[Unable to save .pdf files from Adobe Acrobat Reader to the Sharepoint Document Library.  As per http]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>Unable to save .pdf files from Adobe Acrobat Reader to the Sharepoint Document Library.  As per http://support.microsoft.com/kb/265867/en-us this is a known issue and the workaround is mentioned in the Microsoft KB article.  During troubleshooting it is discovered there is another way this can be done.</p>
<p>For this we first need to ensure that WebDav is enabled in Web Service Extensions in the IIS.  Also make sure that the WebClient service is running in the Services.msc in Windows Server 2003.  Once we have this done, we add a network place using the UNC path.  For instance, if your document library url is http://sharepoint/documents then type in the path as \\sharepoint\documents and this would ask for your valid credentials.  Once you enter your credentials, a network share folder would be created in your My Network Places.  Now you can open your favorite .pdf files in the Adobe Acrobar Reader and save a copy of it directly into the Sharepoint Document Library using the netwrok share in My Network Places.</p>
<p>Note:  The above procedure can be used only to create network shares for folder in the Sharepoint site running on port 80 only.  This is because Web Folders are created for other port numbers and as per the above quoted Microsoft KB article, it is a known issue that .pdf files cannot be saved.  This applies to all non Office applications like .jpg, .rtf etc&#8230;</p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Basic Screen scraping sample]]></title>
<link>http://yourtahir.wordpress.com/2008/06/16/basic-screen-scraping-sample/</link>
<pubDate>Mon, 16 Jun 2008 05:58:08 +0000</pubDate>
<dc:creator>tahir24434</dc:creator>
<guid>http://yourtahir.wordpress.com/2008/06/16/basic-screen-scraping-sample/</guid>
<description><![CDATA[&#8220;Screen scraping&#8221; means grab the contents of a web page. ASP.NET makes scraping easy. Yo]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>&#8220;Screen scraping&#8221; means grab the contents of a web page. ASP.NET makes scraping easy. You can grab the contents of any site and then use that contents according to your needs.</p>
<p>For example, you can grab the contents of stock exchange site and then extract useful information from that one. We will remain at very basic level in this article. In future we will move to some useful practical knowledge.</p>
<p><em><strong>Scraping through ASP.NET:</strong></em></p>
<p>You have to include following name spaces</p>
<p>1. System.Net (For WebClient)      2. System.Text (For UTF8Encoding)</p>
<p>// make object of WebClient.</p>
<p>WebClient MyClient = new WebClient();</p>
<p>// the url of site whose contents you want to grab.<br />
string Url = &#8220;http://www.google.com.pk&#8221;</p>
<p>// to get string, as downloaded data returns byte[]<br />
UTF8Encoding MyEncoding = new UTF8Encoding();</p>
<p>// Calling DownloadData function. It will return all contents inform of byte[] array. You can get the                    string by calling GetString method of UTF8Encoding object<br />
string str = MyEncoding.GetString(MyClient.DownloadData(Url));</p>
<p>In this string you have all the contents. you can extract any thing from it.</p>
<p>Enjoy.</p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[SkyDrive: Why aren't thou nicer to me? or "How to crawl pages and download all images using C#"]]></title>
<link>http://alexduggleby.com/2008/05/24/skydrive-why-arent-thou-nicer-to-me-or-how-to-crawl-pages-and-download-all-images-using-c/</link>
<pubDate>Sat, 24 May 2008 19:11:55 +0000</pubDate>
<dc:creator>Alex Duggleby</dc:creator>
<guid>http://alexduggleby.com/2008/05/24/skydrive-why-arent-thou-nicer-to-me-or-how-to-crawl-pages-and-download-all-images-using-c/</guid>
<description><![CDATA[Ok, SkyDrive is still a baby, and personally I&#8217;ve used other services providing file space in ]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>Ok, SkyDrive is still a baby, and personally I&#8217;ve used other services providing file space in the cloud and enjoyed them a little better. But this post isn&#8217;t about if SkyDrive is good or bad, it&#8217;s just about a missing feature that is very painful. Someone wanted to share some fotos, uploaded them to SkyDrive and all I wanted was to download them all to my PC. Tough look, you can click on each and every image to get to the preview page, where you click on the preview picture to then finally get at the actual picture. Multiply that by about 100. I have better things to do than waste my time on that.</p>
<p>So a Dev does what he does best, fires up Visual Studio 2008 and hacks away (did I just say I had something better to do &#8211; well I lied partially, but before I go off to do that, there is always time for some good ol&#8217; C#).</p>
<p>I&#8217;ve posted it here not as a finished utility (there are no binaries) but as a small sample. Using WebClients, RegEx and some other stuff it downloads the list page of the SkyDrive folder, fetches the preview page and then downloads the actual image to a folder on the hard disk. Not really rocket science and of course there are a few quirks (no real error handling for example), but it&#8217;s just a sample. Feel free to extend as you wish, don&#8217;t blame me if it starts downloading Gigabytes of files overnight, because you accidentally crawled a <a title="What's a Honeypot?" href="http://en.wikipedia.org/wiki/Honeypot_(computing)">HoneyPot</a>. (And yes, it only downloads jpgs at the moment. I didn&#8217;t need any other types.)</p>
<p>May those SkyDrive bytes be with you&#8230;</p>
<p>/**********************************************************************************<br />
 *<br />
 * Example Application for crawling web pages and downloading images.<br />
 *<br />
 * This code works if you pass in a SkyDrive Folder Url (http://&#8230;. /browse.aspx/&#8230;)<br />
 * and will download any jpg images it finds in there.<br />
 *<br />
 * Permission to use, copy, modify, distribute and sell this software and its<br />
 * documentation for any purpose is hereby granted without fee.<br />
 * I make no representations about the suitability of this software for any purpose.<br />
 * It is provided &#8220;as is&#8221; without express or implied warranty.<br />
 *<br />
 * Alex Duggleby &#8211; 24.05.08 &#8211; V0.9 &#8211; http://alexduggleby.com<br />
 *<br />
 **********************************************************************************/<br />
using System;<br />
using System.Collections.Generic;<br />
using System.Linq;<br />
using System.Text;<br />
using System.Net;<br />
using System.Text.RegularExpressions;<br />
using System.IO;<br />
using System.Web;<br />
using System.ComponentModel;</p>
<p>namespace Tools.SkyDrive.DownloadAll<br />
{<br />
    class Program<br />
    {<br />
        // Used for tracking how many items we have left<br />
        private static int _wcInnerCount = 0;<br />
        private static int _wcInnerCompleted = 0;</p>
<p>        // We have to start somewhere<br />
        private static Uri _uriStart;</p>
<p>        // Work we have already done<br />
        private readonly static List<string> _urisCrawled = new List<string>();<br />
        private readonly static List<string> _imagesDownloaded = new List<string>();</p>
<p>        // Download images to?<br />
        private readonly static DirectoryInfo _diDownloadTo = new DirectoryInfo(Path.Combine(Path.Combine(System.Environment.GetFolderPath(Environment.SpecialFolder.Personal), &#8220;Downloads&#8221;),&#8221;Images&#8221;));</p>
<p>        // This finds urls in the page<br />
        private readonly static Regex _regexUrl = new Regex(&#8220;href\\s*=\\s*(?:(?:\\\&#8221;(?<url>[^\\\"]*)\\\&#8221;)&#124;(?<url>[^\\s]* ))&#8221;);</p>
<p>        // This finds the open url in the image page<br />
        private readonly static Regex _regexUrlOpen = new Regex(&#8220;href\\s*=\\s*(?:(?:\\\&#8221;(?<url>[^\\\"]*)\\\&#8221;)&#124;(?<url>[^\\s]*)) title=\\\&#8221;Open\\\&#8221;"); </p>
<p>        /// <summary><br />
        /// Takes the url to a skydrive folder page and downloads all jpg images.<br />
        /// </summary><br />
        static void Main(string[] args)<br />
        {<br />
            // Usage check<br />
            if (args.Length != 1)<br />
            {<br />
                Console.WriteLine(&#8220;Usage: App.exe http://theUrlToThe/SkyDrive/FolderPage&#8221;);<br />
                return;<br />
            }</p>
<p>            try<br />
            {<br />
                // First parameter is url<br />
                _uriStart = new Uri(args[0]);<br />
            }<br />
            catch (Exception _ex)<br />
            {<br />
                Console.WriteLine(&#8220;Invalid Url. &#8221; + _ex.Message);<br />
                return;<br />
            }</p>
<p>            // Make sure download directory exists<br />
            if (!_diDownloadTo.Exists) _diDownloadTo.Create();</p>
<p>            using (WebClient _wc = new WebClient())<br />
            {<br />
                // This is the index with all the images<br />
                string _pageContents = _wc.DownloadString(_uriStart);</p>
<p>                // Each image has a preview page, so we get the url to that, before we get the url to the actual image<br />
                foreach (Match _matchUrlToImagePage<br />
                    in _regexUrl.Matches(_pageContents))<br />
                {<br />
                    Uri _uriToImagePage =<br />
                        new Uri(_uriStart, HttpUtility.HtmlDecode(_matchUrlToImagePage.Groups["url"].Value));</p>
<p>                    CrawlPreviewPage(_uriToImagePage);<br />
                }<br />
            }</p>
<p>            // Wait for the async web clients to complete&#8230;<br />
            while (_wcInnerCompleted < _wcInnerCount)<br />
            {<br />
                Console.WriteLine(&#8220;Wait for images to complete&#8230;&#8221;);<br />
                Console.ReadLine();<br />
            }</p>
<p>            Console.WriteLine(&#8220;Should be finished!&#8221;);<br />
            Console.ReadLine();<br />
        }</p>
<p>        /// <summary><br />
        /// Parses the preview page and finds the actual image link<br />
        /// </summary><br />
        ///
<param name="uriToImagePage">The url to the preview page</param>
        /// <returns></returns><br />
        private static void CrawlPreviewPage(Uri uriToImagePage)<br />
        {<br />
            using (WebClient _wc = new WebClient())<br />
            {<br />
                if (!_urisCrawled.Contains(uriToImagePage.ToString()))<br />
                {<br />
                    _urisCrawled.Add(uriToImagePage.ToString());</p>
<p>                    if (uriToImagePage.ToString().ToLower().EndsWith(&#8220;.jpg&#8221;))<br />
                    {<br />
                        string _pageContents = _wc.DownloadString(uriToImagePage);</p>
<p>                        // Find the image we want to download&#8230; There should be<br />
                        // only one link with title=&#8221;Open&#8221; in it.<br />
                        foreach (Match _matchImage in _regexUrlOpen.Matches(_pageContents))<br />
                        {<br />
                            Uri _uriToImage = new Uri(_matchImage.Groups["url"].Value);</p>
<p>                            DownloadImage(_uriToImage);<br />
                        }<br />
                    }<br />
                }<br />
            }<br />
        }</p>
<p>        /// <summary><br />
        /// Downloads async&#8217;ly an image from a Uri<br />
        /// </summary><br />
        ///
<param name="uriToImage">The uri to download</param>
        private static void DownloadImage(Uri uriToImage)<br />
        {<br />
            // Output the url<br />
            Console.WriteLine(&#8220;{0}{1}&#8221;, uriToImage.ToString(), Environment.NewLine);</p>
<p>            if (!_imagesDownloaded.Contains(uriToImage.ToString()))<br />
            {<br />
                _imagesDownloaded.Add(uriToImage.ToString());<br />
                string _lowerUrl = uriToImage.ToString().ToLower();</p>
<p>                // Simple checking<br />
                if (_lowerUrl.EndsWith(&#8220;.jpg&#8221;) &#038;&<br />
                   (!_lowerUrl.Contains(&#8220;browse&#8221;)) &#038;&<br />
                   (!_lowerUrl.Contains(&#8220;self&#8221;)))<br />
                {<br />
                    // HtmlDecode here because some urls have encoded characters<br />
                    string _localFilename = HttpUtility.HtmlDecode(<br />
                        uriToImage.Segments[uriToImage.Segments.Length - 1]);</p>
<p>                    // Create a valid local filename<br />
                    Path.GetInvalidPathChars().ToList().ForEach(<br />
                        c => _localFilename = _localFilename.Replace(c, &#8216;_&#8217;));</p>
<p>                    Console.Write(&#8220;Downloading {0}&#8230;{1}&#8221;, _localFilename, Environment.NewLine);</p>
<p>                    // Create a seperate web client for each image (uses async, and you can&#8217;t<br />
                    // issue two downloads at the same time for the same client). Of course<br />
                    // here we should be using some kind of pooling but this is the quickest<br />
                    // way to do it.<br />
                    using (WebClient _wcInner = new WebClient())<br />
                    {<br />
                        _wcInnerCount++;<br />
                        _wcInner.DownloadFileAsync(uriToImage, Path.Combine(_diDownloadTo.ToString(), _localFilename));<br />
                        _wcInner.DownloadFileCompleted += new AsyncCompletedEventHandler(_wcInner_DownloadFileCompleted);<br />
                    }<br />
                }<br />
            }<br />
        }</p>
<p>        // Is fired when a download complete. We output status and check if we are finished!<br />
        private static void _wcInner_DownloadFileCompleted(object sender, AsyncCompletedEventArgs e)<br />
        {<br />
            // Increase the completed counter<br />
            _wcInnerCompleted++;</p>
<p>            // Ok, we could do some more extensive checking, this could trigger<br />
            // even if there are still items to download&#8230; but hey, it&#8217;s just a<br />
            // quick utility!<br />
            if (_wcInnerCompleted == _wcInnerCount)<br />
            {<br />
                Console.WriteLine(&#8220;{0}{1}{2}&#8221;, Environment.NewLine, &#8220;Finished all files!&#8221;, Environment.NewLine);<br />
                Console.ReadLine();<br />
            }<br />
            else<br />
            {<br />
                Console.WriteLine(&#8220;File {0} of {1} completed!&#8221;, _wcInnerCompleted, _wcInnerCount);<br />
            }<br />
        }<br />
    }<br />
}</p>
</div>]]></content:encoded>
</item>

</channel>
</rss>
