La notification à la demande de devis,

côté sérveur.

* Makefile:
* Yavsc.sln:
* pkg.mdproj:
* Yavsc.csproj:
* Presta.csproj:
* TestAPI.csproj:
* YavscModel.csproj:
* fortune.csproj:
* WebControls.csproj:
* YavscClient.csproj:
* SalesCatalog.csproj:
* ITContentProvider.csproj:
* NpgsqlMRPProviders.csproj:
* NpgsqlBlogProvider.csproj:
* NpgsqlContentProvider.csproj: ajout d'une configuration de debuggage
  pour Lua

* App.master:
* LocalizedText.resx:
* LocalizedText.fr.resx:
* LocalizedText.Designer.cs:
* LocalizedText.fr.Designer.cs: traductions

* EventPub.aspx: debug sur page encore inutilisée

* NominativeEventPub.cs: implémentation du nom de préstataire dans la
  notification nominative

* Commande.cs: code plus simple

* GoogleHelpers.cs:
* MessageWithPayLoad.cs: fixe l'envoi de la notification GCM

* MessageWithPayloadResponse.cs: fixe la réception de la notification
  GCM

* WorkFlowManager.cs: envoyer un notification GCM + email à la demande
  de devis
This commit is contained in:
Paul Schneider 2015-12-24 13:59:07 +01:00
commit 5a4179d051
42 changed files with 644 additions and 334 deletions

View file

@ -34,12 +34,7 @@ namespace Yavsc.Model.Calendar
{
#region INominative implementation
public string PerformerName {
get {
throw new NotImplementedException ();
}
set {
throw new NotImplementedException ();
}
get ; set ;
}
#endregion
}

View file

@ -1,3 +1,27 @@
2015-12-24 Paul Schneider <paul@pschneider.fr>
* NominativeEventPub.cs: implémentation du nom de préstataire
dans la notification nominative
* Commande.cs: code plus simple
* GoogleHelpers.cs:
* MessageWithPayLoad.cs: fixe l'envoi de la notification GCM
* MessageWithPayloadResponse.cs: fixe la réception de la
notification GCM
* LocalizedText.resx:
* LocalizedText.fr.resx:
* LocalizedText.Designer.cs:
* LocalizedText.fr.Designer.cs: traductions
* WorkFlowManager.cs: envoyer un notification GCM + email à la
demande de devis
* YavscModel.csproj: ajout d'une configuration de debuggage
pour Lua
2015-12-23 Paul Schneider <paul@pschneider.fr>
* WorkFlowManager.cs: une note à faire : envoyer le lieu de la

View file

@ -105,8 +105,7 @@ namespace Yavsc.Model.FrontOffice
// stores the parameters:
SetParameters(collection);
WorkFlowManager.RegisterCommand (this); // gives a value to this.Id
string strcmdid = Id.ToString ();
UserFileSystemManager.Put(Path.Combine("commandes",strcmdid),files);
UserFileSystemManager.Put(Path.Combine("commandes",Id.ToString ()),files);
}
/// <summary>

View file

@ -106,6 +106,8 @@ namespace Yavsc.Model.Google.Api
using (var r =
new SimpleJsonPostMethod<MessageWithPayload<YaEvent>,MessageWithPayloadResponse>(
"https://gcm-http.googleapis.com/gcm/send")) {
r.SetCredential (ConfigurationManager.AppSettings ["GOOGLE_GCM_API_KEY"]);
if (evpub.CircleIds != null) {
var users = Circle.Union (evpub.CircleIds);
var regids = new List<string> ();
@ -127,7 +129,7 @@ namespace Yavsc.Model.Google.Api
var msg = new MessageWithPayload<YaEvent> () {
notification = new Notification() { title = evpub.Title, body = evpub.Description, icon = "event" },
data = new YaEvent[] { (YaEvent)evpub }, registration_ids = regids.ToArray() };
data = evpub , registration_ids = regids.ToArray() };
return r.Invoke (msg);
} else {
@ -145,13 +147,14 @@ namespace Yavsc.Model.Google.Api
using (var r =
new SimpleJsonPostMethod<MessageWithPayload<YaEvent>,MessageWithPayloadResponse> (
"https://gcm-http.googleapis.com/gcm/send")) {
r.SetCredential ("key="+ConfigurationManager.AppSettings ["GOOGLE_API_KEY"]);
var userprofile = ProfileBase.Create (evpub.PerformerName);
var regid = userprofile.GetPropertyValue ("gregid") as string;
if (regid == null)
throw new NotImplementedException ("Notification via e-mail");
var msg = new MessageWithPayload<YaEvent> () {
notification = new Notification() { title = evpub.Title, body = evpub.Description, icon = "event" },
data = new YaEvent[] { (YaEvent)evpub }, registration_ids = new string[] { regid } };
data = evpub, registration_ids = new string[] { regid } };
return r.Invoke (msg);
}
}

View file

@ -39,7 +39,7 @@ namespace Yavsc.Model.Google.Api.Messaging
/// <summary>
/// The data.
/// </summary>
public T[] data ;
public T data ;
/// <summary>
/// The notification.
/// </summary>

View file

@ -32,7 +32,7 @@ namespace Yavsc.Model.Google.Api.Messaging
/// <summary>
/// The multicast identifier.
/// </summary>
public int multicast_id;
public string multicast_id;
/// <summary>
/// The success count.
/// </summary>
@ -44,7 +44,7 @@ namespace Yavsc.Model.Google.Api.Messaging
/// <summary>
/// The canonical identifiers... ?!?
/// </summary>
public int canonical_ids;
public string canonical_ids;
/// <summary>
/// Detailled result.
/// </summary>

View file

@ -196,12 +196,24 @@ namespace Yavsc.Model {
}
}
public static string YourProfile {
get {
return ResourceManager.GetString("YourProfile", resourceCulture);
}
}
public static string EndDate {
get {
return ResourceManager.GetString("EndDate", resourceCulture);
}
}
public static string DoSpecifyCircles {
get {
return ResourceManager.GetString("DoSpecifyCircles", resourceCulture);
}
}
public static string Circles {
get {
return ResourceManager.GetString("Circles", resourceCulture);
@ -244,6 +256,12 @@ namespace Yavsc.Model {
}
}
public static string YourPosts {
get {
return ResourceManager.GetString("YourPosts", resourceCulture);
}
}
public static string Non_existent_user {
get {
return ResourceManager.GetString("Non_existent_user", resourceCulture);
@ -286,6 +304,12 @@ namespace Yavsc.Model {
}
}
public static string younotadmin {
get {
return ResourceManager.GetString("younotadmin", resourceCulture);
}
}
public static string Create {
get {
return ResourceManager.GetString("Create", resourceCulture);
@ -340,12 +364,6 @@ namespace Yavsc.Model {
}
}
public static string is_licensed_by {
get {
return ResourceManager.GetString("is_licensed_by", resourceCulture);
}
}
public static string BookingTitle6829C {
get {
return ResourceManager.GetString("BookingTitle6829C", resourceCulture);
@ -622,9 +640,9 @@ namespace Yavsc.Model {
}
}
public static string DoSpecifyCircles {
public static string is_licensed_by {
get {
return ResourceManager.GetString("DoSpecifyCircles", resourceCulture);
return ResourceManager.GetString("is_licensed_by", resourceCulture);
}
}
@ -646,9 +664,9 @@ namespace Yavsc.Model {
}
}
public static string younotadmin {
public static string Home {
get {
return ResourceManager.GetString("younotadmin", resourceCulture);
return ResourceManager.GetString("Home", resourceCulture);
}
}
@ -670,12 +688,6 @@ namespace Yavsc.Model {
}
}
public static string Home {
get {
return ResourceManager.GetString("Home", resourceCulture);
}
}
public static string DoTag {
get {
return ResourceManager.GetString("DoTag", resourceCulture);
@ -838,6 +850,12 @@ namespace Yavsc.Model {
}
}
public static string DoPost {
get {
return ResourceManager.GetString("DoPost", resourceCulture);
}
}
public static string entries {
get {
return ResourceManager.GetString("entries", resourceCulture);

File diff suppressed because it is too large Load diff

View file

@ -51,6 +51,7 @@
<data name="DocTemplateException"><value>Une erreur est survenue à la génération de votre document</value></data>
<data name="Description"><value>Description</value></data>
<data name="DisplayName"><value>Nom affiché</value></data>
<data name="DoPost"><value>Poster</value></data>
<data name="DoTag"><value>Tagger</value></data>
<data name="Edit"><value>Éditer</value></data>
<data name="Edited"><value>Edité</value></data>
@ -155,4 +156,6 @@
<data name="YourNeed"><value>Votre besoin</value></data>
<data name="yourquerytransmitted"><value>Votre demande a été transmise</value></data>
<data name="YourSkills"><value>Vos talents, vos spécialités, le domaine de vos activités</value></data>
<data name="YourPosts"><value>Vos posts</value></data>
<data name="YourProfile"><value>Votre profile</value></data>
</root>

View file

@ -49,6 +49,7 @@
<data name="Description"><value>Description</value></data>
<data name="DisplayName"><value>Display Name</value></data>
<data name="DoAnEstimate"><value>Do an estimate</value></data>
<data name="DoPost"><value>Do post</value></data>
<data name="DocTemplateException"><value>Exception occured when rendering your document</value></data>
<data name="DoNotPublishMyActivity"><value>Do Not Publish My Activity</value></data>
<data name="DoSpecifyCircles"><value>Please, specify circles for audiance</value></data>
@ -160,5 +161,7 @@
<data name="YourNeed"><value>Your need</value></data>
<data name="yourquerytransmitted"><value>your query has been transmitted</value></data>
<data name="YourSkills"><value>Your skills, your special fields, the scope of your activities</value></data>
<data name="YourPosts"><value>You posts</value></data>
<data name="YourProfile"><value>Your profile</value></data>
</root>

View file

@ -10,6 +10,11 @@ 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
{
@ -19,7 +24,7 @@ namespace Yavsc.Model.WorkFlow
/// It takes orders store them and raise some events for modules
/// It publishes estimates and invoices
/// </summary>
public static class WorkFlowManager
public static class WorkFlowManager
{
/// <summary>
@ -28,15 +33,15 @@ namespace Yavsc.Model.WorkFlow
/// <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)
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);
if (!activities.Contains (act))
activities.Add (act);
}
return activities.ToArray();
return activities.ToArray ();
}
/// <summary>
@ -45,7 +50,7 @@ namespace Yavsc.Model.WorkFlow
/// <returns>The performer.</returns>
/// <param name="MEACode">MEA code.</param>
/// <param name="skills">Skills.</param>
public static PerformerProfile [] FindPerformer (string MEACode, SkillRating[] skills)
public static PerformerProfile [] FindPerformer (string MEACode, SkillRating[] skills)
{
string[] usernames = SkillManager.FindPerformer (MEACode, skills);
List<PerformerProfile> result = new List<PerformerProfile> ();
@ -75,17 +80,51 @@ namespace Yavsc.Model.WorkFlow
/// </summary>
/// <returns>The command.</returns>
/// <param name="com">COM.</param>
public static long RegisterCommand(Command com)
public static long RegisterCommand (Command com)
{
long cmdid = DefaultProvider.RegisterCommand (com);
string errorMsgGCM=null;
if (com.GetType ().GetInterface ("INominative") != null) {
INominative cmdn = com as INominative;
NominativeEventPub ev = new NominativeEventPub ();
ev.PerformerName = cmdn.PerformerName;
ev.Description = com.GetDescription ();
string desc = com.GetDescription ();
ev.Description = desc;
// TODO send a location
GoogleHelpers.NotifyEvent (ev);
try {
var gnresponse = GoogleHelpers.NotifyEvent (ev);
}
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)
errorMsgGCM = "No response";
throw new Exception (errorMsgGCM);
}
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);
}
}
}
catch (Exception ex) {
errorEMail = ex.Message;
}
}
return cmdid;
}
@ -98,6 +137,7 @@ namespace Yavsc.Model.WorkFlow
{
DefaultProvider.Update (estim);
}
/// <summary>
/// Gets the estimate.
/// </summary>
@ -107,6 +147,7 @@ namespace Yavsc.Model.WorkFlow
{
return DefaultProvider.Get (estid);
}
/// <summary>
/// Gets the estimates, refering the
/// given client or username .
@ -143,7 +184,7 @@ namespace Yavsc.Model.WorkFlow
/// </summary>
/// <returns>The stock status.</returns>
/// <param name="productReference">Product reference.</param>
public static StockStatus GetStock(string productReference)
public static StockStatus GetStock (string productReference)
{
return DefaultProvider.GetStockStatus (productReference);
}
@ -165,16 +206,18 @@ namespace Yavsc.Model.WorkFlow
{
DefaultProvider.DropWritting (wrid);
}
/// <summary>
/// Drops the estimate.
/// </summary>
/// <param name="estid">Estid.</param>
public static void DropEstimate (long estid)
{
DefaultProvider.DropEstimate(estid);
DefaultProvider.DropEstimate (estid);
}
static IContentProvider defaultProvider;
/// <summary>
/// Gets the content provider.
/// </summary>
@ -188,6 +231,7 @@ namespace Yavsc.Model.WorkFlow
return defaultProvider;
}
}
/// <summary>
/// Drops the writting tag.
/// </summary>
@ -209,14 +253,14 @@ namespace Yavsc.Model.WorkFlow
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;
for (var i = 0; i < pbs.Length; i++)
providers [i] = pbs [i] as IContentProvider;
}
return providers;
}
}
private static IContentProvider [] providers = null;
private static IContentProvider[] providers = null;
/// <summary>
/// Creates the estimate.
@ -226,7 +270,7 @@ namespace Yavsc.Model.WorkFlow
/// <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)
public static Estimate CreateEstimate (string responsible, string client, string title, string description)
{
Estimate created = DefaultProvider.CreateEstimate (responsible, client, title, description);
return created;
@ -240,9 +284,9 @@ namespace Yavsc.Model.WorkFlow
/// <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)
public static long Write (long estid, string desc, decimal ucost, int count, string productid)
{
if (!string.IsNullOrWhiteSpace(productid)) {
if (!string.IsNullOrWhiteSpace (productid)) {
if (Catalog == null)
Catalog = CatalogManager.GetCatalog ();
if (Catalog == null)
@ -252,7 +296,7 @@ namespace Yavsc.Model.WorkFlow
throw new Exception ("Product not found");
// TODO new EstimateChange Event
}
return DefaultProvider.Write(estid, desc, ucost, count, productid);
return DefaultProvider.Write (estid, desc, ucost, count, productid);
}
/// <summary>
@ -261,19 +305,21 @@ namespace Yavsc.Model.WorkFlow
/// <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)
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)
public static CommandSet GetCommands (string username)
{
return DefaultProvider.GetCommands (username);
}
/// <summary>
/// Registers the activity.
/// </summary>

View file

@ -62,6 +62,12 @@
<WarningLevel>4</WarningLevel>
<TargetFrameworkVersion>v4.5.1</TargetFrameworkVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'LuaDebug|AnyCPU' ">
<Optimize>false</Optimize>
<OutputPath>bin\Lua</OutputPath>
<WarningLevel>4</WarningLevel>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.ComponentModel.DataAnnotations" />