<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:blogger='http://schemas.google.com/blogger/2008' xmlns:georss='http://www.georss.org/georss' xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-7002820434209519335</id><updated>2025-02-24T03:52:56.209-03:00</updated><category term="dicas"/><category term="dll"/><category term="iis"/><category term="windows"/><category term="sql server"/><category term="componentes"/><category term="ajax"/><category term="javascript"/><category term="salvador"/><category term="web.config"/><category term="banco de dados"/><category term="imagem"/><category term="nfe"/><category term="nota fiscal eletrônica"/><category term="segurança"/><category term="visual studio"/><category term="xml"/><category term="crystal reports"/><category term="handler"/><category term="thumbnail"/><category term="web-service"/><category term="crash"/><category term="desempenho"/><category term="erros"/><category term="google"/><category term="html"/><category term="ip"/><category term="jquery"/><category term="upload"/><category term="winform"/><category term="api"/><category term="application"/><category term="certificado digital"/><category term="correios"/><category term="flash"/><category term="hotspot"/><category term="integração"/><category term="komerci"/><category term="linux"/><category term="mikrotik"/><category term="mysql"/><category term="pdf"/><category term="plesk"/><category term="rede"/><category term="site"/><category term="ssl"/><category term="tcp"/><category term="acesso simultâneo"/><category term="analytics"/><category term="asp"/><category term="backup"/><category term="blog"/><category term="boleto bancário"/><category term="captcha"/><category term="cep"/><category term="chat"/><category term="cloud server"/><category term="clr"/><category term="crop"/><category term="cufon"/><category term="código de barras"/><category term="deadlock"/><category term="diretório virtual"/><category term="e-mail"/><category term="exportação"/><category term="firebird"/><category term="frete"/><category term="ftp"/><category term="ghostscript"/><category term="gráficos"/><category term="host"/><category term="importação"/><category term="installshield"/><category term="locaweb"/><category term="log"/><category term="master page"/><category term="memória"/><category term="microterminal"/><category term="mootools"/><category term="multi-upload"/><category term="mvc"/><category term="pagseguro"/><category term="php"/><category term="post"/><category term="relatório"/><category term="resources"/><category term="rss"/><category term="scanner"/><category term="sessão"/><category term="som"/><category term="sqldatasource"/><category term="template"/><category term="time-out"/><category term="web"/><category term="windows service"/><category term="wordpress"/><category term="wsdl"/><title type='text'>Thiago Marçal</title><subtitle type='html'>ASP.NET, AJAX, SQL Server</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://thiagomarcal.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7002820434209519335/posts/default?redirect=false'/><link rel='alternate' type='text/html' href='http://thiagomarcal.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><link rel='next' type='application/atom+xml' href='http://www.blogger.com/feeds/7002820434209519335/posts/default?start-index=26&amp;max-results=25&amp;redirect=false'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>78</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-7002820434209519335.post-438786960051598457</id><published>2016-09-27T15:40:00.001-03:00</published><updated>2016-09-27T15:41:48.458-03:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="ftp"/><category scheme="http://www.blogger.com/atom/ns#" term="time-out"/><category scheme="http://www.blogger.com/atom/ns#" term="upload"/><title type='text'>Sanando o &quot;The request was aborted: The request was canceled.&quot; no upload</title><content type='html'>Nome do post meio estranho, mas vamos lá!&lt;br /&gt;
Esses dias, fazendo um uploadzinho maroto, o cliente precisou enviar um arquivo &quot;grande&quot; só que na hospedagem dele, mesmo adicionando os parâmetros de configuração no web.config como &lt;span style=&quot;color: #cc0000; font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;executionTimeout&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #cc0000; font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;maxRequestLength&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #cc0000; font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;maxAllowedContentLength&lt;/span&gt;, etc, continuava o erro. Dando uma vasculhada na net algumas pessoas resolveram colocando o &lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;KeepAlive &lt;/span&gt;como &lt;span style=&quot;color: blue; font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;false &lt;/span&gt;mas eu estava usando o &lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;WebClient &lt;/span&gt;que não tem o atributo e não queria reprogramar o que já havia feito. Eis que encontro uma solução que caiu como uma luva mesmo não usando o atributo.&lt;br /&gt;
Adicione ao projeto a classe&amp;nbsp;&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;ExtendedWebClient &lt;/span&gt;conforme o código abaixo:&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;public class&lt;/span&gt; &lt;span style=&quot;color: #3d85c6;&quot;&gt;ExtendedWebClient &lt;/span&gt;: &lt;span style=&quot;color: #3d85c6;&quot;&gt;WebClient&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: blue;&quot;&gt;public int&lt;/span&gt; Timeout { &lt;span style=&quot;color: blue;&quot;&gt;get&lt;/span&gt;; &lt;span style=&quot;color: blue;&quot;&gt;set&lt;/span&gt;; }&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: blue;&quot;&gt;public new bool&lt;/span&gt; AllowWriteStreamBuffering { &lt;span style=&quot;color: blue;&quot;&gt;get&lt;/span&gt;; &lt;span style=&quot;color: blue;&quot;&gt;set&lt;/span&gt;; }&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: blue;&quot;&gt;protected override&lt;/span&gt; &lt;span style=&quot;color: #3d85c6;&quot;&gt;WebRequest &lt;/span&gt;GetWebRequest(&lt;span style=&quot;color: #3d85c6;&quot;&gt;Uri &lt;/span&gt;address)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: blue;&quot;&gt;var &lt;/span&gt;request = &lt;span style=&quot;color: blue;&quot;&gt;base&lt;/span&gt;.GetWebRequest(address);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: blue;&quot;&gt;if &lt;/span&gt;(request != null)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; request.Timeout = Timeout;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: blue;&quot;&gt;var &lt;/span&gt;httpRequest = request &lt;span style=&quot;color: blue;&quot;&gt;as &lt;/span&gt;&lt;span style=&quot;color: #3d85c6;&quot;&gt;HttpWebRequest&lt;/span&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: blue;&quot;&gt;if &lt;/span&gt;(httpRequest != &lt;span style=&quot;color: blue;&quot;&gt;null&lt;/span&gt;)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; httpRequest.AllowWriteStreamBuffering = AllowWriteStreamBuffering;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: blue;&quot;&gt;return &lt;/span&gt;request;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: blue;&quot;&gt;public &lt;/span&gt;ExtendedWebClient()&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Timeout = 100000;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
Então, agora é apenas substituir o&amp;nbsp;&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;WebClient&lt;/span&gt; por&amp;nbsp;&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;ExtendedWebClient&lt;/span&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;&amp;nbsp;ficando assim:&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;&lt;span style=&quot;color: #3d85c6;&quot;&gt;ExtendedWebClient&lt;/span&gt; ftp = &lt;span style=&quot;color: blue;&quot;&gt;new &lt;/span&gt;&lt;span style=&quot;color: #3d85c6;&quot;&gt;ExtendedWebClient&lt;/span&gt;();&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;ftp.Timeout = &lt;span style=&quot;color: #3d85c6;&quot;&gt;Timeout&lt;/span&gt;.Infinite;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;ftp.AllowWriteStreamBuffering = &lt;/span&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;false&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: inherit;&quot;&gt;E o resto segue!&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: inherit;&quot;&gt;Pode utilizar o &lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;KeepAlive&lt;/span&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;? Pode! Basta fazer da mesma forma que o&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;AllowWriteStreamBuffering&lt;/span&gt;.&lt;br /&gt;
&lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;br /&gt;&lt;/span&gt;</content><link rel='replies' type='application/atom+xml' href='http://thiagomarcal.blogspot.com/feeds/438786960051598457/comments/default' title='Postar comentários'/><link rel='replies' type='text/html' href='http://thiagomarcal.blogspot.com/2016/09/sanando-o-request-was-aborted-request.html#comment-form' title='0 Comentários'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7002820434209519335/posts/default/438786960051598457'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7002820434209519335/posts/default/438786960051598457'/><link rel='alternate' type='text/html' href='http://thiagomarcal.blogspot.com/2016/09/sanando-o-request-was-aborted-request.html' title='Sanando o &quot;The request was aborted: The request was canceled.&quot; no upload'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7002820434209519335.post-6962938549480782681</id><published>2016-09-27T11:48:00.000-03:00</published><updated>2016-09-27T11:48:25.956-03:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="hotspot"/><category scheme="http://www.blogger.com/atom/ns#" term="mikrotik"/><title type='text'>Implementação do ASP.NET (C#) com o Mikrotik (Hotspot)</title><content type='html'>Esse projeto até hoje tem demanda e, a pedidos de vocês, coloquei um pequeno projeto no GitHub para que possamos ir incrementando pouco a pouco com nossas idéias e sugestões. Hoje está bem básico e fiz o mais rápido possível para dar aquela forcinha.&lt;br /&gt;
Está em &lt;b&gt;WebForm &lt;/b&gt;para que fique bem entendível e sirva de base para utilizar com outras linguagens de programação (PHP, Java, etc).&lt;br /&gt;
Lembrando que no post anterior,&amp;nbsp;&lt;a href=&quot;http://thiagomarcal.blogspot.com.br/2011/09/adicionando-uma-pagina-de-cadastro-de.html&quot;&gt;http://thiagomarcal.blogspot.com.br/2011/09/adicionando-uma-pagina-de-cadastro-de.html&lt;/a&gt;, tem toda a configuração inicial e muitos de vocês manjam melhor do que eu com o Mikrotik. Beleza?&lt;br /&gt;
Dúvidas, sugestões, correções, etc deixem nos comentários. Se quiserem algo muito específico e queiram me presentear com um Mikrotik, eu aceito! :)&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Download:&lt;/b&gt;&amp;nbsp;&lt;a href=&quot;https://github.com/tmarcal/Mikrotik&quot;&gt;https://github.com/tmarcal/Mikrotik&lt;/a&gt;</content><link rel='replies' type='application/atom+xml' href='http://thiagomarcal.blogspot.com/feeds/6962938549480782681/comments/default' title='Postar comentários'/><link rel='replies' type='text/html' href='http://thiagomarcal.blogspot.com/2016/09/implementacao-do-aspnet-c-com-o.html#comment-form' title='0 Comentários'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7002820434209519335/posts/default/6962938549480782681'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7002820434209519335/posts/default/6962938549480782681'/><link rel='alternate' type='text/html' href='http://thiagomarcal.blogspot.com/2016/09/implementacao-do-aspnet-c-com-o.html' title='Implementação do ASP.NET (C#) com o Mikrotik (Hotspot)'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7002820434209519335.post-6076076725980937720</id><published>2016-09-07T19:40:00.000-03:00</published><updated>2016-09-07T19:41:59.252-03:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="installshield"/><category scheme="http://www.blogger.com/atom/ns#" term="windows service"/><title type='text'>No feriado, vamos resolver problemas</title><content type='html'>Dica rápida para que está tendo o erro &lt;b&gt;&quot;Could not create _isconfig.xml for use with InstallUtilLib.dll&quot;&lt;/b&gt; ao compilar um projeto de instalação (InstallShield). O nome do projeto que está sendo instalado não pode ser igual ao nome do projeto de instalação (e vice-versa). :D</content><link rel='replies' type='application/atom+xml' href='http://thiagomarcal.blogspot.com/feeds/6076076725980937720/comments/default' title='Postar comentários'/><link rel='replies' type='text/html' href='http://thiagomarcal.blogspot.com/2016/09/no-feriado-vamos-resolver-problemas.html#comment-form' title='0 Comentários'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7002820434209519335/posts/default/6076076725980937720'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7002820434209519335/posts/default/6076076725980937720'/><link rel='alternate' type='text/html' href='http://thiagomarcal.blogspot.com/2016/09/no-feriado-vamos-resolver-problemas.html' title='No feriado, vamos resolver problemas'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7002820434209519335.post-1140210716488983890</id><published>2016-09-06T21:03:00.001-03:00</published><updated>2016-09-07T19:41:23.817-03:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="segurança"/><category scheme="http://www.blogger.com/atom/ns#" term="web.config"/><title type='text'>Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.</title><content type='html'>Retornando das cinzas com dicas, macetes e artigos depois de tanto tempo e inúmeros e-mails o bom filho a casa torna. Restaurando os e-mails de alguns internautas duvidosos, muitos se depararam o erro:&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&quot;Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.&quot;&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
Geralmente sempre acontece quando tentam publicar uma aplicação em um servidor externo e dizem: &lt;i&gt;na minha máquina estava funcionando!&lt;/i&gt; Não é? Se identificou? Adicionem no &lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;web.config&lt;/span&gt; o nível de segurança:&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;system.web&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&amp;gt; &lt;/span&gt;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;span style=&quot;color: blue;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;trust &lt;/span&gt;&lt;span style=&quot;color: red;&quot;&gt;level&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;=&lt;/span&gt;&quot;&lt;span style=&quot;color: blue;&quot;&gt;Full&lt;/span&gt;&quot;&lt;span style=&quot;color: blue;&quot;&gt;/&amp;gt;&lt;/span&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;&amp;lt;&lt;/span&gt;/&lt;span style=&quot;color: #990000;&quot;&gt;system.web&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
E se não der para adicionar ou se não funcionar? Rapaz, esse assunto é polêmico (envolve segurança, bla bla bla). Tem servidores e servidores e não vale a dor de cabeça de ter adaptar demais sua aplicação para o que o provedor te oferece. Acredito que para uma boa relação ambos tem que caminhar de mão dadas.</content><link rel='replies' type='application/atom+xml' href='http://thiagomarcal.blogspot.com/feeds/1140210716488983890/comments/default' title='Postar comentários'/><link rel='replies' type='text/html' href='http://thiagomarcal.blogspot.com/2016/09/unable-to-load-one-or-more-of-requested.html#comment-form' title='0 Comentários'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7002820434209519335/posts/default/1140210716488983890'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7002820434209519335/posts/default/1140210716488983890'/><link rel='alternate' type='text/html' href='http://thiagomarcal.blogspot.com/2016/09/unable-to-load-one-or-more-of-requested.html' title='Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7002820434209519335.post-3945538679896345130</id><published>2011-11-28T09:00:00.000-02:00</published><updated>2011-11-28T09:00:14.084-02:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="application"/><category scheme="http://www.blogger.com/atom/ns#" term="diretório virtual"/><category scheme="http://www.blogger.com/atom/ns#" term="dll"/><category scheme="http://www.blogger.com/atom/ns#" term="iis"/><category scheme="http://www.blogger.com/atom/ns#" term="site"/><category scheme="http://www.blogger.com/atom/ns#" term="windows"/><title type='text'>Convertendo uma pasta em aplicação no IIS via código (C#)</title><content type='html'>Somente pelo IIS é possível converter uma pasta em aplicação? Mais ou menos. Na versão 7 do IIS já dispõe de módulos que simplificam o processo de criação de site, diretório virtual, &lt;i&gt;pools &lt;/i&gt;de aplicação e as aplicações em si. Nesse artigo mostrarei bem rápido como converter uma pasta em uma aplicação.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjUp22_RXz3b3RBU-dlFxJzebvzjyHGYiJEfRDvB55CHFAizrjI1iEt8ra-iUtUK8yh0aL03VCxKiwqaVh0qRO6W-T1hCaZyafqNvJh82tRpJ7oI5JLiN-epZ04GSXdU4J2bVAHfXxYnjUI/s1600/applicaton_iis.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjUp22_RXz3b3RBU-dlFxJzebvzjyHGYiJEfRDvB55CHFAizrjI1iEt8ra-iUtUK8yh0aL03VCxKiwqaVh0qRO6W-T1hCaZyafqNvJh82tRpJ7oI5JLiN-epZ04GSXdU4J2bVAHfXxYnjUI/s1600/applicaton_iis.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
Crie sua aplicação e adicione, como referência, o binário &lt;b&gt;Microsoft.Web.Administration.dll&lt;/b&gt; que fica na pasta&amp;nbsp;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;C:\Windows\System32\inetsrv&lt;/span&gt; . Agora adicione o seguinte código:&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;using &lt;/span&gt;Microsoft.Web.Administration;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;private void&lt;/span&gt; CriaEntradaIIS(&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;string &lt;/span&gt;diretorio)&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;try&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #38761d;&quot;&gt;// Cria a pasta do site&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;if&lt;/span&gt; (!&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #3d85c6;&quot;&gt;Directory&lt;/span&gt;.Exists(diretorio))&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #3d85c6;&quot;&gt;Directory&lt;/span&gt;.CreateDirectory(diretorio);&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #38761d;&quot;&gt;// Servidor de Aplicação&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #3d85c6;&quot;&gt;ServerManager &lt;/span&gt;sm = &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;new &lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #3d85c6;&quot;&gt;ServerManager&lt;/span&gt;();&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #38761d;&quot;&gt;// Captura o site raiz onde irá adicionar a aplicação&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #3d85c6;&quot;&gt;Site &lt;/span&gt;st = sm.Sites[&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red;&quot;&gt;&quot;Default Web Site&quot;&lt;/span&gt;];&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #38761d;&quot;&gt;// Cria a aplicação no diretório criado apontando o caminho, ex: aplicacao&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #3d85c6;&quot;&gt;Application &lt;/span&gt;app = st.Applications.Add(&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red;&quot;&gt;&quot;/aplicacao&quot;&lt;/span&gt;, diretorio);&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; app.ApplicationPoolName = &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red;&quot;&gt;&quot;ASP.NET v4.0&quot;&lt;/span&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; sm.CommitChanges();&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #38761d;&quot;&gt;// Libera&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; sm.Dispose();&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;catch &lt;/span&gt;(&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #3d85c6;&quot;&gt;Exception &lt;/span&gt;erro)&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;return&lt;/span&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Se tentar executar dará erro... Antes dê permissão total ao grupo &lt;b&gt;Serviço de Rede&lt;/b&gt; (&lt;i&gt;Network Service&lt;/i&gt;) à pasta&amp;nbsp;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;C:\Windows\System32\inetsrv\config&lt;/span&gt; . Agora sim irá criar. Para mais exemplos veja nesse post &lt;a href=&quot;http://stackoverflow.com/questions/4518186/using-servermanager-to-create-application-within-application&quot; target=&quot;_blank&quot;&gt;aqui&lt;/a&gt;.</content><link rel='replies' type='application/atom+xml' href='http://thiagomarcal.blogspot.com/feeds/3945538679896345130/comments/default' title='Postar comentários'/><link rel='replies' type='text/html' href='http://thiagomarcal.blogspot.com/2011/11/convertendo-uma-pasta-em-aplicacao-no.html#comment-form' title='3 Comentários'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7002820434209519335/posts/default/3945538679896345130'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7002820434209519335/posts/default/3945538679896345130'/><link rel='alternate' type='text/html' href='http://thiagomarcal.blogspot.com/2011/11/convertendo-uma-pasta-em-aplicacao-no.html' title='Convertendo uma pasta em aplicação no IIS via código (C#)'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjUp22_RXz3b3RBU-dlFxJzebvzjyHGYiJEfRDvB55CHFAizrjI1iEt8ra-iUtUK8yh0aL03VCxKiwqaVh0qRO6W-T1hCaZyafqNvJh82tRpJ7oI5JLiN-epZ04GSXdU4J2bVAHfXxYnjUI/s72-c/applicaton_iis.png" height="72" width="72"/><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7002820434209519335.post-3357115889212910412</id><published>2011-11-22T13:00:00.000-02:00</published><updated>2011-11-22T13:00:01.553-02:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="componentes"/><category scheme="http://www.blogger.com/atom/ns#" term="dll"/><category scheme="http://www.blogger.com/atom/ns#" term="ghostscript"/><category scheme="http://www.blogger.com/atom/ns#" term="imagem"/><category scheme="http://www.blogger.com/atom/ns#" term="pdf"/><category scheme="http://www.blogger.com/atom/ns#" term="upload"/><category scheme="http://www.blogger.com/atom/ns#" term="winform"/><title type='text'>Converter PDF em Imagem em C# com GhostScript</title><content type='html'>Esse é um artigo bem &lt;i&gt;old&lt;/i&gt;, mas que muita gente me enviou e-mails pedindo como fazer isso. Então criei um artigo bem resumido baseado no de &lt;a href=&quot;http://www.codeproject.com/KB/cs/GhostScriptUseWithCSharp.aspx&quot; target=&quot;_blank&quot;&gt;Lord TaGoH&lt;/a&gt;. Primeiramente, você precisa ter a DLL do &lt;a href=&quot;http://pages.cs.wisc.edu/~ghost/&quot; target=&quot;_blank&quot;&gt;GhostScript&lt;/a&gt; em seu projeto: ou você instala ou pega de alguém que já tenha instalado. O arquivo que me refiro é o &lt;a href=&quot;http://www.google.com.br/webhp?hl=pt-BR#sclient=psy-ab&amp;amp;hl=pt-BR&amp;amp;site=webhp&amp;amp;source=hp&amp;amp;q=gsdll32.dll&amp;amp;pbx=1&amp;amp;oq=gsdll32.dll&amp;amp;aq=f&amp;amp;aqi=&amp;amp;aql=&amp;amp;gs_sm=e&amp;amp;gs_upl=85629l85629l2l85950l1l1l0l0l0l0l0l0ll2l0&amp;amp;bav=on.2,or.r_gc.r_pw.,cf.osb&amp;amp;fp=58a32b3fdd9b5bd1&amp;amp;biw=1364&amp;amp;bih=704&quot;&gt;gsdll32.dll&lt;/a&gt;. &lt;b&gt;Obs:&lt;/b&gt; a conversão só funciona para as versões mais recentes então pegue alguma a partir da versão 9 como garantia.&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhvSvAtvD4AOdYaSL2ewHabzKqStOogrOoWP15c5mhEkB3uob7xKMpublAlH-_002Wp3LIhie_4e6JnFCVUJ41oNNzez5psGHbNfi2J1Y8X2AmFwUTv_2-IhWrGQaLo6xFwtdRtGDePjvkE/s1600/ghostscript_pdf_to_image.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhvSvAtvD4AOdYaSL2ewHabzKqStOogrOoWP15c5mhEkB3uob7xKMpublAlH-_002Wp3LIhie_4e6JnFCVUJ41oNNzez5psGHbNfi2J1Y8X2AmFwUTv_2-IhWrGQaLo6xFwtdRtGDePjvkE/s1600/ghostscript_pdf_to_image.jpg&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
Lembra do meu último post de &lt;a href=&quot;http://thiagomarcal.blogspot.com/2011/11/scanear-um-documento-com-c.html&quot;&gt;scaneamento&lt;/a&gt;? Adicionei um botão de anexar um PDF e converter em imagem, então irei aproveitar a mesma aplicação adicionando essa funcionalidade. Copie a DLL para seu projeto e, em &lt;b&gt;Propriedades&lt;/b&gt;, deixe configurado o atributo &lt;b&gt;Copiar sempre&lt;/b&gt; para quando for compilá-la caso seja um &lt;b&gt;Windows Form&lt;/b&gt;. Se for um &lt;b&gt;Web Form&lt;/b&gt;, adicione em algum local onde a classe conversora possa encontrá-la.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi0qBmqLD5Hhnb9ZKMGtsgC2FsIvSvZqNWcPP5TRwwOmnXo6EK8ahzEUtDQsoLCs6iea_NEBo7j-xaN7G-H1HU4fNKdZoxhf1H6rcvwDnYmwGJWmSvPPJuipUr6LObPgw9wbvqbCidvHwb-/s1600/gsldll32_build_pdf_image.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;267&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi0qBmqLD5Hhnb9ZKMGtsgC2FsIvSvZqNWcPP5TRwwOmnXo6EK8ahzEUtDQsoLCs6iea_NEBo7j-xaN7G-H1HU4fNKdZoxhf1H6rcvwDnYmwGJWmSvPPJuipUr6LObPgw9wbvqbCidvHwb-/s320/gsldll32_build_pdf_image.png&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
Na página do &lt;a href=&quot;http://www.codeproject.com/KB/cs/GhostScriptUseWithCSharp.aspx&quot; target=&quot;_blank&quot;&gt;CodeProject&lt;/a&gt; dispõe de uma classe (binária) já pronta para uso uso da DLL chamada de &lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;PdfToImage&lt;/span&gt;. Então você podem baixar de&amp;nbsp;&lt;a href=&quot;http://www.codeproject.com/KB/cs/GhostScriptUseWithCSharp/ConvertPDF_source_1.2.zip&quot;&gt;lá&lt;/a&gt; ou &lt;a href=&quot;http://www.mediafire.com/?wvdjagidb3i78wl&quot; target=&quot;_blank&quot;&gt;aqui&lt;/a&gt;. Baixado a DLL, você pode adicionar como referência ao seu projeto/página. Agora é só código...&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;using &lt;/span&gt;PdfToImage;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #6aa84f; font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;// Objeto de conversão&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #3d85c6;&quot;&gt;PDFConvert &lt;/span&gt;converter = &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;new &lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #3d85c6;&quot;&gt;PDFConvert&lt;/span&gt;();&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #6aa84f; font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;// Arquivo PDF selecionado de um&amp;nbsp;OpenFileDialog&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;string &lt;/span&gt;arquivo = FileUploadSelect.FileName;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #6aa84f; font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;// Local de saída do arquivo convertido&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;string &lt;/span&gt;output = _directoryForImages + &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red;&quot;&gt;&quot;LJ_&quot;&lt;/span&gt; + _loja + &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red;&quot;&gt;&quot;_Scan_&quot;&lt;/span&gt; + &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #3d85c6;&quot;&gt;DateTime&lt;/span&gt;.Now.ToString(&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red;&quot;&gt;&quot;yyyy_MM_dd_HH_mm_ss&quot;&lt;/span&gt;) + &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red;&quot;&gt;&quot;.jpg&quot;&lt;/span&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #6aa84f; font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;// Configurações de conversão&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;converter.OutputToMultipleFile = &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;false&lt;/span&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;converter.TextAlphaBit = 4;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;converter.FirstPageToConvert = 1;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;converter.LastPageToConvert = 1;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;converter.FitPage = &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;false&lt;/span&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;converter.JPEGQuality = 10;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;converter.OutputFormat = &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red;&quot;&gt;&quot;png16m&quot;&lt;/span&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #6aa84f; font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;// Faz a conversão e retorna true se estiver tudo OK&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;bool &lt;/span&gt;resultado = converter.Convert(arquivo, output);&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
Pronto! Mais fácil do que isso impossível. Fique atento às configurações de conversão, senão não funciona.</content><link rel='replies' type='application/atom+xml' href='http://thiagomarcal.blogspot.com/feeds/3357115889212910412/comments/default' title='Postar comentários'/><link rel='replies' type='text/html' href='http://thiagomarcal.blogspot.com/2011/11/converter-pdf-em-imagem-em-c-com.html#comment-form' title='1 Comentários'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7002820434209519335/posts/default/3357115889212910412'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7002820434209519335/posts/default/3357115889212910412'/><link rel='alternate' type='text/html' href='http://thiagomarcal.blogspot.com/2011/11/converter-pdf-em-imagem-em-c-com.html' title='Converter PDF em Imagem em C# com GhostScript'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhvSvAtvD4AOdYaSL2ewHabzKqStOogrOoWP15c5mhEkB3uob7xKMpublAlH-_002Wp3LIhie_4e6JnFCVUJ41oNNzez5psGHbNfi2J1Y8X2AmFwUTv_2-IhWrGQaLo6xFwtdRtGDePjvkE/s72-c/ghostscript_pdf_to_image.jpg" height="72" width="72"/><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7002820434209519335.post-3970441429148122823</id><published>2011-11-20T14:37:00.001-02:00</published><updated>2011-11-20T20:33:53.441-02:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="componentes"/><category scheme="http://www.blogger.com/atom/ns#" term="dll"/><category scheme="http://www.blogger.com/atom/ns#" term="scanner"/><category scheme="http://www.blogger.com/atom/ns#" term="windows"/><category scheme="http://www.blogger.com/atom/ns#" term="winform"/><title type='text'>Scanear um documento com C#</title><content type='html'>Um dos melhores componentes de scaneamento que já utilizei é o da &lt;a href=&quot;http://vintasoft.com/pt/vstwain-dotnet-index.html&quot; target=&quot;_blank&quot;&gt;VintaSoft&lt;/a&gt;. Ele não é &lt;i&gt;free&lt;/i&gt;, mas pode ser utilizado normalmente. O único&amp;nbsp;empecilho&amp;nbsp;é que, para cada &lt;i&gt;scan &lt;/i&gt;que fizer, ele irá solicitar que clique em &lt;b&gt;Evaluate&lt;/b&gt;. Quem comprar, vale a pena pois é muito bom e seu suporte sempre está a disposição. Chega de elogios e vamos ao que interessa.&lt;br /&gt;
&lt;br /&gt;
O componente permite tanto utilizar em &lt;b&gt;Windows Form&lt;/b&gt; quando &lt;b&gt;Web Form&lt;/b&gt; e no site há todos os &lt;a href=&quot;http://vintasoft.com/pt/vstwain-dotnet-examples.html&quot; target=&quot;_blank&quot;&gt;exemplos&lt;/a&gt; necessários. Baixe o componente e instale. Para nosso exemplo, trabalharemos com um &lt;b&gt;Windows Form&lt;/b&gt;. Fiz uma pequena aplicação de &lt;i&gt;scanear &lt;/i&gt;nota fiscal.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhseVJKjZVPGBJMl1qeRPUYYOgigS62Ravad-P5IHWXvXM0pGPd9wqadPO5qNYj420g1xrtQrP42h21r6FhgXZB2eXYEKurvIZIwLNVwLpelttdDTsID52s7dFjB5e5HmGltYhAj3SvsKOw/s1600/aplicao_scan_nota_fiscal.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;236&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhseVJKjZVPGBJMl1qeRPUYYOgigS62Ravad-P5IHWXvXM0pGPd9wqadPO5qNYj420g1xrtQrP42h21r6FhgXZB2eXYEKurvIZIwLNVwLpelttdDTsID52s7dFjB5e5HmGltYhAj3SvsKOw/s320/aplicao_scan_nota_fiscal.png&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
Vá na pasta de instalação do componente, copie o arquivo &lt;b&gt;Vintasoft.Twain.dll &lt;/b&gt;para sua aplicação e adicione como referência. No &lt;i&gt;Code-Behind&lt;/i&gt; do formulário a ser trabalhado, adicione o seguinte código para inicializar o componente:&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;using &lt;/span&gt;Vintasoft.Twain;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #6aa84f; font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;// Carrega o gerenciador de dispositivo&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #3d85c6;&quot;&gt;DeviceManager &lt;/span&gt;_deviceManager = &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;new &lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #3d85c6;&quot;&gt;DeviceManager&lt;/span&gt;();&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #3d85c6;&quot;&gt;Device &lt;/span&gt;_device;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #6aa84f; font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;// Avalia se é um dispositivo útil&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;if&lt;/span&gt; (!_deviceManager.IsTwainAvailable)&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #3d85c6;&quot;&gt;MessageBox&lt;/span&gt;.Show(&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red;&quot;&gt;&quot;Não é um dispositivo TWAIN!&quot;&lt;/span&gt;, &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red;&quot;&gt;&quot;Erro&quot;&lt;/span&gt;, &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #3d85c6;&quot;&gt;MessageBoxButtons&lt;/span&gt;.OK, &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #3d85c6;&quot;&gt;MessageBoxIcon&lt;/span&gt;.Error);&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;return&lt;/span&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue; font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;try&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #6aa84f; font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;// Abre o gerenciador de dispositivo&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;_deviceManager.Open();&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #6aa84f; font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;// Seta o dispositivo corrente&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;_device = _deviceManager.Devices.Current;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;lblDipositivo.Text = _deviceManager.Devices.Current.Info.ProductName;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;catch &lt;/span&gt;(&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #3d85c6;&quot;&gt;TwainDeviceManagerException &lt;/span&gt;ex)&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #3d85c6;&quot;&gt;MessageBox&lt;/span&gt;.Show(ex.Message, &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red;&quot;&gt;&quot;Gerenciador de Dispositivos&quot;&lt;/span&gt;);&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;return;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Agora, ao clicar no botão &lt;b&gt;Scannear&lt;/b&gt;, adicionamos o seguinte método:&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;private void&lt;/span&gt; btnScanear_Click(&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;object &lt;/span&gt;sender, &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #3d85c6;&quot;&gt;EventArgs &lt;/span&gt;e)&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;try&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #6aa84f;&quot;&gt;// Seta as configurações&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; _device.TransferMode = &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #3d85c6;&quot;&gt;TransferMode&lt;/span&gt;.File;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;try&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; _device.ShowUI = &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;false&lt;/span&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; _device.ShowIndicators = &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;false&lt;/span&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; _device.DisableAfterAcquire = &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;true&lt;/span&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;catch &lt;/span&gt;{ }&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #6aa84f;&quot;&gt;// Abre o dispositivo&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; _device.Open();&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #6aa84f;&quot;&gt;// Propriedades do scaneamento&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;try&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; _device.UnitOfMeasure = &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #3d85c6;&quot;&gt;UnitOfMeasure&lt;/span&gt;.Inches;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; _device.Resolution = &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;new &lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #3d85c6;&quot;&gt;Resolution&lt;/span&gt;(&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;float&lt;/span&gt;.Parse(resolucaoX.SelectedItem.ToString()), &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;float&lt;/span&gt;.Parse(resolucaoY.SelectedItem.ToString()));&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;catch &lt;/span&gt;{ }&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #6aa84f;&quot;&gt;// Informação sobre o arquivo&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; _arquivo = &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red;&quot;&gt;&quot;LJ_&quot;&lt;/span&gt; + _loja + &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red;&quot;&gt;&quot;_Scan_&quot;&lt;/span&gt; + &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #3d85c6;&quot;&gt;DateTime&lt;/span&gt;.Now.ToString(&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red;&quot;&gt;&quot;yyyy_MM_dd_HH_mm_ss&quot;&lt;/span&gt;) + &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red;&quot;&gt;&quot;.jpg&quot;&lt;/span&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; _device.FileName = _directoryForImages + _arquivo;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #6aa84f;&quot;&gt;//_device.FileFormat = TwainImageFileFormat.Jpeg;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #6aa84f;&quot;&gt;// Captura a imagem&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #3d85c6;&quot;&gt;AcquireModalState &lt;/span&gt;acquireModalState = &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #3d85c6;&quot;&gt;AcquireModalState&lt;/span&gt;.None;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;do&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; acquireModalState = _device.AcquireModal();&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;switch &lt;/span&gt;(acquireModalState)&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;case &lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #3d85c6;&quot;&gt;AcquireModalState&lt;/span&gt;.ImageAcquired:&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; _device.FileName = _directoryForImages + _arquivo;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #6aa84f;&quot;&gt;//_device.FileFormat = TwainImageFileFormat.Jpeg;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;break&lt;/span&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;case &lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #3d85c6;&quot;&gt;AcquireModalState&lt;/span&gt;.ScanCompleted:&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; CloseDevice();&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;break&lt;/span&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;case &lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #3d85c6;&quot;&gt;AcquireModalState&lt;/span&gt;.ScanCanceled:&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; CloseDevice();&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;break&lt;/span&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;case &lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #3d85c6;&quot;&gt;AcquireModalState&lt;/span&gt;.ScanFailed:&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; CloseDevice();&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;break&lt;/span&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;case &lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #3d85c6;&quot;&gt;AcquireModalState&lt;/span&gt;.UserInterfaceClosed:&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; CloseDevice();&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;break&lt;/span&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;while &lt;/span&gt;(acquireModalState != &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #3d85c6;&quot;&gt;AcquireModalState&lt;/span&gt;.None);&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;catch &lt;/span&gt;(&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #3d85c6;&quot;&gt;TwainException &lt;/span&gt;ex)&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #3d85c6;&quot;&gt;MessageBox&lt;/span&gt;.Show(ex.Message + &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red;&quot;&gt;&quot; - &quot;&lt;/span&gt; + ex.StackTrace, &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red;&quot;&gt;&quot;Erro&quot;&lt;/span&gt;, &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #3d85c6;&quot;&gt;MessageBoxButtons&lt;/span&gt;.OK, &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #3d85c6;&quot;&gt;MessageBoxIcon&lt;/span&gt;.Error);&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;return&lt;/span&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
E outros métodos são necessários adicionar ao &lt;b&gt;form&lt;/b&gt;, como:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;summary&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #6aa84f; font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #cccccc; font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;///&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #6aa84f; font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt; Fecha o dispositivo e a gerência&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #6aa84f; font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/summary&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;private void&lt;/span&gt; CloseDeviceAndDeviceManager()&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #6aa84f;&quot;&gt;// Verifica de há dispositivo&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;if &lt;/span&gt;(_device != &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;null&lt;/span&gt;)&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;if &lt;/span&gt;(_device.State != &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #3d85c6;&quot;&gt;DeviceState&lt;/span&gt;.Closed)&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; _device.Close();&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #6aa84f;&quot;&gt;// Fecha a gerência&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;if &lt;/span&gt;(_deviceManager.State != &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #3d85c6;&quot;&gt;DeviceManagerState&lt;/span&gt;.Closed)&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; _deviceManager.Close();&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;summary&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #6aa84f; font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #cccccc; font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;///&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #6aa84f; font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt; Fecha o dispositivo&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #6aa84f; font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/summary&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;private void&lt;/span&gt; CloseDevice()&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #6aa84f;&quot;&gt;// Desabilita o serviço&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;if &lt;/span&gt;(_device.State == &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #3d85c6;&quot;&gt;DeviceState&lt;/span&gt;.Enabled)&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;if &lt;/span&gt;(!_device.ShowUI)&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; _device.Disable();&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #6aa84f;&quot;&gt;// Fecha&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if (_device.State == &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #3d85c6;&quot;&gt;DeviceState&lt;/span&gt;.Opened)&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; _device.Close();&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;summary&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #6aa84f; font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #cccccc; font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;///&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #6aa84f; font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt; Ao fechar o formulário, libera o uso&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #6aa84f; font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/summary&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;private void&lt;/span&gt; Scan_FormClosing(&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;object &lt;/span&gt;sender, &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #3d85c6;&quot;&gt;FormClosingEventArgs &lt;/span&gt;e)&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;if &lt;/span&gt;(_device != &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;null&lt;/span&gt;)&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #6aa84f;&quot;&gt;// Verifica se está em uso&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if (_device.State == &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #3d85c6;&quot;&gt;DeviceState&lt;/span&gt;.Transferring ||&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; _device.State == &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #3d85c6;&quot;&gt;DeviceState&lt;/span&gt;.TransferReady)&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #6aa84f;&quot;&gt;// Envia a solicitação de cancelamento&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; _device.CancelTransfer();&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #6aa84f;&quot;&gt;// Aguarda finalizar&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; e.Cancel = &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;true&lt;/span&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #3d85c6;&quot;&gt;MessageBox&lt;/span&gt;.Show(&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red;&quot;&gt;&quot;O dispositivo está em uso! Aguarde alguns instantes enquanto é solicitado a liberação do scanner.&quot;&lt;/span&gt;, &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red;&quot;&gt;&quot;Informação&quot;&lt;/span&gt;);&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;return&lt;/span&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #6aa84f;&quot;&gt;// Fecha o dispositivo e a gerência&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; CloseDeviceAndDeviceManager();&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
Pronto! O scaneamento é realizado e é gerado um arquivo JPG. Reparem que está comentado o atributo&amp;nbsp;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;_device.FileFormat&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #6aa84f; font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp;&lt;/span&gt;porque nem todo scanner dá a possibilidade de configuração. Alguns aceitam e outros não. Se utilizar alguma configuração que o scanner não suporta, deve aparecer a mensagem: &lt;b&gt;&quot;Failed to get/get to capability&quot;&lt;/b&gt;. Então você precisa deixar apenas as configurações que o scanner suporte.&lt;br /&gt;
Bons scans!</content><link rel='replies' type='application/atom+xml' href='http://thiagomarcal.blogspot.com/feeds/3970441429148122823/comments/default' title='Postar comentários'/><link rel='replies' type='text/html' href='http://thiagomarcal.blogspot.com/2011/11/scanear-um-documento-com-c.html#comment-form' title='4 Comentários'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7002820434209519335/posts/default/3970441429148122823'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7002820434209519335/posts/default/3970441429148122823'/><link rel='alternate' type='text/html' href='http://thiagomarcal.blogspot.com/2011/11/scanear-um-documento-com-c.html' title='Scanear um documento com C#'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhseVJKjZVPGBJMl1qeRPUYYOgigS62Ravad-P5IHWXvXM0pGPd9wqadPO5qNYj420g1xrtQrP42h21r6FhgXZB2eXYEKurvIZIwLNVwLpelttdDTsID52s7dFjB5e5HmGltYhAj3SvsKOw/s72-c/aplicao_scan_nota_fiscal.png" height="72" width="72"/><thr:total>4</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7002820434209519335.post-751510448802916997</id><published>2011-11-20T14:02:00.001-02:00</published><updated>2011-11-20T14:36:14.887-02:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="componentes"/><category scheme="http://www.blogger.com/atom/ns#" term="crop"/><category scheme="http://www.blogger.com/atom/ns#" term="handler"/><category scheme="http://www.blogger.com/atom/ns#" term="imagem"/><category scheme="http://www.blogger.com/atom/ns#" term="thumbnail"/><title type='text'>Recortando uma Imagem em Tempo de Execução (Image Crop) em C#</title><content type='html'>Lembram do post de &lt;a href=&quot;http://thiagomarcal.blogspot.com/2011/02/redimensionar-imagens-com-alta.html&quot;&gt;Redimensionar Imagem&lt;/a&gt;? Esse post será bem similar e explicarei em poucas palavras o que ele faz. O que é &lt;b&gt;Crop&lt;/b&gt;? Segundo a &lt;a href=&quot;http://en.wikipedia.org/wiki/Cropping_(image)&quot; target=&quot;_blank&quot;&gt;Wikipedia&lt;/a&gt;,&amp;nbsp;&lt;i&gt;Crop &lt;/i&gt;(Recorte) refere-se à remoção da parte exterior de uma imagem para melhorar o seu&amp;nbsp;enquadramento. Um exemplo mais entendível: temos uma galeria de fotos nas quais todas as imagens possuem largura e altura diferentes que não são proporcionais; o redimensionamento de imagem para gerar um &lt;i&gt;thumb &lt;/i&gt;não irá funcionar pois o produto final ou ficará distorcido ou não ficarão com tamanhos iguais. É aí que o recorte entra...&lt;br /&gt;
&lt;div&gt;
&lt;br /&gt;
&lt;div&gt;
Veja o exemplo abaixo (retirado da &lt;a href=&quot;http://en.wikipedia.org/wiki/Cropping_(image)&quot; target=&quot;_blank&quot;&gt;Wikipedia&lt;/a&gt;):&lt;/div&gt;
&lt;div&gt;
&lt;ul class=&quot;gallery&quot; style=&quot;background-color: white; font-family: sans-serif; font-size: 13px; line-height: 19px; list-style-image: url(data:image/png; list-style-type: square; margin-bottom: 0.5em; margin-left: 2px; margin-right: 2px; margin-top: 2px; max-width: 486px; padding-bottom: 2px; padding-left: 2px; padding-right: 2px; padding-top: 2px; zoom: 1;&quot;&gt;
&lt;li class=&quot;gallerybox&quot; style=&quot;border-bottom-color: white; border-bottom-style: solid; border-bottom-width: 2px; border-left-color: white; border-left-style: solid; border-left-width: 2px; border-right-color: white; border-right-style: solid; border-right-width: 2px; border-top-color: white; border-top-style: solid; border-top-width: 2px; display: inline-block; margin-bottom: 0.1em; vertical-align: top; width: 235px; zoom: 1;&quot;&gt;&lt;div style=&quot;width: 235px;&quot;&gt;
&lt;div class=&quot;thumb&quot; style=&quot;background-color: #f9f9f9; border-bottom-color: rgb(204, 204, 204); border-bottom-style: solid; border-bottom-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(204, 204, 204); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(204, 204, 204); border-top-style: solid; border-top-width: 1px; margin-bottom: 2px; margin-left: 2px; margin-right: 2px; margin-top: 2px; text-align: center; width: 230px;&quot;&gt;
&lt;div style=&quot;margin-bottom: 22.5px; margin-left: auto; margin-right: auto; margin-top: 22.5px;&quot;&gt;
&lt;img alt=&quot;&quot; height=&quot;185&quot; src=&quot;http://upload.wikimedia.org/wikipedia/commons/thumb/b/b3/Chartzit001.JPG/200px-Chartzit001.JPG&quot; style=&quot;background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; border-bottom-style: none; border-color: initial; border-left-style: none; border-right-style: none; border-top-style: none; border-width: initial; display: block; margin-bottom: 0px; margin-left: auto; margin-right: auto; margin-top: 0px; vertical-align: middle;&quot; width=&quot;200&quot; /&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;gallerytext&quot; style=&quot;font-size: 12px; overflow-x: hidden; overflow-y: hidden; padding-bottom: 2px; padding-left: 4px; padding-right: 4px; padding-top: 2px; word-wrap: break-word;&quot;&gt;
&lt;div style=&quot;line-height: 1.5em; margin-bottom: 0.5em; margin-top: 0.4em;&quot;&gt;
Imagem recortada&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/li&gt;
&amp;nbsp;
&lt;li class=&quot;gallerybox&quot; style=&quot;border-bottom-color: white; border-bottom-style: solid; border-bottom-width: 2px; border-left-color: white; border-left-style: solid; border-left-width: 2px; border-right-color: white; border-right-style: solid; border-right-width: 2px; border-top-color: white; border-top-style: solid; border-top-width: 2px; display: inline-block; margin-bottom: 0.1em; vertical-align: top; width: 235px; zoom: 1;&quot;&gt;&lt;div style=&quot;width: 235px;&quot;&gt;
&lt;div class=&quot;thumb&quot; style=&quot;background-color: #f9f9f9; border-bottom-color: rgb(204, 204, 204); border-bottom-style: solid; border-bottom-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(204, 204, 204); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(204, 204, 204); border-top-style: solid; border-top-width: 1px; margin-bottom: 2px; margin-left: 2px; margin-right: 2px; margin-top: 2px; text-align: center; width: 230px;&quot;&gt;
&lt;div style=&quot;margin-bottom: 40px; margin-left: auto; margin-right: auto; margin-top: 40px;&quot;&gt;
&lt;img alt=&quot;&quot; height=&quot;150&quot; src=&quot;http://upload.wikimedia.org/wikipedia/commons/thumb/b/b3/Teva_17_3_%2864%29.JPG/200px-Teva_17_3_%2864%29.JPG&quot; style=&quot;background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; border-bottom-style: none; border-color: initial; border-left-style: none; border-right-style: none; border-top-style: none; border-width: initial; display: block; margin-bottom: 0px; margin-left: auto; margin-right: auto; margin-top: 0px; vertical-align: middle;&quot; width=&quot;200&quot; /&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;gallerytext&quot; style=&quot;font-size: 12px; overflow-x: hidden; overflow-y: hidden; padding-bottom: 2px; padding-left: 4px; padding-right: 4px; padding-top: 2px; word-wrap: break-word;&quot;&gt;
&lt;div style=&quot;line-height: 1.5em; margin-bottom: 0.5em; margin-top: 0.4em;&quot;&gt;
Imagem original&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div&gt;
No caso em questão era desejado obter um &lt;i&gt;thumb &lt;/i&gt;quadrado da imagem. O enquadramento desejado não é proporcional à image original, logo é feito o recorte.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Dessa vez não irei colocar o código pois é um pouco grandinho, mas, como disse, é bem similar ao código do post de&amp;nbsp;&lt;a href=&quot;http://thiagomarcal.blogspot.com/2011/02/redimensionar-imagens-com-alta.html&quot;&gt;Redimensionar Imagem&lt;/a&gt;&amp;nbsp;bem como seu uso (em forma de &lt;i&gt;handler.ashx&lt;/i&gt;). Esse código é bem velhinho e não é meu. Ele está aí na net a muito tempo e já o vi em vários blogs e artigos. A última vez que o vi estava no &lt;b&gt;subversion &lt;/b&gt;de &lt;a href=&quot;http://www.assembla.com/code/dne/subversion/nodes/Irdic3Lib/Helpers/Thumnail.cs&quot; target=&quot;_blank&quot;&gt;Assembla&lt;/a&gt;.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
Logo, baixem &lt;a href=&quot;http://www.mediafire.com/?5960rpfp3aow035&quot; target=&quot;_blank&quot;&gt;aqui&lt;/a&gt; e usem-o como desejar.&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://thiagomarcal.blogspot.com/feeds/751510448802916997/comments/default' title='Postar comentários'/><link rel='replies' type='text/html' href='http://thiagomarcal.blogspot.com/2011/11/recortando-uma-imagem-em-tempo-de.html#comment-form' title='0 Comentários'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7002820434209519335/posts/default/751510448802916997'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7002820434209519335/posts/default/751510448802916997'/><link rel='alternate' type='text/html' href='http://thiagomarcal.blogspot.com/2011/11/recortando-uma-imagem-em-tempo-de.html' title='Recortando uma Imagem em Tempo de Execução (Image Crop) em C#'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7002820434209519335.post-4739630871436038033</id><published>2011-11-20T13:52:00.001-02:00</published><updated>2011-11-20T14:01:13.150-02:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="ajax"/><category scheme="http://www.blogger.com/atom/ns#" term="dicas"/><category scheme="http://www.blogger.com/atom/ns#" term="javascript"/><title type='text'>Usando o ScripManager em sequência</title><content type='html'>Esse artigo será apenas uma dica para os desatentos. Quando você usa o &lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;ScriptManager &lt;/span&gt;para exibir um alerta, por exemplo, e em outro trecho do código fazer a mesma coisa, verá que apenas o primeiro alerta é demonstrado e o segundo não. O porquê disso é se estiver reaproveitando o mesmo script e não diferenciar o bloco de execução dele, sempre será exibido apenas o primeiro. Logo, o certo, é ter algo do tipo:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #6aa84f; font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;// Exibe o primeiro alerta&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #3d85c6;&quot;&gt;ScriptManager&lt;/span&gt;.RegisterStartupScript(Page, &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;typeof&lt;/span&gt;(&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #3d85c6;&quot;&gt;Page&lt;/span&gt;), &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red;&quot;&gt;&quot;script1&quot;&lt;/span&gt;, &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red;&quot;&gt;&quot;alert(&#39;Alerta 1&#39;);&quot;&lt;/span&gt;, &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;true&lt;/span&gt;);&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;...&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #6aa84f; font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;// Exibe o segundo alerta&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #3d85c6;&quot;&gt;ScriptManager&lt;/span&gt;.RegisterStartupScript(Page, &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;typeof&lt;/span&gt;(&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #3d85c6;&quot;&gt;Page&lt;/span&gt;), &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red;&quot;&gt;&quot;script2&quot;&lt;/span&gt;, &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red;&quot;&gt;&quot;alert(&#39;Alerta 2&#39;);&quot;&lt;/span&gt;, &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;true&lt;/span&gt;);&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
Reparou no bloco &lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;script1 &lt;/span&gt;e &lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;script2&lt;/span&gt;? É isso.&lt;br /&gt;
&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://thiagomarcal.blogspot.com/feeds/4739630871436038033/comments/default' title='Postar comentários'/><link rel='replies' type='text/html' href='http://thiagomarcal.blogspot.com/2011/11/usando-o-scripmanager-em-sequencia.html#comment-form' title='0 Comentários'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7002820434209519335/posts/default/4739630871436038033'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7002820434209519335/posts/default/4739630871436038033'/><link rel='alternate' type='text/html' href='http://thiagomarcal.blogspot.com/2011/11/usando-o-scripmanager-em-sequencia.html' title='Usando o ScripManager em sequência'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7002820434209519335.post-2491490350569890487</id><published>2011-09-05T23:03:00.001-03:00</published><updated>2016-09-27T11:49:55.917-03:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="api"/><category scheme="http://www.blogger.com/atom/ns#" term="hotspot"/><category scheme="http://www.blogger.com/atom/ns#" term="html"/><category scheme="http://www.blogger.com/atom/ns#" term="integração"/><category scheme="http://www.blogger.com/atom/ns#" term="ip"/><category scheme="http://www.blogger.com/atom/ns#" term="linux"/><category scheme="http://www.blogger.com/atom/ns#" term="mikrotik"/><category scheme="http://www.blogger.com/atom/ns#" term="rede"/><category scheme="http://www.blogger.com/atom/ns#" term="ssl"/><category scheme="http://www.blogger.com/atom/ns#" term="tcp"/><category scheme="http://www.blogger.com/atom/ns#" term="windows"/><title type='text'>Adicionando uma página de cadastro de usuários (Hotspot) em ASP.NET no Mikrotik</title><content type='html'>Cada projeto que pego, é uma aventura nova a ser encarada! Dessa vez me adentrei no universo de Linux, rede, SSH, infra e tudo o que é direito. Quem não conhece, a &lt;a href=&quot;http://www.mikrotik.com/&quot;&gt;Mikrotik&lt;/a&gt; é uma empresa de grande referência no que tange em equipamentos para redes de computadores. Seu principal destaque é o &lt;b&gt;RouterOS &lt;/b&gt;que é sistema operacional que torna o roteador um poderoso gerente de rede. Dentro do &lt;b&gt;Mikrotik &lt;/b&gt;(irei me referenciar sempre dessa forma generalizando como um produto), há o &lt;a href=&quot;http://pt.wikipedia.org/wiki/Hotspot&quot;&gt;HotSpot&lt;/a&gt;. Com ele pode-se gerenciar quem irá autenticar na rede para usar a internet (ou apenas a intranet), banda usada, taxa de transferência e outras funcionalidades por usuário ou de forma geral. Um exemplo de uso desse sistema é de quando você vai a uma rede corporativa onde precisa autenticar-se para usar a internet... é isso!&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjAHvROSBvue1jIFBuJLsls_NVzR8I4qvdXneZOzZCtasAXeQ1EIcKPuj9kwt_QzdD7kbHvteoHsQJ5b-DME9MCqal0Yj1znXb8aikDW3jhQlkF7ExGmZWBEJdHMP5wpCL7mLE7PT6aH3QY/s1600/hotspot_mikrotik.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;320&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjAHvROSBvue1jIFBuJLsls_NVzR8I4qvdXneZOzZCtasAXeQ1EIcKPuj9kwt_QzdD7kbHvteoHsQJ5b-DME9MCqal0Yj1znXb8aikDW3jhQlkF7ExGmZWBEJdHMP5wpCL7mLE7PT6aH3QY/s320/hotspot_mikrotik.jpg&quot; width=&quot;300&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
Qual é o objetivo desse artigo então? A princípio é apenas obter as páginas originais de &lt;i&gt;hotspot &lt;/i&gt;do &lt;b&gt;Mikrotik&lt;/b&gt;, colocar um redirecionador para uma página externa, criar uma página externa de cadastro de usuário (para que possa acessar a rede) e fazer funcionar. Não ensinarei como configurar ou criar o &lt;i&gt;hotspot&lt;/i&gt;. Pela &lt;i&gt;net &lt;/i&gt;há vários tutoriais muito bons sobre o assunto e também não é de minha área. Recomendo fortemente o fórum da &lt;b&gt;&lt;a href=&quot;http://under-linux.org/f143/&quot;&gt;Under-Linux&lt;/a&gt;&amp;nbsp;&lt;/b&gt;que lá o pessoal manja muito no assunto.&lt;br /&gt;
&lt;br /&gt;
Nesse artigo usei o Mikrotik &lt;a href=&quot;http://www.mdbrasil.com.br/isp-safe/0,,mikrotik,00037,false,1.html&quot;&gt;MKBR100&lt;/a&gt;&amp;nbsp;que é bem fácil de usar: basta plugar o cabo de rede da internet, do servidor e da energia. Pronto!&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgztRGJOCFpMmf1v3_iWaKx5Py9hdwAxu1Z-BZ-67kNsde2DhTui3nMQY-TjOMd42r5WDx0Mri3KhofFZMKnhkXK0QXN0jpiVW5QwcqAxXwTlnonlf_UkUVkPZPaPySBt0XsOnDPfXFrAfd/s1600/mkbr100.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgztRGJOCFpMmf1v3_iWaKx5Py9hdwAxu1Z-BZ-67kNsde2DhTui3nMQY-TjOMd42r5WDx0Mri3KhofFZMKnhkXK0QXN0jpiVW5QwcqAxXwTlnonlf_UkUVkPZPaPySBt0XsOnDPfXFrAfd/s1600/mkbr100.jpg&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
Para acessar seu SO, deve-se utilizar o &lt;a href=&quot;http://wirelessconnect.eu/articles/winbox_download&quot;&gt;Winbox&lt;/a&gt;&amp;nbsp;como se fosse um daqueles &lt;i&gt;players &lt;/i&gt;de máquina virtual ou OpenSSH. Vamos lá colocar a mão na massa!&lt;br /&gt;
&lt;br /&gt;
Conecte o cabo de rede de seu PC (ou servidor) na porta (interface)&amp;nbsp;&lt;i&gt;ether2 &lt;/i&gt;do Mikrotik. Agora conecte outro cabo na &lt;i&gt;ether1 &lt;/i&gt;para os outros computadores da rede (ou roteador simples). Porquê na &lt;i&gt;ether1&lt;/i&gt;? Estou considerando que o &lt;i&gt;hotspot &lt;/i&gt;está configurado para monitorar essa interface enquanto a &lt;i&gt;ether2 &lt;/i&gt;será utilizado para que o servidor de comunique com o aparelho. Seria algo do tipo:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgQOh5tTdfZU2nwSlERS6QR2GQkj-oVsNzuPsYFg0t_R_GEKizAGhGdS5fX1NXg1XvDStR1T4GD_Suwcglbi55LX2F6S2JJ2F2uLCO1w_mnjGY7rLNhj4UYYoX3n-nr9Yi2KgEf-f6m_8w9/s1600/diagrama_hotspot_mikrotik.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;260&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgQOh5tTdfZU2nwSlERS6QR2GQkj-oVsNzuPsYFg0t_R_GEKizAGhGdS5fX1NXg1XvDStR1T4GD_Suwcglbi55LX2F6S2JJ2F2uLCO1w_mnjGY7rLNhj4UYYoX3n-nr9Yi2KgEf-f6m_8w9/s400/diagrama_hotspot_mikrotik.jpg&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
Vá em &lt;b&gt;IP &lt;/b&gt;&amp;gt; &lt;b&gt;Address &lt;/b&gt;no Mikrotik para que sejam configuradas as interfaces e sejam endereçados conforme os exemplos abaixo:&lt;br /&gt;
&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;&lt;b&gt;ether1:&lt;/b&gt; 192.168.88.1&lt;/li&gt;
&lt;li&gt;&lt;b&gt;ether2:&lt;/b&gt; 192.168.88.2&lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;
Somente através de IP que será possível enviar os arquivos do &lt;i&gt;hotspot&lt;/i&gt;. Se ficar conectando, via MAC, pelo Winbox, você terá a mensagem de erro: &lt;b&gt;&quot;router has been disconnected&quot; &lt;/b&gt;(logo, conecte-se usando a &lt;i&gt;ether2 &lt;/i&gt;-&amp;nbsp;192.168.88.2). E outra coisa é: se não seguir o esquema acima, outros erros você terá, como:&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&lt;i&gt;could not connect to ... no response&lt;/i&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;i&gt;could not connect to ... connection refused&lt;/i&gt;&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&lt;i&gt;could not connect to ... network is unreachable&lt;/i&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;i&gt;could not fetch index from ... not found&lt;/i&gt;&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Tudo isso por causa de configuração apenas! É bom deixar o IP do servidor fixo para que possa dar permissão de porta, firewall, etc. No caso deixei como 192.168.88.30 (que no caso era minha própria máquina). Uma dica: às vezes dê um &lt;i&gt;reboot &lt;/i&gt;no aparelho!&lt;br /&gt;
&lt;br /&gt;
O próximo passo é ativar a porta da API que o Mikrotik dispõe para integração com linguagens de programação. É através dela que iremos conectar e fazer a comunicação. Só que precisamos ativá-la. Vá em &lt;b&gt;IP &lt;/b&gt;&amp;gt; &lt;b&gt;Services &lt;/b&gt;e ative a &lt;b&gt;API &lt;/b&gt;na porta 8728.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiMxaf3wJdv6uNJJYMuUmYm2p314OV6crwLPcP2cXcjZ5SNLl-z6K7i-vrFG6wDn14FhljU620MF-a4cn7-2YRl70l2E7jB5igMyp64VoTMhYAQXWNm2Mdn5CNQqA0hy-q6UTDAAcPVooHj/s1600/mikrotik_api_ativacao.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;290&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiMxaf3wJdv6uNJJYMuUmYm2p314OV6crwLPcP2cXcjZ5SNLl-z6K7i-vrFG6wDn14FhljU620MF-a4cn7-2YRl70l2E7jB5igMyp64VoTMhYAQXWNm2Mdn5CNQqA0hy-q6UTDAAcPVooHj/s400/mikrotik_api_ativacao.png&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
Também libere, no &lt;b&gt;Firewall&lt;/b&gt;, as portas para conexão tanto do sistema quanto do Winbox (pelo IP), senão quando estiver acessando pela página de cadastro, irá surgir o erro: &lt;b&gt;&quot;nenhuma conexão pôde ser feita porque a máquina de destino as recusou ativamente ..:8728.&quot;&lt;/b&gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjEi0z8mmdD5aoyjEyHHDq6Z4YRKkx69ky77y34hargI4k4gockNF9UL8wESORZQFgIV7dozxZzwJUaH3yYLJtSQFcA08DAw947B2kzWnXC1d1acZxIcUKba38CUdrypR-tpBcNMAWvlcqT/s1600/mikrotik_ip_firewall.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;290&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjEi0z8mmdD5aoyjEyHHDq6Z4YRKkx69ky77y34hargI4k4gockNF9UL8wESORZQFgIV7dozxZzwJUaH3yYLJtSQFcA08DAw947B2kzWnXC1d1acZxIcUKba38CUdrypR-tpBcNMAWvlcqT/s400/mikrotik_ip_firewall.png&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
Para permitir a navegação e envio de informações, adicione as permissões no &lt;b&gt;Walled Garden&lt;/b&gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhRri0L27PEDRw_YoCzdEJT-mQos1g4WAnwiPTQH8Tk_haM9ThUfDjKoR1XvFS7lDnk5xOIqj11uNEGQQewRWbF83tHqEUyqKiozQVOFtlVLnksWlpUENHHx4seqwCxokVU0MfaH29rqRhL/s1600/mikrotik_walledgarden.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;290&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhRri0L27PEDRw_YoCzdEJT-mQos1g4WAnwiPTQH8Tk_haM9ThUfDjKoR1XvFS7lDnk5xOIqj11uNEGQQewRWbF83tHqEUyqKiozQVOFtlVLnksWlpUENHHx4seqwCxokVU0MfaH29rqRhL/s400/mikrotik_walledgarden.png&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
Vejam que até o momento tudo é configuração e nada de programação. Continuemos...&lt;br /&gt;
&lt;br /&gt;
Agora vamos em &lt;b&gt;Files &lt;/b&gt;e selecione todos os arquivos da pasta &lt;i&gt;hotspot&lt;/i&gt;, arraste para sua área de trabalho que será copiado. Para enviar faça o processo inverso... Se estiver acessando pelo IP vai dar certo, senão cairá a conexão (lembra que disse acima?).&lt;br /&gt;
&lt;br /&gt;
Abra o HTML da página &lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;login.html&lt;/span&gt; e acione um link para a página de cadastro que ficará hospedada no servidor. Adicionei o link &lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #990000;&quot;&gt;&amp;lt;a&lt;/span&gt; &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red;&quot;&gt;href&lt;/span&gt;=&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;&quot;http://192.168.88.30/mikrotik/cadastro.aspx&quot;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #990000;&quot;&gt;&amp;gt;&lt;/span&gt;cadastre-se&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #990000;&quot;&gt;&amp;lt;/a&amp;gt;&lt;/span&gt;&lt;/span&gt; . Customize as demais páginas como desejar e as envie de volta. Praticamente terminamos de trabalhar no &lt;b&gt;Mikrotik&lt;/b&gt;.&lt;br /&gt;
&lt;br /&gt;
Agora vem o mais simples: criar a página ASP.NET. Você pode utilizar qualquer linguagem de programação que possa usar TCP na comunicação e que a &lt;a href=&quot;http://wiki.mikrotik.com/wiki/Manual:API&quot;&gt;API&lt;/a&gt; suporte: PHP, Delphi, C, C++, C#, Flash, Ruby on Rails, Java, Python, VB.NET, etc.&lt;br /&gt;
&lt;br /&gt;
Faça o download da classe MK, em C# (eles já dispõe de classes prontas para outras linguagens também), nesse link &lt;a href=&quot;http://wiki.mikrotik.com/wiki/API_in_C_Sharp&quot;&gt;aqui&lt;/a&gt; e adicione no seu projeto. Agora crie um &lt;b&gt;Web Form&lt;/b&gt; adicionando os campos que queira trabalhar. No meu exemplo, só quis login (&lt;i&gt;username&lt;/i&gt;) e senha. Adicione um &lt;b&gt;Button &lt;/b&gt;e um método para executar o cadastro do usuário conforme exemplo abaixo:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #38761d; font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;// Autenticação&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #3d85c6;&quot;&gt;MK &lt;/span&gt;mikrotik = &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;new &lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #3d85c6;&quot;&gt;MK&lt;/span&gt;(&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red;&quot;&gt;&quot;192.168.88.2&quot;&lt;/span&gt;);&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;if &lt;/span&gt;(!mikrotik.Login(&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red;&quot;&gt;&quot;admin&quot;&lt;/span&gt;, &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red;&quot;&gt;&quot;&quot;&lt;/span&gt;))&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #3d85c6;&quot;&gt;ScriptManager&lt;/span&gt;.RegisterStartupScript(Page, &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;typeof&lt;/span&gt;(Page), &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red;&quot;&gt;&quot;alert&quot;&lt;/span&gt;, &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red;&quot;&gt;&quot;alert(&#39;Houve um problema de comunicação com o Hotspot! Por favor, tente mais tarde.&#39;);&quot;&lt;/span&gt;, &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;true&lt;/span&gt;);&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; mikrotik.Close();&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;return&lt;/span&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #38761d;&quot;&gt;// Requisição&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; mikrotik.Send(&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red;&quot;&gt;&quot;/ip/hotspot/user/add&quot;&lt;/span&gt;);&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; mikrotik.Send(&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red;&quot;&gt;&quot;=name=&quot;&lt;/span&gt; + nome.Text);&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; mikrotik.Send(&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red;&quot;&gt;&quot;=password=&quot;&lt;/span&gt; + senha.Text, &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;true&lt;/span&gt;);&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #38761d;&quot;&gt;//Retorno&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;string &lt;/span&gt;retorno = &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;string&lt;/span&gt;.Empty;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;foreach &lt;/span&gt;(&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;string &lt;/span&gt;h &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;in &lt;/span&gt;mikrotik.Read())&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;if &lt;/span&gt;(retorno != &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;string&lt;/span&gt;.Empty)&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; retorno += &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red;&quot;&gt;&quot;, &quot;&lt;/span&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; retorno += h;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #38761d;&quot;&gt;// Fecha objeto&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; mikrotik.Close();&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #38761d;&quot;&gt;// Validação&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;if &lt;/span&gt;(retorno.ToLower().Contains(&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red;&quot;&gt;&quot;!done=ret=&quot;&lt;/span&gt;))&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #3d85c6;&quot;&gt;ScriptManager&lt;/span&gt;.RegisterStartupScript(Page, &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;typeof&lt;/span&gt;(Page), &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red;&quot;&gt;&quot;alert&quot;&lt;/span&gt;, &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red;&quot;&gt;&quot;alert(&#39;Cadastro realizado com sucesso!&#39;); location.href=&#39;http://192.168.88.1/login.html&#39;;&quot;&lt;/span&gt;, &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;true&lt;/span&gt;);&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;else if&lt;/span&gt; (retorno.ToLower().Contains(&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red;&quot;&gt;&quot;message=failure: already have user with this name for this server&quot;&lt;/span&gt;))&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #3d85c6;&quot;&gt;ScriptManager&lt;/span&gt;.RegisterStartupScript(Page, &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;typeof&lt;/span&gt;(Page), &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red;&quot;&gt;&quot;alert&quot;&lt;/span&gt;, &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red;&quot;&gt;&quot;alert(&#39;Já existe um usuário com esse nome!&#39;);&quot;&lt;/span&gt;, &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;true&lt;/span&gt;);&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;else&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #3d85c6;&quot;&gt;ScriptManager&lt;/span&gt;.RegisterStartupScript(Page, &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;typeof&lt;/span&gt;(Page), &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red;&quot;&gt;&quot;alert&quot;&lt;/span&gt;,&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red;&quot;&gt; &quot;alert(&#39;Falha no cadastro: &quot;&lt;/span&gt; + retorno + &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red;&quot;&gt;&quot;!&#39;);&quot;&lt;/span&gt;, &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;true&lt;/span&gt;);&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Você poderia não só fazer o cadastro de usuário no &lt;i&gt;hotspot &lt;/i&gt;como também executar qualquer comando (SSH) no Mikrotik. Lembrando que eu atropelei muita coisa aí no que diz respeito a configuração do dispositivo na qual disse logo no início que não era minha finalidade. Vocês observaram que a parte de programação é bem simples do que configuração... e com certeza é! Agora nunca irá sair de minha cabeça a palavra &lt;i&gt;&lt;b&gt;Mikrotik&amp;nbsp;Mikrotik&amp;nbsp;Mikrotik&amp;nbsp;Mikrotik&amp;nbsp;Mikrotik&lt;/b&gt;&lt;/i&gt; ... Por favor, qualquer erro ou informação adicional me avise!&lt;br /&gt;
&lt;br /&gt;
[]&#39;s&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;color: red;&quot;&gt;UPDATE:&lt;/span&gt;&lt;/b&gt; disponibilizei uma implementação no post&amp;nbsp;http://thiagomarcal.blogspot.com.br/2016/09/implementacao-do-aspnet-c-com-o.html&lt;br /&gt;
&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://thiagomarcal.blogspot.com/feeds/2491490350569890487/comments/default' title='Postar comentários'/><link rel='replies' type='text/html' href='http://thiagomarcal.blogspot.com/2011/09/adicionando-uma-pagina-de-cadastro-de.html#comment-form' title='38 Comentários'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7002820434209519335/posts/default/2491490350569890487'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7002820434209519335/posts/default/2491490350569890487'/><link rel='alternate' type='text/html' href='http://thiagomarcal.blogspot.com/2011/09/adicionando-uma-pagina-de-cadastro-de.html' title='Adicionando uma página de cadastro de usuários (Hotspot) em ASP.NET no Mikrotik'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjAHvROSBvue1jIFBuJLsls_NVzR8I4qvdXneZOzZCtasAXeQ1EIcKPuj9kwt_QzdD7kbHvteoHsQJ5b-DME9MCqal0Yj1znXb8aikDW3jhQlkF7ExGmZWBEJdHMP5wpCL7mLE7PT6aH3QY/s72-c/hotspot_mikrotik.jpg" height="72" width="72"/><thr:total>38</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7002820434209519335.post-6629779308605983674</id><published>2011-09-03T23:37:00.000-03:00</published><updated>2011-09-03T23:37:08.283-03:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="dicas"/><category scheme="http://www.blogger.com/atom/ns#" term="iis"/><category scheme="http://www.blogger.com/atom/ns#" term="plesk"/><category scheme="http://www.blogger.com/atom/ns#" term="segurança"/><category scheme="http://www.blogger.com/atom/ns#" term="windows"/><title type='text'>Recuperando a senha da conta identidade do Pool de Aplicativos do Plesk no IIS</title><content type='html'>Mais um título longo... um tanto confuso, mas em resposta a uma dúvida de um amigo:&lt;br /&gt;
&lt;blockquote&gt;&lt;b&gt;&lt;i&gt;&quot;Exclui um Application Pool no IIS e nela estava configurada uma conta interna do Plesk: IWAM_plesk. Não sei a senha utilizada. Tem como recuperar a senha para recriar um novo application?&quot;&lt;/i&gt;&lt;/b&gt;&lt;/blockquote&gt;Sim! O &lt;b&gt;Plesk &lt;/b&gt;sempre nos pregando aquela peça... Os dois &lt;i&gt;pools&lt;/i&gt;&lt;i&gt;&amp;nbsp;&lt;/i&gt;que o &lt;b&gt;Plesk &lt;/b&gt;utiliza estão vinculados à conta &lt;b&gt;IWAM_plesk&lt;/b&gt;&amp;nbsp;(conta interna) para que possam manipular corretamente os arquivos e seus aplicativos (bem como as permissões necessárias) no sistema operacional:&lt;br /&gt;
&lt;br /&gt;
&lt;ol&gt;&lt;li&gt;plesk(default)(2.0)(pool)&lt;/li&gt;
&lt;li&gt;plesk(default)(4.0)(pool)&lt;/li&gt;
&lt;/ol&gt;&lt;br /&gt;
&amp;nbsp;Então façamos as seguintes etapas:&lt;br /&gt;
&lt;br /&gt;
&lt;ul&gt;&lt;li&gt;Abra o &lt;b&gt;Prompt de Comando&lt;/b&gt; em Modo Administrador;&lt;/li&gt;
&lt;li&gt;Navegue para a pasta&amp;nbsp;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;C:\Windows\system32\inetsrv&lt;/span&gt;;&lt;/li&gt;
&lt;li&gt;Execute o comando&amp;nbsp;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;appcmd.exe list apppool “plesk(default)(2.0)(pool)” /text:*&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;div&gt;Aparecerá a descrição completa desse pool. Procure a entrada referente ao usuário e senha do &lt;b&gt;Plesk &lt;/b&gt;conforme a figura abaixo:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjha8KMvfc87umhdxfUIpfl4ZoDs0CRuDxlhyphenhyphenYLOqzjkPj-YcLeFmdMAQUl4hWeIWMs_LMK1ZIGkfDc6ahKakU8NHXfuuH76Yw7TTyPIheHzqakZ7ZmLPEUS_PGpRPcWAXHEIrXCGC_tyFH/s1600/ii_pool_dados_plesk.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;133&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjha8KMvfc87umhdxfUIpfl4ZoDs0CRuDxlhyphenhyphenYLOqzjkPj-YcLeFmdMAQUl4hWeIWMs_LMK1ZIGkfDc6ahKakU8NHXfuuH76Yw7TTyPIheHzqakZ7ZmLPEUS_PGpRPcWAXHEIrXCGC_tyFH/s400/ii_pool_dados_plesk.png&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div&gt;Agora você tem a senha do usuário! No site de &lt;a href=&quot;http://www.dhirajranka.com/?tag=iis-application-pool-password&quot;&gt;Dhiraj&lt;/a&gt; tem mais detalhes acerca desse tipo de recuperação.&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://thiagomarcal.blogspot.com/feeds/6629779308605983674/comments/default' title='Postar comentários'/><link rel='replies' type='text/html' href='http://thiagomarcal.blogspot.com/2011/09/recuperando-senha-da-conta-identidade.html#comment-form' title='0 Comentários'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7002820434209519335/posts/default/6629779308605983674'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7002820434209519335/posts/default/6629779308605983674'/><link rel='alternate' type='text/html' href='http://thiagomarcal.blogspot.com/2011/09/recuperando-senha-da-conta-identidade.html' title='Recuperando a senha da conta identidade do Pool de Aplicativos do Plesk no IIS'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjha8KMvfc87umhdxfUIpfl4ZoDs0CRuDxlhyphenhyphenYLOqzjkPj-YcLeFmdMAQUl4hWeIWMs_LMK1ZIGkfDc6ahKakU8NHXfuuH76Yw7TTyPIheHzqakZ7ZmLPEUS_PGpRPcWAXHEIrXCGC_tyFH/s72-c/ii_pool_dados_plesk.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7002820434209519335.post-8544325459942963646</id><published>2011-09-03T22:40:00.000-03:00</published><updated>2011-09-03T22:40:01.131-03:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="crystal reports"/><category scheme="http://www.blogger.com/atom/ns#" term="dicas"/><title type='text'>Calculando saldo final no Crystal Reports</title><content type='html'>Antes de começar o artigo, queria dizer que nesse mês irei responder muitas das questões que recebo por e-mail (calma que um dia sempre respondo) em forma de artigo, então muitos deles serão curtos e rápidos. Uma das respostas será nesse artigo.&lt;br /&gt;
Bem, como calculo o saldo, linha a linha, de entradas e saídas no Crystal Reports? De forma bem simples: uso de variáveis globais. Um bom artigo que sempre recomendo é o de &lt;a href=&quot;http://aspalliance.com/1940_Using_Variables_Within_Crystal_Report_Formulas.5&quot;&gt;Vince Varallo&lt;/a&gt;: não tem erro!&lt;br /&gt;
Supondo que você tenha o seguinte relatório e com os respectivos campos:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi1rFv5yclZE_L9k4WIDq_JmQSr-YERWQH1YglMDn_TKyMt0awErNrzqjRwFv1bCe_lix38V_wNCe81pd3ngAXeY2VSqiduk2QiLeti-vBSzqA0WCOKZLg50xRqFWWO627N9TrwRIXa6vVZ/s1600/relatorio_saldo_crystal_reports.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;182&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi1rFv5yclZE_L9k4WIDq_JmQSr-YERWQH1YglMDn_TKyMt0awErNrzqjRwFv1bCe_lix38V_wNCe81pd3ngAXeY2VSqiduk2QiLeti-vBSzqA0WCOKZLg50xRqFWWO627N9TrwRIXa6vVZ/s400/relatorio_saldo_crystal_reports.png&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
Esses dados já devem ser puxados do &lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;DataSet &lt;/span&gt;utilizado (na dúvida, veja o &lt;a href=&quot;http://thiagomarcal.blogspot.com/2010/09/gerando-relatorios-com-o-crystal.html&quot;&gt;post&lt;/a&gt; de criar relatórios). Agora adicionamos um &lt;b&gt;Formula Field&lt;/b&gt; com o nome &lt;i&gt;SALDO&lt;/i&gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgnsnEuSyJw7VXvzdcGVKm4f2YZbtbTwAtvXy4_biMnqW03j6WgqwpUzWFv31DM7wYMgF36ENL0qrdu6z6eex9hTGtM7rhVIluTqFYzZ8iIg-TP7sdvEymTefQw8b-YslLPxhkMK8ivh-64/s1600/formula_field_crystal_reports.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;82&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgnsnEuSyJw7VXvzdcGVKm4f2YZbtbTwAtvXy4_biMnqW03j6WgqwpUzWFv31DM7wYMgF36ENL0qrdu6z6eex9hTGtM7rhVIluTqFYzZ8iIg-TP7sdvEymTefQw8b-YslLPxhkMK8ivh-64/s320/formula_field_crystal_reports.png&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
Clique em &lt;b&gt;Use Editor &lt;/b&gt;e escreva a seguinte fórmula:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjIcbpbxRzn9vdR3L93H940bhyBIkZolyDUB8f6RO6nLryAjn42BkEItKybI-liJxTrLpY2RVQaVYSskV-JCGcuX2S-bOCwXdUe-FBW5Sz3nJwlsGgcdSi9uSQEjZkl6-WF29ScNHKkI9Ay/s1600/calculo_saldo_crystal_reports.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;226&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjIcbpbxRzn9vdR3L93H940bhyBIkZolyDUB8f6RO6nLryAjn42BkEItKybI-liJxTrLpY2RVQaVYSskV-JCGcuX2S-bOCwXdUe-FBW5Sz3nJwlsGgcdSi9uSQEjZkl6-WF29ScNHKkI9Ay/s320/calculo_saldo_crystal_reports.png&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;Global NumberVar&lt;/span&gt; SALDO_FINAL;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;if &lt;/span&gt;(&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;RECORDNUMBER &lt;/span&gt;= 1) &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;then&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; SALDO_FINAL := @ENTRADA - @SAIDA&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue; font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;else&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; SALDO_FINAL := SALDO_FINAL + @ENTRADA - @SAIDA&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Ou seja, na primeira linha obtenho o saldo inicial diminuindo a ENTRADA da SAIDA. Nos demais já adiciono o saldo anterior. Tranquilo? Agora basta adicionar no relatório esse campo criado.</content><link rel='replies' type='application/atom+xml' href='http://thiagomarcal.blogspot.com/feeds/8544325459942963646/comments/default' title='Postar comentários'/><link rel='replies' type='text/html' href='http://thiagomarcal.blogspot.com/2011/09/calculando-saldo-final-no-crystal.html#comment-form' title='0 Comentários'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7002820434209519335/posts/default/8544325459942963646'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7002820434209519335/posts/default/8544325459942963646'/><link rel='alternate' type='text/html' href='http://thiagomarcal.blogspot.com/2011/09/calculando-saldo-final-no-crystal.html' title='Calculando saldo final no Crystal Reports'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi1rFv5yclZE_L9k4WIDq_JmQSr-YERWQH1YglMDn_TKyMt0awErNrzqjRwFv1bCe_lix38V_wNCe81pd3ngAXeY2VSqiduk2QiLeti-vBSzqA0WCOKZLg50xRqFWWO627N9TrwRIXa6vVZ/s72-c/relatorio_saldo_crystal_reports.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7002820434209519335.post-2212950737188874087</id><published>2011-08-23T00:44:00.000-03:00</published><updated>2011-08-23T00:44:13.414-03:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="dicas"/><category scheme="http://www.blogger.com/atom/ns#" term="host"/><category scheme="http://www.blogger.com/atom/ns#" term="iis"/><category scheme="http://www.blogger.com/atom/ns#" term="site"/><category scheme="http://www.blogger.com/atom/ns#" term="web"/><title type='text'>Testando um Web-Site na própria máquina como se fosse externamente</title><content type='html'>Tentei elaborar um título de forma que ficasse entendível o que eu queria dizer. Não sei se ajuda, mas significa que:&lt;br /&gt;
&lt;blockquote&gt;&lt;b&gt;&quot;Testaremos o acesso a um web-site que está publicado no IIS mas que no navegador não iremos usar localhost para buscá-lo e sim o próprio endereço.&quot;&lt;/b&gt;&lt;/blockquote&gt;Ficou bom agora? Então vamos lá. No &lt;b&gt;IIS&lt;/b&gt; crie um &lt;i&gt;web-site&lt;/i&gt;. O processo é bem simples:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjzLIOv6mwEvp7PgvcjWquzgBRmER0RKJkfgl54NCLSgmw3UDUQnXF9OnO9wZwEBA8eA9TZTzwCHIraQJnauntQ-HxXVorCprepb2nF-dLQX1eQzQ9is-Diwrt75cfOZ43-k39dKoVPHM_c/s1600/iis_criar_site.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;193&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjzLIOv6mwEvp7PgvcjWquzgBRmER0RKJkfgl54NCLSgmw3UDUQnXF9OnO9wZwEBA8eA9TZTzwCHIraQJnauntQ-HxXVorCprepb2nF-dLQX1eQzQ9is-Diwrt75cfOZ43-k39dKoVPHM_c/s400/iis_criar_site.png&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
Pronto! Já temos nosso site, mas se formos testar: &lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;http://thiagomarcal.com.br/&lt;/span&gt; não encontra!&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi49LkGFNxbt2MlidMLZIUuyF4W_oJscoeeiIDzHRQMiUbPxs4rhkVwcsRIrhWHo8aGyufnyX4lUG4x09aBkRIACD0VQO5yiA1_GHbsFo7FPOKbVMtxOOMg-4vi3dU8ZLGk6KxrKz9t3A34/s1600/erro_busca_site.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;275&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi49LkGFNxbt2MlidMLZIUuyF4W_oJscoeeiIDzHRQMiUbPxs4rhkVwcsRIrhWHo8aGyufnyX4lUG4x09aBkRIACD0VQO5yiA1_GHbsFo7FPOKbVMtxOOMg-4vi3dU8ZLGk6KxrKz9t3A34/s400/erro_busca_site.png&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
Por que isso? Quando queremos procurar um site, o sistema operacional analisa o &lt;a href=&quot;http://en.wikipedia.org/wiki/Hostname&quot;&gt;hostname&lt;/a&gt; para saber onde encontrar esse endereço: se for interno e mapeado usa-se a rede interna, senão procura a rede externa dentre outros. Como não existe o mapeamento e tampouco o domínio externo, não acha nada. Então vamos alterar o arquivo de &lt;i&gt;host&lt;/i&gt;.&lt;br /&gt;
&lt;br /&gt;
Siga para o caminho:&amp;nbsp;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;C:\Windows\System32\drivers\etc&lt;/span&gt; e abra o arquivo &lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;hosts&lt;/span&gt;, em modo texto, para adicionarmos algumas entradas.&lt;br /&gt;
&lt;br /&gt;
&lt;pre style=&quot;background-attachment: initial; background-clip: initial; background-color: #eeeeee; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; font-family: Consolas, Menlo, Monaco, &#39;Lucida Console&#39;, &#39;Liberation Mono&#39;, &#39;DejaVu Sans Mono&#39;, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, monospace, serif; font-size: 14px; margin-bottom: 10px; max-height: 600px; overflow-x: auto; overflow-y: auto; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; padding-top: 5px; vertical-align: baseline; width: auto;&quot;&gt;# copyright (c) 1993-2009 microsoft corp.
#
# this is a sample hosts file used by microsoft tcp/ip for windows.
#
# this file contains the mappings of ip addresses to host names. each
# entry should be kept on an individual line. the ip address should
# be placed in the first column followed by the corresponding host name.
# the ip address and the host name should be separated by at least one
# space.
#
# additionally, comments (such as these) may be inserted on individual
# lines or following the machine name denoted by a &#39;#&#39; symbol.
#
# for example:
#
#      102.54.94.97     rhino.acme.com          # source server
#       38.25.63.10     x.acme.com              # x client host

# localhost name resolution is handled within dns itself.
#	127.0.0.1       localhost
#	::1             localhost

127.0.0.1	thiagomarcal.com.br&lt;/pre&gt;&lt;br /&gt;
Coloque, na última linha, o IP, tabulação e nome do domínio nessa ordem para o site desejado. Salve e teste novamente o acesso. E pronto!&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgQn7T7yPwbxQR9GoJ8rFV7ri_EMBHV31mi4sw3k4YRRBEWjW7rczp5L-96HLbeRuAUXBu0KBG2Ot403D49btlTS_wpWogcyvik1eLo5PMAL2eT0E_xqYcHb83pnOD31UW06qqPsugc33AV/s1600/thiago_marcal_site.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;248&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgQn7T7yPwbxQR9GoJ8rFV7ri_EMBHV31mi4sw3k4YRRBEWjW7rczp5L-96HLbeRuAUXBu0KBG2Ot403D49btlTS_wpWogcyvik1eLo5PMAL2eT0E_xqYcHb83pnOD31UW06qqPsugc33AV/s400/thiago_marcal_site.png&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
Mais fácil do que isso: impossível!</content><link rel='replies' type='application/atom+xml' href='http://thiagomarcal.blogspot.com/feeds/2212950737188874087/comments/default' title='Postar comentários'/><link rel='replies' type='text/html' href='http://thiagomarcal.blogspot.com/2011/08/testando-um-web-site-na-propria-maquina.html#comment-form' title='0 Comentários'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7002820434209519335/posts/default/2212950737188874087'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7002820434209519335/posts/default/2212950737188874087'/><link rel='alternate' type='text/html' href='http://thiagomarcal.blogspot.com/2011/08/testando-um-web-site-na-propria-maquina.html' title='Testando um Web-Site na própria máquina como se fosse externamente'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjzLIOv6mwEvp7PgvcjWquzgBRmER0RKJkfgl54NCLSgmw3UDUQnXF9OnO9wZwEBA8eA9TZTzwCHIraQJnauntQ-HxXVorCprepb2nF-dLQX1eQzQ9is-Diwrt75cfOZ43-k39dKoVPHM_c/s72-c/iis_criar_site.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7002820434209519335.post-5491013475615190223</id><published>2011-08-21T11:35:00.001-03:00</published><updated>2011-08-28T16:32:28.293-03:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="dicas"/><category scheme="http://www.blogger.com/atom/ns#" term="php"/><category scheme="http://www.blogger.com/atom/ns#" term="visual studio"/><category scheme="http://www.blogger.com/atom/ns#" term="web-service"/><category scheme="http://www.blogger.com/atom/ns#" term="wsdl"/><title type='text'>Consumindo Web-Service PHP através do ASP.NET (C#)</title><content type='html'>Já passou por aqui um &lt;a href=&quot;http://thiagomarcal.blogspot.com/2011/02/calculando-frete-com-web-service-dos.html&quot;&gt;post&lt;/a&gt; sobre de como consumir um web-service, mas era em ASP.NET. Agora como consumir um web-service em PHP? Da mesma forma. Não muda! O fato de escrever esse post é apenas e pelo simples fato de ter um certo&amp;nbsp;inconveniente&amp;nbsp;na elaboração do web-service em PHP.&lt;br /&gt;
Se procurar na net, recomendo o artigo de &lt;a href=&quot;http://imasters.com.br/artigo/4535/php/construindo_web_services_em_php/&quot;&gt;Maurício Reckziegel&lt;/a&gt; da &lt;a href=&quot;http://imasters.com.br/&quot;&gt;iMasters&lt;/a&gt;&amp;nbsp;que é muito bom e explica certinho como fazer. Se você seguir à risca o que está escrito irá conseguir elaborar um web-service em PHP normalmente e irá conseguir consumir, menos em ASP.NET. Não é que a matéria esteja errada, é porque o ASP.NET é chato com a validação do &lt;a href=&quot;http://www.w3.org/TR/wsdl&quot;&gt;WSDL&lt;/a&gt;&amp;nbsp;que é gerado pelo PHP. O documento (WSDL) tem que ser gerado na mão e, quando não é gerado de forma automática, estamos susceptíveis ao erro. Com o web-service em PHP é assim...&lt;br /&gt;
Então, digamos que você tenha elaborado o web-service em PHP e já fez referência na sua aplicação. Contudo sua aplicação pode dar erro ou retornar nada. Primeiramente, todo WSDL que iremos usar deve ser validado antes de ser devidamente consumido. O &lt;b&gt;Visual Studio&lt;/b&gt; dispõe de uma ferramenta que valida e gera a classe consumidora (que não precisar ser usada pois está&amp;nbsp;intrínseco na ferramenta). Vá em &lt;b&gt;Iniciar &lt;/b&gt;&amp;gt; &lt;b&gt;Todos os Programas&lt;/b&gt; &amp;gt; &lt;b&gt;Microsoft Visual Studio&lt;/b&gt; &amp;gt;&amp;nbsp;&lt;b&gt;Visual Studio Tools&lt;/b&gt; &amp;gt;&amp;nbsp;&lt;b&gt;Visual Studio 2008 Command Prompt&lt;/b&gt;. Irá abrir um prompt de comando. Escreva por exemplo: wsdl http://thiagomarcal.blogspot.com/webservice.php?wsdl . Se der tudo certo, irá surgir um resultado semelhante a esse:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjiHvgfuHTVrqhFfA6U3CMmhIU_TKzr3ZBAHfb1VfQuEHW-EUPGdkhjgqgPyh08Z6spg4AV3f2DOH-WhjzqrJ0v8dMKPFhJ2fKRfwZlDcTVADmI4eYv-KB10J4OC41Lfihs73NMCPAorQEo/s1600/wsdl_validacao_weservice_php.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;200&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjiHvgfuHTVrqhFfA6U3CMmhIU_TKzr3ZBAHfb1VfQuEHW-EUPGdkhjgqgPyh08Z6spg4AV3f2DOH-WhjzqrJ0v8dMKPFhJ2fKRfwZlDcTVADmI4eYv-KB10J4OC41Lfihs73NMCPAorQEo/s400/wsdl_validacao_weservice_php.jpg&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
Se estiver tudo OK, então pode usar tranquilamente, caso contrário irá surgir o seguinte problema:&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;background-color: white; font-family: Arial, &#39;Liberation Sans&#39;, &#39;DejaVu Sans&#39;, sans-serif; font-size: 14px; line-height: 18px;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;pre style=&quot;background-attachment: initial; background-clip: initial; background-color: #eeeeee; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; font-family: Consolas, Menlo, Monaco, &#39;Lucida Console&#39;, &#39;Liberation Mono&#39;, &#39;DejaVu Sans Mono&#39;, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, monospace, serif; font-size: 14px; margin-bottom: 10px; max-height: 600px; overflow-x: auto; overflow-y: auto; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; padding-top: 5px; vertical-align: baseline; width: auto;&quot;&gt;Microsoft (R) Web Services Description Language Utility
[Microsoft (R) .NET Framework, Version 2.0.50727.3038]
Copyright (C) Microsoft Corporation. All rights reserved.

Warning: This web reference does not conform to WS-I Basic Profile v1.1.&lt;/pre&gt;&lt;br /&gt;
Ou seja, o WSDL gerado pelo PHP não está conforme o padrão. Dando uma alterada aqui e ali, podemos usar o seguinte código para gerarmos o web-service em PHP dentro dos conformes:&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red; font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;lt;?php&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #38761d; font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;// Requerimento aos componentes&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;require_once&lt;/span&gt;(&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red;&quot;&gt;&#39;nusoap/nusoap.php&#39;&lt;/span&gt;);&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;include&lt;/span&gt;(&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red;&quot;&gt;&quot;class.phpmailer.php&quot;&lt;/span&gt;);&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;include&lt;/span&gt;(&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red;&quot;&gt;&quot;class.smtp.php&quot;&lt;/span&gt;);&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #38761d; font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;// Criação da instância&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;$server = &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #674ea7;&quot;&gt;new &lt;/span&gt;soap_server();&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #38761d; font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;// Registro do método&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;$server-&amp;gt;register(&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red;&quot;&gt;&#39;EnviaMail&#39;&lt;/span&gt;);&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #38761d; font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;// WSDL&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;$server-&amp;gt;configureWSDL(&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red;&quot;&gt;&#39;server.EnviaMail&#39;,&#39;urn:server.EnviaMail&#39;&lt;/span&gt;);&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;$server-&amp;gt;wsdl-&amp;gt;schemaTargetNamespace = &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red;&quot;&gt;&#39;urn:server.EnviaMail&#39;&lt;/span&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #38761d; font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;// registra o método a ser oferecido&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;$server-&amp;gt;register(&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red;&quot;&gt;&#39;EnviaMail&#39;&lt;/span&gt;, &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #38761d;&quot;&gt;//nome do método&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;array&lt;/span&gt;(&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red;&quot;&gt;&#39;email&#39;&lt;/span&gt; =&amp;gt; &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red;&quot;&gt;&#39;xsd:string&#39;&lt;/span&gt;), &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #38761d;&quot;&gt;//parâmetros de entrada&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;array&lt;/span&gt;(&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red;&quot;&gt;&#39;return&#39;&lt;/span&gt; =&amp;gt; &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red;&quot;&gt;&#39;xsd:string&#39;&lt;/span&gt;), &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #38761d;&quot;&gt;//parâmetros de saída&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red;&quot;&gt;&#39;urn:server.EnviaMail&#39;&lt;/span&gt;, &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #38761d;&quot;&gt;//namespace&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red;&quot;&gt;&#39;urn:server.EnviaMail#EnviaMail&#39;&lt;/span&gt;, &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #38761d;&quot;&gt;//soapaction&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red;&quot;&gt;&#39;rpc&#39;&lt;/span&gt;, &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #38761d;&quot;&gt;//style&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red;&quot;&gt;&#39;literal&#39;&lt;/span&gt;, &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #38761d;&quot;&gt;//use&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red;&quot;&gt;&#39;Retorna se o e-mail foi enviado&#39;&lt;/span&gt; &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #38761d;&quot;&gt;//documentação do serviço&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;);&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #38761d; font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;// Definição do método a ser utilizado&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;function &lt;/span&gt;EnviaMail($email) {&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;return &lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red;&quot;&gt;&quot;E-email enviado com sucesso!&quot;&lt;/span&gt;; &lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #38761d; font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;// Requisição para uso do serviço&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;$HTTP_RAW_POST_DATA = &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;isset&lt;/span&gt;($HTTP_RAW_POST_DATA) ? $HTTP_RAW_POST_DATA : &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red;&quot;&gt;&#39;&#39;&lt;/span&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;$server-&amp;gt;service($HTTP_RAW_POST_DATA);&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red; font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;?&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
Perceberam a diferença? Praticamente nenhuma, mas há: o estilo do documento. Não irei entrar em detalhes, mas dois tipos de documentos mais usados: &lt;b&gt;encoded &lt;/b&gt;e &lt;b&gt;literal &lt;/b&gt;(veja mais nesse &lt;a href=&quot;http://www.ibm.com/developerworks/webservices/library/ws-whichwsdl/&quot;&gt;artigo&lt;/a&gt;). Use &lt;i&gt;literal&lt;/i&gt;! Com isso seu web-service será consumido certinho...&lt;br /&gt;
Se estiver com o erro:&amp;nbsp;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;O cliente encontrou o tipo conteúdo de resposta de &#39; text/html; charset = utf-8 &#39;, mas era esperado &#39;text/xml&#39;&lt;/span&gt; ou&amp;nbsp;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;The client find the answer &#39;text/html&#39;, but was expected &#39;text/xml&#39;&lt;/span&gt;. verifique se seu web-service está imprimindo conteúdo HTML (&lt;b&gt;echo&lt;/b&gt;) e comprometendo o retorno dos dados. Tranquilo, né?</content><link rel='replies' type='application/atom+xml' href='http://thiagomarcal.blogspot.com/feeds/5491013475615190223/comments/default' title='Postar comentários'/><link rel='replies' type='text/html' href='http://thiagomarcal.blogspot.com/2011/08/consumindo-web-service-php-atraves-do.html#comment-form' title='2 Comentários'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7002820434209519335/posts/default/5491013475615190223'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7002820434209519335/posts/default/5491013475615190223'/><link rel='alternate' type='text/html' href='http://thiagomarcal.blogspot.com/2011/08/consumindo-web-service-php-atraves-do.html' title='Consumindo Web-Service PHP através do ASP.NET (C#)'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjiHvgfuHTVrqhFfA6U3CMmhIU_TKzr3ZBAHfb1VfQuEHW-EUPGdkhjgqgPyh08Z6spg4AV3f2DOH-WhjzqrJ0v8dMKPFhJ2fKRfwZlDcTVADmI4eYv-KB10J4OC41Lfihs73NMCPAorQEo/s72-c/wsdl_validacao_weservice_php.jpg" height="72" width="72"/><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7002820434209519335.post-2008180009962696790</id><published>2011-07-28T20:01:00.000-03:00</published><updated>2011-07-28T20:01:33.132-03:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="banco de dados"/><category scheme="http://www.blogger.com/atom/ns#" term="desempenho"/><category scheme="http://www.blogger.com/atom/ns#" term="dicas"/><category scheme="http://www.blogger.com/atom/ns#" term="sql server"/><title type='text'>Problemas de cache no SQL Server</title><content type='html'>Se você estiver recebendo uma mensagem do tipo:&lt;br /&gt;
&lt;br /&gt;
&lt;blockquote&gt;&lt;b&gt;&lt;i&gt;O SQL Server encontrou %d ocorrência(s) de liberação de armazenamento em cache para o cache &#39;%s&#39; (parte do cache do esquema) devido à manutenção do banco de dados ou operações de reconfiguração.&lt;/i&gt;&lt;/b&gt;&lt;/blockquote&gt;ou&lt;br /&gt;
&lt;blockquote&gt;&lt;b&gt;&lt;i&gt;SQL Server has encountered %d occurrence(s) of cachestore flush for the &#39;%s&#39; cachestore (part of plan cache) due to some database maintenance or reconfigure operations.&lt;/i&gt;&lt;/b&gt;&lt;/blockquote&gt;É porque, segundo a &lt;a href=&quot;http://msdn.microsoft.com/en-us/library/ms174269.aspx&quot;&gt;MSDN&lt;/a&gt;,&amp;nbsp;ao limpar o cache do plano gera uma recompilação de todos os planos de execução subseqüentes e pode&amp;nbsp;provocar uma queda repentina e temporária no desempenho da consulta. Para cada armazenamento em cache limpo no cache do plano, aparece a mensagem supracitada.&lt;br /&gt;
&lt;br /&gt;
Para resolver isso, basta ir no banco correspondente, clicar com o direito sobre ele e escolher &lt;b&gt;Properties &lt;/b&gt;(&lt;b&gt;Propriedades&lt;/b&gt;). Entre em &lt;b&gt;Options &lt;/b&gt;(&lt;b&gt;Opções&lt;/b&gt;) e configure o&amp;nbsp;&lt;b&gt;Auto-Close&lt;/b&gt; (&lt;b&gt;Fechamento Automático&lt;/b&gt;) para &lt;b&gt;False&lt;/b&gt;.</content><link rel='replies' type='application/atom+xml' href='http://thiagomarcal.blogspot.com/feeds/2008180009962696790/comments/default' title='Postar comentários'/><link rel='replies' type='text/html' href='http://thiagomarcal.blogspot.com/2011/07/problemas-de-cache-no-sql-server.html#comment-form' title='0 Comentários'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7002820434209519335/posts/default/2008180009962696790'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7002820434209519335/posts/default/2008180009962696790'/><link rel='alternate' type='text/html' href='http://thiagomarcal.blogspot.com/2011/07/problemas-de-cache-no-sql-server.html' title='Problemas de cache no SQL Server'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7002820434209519335.post-8768276729399318048</id><published>2011-07-21T01:19:00.000-03:00</published><updated>2011-07-21T01:19:49.020-03:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="asp"/><category scheme="http://www.blogger.com/atom/ns#" term="erros"/><category scheme="http://www.blogger.com/atom/ns#" term="iis"/><category scheme="http://www.blogger.com/atom/ns#" term="segurança"/><category scheme="http://www.blogger.com/atom/ns#" term="web.config"/><title type='text'>Error 500 Internal Server Error - Como descobrir o problema</title><content type='html'>Quando dá esse erro muitas pessoas tremem só de ver! Abaixo darei uma dica para quem é marinheiro de primeira viagem e se depara com isso.&lt;br /&gt;
&lt;br /&gt;
Essa tela é gerada pelo &lt;b&gt;IIS &lt;/b&gt;para camuflar o erro para o usuário. Se a aplicação não for bem tratada quanto a erros, esse é o último recurso que o IIS faz para não exibir o erro na tela. Seria bem incômodo para o usuário ver na tela o erro de seu site, por exemplo. Para quem está gerenciando a aplicação é incômodo até certa parte, pois muitas vezes o desenvolvedor resolve o problema mais olhando o erro do que analisando &lt;i&gt;log&lt;/i&gt;, &lt;i&gt;events&lt;/i&gt;, etc. Pois bem, vamos lá!&lt;br /&gt;
&lt;br /&gt;
Abra o IIS e procure pela função &lt;b&gt;Error Pages&lt;/b&gt; (&lt;b&gt;Páginas de Erro&lt;/b&gt;) no módulo &lt;b&gt;IIS&lt;/b&gt;. Entre e procure pelo &lt;i&gt;link&amp;nbsp;&lt;/i&gt;&lt;b&gt;Edit Resource &amp;nbsp;Settings&lt;/b&gt; (&lt;b&gt;Editar Configurações de Recurso&lt;/b&gt;). Ao abrir, a tela de&amp;nbsp;&lt;b&gt;Edit Error Pages Settings&lt;/b&gt; (&lt;b&gt;Editar Configurações de Página de Erro&lt;/b&gt;) escolha a opção&amp;nbsp;&lt;b&gt;Detailed errors&lt;/b&gt; (&lt;b&gt;Erros detalhados&lt;/b&gt;) e &lt;b&gt;OK&lt;/b&gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjmcQGwzcTdNVXEb0u1GDACbiNTVffKdA4b9wN4Xzu_On0Wyd_RHPrCGrv313pubn5zhgpsZQaazmTXKUrU7tfqfDRUkpwE8arTxgIRdwFYhFEM8Dz7EztwnZ_u-kD6m3ZvyBD3klPjddkB/s1600/conf_iis_pagina_erro.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;292&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjmcQGwzcTdNVXEb0u1GDACbiNTVffKdA4b9wN4Xzu_On0Wyd_RHPrCGrv313pubn5zhgpsZQaazmTXKUrU7tfqfDRUkpwE8arTxgIRdwFYhFEM8Dz7EztwnZ_u-kD6m3ZvyBD3klPjddkB/s320/conf_iis_pagina_erro.png&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
Ou, mais especificamente para o ASP.NET, procure a função &lt;b&gt;.NET Error Pages&lt;/b&gt; (&lt;b&gt;Páginas de Erro do .NET&lt;/b&gt;) no módulo &lt;b&gt;ASP.NET&lt;/b&gt;.&amp;nbsp;Entre e procure pelo&amp;nbsp;&lt;i&gt;link&amp;nbsp;&lt;/i&gt;&lt;b&gt;Edit Resource &amp;nbsp;Settings&lt;/b&gt;&amp;nbsp;(&lt;b&gt;Editar Configurações de Recurso&lt;/b&gt;). Ao abrir, a tela de&amp;nbsp;&lt;b&gt;Edit Error Pages Settings&lt;/b&gt;&amp;nbsp;(&lt;b&gt;Editar Configurações de Página de Erro&lt;/b&gt;) escolha a opção&amp;nbsp;&lt;b&gt;Desactive&lt;/b&gt;&amp;nbsp;(&lt;b&gt;Desativar&lt;/b&gt;) e&amp;nbsp;&lt;b&gt;OK&lt;/b&gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhiFAgmDPPhT0UFHQgtjKd9Pa3f02XqK6w38lULa49bOau3GYOnhy0SU1UpAq9PO-0q7REyTfuNKVXfnEEd16SRbOGY3nJVwgzCWsYzWP3uIcDiteg_kO4u1_LFc-WtrPKKXadDykT0mYyE/s1600/conf_iis_pagina_erro_aspnet.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;218&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhiFAgmDPPhT0UFHQgtjKd9Pa3f02XqK6w38lULa49bOau3GYOnhy0SU1UpAq9PO-0q7REyTfuNKVXfnEEd16SRbOGY3nJVwgzCWsYzWP3uIcDiteg_kO4u1_LFc-WtrPKKXadDykT0mYyE/s320/conf_iis_pagina_erro_aspnet.png&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
Com isso, a depender do erro, já estarão sendo enviados para a tela. Lembram do &lt;i&gt;&lt;a href=&quot;http://thiagomarcal.blogspot.com/2010/09/vulnerabilidade-de-seguranca-no-aspnet.html&quot;&gt;post&lt;/a&gt; &lt;/i&gt;sobre segurança? No &lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;web.config&lt;/span&gt;, deixe o &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #990000; font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;customErrors &lt;/span&gt;com o atributo &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #cc0000; font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;mode&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue; font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;=&quot;Off&quot;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&amp;nbsp;caso necessário para que os erros sejam exibidos&lt;/span&gt;.&lt;br /&gt;
&lt;br /&gt;
Caso ainda não tenha descoberto o problema, acesse a configuração do &lt;b&gt;ASP &amp;nbsp;&lt;/b&gt;no módulo &lt;b&gt;IIS&lt;/b&gt;. Expanda a propriedade &lt;b&gt;Debugging Properties&lt;/b&gt; (&lt;b&gt;Propriedades de Depuração&lt;/b&gt;) e coloque como &lt;b&gt;True &lt;/b&gt;a função&amp;nbsp;&lt;b&gt;Send Errors to Browser&lt;/b&gt; (&lt;b&gt;Enviar Erros ao Navegador&lt;/b&gt;).&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg09QD_YKb8zzccBpnr4gfAIHTb85rGnRn_0ERJqNg59YkEqicYZ4OhQOtGLV5YX6fqWFRc87AS465z4B7PiiRmIZbDnM8bpA_d1cyVMCZH2qSzXe6GUbOcamNwZ8mnwfYI4atzHwrsZd1Z/s1600/conf_asp_enviar_erros_navegador.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;242&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg09QD_YKb8zzccBpnr4gfAIHTb85rGnRn_0ERJqNg59YkEqicYZ4OhQOtGLV5YX6fqWFRc87AS465z4B7PiiRmIZbDnM8bpA_d1cyVMCZH2qSzXe6GUbOcamNwZ8mnwfYI4atzHwrsZd1Z/s400/conf_asp_enviar_erros_navegador.png&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
Isso deve ser mais do que o suficiente para exibir o erro e identificar qual o problema está na aplicação. Lembrando que, se preferível, não deixar o erro ser exibido para o cliente. Deve-se fazer o possível para tratar e localizar adequadamente o problema. Segurança em primeiro lugar!</content><link rel='replies' type='application/atom+xml' href='http://thiagomarcal.blogspot.com/feeds/8768276729399318048/comments/default' title='Postar comentários'/><link rel='replies' type='text/html' href='http://thiagomarcal.blogspot.com/2011/07/error-500-internal-server-error-como.html#comment-form' title='1 Comentários'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7002820434209519335/posts/default/8768276729399318048'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7002820434209519335/posts/default/8768276729399318048'/><link rel='alternate' type='text/html' href='http://thiagomarcal.blogspot.com/2011/07/error-500-internal-server-error-como.html' title='Error 500 Internal Server Error - Como descobrir o problema'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjmcQGwzcTdNVXEb0u1GDACbiNTVffKdA4b9wN4Xzu_On0Wyd_RHPrCGrv313pubn5zhgpsZQaazmTXKUrU7tfqfDRUkpwE8arTxgIRdwFYhFEM8Dz7EztwnZ_u-kD6m3ZvyBD3klPjddkB/s72-c/conf_iis_pagina_erro.png" height="72" width="72"/><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7002820434209519335.post-4952980436256637748</id><published>2011-07-21T00:41:00.001-03:00</published><updated>2011-07-21T01:25:33.502-03:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="cufon"/><category scheme="http://www.blogger.com/atom/ns#" term="dicas"/><category scheme="http://www.blogger.com/atom/ns#" term="javascript"/><category scheme="http://www.blogger.com/atom/ns#" term="jquery"/><category scheme="http://www.blogger.com/atom/ns#" term="master page"/><title type='text'>Cufon na Master Page</title><content type='html'>Para quem está com problemas no carregamento/aplicação do &lt;b&gt;&lt;a href=&quot;https://github.com/sorccu/cufon/&quot;&gt;Cufon&lt;/a&gt;&lt;/b&gt;&amp;nbsp;quando estiver usando &lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;Master Page&lt;/span&gt;, chame-o da seguinte forma:&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #990000; font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;lt;script&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;Cufon.now();&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;function&lt;/span&gt; pageLoad(sender, args) {&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; Cufon.refresh();&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #990000; font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;lt;/script&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
Assim ele aplica corretamente após o carregamento da página.</content><link rel='replies' type='application/atom+xml' href='http://thiagomarcal.blogspot.com/feeds/4952980436256637748/comments/default' title='Postar comentários'/><link rel='replies' type='text/html' href='http://thiagomarcal.blogspot.com/2011/07/cufon-na-master-page.html#comment-form' title='0 Comentários'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7002820434209519335/posts/default/4952980436256637748'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7002820434209519335/posts/default/4952980436256637748'/><link rel='alternate' type='text/html' href='http://thiagomarcal.blogspot.com/2011/07/cufon-na-master-page.html' title='Cufon na Master Page'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7002820434209519335.post-4205857279297885174</id><published>2011-07-20T09:00:00.011-03:00</published><updated>2011-07-21T01:26:31.448-03:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="ajax"/><category scheme="http://www.blogger.com/atom/ns#" term="dicas"/><title type='text'>Out of Memory at Line - Memória Insuficiente</title><content type='html'>Dica rápida para quem tiver esse tipo de problema: remova o atributo&amp;nbsp;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #990000;&quot;&gt;LoadScriptsBeforeUI&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;=&#39;false&#39;&lt;/span&gt;&lt;/span&gt; from &lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;ScriptManager&lt;/span&gt;. Dentro de &lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;Grid &lt;/span&gt;editáveis ou em formulários dinâmicos a validação do &lt;b&gt;Javascript &lt;/b&gt;falha quando estiver fazendo esse tipo de otimização.</content><link rel='replies' type='application/atom+xml' href='http://thiagomarcal.blogspot.com/feeds/4205857279297885174/comments/default' title='Postar comentários'/><link rel='replies' type='text/html' href='http://thiagomarcal.blogspot.com/2011/07/out-of-memory-at-line-memoria.html#comment-form' title='0 Comentários'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7002820434209519335/posts/default/4205857279297885174'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7002820434209519335/posts/default/4205857279297885174'/><link rel='alternate' type='text/html' href='http://thiagomarcal.blogspot.com/2011/07/out-of-memory-at-line-memoria.html' title='Out of Memory at Line - Memória Insuficiente'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7002820434209519335.post-1108085663288453030</id><published>2011-07-17T20:08:00.000-03:00</published><updated>2011-07-17T20:08:44.976-03:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="analytics"/><category scheme="http://www.blogger.com/atom/ns#" term="api"/><category scheme="http://www.blogger.com/atom/ns#" term="google"/><category scheme="http://www.blogger.com/atom/ns#" term="integração"/><title type='text'>Integração ASP.NET (C#) com o Google Analytics</title><content type='html'>Nesse artigo irei demonstrar como fazer consultas no &lt;b&gt;&lt;a href=&quot;http://www.google.com/intl/pt-BR/analytics/&quot;&gt;Google Analytics&lt;/a&gt;&lt;/b&gt;, de um determinado &lt;i&gt;site&lt;/i&gt;, para ser usado em cálculos estatísticos afim de gerar gráficos semelhantes. Ou seja, irei demonstrar como fazer a consulta e retornar os dados. Os gráficos e exposição dos dados ficará ao seu critério. Ao final poderá ter algo assim:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhy5I_x0pEash-vHWgFCyw36_-qK2-BKVRz3Wl-FY03epuOcHiv7bfKPGDGWdcKIJxI0xqjer5Dp0P6mdWPowBeTY259MyGJRAP0bv7m9xBWEwAirF-1UGZMGGK-ZHskOshqO-zrqQG8RhA/s1600/google_analytics_painel_integracao.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;218&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhy5I_x0pEash-vHWgFCyw36_-qK2-BKVRz3Wl-FY03epuOcHiv7bfKPGDGWdcKIJxI0xqjer5Dp0P6mdWPowBeTY259MyGJRAP0bv7m9xBWEwAirF-1UGZMGGK-ZHskOshqO-zrqQG8RhA/s400/google_analytics_painel_integracao.png&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
Primeiramente e óbvio, é preciso dos dados da conta Google como o e-mail e senha para autenticação. Cada &lt;i&gt;site &lt;/i&gt;cadastrado no &lt;b&gt;Analytics &lt;/b&gt;tem um &lt;b&gt;ID do Perfil&lt;/b&gt; e ele pode ser localizado na seguinte página &amp;nbsp;de &lt;b&gt;Configurações do Perfil&lt;/b&gt;. Através desse &lt;i&gt;Id&lt;/i&gt; é que consultamos os dados de um determinado &lt;i&gt;site&lt;/i&gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi3b7ZINbjOXCB4tmIOQgckUm0pYw_lK8b_f7OLzrDk-gDFl0132a1pGDMCAEJcUA8INzJXRdyOGpm_X_qeiB3GHMo8wdbyYTZtFpOxyN1cJWilgW6HiXdSyZQKhW6aZNMsrsHcG6kBpMe5/s1600/perfil_id_analytics.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;101&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi3b7ZINbjOXCB4tmIOQgckUm0pYw_lK8b_f7OLzrDk-gDFl0132a1pGDMCAEJcUA8INzJXRdyOGpm_X_qeiB3GHMo8wdbyYTZtFpOxyN1cJWilgW6HiXdSyZQKhW6aZNMsrsHcG6kBpMe5/s400/perfil_id_analytics.png&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
Com esses dados em mãos, vamos ao entendimento da integração. O &lt;a href=&quot;http://www.google.com.br/&quot;&gt;Google&lt;/a&gt; disponibilizou um &lt;i&gt;framework &lt;/i&gt;que auxilia na consulta e retorno de dados em .NET e ela pode ser baixada no &lt;b&gt;&lt;a href=&quot;http://code.google.com/p/google-gdata/&quot;&gt;Google GData&lt;/a&gt;&lt;/b&gt;. Dentro dela contêm vários binários mas precisaremos apenas dos seguintes:&lt;br /&gt;
&lt;br /&gt;
&lt;ol&gt;&lt;li&gt;Google.GData.Analytics.dll&lt;/li&gt;
&lt;li&gt;Google.GData.Client.dll&lt;/li&gt;
&lt;li&gt;Google.GData.Extensions.dll&lt;/li&gt;
&lt;/ol&gt;&lt;br /&gt;
Adicione-os ao seu projeto. Mas antes de começar a programar isso, vamos ao entendimento das consultas realizadas. No &lt;i&gt;link&amp;nbsp;&lt;/i&gt;&lt;a href=&quot;http://code.google.com/intl/pt-BR/apis/analytics/docs/gdata/gdataExplorer.html&quot;&gt;http://code.google.com/intl/pt-BR/apis/analytics/docs/gdata/gdataExplorer.html&lt;/a&gt;&amp;nbsp;tem um simulador que será similar à consulta feita pela sua aplicação. Já no &lt;i&gt;link&amp;nbsp;&lt;/i&gt;&lt;a href=&quot;http://code.google.com/intl/pt-BR/apis/analytics/docs/gdata/gdataReferenceDimensionsMetrics.html&quot;&gt;http://code.google.com/intl/pt-BR/apis/analytics/docs/gdata/gdataReferenceDimensionsMetrics.html&lt;/a&gt;&amp;nbsp;contêm toda as especificações necessárias.&lt;br /&gt;
Como não gosto de perder tempo e, para muitos pode ser um pouco confuso o seu entendimento logo de cara, vamos fazer uma abstração:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi2_TfLP046fDOmY8ne80prA-ojhs6t0AejSBBCV1GRMOneGcpsZpzo_0kPrABYcH9GUZwN5aZzwkzzePy0_0F_bweEphNj4gFbHdkzBaxG7ehNgIDdquv2vEtWDShCEeaBOfxRYWVQg2v3/s1600/explicacao_api_analytics.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;137&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi2_TfLP046fDOmY8ne80prA-ojhs6t0AejSBBCV1GRMOneGcpsZpzo_0kPrABYcH9GUZwN5aZzwkzzePy0_0F_bweEphNj4gFbHdkzBaxG7ehNgIDdquv2vEtWDShCEeaBOfxRYWVQg2v3/s400/explicacao_api_analytics.png&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;&lt;i&gt;ids&lt;/i&gt;: é o ID do Perfil conforme vimos anteriormente;&lt;/li&gt;
&lt;li&gt;&lt;i&gt;dimensions&lt;/i&gt;: vamos &quot;acatar&quot; que seja os relacionamentos (linhas)&amp;nbsp;&amp;nbsp;(não é obrigatório);&lt;/li&gt;
&lt;li&gt;&lt;i&gt;metrics&lt;/i&gt;: vamos &quot;acatar&quot; que seja o que deseja buscar (colunas);&lt;/li&gt;
&lt;li&gt;&lt;i&gt;segment&lt;/i&gt;: especificação do tipo de consulta (não é obrigatório);&amp;nbsp;&lt;/li&gt;
&lt;li&gt;&lt;i&gt;filters&lt;/i&gt;: é o WHERE da consulta&amp;nbsp;(não é obrigatório);&lt;/li&gt;
&lt;li&gt;&lt;i&gt;sort&lt;/i&gt;: ordenação&amp;nbsp;&amp;nbsp;(não é obrigatório);&lt;/li&gt;
&lt;li&gt;&lt;i&gt;start-date&lt;/i&gt;: data de início (formato yyyy-MM-dd);&lt;/li&gt;
&lt;li&gt;&lt;i&gt;end-date&lt;/i&gt;: data final&amp;nbsp;(formato yyyy-MM-dd);&lt;/li&gt;
&lt;li&gt;&lt;i&gt;start-index&lt;/i&gt;: serve para paginar dados (como o MySQL usa o LIMIT);&lt;/li&gt;
&lt;li&gt;&lt;i&gt;max-result&lt;/i&gt;: quantidade máxima de registros retornados.&lt;/li&gt;
&lt;/ul&gt;&lt;br /&gt;
Essa é a explicação mais entendível possível e que posso passar para vocês. Logo, antes de botar a mão na massa, sugiro fazer várias simulações e ver como é retornado os objetos. De acordo com a simulação que fiz, por exemplo, e de acordo com a figura seria a seguinte busca:&lt;br /&gt;
&lt;br /&gt;
&lt;blockquote&gt;&lt;i&gt;&lt;b&gt;&quot;Me retorne todas as cidades, que visitaram meu blog, com suas respectivas quantidades de visitas no período de 03/07/2011 a 17/07/2011 ordenada por cidade. Só me traga os 50 primeiros registros.&quot;&lt;/b&gt;&lt;/i&gt;&lt;/blockquote&gt;&lt;br /&gt;
Então, me seria retornado a seguinte &quot;tabela&quot;:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiYxe1jcNHdHfUDqxsryUni_5U2NtB-40tQxM3591U_fleFAEOR6ojjfX2k1xC8FBoxfXSetbD5YjQNBN6lm2vdJPncuxMyNvdm2h8PpRgHTeoL2kb6DTVFGh4ziYAhB-g_CN73RJ4jux-R/s1600/analytics_tabela_integracao_consulta.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;197&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiYxe1jcNHdHfUDqxsryUni_5U2NtB-40tQxM3591U_fleFAEOR6ojjfX2k1xC8FBoxfXSetbD5YjQNBN6lm2vdJPncuxMyNvdm2h8PpRgHTeoL2kb6DTVFGh4ziYAhB-g_CN73RJ4jux-R/s400/analytics_tabela_integracao_consulta.png&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
Ficou claro? Tranquilo, né? A pior parte já passou. Agora, porquê escrevi &quot;tabela&quot;... Porque não é! Lembra que&amp;nbsp;abstraímos&amp;nbsp;para que seja isso. Sabendo de como a &lt;b&gt;API &lt;/b&gt;trabalha então bastemos implementar. Vamos lá! Pode-se criar uma classe ou incorporar na mesma página o código. Fica a seu critério!&lt;br /&gt;
&lt;br /&gt;
Adicione os seguintes &lt;i&gt;namespaces&lt;/i&gt;:&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;using &lt;/span&gt;Google.Analytics;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;using &lt;/span&gt;Google.GData.Analytics;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;using &lt;/span&gt;Google.GData.Client;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;using &lt;/span&gt;Google.GData.Extensions;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
Também as variáveis abaixo são necessárias para a devida autenticação e consulta nas quais descrevem:&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #38761d; font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;// Variáveis&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;string &lt;/span&gt;user; &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #38761d;&quot;&gt;// Usuário da Conta Google Analytics&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;string &lt;/span&gt;pass; &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #38761d;&quot;&gt;// Senha&amp;nbsp;&amp;nbsp;da Conta Google Analytics&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;string &lt;/span&gt;id_tabela; &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #38761d;&quot;&gt;// ID do Perfil&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #38761d; font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;// Inicialização&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;user = &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red;&quot;&gt;&quot;email@gmail.com&quot;&lt;/span&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;pass = &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red;&quot;&gt;&quot;senha&quot;&lt;/span&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;id_tabela = &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red;&quot;&gt;&quot;ga:30897221&quot;&lt;/span&gt;; &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #38761d;&quot;&gt;// Tem que colocar a string &quot;ga&quot; na frete do ID do Perfil&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
Agora adicione os seguinte métodos:&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #999999; font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #999999; font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;/// &lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #38761d; font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;Consulta o Analytics&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #999999; font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #999999; font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;/// &amp;lt;param name=&quot;query&quot;&amp;gt;&amp;lt;/param&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;private &lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #3d85c6;&quot;&gt;DataFeed &lt;/span&gt;ConsultaAnalytics(&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #3d85c6;&quot;&gt;DataQuery &lt;/span&gt;query)&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #3d85c6;&quot;&gt;AnalyticsService &lt;/span&gt;asv = &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;new &lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #3d85c6;&quot;&gt;AnalyticsService&lt;/span&gt;(&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red;&quot;&gt;&quot;gaExportAPI_acctSample_v2.0&quot;&lt;/span&gt;);&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; asv.setUserCredentials(user, pass);&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #3d85c6;&quot;&gt;String &lt;/span&gt;baseUrl = &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red;&quot;&gt;&quot;https://www.google.com/analytics/feeds/data&quot;&lt;/span&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; query.Ids = id_tabela;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; query.Uri = &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;new &lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #3d85c6;&quot;&gt;Uri&lt;/span&gt;(baseUrl);&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; return asv.Query(query);&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #999999; font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #999999; font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;/// &lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #38761d; font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;Retorna o resultado da consulta&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #999999; font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #999999; font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;/// &amp;lt;param name=&quot;query&quot;&amp;gt;&amp;lt;/param&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #999999; font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;/// &amp;lt;returns&amp;gt;&amp;lt;/returns&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;private &lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #3d85c6;&quot;&gt;DataTable&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #0b5394;&quot;&gt; &lt;/span&gt;RetornaTabela(&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #3d85c6;&quot;&gt;DataQuery &lt;/span&gt;query)&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #3d85c6;&quot;&gt;DataTable &lt;/span&gt;resultado = &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;new &lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #3d85c6;&quot;&gt;DataTable&lt;/span&gt;();&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #3d85c6;&quot;&gt;DataFeed &lt;/span&gt;feed = ConsultaAnalytics(query);&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;if &lt;/span&gt;(feed.Entries.Count &amp;gt; 0)&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #38761d;&quot;&gt;// Cria as colunas&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #3d85c6;&quot;&gt;DataEntry &lt;/span&gt;colunEntry = feed.Entries[0] &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;as &lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #3d85c6;&quot;&gt;DataEntry&lt;/span&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;foreach &lt;/span&gt;(&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #3d85c6;&quot;&gt;Dimension &lt;/span&gt;colundimension &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;in &lt;/span&gt;colunEntry.Dimensions)&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; resultado.Columns.Add(&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;new &lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #3d85c6;&quot;&gt;DataColumn&lt;/span&gt;(colundimension.Name.Substring(3)));&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;foreach &lt;/span&gt;(&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #3d85c6;&quot;&gt;Metric &lt;/span&gt;colunmetric &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;in &lt;/span&gt;colunEntry.Metrics)&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; resultado.Columns.Add(&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;new &lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #3d85c6;&quot;&gt;DataColumn&lt;/span&gt;(colunmetric.Name.Substring(3))); &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #38761d;&quot;&gt;// Insere os dados&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;foreach &lt;/span&gt;(&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #3d85c6;&quot;&gt;DataEntry&lt;/span&gt; singleEntry &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;in &lt;/span&gt;feed.Entries)&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #3d85c6;&quot;&gt;DataRow &lt;/span&gt;rw = resultado.NewRow();&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;foreach &lt;/span&gt;(&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #3d85c6;&quot;&gt;Metric &lt;/span&gt;metric &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;in &lt;/span&gt;singleEntry.Metrics)&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; rw[metric.Name.Substring(3)] = metric.Value;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;foreach &lt;/span&gt;(&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #3d85c6;&quot;&gt;Dimension &lt;/span&gt;dimension &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;in &lt;/span&gt;singleEntry.Dimensions)&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; rw[dimension.Name.Substring(3)] = dimension.Value;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; resultado.Rows.Add(rw);&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;return &lt;/span&gt;resultado;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
Óbvio que essas são apenas sugestões de implementações e você podem mudar o quanto achar melhor a depender de sua unidade de negócio. Agora vamos fazer aquela consulta:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #38761d; font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;// Dados da consulta&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #3d85c6;&quot;&gt;DataQuery &lt;/span&gt;q = &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;new &lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #3d85c6;&quot;&gt;DataQuery&lt;/span&gt;();&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; q.Dimensions = &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red;&quot;&gt;&quot;ga:city&quot;&lt;/span&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; q.Metrics = &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red;&quot;&gt;&quot;ga:visits&quot;&lt;/span&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; q.GAStartDate = &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #3d85c6;&quot;&gt;DateTime&lt;/span&gt;.Parse(&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red;&quot;&gt;&quot;03/07/2011&quot;&lt;/span&gt;).ToString(&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red;&quot;&gt;&quot;yyyy-MM-dd&quot;&lt;/span&gt;);&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; q.GAEndDate = DateTime.Parse(&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red;&quot;&gt;&quot;17/07/2011&quot;&lt;/span&gt;).ToString(&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red;&quot;&gt;&quot;yyyy-MM-dd&quot;&lt;/span&gt;);&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; q.Sort = &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red;&quot;&gt;&quot;ga:&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red;&quot;&gt;city&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red;&quot;&gt;&quot;&lt;/span&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; q.NumberToRetrieve = 50;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #38761d;&quot;&gt;// Resultado&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #3d85c6;&quot;&gt;DataTable &lt;/span&gt;resultado = RetornaTabela(q);&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Pronto! Irá me retornar um &lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;DataTable &lt;/span&gt;com aquela tabela de dados. Basicamente todas aquelas informações que você vê no &lt;b&gt;Analytics &lt;/b&gt;são vindas em formato tabela e que, posteriormente, são feitos tratamentos e cálculos sobre eles. Como disse no início do artigo, agora basta usar a tabela de dados conforme desejar...&lt;br /&gt;
Espero que tenham gostado depois de um tempo sem postar nada...</content><link rel='replies' type='application/atom+xml' href='http://thiagomarcal.blogspot.com/feeds/1108085663288453030/comments/default' title='Postar comentários'/><link rel='replies' type='text/html' href='http://thiagomarcal.blogspot.com/2011/07/integracao-aspnet-c-com-o-google.html#comment-form' title='3 Comentários'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7002820434209519335/posts/default/1108085663288453030'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7002820434209519335/posts/default/1108085663288453030'/><link rel='alternate' type='text/html' href='http://thiagomarcal.blogspot.com/2011/07/integracao-aspnet-c-com-o-google.html' title='Integração ASP.NET (C#) com o Google Analytics'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhy5I_x0pEash-vHWgFCyw36_-qK2-BKVRz3Wl-FY03epuOcHiv7bfKPGDGWdcKIJxI0xqjer5Dp0P6mdWPowBeTY259MyGJRAP0bv7m9xBWEwAirF-1UGZMGGK-ZHskOshqO-zrqQG8RhA/s72-c/google_analytics_painel_integracao.png" height="72" width="72"/><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7002820434209519335.post-7700217691496022581</id><published>2011-04-09T01:17:00.001-03:00</published><updated>2011-04-11T14:10:14.444-03:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="banco de dados"/><category scheme="http://www.blogger.com/atom/ns#" term="cloud server"/><category scheme="http://www.blogger.com/atom/ns#" term="crystal reports"/><category scheme="http://www.blogger.com/atom/ns#" term="dll"/><category scheme="http://www.blogger.com/atom/ns#" term="erros"/><category scheme="http://www.blogger.com/atom/ns#" term="iis"/><category scheme="http://www.blogger.com/atom/ns#" term="locaweb"/><category scheme="http://www.blogger.com/atom/ns#" term="plesk"/><category scheme="http://www.blogger.com/atom/ns#" term="sql server"/><category scheme="http://www.blogger.com/atom/ns#" term="windows"/><title type='text'>Mega Post de Erros</title><content type='html'>Lidar com erros é algo realmente muito chato... Chato demais! Esses dias fui convocado para fazer um certo trabalho de migração entre servidores. Um desses servidores era um &lt;a href=&quot;http://www.locaweb.com.br/produtos/cloud-server.html&quot;&gt;&lt;b&gt;Cloud Server Pro&lt;/b&gt;&lt;/a&gt; da &lt;b&gt;Locaweb&lt;/b&gt;. Em muitos posts que aqui escrevi tem um pouco retratando sobre a Locaweb. Trabalho e já trabalhei muito com ela e sei de todos os seus passos e &quot;artimanhas&quot; de atendimento... O antigo Cloud Server foi até tranquilo de trabalhar, mas esse novo... Vamos aos problemas!&lt;br /&gt;
&lt;br /&gt;
Uma dica que dou sempre quando alguém quer contratar um servidor: leiam muito sobre os prós e contras. Os prós vejam no próprio &lt;i&gt;site &lt;/i&gt;do prestador, os contras vejam nos relatos de usuários. No post a seguir não estou jogando a Locaweb contra a parede, apenas estou expondo erros que podem ser sanados de forma fácil mas que burocraticamente é jogado para o cliente se virar (nos 30!).&lt;br /&gt;
&lt;br /&gt;
Nesse Cloud Server vem embutido o &lt;a href=&quot;http://www.parallels.com/products/plesk95/&quot;&gt;Plesk&lt;/a&gt;. Em poucas palavras serve para gerenciar a hospedagem através de uma interface &lt;i&gt;web&lt;/i&gt;. É uma boa ferramenta de gerência, tem tudo para gerenciar sua hospedagem. Só que esse demais gera ocupação demais (redundância) de espaço em disco. Dos 50 Gb que você contrata, 40Gb é para o sistema operacional e 10Gb para seus arquivos. Sendo que dos 10Gb é para todos os seus arquivos, e-mails, banco de dados, etc. Ou seja, apenas&amp;nbsp;usufrui&amp;nbsp;dos 10Gb um pouco menos que 9Gb e olhe lá.&lt;br /&gt;
&lt;br /&gt;
Bem, dizem que vem tudo preparado e instalado para usar... Verdade até certa parte! Quem está usando e é iniciante vai ver que é mil maravilhas. Dá para fazer o básico de tudo. O problema vem a seguir...&lt;br /&gt;
&lt;br /&gt;
Um cliente contratou o Cloud Server gerenciado pelo cliente (ou seja, sobrou para o usuário final) e me passou para configurar e deixar no ponto de uso fazendo toda a migração e instalação. Em um passe de mágica surgem os problemas...&lt;br /&gt;
&lt;br /&gt;
Os bancos de dados que vem são o &lt;b&gt;MS SQL Server 2008&lt;/b&gt; e o &lt;b&gt;MySQL&lt;/b&gt;. Não há interface para &lt;i&gt;dump &lt;/i&gt;e &lt;i&gt;recovery &lt;/i&gt;das bases forçando a usar o Plesk para isso, mas não queria. Onde está o &lt;b&gt;&lt;a href=&quot;http://www.microsoft.com/downloads/en/details.aspx?FamilyID=08e52ac2-1d62-45f6-9a4a-4b76a8564a2b&quot;&gt;Management Studio 2008&lt;/a&gt;&lt;/b&gt;? Onde está o &lt;b&gt;&lt;a href=&quot;http://dev.mysql.com/downloads/workbench/&quot;&gt;MySQL Workbench&lt;/a&gt;&lt;/b&gt;? Como vou fazer para migrar as bases? Gerar &lt;i&gt;script &lt;/i&gt;de bancos gigantes? Nem pensar! Preciso instalar!&lt;br /&gt;
&lt;br /&gt;
Mas como instalar esses aplicativos? Se fazer &lt;i&gt;download&lt;/i&gt;, gera tráfego. Se pedir para a Locaweb tem que pagar e se pedir, de graça, não instala! Lembrando que esses aplicativos, no mínimo, são gratuitos e deveriam estar em uma zona em que os usuários pudessem obtê-los de forma fácil e sem cobrança. Pois bem, feito o &lt;i&gt;download&lt;/i&gt;, hora de instalar. Abrindo o executável (lembrando que tem que ser a da versão 64bits) dá aviso de incompatibilidade. É preciso instalar o &lt;b&gt;Service Pack 1 do SQL Server 2008&lt;/b&gt; (mais tráfego). Baixado o &lt;a href=&quot;http://www.microsoft.com/downloads/details.aspx?familyid=66AB3DBB-BF3E-4F46-9559-CCC6A4F9DC19&amp;amp;displaylang=pt-br&quot;&gt;SP1&lt;/a&gt; é preciso instalá-lo. Tranquilo e instalado sem problemas. Hora de instalar o &lt;i&gt;Management Studio&lt;/i&gt;...&lt;br /&gt;
&lt;br /&gt;
Ao tentar abrir, outro problema?!?! É preciso do&amp;nbsp;&lt;a href=&quot;http://www.microsoft.com/downloads/details.aspx?familyid=333325FD-AE52-4E35-B531-508D977D32A6&amp;amp;displaylang=pt-br&quot;&gt;Framework 3.5&lt;/a&gt;! Incrivel... No Cloud Server vem instalado a versão 2.0 e 4.0 do &lt;i&gt;Framework &lt;/i&gt;&lt;b&gt;ASP.NET&lt;/b&gt; mas não tem a 3.5 ativado. Menos mal, porque no &lt;b&gt;Windows Server 2008&lt;/b&gt; é nativo, basta ativar. Realize os seguintes passos (retirado do &lt;a href=&quot;http://wiki.locaweb.com.br/pt-br/MS_SQL_Server_2008_-_Instalando_SQL_Server_2008_para_Servidor_com_Gerenciamento_pelo_Cliente&quot;&gt;Wiki&lt;/a&gt;):&lt;br /&gt;
&lt;br /&gt;
&lt;ol&gt;&lt;li&gt;Clique em &lt;i&gt;Start&lt;/i&gt;, &lt;i&gt;Administrative Tools&lt;/i&gt; e selecione &lt;i&gt;Server Manager&lt;/i&gt;;&lt;/li&gt;
&lt;li&gt;Na interface, clique em &lt;i&gt;Features &lt;/i&gt;e clique em &lt;i&gt;Add Features&lt;/i&gt;;&lt;/li&gt;
&lt;li&gt;Selecione a primeira opção &lt;i&gt;.NET Framework 3.5.1 Features&lt;/i&gt; e adicione todos seus dependentes;&lt;/li&gt;
&lt;li&gt;Conclua a instalação do &lt;i&gt;Framework&lt;/i&gt;.&lt;/li&gt;
&lt;/ol&gt;&lt;br /&gt;
Agora sim, tudo pronto! Vamos instalar o &lt;i&gt;Management Studio&lt;/i&gt;. Clica no instalador e... Erro! Caramba... de novo!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;TITLE: SQL Server Setup failure.&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;-------------------------------&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;SQL Server Setup has encountered the following error:&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;Invoke or BeginInvoke cannot be called on a control until the window handle has been created.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
A dica é: feche o &lt;b&gt;Windows Explorer&lt;/b&gt;! Por algum motivo, a instalação do &lt;i&gt;Management Studio&lt;/i&gt; não inicia quando o &lt;i&gt;Windows Explorer&lt;/i&gt; estiver em aberto. Copie para a Área de Trabalho e abra o instalador... Agora sim! Depois de tanta &lt;i&gt;malemolência &lt;/i&gt;pelo menos iniciemos a instalação. Para quem tem dúvidas e um passo-a-passo bem explicativo de como instalar o &lt;i&gt;Management Studio&lt;/i&gt;, acesse &lt;a href=&quot;http://www.marcosdellantonio.net/2009/06/08/instalando-o-sql-server-management-studio-2008-express/&quot;&gt;aqui&lt;/a&gt;&amp;nbsp;o post de &lt;b&gt;Marcos dell Antonio&lt;/b&gt;. Há uma dica bem interessante que pode confundir o usuário na hora da instalação. Terminado a instalação, menos um item da lista de afazeres.&lt;br /&gt;
&lt;br /&gt;
Consegui conectar ao &lt;i&gt;SQL Server&lt;/i&gt; local, criei as bases, usuários, fiz &lt;i&gt;restores&lt;/i&gt;, configurei o&amp;nbsp;&lt;i&gt;backup&lt;/i&gt;, providenciei tudo o que tinha que fazer onde o &lt;i&gt;Plesk &lt;/i&gt;jamais pensaria em um dia ser. Agora o principal, testar um &lt;i&gt;website&lt;/i&gt;. Publiquei o &lt;i&gt;site &lt;/i&gt;no &lt;b&gt;IIS&lt;/b&gt; e abri o navegador para visualizar. Erro!&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;background-color: yellow; font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;Could not load type &#39;System.ServiceModel.Activation.HttpModule&#39; from assembly &#39;System.ServiceModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089&#39;.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
Sabe o porquê disso? Eu instalei o &lt;b&gt;ASP.NET 3.5&lt;/b&gt; depois que eu já tinha a versão 4.0 instalada por causa do &lt;i&gt;Management Studio &lt;/i&gt;então gerou conflito nas DLL&#39;s. Para resolver, faça o seguinte:&lt;br /&gt;
&lt;br /&gt;
&lt;ol&gt;&lt;li&gt;Vá para a pasta&amp;nbsp;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;C:\Windows\Microsoft.NET\Framework64\v4.0.30319&lt;/span&gt;;&lt;/li&gt;
&lt;li&gt;Execute o comando&amp;nbsp;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;aspnet_regiis.exe -iru&lt;/span&gt;&lt;/li&gt;
&lt;/ol&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhxTlTwKnJJp1w5pLmisW3dndHbzA2dPoKjCkhyqJP_rpYfceTHiNTaAJKYCLja5ZhvGtLhNy6r5DDj2bvlP7rXF3xaxMyZW9LI6P7RMnKOx-Not6fuF_F3Rrrh4hgE9Fdj_yAGqd3mwax_/s1600/reinstal_aspnet.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;300&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhxTlTwKnJJp1w5pLmisW3dndHbzA2dPoKjCkhyqJP_rpYfceTHiNTaAJKYCLja5ZhvGtLhNy6r5DDj2bvlP7rXF3xaxMyZW9LI6P7RMnKOx-Not6fuF_F3Rrrh4hgE9Fdj_yAGqd3mwax_/s400/reinstal_aspnet.png&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;
&lt;/div&gt;&lt;br /&gt;
Agora vamos testar! Abri o navegador e digitei o endereço e... Mais erro!&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;background-color: yellow; font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;There is a duplicate &#39;system.web.extensions/scripting/scriptResourceHandler&#39;&amp;nbsp;section defined&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
Mais conflitos! Se você tiver outra versão do &lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;System.Web.Extensions&lt;/span&gt; instalado, devido ao &lt;b&gt;ASP.NET AJAX&lt;/b&gt; por exemplo, a versão que está no &lt;b&gt;&lt;a href=&quot;http://en.wikipedia.org/wiki/Global_Assembly_Cache&quot;&gt;GAC&lt;/a&gt; &lt;/b&gt;do sistema difere da que você quer chamar ocorrendo ambiguidade. O correto seria alterar os &lt;i&gt;assemblys &lt;/i&gt;mas como isso é muito trabalhoso e pode acontecer algum imprevisto para aqueles que não sabem manuseá-las, então aconselho o seguinte: remova toda a&amp;nbsp;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;sectionGroup&lt;/span&gt; do seu &lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;web.config&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt; ou comente-as&lt;/span&gt;:&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue; font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;lt;!--&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #38761d; font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;lt;sectionGroup name=&quot;system.web.extensions&quot; type=&quot;System.Web.Configuration.SystemWebExtensionsSectionGroup, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35&quot;&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #38761d; font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;lt;sectionGroup name=&quot;scripting&quot; type=&quot;System.Web.Configuration.ScriptingSectionGroup, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35&quot;&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #38761d; font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;lt;section name=&quot;scriptResourceHandler&quot; type=&quot;System.Web.Configuration.ScriptingScriptResourceHandlerSection, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35&quot; requirePermission=&quot;false&quot; allowDefinition=&quot;MachineToApplication&quot; /&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #38761d; font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;lt;sectionGroup name=&quot;webServices&quot; type=&quot;System.Web.Configuration.ScriptingWebServicesSectionGroup, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35&quot;&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #38761d; font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;lt;section name=&quot;jsonSerialization&quot; type=&quot;System.Web.Configuration.ScriptingJsonSerializationSection, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35&quot; requirePermission=&quot;false&quot; allowDefinition=&quot;Everywhere&quot; /&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #38761d; font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;lt;section name=&quot;profileService&quot; type=&quot;System.Web.Configuration.ScriptingProfileServiceSection, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35&quot; requirePermission=&quot;false&quot; allowDefinition=&quot;MachineToApplication&quot; /&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #38761d; font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;lt;section name=&quot;authenticationService&quot; type=&quot;System.Web.Configuration.ScriptingAuthenticationServiceSection, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35&quot; requirePermission=&quot;false&quot; allowDefinition=&quot;MachineToApplication&quot; /&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #38761d; font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;lt;/sectionGroup&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #38761d; font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;lt;/sectionGroup&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #38761d; font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;lt;/sectionGroup&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue; font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;--&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
No caso comentei o &lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;sectionGroup &lt;/span&gt;do &lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;System.Web.Extension&lt;/span&gt; que pode estar na versão 1.0, 2.0 ou 3.5 que for.&lt;br /&gt;
&lt;br /&gt;
Agora vamos lá! De pés juntos e mãos dadas: Abre o navegador e... e... e... Funcionou! Depois de um árduo trabalho aparentemente tudo estava normal. Vamos testar outros &lt;i&gt;sites &lt;/i&gt;e... e... e... Mais erros!&lt;br /&gt;
&lt;br /&gt;
Quem ainda não está acostumado a trabalhar com &lt;b&gt;Windows Server 2008&lt;/b&gt; e &lt;b&gt;IIS 7&lt;/b&gt; terá que aprender muito sobre permissões e tratamento de erros. Incontestavelmente a tela do erro 500 irá aparecer e muito se sua aplicação não estiver configurada adequadamente para o IIS 7. Nem sempre a mesma aplicação que está no IIS 6 irá funcionar no IIS 7. Então eis que surge a tela do &lt;b&gt;Erro 500 Erro Interno do Servidor&lt;/b&gt; ou &lt;b&gt;&lt;i&gt;Error 500 Internal Server Error:&lt;/i&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;i&gt;&lt;br /&gt;
&lt;/i&gt;&lt;/b&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhUM5CV4-XI8W9fllLWK99ya2M67rN1y0mu1GMV6XGHJuOhI56NY4mgH3JCG8mYeXnfuPveVJSsz-ibv2Usa9staHO56SQ8bm77NaTHVvdedL2NaX9NkzZCASRk4Dj6kkjS_7XkFFRwUE0F/s1600/erro_500.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;184&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhUM5CV4-XI8W9fllLWK99ya2M67rN1y0mu1GMV6XGHJuOhI56NY4mgH3JCG8mYeXnfuPveVJSsz-ibv2Usa9staHO56SQ8bm77NaTHVvdedL2NaX9NkzZCASRk4Dj6kkjS_7XkFFRwUE0F/s320/erro_500.png&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;b&gt;&lt;i&gt;&lt;br /&gt;
&lt;/i&gt;&lt;/b&gt;&lt;br /&gt;
Ou então:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiUsweTMHnY3K7Z69TjHZ2SsyEFR1S12_vNIQvJhUoxyzV62B6IlIUkXXcVsIUfzSiV1brJtfar8EmjiDxufm_5GASAzICvlzBbuYZKGvCH8S8FnhByBsmtBgtDDkVS3fJ_M9TA0QHJPMit/s1600/internal_500.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;198&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiUsweTMHnY3K7Z69TjHZ2SsyEFR1S12_vNIQvJhUoxyzV62B6IlIUkXXcVsIUfzSiV1brJtfar8EmjiDxufm_5GASAzICvlzBbuYZKGvCH8S8FnhByBsmtBgtDDkVS3fJ_M9TA0QHJPMit/s320/internal_500.jpg&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
Dá para descobrir o que é? Vou dar a dica: revise seu &lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;web.config&lt;/span&gt;. &lt;b&gt;&lt;i&gt;&quot;Ah, mas está tudo certo, não sei porque não funciona...&quot;&lt;/i&gt;&lt;/b&gt;. Engano, está errado. Já disse que o IIS 7 é chato, muito chato. O &lt;i&gt;parser &lt;/i&gt;dele é muito minucioso e se não estiver nos padrões vai dar problema.&lt;br /&gt;
&lt;br /&gt;
Se você não sabe utilizar bem o IIS e tem medo de alterar uma coisinha ali e outra acolá vou dar a maior dica: saia abrindo cada opção do painel da aplicação até que uma delas acuse um erro de configuração.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhWoyb4tqNA7tFZ9vAa1JqSoPklPyJ_EOT5felfmZUtSi0XAiCnbbxGKTSdHKKy5VMJZnq04t1MuVBD77pbl9hyphenhyphenETCFvb6ACUNzLphILLCfWaGMfq8ZGeFGfJ4vdNf_eYM57aY-80BYqW7D/s1600/painel_opcoes.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;273&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhWoyb4tqNA7tFZ9vAa1JqSoPklPyJ_EOT5felfmZUtSi0XAiCnbbxGKTSdHKKy5VMJZnq04t1MuVBD77pbl9hyphenhyphenETCFvb6ACUNzLphILLCfWaGMfq8ZGeFGfJ4vdNf_eYM57aY-80BYqW7D/s400/painel_opcoes.png&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
Por exemplo, abra o item &lt;b&gt;Documento Padrão&lt;/b&gt;. Se ele estiver configurado corretamente então abrirá a próxima tela normalmente. Se tiver algum erro, aparecerá um alerta. Então no &lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;web.config&lt;/span&gt; você deve corrigir a sessão correspondente. Ficou claro? Saia clicando um a um até que um deles se denuncie podendo então fazer a correção.&lt;br /&gt;
&lt;br /&gt;
O que ocorreu comigo foi que um &lt;i&gt;site &lt;/i&gt;que estava no IIS 6 podia colocar a mesma página (&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;index.aspx&lt;/span&gt;) como padrão, duas vezes, e não tinha problema. Quando foi para o IIS 7, na qual estava herdando a configuração pai, e foi adicionar a página &lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;index.aspx&lt;/span&gt; como padrão novamente, ele dava erro e não sabia&amp;nbsp;porquê. Então removi a entrada do &lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;web.config&lt;/span&gt; e funcionou. Desabilitar a mensagem de erro amigável no navegador vai funcionar (encontrar o erro)? Não. Desabilitar as páginas de erros personalizáveis do IIS vai funcionar&amp;nbsp;(encontrar o erro)? Talvez ou não. Depende muito do ambiente que está configurado e quem está manipulando.&lt;br /&gt;
&lt;br /&gt;
Pronto! Mais um problema solucionado... Vamos testar outro &lt;i&gt;site &lt;/i&gt;e... e... e... Erro! Agora aconteceu um erro 404. Mas como? &lt;b&gt;Erro 404&lt;/b&gt; de&lt;i&gt; página não encontrada&lt;/i&gt; mas se o caminho está lá? Incrivelmente no IIS do Cloud Server possuem dois &lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;Applications Pools&lt;/span&gt; do Plesk (e mais outros nativos):&amp;nbsp;Plesk(default)(2.0) e&amp;nbsp;Plesk(default)(4.0). O &lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;pool&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&amp;nbsp;&lt;/span&gt;do 2.0 quase nem sempre funciona. E um comportamento anormal é que se você tem um &lt;i&gt;site &lt;/i&gt;pai em 2.0 e um filho em 2.0 às vezes pára de funcionar. O &quot;correto&quot; é ter um pai 2.0 ou 4.0 com filho sempre 4.0. Estranho? Pode crer! E onde está o &lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;pool&lt;/span&gt; do 3.5? Tem que criar na mão mesmo.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Nota:&lt;/b&gt; Se você reiniciar o IIS o Plesk pára de vez e não volta:&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhQuN1zjHWpc1BHZIYogqezf5LV58Okpus2cAv0v25SXZZwxn89JKLXI9o9UHvFdBC6Ccu9pOho3xZCzL8Ps_7ob7A6umItvJDmDJmYYibgvZ7Tb281MxhMK3x1WT5R7xpp-K5Qd6ZI5Flz/s1600/plesk_iis.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhQuN1zjHWpc1BHZIYogqezf5LV58Okpus2cAv0v25SXZZwxn89JKLXI9o9UHvFdBC6Ccu9pOho3xZCzL8Ps_7ob7A6umItvJDmDJmYYibgvZ7Tb281MxhMK3x1WT5R7xpp-K5Qd6ZI5Flz/s1600/plesk_iis.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
Você terá que iniciá-lo manualmente. Mas antes terá que iniciar seu &lt;i&gt;pool&lt;/i&gt; também (que é muito suspeito):&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiKkEgcV3A99BHxmhLErDmFE52hzHpwrNCkBjZOcwkcobofiFA9_8HZNePcklZnptod-fXWOHkySH-Vm7WMppzXhV_ZCY1y8O8td0lUar0tV4WuZmYKJX29boyu8aX3jWVGUhAebtj3byHN/s1600/plesk_pool.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;116&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiKkEgcV3A99BHxmhLErDmFE52hzHpwrNCkBjZOcwkcobofiFA9_8HZNePcklZnptod-fXWOHkySH-Vm7WMppzXhV_ZCY1y8O8td0lUar0tV4WuZmYKJX29boyu8aX3jWVGUhAebtj3byHN/s400/plesk_pool.png&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
&amp;nbsp;Ajeitado uma coisinha ali, outra aqui, vamos testar mais algumas coisas e... e... e... Quase tudo certo. Em questão de funcionalidade (que deveria ser) está quase tudo certo a não ser o funcionamento do bom e velho &lt;b&gt;Crystal Reports&lt;/b&gt;. Quem já leu o post de erros do Crystal &lt;a href=&quot;http://thiagomarcal.blogspot.com/2010/07/corrigindo-dois-erros-em-uma-taca-so-o.html&quot;&gt;aqui&lt;/a&gt; e &lt;a href=&quot;http://thiagomarcal.blogspot.com/2010/09/gerando-relatorios-com-o-crystal.html&quot;&gt;aqui&lt;/a&gt; nos deparamos com o erro:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;O inicializador de tipo de &#39;CrystalDecisions.CrystalReports.Engine.ReportDocument&#39; acionou uma exceção&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
ou&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;The type initializer for &#39;CrystalDecisions.CrystalReports.Engine.ReportDocument&#39; threw an exception&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
Cuidado! Esse não é o descritivo do erro. Só com isso não dá para saber o motivo. Faça o &lt;i&gt;debug&lt;/i&gt;, &lt;i&gt;log&lt;/i&gt;, &amp;nbsp;exibição da pilha ou na própria tela exiba o erro (sem ter AJAX) que teremos o erro completo. No link dos dois posts anteriores que fiz explica o problema do Crystal na plataforma 64bits e como pode resolver. Só que o problema no meu caso era permissão.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;background-color: yellow; font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;Server Error in &#39;/virtual_directory_name&#39; Application.&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;background-color: yellow; font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;Error in File UNKNOWN.RPT:&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;background-color: yellow; font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;The request could not be submitted for background processing.&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;background-color: yellow; font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;background-color: yellow; font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;background-color: yellow; font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;Exception Details: System.Runtime.InteropServices.COMException: Error in File UNKNOWN.RPT: The request could not be submitted for background processing.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Os usuários listados abaixo, não tinham permissão na execução de &lt;i&gt;scripts &lt;/i&gt;&lt;b&gt;DCOM &lt;/b&gt;e gravação em algumas pastas (principalmente as que estão na unidade C):&lt;br /&gt;
&lt;br /&gt;
&lt;ul&gt;&lt;li&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;IWAN_plesk(default)&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;IUSR&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;IIS_IUSR&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;NETWORK SERVICE&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;INTERACTIVE&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;br /&gt;
Esses são os usuários que devem ter privilégio (descritos abaixo) nas pastas listadas abaixo:&lt;br /&gt;
&lt;br /&gt;
&lt;ul&gt;&lt;li&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;C:\Windows\Temp\&lt;/span&gt;&amp;nbsp;: leitura \ escrita&lt;/li&gt;
&lt;li&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;C:\Program Files (x86)\Business Objects\Common\2.8\bin\&lt;/span&gt; : leitura&lt;/li&gt;
&lt;li&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;C:\&lt;/span&gt; : leitura&lt;/li&gt;
&lt;/ul&gt;&lt;br /&gt;
&lt;b&gt;Obs:&lt;/b&gt; Para alguns servidores é preciso aplicar o&amp;nbsp;&lt;i&gt;&lt;b&gt;Replace permission entries on all child objects&lt;/b&gt;&lt;/i&gt; nessas pastas.&lt;br /&gt;
&lt;br /&gt;
Lembrando de reiniciar o IIS e/ou o servidor para recarregar as configurações.&lt;br /&gt;
&lt;br /&gt;
Se estiver trabalhando com &lt;b&gt;Windows Service&lt;/b&gt; ou &lt;b&gt;Windows Form&lt;/b&gt; e ocorra o erro:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;background-color: yellow; font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;System.IO.FileNotFoundException: Retrieving the COM class factory for component with CLSID {5FF57840-5172-4482-9CA3-541C7878AE0F} failed due to the following error: 8007007e&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Basta compilar sua aplicação em &lt;b&gt;x86&lt;/b&gt;.&lt;br /&gt;
&lt;br /&gt;
E agora, tudo certo? Até o momento sim. Porque não dizer que está tudo OK? Depois de ter ocorrido todos esses problemas, fica-se receoso com o futuro. Pode ser que ocorra outro problema posteriormente? Sim e irá.&lt;br /&gt;
&lt;br /&gt;
Conforme disse anteriormente, o post não é para dizer mal sobre a Locaweb e/ou Plesk. Acho que eles prestam um serviço adequado para o nível nacional (até uso) contudo são coisas que acontecem que simplesmente poderiam ser sanadas antes de jogar o pepino para o cliente. Se você tiver algum problema desses e sua gerência for pelo cliente, nem adianta pedir que eles vão lhe informar: &lt;i&gt;&lt;b&gt;&quot;o gerenciamento é por conta do cliente e não nos responsabilizamos&quot;&lt;/b&gt;&lt;/i&gt; ou &lt;b&gt;&lt;i&gt;&quot;a ferramenta (Plesk) é terceirizada e não prestamos suporte.&quot;&lt;/i&gt;&lt;/b&gt;. Enfim, espero que o post ajude a você, cliente e usuário, a corrigir seus problemas/pepinos que ocorrerem. Isso me lembra quando lançou o &lt;i&gt;&lt;a href=&quot;http://pt.wikipedia.org/wiki/Ligar_e_Usar&quot;&gt;plug-and-play&lt;/a&gt;&lt;/i&gt;... a velha piadinha do &lt;i&gt;plug-and-pray&lt;/i&gt;&amp;nbsp;(ligar e rezar) não some da cabeça quando ocorre esse tipo de problema. Porque será?</content><link rel='replies' type='application/atom+xml' href='http://thiagomarcal.blogspot.com/feeds/7700217691496022581/comments/default' title='Postar comentários'/><link rel='replies' type='text/html' href='http://thiagomarcal.blogspot.com/2011/04/mega-post-de-erros.html#comment-form' title='0 Comentários'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7002820434209519335/posts/default/7700217691496022581'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7002820434209519335/posts/default/7700217691496022581'/><link rel='alternate' type='text/html' href='http://thiagomarcal.blogspot.com/2011/04/mega-post-de-erros.html' title='Mega Post de Erros'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhxTlTwKnJJp1w5pLmisW3dndHbzA2dPoKjCkhyqJP_rpYfceTHiNTaAJKYCLja5ZhvGtLhNy6r5DDj2bvlP7rXF3xaxMyZW9LI6P7RMnKOx-Not6fuF_F3Rrrh4hgE9Fdj_yAGqd3mwax_/s72-c/reinstal_aspnet.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7002820434209519335.post-2288709492388411594</id><published>2011-03-16T02:15:00.000-03:00</published><updated>2011-03-16T02:15:21.017-03:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="dicas"/><category scheme="http://www.blogger.com/atom/ns#" term="erros"/><category scheme="http://www.blogger.com/atom/ns#" term="web.config"/><title type='text'>Erros mais frequentes no ASP.NET</title><content type='html'>Para quem está começando a desenvolver com ASP.NET e se depara com a tela amarela, já deve ficar horrorizado com a linguagem. Diferente das linguagens ultrapassadas, essa tela é muito útil para desvendar os problemas e, posteriormente, corrigí-los.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjk2DdQKpl4xONQXrWMefIWTls-yyOib089UrVrx5G7dyoILosQAU9zm_2Myidxi45mOupnZgMPLBWezNCezs_C0RPcyk0VUV2MNMiP2W-za6EIdCmd_M7JGQqjuRvHGjJoek9Io6DXckx8/s1600/tela_erro_aspnet.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjk2DdQKpl4xONQXrWMefIWTls-yyOib089UrVrx5G7dyoILosQAU9zm_2Myidxi45mOupnZgMPLBWezNCezs_C0RPcyk0VUV2MNMiP2W-za6EIdCmd_M7JGQqjuRvHGjJoek9Io6DXckx8/s1600/tela_erro_aspnet.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
As telas de erro do ASP.NET mais comuns são aquelas nas quais são exibidas direto o erro para o usuário. Lembrando que já vimos em um &lt;a href=&quot;http://thiagomarcal.blogspot.com/2010/09/vulnerabilidade-de-seguranca-no-aspnet.html&quot;&gt;post&lt;/a&gt;&amp;nbsp;que isso demonstra vulnerabilidade do sistema mas que, a nível de homologação, é utilizável para identificar os problemas, análise da pilha e comportamento do mesmo.&lt;br /&gt;
&lt;br /&gt;
Não vou explicar tudo sobre erros no ASP.NET senão teríamos um grande post de tudo o que ocasiona erros, mas para auxiliar os iniciantes, a &lt;b&gt;Locaweb &lt;/b&gt;disponibilizou um tópico nas quais explica os erros mais comuns de programação bem como corrigí-los. Dêem uma lida para conferir... Veja &lt;a href=&quot;http://wiki.locaweb.com.br/pt-br/Erros_mais_frequentes_no_Asp.Net&quot;&gt;aqui&lt;/a&gt;!</content><link rel='replies' type='application/atom+xml' href='http://thiagomarcal.blogspot.com/feeds/2288709492388411594/comments/default' title='Postar comentários'/><link rel='replies' type='text/html' href='http://thiagomarcal.blogspot.com/2011/03/erros-mais-frequentes-no-aspnet.html#comment-form' title='0 Comentários'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7002820434209519335/posts/default/2288709492388411594'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7002820434209519335/posts/default/2288709492388411594'/><link rel='alternate' type='text/html' href='http://thiagomarcal.blogspot.com/2011/03/erros-mais-frequentes-no-aspnet.html' title='Erros mais frequentes no ASP.NET'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjk2DdQKpl4xONQXrWMefIWTls-yyOib089UrVrx5G7dyoILosQAU9zm_2Myidxi45mOupnZgMPLBWezNCezs_C0RPcyk0VUV2MNMiP2W-za6EIdCmd_M7JGQqjuRvHGjJoek9Io6DXckx8/s72-c/tela_erro_aspnet.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7002820434209519335.post-3069324185441307905</id><published>2011-03-13T11:26:00.000-03:00</published><updated>2011-03-13T11:26:35.526-03:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="ajax"/><category scheme="http://www.blogger.com/atom/ns#" term="componentes"/><category scheme="http://www.blogger.com/atom/ns#" term="dicas"/><category scheme="http://www.blogger.com/atom/ns#" term="javascript"/><title type='text'>Utilizando mensagem de confirmação e executando código de acordo com o que foi clicado na mesma página</title><content type='html'>Não sei se o título ficou claro com o que eu queria dizer, mas vejamos a seguinte situação:&lt;br /&gt;
&lt;blockquote&gt;&lt;i&gt;&quot;Quero colocar uma mensagem de confirmação via code-behind onde irá ser emitida para o usuário e a depender do que ele escolher irá ser processado um certo trecho de código ou outro. Tipo o confirm do JavaScript, só que é executado pelo ASP.NET.&quot;&lt;/i&gt;&lt;/blockquote&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgcy7OuUM47KWAKaIC4PAa-itzQvF_IqVFAWDRw_pORn3JEYA_732cnj7nO-FCQLoP6iPZIw0sQJPHUtj0ifTaMoQw4U-m8MJiW3ozrGOUY7EOL5YQGpsO2SnbUc9J6SpT8hfn2tQIg6c7j/s1600/confirm_box.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;125&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgcy7OuUM47KWAKaIC4PAa-itzQvF_IqVFAWDRw_pORn3JEYA_732cnj7nO-FCQLoP6iPZIw0sQJPHUtj0ifTaMoQw4U-m8MJiW3ozrGOUY7EOL5YQGpsO2SnbUc9J6SpT8hfn2tQIg6c7j/s400/confirm_box.png&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
No &lt;b&gt;&lt;a href=&quot;http://www.codeproject.com/info/search.aspx?artkw=confirm+message+c%23&amp;amp;sbo=kw&quot;&gt;Code Project&lt;/a&gt;&lt;/b&gt; tem várias formas de implementação e umas delas me chamou a atenção: o de &lt;a href=&quot;http://www.codeproject.com/KB/aspnet/AJAX_Enabled_MessageBox.aspx&quot;&gt;Yavuz Kucukpetek&lt;/a&gt;. Usando &lt;b&gt;AJAX &lt;/b&gt;é possível transformar um &lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;Panel &lt;/span&gt;nessa janela flutuante usando o &lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;ModalPopupExtender&lt;/span&gt;. Dei uma simplificada no código dele (já informei que não fiz, apenas ajustei) e você podem baixar o controle modificado&amp;nbsp;&lt;a href=&quot;http://www.mediafire.com/?w2qs8k68z5cqxm3&quot;&gt;aqui&lt;/a&gt;.&lt;br /&gt;
&lt;br /&gt;
Depois que baixarem o controle, adicione no seu projeto. Vamos lá! Na página que deseja utilizar o controle, registre-o e coloque-o da seguinte forma:&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;background-color: yellow;&quot;&gt;&amp;lt;%&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;@&lt;/span&gt; &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #990000;&quot;&gt;Register &lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red;&quot;&gt;Src&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;=&quot;~/inc_ConfirmMessage.ascx&quot;&lt;/span&gt; &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red;&quot;&gt;TagName&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;=&quot;ConfirmacaoBox&quot;&lt;/span&gt; &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red;&quot;&gt;TagPrefix&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;=&quot;Thiago&quot;&lt;/span&gt; &lt;span class=&quot;Apple-style-span&quot; style=&quot;background-color: yellow;&quot;&gt;%&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #990000;&quot;&gt;Thiago&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #990000;&quot;&gt;ConfirmacaoBox &lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red;&quot;&gt;ID&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;=&quot;ConfirmacaoBox&quot;&lt;/span&gt; &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red;&quot;&gt;runat&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;=&quot;server&quot;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #990000;&quot;&gt;Thiago&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #990000;&quot;&gt;ConfirmacaoBox&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
No &lt;i&gt;code-behind&lt;/i&gt; deverá ficar o seguinte:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;protected void&lt;/span&gt; Page_Load(&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;object &lt;/span&gt;sender, &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #3d85c6;&quot;&gt;EventArgs &lt;/span&gt;e)&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;{&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;ConfirmacaoBox.MsgBoxAnswered += Mensagem_Resposta;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;}&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;public void&lt;/span&gt; Mensagem_Resposta(&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;object &lt;/span&gt;sender, &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #3d85c6;&quot;&gt;inc_ConfirmMessage&lt;/span&gt;.&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #3d85c6;&quot;&gt;MsgBoxEventArgs &lt;/span&gt;e)&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;{&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;if&lt;/span&gt; (e.Answer == &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #3d85c6;&quot;&gt;inc_ConfirmMessage&lt;/span&gt;.&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #3d85c6;&quot;&gt;enmAnswer&lt;/span&gt;.OK)&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;{&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #38761d;&quot;&gt;// Se clicou em OK processa o que deseja&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;}&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;else&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;{&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #38761d;&quot;&gt;// Senão processa outra coisa&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;}&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;}&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;protected void&lt;/span&gt; ExecutaProcesso_Click(&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;object &lt;/span&gt;sender, &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #3d85c6;&quot;&gt;EventArgs &lt;/span&gt;e)&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;{&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;ConfirmacaoBox.AddMessage(&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red;&quot;&gt;&quot;Deseja continuar o cálculo do processo na mesma página?&quot;&lt;/span&gt;, &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #3d85c6;&quot;&gt;inc_ConfirmMessage&lt;/span&gt;.&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #3d85c6;&quot;&gt;enmMessageType&lt;/span&gt;.Attention, &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;true&lt;/span&gt;, &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;true&lt;/span&gt;, &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red;&quot;&gt;&quot;&quot;&lt;/span&gt;);&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;}&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
Pronto! Apenas isso... Vamos às explicações. No &lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;Page_Load &lt;/span&gt;precisamos informar o método que irá gerenciar as decisões do usuário, por isso informamos o &lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;Mensagem_Resposta&lt;/span&gt;. Dentro dele irá conter os processos que irão ser executados a depender da escolha. O &lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;ExecutaProcesso_Click &lt;/span&gt;é o método executado quando clicamos no botão que irá disparar a pergunta.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&lt;i&gt;&quot;Ah Thiago, mas aí é só apenas uma confirmação. E se eu quiser várias interações?&quot;&lt;/i&gt;&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
Simples, basta adicionar outra &lt;i&gt;Caixa de Confirmação&lt;/i&gt; para a segunda etapa de decisões chamando-a dentro do processo de decisão da primeira e assim por diante.</content><link rel='replies' type='application/atom+xml' href='http://thiagomarcal.blogspot.com/feeds/3069324185441307905/comments/default' title='Postar comentários'/><link rel='replies' type='text/html' href='http://thiagomarcal.blogspot.com/2011/03/utilizando-mensagem-de-confirmacao-e.html#comment-form' title='0 Comentários'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7002820434209519335/posts/default/3069324185441307905'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7002820434209519335/posts/default/3069324185441307905'/><link rel='alternate' type='text/html' href='http://thiagomarcal.blogspot.com/2011/03/utilizando-mensagem-de-confirmacao-e.html' title='Utilizando mensagem de confirmação e executando código de acordo com o que foi clicado na mesma página'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgcy7OuUM47KWAKaIC4PAa-itzQvF_IqVFAWDRw_pORn3JEYA_732cnj7nO-FCQLoP6iPZIw0sQJPHUtj0ifTaMoQw4U-m8MJiW3ozrGOUY7EOL5YQGpsO2SnbUc9J6SpT8hfn2tQIg6c7j/s72-c/confirm_box.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7002820434209519335.post-1453922554198862144</id><published>2011-03-12T16:55:00.000-03:00</published><updated>2011-03-12T16:55:03.026-03:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="acesso simultâneo"/><category scheme="http://www.blogger.com/atom/ns#" term="application"/><category scheme="http://www.blogger.com/atom/ns#" term="deadlock"/><category scheme="http://www.blogger.com/atom/ns#" term="dicas"/><title type='text'>Bloqueando apenas um acesso por vez em uma variável de aplicação</title><content type='html'>Toda aplicação &lt;i&gt;web &lt;/i&gt;que trabalhamos raramente pensamos na quantidade de acessos que são realizados simultaneamente em um determinado trecho de código. Um exemplo clássico é uma variável de contador de acessos/visitantes. Armazenamos o valor inicialmente em uma variável de aplicação. Depois quando um usuário acessa, é incrementado em 1. Só que se ao mesmo tempo acessar dois ou mais usuários, eles podem capturar o mesmo valor ou valor defasado e colocar a contagem errada. Veja o exemplo abaixo:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh0s48Y2IL4geMMmkEOxUKdYjBGaeOBqNrgXf44Wd8XEQWfjRTuGteHOcDrMpV7qJyyOdDc36pHDYzgXPgpCTr15Kj0AAcorYc7oSnjmrC4lZDoJ5xdc54Ky9wFqIdRT9Fet7k9lss_lwoh/s1600/acesso_simultaneo.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;292&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh0s48Y2IL4geMMmkEOxUKdYjBGaeOBqNrgXf44Wd8XEQWfjRTuGteHOcDrMpV7qJyyOdDc36pHDYzgXPgpCTr15Kj0AAcorYc7oSnjmrC4lZDoJ5xdc54Ky9wFqIdRT9Fet7k9lss_lwoh/s400/acesso_simultaneo.png&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
Quando tivemos o acesso simultâneo\paralelo, o valor capturado da variável da aplicação foi colhido pelos dois usuários e o valor armazenado foi comprometido. Para isso devemos bloquear o acesso à variável de aplicação e permitir apenas um usuário por vez executar a soma. Nesse caso, pode-se utilizar o seguinte trecho:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;try&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;{&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Application.Lock();&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;lock &lt;/span&gt;(&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;this&lt;/span&gt;)&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;{&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #38761d;&quot;&gt;// Trecho a ser executado que altera uma variável de aplicação ou bloco crítico&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;}&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Application.UnLock();&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;}&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;catch&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;{&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Application.UnLock();&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;}&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
O &lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;Application.Lock()&lt;/span&gt; irá bloquear o acesso de outros usuários às variáveis de aplicação e depois o&amp;nbsp;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;Application.UnLock()&lt;/span&gt; libera. O &lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;lock (this)&lt;/span&gt; permitirá apenas o acesso de um único usuário por vez no trecho de código crítico. A combinação dos dois métodos depende muito do que estiver fazendo. Cada caso tem seu respectivo uso. O simples uso do &lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;lock (this)&lt;/span&gt;&amp;nbsp;pode resolver... Ele é muito usado para evitar &lt;i&gt;&lt;a href=&quot;http://pt.wikipedia.org/wiki/Deadlock&quot;&gt;deadlocks&lt;/a&gt;&lt;/i&gt;. No mais, só isso. Recomendo dar uma lida posteriormente nos artigos abaixo:&lt;br /&gt;
&lt;br /&gt;
&lt;ul&gt;&lt;li&gt;&lt;a href=&quot;http://msdn.microsoft.com/en-us/library/c5kehkcz.aspx&quot;&gt;Lock Statment&lt;/a&gt;&amp;nbsp;- MSDN&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://support.microsoft.com/kb/271787/pt-br&quot;&gt;Problemas no uso de Application.Lock() e Application.UnLock()&lt;/a&gt;&amp;nbsp;- MSDN&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://technet.microsoft.com/pt-br/library/ms177433.aspx&quot;&gt;Deadlock&lt;/a&gt;&amp;nbsp;- Technet&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://www.macoratti.net/07/06/aspn_tas.htm&quot;&gt;Apresentando o objeto Application&lt;/a&gt; - Marcoratti&lt;/li&gt;
&lt;/ul&gt;</content><link rel='replies' type='application/atom+xml' href='http://thiagomarcal.blogspot.com/feeds/1453922554198862144/comments/default' title='Postar comentários'/><link rel='replies' type='text/html' href='http://thiagomarcal.blogspot.com/2011/03/bloqueando-apenas-um-acesso-por-vez-em.html#comment-form' title='0 Comentários'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7002820434209519335/posts/default/1453922554198862144'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7002820434209519335/posts/default/1453922554198862144'/><link rel='alternate' type='text/html' href='http://thiagomarcal.blogspot.com/2011/03/bloqueando-apenas-um-acesso-por-vez-em.html' title='Bloqueando apenas um acesso por vez em uma variável de aplicação'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh0s48Y2IL4geMMmkEOxUKdYjBGaeOBqNrgXf44Wd8XEQWfjRTuGteHOcDrMpV7qJyyOdDc36pHDYzgXPgpCTr15Kj0AAcorYc7oSnjmrC4lZDoJ5xdc54Ky9wFqIdRT9Fet7k9lss_lwoh/s72-c/acesso_simultaneo.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7002820434209519335.post-8501635421406201322</id><published>2011-03-12T16:16:00.001-03:00</published><updated>2011-03-12T16:18:41.105-03:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="desempenho"/><category scheme="http://www.blogger.com/atom/ns#" term="dicas"/><category scheme="http://www.blogger.com/atom/ns#" term="dll"/><category scheme="http://www.blogger.com/atom/ns#" term="iis"/><title type='text'>Diferenças entre Aplicações Compiladas e Não-Compiladas</title><content type='html'>Quando programávamos (ou programamos) com aquelas linguagens do tipo &lt;b&gt;PHP &lt;/b&gt;ou &lt;b&gt;ASP Clássico&lt;/b&gt; apenas pegávamos o que foi implementado e jogávamos no servidor &lt;i&gt;web &lt;/i&gt;para uso. Com a inovação das tecnologias e tipos de linguagens (compiladas, interpretadas, híbridas) algumas dúvidas nos cercam quando estamos publicando um certo projeto. Nesse caso, falemos do ASP.NET para as versões acima da 2.0.&lt;br /&gt;
&lt;br /&gt;
Antes de mais nada, o ASP.NET é &lt;a href=&quot;http://msdn.microsoft.com/pt-br/library/ms178466.aspx&quot;&gt;compilado&lt;/a&gt;. Mesmo que você jogue os fontes no &lt;b&gt;IIS &lt;/b&gt;ele é compilado na primeira vez que é acessado (e/ou alterado). Você não vê, mas por trás é feito isso. Para quem nunca compilou uma aplicação &lt;i&gt;web&lt;/i&gt;, há diversas formas para uma dada finalidade. Geralmente é usada a função &lt;b&gt;Publish Web Site &lt;/b&gt;(compila e publica).&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhT4HVpUGAiLNkgwrBjDtrAJXgv79re2aMyrCFmTo-4QqIWd_Fk48PcaYBWCtFy2Kbdwl_fcrs5jfMHu-oDuO_QxNQbFpTaydxjxZlpqgyp5J1f48R7WX0sf4ZKr8nVzUHptJ45kWDxfoT9/s1600/publicar_web_site.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhT4HVpUGAiLNkgwrBjDtrAJXgv79re2aMyrCFmTo-4QqIWd_Fk48PcaYBWCtFy2Kbdwl_fcrs5jfMHu-oDuO_QxNQbFpTaydxjxZlpqgyp5J1f48R7WX0sf4ZKr8nVzUHptJ45kWDxfoT9/s1600/publicar_web_site.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
Mas o que muitos perguntam é: &lt;i&gt;existe diferença de desempenho?&lt;/i&gt; &lt;b&gt;Não!&lt;/b&gt; Muitos dizem que há um pouco, mas já trabalhei com várias aplicações e não notei qualquer diferença. Li vários artigos por aí na &lt;i&gt;net &lt;/i&gt;e não achei qualquer um que demonstrasse e/ou notasse diferença brusca de desempenho. Então, elaborei a seguinte &lt;i&gt;tabelinha &lt;/i&gt;abaixo com um pequeno resumo. Se tiver mais, favor avisar-me que atualizo:&lt;br /&gt;
&lt;br /&gt;
&lt;table border=&quot;1&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;MsoTableLightListAccent1&quot; style=&quot;border-collapse: collapse; border: none; mso-border-alt: solid #4F81BD 1.0pt; mso-border-themecolor: accent1; mso-padding-alt: 0cm 5.4pt 0cm 5.4pt; mso-yfti-tbllook: 1184;&quot;&gt;&lt;tbody&gt;
&lt;tr style=&quot;mso-yfti-firstrow: yes; mso-yfti-irow: -1;&quot;&gt;   &lt;td style=&quot;background: #4F81BD; border-bottom: none; border-left: solid #4F81BD 1.0pt; border-right: none; border-top: solid #4F81BD 1.0pt; mso-background-themecolor: accent1; mso-border-left-themecolor: accent1; mso-border-top-themecolor: accent1; padding: 0cm 5.4pt 0cm 5.4pt; width: 144.05pt;&quot; valign=&quot;top&quot; width=&quot;192&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-yfti-cnfc: 5;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/td&gt;   &lt;td style=&quot;background: #4F81BD; border-top: solid #4F81BD 1.0pt; border: none; mso-background-themecolor: accent1; mso-border-top-themecolor: accent1; padding: 0cm 5.4pt 0cm 5.4pt; width: 144.05pt;&quot; valign=&quot;top&quot; width=&quot;192&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-yfti-cnfc: 1;&quot;&gt;&lt;b&gt;&lt;span style=&quot;color: white;&quot;&gt;Compilada&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;/td&gt;   &lt;td style=&quot;background: #4F81BD; border-bottom: none; border-left: none; border-right: solid #4F81BD 1.0pt; border-top: solid #4F81BD 1.0pt; mso-background-themecolor: accent1; mso-border-right-themecolor: accent1; mso-border-top-themecolor: accent1; padding: 0cm 5.4pt 0cm 5.4pt; width: 144.1pt;&quot; valign=&quot;top&quot; width=&quot;192&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-yfti-cnfc: 1;&quot;&gt;&lt;b&gt;&lt;span style=&quot;color: white;&quot;&gt;Não-Compilada&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;/td&gt;  &lt;/tr&gt;
&lt;tr style=&quot;mso-yfti-irow: 0;&quot;&gt;   &lt;td style=&quot;border-right: none; border: solid #4F81BD 1.0pt; mso-border-themecolor: accent1; padding: 0cm 5.4pt 0cm 5.4pt; width: 144.05pt;&quot; valign=&quot;top&quot; width=&quot;192&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-yfti-cnfc: 68;&quot;&gt;&lt;b&gt;&lt;o:p&gt;&amp;nbsp;Desempenho&lt;/o:p&gt;&lt;/b&gt;&lt;/div&gt;&lt;/td&gt;   &lt;td style=&quot;border-bottom: solid #4F81BD 1.0pt; border-left: none; border-right: none; border-top: solid #4F81BD 1.0pt; mso-border-bottom-themecolor: accent1; mso-border-top-themecolor: accent1; padding: 0cm 5.4pt 0cm 5.4pt; width: 144.05pt;&quot; valign=&quot;top&quot; width=&quot;192&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-yfti-cnfc: 64;&quot;&gt;&lt;o:p&gt;&amp;nbsp;Normal&lt;/o:p&gt;&lt;/div&gt;&lt;/td&gt;   &lt;td style=&quot;border-left: none; border: solid #4F81BD 1.0pt; mso-border-themecolor: accent1; padding: 0cm 5.4pt 0cm 5.4pt; width: 144.1pt;&quot; valign=&quot;top&quot; width=&quot;192&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-yfti-cnfc: 64;&quot;&gt;&lt;o:p&gt;Normal&lt;/o:p&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr style=&quot;mso-yfti-irow: 2; mso-yfti-lastrow: yes;&quot;&gt;   &lt;td style=&quot;border-right: none; border: solid #4F81BD 1.0pt; mso-border-themecolor: accent1; padding: 0cm 5.4pt 0cm 5.4pt; width: 144.05pt;&quot; valign=&quot;top&quot; width=&quot;192&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-yfti-cnfc: 68;&quot;&gt;&lt;b&gt;&lt;o:p&gt;&amp;nbsp;Código-fonte&lt;/o:p&gt;&lt;/b&gt;&lt;/div&gt;&lt;/td&gt;   &lt;td style=&quot;border-bottom: solid #4F81BD 1.0pt; border-left: none; border-right: none; border-top: solid #4F81BD 1.0pt; mso-border-bottom-themecolor: accent1; mso-border-top-themecolor: accent1; padding: 0cm 5.4pt 0cm 5.4pt; width: 144.05pt;&quot; valign=&quot;top&quot; width=&quot;192&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-yfti-cnfc: 64;&quot;&gt;&lt;o:p&gt;&amp;nbsp;Protegido em DLL&#39;s&lt;/o:p&gt;&lt;/div&gt;&lt;/td&gt;   &lt;td style=&quot;border-left: none; border: solid #4F81BD 1.0pt; mso-border-themecolor: accent1; padding: 0cm 5.4pt 0cm 5.4pt; width: 144.1pt;&quot; valign=&quot;top&quot; width=&quot;192&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-yfti-cnfc: 64;&quot;&gt;&lt;o:p&gt;Visível&amp;nbsp;&lt;/o:p&gt;&lt;/div&gt;&lt;/td&gt;  &lt;/tr&gt;
&lt;tr style=&quot;mso-yfti-irow: 2; mso-yfti-lastrow: yes;&quot;&gt;   &lt;td style=&quot;border-right: none; border: solid #4F81BD 1.0pt; mso-border-themecolor: accent1; padding: 0cm 5.4pt 0cm 5.4pt; width: 144.05pt;&quot; valign=&quot;top&quot; width=&quot;192&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-yfti-cnfc: 68;&quot;&gt;&lt;b&gt;&lt;o:p&gt;&amp;nbsp;HTML&lt;/o:p&gt;&lt;/b&gt;&lt;/div&gt;&lt;/td&gt;   &lt;td style=&quot;border-bottom: solid #4F81BD 1.0pt; border-left: none; border-right: none; border-top: solid #4F81BD 1.0pt; mso-border-bottom-themecolor: accent1; mso-border-top-themecolor: accent1; padding: 0cm 5.4pt 0cm 5.4pt; width: 144.05pt;&quot; valign=&quot;top&quot; width=&quot;192&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-yfti-cnfc: 64;&quot;&gt;&lt;o:p&gt;&amp;nbsp;Sem mudança&lt;/o:p&gt;&lt;/div&gt;&lt;/td&gt;   &lt;td style=&quot;border-left: none; border: solid #4F81BD 1.0pt; mso-border-themecolor: accent1; padding: 0cm 5.4pt 0cm 5.4pt; width: 144.1pt;&quot; valign=&quot;top&quot; width=&quot;192&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-yfti-cnfc: 64;&quot;&gt;&lt;o:p&gt;Sem mudança&amp;nbsp;&lt;/o:p&gt;&lt;/div&gt;&lt;/td&gt;  &lt;/tr&gt;
&lt;tr style=&quot;mso-yfti-irow: 2; mso-yfti-lastrow: yes;&quot;&gt;   &lt;td style=&quot;border-right: none; border: solid #4F81BD 1.0pt; mso-border-themecolor: accent1; padding: 0cm 5.4pt 0cm 5.4pt; width: 144.05pt;&quot; valign=&quot;top&quot; width=&quot;192&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-yfti-cnfc: 68;&quot;&gt;&lt;b&gt;&lt;o:p&gt;&amp;nbsp;Atualização\Correção&lt;/o:p&gt;&lt;/b&gt;&lt;/div&gt;&lt;/td&gt;   &lt;td style=&quot;border-bottom: solid #4F81BD 1.0pt; border-left: none; border-right: none; border-top: solid #4F81BD 1.0pt; mso-border-bottom-themecolor: accent1; mso-border-top-themecolor: accent1; padding: 0cm 5.4pt 0cm 5.4pt; width: 144.05pt;&quot; valign=&quot;top&quot; width=&quot;192&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-yfti-cnfc: 64;&quot;&gt;&lt;o:p&gt;&amp;nbsp;Precisa compilar todo o projeto e publicá-lo (código-fonte) enquanto no &lt;i&gt;design &lt;/i&gt;pode alterar normalmente&lt;/o:p&gt;&lt;/div&gt;&lt;/td&gt;   &lt;td style=&quot;border-left: none; border: solid #4F81BD 1.0pt; mso-border-themecolor: accent1; padding: 0cm 5.4pt 0cm 5.4pt; width: 144.1pt;&quot; valign=&quot;top&quot; width=&quot;192&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-yfti-cnfc: 64;&quot;&gt;&lt;o:p&gt;Pode alterar diretamente no problema (página)&lt;/o:p&gt;&lt;/div&gt;&lt;/td&gt;  &lt;/tr&gt;
&lt;tr style=&quot;mso-yfti-irow: 2; mso-yfti-lastrow: yes;&quot;&gt;   &lt;td style=&quot;border-right: none; border: solid #4F81BD 1.0pt; mso-border-themecolor: accent1; padding: 0cm 5.4pt 0cm 5.4pt; width: 144.05pt;&quot; valign=&quot;top&quot; width=&quot;192&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-yfti-cnfc: 68;&quot;&gt;&lt;b&gt;&lt;o:p&gt;&amp;nbsp;Primeiro Acesso&lt;/o:p&gt;&lt;/b&gt;&lt;/div&gt;&lt;/td&gt;   &lt;td style=&quot;border-bottom: solid #4F81BD 1.0pt; border-left: none; border-right: none; border-top: solid #4F81BD 1.0pt; mso-border-bottom-themecolor: accent1; mso-border-top-themecolor: accent1; padding: 0cm 5.4pt 0cm 5.4pt; width: 144.05pt;&quot; valign=&quot;top&quot; width=&quot;192&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-yfti-cnfc: 64;&quot;&gt;&lt;o:p&gt;&amp;nbsp;Normal&lt;/o:p&gt;&lt;/div&gt;&lt;/td&gt;   &lt;td style=&quot;border-left: none; border: solid #4F81BD 1.0pt; mso-border-themecolor: accent1; padding: 0cm 5.4pt 0cm 5.4pt; width: 144.1pt;&quot; valign=&quot;top&quot; width=&quot;192&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-yfti-cnfc: 64;&quot;&gt;&lt;o:p&gt;Lento&amp;nbsp;&lt;/o:p&gt;&lt;/div&gt;&lt;/td&gt;  &lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;
Óbvio que toda regra tem sua exceção, então a depender dos casos supra-citados pode haver pequenos detalhes que mudam uma coisinha ou outra mas nada de tão drástico (de acordo com a tabela - exemplo, na compilação FULL você não altera sequer o HTML). Se quiserem conhecer mais sobre os tipos de compilação (Full, Pré ou Sob-Demanda) visite os links da &lt;a href=&quot;http://msdn.microsoft.com/pt-br/library/cc580627.aspx&quot;&gt;MSDN&lt;/a&gt; e de &lt;a href=&quot;http://www.bufaloinfo.com.br/artigos/artigo13072005.asp&quot;&gt;Dennes Torres&lt;/a&gt;.</content><link rel='replies' type='application/atom+xml' href='http://thiagomarcal.blogspot.com/feeds/8501635421406201322/comments/default' title='Postar comentários'/><link rel='replies' type='text/html' href='http://thiagomarcal.blogspot.com/2011/03/diferencas-entre-aplicacoes-compiladas.html#comment-form' title='0 Comentários'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7002820434209519335/posts/default/8501635421406201322'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7002820434209519335/posts/default/8501635421406201322'/><link rel='alternate' type='text/html' href='http://thiagomarcal.blogspot.com/2011/03/diferencas-entre-aplicacoes-compiladas.html' title='Diferenças entre Aplicações Compiladas e Não-Compiladas'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhT4HVpUGAiLNkgwrBjDtrAJXgv79re2aMyrCFmTo-4QqIWd_Fk48PcaYBWCtFy2Kbdwl_fcrs5jfMHu-oDuO_QxNQbFpTaydxjxZlpqgyp5J1f48R7WX0sf4ZKr8nVzUHptJ45kWDxfoT9/s72-c/publicar_web_site.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7002820434209519335.post-4198656032609958204</id><published>2011-02-27T16:57:00.001-03:00</published><updated>2011-02-27T16:59:28.486-03:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="componentes"/><category scheme="http://www.blogger.com/atom/ns#" term="dicas"/><category scheme="http://www.blogger.com/atom/ns#" term="dll"/><category scheme="http://www.blogger.com/atom/ns#" term="imagem"/><category scheme="http://www.blogger.com/atom/ns#" term="pdf"/><category scheme="http://www.blogger.com/atom/ns#" term="thumbnail"/><title type='text'>Convertendo HTML em PDF</title><content type='html'>Nesse artigo veremos como converter um HTML em PDF. O HTML pode vir de uma página externa quanto ser criado em tempo de execução. Não haverá muito o que explicar pois o código em si, você encontra a rodo pela &lt;i&gt;net&lt;/i&gt;. Usaremos o componente &lt;b&gt;&lt;a href=&quot;http://sourceforge.net/projects/itextsharp/&quot;&gt;iTextSharp&lt;/a&gt;&lt;/b&gt;.&lt;br /&gt;
&lt;br /&gt;
Baixe o binário e adicione em seu aplicativo (pasta &lt;b&gt;Bin&lt;/b&gt;). Utilize o código abaixo para fazer o processo de conversão e exibição do PDF na tela:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;using &lt;/span&gt;System;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;using &lt;/span&gt;System.Web;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;using &lt;/span&gt;System.IO;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;using &lt;/span&gt;iTextSharp.text;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;using &lt;/span&gt;iTextSharp.text.pdf;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;using &lt;/span&gt;iTextSharp.text.html.simpleparser;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #38761d;&quot;&gt;// Captura ou atribui o HTML a ser convertido - no caso estou baixando de uma URL&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;string &lt;/span&gt;html = &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;new &lt;/span&gt;System.Net.&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #3d85c6;&quot;&gt;WebClient&lt;/span&gt;().DownloadString(&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #990000;&quot;&gt;&quot;http://thiagomarcal.blogspot.com/&quot;&lt;/span&gt;);&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #38761d;&quot;&gt;//string html = &quot;Convertendo o HTML em PDF - Thiago Marçal&quot;;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #38761d; font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;// Cria o documento aplicando o tamanho e margens&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #3d85c6;&quot;&gt;Document &lt;/span&gt;documento = &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;new &lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #3d85c6;&quot;&gt;Document&lt;/span&gt;(&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #3d85c6;&quot;&gt;PageSize&lt;/span&gt;.A4, 80, 50, 30, 65);&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #38761d;&quot;&gt;// Memory Stream para ser usado na conversão e emissão&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #3d85c6;&quot;&gt;MemoryStream &lt;/span&gt;ms = &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;new &lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #3d85c6;&quot;&gt;MemoryStream&lt;/span&gt;();&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #38761d;&quot;&gt;// Inicializa o gravador&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #3d85c6;&quot;&gt;PdfWriter &lt;/span&gt;writer = &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #3d85c6;&quot;&gt;PdfWriter&lt;/span&gt;.GetInstance(documento, ms);&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #38761d;&quot;&gt;// Lê o HTML e atribui&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #3d85c6;&quot;&gt;StringReader &lt;/span&gt;conteudo = &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;new &lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #3d85c6;&quot;&gt;StringReader&lt;/span&gt;(html);&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #38761d;&quot;&gt;// Objeto de conversão do HTML&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #3d85c6;&quot;&gt;HTMLWorker &lt;/span&gt;objeto = &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;new &lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #3d85c6;&quot;&gt;HTMLWorker&lt;/span&gt;(documento);&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #38761d;&quot;&gt;// Abre o documento&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;documento.Open();&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #38761d;&quot;&gt;// Aplica o parser para análise de conversão&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #38761d; font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;// Geralmente aqui ocasiona muitos erros - irei explicar no post&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;objeto.Parse(conteudo);&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #38761d;&quot;&gt;// Fecha o documento&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;documento.Close();&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #38761d;&quot;&gt;// Força o download do PDF gerado - se desejável você pode salvar em disco também&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Response.Clear();&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Response.AddHeader(&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #990000;&quot;&gt;&quot;content-disposition&quot;, &quot;attachment; filename=Documento_HTML.pdf&quot;&lt;/span&gt;);&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Response.ContentType = &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #990000;&quot;&gt;&quot;application/pdf&quot;&lt;/span&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Response.Buffer = &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;true&lt;/span&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Response.OutputStream.Write(ms.GetBuffer(), 0, ms.GetBuffer().Length);&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Response.OutputStream.Flush();&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Response.End();&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Veja que a variável &lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;html &lt;/span&gt;eu atribuo o HTML que desejo converter. O seu conteúdo pode vir externamente ou posso atribuir um valor desejado.&lt;br /&gt;
&lt;br /&gt;
Vamos aos problemas! Muitos vão encontrar erro quando o objeto estiver fazendo o &lt;i&gt;parser &lt;/i&gt;do HTML e muitos irão falhar. Acontece que, devido à complexidade do HTML que estiver trabalhando, o componente não consegue converter para o formato adequado ao que ele usa internamente. Por exemplo, o &lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;TABLE &lt;/span&gt;do HTML que usamos é &quot;meio&quot; diferente do &lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;TABLE &lt;/span&gt;que o componente usa. Esse é um dos exemplos... Então prepara-se para fazer um tratamento adequado antes de fazer o &lt;i&gt;parser&lt;/i&gt;. Eu sugiro o seguinte:&lt;br /&gt;
&lt;ol&gt;&lt;li&gt;Use expressão regular para validar seu HTML;&lt;/li&gt;
&lt;li&gt;Use expressão regular e/ou o &lt;a href=&quot;http://htmlagilitypack.codeplex.com/&quot;&gt;HtmlAgilityPack&lt;/a&gt;&amp;nbsp;para remover os JavaScripts;&lt;/li&gt;
&lt;li&gt;O conteúdo a ser convertido deve ser apenas o que está dentro do &lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;body&lt;/span&gt;;&lt;/li&gt;
&lt;li&gt;Imagens, CSS e links devem conter o caminho completo (exemplo: http://thiagomarcal.blogspot.com/imgs/logo.png ao invés de ../imgs/logo.png), etc.&lt;/li&gt;
&lt;/ol&gt;&lt;div&gt;Ou seja, quanto mais simplificado for seu HTML mais rápido e fácil será convertido em PDF. Uma observação bem clara é: nem sempre ficará 100% que o esperado.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div&gt;Uma dica que pode ser usada (e um armengue, claro!) é fazer o seguinte:&lt;/div&gt;&lt;div&gt;&lt;ol&gt;&lt;li&gt;Gere um &lt;i&gt;thumb &lt;/i&gt;(imagem) do HTML que deseja converter (saiba como gerar um &lt;i&gt;thumb &lt;/i&gt;de um HTML nesse &lt;a href=&quot;http://thiagomarcal.blogspot.com/2010/12/gerar-thumbnail-de-um-html.html&quot;&gt;post&lt;/a&gt;) e salve em disco;&lt;/li&gt;
&lt;li&gt;Atribua a variável &lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;html &lt;/span&gt;com o conteúdo &lt;i&gt;&quot;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;lt;img src=&quot;http://thiagomarcal.blogspot.com/imgs/thumb.png&quot; /&amp;gt;&lt;/span&gt;&quot;&lt;/i&gt;;&lt;/li&gt;
&lt;li&gt;Coloque o &lt;b&gt;width &lt;/b&gt;e &lt;b&gt;height &lt;/b&gt;na &lt;i&gt;tag &lt;/i&gt;IMG o tamanho desejado (pode ser até o tamanho do papel).&lt;/li&gt;
&lt;/ol&gt;&lt;/div&gt;&lt;div&gt;Pronto! O &lt;i&gt;parser &lt;/i&gt;irá identificar apenas uma imagem no HTML e gerará o PDF com ela. Mole-mole...&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://thiagomarcal.blogspot.com/feeds/4198656032609958204/comments/default' title='Postar comentários'/><link rel='replies' type='text/html' href='http://thiagomarcal.blogspot.com/2011/02/convertendo-html-em-pdf.html#comment-form' title='6 Comentários'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7002820434209519335/posts/default/4198656032609958204'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7002820434209519335/posts/default/4198656032609958204'/><link rel='alternate' type='text/html' href='http://thiagomarcal.blogspot.com/2011/02/convertendo-html-em-pdf.html' title='Convertendo HTML em PDF'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>6</thr:total></entry></feed>