* ResetPassword.txt: Un message pour le mot de passe oublié * style.css: fixe un 404 * UpdatePassword.aspx: Implémente le formulaire de mise à jour du mot de passe, accessible depuis l'e-mail. * Contact.aspx: implémente la page de contact préstataire * UpdatePassword.cs: modèle de la modification de mot de passe au jeton de securité (qui est encore un fake en l'état) * CommandRegistration.cs: un enregistrement de commande * NominativeCommandRegistration.cs: un enregistrement de commande nominative * .gitignore: ignore ma config LuaDebug * NpgsqlMembershipProvider.cs: ne pas crasher à la lecture en base de la question de recupération du mot de passe quand elle est nulle. * BasketController.cs: renvoie l'objet décrivant la prise de commande * Global.asax.cs: ignorer les routes vers App_Data et App_Code * instdbws.sql: passage du type json à jsonb pour les paramètres de la commande * RegistrationMail.txt: un piti message à l'enregistrement * AccountController.cs: Envoi du message du mot de passe oublié, methode de changemnet du mot de passe. * AdminController.cs: xmldoc + refabrication helper Notify * HomeController.cs: * BlogsController.cs: * GoogleController.cs: refabrication helper Notify * FrontOfficeController.cs: Refabrication: Utilisation du nouvel enregistrement de commande. + refabrication helper Notify * YavscHelpers.cs: implémente la methode d'envoi du message de mot de passe oublié + refabrication helper Notify * App.master: Corrige la notification Html * AppAdmin.master: Le lien vers la page de contact était associé à tort à la classe css "thanks" * yavsc.js: message plus parlant en cas de requête Ajax mal formée. * Login.aspx: Implémente le lien vers le formulaire de recupération du mot de passe * UserPost.aspx: . * Booking.aspx: format du code * Performer.ascx: l'e-mail préstataire ne sera jamais fourni par l'application, aussi, on parlera de "prendre contact", d'échanger ... mais pas de donner l'adresse e-mail. L'information "son email" n'est donc pas disponible meme à l'utilisateur autorisé. La prise de contact, ou autre fux de comunication le sont. * Performers.aspx: affiche la notification à l'envoi de la demande de devis * Product.aspx: * Service.aspx: les periodes du catalogue et du calendrier sont fondue. * Contact.aspx: traduction en français * Web.config: * la procédure de recupération du mot de passe est activée * l'e-message envoyé est construit à partir d'un modèle, un fichier texte trouvé dans /App_Data, et indiqué à l'application par le paramêtre applicatif "LostPasswordMessage" * Yavsc.csproj: reference les nouveaux fichiers * Product.cs: utilise la période du calendrier * Commande.cs: renvoie un objet à la prise de commande, indiquant l'identifiant de commande, et les messages envoyés en cas de commande nominative. * GoogleHelpers.cs: icone à la notification mobile * LocalizedText.resx: * LocalizedText.fr.resx: * LocalizedText.Designer.cs: * LocalizedText.fr.Designer.cs: traductions * UserNameBase.cs: fixe la dé-sérialisation * WorkFlowManager.cs: refabrication de la prise de commande * YavscModel.csproj: nouveaux objets du modèle * OtherWebException.aspx: page obsolete * Period.cs: fondre la période: celle du catalogue disparait, au profit de celle du calendrier.
347 lines
9.6 KiB
C#
347 lines
9.6 KiB
C#
using System;
|
|
using Yavsc.Model.WorkFlow;
|
|
using System.Configuration;
|
|
using System.Collections.Specialized;
|
|
using Yavsc.Model.FrontOffice;
|
|
using System.Configuration.Provider;
|
|
using Yavsc.Model.FrontOffice.Catalog;
|
|
using System.Collections.Generic;
|
|
using Yavsc.Model.Skill;
|
|
using System.Linq;
|
|
using Yavsc.Model.Calendar;
|
|
using Yavsc.Model.Google.Api;
|
|
using System.Net.Mail;
|
|
using System.Web.Security;
|
|
using System.Web.Configuration;
|
|
using System.Net;
|
|
using System.IO;
|
|
|
|
namespace Yavsc.Model.WorkFlow
|
|
{
|
|
|
|
|
|
/// <summary>
|
|
/// Work flow manager.
|
|
/// It takes orders store them and raise some events for modules
|
|
/// It publishes estimates and invoices
|
|
/// </summary>
|
|
public static class WorkFlowManager
|
|
{
|
|
|
|
/// <summary>
|
|
/// Finds the activity.
|
|
/// </summary>
|
|
/// <returns>The activity.</returns>
|
|
/// <param name="pattern">Pattern.</param>
|
|
/// <param name="exerted">If set to <c>true</c> exerted.</param>
|
|
public static Activity[] FindActivity (string pattern = "%", bool exerted = true)
|
|
{
|
|
List<Activity> activities = new List<Activity> ();
|
|
foreach (var provider in Providers) {
|
|
foreach (var act in provider.FindActivity (pattern, exerted))
|
|
if (!activities.Contains (act))
|
|
activities.Add (act);
|
|
}
|
|
return activities.ToArray ();
|
|
}
|
|
|
|
/// <summary>
|
|
/// Finds the performer.
|
|
/// </summary>
|
|
/// <returns>The performer.</returns>
|
|
/// <param name="MEACode">MEA code.</param>
|
|
/// <param name="skills">Skills.</param>
|
|
public static PerformerProfile [] FindPerformer (string MEACode, SkillRating[] skills)
|
|
{
|
|
string[] usernames = SkillManager.FindPerformer (MEACode, skills);
|
|
List<PerformerProfile> result = new List<PerformerProfile> ();
|
|
foreach (string user in usernames)
|
|
result.Add (SkillManager.GetUserSkills (user));
|
|
return result.ToArray ();
|
|
}
|
|
|
|
/// <summary>
|
|
/// Gets the activity.
|
|
/// </summary>
|
|
/// <returns>The activity.</returns>
|
|
/// <param name="meacode">MAE code.</param>
|
|
public static Activity GetActivity (string meacode)
|
|
{
|
|
return DefaultProvider.GetActivity (meacode);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Gets or sets the catalog.
|
|
/// </summary>
|
|
/// <value>The catalog.</value>
|
|
public static Catalog Catalog { get; set; }
|
|
|
|
|
|
|
|
/// <summary>
|
|
/// Registers the command.
|
|
/// </summary>
|
|
/// <returns>The command.</returns>
|
|
/// <param name="com">COM.</param>
|
|
public static CommandRegistration RegisterCommand (Command com)
|
|
{
|
|
long cmdid = DefaultProvider.RegisterCommand (com);
|
|
string errorMsgGCM=null;
|
|
if (com.GetType ().GetInterface ("INominative") != null) {
|
|
var result = new NominativeCommandRegistration ();
|
|
result.CommandId = cmdid;
|
|
INominative cmdn = com as INominative;
|
|
NominativeEventPub ev = new NominativeEventPub ();
|
|
ev.PerformerName = cmdn.PerformerName;
|
|
string desc = com.GetDescription ();
|
|
ev.Description = desc;
|
|
// TODO send a location
|
|
try {
|
|
|
|
var gnresponse = GoogleHelpers.NotifyEvent (ev);
|
|
if (gnresponse.failure > 0 || gnresponse.success <=0)
|
|
result.NotifiedOnMobile = false;
|
|
else result.NotifiedOnMobile = true;
|
|
|
|
} catch (WebException ex) {
|
|
|
|
using (var respstream = ex.Response.GetResponseStream ()) {
|
|
using (StreamReader rdr = new StreamReader (respstream)) {
|
|
errorMsgGCM = rdr.ReadToEnd ();
|
|
rdr.Close ();
|
|
}
|
|
respstream.Close ();
|
|
}
|
|
if (errorMsgGCM == null)
|
|
throw;
|
|
|
|
throw new Exception (errorMsgGCM,ex);
|
|
}
|
|
string errorEMail = null;
|
|
try {
|
|
var pref = Membership.GetUser (cmdn.PerformerName);
|
|
using (System.Net.Mail.MailMessage msg =
|
|
new MailMessage (
|
|
WebConfigurationManager.AppSettings.Get ("OwnerEMail"),
|
|
pref.Email,
|
|
"[Demande de devis] " + com.ClientName,
|
|
desc)) {
|
|
using (System.Net.Mail.SmtpClient sc = new SmtpClient ()) {
|
|
sc.Send (msg);
|
|
result.EmailSent = true;
|
|
}
|
|
}
|
|
} catch (Exception ex) {
|
|
errorEMail = ex.Message;
|
|
result.EmailSent = false;
|
|
}
|
|
return result;
|
|
} else
|
|
throw new NotImplementedException ();
|
|
}
|
|
|
|
/// <summary>
|
|
/// Updates the estimate.
|
|
/// </summary>
|
|
/// <param name="estim">Estim.</param>
|
|
public static void UpdateEstimate (Estimate estim)
|
|
{
|
|
DefaultProvider.Update (estim);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Gets the estimate.
|
|
/// </summary>
|
|
/// <returns>The estimate.</returns>
|
|
/// <param name="estid">Estid.</param>
|
|
public static Estimate GetEstimate (long estid)
|
|
{
|
|
return DefaultProvider.Get (estid);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Gets the estimates, refering the
|
|
/// given client or username .
|
|
/// </summary>
|
|
/// <returns>The estimates.</returns>
|
|
/// <param name="responsible">Responsible.</param>
|
|
public static Estimate [] GetResponsibleEstimates (string responsible)
|
|
{
|
|
return DefaultProvider.GetEstimates (null, responsible);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Gets the client estimates.
|
|
/// </summary>
|
|
/// <returns>The client estimates.</returns>
|
|
/// <param name="client">Client.</param>
|
|
public static Estimate [] GetClientEstimates (string client)
|
|
{
|
|
return DefaultProvider.GetEstimates (client, null);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Gets the user estimates.
|
|
/// </summary>
|
|
/// <returns>The user estimates.</returns>
|
|
/// <param name="username">Username.</param>
|
|
public static Estimate [] GetUserEstimates (string username)
|
|
{
|
|
return DefaultProvider.GetEstimates (username);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Gets the stock for a given product reference.
|
|
/// </summary>
|
|
/// <returns>The stock status.</returns>
|
|
/// <param name="productReference">Product reference.</param>
|
|
public static StockStatus GetStock (string productReference)
|
|
{
|
|
return DefaultProvider.GetStockStatus (productReference);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Updates the writting.
|
|
/// </summary>
|
|
/// <param name="wr">Wr.</param>
|
|
public static void UpdateWritting (Writting wr)
|
|
{
|
|
DefaultProvider.UpdateWritting (wr);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Drops the writting.
|
|
/// </summary>
|
|
/// <param name="wrid">Wrid.</param>
|
|
public static void DropWritting (long wrid)
|
|
{
|
|
DefaultProvider.DropWritting (wrid);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Drops the estimate.
|
|
/// </summary>
|
|
/// <param name="estid">Estid.</param>
|
|
public static void DropEstimate (long estid)
|
|
{
|
|
DefaultProvider.DropEstimate (estid);
|
|
}
|
|
|
|
static IContentProvider defaultProvider;
|
|
|
|
/// <summary>
|
|
/// Gets the content provider.
|
|
/// </summary>
|
|
/// <value>The content provider.</value>
|
|
public static IContentProvider DefaultProvider {
|
|
|
|
get {
|
|
if (defaultProvider == null)
|
|
defaultProvider = ManagerHelper.CreateDefaultProvider
|
|
("system.web/workflow") as IContentProvider;
|
|
return defaultProvider;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Drops the writting tag.
|
|
/// </summary>
|
|
/// <param name="wrid">Wrid.</param>
|
|
/// <param name="tag">Tag.</param>
|
|
public static void DropWrittingTag (long wrid, string tag)
|
|
{
|
|
throw new NotImplementedException ();
|
|
}
|
|
|
|
/// <summary>
|
|
/// Gets the providers.
|
|
/// </summary>
|
|
/// <value>The providers.</value>
|
|
public static IContentProvider [] Providers {
|
|
|
|
get {
|
|
if (providers == null) {
|
|
var pbs = ManagerHelper.CreateProviders
|
|
("system.web/workflow");
|
|
providers = new IContentProvider [pbs.Length];
|
|
for (var i = 0; i < pbs.Length; i++)
|
|
providers [i] = pbs [i] as IContentProvider;
|
|
}
|
|
return providers;
|
|
}
|
|
}
|
|
|
|
private static IContentProvider[] providers = null;
|
|
|
|
/// <summary>
|
|
/// Creates the estimate.
|
|
/// </summary>
|
|
/// <returns>The estimate.</returns>
|
|
/// <param name="responsible">Responsible.</param>
|
|
/// <param name="client">Client.</param>
|
|
/// <param name="title">Title.</param>
|
|
/// <param name="description">Description.</param>
|
|
public static Estimate CreateEstimate (string responsible, string client, string title, string description)
|
|
{
|
|
Estimate created = DefaultProvider.CreateEstimate (responsible, client, title, description);
|
|
return created;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Write the specified estid, desc, ucost, count and productid.
|
|
/// </summary>
|
|
/// <param name="estid">Estid.</param>
|
|
/// <param name="desc">Desc.</param>
|
|
/// <param name="ucost">Ucost.</param>
|
|
/// <param name="count">Count.</param>
|
|
/// <param name="productid">Productid.</param>
|
|
public static long Write (long estid, string desc, decimal ucost, int count, string productid)
|
|
{
|
|
if (!string.IsNullOrWhiteSpace (productid)) {
|
|
if (Catalog == null)
|
|
Catalog = CatalogManager.GetCatalog ();
|
|
if (Catalog == null)
|
|
throw new Exception ("No catalog");
|
|
Product p = Catalog.FindProduct (productid);
|
|
if (p == null)
|
|
throw new Exception ("Product not found");
|
|
// TODO new EstimateChange Event
|
|
}
|
|
return DefaultProvider.Write (estid, desc, ucost, count, productid);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Sets the estimate status.
|
|
/// </summary>
|
|
/// <param name="estid">Estid.</param>
|
|
/// <param name="status">Status.</param>
|
|
/// <param name="username">Username.</param>
|
|
public static void SetEstimateStatus (long estid, int status, string username)
|
|
{
|
|
DefaultProvider.SetEstimateStatus (estid, status, username);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Gets the commands.
|
|
/// </summary>
|
|
/// <returns>The commands.</returns>
|
|
/// <param name="username">Username.</param>
|
|
public static CommandSet GetCommands (string username)
|
|
{
|
|
return DefaultProvider.GetCommands (username);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Registers the activity.
|
|
/// </summary>
|
|
/// <param name="activityName">Activity name.</param>
|
|
/// <param name="meacode">Meacode.</param>
|
|
/// <param name="comment">Comment.</param>
|
|
public static void RegisterActivity (string activityName, string meacode, string comment)
|
|
{
|
|
DefaultProvider.RegisterActivity (activityName, meacode, comment);
|
|
}
|
|
}
|
|
}
|
|
|