diff --git a/web/Controllers/AccountController.cs b/web/Controllers/AccountController.cs
index bd471159..5d0bdfed 100644
--- a/web/Controllers/AccountController.cs
+++ b/web/Controllers/AccountController.cs
@@ -255,7 +255,7 @@ namespace Yavsc.Controllers
/// Model.
[Authorize]
[HttpGet]
- public ActionResult Profile (Profile model)
+ public ActionResult MyProfile (Profile model)
{
string username = Membership.GetUser ().UserName;
ViewData ["UserName"] = username;
@@ -272,7 +272,7 @@ namespace Yavsc.Controllers
[Authorize]
[HttpPost]
// ASSERT("Membership.GetUser ().UserName is made of simple characters, no slash nor backslash"
- public ActionResult Profile (Profile model, HttpPostedFileBase AvatarFile)
+ public ActionResult MyProfile (Profile model, HttpPostedFileBase AvatarFile)
{
string username = Membership.GetUser ().UserName;
ViewData ["UserName"] = username;
diff --git a/web/Controllers/BasketController.cs b/web/Controllers/BasketController.cs
index 93c7bc27..0dff26a7 100644
--- a/web/Controllers/BasketController.cs
+++ b/web/Controllers/BasketController.cs
@@ -21,6 +21,7 @@ namespace Yavsc.ApiControllers
/// The wfmgr.
///
protected WorkFlowManager wfmgr = null;
+
///
/// Initialize the specified controllerContext.
///
@@ -78,10 +79,7 @@ namespace Yavsc.ApiControllers
[AcceptVerbs("POST")]
public void Post(long itemId)
{
-
throw new NotImplementedException ();
}
-
-
}
}
\ No newline at end of file
diff --git a/web/Controllers/BlogsApiController.cs b/web/Controllers/BlogsApiController.cs
index 04620933..d7da2cda 100644
--- a/web/Controllers/BlogsApiController.cs
+++ b/web/Controllers/BlogsApiController.cs
@@ -51,16 +51,7 @@ namespace Yavsc.ApiControllers
///
/// User.
/// Title.
- public static void RemovePost(string user, string title) {
- if (!Roles.IsUserInRole ("Admin")) {
- string rguser = Membership.GetUser ().UserName;
- if (rguser != user) {
- throw new AccessViolationException (
- string.Format (
- "Vous n'avez pas le droit de suprimer des billets du Blog de {0}",
- user));
- }
- }
+ public void RemovePost(string user, string title) {
BlogEntry e = BlogManager.GetPost (user, title);
if (e == null) {
throw new KeyNotFoundException (
diff --git a/web/Controllers/BlogsController.cs b/web/Controllers/BlogsController.cs
index 2c0ec793..92c6c375 100644
--- a/web/Controllers/BlogsController.cs
+++ b/web/Controllers/BlogsController.cs
@@ -342,7 +342,7 @@ namespace Yavsc.Controllers
ViewData["returnUrl"]=returnUrl;
if (!confirm)
return View ("RemovePost");
- BlogsApiController.RemovePost (user,title);
+ BlogManager.RemovePost (user,title);
if (returnUrl == null)
RedirectToAction ("Index",new { user = user });
return Redirect (returnUrl);
diff --git a/web/Controllers/GoogleController.cs b/web/Controllers/GoogleController.cs
index 2f1d4cfc..c1969777 100644
--- a/web/Controllers/GoogleController.cs
+++ b/web/Controllers/GoogleController.cs
@@ -241,10 +241,9 @@ namespace Yavsc.Controllers
});
}
string cred = OAuth2.GetFreshGoogleCredential (HttpContext.Profile);
- string json;
+
CalendarApi c = new CalendarApi ();
- CalendarList cl = c.GetCalendars (cred, out json);
- ViewData ["json"] = json;
+ CalendarList cl = c.GetCalendars (cred);
ViewData ["returnUrl"] = returnUrl;
return View (cl);
}
@@ -254,6 +253,7 @@ namespace Yavsc.Controllers
///
/// The calendar.
/// Calchoice.
+ /// return Url.
[HttpPost]
[Authorize]
public ActionResult SetCalendar (string calchoice,string returnUrl)
@@ -318,9 +318,8 @@ namespace Yavsc.Controllers
CalendarApi c = new CalendarApi ();
CalendarEntryList res;
- string responseStr;
try {
- res = c.GetCalendar (calid, mindate, maxdate, upr, out responseStr);
+ res = c.GetCalendar (calid, mindate, maxdate, upr);
} catch (GoogleErrorException ex) {
ViewData ["Title"] = ex.Title;
ViewData ["Content"] = ex.Content;
diff --git a/web/Controllers/WorkFlowController.cs b/web/Controllers/WorkFlowController.cs
index 5f27af4b..ed26a126 100644
--- a/web/Controllers/WorkFlowController.cs
+++ b/web/Controllers/WorkFlowController.cs
@@ -1,14 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
+using System.Net.Http;
using System.Web;
+using System.Web.Security;
using WorkFlowProvider;
using Yavsc.Model.WorkFlow;
-using System.Web.Http.Controllers;
-using System.Web.Security;
-using System.Web.Http.ModelBinding;
-using System.Net.Http;
using System.Web.Http;
+using System.Web.Http.Controllers;
+using System.Web.Http.ModelBinding;
namespace Yavsc.ApiControllers
{
diff --git a/web/Formatters/EstimToPdfFormatter.cs b/web/Formatters/EstimToPdfFormatter.cs
index 3d058e67..72637b7d 100644
--- a/web/Formatters/EstimToPdfFormatter.cs
+++ b/web/Formatters/EstimToPdfFormatter.cs
@@ -20,14 +20,15 @@
// along with this program. If not, see .
using System;
using System.Collections.Generic;
-using System.IO;
-using System.Net.Http.Headers;
-using System.Net.Http.Formatting;
-using Yavsc.Model.WorkFlow;
-using Yavsc.Model.RolesAndMembers;
-using System.Web.Profile;
-using System.Web;
using System.Diagnostics;
+using System.IO;
+using System.Net.Http;
+using System.Net.Http.Formatting;
+using System.Net.Http.Headers;
+using System.Web;
+using System.Web.Profile;
+using Yavsc.Model.RolesAndMembers;
+using Yavsc.Model.WorkFlow;
namespace Yavsc.Formatters
{
@@ -69,8 +70,9 @@ namespace Yavsc.Formatters
return enumerableType.IsAssignableFrom(type);
}
}
+
///
- /// Writes to stream.
+ /// Writes synchronously to the buffered stream.
///
/// Type.
/// Value.
@@ -97,7 +99,7 @@ namespace Yavsc.Formatters
tmpe.Session.Add ("to", prcli);
tmpe.Init ();
- string content = tmpe.TransformText ();
+ string contentStr = tmpe.TransformText ();
string name = string.Format ("tmpestimtex-{0}", e.Id);
string fullname = Path.Combine (
@@ -106,7 +108,7 @@ namespace Yavsc.Formatters
FileInfo fo = new FileInfo(fullname + ".pdf");
using (StreamWriter sw = new StreamWriter (fi.FullName))
{
- sw.Write (content);
+ sw.Write (contentStr);
}
using (Process p = new Process ()) {
p.StartInfo.WorkingDirectory = HttpRuntime.CodegenDir;
@@ -129,8 +131,10 @@ namespace Yavsc.Formatters
}
fi.Delete();
fo.Delete();
+
}
+
}
}
diff --git a/web/Formatters/RssFeedsFormatter.cs b/web/Formatters/RssFeedsFormatter.cs
index 56983bf8..04f63e3f 100644
--- a/web/Formatters/RssFeedsFormatter.cs
+++ b/web/Formatters/RssFeedsFormatter.cs
@@ -48,7 +48,7 @@ namespace Yavsc.Formatters
private const string dateformat = "ddd, dd MMM yyyy HH:mm:ss K";
///
- /// Writes to stream.
+ /// Writes synchronously to the buffered stream.
///
/// Type.
/// Value.
diff --git a/web/Formatters/TexToPdfFormatter.cs b/web/Formatters/TexToPdfFormatter.cs
index 71c18733..5f92be6c 100644
--- a/web/Formatters/TexToPdfFormatter.cs
+++ b/web/Formatters/TexToPdfFormatter.cs
@@ -25,9 +25,13 @@ using System.Collections.Generic;
using System.IO;
using System.Web;
using System.Diagnostics;
+using System.Net.Http;
namespace Yavsc.Formatters
{
+ ///
+ /// Tex to pdf formatter.
+ ///
public class TexToPdfFormatter: BufferedMediaTypeFormatter
{
///
@@ -73,7 +77,7 @@ namespace Yavsc.Formatters
public override void WriteToStream (Type type, object value, Stream stream, HttpContentHeaders contentHeaders)
{
- string content = value as string;
+ string cntStr = value as string;
string name = "tmpdoc-"+Guid.NewGuid().ToString();
string fullname = Path.Combine (
HttpRuntime.CodegenDir, name);
@@ -81,7 +85,7 @@ namespace Yavsc.Formatters
FileInfo fo = new FileInfo(fullname + ".pdf");
using (StreamWriter sw = new StreamWriter (fi.FullName))
{
- sw.Write (content);
+ sw.Write (cntStr);
}
using (Process p = new Process ()) {
p.StartInfo.WorkingDirectory = HttpRuntime.CodegenDir;
diff --git a/web/Global.asax.cs b/web/Global.asax.cs
index c840fb65..8fd9f0f1 100644
--- a/web/Global.asax.cs
+++ b/web/Global.asax.cs
@@ -6,9 +6,9 @@ using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Routing;
-using System.Web.Http;
using Yavsc.Formatters;
using Yavsc.Model.FrontOffice;
+using System.Web.Http;
namespace Yavsc
{
@@ -49,17 +49,18 @@ namespace Yavsc
new { controller = "Blogs", action = "Index", user=UrlParameter.Optional, title = UrlParameter.Optional }
);
}
+
///
- /// Applications the start.
+ /// Starts the Application.
///
protected void Application_Start ()
{
AreaRegistration.RegisterAllAreas ();
GlobalConfiguration.Configuration.Routes.MapHttpRoute(
- name: "DefaultApi",
+ name: "DefaultApi",
routeTemplate: "api/{controller}/{action}/{*id}",
defaults: new { controller = "WorkFlow", action="Index", id=0 }
- );
+ );
RegisterRoutes (RouteTable.Routes);
}
diff --git a/web/Helpers/BBCodeHelper.cs b/web/Helpers/BBCodeHelper.cs
index d6d093c6..f16cc581 100644
--- a/web/Helpers/BBCodeHelper.cs
+++ b/web/Helpers/BBCodeHelper.cs
@@ -103,6 +103,9 @@ namespace Yavsc.Helpers
///
public static void InitParser ()
{
+ // prevents a failure at second call
+ parent.Clear ();
+
BBTag urlBBTag = new BBTag ("url", "", "", true, true, UrlContentTransformer, new BBAttribute ("href", "",UrlAttributeTransformer), new BBAttribute ("href", "href",UrlAttributeTransformer));
BBTag bblist =new BBTag ("list", "
");
@@ -177,12 +180,12 @@ namespace Yavsc.Helpers
}
);
// used to build the doc toc
- parent.Clear ();
parent.Add ("*", bblist);
parent.Add ("sect3", bbs2);
parent.Add ("sect2", bbs1);
parent.Add ("sect1", bbdp);
//
+
}
///
/// Inits the document page.
@@ -270,7 +273,7 @@ namespace Yavsc.Helpers
static string UrlContentTransformer (string instr)
{
if (string.IsNullOrWhiteSpace (instr)) {
- return urlValue;
+ return "<"+urlValue+">";
} else
return instr;
}
diff --git a/web/Helpers/Google/CalendarApi.cs b/web/Helpers/Google/CalendarApi.cs
index 1a02706f..2f21630f 100644
--- a/web/Helpers/Google/CalendarApi.cs
+++ b/web/Helpers/Google/CalendarApi.cs
@@ -28,6 +28,7 @@ using System.IO;
using System.Text;
using Newtonsoft.Json;
using System.Web;
+using System.Runtime.Serialization.Json;
namespace Yavsc.Helpers.Google
{
@@ -60,8 +61,7 @@ namespace Yavsc.Helpers.Google
///
/// The calendars.
/// Cred.
- /// Json.
- public CalendarList GetCalendars (string cred, out string json)
+ public CalendarList GetCalendars (string cred)
{
CalendarList res = null;
HttpWebRequest webreq = WebRequest.CreateHttp (getCalListUri);
@@ -70,10 +70,7 @@ namespace Yavsc.Helpers.Google
webreq.ContentType = "application/http";
using (WebResponse resp = webreq.GetResponse ()) {
using (Stream respstream = resp.GetResponseStream ()) {
- using (StreamReader readresp = new StreamReader (respstream, Encoding.UTF8)) {
- json = readresp.ReadToEnd ();
- res = JsonConvert.DeserializeObject (json);
- }
+ res = (CalendarList) new DataContractJsonSerializer(typeof(CalendarList)).ReadObject (respstream);
}
resp.Close ();
}
@@ -89,8 +86,7 @@ namespace Yavsc.Helpers.Google
/// Mindate.
/// Maxdate.
/// Upr.
- /// Response string.
- public CalendarEntryList GetCalendar (string calid, DateTime mindate, DateTime maxdate, ProfileBase upr, out string responseStr)
+ public CalendarEntryList GetCalendar (string calid, DateTime mindate, DateTime maxdate, ProfileBase upr)
{
string uri = string.Format (
getCalEntriesUri, HttpUtility.UrlEncode (calid)) +
@@ -107,18 +103,14 @@ namespace Yavsc.Helpers.Google
try {
using (WebResponse resp = webreq.GetResponse ()) {
using (Stream respstream = resp.GetResponseStream ()) {
- using (StreamReader readresp = new StreamReader (respstream, Encoding.UTF8)) {
- responseStr = readresp.ReadToEnd ();
try {
- res = JsonConvert.DeserializeObject (responseStr);
- } catch (JsonReaderException ex) {
+ res = (CalendarEntryList) new DataContractJsonSerializer(typeof(CalendarEntryList)).ReadObject (respstream);
+ } catch (Exception ex) {
respstream.Close ();
resp.Close ();
webreq.Abort ();
- throw new GoogleErrorException(ex,responseStr);
+ throw new GoogleErrorException(ex);
}
- }
- respstream.Close ();
}
resp.Close ();
}
diff --git a/web/Helpers/Google/OAuth2.cs b/web/Helpers/Google/OAuth2.cs
index 5bd260c5..22b4a937 100644
--- a/web/Helpers/Google/OAuth2.cs
+++ b/web/Helpers/Google/OAuth2.cs
@@ -27,6 +27,7 @@ using Yavsc.Model.Google;
using System.Web.Profile;
using System.Web;
using Yavsc.Model;
+using System.Runtime.Serialization.Json;
namespace Yavsc.Helpers.Google
{
@@ -45,16 +46,14 @@ namespace Yavsc.Helpers.Google
public static People GetMe (AuthToken gat)
{
People me;
+ DataContractJsonSerializer ppser = new DataContractJsonSerializer (typeof(People));
HttpWebRequest webreppro = WebRequest.CreateHttp (getPeopleUri + "/me");
webreppro.ContentType = "application/http";
webreppro.Headers.Add (HttpRequestHeader.Authorization, gat.token_type + " " + gat.access_token);
webreppro.Method = "GET";
using (WebResponse proresp = webreppro.GetResponse ()) {
using (Stream prresponseStream = proresp.GetResponseStream ()) {
- using (StreamReader readproresp = new StreamReader (prresponseStream, Encoding.UTF8)) {
- string prresponseStr = readproresp.ReadToEnd ();
- me = JsonConvert.DeserializeObject (prresponseStr);
- }
+ me = (People) ppser.ReadObject (prresponseStream);
prresponseStream.Close ();
}
proresp.Close ();
@@ -189,11 +188,7 @@ namespace Yavsc.Helpers.Google
AuthToken gat = null;
using (WebResponse response = webreq.GetResponse ()) {
using (Stream responseStream = response.GetResponseStream ()) {
- using (StreamReader readStream = new StreamReader (responseStream, Encoding.UTF8)) {
- string responseStr = readStream.ReadToEnd ();
- gat = JsonConvert.DeserializeObject (responseStr);
- readStream.Close ();
- }
+ gat = (AuthToken) new DataContractJsonSerializer(typeof(AuthToken)).ReadObject (responseStream);
responseStream.Close ();
}
response.Close ();
diff --git a/web/Helpers/SimpleJsonPostMethod.cs b/web/Helpers/SimpleJsonPostMethod.cs
index 7a521efa..c608bd46 100644
--- a/web/Helpers/SimpleJsonPostMethod.cs
+++ b/web/Helpers/SimpleJsonPostMethod.cs
@@ -22,7 +22,7 @@ using System;
using System.Net;
using System.Text;
using System.IO;
-using Newtonsoft.Json;
+using System.Runtime.Serialization.Json;
namespace Yavsc.Helpers
{
@@ -74,23 +74,18 @@ namespace Yavsc.Helpers
/// Query.
public TAnswer Invoke(TQuery query)
{
- Byte[] bytes = System.Text.Encoding.UTF8.GetBytes (
- JsonConvert.SerializeObject(query));
- Request.ContentLength = bytes.Length;
- using (Stream dataStream = Request.GetRequestStream ()) {
- dataStream.Write (bytes, 0, bytes.Length);
- dataStream.Close ();
+ DataContractJsonSerializer serquery = new DataContractJsonSerializer (typeof(TQuery));
+ DataContractJsonSerializer seransw = new DataContractJsonSerializer (typeof(TAnswer));
+
+ using (MemoryStream streamQuery = new MemoryStream ()) {
+ serquery.WriteObject (streamQuery, query);
}
+
TAnswer ans = default (TAnswer);
using (WebResponse response = Request.GetResponse ()) {
using (Stream responseStream = response.GetResponseStream ()) {
- using (StreamReader readStream = new StreamReader (responseStream, Encoding.UTF8)) {
- string responseStr = readStream.ReadToEnd ();
- ans = JsonConvert.DeserializeObject (responseStr);
- readStream.Close ();
- }
- responseStream.Close ();
+ ans = (TAnswer) seransw.ReadObject(responseStream);
}
response.Close();
}
diff --git a/web/Models/App.master b/web/Models/App.master
index aa7de13a..7c5db7f0 100644
--- a/web/Models/App.master
+++ b/web/Models/App.master
@@ -11,7 +11,7 @@
-
+
@@ -52,12 +52,12 @@
Page d'accueil
<%= Html.ActionLink("Login", "Login", "Account", new { returnUrl=Request.Url.PathAndQuery }, new { @class="actionlink" } ) %>
Pour pouvoir poster ou commenter
- ?returnUrl=<%=Request.Url.PathAndQuery%>" class="actionlink">
+ ?returnUrl=<%=ViewData["returnUrl"]==null?Request.Url.PathAndQuery:(string)ViewData["returnUrl"]%>" class="actionlink">
S'authentifier avec son compte Google+
<% } else { %>
- <%= Html.ActionLink(HttpContext.Current.User.Identity.Name, "Profile", "Account", null, new { @class="actionlink" }) %>
+ <%= Html.ActionLink(HttpContext.Current.User.Identity.Name, "MyProfile", "Account", null, new { @class="actionlink" }) %>
Édition de votre profile
@ <%= Html.ActionLink( YavscHelpers.SiteName, "Index", "Home" ,null, new { @class="actionlink" }) %>
Page d'accueil
diff --git a/web/MvcActionValueBinder.cs b/web/MvcActionValueBinder.cs
deleted file mode 100644
index 83e19df7..00000000
--- a/web/MvcActionValueBinder.cs
+++ /dev/null
@@ -1,97 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Collections.Specialized;
-using System.Globalization;
-using System.Linq;
-using System.Net.Http;
-using System.Net.Http.Formatting;
-using System.Threading;
-using System.Threading.Tasks;
-using System.Web.Http;
-using System.Web.Http.Controllers;
-using System.Web.Http.ModelBinding;
-using System.Web.Http.ValueProviders;
-using System.Web.Http.ValueProviders.Providers;
-
-namespace Basic
-{
- // Binder with MVC semantics. Treat the body as KeyValue pairs and model bind it.
- ///
- /// Mvc action value binder.
- ///
- public class MvcActionValueBinder : DefaultActionValueBinder
- {
- // Per-request storage, uses the Request.Properties bag. We need a unique key into the bag.
- private const string Key = "5DC187FB-BFA0-462A-AB93-9E8036871EC8";
-
- ///
- /// Gets the binding.
- ///
- /// The binding.
- /// Action descriptor.
- public override HttpActionBinding GetBinding (HttpActionDescriptor actionDescriptor)
- {
-
- HttpActionBinding actionBinding = new HttpActionBinding ();
-
- HttpParameterDescriptor[] parameters = actionDescriptor.GetParameters ().ToArray ();
- HttpParameterBinding[] binders = Array.ConvertAll (parameters, p => DetermineBinding (actionBinding, p));
-
- actionBinding.ParameterBindings = binders;
- return actionBinding;
- }
-
- private HttpParameterBinding DetermineBinding (HttpActionBinding actionBinding, HttpParameterDescriptor parameter)
- {
- HttpConfiguration config = parameter.Configuration;
-
- var attr = new ModelBinderAttribute(); // use default settings
-
- ModelBinderProvider provider = attr.GetModelBinderProvider(config);
-
- // Alternatively, we could put this ValueProviderFactory in the global config.
- List vpfs = new List(attr.GetValueProviderFactories(config));
- vpfs.Add(new BodyValueProviderFactory());
- //vpfs.Add (new RouteDataValueProviderFactory ());
- return new ModelBinderParameterBinding(parameter, provider, vpfs);
- }
-
- // Derive from ActionBinding so that we have a chance to read the body once and then share that with all the parameters.
- private class MvcActionBinding : HttpActionBinding
- {
- // Read the body upfront , add as a ValueProvider
- public override Task ExecuteBindingAsync (HttpActionContext actionContext, CancellationToken cancellationToken)
- {
- HttpRequestMessage request = actionContext.ControllerContext.Request;
- HttpContent content = request.Content;
- if (content != null) {
- // content.ReadAsStreamAsync ().Result;
- FormDataCollection fd = content.ReadAsAsync ().Result;
- if (fd != null) {
-
- NameValueCollection nvc = fd.ReadAsNameValueCollection ();
-
- System.Web.Http.ValueProviders.IValueProvider vp = new System.Web.Http.ValueProviders.Providers.NameValueCollectionValueProvider (nvc, CultureInfo.InvariantCulture);
-
- request.Properties.Add (Key, vp);
- }
- }
-
- return base.ExecuteBindingAsync (actionContext, cancellationToken);
- }
- }
- // Get a value provider over the body. This can be shared by all parameters.
- // This gets the values computed in MvcActionBinding.
- private class BodyValueProviderFactory : System.Web.Http.ValueProviders.ValueProviderFactory
- {
- public override System.Web.Http.ValueProviders.IValueProvider GetValueProvider (HttpActionContext actionContext)
- {
- object vp;
- actionContext.Request.Properties.TryGetValue (Key, out vp);
- return (System.Web.Http.ValueProviders.IValueProvider)vp; // can be null
- }
- }
- }
-}
-
-
diff --git a/web/Views/Account/Profile.aspx b/web/Views/Account/MyProfile.aspx
similarity index 97%
rename from web/Views/Account/Profile.aspx
rename to web/Views/Account/MyProfile.aspx
index fa9ea1cc..4cbc9534 100644
--- a/web/Views/Account/Profile.aspx
+++ b/web/Views/Account/MyProfile.aspx
@@ -11,7 +11,7 @@ table.layout { border-width: 0; }
table.layout TR TD { max-width:40%; }
<%= Html.ValidationSummary() %>
-<% using(Html.BeginForm("Profile", "Account", FormMethod.Post, new { enctype = "multipart/form-data" })) %>
+<% using(Html.BeginForm("MyProfile", "Account", FormMethod.Post, new { enctype = "multipart/form-data" })) %>
<% { %>