* Makefile: cleans the StyleCop cache

* 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
main
Paul Schneider 11 years ago
parent c606a8cc40
commit 8c4a6b9f19
7 changed files with 49 additions and 40 deletions

@ -1,3 +1,7 @@
2015-06-07 Paul Schneider <paul@pschneider.fr>
* Makefile: cleans the StyleCop cache
2015-06-06 Paul Schneider <paul@pschneider.fr> 2015-06-06 Paul Schneider <paul@pschneider.fr>
* Yavsc.sln: modifies the Version control integration * Yavsc.sln: modifies the Version control integration

@ -45,6 +45,7 @@ build:
clean: clean:
xbuild /t:Clean xbuild /t:Clean
find -name "StyleCop.Cache" -exec rm {} \;
rm -rf $(LDYDESTDIR) rm -rf $(LDYDESTDIR)
sourcepkg: sourcepkg:

@ -108,7 +108,6 @@ namespace Yavsc.ApiControllers
LogoImgLocator = "http://yavsc.pschneider.fr/favicon.png", LogoImgLocator = "http://yavsc.pschneider.fr/favicon.png",
Location = new Position () { Longitude = 0, Latitude = 0 }, Location = new Position () { Longitude = 0, Latitude = 0 },
LocationType = "Salle des fêtes" LocationType = "Salle des fêtes"
}; };
} }
@ -133,12 +132,6 @@ namespace Yavsc.ApiControllers
} }
/// <summary> /// <summary>
/// Registers with push notifications enabled. /// Registers with push notifications enabled.
/// </summary> /// </summary>
@ -200,7 +193,6 @@ namespace Yavsc.ApiControllers
using (r) { using (r) {
var msg = new MessageWithPayload<YaEvent> () { data = new YaEvent[] { (YaEvent)evpub } }; var msg = new MessageWithPayload<YaEvent> () { data = new YaEvent[] { (YaEvent)evpub } };
msg.to = string.Join (" ", Circle.Union (evpub.Circles)); msg.to = string.Join (" ", Circle.Union (evpub.Circles));
return r.Invoke (msg); return r.Invoke (msg);
} }
} }

@ -1,29 +1,18 @@
using System; using System;
using Yavsc; using System.Collections.Generic;
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.Net; 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 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 Yavsc.Formatters;
using System.Text; using Yavsc.Helpers;
using System.Web.Profile;
using System.Collections.Specialized;
using Yavsc.Model; using Yavsc.Model;
using Yavsc.Model.FrontOffice; using Yavsc.Model.FrontOffice;
using Yavsc.Helpers; using Yavsc.Model.RolesAndMembers;
using System.Net.Http.Headers; using Yavsc.Model.WorkFlow;
using System.IO;
namespace Yavsc.ApiControllers namespace Yavsc.ApiControllers
{ {
@ -161,15 +150,16 @@ namespace Yavsc.ApiControllers
LocalizedText.Estimate_not_found)) LocalizedText.Estimate_not_found))
}; };
HttpResponseMessage result = new HttpResponseMessage () { var memPdf = new MemoryStream ();
Content = new ObjectContent (typeof(string), HttpResponseMessage result = new HttpResponseMessage ();
texest, new TexToPdfFormatter ().WriteToStream (
new TexToPdfFormatter ()) typeof(string), texest, memPdf,null);
}; memPdf.Position = 0;
var sr = new StreamReader(memPdf);
result.Content.Headers.ContentDisposition = new ContentDispositionHeaderValue ("attachment") { var str = sr.ReadToEnd();
FileName = "estimate-" + id.ToString () + ".pdf" result.Content = new StringContent (str);
}; TexToPdfFormatter.SetFileName (result.Content.Headers, "estimate-" + id.ToString ());
result.Content.Headers.ContentType = new MediaTypeHeaderValue("text/x-tex");
return result; return result;
} }
@ -226,7 +216,6 @@ namespace Yavsc.ApiControllers
prtu.SetPropertyValue("Mobile",model.Mobile); prtu.SetPropertyValue("Mobile",model.Mobile);
prtu.SetPropertyValue("Phone",model.Phone); prtu.SetPropertyValue("Phone",model.Phone);
prtu.SetPropertyValue("ZipCode",model.ZipCode); prtu.SetPropertyValue("ZipCode",model.ZipCode);
break; break;
default: default:
break; break;

@ -0,0 +1,14 @@
2015-06-07 Paul Schneider <paul@pschneider.fr>
* 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

@ -26,6 +26,7 @@ using System.IO;
using System.Web; using System.Web;
using System.Diagnostics; using System.Diagnostics;
using System.Net.Http; using System.Net.Http;
using Yavsc.Helpers;
namespace Yavsc.Formatters namespace Yavsc.Formatters
{ {
@ -99,7 +100,7 @@ namespace Yavsc.Formatters
p.Start (); p.Start ();
p.WaitForExit (); p.WaitForExit ();
if (p.ExitCode != 0) 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)) { using (StreamReader sr = new StreamReader (fo.FullName)) {
@ -108,7 +109,14 @@ namespace Yavsc.Formatters
} }
fi.Delete(); fi.Delete();
fo.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"
};
}
} }
} }

@ -181,6 +181,7 @@
<Compile Include="Helpers\TemplateException.cs" /> <Compile Include="Helpers\TemplateException.cs" />
<Compile Include="Helpers\MarkdownHelper.cs" /> <Compile Include="Helpers\MarkdownHelper.cs" />
<Compile Include="ApiControllers\CalendarController.cs" /> <Compile Include="ApiControllers\CalendarController.cs" />
<Compile Include="Formatters\FormatterException.cs" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Content Include="Views\Web.config" /> <Content Include="Views\Web.config" />

Loading…