tag:blogger.com,1999:blog-192068932024-03-14T04:56:42.193+01:00fhtinoFabriziohttp://www.blogger.com/profile/08391423682734740591noreply@blogger.comBlogger121125tag:blogger.com,1999:blog-19206893.post-26581093075883112832016-12-06T21:12:00.000+01:002016-12-06T21:12:27.705+01:00First tests with SQL Server vNext on Linux and Windows<br />
<a href="http://www.fhtino.it/blog/showpost.aspx?id=6790c78accb84f9c9d0ecd315ec3f450">http://www.fhtino.it/blog/showpost.aspx?id=6790c78accb84f9c9d0ecd315ec3f450</a><br />
<br />Fabriziohttp://www.blogger.com/profile/08391423682734740591noreply@blogger.com0tag:blogger.com,1999:blog-19206893.post-62379864016727807132016-04-27T21:12:00.003+02:002016-04-28T09:35:00.307+02:00Visual studio 2015 update 2... e siamo alle solite: un update che scassa quello che prima funzionava.<br />
<br />
Votate, votate, votate!<br />
<br />
<a href="https://connect.microsoft.com/VisualStudio/feedback/details/2551316/untracked-files-section-missing-from-git-changes-dialog">https://connect.microsoft.com/VisualStudio/feedback/details/2551316/untracked-files-section-missing-from-git-changes-dialog</a><br />
<br />
<br />
<br />
<br />Fabriziohttp://www.blogger.com/profile/08391423682734740591noreply@blogger.com0tag:blogger.com,1999:blog-19206893.post-32295328806022600362015-08-22T11:06:00.004+02:002015-08-22T11:06:41.775+02:00MSDeployUseChecksum too slowThe new (2013) web deploy based on file checksum is very interesting. But it's really too slow. I've tested it on a small web site on Azure (50 items aspx, images, dll, js,. etc). It requires about 3 minutes to check the site and create the list for updates. Too slow. It's completely useless. What a pity!<div>
<br />I noticed an high usage of outbound network on my PC and low inbound. I suppose that Visual Studio transfers all the files to the remote server for the check. Mine is only a guess.<br /><br />http://blogs.msdn.com/b/webdev/archive/2013/10/30/web-publishing-updates-for-app-offline-and-usechecksum.aspx <br /></div>
Fabriziohttp://www.blogger.com/profile/08391423682734740591noreply@blogger.com0tag:blogger.com,1999:blog-19206893.post-45629008948569512922014-05-14T07:00:00.000+02:002014-05-14T13:06:50.763+02:00Informazioni di base su email e filtri antispam[Per un amico, ma potrebbe essere utile anche ad altri, quindi scrivo qui in pubblico]<br />
<br />
Un po' di informazioni di base su email e filtri anti-spam.<br />
<br />
In estrema sintesi, spesso un'email fa vari salti e passa attraverso vari server prima di giungere al destinatario. Durante questi salti possono intervenire vari sistemi antispam.<br />
Un scenario tipico prevede questi passaggi:<br />
- client del mittente<br />
- server del provider email del mittente<br />
- (eventuali server smtp intermedi)<br />
- server del provider email del destinatario<br />
- client del destinatario<br />
<br />
Il "client" può essere un vero client (ad esempio Office Outlook) oppure un'applicazione web (ad esempio GMail).<br />
Lo spam può essere filtrato (cioè tolto dalla "inbox" e messo in una sottocartella) e/o bloccato, quindi messaggio non accettato e rimandato al mittente. Chi filtra e/o blocca lo spam? Putroppo un po' tutti: server mittente, server intermedi, server destinatario e client destinatario.<br />
Alcune volte capita di mandare un messaggio ma il destinatario non lo vede. Dov'è andato a finire? In molti posti: rimandato al mittente, cancellato in automatico, messo in sottocartelle di spam/junk, parzialmente cancellato. Quindi il messaggio potrebbe essere in qualche sottocartella "spam" del server destinatario ma non essere visibile dal client del destinatario perchè il client scarica solo la posta della cartella "Inbox/Posta in arrivo", che è già stata filtrata dal server. Oppure essere nella cartella Spam del client locale (ad esempio outlook).<br />
<br />
La cosa si complica se il messaggio viene inviato a più persone, o direttamente o via sistemi di mailing-list. Lo stesso messaggio viene copiato ed inviato ad ogni destinatario. In generale ogni copia del messaggio può seguire un percorso diverso, quindi incontrare filtri e regole diverse anti-spam. Risultato? Alcuni ricevono, altri no. E tu, mittente, hai dei feedback? Alcune volte si, altre purtroppo no.<br />
<br />
Bisogna poi ricordarsi che esistono anche le blacklist di smtp server e range di indirizzi IP. Quindi il server del mittente potrebbe non essere in grado di inviare email indipendentemente dai filtri antispam.<br />
<br />
<div>
<br /></div>
Fabriziohttp://www.blogger.com/profile/08391423682734740591noreply@blogger.com0tag:blogger.com,1999:blog-19206893.post-39146815810888621682014-02-27T07:00:00.000+01:002014-02-27T14:19:15.029+01:00How to move records between tablesAD FUTURAM REI MEMORIAM :)<br />
How to move all records from a source table to a destination table.<br />
<br />
This following command only works if the two table are identical (same fields in the same order):<br />
<br />
DELETE [SourceTable]<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>OUTPUT<br />
DELETED.*<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>INTO [DestinationTable]<br />
<div>
<br /></div>
<div>
<br /></div>
<div>
If stuctures are different, then you need to specify every field you want to copy, respecting the order of the fields of the destination table:</div>
<div>
<br /></div>
<div>
DELETE [SourceTable]<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>OUTPUT<br />
DELETED.Name,<br />
<div>
DELETED.Age,</div>
<div>
DELETED.Address</div>
INTO [DestinationTable]<br />
<br />
<br /></div>
Fabriziohttp://www.blogger.com/profile/08391423682734740591noreply@blogger.com0tag:blogger.com,1999:blog-19206893.post-71929189639841517412013-12-16T07:00:00.000+01:002013-12-16T11:43:30.577+01:00New Azure Storage Client not compatible with current Storage EmulatorBad news. Azure Storage Client 3.0 and 3.0.1 is not compatible with Storage Emulator 2.2 (the current version). You will get a generic "The remote server returned an error: (400) Bad Request." on CreateIfNotExists().<br />
<br />
No mention on releses https://github.com/WindowsAzure/azure-storage-net/blob/master/README.md<br />
Info here: <a href="http://blogs.msdn.com/b/windowsazurestorage/archive/2013/11/27/windows-azure-storage-release-introducing-cors-json-minute-metrics-and-more.aspx">http://blogs.msdn.com/b/windowsazurestorage/archive/2013/11/27/windows-azure-storage-release-introducing-cors-json-minute-metrics-and-more.aspx</a><br />
<br />
:(<br />
<br />
<br />
<br />
<br />Fabriziohttp://www.blogger.com/profile/08391423682734740591noreply@blogger.com0tag:blogger.com,1999:blog-19206893.post-16594581102907098152013-12-14T17:09:00.001+01:002013-12-14T17:09:37.528+01:00Calculate space used by VHD on Azure Blob StorageA piece of code to calculate space used by VHD files (Azure Virtual Machine) on Azure Blob Storage.<br />
Code adapted (and fixed) from a previous post of Michel Chi http://nettecharticles.blogspot.tw/2012/12/azurevhdcharge.html<br />
<br />
<br />
<span style="font-family: Courier New, Courier, monospace; font-size: xx-small;"> public static void Exec()</span><br />
<span style="font-family: Courier New, Courier, monospace; font-size: xx-small;"> {</span><br />
<span style="font-family: Courier New, Courier, monospace; font-size: xx-small;"> string accountName = ".......";</span><br />
<span style="font-family: Courier New, Courier, monospace; font-size: xx-small;"> string keyValue = ".......";</span><br />
<span style="font-family: Courier New, Courier, monospace; font-size: xx-small;"><br /></span>
<span style="font-family: Courier New, Courier, monospace; font-size: xx-small;"> Console.WriteLine("UTC NOW : " + DateTime.UtcNow);</span><br />
<span style="font-family: Courier New, Courier, monospace; font-size: xx-small;"><br /></span>
<span style="font-family: Courier New, Courier, monospace; font-size: xx-small;"> float GB = (1024 * 1024 * 1024);</span><br />
<span style="font-family: Courier New, Courier, monospace; font-size: xx-small;"> float totalBytes = 0;</span><br />
<span style="font-family: Courier New, Courier, monospace; font-size: xx-small;"><br /></span>
<span style="font-family: Courier New, Courier, monospace; font-size: xx-small;"> var storage = new CloudStorageAccount(new Microsoft.WindowsAzure.Storage.Auth.StorageCredentials(accountName, keyValue), false);</span><br />
<span style="font-family: Courier New, Courier, monospace; font-size: xx-small;"> var blobClient = storage.CreateCloudBlobClient();</span><br />
<span style="font-family: Courier New, Courier, monospace; font-size: xx-small;"> var vhds = blobClient.GetContainerReference("vhds");</span><br />
<span style="font-family: Courier New, Courier, monospace; font-size: xx-small;"> var blobs = vhds.ListBlobs();</span><br />
<span style="font-family: Courier New, Courier, monospace; font-size: xx-small;"><br /></span>
<span style="font-family: Courier New, Courier, monospace; font-size: xx-small;"> foreach (var blob in blobs)</span><br />
<span style="font-family: Courier New, Courier, monospace; font-size: xx-small;"> {</span><br />
<span style="font-family: Courier New, Courier, monospace; font-size: xx-small;"> var pageBlob = vhds.GetPageBlobReference(blob.Uri.Segments.Last());</span><br />
<span style="font-family: Courier New, Courier, monospace; font-size: xx-small;"> pageBlob.FetchAttributes();</span><br />
<span style="font-family: Courier New, Courier, monospace; font-size: xx-small;"> var pageRanges = pageBlob.GetPageRanges();</span><br />
<span style="font-family: Courier New, Courier, monospace; font-size: xx-small;"><br /></span>
<span style="font-family: Courier New, Courier, monospace; font-size: xx-small;"> float vhdBytes = pageRanges.Sum(x => x.EndOffset - x.StartOffset);</span><br />
<span style="font-family: Courier New, Courier, monospace; font-size: xx-small;"><br /></span>
<span style="font-family: Courier New, Courier, monospace; font-size: xx-small;"> totalBytes += vhdBytes;</span><br />
<span style="font-family: Courier New, Courier, monospace; font-size: xx-small;"><br /></span>
<span style="font-family: Courier New, Courier, monospace; font-size: xx-small;"> Console.WriteLine(new string('-', 60));</span><br />
<span style="font-family: Courier New, Courier, monospace; font-size: xx-small;"> Console.WriteLine("ID = " + blob.Uri.Segments.Last());</span><br />
<span style="font-family: Courier New, Courier, monospace; font-size: xx-small;"> Console.WriteLine("Used GB = " + vhdBytes / GB);</span><br />
<span style="font-family: Courier New, Courier, monospace; font-size: xx-small;"> Console.WriteLine("DailyUsage = " + vhdBytes / GB / 31.0);</span><br />
<span style="font-family: Courier New, Courier, monospace; font-size: xx-small;"> Console.WriteLine("PageRanges = " + pageRanges.Count()); </span><br />
<span style="font-family: Courier New, Courier, monospace; font-size: xx-small;"><br /></span>
<span style="font-family: Courier New, Courier, monospace; font-size: xx-small;"> }</span><br />
<span style="font-family: Courier New, Courier, monospace; font-size: xx-small;"><br /></span>
<span style="font-family: Courier New, Courier, monospace; font-size: xx-small;"> Console.WriteLine(new string('-', 60));</span><br />
<span style="font-family: Courier New, Courier, monospace; font-size: xx-small;"> Console.WriteLine("Total GB : " + totalBytes / GB);</span><br />
<span style="font-family: Courier New, Courier, monospace; font-size: xx-small;"> Console.WriteLine("Daily usage : " + totalBytes / GB / 31.0);</span><br />
<span style="font-family: Courier New, Courier, monospace; font-size: xx-small;"><br /></span>
<span style="font-family: Courier New, Courier, monospace; font-size: xx-small;"> Console.WriteLine(new string('-', 60));</span><br />
<span style="font-family: Courier New, Courier, monospace; font-size: xx-small;"> }</span><br />
<br />Fabriziohttp://www.blogger.com/profile/08391423682734740591noreply@blogger.com0tag:blogger.com,1999:blog-19206893.post-4871070933730296962013-11-28T07:00:00.000+01:002013-11-28T12:45:17.706+01:00Nuova versione dell'applicazione bollettini allerta meteoidrologicaTre anni fa, per provare Google App Engine, avevo sviluppa un'applicazione che prelevava i bollettini (pdf!) di Allerta Meteoidrologica di Arpa Piemonte, li elaborava e li mandava (gratuitamente) via email agli iscritti.<br />
In questi giorni ho rifatto l'applicazione, questa volta su Microsoft Azure: <a href="http://fhtino.azurewebsites.net/bollettino/">http://fhtino.azurewebsites.net/bollettino/</a><br />
<br />
Solito avvertimento :)<br />
<i>Data la natura sperimentale e dimostrativa dell'applicazione, non è garantita la correttezza dei dati e la loro regolarità. I dati sono quindi da considerarsi NON VALIDI. Per avere i dati ufficiali fare sempre riferimento a quelli pubblicati sul sito di ARPA Piemonte all'indirizzo http://www.arpa.piemonte.it </i><br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://1.bp.blogspot.com/-d_RJunyq8jY/UpcsbCl4U0I/AAAAAAAAEZs/I5q9W6P773I/s1600/screenshot_bollettino.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://1.bp.blogspot.com/-d_RJunyq8jY/UpcsbCl4U0I/AAAAAAAAEZs/I5q9W6P773I/s1600/screenshot_bollettino.png" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<br />
<br />Fabriziohttp://www.blogger.com/profile/08391423682734740591noreply@blogger.com0tag:blogger.com,1999:blog-19206893.post-80925539445808006122012-12-12T21:27:00.001+01:002012-12-12T21:27:29.739+01:00Sql 2012 Management Studio bug?Premetto che non sono un DB Admin (abbiate pietà) ma ho l'impressione che ci sia qualcosa che non va nel Management Studio di Sql 2012 (Express nel mio caso).<br />
Ho fatto un full backup e poi un differnziale. Ho quindi iniziato il processo di restore. Per prima cosa ho fatto il restore del full, lasciano il database "aperto" (NORECOVERY). Successivamente ho fatto il restore del differenziale ma ricevo questo errore: "Unable to create a restore plan due to break in the LSN chain".<br />
<br />
Ho seguito Tasks --> Restore --> Database...<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://1.bp.blogspot.com/-PagjWGMighQ/UMhHcp_r8dI/AAAAAAAAELU/NK_KpU-YQ_Q/s1600/img2.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="272" src="http://1.bp.blogspot.com/-PagjWGMighQ/UMhHcp_r8dI/AAAAAAAAELU/NK_KpU-YQ_Q/s400/img2.png" width="400" /></a></div>
<br />
e questo è l'errore:<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://1.bp.blogspot.com/-2vpc1LpaT4s/UMhHb8WC4FI/AAAAAAAAELQ/X4lGapT1egQ/s1600/img1.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="348" src="http://1.bp.blogspot.com/-2vpc1LpaT4s/UMhHb8WC4FI/AAAAAAAAELQ/X4lGapT1egQ/s400/img1.png" width="400" /></a></div>
<br />
Se invece seguo Tasks --> Restore --> Files and filegroups... funziona tutto per bene.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://2.bp.blogspot.com/-Ex9K-XWi07o/UMhHdRuOrAI/AAAAAAAAELY/O7HsYiRzUGU/s1600/img3.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="358" src="http://2.bp.blogspot.com/-Ex9K-XWi07o/UMhHdRuOrAI/AAAAAAAAELY/O7HsYiRzUGU/s400/img3.png" width="400" /></a></div>
<br />
<br />
<br />
Ovviamente funziona tutto per bene anche se eseguo i comandi TSQL direttamente:<br />
<br />
<br />
RESTORE DATABASE [HA] FROM DISK = N'D:\temp\dbbackup_tests\Full.bak' WITH FILE = 1, MOVE N'HA' TO N'D:\temp\dbbackup_tests\HA.mdf', MOVE N'HA_log' TO N'D:\temp\dbbackup_tests\HA_log.ldf', NORECOVERY, NOUNLOAD, STATS = 5<br />
<br />
RESTORE DATABASE [HA] FROM DISK = N'D:\temp\dbbackup_tests\Diff.bak' WITH FILE = 1, NOUNLOAD, STATS = 5<br />
<br />
Per info, i backup funzionano sia da Management Studio che direttamente da TSQL:<br />
<br />
<br />
BACKUP DATABASE [HA] TO DISK = N'D:\temp\dbbackup_tests\Full.bak' WITH NOFORMAT, INIT, NAME = N'HA-Full Database Backup', SKIP, NOREWIND, NOUNLOAD, STATS = 10<br />
<br />
BACKUP DATABASE [HA] TO DISK = N'D:\temp\dbbackup_tests\Diff.bak' WITH DIFFERENTIAL , NOFORMAT, INIT, NAME = N'HA-Differential Database Backup', SKIP, NOREWIND, NOUNLOAD, STATS = 10<br />
<div>
<br /></div>
<br />
<br />
<div>
<br /></div>
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />Fabriziohttp://www.blogger.com/profile/08391423682734740591noreply@blogger.com2tag:blogger.com,1999:blog-19206893.post-54406710231499680752012-05-29T16:22:00.001+02:002012-05-29T16:22:22.061+02:00GMail down : sono uno dello 0.11%Che bello! Ho scoperto di essere parte di un circolo ristretto ed esclusivo di cui fanno parte solo lo 0.11% degli utenti. Peccato che sia quello che ha gmail scassato! :(<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://2.bp.blogspot.com/-KrOEXmiJsHM/T8TbbXutq5I/AAAAAAAAEGI/xcuujCk6uPQ/s1600/GMailDown.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="456" src="http://2.bp.blogspot.com/-KrOEXmiJsHM/T8TbbXutq5I/AAAAAAAAEGI/xcuujCk6uPQ/s640/GMailDown.png" width="640" /></a></div>
<br />
<br />Fabriziohttp://www.blogger.com/profile/08391423682734740591noreply@blogger.com1tag:blogger.com,1999:blog-19206893.post-32342728278451744132012-04-20T07:00:00.000+02:002012-04-20T07:45:24.123+02:00sql server compact 4.0 & entity framework & VS 2010 (no web app)<span style="font-family: inherit;">Entity framework of VS2010 SP1 has a good support for sql server compact 4.0. But... it works only in web application projects. It's known issue... or is it feature? ;)</span><br />
<span style="font-family: inherit;">I've found a simple way to use EF + SqlCompact4.0 with console and winform application in VS2010 SP1. It requires a bit of hack of the db connection string.</span><br />
<div>
<span style="font-family: inherit;"><br /></span></div>
<span style="font-family: inherit;">1 - Create an EF edmx pointing to a "normal" Sql Server (I used tempdb of a sql server express). Do not map any table. </span><span style="font-family: inherit;">The resulting connection string in the app.config will be something like this:</span><br />
<span style="color: #009900; font-family: inherit;"><add name="MyEntities" connectionString="metadata=<wbr></wbr>res://*/MyModel.csdl|res://*/<wbr></wbr>MyModel.ssdl|res://*/MyModel.<wbr></wbr>msl;provider=</span><span style="color: red; font-family: inherit;">System.Data.<wbr></wbr>SqlClient</span><span style="font-family: inherit;">;</span><span style="color: #009900; font-family: inherit;">provider connection string=</span><span style="color: red; font-family: inherit;">&quot;data source=.\sqlexpress;initial catalog=tempdb;integrated security=True;<wbr></wbr>multipleactiveresultsets=True;<wbr></wbr>App=EntityFramework&quot;</span><span style="color: #009900; font-family: inherit;">" providerName="System.Data.<wbr></wbr>EntityClient" /></span><br />
<div>
<div>
<br /></div>
<div>
<span style="font-family: inherit;">2 - Edit the app.config. Modify the connection string and point it to the sql server 4.0 compact file. Save the file.</span><br />
<span style="color: #009900; font-family: inherit;"><add name="MyEntities" connectionString="metadata=<wbr></wbr>res://*/MyModel.csdl|res://*/<wbr></wbr>MyModel.ssdl|res://*/MyModel.<wbr></wbr>msl;provider=</span><span style="color: red; font-family: inherit;">System.Data.<wbr></wbr>SqlServerCe.4.0</span><span style="color: #009900; font-family: inherit;">;provider connection string=</span><span style="color: red; font-family: inherit;">'Data Source=&quot;C:\path_to_my_<wbr></wbr>file\MyDB.sdf&quot;' </span><span style="color: #009900; font-family: inherit;">" providerName="System.Data.<wbr></wbr>EntityClient" /></span></div>
<div>
<span style="font-family: inherit;"><br /></span><br />
<span style="font-family: inherit;">3 - Update the EF model from database (right click on the backgrounf of the model). Now it shows the table of the sdf file.</span></div>
<div>
<br /></div>
<span style="font-family: inherit;"><br /></span><br />
<span style="font-family: inherit;"><br /></span><br />
<span style="font-family: inherit;">Ad Perpetuam Rei Memoriam</span><br />
<span style="font-family: inherit;"><br /></span><br />
<br /></div>Fabriziohttp://www.blogger.com/profile/08391423682734740591noreply@blogger.com0tag:blogger.com,1999:blog-19206893.post-85279482692670536282012-02-17T07:00:00.000+01:002012-02-17T14:18:11.646+01:00Segnalazione articolo: "The Management Team" by Joel SpolskyArticolo molto interessante. Mi chiedo se si applica a tutti i tipi/settori di lavoro. Al settore ICT sicuramente sì. IMHO.<br />
<i><br /></i><br />
<i>The “management team” isn’t the “decision making” team. It’s a support function. You may want to call them administration instead of management, which will keep them from getting too big for their britches.</i><br />
<i>Administrators aren’t supposed to make the hard decisions. They don’t know enough. </i><br />
<br />
<a href="http://www.avc.com/a_vc/2012/02/the-management-team-guest-post-from-joel-spolsky.html">http://www.avc.com/a_vc/2012/02/the-management-team-guest-post-from-joel-spolsky.html</a>
<br />
<br />
<div>
<br /></div>Fabriziohttp://www.blogger.com/profile/08391423682734740591noreply@blogger.com0tag:blogger.com,1999:blog-19206893.post-47952897938468049502012-02-10T06:00:00.000+01:002012-02-10T08:36:23.000+01:00Attenzione: sito di phishing su dominio .itOggi è arrivata l'ennesima email di phishing ma questa volta gmail non l'ha bloccata e l'ho trovata in InBox. Mannaggia! La cosa nuova è che punta ad un sito su dominio .it Eccolo: www.sicurezzacartasi.it<br />
<br />
Chrome, per fortuna, avverte che si tratta di un possibile phishing:<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://2.bp.blogspot.com/-6OvgDXi1jHE/TzTHwc-ISyI/AAAAAAAAD7A/WDO2ERSwF7Q/s1600/phishing1.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="212" src="http://2.bp.blogspot.com/-6OvgDXi1jHE/TzTHwc-ISyI/AAAAAAAAD7A/WDO2ERSwF7Q/s400/phishing1.png" width="400" /></a></div>
<br />
Aprendo comunque il sito (sconsigliato) ecco come appare. Sembra veramente un sito di CartaSi.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://1.bp.blogspot.com/-v2YuAw7sr-Q/TzTIFIH8mkI/AAAAAAAAD7I/vUfy_DfDaFo/s1600/phishing2.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="301" src="http://1.bp.blogspot.com/-v2YuAw7sr-Q/TzTIFIH8mkI/AAAAAAAAD7I/vUfy_DfDaFo/s400/phishing2.png" width="400" /></a></div>
<br />
Ed ecco il phishing in azione: ho messo utente e password (ovviamente finti, tipo foo e bar) ed ecco la pagina che mi chiede i dati della mia carta:<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://3.bp.blogspot.com/-2_jTP06VTgs/TzTIVSKmdFI/AAAAAAAAD7Q/E0xaZdMHLPQ/s1600/phishing3.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="301" src="http://3.bp.blogspot.com/-2_jTP06VTgs/TzTIVSKmdFI/AAAAAAAAD7Q/E0xaZdMHLPQ/s400/phishing3.png" width="400" /></a></div>
<br />
<br />
Quindi, cari utenti "poco esperti" o "poco attenti", occhio ai siti a cui vi collegate.<br />
<br />
<br />
<br />Fabriziohttp://www.blogger.com/profile/08391423682734740591noreply@blogger.com0tag:blogger.com,1999:blog-19206893.post-73203891945940389382011-12-20T21:00:00.000+01:002011-12-21T06:21:02.433+01:00How to mix entity framework and tsql commandsEntity Framewok is a powerful library. But sometimes you need to mix Entity Framework activities and standard TSQL command on the same connection and under the same transaction. The easiest way to do that is using a TransactionScope area:<br />
<br />
<span style="font-family: 'Courier New', Courier, monospace;">using(TransactionScope ts = new TransactionScope())</span><br />
<span style="font-family: 'Courier New', Courier, monospace;">{</span><br />
<span style="font-family: 'Courier New', Courier, monospace;"> ...</span><br />
<span style="font-family: 'Courier New', Courier, monospace;"> ... write your EF code and your TSQL code (sqlconenction + sqlcommand + ...)</span><br />
<span style="font-family: 'Courier New', Courier, monospace;"> ...</span><br />
<span style="font-family: 'Courier New', Courier, monospace;"> ts.complete();</span><br />
<span style="font-family: 'Courier New', Courier, monospace;">}</span><br />
<br />
TransactionScope works fine but in many cases the transaction is escalated to a distributed transaction so you need to setup the MSDTC and you lose in performance.<br />
<br />
Using NET 4.0 there is a simple and very powerful solution: ObjectContext.ExecuteStoreCommand(string)<br />
The method sends the command directly to the underlying database. It uses the same connection of the ObjectContext. But... it's not transactional with SaveChanges. :(<br />
Solution: a couple of command to explicitely open connection and manage a global transaction.<br />
<br />
<span style="font-family: 'Courier New', Courier, monospace;">var mydb = new MyEFDB();</span><br />
<span style="font-family: 'Courier New', Courier, monospace;">mydb.Connection.Open();</span><br />
<span style="font-family: 'Courier New', Courier, monospace;">var tran = mydb.Connection.BeginTransaction();</span><br />
<span style="font-family: 'Courier New', Courier, monospace;">...</span><br />
<span style="font-family: 'Courier New', Courier, monospace;">// (now you can mix you EF code with your TSQL code)</span><br />
<span style="font-family: 'Courier New', Courier, monospace;">...</span><br />
<span style="font-family: 'Courier New', Courier, monospace;">mydb.ExecuteStoreCommand("DELETE FROM MyTable WHERE ...");</span><br />
<span style="font-family: 'Courier New', Courier, monospace;">...</span><br />
<span style="font-family: 'Courier New', Courier, monospace;">foreach(var c in mydb.Customers)</span><br />
<span style="font-family: 'Courier New', Courier, monospace;"> c.Name=....</span><br />
<span style="font-family: 'Courier New', Courier, monospace;">...</span><br />
<span style="font-family: 'Courier New', Courier, monospace;">mydb.SaveChanges();</span><br />
<span style="font-family: 'Courier New', Courier, monospace;">tran.Commit();</span><br />
<span style="font-family: 'Courier New', Courier, monospace;">mydb.Connection.Close();</span><br />
<span style="font-family: inherit;"><br /></span><br />
<span style="font-family: inherit;">Steps:</span><br />
<br />
<ul>
<li><span style="font-family: inherit;">open the db connection</span></li>
<li><span style="font-family: inherit;">begina the transaction</span></li>
<li><span style="font-family: inherit;">do your TSQL and EF</span></li>
<li><span style="font-family: inherit;">save EF changes</span></li>
<li><span style="font-family: inherit;">commit transaction</span></li>
<li><span style="font-family: inherit;">close connection</span></li>
</ul>
<br />
<span style="font-family: inherit;"><br /></span><br />
<span style="font-family: inherit;"><br /></span><br />
<span style="font-family: inherit;"><br /></span><br />
<br />Fabriziohttp://www.blogger.com/profile/08391423682734740591noreply@blogger.com0tag:blogger.com,1999:blog-19206893.post-43686027228133429222011-11-01T21:50:00.001+01:002011-11-01T21:50:29.278+01:00Scuotere un LG Optimus One per installare il firmwareDomandona: come si fa a ripristinare il firmware originale su un LG Optimus One? Semplice, basta scuoterlo.<br />
Beh, ok, non basta solo scuoterlo, ma fra le altre cose bisogna anche "shakerarlo" un po'. All'inizio non ci credevo ma visto che KDZ non riusciva a caricarmi il firmware, ci ho prova. E ha funzionato!!!<br />
Qui c'è la procedura in italiano per ripristinare il firmware con il link ai vari firmware:<br />
<a href="http://www.androidworld.it/forum/modding-e-firmware-lg-optimus-one-114/%5Bguida%5D-ripristino-firmware-ufficiale-tramite-kdz-10080/">http://www.androidworld.it/forum/modding-e-firmware-lg-optimus-one-114/%5Bguida%5D-ripristino-firmware-ufficiale-tramite-kdz-10080/</a><br />
Maggiori dettagli su Xda-Developers: <a href="http://forum.xda-developers.com/showthread.php?t=883314">http://forum.xda-developers.com/showthread.php?t=883314</a><br />
<br />
Per la cronaca: stavo facendo l'aggiornamento ufficale di LG e si è pianto tutto. Il telefono è rimasto in Emergency Mode e non c'è stato verso di farlo ripartire. Ovviamente non era neanche possibile ripartire con l'aggiornamento :(<br />
Prima di portarlo in assistenza ho provato la procedura con KDZ e ha funzionato (modalità EMERGENCY). Alla fine ho dovuto fare anche un hard reset (tasto home+volume_giù+power). Quindi telefono completamente "nuovo": rimesso il mio account gmail e in 5 minuti avevo nuovamente tutti i miei contatti, email e calendario. :)<br />
<br />Fabriziohttp://www.blogger.com/profile/08391423682734740591noreply@blogger.com0tag:blogger.com,1999:blog-19206893.post-29611935206163323402011-09-18T10:00:00.002+02:002011-09-19T16:34:58.845+02:00How to get users list from Google Apps using OAuth and C#Recently I've added support for Google Apps to <a href="http://gs.fhtino.it/gdocbackup">GDocBackup</a>. Using a domain administrator username+password it retrieves users list and then backups all documents for each user. The backup is executed using the OAuth domanin keys. So GDocBackup uses two different authentication method: username+password and OAuth. I don't like that. I'd like to use OAuth for both tasks. After some tests, internet search and the help of Claudio Cherubino, I've done a working application.<br />
This is a very quick step-by-step guide on how I used OAuth.<br />
<br />
<b>Step 1</b> : activate OAuth for your domain. Go to domain control panel -> Advanced tools -> Manage OAuth domain key and activate the key.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://4.bp.blogspot.com/-qD8gWfxG4vI/TnWiLv5lhNI/AAAAAAAAD1g/FQ5apq2Fpss/s1600/oauth1.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="256" src="http://4.bp.blogspot.com/-qD8gWfxG4vI/TnWiLv5lhNI/AAAAAAAAD1g/FQ5apq2Fpss/s640/oauth1.png" width="640" /></a></div>
<br />
<b>Step 2</b> : enable readonly Provisioning API. Go to domain control panel -> Advanced tools -> Manage third party OAuth Client access. Under [Client Name] add your full domain name. Under [One or more api scopes] add https://apps-apis.google.com/a/feeds/user/#readonly. Then press [Authorize].<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://3.bp.blogspot.com/-jqe2PiAC2VM/TnWimn0n47I/AAAAAAAAD1k/L4QokJF_IlQ/s1600/oauth2.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="224" src="http://3.bp.blogspot.com/-jqe2PiAC2VM/TnWimn0n47I/AAAAAAAAD1k/L4QokJF_IlQ/s640/oauth2.png" width="640" /></a></div>
<br />
<b>Step 3</b> : download the official Google GData library for .NET: <a href="http://code.google.com/p/google-gdata/">http://code.google.com/p/google-gdata/</a><br />
<br />
<b>Step 4</b> : create a C# application with Visual Studio, add the required DLL from Google GData library and write a piece of code like the following. It will retrieve all user login.<br />
<br />
<br />
<br />
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">string mydomain = "___mydomain___";</span><br />
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">string myOAuthConsumerSecret = "___mysecretkey___";</span><br />
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"><br /></span><br />
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">GOAuthRequestFactory reqF = new GOAuthRequestFactory("apps", "mytestapp");</span><br />
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">reqF.ConsumerKey = mydomain;</span><br />
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">reqF.ConsumerSecret = myOAuthConsumerSecret;</span><br />
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"><br /></span><br />
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">UserService userService = new UserService("mytestapp");</span><br />
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">userService.RequestFactory = reqF;</span><br />
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"><br /></span><br />
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">UserQuery query = new UserQuery(mydomain, true);</span><br />
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">UserFeed usersFeed = userService.Query(query);</span><br />
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">foreach (UserEntry entry in usersFeed.Entries)</span><br />
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"> Console.WriteLine(entry.Login.UserName);</span><br />
<br />
<br />
<br />
[Update]<br />
Details about API authorization: <a href="http://www.google.com/support/a/bin/answer.py?answer=162106">http://www.google.com/support/a/bin/answer.py?answer=162106</a><br />
<br />
<br />
<br />Fabriziohttp://www.blogger.com/profile/08391423682734740591noreply@blogger.com0tag:blogger.com,1999:blog-19206893.post-37268739250788636192011-08-28T22:04:00.003+02:002011-08-28T22:05:38.220+02:00GDocBackup for Google AppsToday I've published the first release of GDocBackup with support for Google Apps. It's a very preliminary release with some issues. It's very easy to use: in the config section, insert the administrator username and password, the domain name and the "OAuth consumer secret" key. Then activate "Google Apps mode" checkbox. GDocBackup will extract all the documents for each user of your domain.<br />
<br />
GDocBackup 0.4.40.153 <a href="http://code.google.com/p/gdocbackup/downloads/list">http://code.google.com/p/gdocbackup/downloads/list</a><br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://4.bp.blogspot.com/-1y41a6zb-g4/Tlqeom8FdPI/AAAAAAAAD1Q/SsRlyI5IvgU/s1600/gdocbackup_for_apps_config.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://4.bp.blogspot.com/-1y41a6zb-g4/Tlqeom8FdPI/AAAAAAAAD1Q/SsRlyI5IvgU/s1600/gdocbackup_for_apps_config.png" /></a></div>
<br />
<br />Fabriziohttp://www.blogger.com/profile/08391423682734740591noreply@blogger.com3tag:blogger.com,1999:blog-19206893.post-67768277018948370192011-05-19T07:00:00.000+02:002011-10-25T13:06:32.967+02:00How to intercept the sql query generated by an EntityDataSourceThe asp.net EntityDataSource (= Entity Framework data source) hides SQL details. But sometimes you could need to see the auto generated SQL command.<br />
<br />
Simple: intercept the QueryCreated event of the EntityDataSource<br />
<br />
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"> protected void EntityDataSource1_QueryCreated(object sender, QueryCreatedEventArgs e)<br /> {<br /> LabelX.Text = (e.Query as System.Data.Objects.ObjectQuery).ToTraceString();<br /> }</span><br />
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"><br /></span><br />
<div>
<br /></div>
If are using an ObjectContext, you can extract the SQL casting the query to ObjectQuery.<div>
<br /></div>
<div>
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">var db = .... ObjectContext...</span></div>
<div>
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">var query = (from x in TableName select x);</span></div>
<div>
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">string sqlquery = (query as System.Data.Objects.ObjectQuery).ToTraceString();</span></div>
<div>
<br /></div>
<div>
<br /></div>Fabriziohttp://www.blogger.com/profile/08391423682734740591noreply@blogger.com0tag:blogger.com,1999:blog-19206893.post-87182037708914084602011-02-25T07:50:00.001+01:002011-02-25T08:26:53.331+01:00ILSpyDalla fine di Febbraio 2011 <a href="http://www.red-gate.com/products/dotnet-development/reflector/">Reflector non sarà più un prodotto gratuito</a>. Due alternative: 35$ per la versione a pagamento oppure <a href="http://www.ilspy.net/">ILSpy</a>.<br />
<a href="http://www.ilspy.net/">ILSpy</a> è disassemblatore come Reflector, è open-source ed è gratuito. Sviluppato dalle stesse persone di SharpDevelop. L'ho provato e sembra funzionare molto bene. :)<br />
<br />
<div style="text-align: center;"><a href="http://www.ilspy.net/">http://www.ilspy.net/</a></div><br />
<div class="separator" style="clear: both; text-align: center;"><a href="http://3.bp.blogspot.com/-rWGXLTZQNck/TWdQ_bx0XdI/AAAAAAAADoo/SHMoexKA4YM/s1600/ilspy.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://3.bp.blogspot.com/-rWGXLTZQNck/TWdQ_bx0XdI/AAAAAAAADoo/SHMoexKA4YM/s1600/ilspy.jpg" /></a></div><div class="separator" style="clear: both; text-align: center;"><br />
</div><div class="separator" style="clear: both; text-align: left;"><br />
</div><div class="separator" style="clear: both; text-align: left;">[Update: al momento non supporta LINQ. Forse in futuro... <a href="http://wiki.sharpdevelop.net/SharpZipLib_Roadmap.ashx">http://wiki.sharpdevelop.net/SharpZipLib_Roadmap.ashx</a>]</div><div class="separator" style="clear: both; text-align: left;"><br />
</div>Fabriziohttp://www.blogger.com/profile/08391423682734740591noreply@blogger.com0tag:blogger.com,1999:blog-19206893.post-48943434834169801122011-02-09T16:52:00.000+01:002011-02-09T16:52:31.635+01:00Piccolo contributo ad un libreria di GoogleVabbè, lo so è proprio una cosa da poco, sono solo 10 righe di codice o poco più, ma comunque la cosa mi fa proprio piacere. Un grazie a <a href="http://www.claudiocherubino.it/">Claudio</a>.<br />
<a href="http://code.google.com/p/google-gdata/issues/detail?id=477">http://code.google.com/p/google-gdata/issues/detail?id=477</a>Fabriziohttp://www.blogger.com/profile/08391423682734740591noreply@blogger.com0tag:blogger.com,1999:blog-19206893.post-22592844690218067022011-02-06T21:16:00.001+01:002011-09-19T09:16:05.851+02:00How to transform a pure Class Library project into a WCF Service LibraryWCF Service Library projects are classic Class Library projects plus some very useful features:<br />
<ul>
<li>they auto-host themselves using the utility WCF Service Host</li>
<li>they can be called and tested using the utility WCF Test Client</li>
<li>they can be discovered and added in other projects of the same solution using "Add Service Reference..."</li>
</ul>
<br />
(WCF Service Host and WCF Test Client are part of Visual Studio 2010).<br />
<br />
The differences between the two type of project are in the .csprojct file. So, you can transform a classis Class Library project inot a WCF Service Library project modifying the .csproj file.<br />
<br />
<b>Steps:</b><br />
<br />
* close VS2010<br />
* do a complete backup of the whole solution :)<br />
* edit the "Class Library" .csproj using notepad (or other text editor)<br />
* under <PropertyGroup> add:<br />
<ul><ul></ul>
</ul>
<span class="Apple-style-span" style="color: red; font-family: 'Courier New', Courier, monospace; font-size: x-small;"><ProjectTypeGuids>{3D9AD99F-2412-4246-B90B-4EAA41C64699};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids><br />
<StartArguments>/client:"WcfTestClient.exe"</StartArguments></span><br />
<br />
* after <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> add:<br />
<br />
<span class="Apple-style-span" style="color: red; font-family: 'Courier New', Courier, monospace; font-size: x-small;"><ProjectExtensions><br />
<VisualStudio><br />
<FlavorProperties GUID="{3D9AD99F-2412-4246-B90B-4EAA41C64699}"><br />
<WcfProjectProperties><br />
<AutoStart>True</AutoStart><br />
</WcfProjectProperties><br />
</FlavorProperties><br />
</VisualStudio><br />
</ProjectExtensions></span><br />
<div>
<br /></div>
<div>
<br /></div>
<div>
The resulting file should looks like this:</div>
<div>
<br /></div>
<span class="Apple-style-span" style="font-size: x-small;"><?xml version="1.0" encoding="utf-8"?><br />
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"><br />
<PropertyGroup><br />
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration><br />
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform><br />
<ProductVersion>8.0.30703</ProductVersion><br />
<SchemaVersion>2.0</SchemaVersion><br />
<ProjectGuid>{08536F3E-152A-46C0-8C63-C0821FE5DE7C}</ProjectGuid><br />
<OutputType>Library</OutputType><br />
<AppDesignerFolder>Properties</AppDesignerFolder><br />
<RootNamespace>PureClassLib</RootNamespace><br />
<AssemblyName>PureClassLib</AssemblyName><br />
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion><br />
<FileAlignment>512</FileAlignment><br />
<span class="Apple-style-span" style="color: red;"><ProjectTypeGuids>{3D9AD99F-2412-4246-B90B-4EAA41C64699};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids><br />
<StartArguments>/client:"WcfTestClient.exe"</StartArguments></span><br />
</PropertyGroup><br />
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "><br />
<DebugSymbols>true</DebugSymbols><br />
<DebugType>full</DebugType><br />
<Optimize>false</Optimize><br />
<OutputPath>bin\Debug\</OutputPath><br />
<DefineConstants>DEBUG;TRACE</DefineConstants><br />
<ErrorReport>prompt</ErrorReport><br />
<WarningLevel>4</WarningLevel><br />
</PropertyGroup><br />
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "><br />
<DebugType>pdbonly</DebugType><br />
<Optimize>true</Optimize><br />
<OutputPath>bin\Release\</OutputPath><br />
<DefineConstants>TRACE</DefineConstants><br />
<ErrorReport>prompt</ErrorReport><br />
<WarningLevel>4</WarningLevel><br />
</PropertyGroup><br />
<ItemGroup><br />
<Reference Include="System" /><br />
<Reference Include="System.Core" /><br />
<Reference Include="System.Runtime.Serialization" /><br />
<Reference Include="System.ServiceModel" /><br />
<Reference Include="System.Xml.Linq" /><br />
<Reference Include="System.Data.DataSetExtensions" /><br />
<Reference Include="Microsoft.CSharp" /><br />
<Reference Include="System.Data" /><br />
<Reference Include="System.Xml" /><br />
</ItemGroup><br />
<ItemGroup><br />
<Compile Include="AcmeService.cs" /><br />
<Compile Include="Class1.cs" /><br />
<Compile Include="IAcmeService.cs" /><br />
<Compile Include="Properties\AssemblyInfo.cs" /><br />
</ItemGroup><br />
<ItemGroup><br />
<None Include="app.config" /><br />
</ItemGroup><br />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /><br />
<span class="Apple-style-span" style="color: red;"><ProjectExtensions><br />
<VisualStudio><br />
<FlavorProperties GUID="{3D9AD99F-2412-4246-B90B-4EAA41C64699}"><br />
<WcfProjectProperties><br />
<AutoStart>True</AutoStart><br />
</WcfProjectProperties><br />
</FlavorProperties><br />
</VisualStudio><br />
</ProjectExtensions></span><br />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.<br />
Other similar extension points exist, see Microsoft.Common.targets.<br />
<Target Name="BeforeBuild"><br />
</Target><br />
<Target Name="AfterBuild"><br />
</Target><br />
--><br />
</Project></span><br />
<div>
<br /></div>
<div>
<br /></div>
<div>
<br /></div>
<div>
A useful link to understand Project Types: <a href="http://www.mztools.com/Articles/2008/MZ2008017.aspx">http://www.mztools.com/Articles/2008/MZ2008017.aspx</a></div>
<div>
<a href="http://www.mztools.com/Articles/2008/MZ2008017.aspx"></a><br />
<br />
<br /></div>
Fabriziohttp://www.blogger.com/profile/08391423682734740591noreply@blogger.com0tag:blogger.com,1999:blog-19206893.post-77408229276321457302011-02-06T21:14:00.002+01:002011-04-25T15:23:04.043+02:00Connet an Android app to Google App Engine - Authenticated !Sometime ago I read a very interesting post on Nick'blog: "Authenticating against App Engine from an Android app" <a href="http://blog.notdot.net/2010/05/Authenticating-against-App-Engine-from-an-Android-app">http://blog.notdot.net/2010/05/Authenticating-against-App-Engine-from-an-Android-app</a><br />
The code was very intersting but I need to refactor a bit and I'd like to add some "utility" method.<br />
Also I added a way to automatically invalidate old Auth token and get a new one.<br />
<br />
My code (very alpha... I'm still working on it...) is here:<br />
<a href="http://code.google.com/p/fhpublicstuff/source/browse/test/GAEConnector/GAEConnector.java">http://code.google.com/p/fhpublicstuff/source/browse/test/GAEConnector/GAEConnector.java</a><br />
<br />
[Update: it manages http and https connections to GAE]<br />
<br />
Usage:<br />
<br />
<br />
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">// ....</span><br />
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"><span class="Apple-style-span" style="color: #cc0000;"><b>_gaeConnector</b></span> = new GAEConnector(null, "http://AAAAAAAA.appspot.com");</span><br />
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">if (!_gaeConnector.Authenticate(MyTest.this)) {</span><br />
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"> message = "***AUTHENTICATION ERROR***";</span><br />
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">}</span><br />
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">// .....</span><br />
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">if (_gaeConnector.isAuthenticated()) {</span><br />
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"> int httpStatusCode = _gaeConnector.GETContent("/myurl", true, true);</span><br />
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"> if (httpStatusCode == 200) {</span><br />
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"> String content = _gaeConnector.getLastContent();</span><br />
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"> // ....</span><br />
<div><br />
</div>Fabriziohttp://www.blogger.com/profile/08391423682734740591noreply@blogger.com0tag:blogger.com,1999:blog-19206893.post-36314829510140232892010-11-25T08:32:00.000+01:002010-11-25T08:32:30.168+01:00Cloud[Per Andrea B.]<br />
<br />
<b><span class="Apple-style-span" style="font-size: large;">Ma vaffan cloud!</span></b><br />
<b><span class="Apple-style-span" style="font-size: large;"><br />
</span></b><br />
<b><span class="Apple-style-span" style="font-size: large;">:)</span></b><br />
<b><span class="Apple-style-span" style="font-size: large;"><br />
</span></b><br />
<b><span class="Apple-style-span" style="font-size: large;"><br />
</span></b>Fabriziohttp://www.blogger.com/profile/08391423682734740591noreply@blogger.com0tag:blogger.com,1999:blog-19206893.post-38307741102594758422010-11-20T14:56:00.000+01:002010-11-20T14:56:40.456+01:00HttpClient - disable follow http redirectI was playing with Apache <a href="http://developer.android.com/reference/org/apache/http/impl/client/DefaultHttpClient.html">DefaultHttpClient</a> on Android. HttpClient follows http redirect by default. But I need to disable it. I expected a simple set property on HttpClient or HttpGet. I was wrong. :(<br />
Found two solution after a long googling.<br />
<br />
My code:<br />
DefaultHttpClient httpClient = new DefaultHttpClient();<br />
HttpGet httpget = new HttpGet("http://....");<br />
<br />
<br />
Solution 1: set parameter<br />
<br />
DefaultHttpClient httpClient = new DefaultHttpClient();<br />
<b>BasicHttpParams params = new BasicHttpParams();</b><br />
<b>HttpClientParams.setRedirecting(params, false);</b><br />
<b>httpClient.setParams(params);</b><br />
<b></b>HttpGet httpget = new HttpGet("http://....");<br />
<br />
Solution 2 - define my own redirecthandler<br />
<br />
DefaultHttpClient httpClient = new DefaultHttpClient();<br />
<b>httpClient.setRedirectHandler(new DefaultRedirectHandler() {</b><br />
<span class="Apple-tab-span" style="white-space: pre;"><b> </b></span><b>@Override</b><br />
<span class="Apple-tab-span" style="white-space: pre;"><b> </b></span><b>public boolean isRedirectRequested(HttpResponse response, HttpContext context) {</b><br />
<span class="Apple-tab-span" style="white-space: pre;"><b> </b></span><b>return false;</b><br />
<span class="Apple-tab-span" style="white-space: pre;"><b> </b></span><b>}</b><br />
<b>});</b><br />
HttpGet httpget = new HttpGet("http://....");Fabriziohttp://www.blogger.com/profile/08391423682734740591noreply@blogger.com0tag:blogger.com,1999:blog-19206893.post-60738785522798355012010-11-10T21:24:00.000+01:002010-11-10T21:24:03.070+01:00My first Android test appMy first test on Android. A Memory game for my kids. :)<br />
<br />
<div class="separator" style="clear: both; text-align: center;"><a href="http://1.bp.blogspot.com/_8eehAYx2jfE/TNr-1UnZubI/AAAAAAAADjc/EyxkAmMiAds/s1600/memory1.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="320" src="http://1.bp.blogspot.com/_8eehAYx2jfE/TNr-1UnZubI/AAAAAAAADjc/EyxkAmMiAds/s320/memory1.png" width="217" /></a></div><br />
But it has some bugs. First of all I need to fix the layout when rotated. :(<br />
<br />
<div class="separator" style="clear: both; text-align: center;"><a href="http://4.bp.blogspot.com/_8eehAYx2jfE/TNr_K2MbviI/AAAAAAAADjg/kMOi0XTe8ww/s1600/memory2.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="216" src="http://4.bp.blogspot.com/_8eehAYx2jfE/TNr_K2MbviI/AAAAAAAADjg/kMOi0XTe8ww/s320/memory2.png" width="320" /></a></div>Fabriziohttp://www.blogger.com/profile/08391423682734740591noreply@blogger.com0