* 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
This commit is contained in:
Paul Schneider
2015-06-07 01:04:09 +02:00
parent c606a8cc40
commit 8c4a6b9f19
7 changed files with 50 additions and 41 deletions

View File

@ -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>
* Yavsc.sln: modifies the Version control integration

View File

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

View File

@ -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
}
/// <summary>
/// Registers with push notifications enabled.
/// </summary>
@ -200,7 +193,6 @@ namespace Yavsc.ApiControllers
using (r) {
var msg = new MessageWithPayload<YaEvent> () { data = new YaEvent[] { (YaEvent)evpub } };
msg.to = string.Join (" ", Circle.Union (evpub.Circles));
return r.Invoke (msg);
}
}

View File

@ -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.Net;
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.Net;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Web.Http;
using System.Web.Profile;
using System.Collections.Specialized;
using System.Web.Security;
using Yavsc.Formatters;
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;

14
web/ChangeLog Normal file
View File

@ -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

View File

@ -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"
};
}
}
}

View File

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