diff --git a/ChangeLog b/ChangeLog index bac6387b..66cd03d2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2015-06-07 Paul Schneider + + * Makefile: cleans the StyleCop cache + 2015-06-06 Paul Schneider * Yavsc.sln: modifies the Version control integration diff --git a/Makefile b/Makefile index 1c6a33e1..c1305b83 100644 --- a/Makefile +++ b/Makefile @@ -45,6 +45,7 @@ build: clean: xbuild /t:Clean + find -name "StyleCop.Cache" -exec rm {} \; rm -rf $(LDYDESTDIR) sourcepkg: diff --git a/web/ApiControllers/CalendarController.cs b/web/ApiControllers/CalendarController.cs index f30e168c..0c7152ee 100644 --- a/web/ApiControllers/CalendarController.cs +++ b/web/ApiControllers/CalendarController.cs @@ -108,7 +108,6 @@ namespace Yavsc.ApiControllers LogoImgLocator = "http://yavsc.pschneider.fr/favicon.png", Location = new Position () { Longitude = 0, Latitude = 0 }, LocationType = "Salle des fĂȘtes" - }; } @@ -133,12 +132,6 @@ namespace Yavsc.ApiControllers } - - - - - - /// /// Registers with push notifications enabled. /// @@ -200,7 +193,6 @@ namespace Yavsc.ApiControllers using (r) { var msg = new MessageWithPayload () { data = new YaEvent[] { (YaEvent)evpub } }; msg.to = string.Join (" ", Circle.Union (evpub.Circles)); - return r.Invoke (msg); } } diff --git a/web/ApiControllers/FrontOfficeApiController.cs b/web/ApiControllers/FrontOfficeApiController.cs index faf80669..47fc8615 100644 --- a/web/ApiControllers/FrontOfficeApiController.cs +++ b/web/ApiControllers/FrontOfficeApiController.cs @@ -1,29 +1,18 @@ using System; -using Yavsc; -using SalesCatalog; -using System.Web.Routing; -using System.Threading.Tasks; -using System.Diagnostics; -using System.Web.Http; -using System.Net.Http; -using System.Web; -using System.Linq; -using System.IO; +using System.Collections.Generic; using System.Net; +using System.Net.Http; +using System.Net.Http.Headers; +using System.Web.Http; +using System.Web.Profile; using System.Web.Security; -using Yavsc.Model.WorkFlow; -using System.Reflection; -using System.Collections.Generic; -using Yavsc.Model.RolesAndMembers; -using Yavsc.Controllers; using Yavsc.Formatters; -using System.Text; -using System.Web.Profile; -using System.Collections.Specialized; +using Yavsc.Helpers; using Yavsc.Model; using Yavsc.Model.FrontOffice; -using Yavsc.Helpers; -using System.Net.Http.Headers; +using Yavsc.Model.RolesAndMembers; +using Yavsc.Model.WorkFlow; +using System.IO; namespace Yavsc.ApiControllers { @@ -161,15 +150,16 @@ namespace Yavsc.ApiControllers LocalizedText.Estimate_not_found)) }; - HttpResponseMessage result = new HttpResponseMessage () { - Content = new ObjectContent (typeof(string), - texest, - new TexToPdfFormatter ()) - }; - - result.Content.Headers.ContentDisposition = new ContentDispositionHeaderValue ("attachment") { - FileName = "estimate-" + id.ToString () + ".pdf" - }; + var memPdf = new MemoryStream (); + HttpResponseMessage result = new HttpResponseMessage (); + new TexToPdfFormatter ().WriteToStream ( + typeof(string), texest, memPdf,null); + memPdf.Position = 0; + var sr = new StreamReader(memPdf); + var str = sr.ReadToEnd(); + result.Content = new StringContent (str); + TexToPdfFormatter.SetFileName (result.Content.Headers, "estimate-" + id.ToString ()); + result.Content.Headers.ContentType = new MediaTypeHeaderValue("text/x-tex"); return result; } @@ -226,7 +216,6 @@ namespace Yavsc.ApiControllers prtu.SetPropertyValue("Mobile",model.Mobile); prtu.SetPropertyValue("Phone",model.Phone); prtu.SetPropertyValue("ZipCode",model.ZipCode); - break; default: break; diff --git a/web/ChangeLog b/web/ChangeLog new file mode 100644 index 00000000..cd386431 --- /dev/null +++ b/web/ChangeLog @@ -0,0 +1,14 @@ +2015-06-07 Paul Schneider + + * CalendarController.cs: removes useless spaces + + * FrontOfficeApiController.cs: Makes the tex to pdf exceptions + available to the user interface, as part of the application + process. + Cleans the using clauses. + + * TexToPdfFormatter.cs: sets the filename as response header. + + * Web.csproj: a new FormatterException, thrown when exit code + of texi2pdf is not null + diff --git a/web/Formatters/TexToPdfFormatter.cs b/web/Formatters/TexToPdfFormatter.cs index 5f92be6c..ed9d9724 100644 --- a/web/Formatters/TexToPdfFormatter.cs +++ b/web/Formatters/TexToPdfFormatter.cs @@ -26,6 +26,7 @@ using System.IO; using System.Web; using System.Diagnostics; using System.Net.Http; +using Yavsc.Helpers; namespace Yavsc.Formatters { @@ -99,7 +100,7 @@ namespace Yavsc.Formatters p.Start (); p.WaitForExit (); if (p.ExitCode != 0) - throw new Exception ("Pdf generation failed with exit code:" + p.ExitCode); + throw new FormatterException ("Pdf generation failed with exit code:" + p.ExitCode); } using (StreamReader sr = new StreamReader (fo.FullName)) { @@ -108,7 +109,14 @@ namespace Yavsc.Formatters } fi.Delete(); fo.Delete(); + if (contentHeaders != null) + SetFileName(contentHeaders, value.GetHashCode ().ToString ()); + } + + public static void SetFileName(HttpContentHeaders contentHeaders, string basename) { + contentHeaders.ContentDisposition = new ContentDispositionHeaderValue ("attachment") { + FileName = "doc-" + basename + ".pdf" + }; } - } } diff --git a/web/Web.csproj b/web/Web.csproj index 181e94cf..87a43d93 100644 --- a/web/Web.csproj +++ b/web/Web.csproj @@ -181,6 +181,7 @@ +