de réservation d'un préstataire * p8-av4.xxs.jpg: * p8-av4.xxs.png: inutile * NoLogin.master: * Entity.cs: * OAuth2.cs: * ApiClient.cs: * PeopleApi.cs: * MapTracks.cs: * SkillManager.cs: * Skills.aspx: * EntityQuery.cs: * CalendarApi.cs: * SimpleJsonPostMethod.cs: * GoogleHelpers.cs: * EventPub.aspx: * GoogleController.cs: * Notification.cs: * UserSkills.aspx: * BackOfficeController.cs: * BackOfficeController.cs: * Notification.cs: * MessageWithPayLoad.cs: * MessageWithPayloadResponse.cs: refabrication * IContentProvider.cs: * NpgsqlBlogProvider.cs: xml doc * NpgsqlContentProvider.cs: implemente un listing des prestataire du code APE en base. * NpgsqlSkillProvider.cs: implemente un listing des domaines de compétence du préstataire en base. * XmlCatalogProvider.cs: Le catalogue de vente implémente mainenant l'interface d'un fournisseur de donnée comme les autres. Il pourrait par exemple vouloir définir des activité et des compétences. Pour l'instant, il n'est pas activé par la configuration, et reste le fournisseur du catalogue legacy (voir </FrontOffice/Catalog> ). * FrontOfficeController.cs: format du code * Global.asax.cs: Une route customisée pour le Front Office : /do (genre, ici, ça bouge.) * activity.sql: implémente en base de donnée le modèle des activités et compétences, ajoute aussi deux activités : l'edition logicielle et "Artiste" * style.css: changement de mes images de fond ... tombées du camion de Xavier et onlinehome.us * p8-av4.s.jpg: changement de taille * AccountController.cs: Met le code MEA à "none" quand il est spécifié non disponible. * BlogsController.cs: fixe un bug de l'edition d'un billet * FrontOfficeController.cs: implemente le contrôle booking simple * HomeController.cs: ajoute l'assemblage du catalog dans le listing dédié * YavscAjaxHelper.cs: Implemente un outil de representation JSon des objets côté serveur * parallax.js: deux fois plus de mouvement autout de x dans le parallax * yavsc.rate.js: imlemente un callback JS pour le rating * Activities.aspx: Des labels au formulaire de déclaration des activités * Activity.ascx: un panneau activité descent * Booking.aspx: implemente l'UI web du booking simple. * EavyBooking.aspx: refabrication du booking lourd * Index.aspx: supprime le panneau du tag Accueil, affiche les activités en cours du site (avec au moins un préstataire valide pour cette activité) * Web.config: Implemente une cote utilisateur, par une nouvelle valeur de son profile (Rate). * Yavsc.csproj: refabrique du code API Google, qui part dans le model. * MarkdownDeep.dll: le tag <p> ne convenait pas, le remplacer par le tag <span> non plus. Maintenant ça devrait être correct, c'est un div, mais que en cas de tag englobant non défini. * BookingQuery.cs: Le booking lourd devient une commande basée sur des activités concernée par l'intervention * ChangeLog: nettoyage * CatalogProvider.cs: implemente l'interface d'un fournissseur de contenu * PerformerProfile.cs: implemente le profile prestataire * SimpleBookingQuery.cs: Les besoin sont exprimé sous forme d'un tableau de valeur du parametrage de la commande * LocalizedText.resx: * LocalizedText.fr.resx: * LocalizedText.Designer.cs: * LocalizedText.fr.Designer.cs: internationalisation * Profile.cs: implemente un accès à l'id d'enregistrement Google GCM * SkillEntity.cs: La compétence appartient à un domaine d'activité, on lui associe un et un seul code APE * SkillProvider.cs: Fait chercher les compétences à partir d'un code activité * WorkFlowManager.cs: implemente l'accès à la liste des préstataires de telle activité * YavscModel.csproj: refabrications * Skills.sql: vient de passer dans activity.Sql * T.cs: la traduction est faite plus simple à appeler (sans cast vers `string`).
210 lines
6 KiB
C#
210 lines
6 KiB
C#
using System;
|
|
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.Formatters;
|
|
using Yavsc.Helpers;
|
|
using Yavsc.Model;
|
|
using Yavsc.Model.FrontOffice;
|
|
using Yavsc.Model.RolesAndMembers;
|
|
using Yavsc.Model.WorkFlow;
|
|
using System.IO;
|
|
using Yavsc.Model.FrontOffice.Catalog;
|
|
using Yavsc.Model.Skill;
|
|
|
|
namespace Yavsc.ApiControllers
|
|
{
|
|
|
|
|
|
/// <summary>
|
|
/// Front office controller.
|
|
/// </summary>
|
|
public class FrontOfficeController : YavscController
|
|
{
|
|
/// <summary>
|
|
/// search the specified Activities.
|
|
/// </summary>
|
|
/// <param name="search">Search.</param>
|
|
|
|
public Activity[] Activities (string search)
|
|
{
|
|
if (search == null)
|
|
search = "%";
|
|
return WorkFlowManager.FindActivity(search,true);
|
|
}
|
|
/// <summary>
|
|
/// Registers the activity.
|
|
/// </summary>
|
|
/// <param name="act">Act.</param>
|
|
[HttpPost,ValidateAjax]
|
|
public void RegisterActivity(Activity act)
|
|
{
|
|
if (ModelState.IsValid)
|
|
WorkFlowManager.RegisterActivity (act.Title, act.Id, act.Comment);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Catalog this instance.
|
|
/// </summary>
|
|
[AcceptVerbs ("GET")]
|
|
public Catalog Catalog ()
|
|
{
|
|
Catalog c = CatalogManager.GetCatalog ();
|
|
return c;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Gets the product categorie.
|
|
/// </summary>
|
|
/// <returns>The product categorie.</returns>
|
|
/// <param name="brandName">Brand name.</param>
|
|
/// <param name="prodCategorie">Prod categorie.</param>
|
|
[AcceptVerbs ("GET")]
|
|
public ProductCategory GetProductCategorie (string brandName, string prodCategorie)
|
|
{
|
|
return CatalogManager.GetCatalog ().GetBrand (brandName).GetProductCategory (prodCategorie);
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// Gets the estimate.
|
|
/// </summary>
|
|
/// <returns>The estimate.</returns>
|
|
/// <param name="id">Estimate Id.</param>
|
|
[Authorize]
|
|
[HttpGet]
|
|
public Estimate GetEstimate (long id)
|
|
{
|
|
Estimate est = WorkFlowManager.DefaultProvider.Get (id);
|
|
string username = Membership.GetUser ().UserName;
|
|
if (est.Client != username)
|
|
if (!Roles.IsUserInRole("Admin"))
|
|
if (!Roles.IsUserInRole("FrontOffice"))
|
|
throw new AuthorizationDenied (
|
|
string.Format (
|
|
"Auth denied to eid {1} for:{2}",
|
|
id, username));
|
|
return est;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Gets the estim tex.
|
|
/// </summary>
|
|
/// <returns>The estim tex.</returns>
|
|
/// <param name="id">Estimate id.</param>
|
|
[AcceptVerbs ("GET")]
|
|
public HttpResponseMessage EstimateToTex (long id)
|
|
{
|
|
string texest = estimateToTex (id);
|
|
if (texest == null)
|
|
throw new InvalidOperationException (
|
|
"Not an estimate");
|
|
HttpResponseMessage result = new HttpResponseMessage () {
|
|
Content = new ObjectContent (typeof(string),
|
|
texest,
|
|
new SimpleFormatter ("text/x-tex"))
|
|
};
|
|
result.Content.Headers.ContentDisposition = new ContentDispositionHeaderValue ("attachment") {
|
|
FileName = "estimate-" + id.ToString () + ".tex"
|
|
};
|
|
return result;
|
|
}
|
|
|
|
private string estimateToTex (long estimid)
|
|
{
|
|
Yavsc.templates.Estim tmpe = new Yavsc.templates.Estim ();
|
|
Estimate e = WorkFlowManager.GetEstimate (estimid);
|
|
tmpe.Session = new Dictionary<string,object> ();
|
|
tmpe.Session.Add ("estim", e);
|
|
Profile prpro = new Profile (ProfileBase.Create (e.Responsible));
|
|
if (!prpro.HasBankAccount)
|
|
throw new TemplateException ("NotBankable:" + e.Responsible);
|
|
if (!prpro.HasPostalAddress)
|
|
throw new TemplateException ("NoPostalAddress:" + e.Responsible);
|
|
|
|
Profile prcli = new Profile (ProfileBase.Create (e.Client));
|
|
if (!prcli.IsBillable)
|
|
throw new TemplateException ("NotBillable:" + e.Client);
|
|
|
|
tmpe.Session.Add ("from", prpro);
|
|
tmpe.Session.Add ("to", prcli);
|
|
tmpe.Session.Add ("efrom", Membership.GetUser (e.Responsible).Email);
|
|
tmpe.Session.Add ("eto", Membership.GetUser (e.Client).Email);
|
|
tmpe.Init ();
|
|
return tmpe.TransformText ();
|
|
}
|
|
|
|
/// <summary>
|
|
/// Gets the estimate in pdf format from tex generation.
|
|
/// </summary>
|
|
/// <returns>The to pdf.</returns>
|
|
/// <param name="id">Estimid.</param>
|
|
[AcceptVerbs("GET")]
|
|
public HttpResponseMessage EstimateToPdf (long id)
|
|
{
|
|
string texest = null;
|
|
try {
|
|
texest = estimateToTex (id);
|
|
} catch (TemplateException ex) {
|
|
return new HttpResponseMessage (HttpStatusCode.OK) { Content =
|
|
new ObjectContent (typeof(string),
|
|
ex.Message, new ErrorHtmlFormatter (HttpStatusCode.NotAcceptable,
|
|
LocalizedText.DocTemplateException
|
|
))
|
|
};
|
|
} catch (Exception ex) {
|
|
return new HttpResponseMessage (HttpStatusCode.OK) { Content =
|
|
new ObjectContent (typeof(string),
|
|
ex.Message, new ErrorHtmlFormatter (HttpStatusCode.InternalServerError,
|
|
LocalizedText.DocTemplateException))
|
|
};
|
|
}
|
|
if (texest == null)
|
|
return new HttpResponseMessage (HttpStatusCode.OK) { Content =
|
|
new ObjectContent (typeof(string), "Not an estimation id:" + id,
|
|
new ErrorHtmlFormatter (HttpStatusCode.NotFound,
|
|
LocalizedText.Estimate_not_found))
|
|
};
|
|
|
|
var memPdf = new MemoryStream ();
|
|
try {
|
|
new TexToPdfFormatter ().WriteToStream (
|
|
typeof(string), texest, memPdf,null);
|
|
}
|
|
catch (FormatterException ex) {
|
|
return new HttpResponseMessage (HttpStatusCode.OK) { Content =
|
|
new ObjectContent (typeof(string), ex.Message+"\n\n"+ex.Output+"\n\n"+ex.Error,
|
|
new ErrorHtmlFormatter (HttpStatusCode.InternalServerError,
|
|
LocalizedText.InternalServerError))
|
|
};
|
|
}
|
|
|
|
var result = new HttpResponseMessage(HttpStatusCode.OK)
|
|
{
|
|
Content = new ByteArrayContent(memPdf.GetBuffer())
|
|
};
|
|
|
|
result.Content.Headers.ContentDisposition = new System.Net.Http.Headers.ContentDispositionHeaderValue ("attachment") {
|
|
FileName = String.Format (
|
|
"Estimation-{0}.pdf",
|
|
id)
|
|
};
|
|
|
|
return result;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Rates the skill, this is a client action to profile its needs.
|
|
/// </summary>
|
|
/// <param name="rate">Skill rating.</param>
|
|
[Authorize()]
|
|
public void RateSkill (SkillRating rate) {
|
|
throw new NotImplementedException ();
|
|
}
|
|
}
|
|
}
|
|
|