[
  {
    "Id": "803713",
    "ThreadId": "346855",
    "Html": "\r\n<p>Hi all,&nbsp;</p>\r\n<p>I've been fiddling with DotNetZip and tried to reproduce something like this&nbsp;<a href=\"http://dotnetzip.codeplex.com/discussions/277113\">http://dotnetzip.codeplex.com/discussions/277113</a><a href=\"http://dotnetzip.codeplex.com/discussions/277113\">#mce_temp_url#</a></p>\r\n<p>My code is simpler and it works, but not completely: I can see the zip process starts\r\n<strong>and finishes</strong>&nbsp;(so it shows me the start message and end message, based on&nbsp;ZipProgressEventType.Saving_Started and&nbsp;ZipProgressEventType.Saving_Completed). It does not show me any progress, though (I'm basing it on&nbsp;ZipProgressEventType.Saving_AfterWriteEntry)</p>\r\n<p>It seems to me the SaveProgress event is not firing or can't reach the method associated with it.&nbsp;</p>\r\n<p>There's some code below&nbsp;(yes, I'm desperate enough to base the variables on Session).</p>\r\n<p>the button which triggers the zip process:</p>\r\n<div style=\"color:black; background-color:white\">\r\n<pre>    <span style=\"color:blue\">protected</span> <span style=\"color:blue\">void</span> btnSalvar_Click(<span style=\"color:blue\">object</span> sender, EventArgs e)\r\n    {\r\n        <span style=\"color:blue\">using</span> (ZipFile zip = <span style=\"color:blue\">new</span> ZipFile())\r\n        {\r\n            <span style=\"color:blue\">string</span> strDiretorioMapeado = Server.MapPath(<span style=\"color:#a31515\">&quot;~/Arquivos/Exportacoes/&quot;</span>);\r\n            zip.AddDirectory(strDiretorioMapeado &#43; <span style=\"color:blue\">this</span>.ddlDiretorios.SelectedValue);\r\n            zip.CompressionLevel = Ionic.Zlib.CompressionLevel.BestCompression;\r\n            zip.SaveProgress &#43;= <span style=\"color:blue\">new</span> EventHandler&lt;SaveProgressEventArgs&gt;(zip_SaveProgress);\r\n            zip.Save(strDiretorioMapeado &#43; <span style=\"color:blue\">this</span>.ddlDiretorios.SelectedItem.Text &#43; <span style=\"color:#a31515\">&quot;.zip&quot;</span>);\r\n        }\r\n    }</pre>\r\n</div>\r\n<p>the zip_SaveProgress method:</p>\r\n<div style=\"color:black; background-color:white\">\r\n<pre>    <span style=\"color:blue\">private</span> <span style=\"color:blue\">void</span> zip_SaveProgress(<span style=\"color:blue\">object</span> sender, SaveProgressEventArgs args)\r\n    {\r\n        <span style=\"color:blue\">if</span> (args.EventType == ZipProgressEventType.Saving_Started)\r\n        {\r\n            <span style=\"color:green\">//this.progressoIniciado = true;</span>\r\n            <span style=\"color:blue\">if</span> (Session[<span style=\"color:#a31515\">&quot;progresso&quot;</span>] != <span style=\"color:blue\">null</span>)\r\n                Session[<span style=\"color:#a31515\">&quot;progresso&quot;</span>] = <span style=\"color:#a31515\">&quot;Iniciado&quot;</span>;\r\n            <span style=\"color:blue\">else</span>\r\n                Session.Add(<span style=\"color:#a31515\">&quot;progresso&quot;</span>, <span style=\"color:#a31515\">&quot;Iniciado&quot;</span>);\r\n                     \r\n        }\r\n        <span style=\"color:blue\">else</span> <span style=\"color:blue\">if</span> (args.EventType == ZipProgressEventType.Saving_Completed)\r\n        {\r\n                Session[<span style=\"color:#a31515\">&quot;progresso&quot;</span>] = <span style=\"color:#a31515\">&quot;Finalizado&quot;</span>;\r\n        }\r\n        <span style=\"color:blue\">else</span> <span style=\"color:blue\">if</span>(args.EventType == ZipProgressEventType.Reading_Started)\r\n            <span style=\"color:blue\">this</span>.litMsg.Text = <span style=\"color:#a31515\">&quot;Lendo diretorio...&quot;</span>;\r\n        <span style=\"color:blue\">else</span> <span style=\"color:blue\">if</span> (args.EventType == ZipProgressEventType.Saving_AfterWriteEntry)\r\n        {\r\n            <span style=\"color:blue\">this</span>.progressoArquivoAtual = args.CurrentEntry.FileName;\r\n            <span style=\"color:blue\">this</span>.arquivosTransferidos = args.EntriesSaved;\r\n            <span style=\"color:blue\">this</span>.totalArquivos = args.EntriesTotal;\r\n            <span style=\"color:blue\">this</span>.progressoPorcento = (<span style=\"color:blue\">double</span>)args.EntriesSaved / args.EntriesTotal;\r\n            <span style=\"color:blue\">if</span> (Session[<span style=\"color:#a31515\">&quot;progresso&quot;</span>] != <span style=\"color:blue\">null</span>)\r\n                Session[<span style=\"color:#a31515\">&quot;porcento&quot;</span>] = progressoPorcento.ToString(<span style=\"color:#a31515\">&quot;#0.##%&quot;</span>);\r\n            <span style=\"color:blue\">else</span>\r\n                Session.Add(<span style=\"color:#a31515\">&quot;porcento&quot;</span>, progressoPorcento.ToString(<span style=\"color:#a31515\">&quot;#0.##%&quot;</span>)); \r\n                       \r\n        }\r\n    }\r\n</pre>\r\n</div>\r\n<p>and the ticker which checks the server every one second:</p>\r\n<p></p>\r\n<div style=\"color:black; background-color:white\">\r\n<pre>    <span style=\"color:blue\">protected</span> <span style=\"color:blue\">void</span> tmrIntervalo_Tick(<span style=\"color:blue\">object</span> sender, EventArgs e)\r\n    {\r\n        <span style=\"color:blue\">if</span> (Session[<span style=\"color:#a31515\">&quot;progresso&quot;</span>] != <span style=\"color:blue\">null</span>)\r\n        {\r\n            <span style=\"color:blue\">if</span> (Session[<span style=\"color:#a31515\">&quot;progresso&quot;</span>] == <span style=\"color:#a31515\">&quot;Iniciado&quot;</span>)\r\n            {\r\n                <span style=\"color:blue\">this</span>.litMsg.Text = <span style=\"color:#a31515\">&quot;Iniciando...&quot;</span>;\r\n                <span style=\"color:blue\">this</span>.litMsg.Text = String.Format(<span style=\"color:#a31515\">&quot;{0} transferidos...&quot;</span>, Session[<span style=\"color:#a31515\">&quot;porcento&quot;</span>].ToString());\r\n                Session[<span style=\"color:#a31515\">&quot;progresso&quot;</span>] = <span style=\"color:#a31515\">&quot;Em progresso&quot;</span>;\r\n            }\r\n            <span style=\"color:blue\">else</span> <span style=\"color:blue\">if</span> (Session[<span style=\"color:#a31515\">&quot;progresso&quot;</span>] == <span style=\"color:#a31515\">&quot;Finalizado&quot;</span>)\r\n            {\r\n                <span style=\"color:blue\">this</span>.litMsg.Text = <span style=\"color:#a31515\">&quot;Finalizado&quot;</span>;\r\n                Session[<span style=\"color:#a31515\">&quot;progresso&quot;</span>] = <span style=\"color:blue\">null</span>;\r\n                Session[<span style=\"color:#a31515\">&quot;porcento&quot;</span>] = <span style=\"color:#a31515\">&quot;0%&quot;</span>;\r\n                <span style=\"color:blue\">this</span>.lstArquivosZip.DataBind();\r\n            }\r\n            <span style=\"color:blue\">else</span> <span style=\"color:blue\">if</span> (Session[<span style=\"color:#a31515\">&quot;progresso&quot;</span>] == <span style=\"color:#a31515\">&quot;Em progresso&quot;</span>)\r\n            {\r\n                <span style=\"color:blue\">this</span>.litMsg.Text = <span style=\"color:#a31515\">&quot;Total: &quot;</span> &#43; Session[<span style=\"color:#a31515\">&quot;porcento&quot;</span>].ToString();\r\n            }\r\n        }\r\n        <span style=\"color:blue\">else</span>\r\n        {\r\n            <span style=\"color:blue\">this</span>.litMsg.Text = <span style=\"color:#a31515\">&quot;Nenhum Zip iniciado ainda.&quot;</span>;\r\n            Session[<span style=\"color:#a31515\">&quot;porcento&quot;</span>] = <span style=\"color:#a31515\">&quot;0%&quot;</span>;\r\n        }\r\n</pre>\r\n</div>\r\n<p></p>\r\n<p>if anyone could help indicating which way to go from here, I'd be thankful.&nbsp;</p>\r\n<p>cheers,&nbsp;</p>\r\n",
    "PostedDate": "2012-03-01T04:40:15.963-08:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "803828",
    "ThreadId": "346855",
    "Html": "<p>I've run a series of simple tests here and apparently, when running locally, I only get the&nbsp;<span>SAVING_COMPLETED event.&nbsp;</span></p>\r\n<p><span>I'm a bit frustrated, but my understanding is that my little knowledge of the web architecture is keeping me from figuring it out. :(</span></p>",
    "PostedDate": "2012-03-01T08:14:16.99-08:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "804327",
    "ThreadId": "346855",
    "Html": "<blockquote style=\"border: solid .1em #ccc; font-style: italic; margin: .25em 1em 0 1em; padding: 0 .25em 0 .25em;\"><strong>marcosaccioly wrote:</strong><br />\r\n<p>I've run a series of simple tests here and apparently, when running locally, I only get the&nbsp;<span>SAVING_COMPLETED event.&nbsp;</span></p>\r\n<p><span>I'm a bit frustrated, but my understanding is that my little knowledge of the web architecture is keeping me from figuring it out. :(</span></p>\r\n</blockquote>\r\n<p>I believe this happens because locally things happen too fast for the browser to update via Ajax. Even though I've been trying to capture the events into session variables in order to display them to the browser window I'm not able to see the changes (even though I have used large folders for testing).</p>\r\n<p>Remotely, though, I was able to grab the percentage. However, I believe that due to client/server relationships not all the event types (ZipProgressEventType). As I'm hitting the server every 500ms I believe the event type is a bit random (hundreds of these events can happen in that time).&nbsp;</p>\r\n<p>So, to sum up:<strong> I was able to get the percentage and the progress across the Internet</strong> (though I get some NaN and have to deal with them).&nbsp;</p>",
    "PostedDate": "2012-03-02T03:33:00.343-08:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  }
]