Implemente la gestion des activités

* Activities.aspx: implémente la vue Html de la liste éditable des
  activités

* Activity.ascx: implémente la vue Html d'une activité

* NpgsqlContentProvider.cs: implemente la gestion des activités côté
  base de donnée Npgsql

* TestAPI.csproj: ... une référence au framework 4.5.1 en moins ...

* FrontOfficeController.cs: Le contrôleur du FrontOffice gére les
  activités

* Global.asax.cs: nettoyage du code

* activity.sql: Typo corrigée sur le terme "MEACode"

* style.css: enlève des images qui n'ont plus rien à faire ici, tant
  ce fichier
concerne maintenant uniquement la disposition ou les éléments de base.

* AccountController.cs: implémente le contrôle par l'utilisateur du
  paramêtre de l'activité principale
associé à son profile.

* FrontOfficeController.cs: Implemente le contrôle de la page des
  activités,
et simplifie le contrôle de la page des compétences.

* HomeController.cs: formattage du code

* ModuleController.cs: inutilisé

* App.master: Theming explicite en page maître

* Profile.aspx: Propose maintenant l'édition de l'activité
  principalement éxercée

* Skills.aspx: supprime une ligne de log

* Index.aspx: RAZ en home page

* MarkdownDeep.dll: remplace le tag englobant les transformations,
il était un "<p>", il est maintenant un "<span>".

* BlogManager.cs: refactorisation

* Activity.cs: implémente un type de commande à associer à une
  activité.

* LocalizedText.fr.resx:
* LocalizedText.Designer.cs:
* LocalizedText.fr.Designer.cs: La traduction de "ne pas publier mon
  activité"

* LocalizedText.resx: La traduction de "ne pas publier mon activité",
  et de "Votre activité"

* ManagerHelper.cs: refabrique l'instanciation des fournisseurs du
  workflow,
pour avoir une liste de toutes les activité prises en charges par tous
  les fournisseurs de contenu.

* Profile.cs: Implement le code activité de l'objet `Profile`

* ProfileEdition.cs: xmldoc

* SkillManager.cs: Formattage du code source

* IContentProvider.cs: reformattage du code+
propriété "Name" du fournisseur +
definition des methodes relatives à la gestion des activités

* WorkFlowManager.cs: Methodes de recupperation des activités fournies
  auprés des fournisseurs de contenu

* YavscModel.csproj: renommage

* Web.csproj: reference les nouveaux éléments du projet relatifs au
  activités

* Web.config: references manquante en cas d'utilisation du
  paramértrage global du thème via la section system.web/pages du
  fichier de configuration.
This commit is contained in:
2015-11-25 13:21:32 +01:00
parent f3bc91289d
commit 2fcaa1ded4
37 changed files with 827 additions and 364 deletions

View File

@ -1,3 +1,8 @@
2015-11-25 Paul Schneider <paul@pschneider.fr>
* NpgsqlContentProvider.cs: implemente la gestion des
activités côté base de donnée Npgsql
2015-11-23 Paul Schneider <paul@pschneider.fr>
* NpgsqlSkillProvider.cs: refactorisation (-Skill+SkillEntity)

View File

@ -21,7 +21,105 @@ namespace Yavsc
/// </summary>
public class NpgsqlContentProvider: ProviderBase, IContentProvider
{
/// <summary>
/// Gets the activity.
/// </summary>
/// <returns>The activity.</returns>
/// <param name="MEACode">MEA code.</param>
public Activity GetActivity (string MEACode)
{
Activity result = null;
using (NpgsqlConnection cnx = CreateConnection ()) {
cnx.Open ();
using (NpgsqlCommand cmd = cnx.CreateCommand ()) {
cmd.CommandText = @"select meacode, title, cmnt
from activity where meacode = :code and applicationname = :app";
cmd.Parameters.AddWithValue ("code", MEACode);
cmd.Parameters.AddWithValue ("app", applicationName);
using (var rdr = cmd.ExecuteReader ()) {
if (rdr.HasRows) {
rdr.Read ();
result = new Activity () {
Id = rdr.GetString (0),
Title = rdr.GetString (1),
Comment = rdr.GetString (2)
};
}
}
}
cnx.Close ();
}
return result;
}
/// <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 Activity[] FindActivity (string pattern, bool exerted)
{
List<Activity> acties = new List<Activity> ();
using (NpgsqlConnection cnx = CreateConnection ()) {
cnx.Open ();
using (NpgsqlCommand cmd = cnx.CreateCommand ()) {
cmd.CommandText = (exerted) ?
@"SELECT a.meacode, a.title, a.cmnt
FROM activity a, profiledata d, profiles p, users u
WHERE u.username = p.username
AND u.applicationname = p.applicationname
AND p.uniqueid = d.uniqueid
AND d.meacode = a.meacode
AND u.isapproved = TRUE
AND u.islockedout = FALSE
AND a.title like :pat
ORDER BY a.meacode " :
@"SELECT meacode, title, cmnt
FROM activity
WHERE title LIKE :pat
ORDER BY meacode ";
cmd.Parameters.AddWithValue ("pat", pattern);
using (var rdr = cmd.ExecuteReader ()) {
if (!rdr.HasRows)
return new Activity[0];
new List<Activity> ();
while (rdr.Read ()) {
acties.Add (new Activity () {
Id = rdr.GetString (0),
Title = rdr.GetString (1),
Comment = rdr.GetString (2)
});
}
}
}
cnx.Close ();
}
return acties.ToArray();
}
/// <summary>
/// Registers the activity.
/// </summary>
/// <param name="activity">Activity.</param>
/// <param name="code">Code.</param>
public void RegisterActivity (string activity, string code, string comment)
{
using (NpgsqlConnection cnx = CreateConnection ()) {
cnx.Open ();
using (NpgsqlCommand cmd = cnx.CreateCommand ()) {
cmd.CommandText = "insert into activity (meacode,title,applicationname,cmnt) " +
" values (:code,:title,:app,:cmt)";
cmd.Parameters.AddWithValue ("code", code);
cmd.Parameters.AddWithValue ("title", activity);
cmd.Parameters.AddWithValue ("app", applicationName);
cmd.Parameters.AddWithValue ("cmt", comment);
cmd.ExecuteNonQuery ();
}
cnx.Close ();
}
}
/// <summary>
/// Registers the command.
@ -38,8 +136,8 @@ namespace Yavsc
"insert into commandes (prdref,creation,params,clientname,applicationname) values (@pref,@creat,@prms,@cli,@app) returning id";
cmd.Parameters.AddWithValue ("@pref", com.ProductRef);
cmd.Parameters.AddWithValue ("@creat", com.CreationDate);
cmd.Parameters.AddWithValue ("@prms", JsonConvert.SerializeObject(com.Parameters));
cmd.Parameters.AddWithValue ("@cli", Membership.GetUser().UserName);
cmd.Parameters.AddWithValue ("@prms", JsonConvert.SerializeObject (com.Parameters));
cmd.Parameters.AddWithValue ("@cli", Membership.GetUser ().UserName);
cmd.Parameters.AddWithValue ("@app", ApplicationName);
cnx.Open ();
com.Id = id = (long)cmd.ExecuteScalar ();
@ -53,7 +151,7 @@ namespace Yavsc
/// </summary>
/// <returns>The commands.</returns>
/// <param name="username">Username.</param>
public CommandSet GetCommands (string username )
public CommandSet GetCommands (string username)
{
// Check the user's authorisations
MembershipUser user = Membership.GetUser ();
@ -72,13 +170,13 @@ namespace Yavsc
cnx.Open ();
using (NpgsqlDataReader rdr = cmd.ExecuteReader ()) {
while (rdr.Read ()) {
Command ycmd = new Command();
ycmd.Id = rdr.GetInt64(0);
ycmd.CreationDate = rdr.GetDateTime(1);
ycmd.ProductRef = rdr.GetString(2);
Command ycmd = new Command ();
ycmd.Id = rdr.GetInt64 (0);
ycmd.CreationDate = rdr.GetDateTime (1);
ycmd.ProductRef = rdr.GetString (2);
object prms = JsonConvert.DeserializeObject<Dictionary<string,string>>(rdr.GetString (3));
ycmd.Parameters = prms as Dictionary<string,string> ;
object prms = JsonConvert.DeserializeObject<Dictionary<string,string>> (rdr.GetString (3));
ycmd.Parameters = prms as Dictionary<string,string>;
cmds.Add (ycmd);
}
@ -109,6 +207,7 @@ namespace Yavsc
{
throw new NotImplementedException ();
}
/// <summary>
/// Gets the estimate status changes.
/// </summary>
@ -118,6 +217,7 @@ namespace Yavsc
{
throw new NotImplementedException ();
}
/// <summary>
/// Tags the writting.
/// </summary>
@ -137,6 +237,7 @@ namespace Yavsc
{
throw new NotImplementedException ();
}
/// <summary>
/// Sets the writting status.
/// </summary>
@ -147,6 +248,7 @@ namespace Yavsc
{
throw new NotImplementedException ();
}
/// <summary>
/// Sets the estimate status.
/// </summary>
@ -169,6 +271,7 @@ namespace Yavsc
{
throw new NotImplementedException ();
}
/// <summary>
/// Install the model in database using the specified cnx.
/// </summary>
@ -235,6 +338,7 @@ namespace Yavsc
return new bool[] { false, false, true, true };
}
}
/// <summary>
/// Gets the estimates created by
/// or for the given user by user name.
@ -265,11 +369,12 @@ namespace Yavsc
}
cnx.Close ();
}
foreach (long id in ids)
ests.Add(Get(id));
return ests.ToArray();
foreach (long id in ids)
ests.Add (Get (id));
return ests.ToArray ();
}
}
/// <summary>
/// Gets the estimates.
/// </summary>
@ -294,7 +399,7 @@ namespace Yavsc
if (responsible != null)
cmd.CommandText += " and ";
cmd.Parameters.AddWithValue ("@clid", client);
}
}
if (responsible != null) {
cmd.CommandText += "username = @resp";
cmd.Parameters.AddWithValue ("@resp", responsible);
@ -308,9 +413,9 @@ namespace Yavsc
}
rdr.Close ();
}
foreach (long id in ids)
ests.Add(Get(id));
return ests.ToArray();
foreach (long id in ids)
ests.Add (Get (id));
return ests.ToArray ();
}
}
}
@ -372,11 +477,11 @@ namespace Yavsc
return null;
}
est = new Estimate ();
est.Title = rdr.GetString(
rdr.GetOrdinal("title"));
est.Title = rdr.GetString (
rdr.GetOrdinal ("title"));
est.Responsible = rdr.GetString(
rdr.GetOrdinal("username"));
est.Responsible = rdr.GetString (
rdr.GetOrdinal ("username"));
int clientidx = rdr.GetOrdinal ("client");
if (!rdr.IsDBNull (clientidx))
est.Client = rdr.GetString (clientidx);
@ -390,7 +495,7 @@ namespace Yavsc
}
// assert est != null
using (NpgsqlCommand cmdw = new NpgsqlCommand ("select _id, productid, ucost, count, description from writtings where estimid = @estid", cnx)) {
cmdw.Parameters.AddWithValue("@estid", estimid);
cmdw.Parameters.AddWithValue ("@estid", estimid);
using (NpgsqlDataReader rdrw = cmdw.ExecuteReader ()) {
List<Writting> lw = null;
if (rdrw.HasRows) {
@ -402,7 +507,7 @@ namespace Yavsc
w.Description = rdrw.GetString (dei);
int opi = rdrw.GetOrdinal ("productid");
if (!rdrw.IsDBNull (opi))
w.ProductReference = rdrw.GetString(opi);
w.ProductReference = rdrw.GetString (opi);
int oco = rdrw.GetOrdinal ("count");
if (!rdrw.IsDBNull (oco))
w.Count = rdrw.GetInt32 (oco);
@ -430,11 +535,11 @@ namespace Yavsc
using (NpgsqlCommand cmd = cnx.CreateCommand ()) {
cmd.CommandText =
"update writtings set " +
"description = @desc, " +
"ucost = @ucost, " +
"count = @count, " +
"productid = @prdid " +
"where _id = @wrid";
"description = @desc, " +
"ucost = @ucost, " +
"count = @count, " +
"productid = @prdid " +
"where _id = @wrid";
cmd.Parameters.AddWithValue ("@wrid", wr.Id);
cmd.Parameters.AddWithValue ("@desc", wr.Description);
cmd.Parameters.AddWithValue ("@ucost", wr.UnitaryCost);
@ -446,7 +551,7 @@ namespace Yavsc
}
}
}
/// <summary>
/// Saves the given Estimate object in database.
/// </summary>
@ -457,7 +562,7 @@ namespace Yavsc
using (NpgsqlCommand cmd = cnx.CreateCommand ()) {
cmd.CommandText =
"update estimate set title = @tit, username = @un, " +
"description = @descr, client = @cli where _id = @estid";
"description = @descr, client = @cli where _id = @estid";
cmd.Parameters.AddWithValue ("@tit", estim.Title);
cmd.Parameters.AddWithValue ("@un", estim.Responsible);
cmd.Parameters.AddWithValue ("@descr", estim.Description);
@ -486,14 +591,14 @@ namespace Yavsc
cmd.CommandText =
"insert into writtings (description, estimid, ucost, count, productid) VALUES (@dscr,@estid,@ucost,@count,@prdid) returning _id";
cmd.Parameters.AddWithValue ("@dscr", desc);
cmd.Parameters.AddWithValue("@estid", estid);
cmd.Parameters.AddWithValue ("@estid", estid);
cmd.Parameters.AddWithValue("@ucost", ucost);
cmd.Parameters.AddWithValue("@count", count);
cmd.Parameters.AddWithValue("@prdid", productid);
cmd.Parameters.AddWithValue ("@ucost", ucost);
cmd.Parameters.AddWithValue ("@count", count);
cmd.Parameters.AddWithValue ("@prdid", productid);
cnx.Open ();
long res = (long) cmd.ExecuteScalar ();
long res = (long)cmd.ExecuteScalar ();
cnx.Close ();
return res;
}
@ -539,10 +644,10 @@ namespace Yavsc
cmd.Parameters.AddWithValue ("@un", client);
cmd.Parameters.AddWithValue ("@resp", responsible);
cmd.Parameters.AddWithValue ("@descr", description);
cmd.Parameters.AddWithValue("@app", ApplicationName);
cmd.Parameters.AddWithValue ("@app", ApplicationName);
cnx.Open ();
Estimate created = new Estimate ();
created.Id = (long) cmd.ExecuteScalar ();
created.Id = (long)cmd.ExecuteScalar ();
cnx.Close ();
created.Title = title;
created.Description = description;
@ -553,7 +658,8 @@ namespace Yavsc
}
}
string applicationName=null;
string applicationName = null;
/// <summary>
/// Gets or sets the name of the application.
/// </summary>
@ -568,6 +674,7 @@ namespace Yavsc
}
string cnxstr = null;
/// <summary>
/// Initialize this object using the specified name and config.
/// </summary>
@ -575,11 +682,11 @@ namespace Yavsc
/// <param name="config">Config.</param>
public override void Initialize (string name, NameValueCollection config)
{
if ( string.IsNullOrWhiteSpace(config ["connectionStringName"]))
if (string.IsNullOrWhiteSpace (config ["connectionStringName"]))
throw new ConfigurationErrorsException ("No name for Npgsql connection string found");
cnxstr = ConfigurationManager.ConnectionStrings [config ["connectionStringName"]].ConnectionString;
applicationName = config["applicationName"] ?? "/";
applicationName = config ["applicationName"] ?? "/";
}

View File

@ -1,3 +1,8 @@
2015-11-25 Paul Schneider <paul@pschneider.fr>
* TestAPI.csproj: ... une référence au framework 4.5.1 en
moins ...
2015-11-19 Paul Schneider <paul@pschneider.fr>
* TestAPI.csproj: adds a build target named "Lua"

View File

@ -20,7 +20,6 @@
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<ConsolePause>false</ConsolePause>
<TargetFrameworkVersion>v4.5.1</TargetFrameworkVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>full</DebugType>
@ -29,7 +28,6 @@
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<ConsolePause>false</ConsolePause>
<TargetFrameworkVersion>v4.5.1</TargetFrameworkVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Lua|AnyCPU' ">
<Optimize>false</Optimize>

View File

@ -25,6 +25,27 @@ namespace Yavsc.ApiControllers
/// </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.
@ -58,7 +79,7 @@ namespace Yavsc.ApiControllers
[HttpGet]
public Estimate GetEstimate (long id)
{
Estimate est = WorkFlowManager.ContentProvider.Get (id);
Estimate est = WorkFlowManager.DefaultProvider.Get (id);
string username = Membership.GetUser ().UserName;
if (est.Client != username)
if (!Roles.IsUserInRole("Admin"))

View File

@ -19,7 +19,7 @@ namespace Yavsc
/// <summary>
/// Mvc application.
/// </summary>
public class MvcApplication : System.Web.HttpApplication
public class MvcApplication : HttpApplication
{
/// <summary>

View File

@ -4,17 +4,20 @@
CREATE TABLE activity
(
"MAECode" character varying(512) NOT NULL, -- Identifiant de l'activité, à terme, il faudrait ajouter un champ à cette id: le code pays....
meacode character varying(512) NOT NULL, -- Identifiant de l'activité, à terme, il faudrait ajouter un champ à cette id: le code pays....
title character varying(2048) NOT NULL, -- Description textuelle du code APE
applicationname character varying(255) NOT NULL,
CONSTRAINT activity_pkey PRIMARY KEY ("MAECode", applicationname)
cmnt character varying, -- a long description for this activity
CONSTRAINT activity_pkey PRIMARY KEY (meacode, applicationname)
)
WITH (
OIDS=FALSE
);
ALTER TABLE activity
OWNER TO yavscdev;
COMMENT ON TABLE activity
IS 'Activités prises en charge par l''application désignée';
COMMENT ON COLUMN activity."MAECode" IS 'Identifiant de l''activité, à terme, il faudrait ajouter un champ à cette id: le code pays.
COMMENT ON COLUMN activity.meacode IS 'Identifiant de l''activité, à terme, il faudrait ajouter un champ à cette id: le code pays.
Definition francaise:
un code NACE sur les quatre première lettre (code européen),
@ -23,5 +26,5 @@ une lettre en cinquième position.
Exemple: ''71.12B'' => "Ingénierie, études techniques"
';
COMMENT ON COLUMN activity.title IS 'Description textuelle du code APE';
COMMENT ON COLUMN activity.cmnt IS 'a long description for this activity';

View File

@ -55,8 +55,7 @@ main video, main img {
footer {
transition: margin 2s, padding 2s;
margin: 0;
margin-top: 2em;
margin: 2em;
padding: 2em;
display: block;
clear: both;
@ -342,7 +341,6 @@ ul.editablelist>li:hover:before {
header {
padding-top:1em;
padding-bottom:1em;
background: url("/App_Themes/images/star-939235_1280.s.jpg") 0 0 no-repeat fixed;
}
#avatar {
@ -354,15 +352,14 @@ header h1, header a , .actionlink, .menuitem, a { padding:.5em;}
nav {
margin: 1em;
padding: 1em;
background: url("/App_Themes/images/helix-nebula-1400x1400.s.jpg") 50% 10% repeat fixed ;
}
main {
margin: 1em;
padding: 1em;
background: url("/App_Themes/images/p8-av4.s.jpg") 50% 20em no-repeat fixed ;
}
footer {
background: url("/App_Themes/images/helix-nebula-1400x1400.s.jpg") 50% 90% repeat fixed ;
margin: 1em;
padding: 1em;
}
footer a {
border-radius:.5em;
@ -400,7 +397,6 @@ header h1, header a , .actionlink, .menuitem, a { padding:.5em;}
header {
padding-top:.5em;
padding-bottom:.5em;
background: url("/App_Themes/images/star-939235_1280.xxs.jpg") 0 0 no-repeat fixed;
}
header h1, header a { padding:.2em;}
@ -408,15 +404,14 @@ header h1, header a { padding:.2em;}
nav {
margin: .5em;
padding: .5em;
background: url("/App_Themes/images/helix-nebula-1400x1400.xxs.jpg") 50% 10% repeat fixed ;
}
main {
margin: .5em;
padding: .5em;
background: url("/App_Themes/images/p8-av4.xxs.jpg") 50% 20em repeat fixed ;
}
footer {
background: url("/App_Themes/images/helix-nebula-1400x1400.xxs.jpg") 50% 10% repeat fixed ;
margin: .5em;
padding: .5em;
}
footer a {
border-radius:.2em;

View File

@ -1,3 +1,56 @@
2015-11-25 Paul Schneider <paul@pschneider.fr>
* Activities.aspx: implémente la vue Html de la liste éditable
des activités
* Activity.ascx: implémente la vue Html d'une activité
* FrontOfficeController.cs: Le contrôleur du FrontOffice gére
les activités
* Global.asax.cs: nettoyage du code
* activity.sql: Typo corrigée sur le terme "MEACode"
* style.css: enlève des images qui n'ont plus rien à faire
ici, tant ce fichier
concerne maintenant uniquement la disposition ou les éléments
de base.
* AccountController.cs: implémente le contrôle par
l'utilisateur du paramêtre de l'activité principale
associé à son profile.
* FrontOfficeController.cs: Implemente le contrôle de la page
des activités,
et simplifie le contrôle de la page des compétences.
* HomeController.cs: formattage du code
* ModuleController.cs: inutilisé
* App.master: Theming explicite en page maître
* Profile.aspx: Propose maintenant l'édition de l'activité
principalement éxercée
* Skills.aspx: supprime une ligne de log
* Index.aspx: RAZ en home page
* MarkdownDeep.dll: remplace le tag englobant les
transformations,
il était un "<p>", il est maintenant un "<span>".
* Web.csproj: reference les nouveaux éléments du projet
relatifs au activités
* Web.config: references manquante en cas d'utilisation du
paramértrage global du thème via la section system.web/pages
du fichier de configuration.
2015-11-23 Paul Schneider <paul@pschneider.fr>
* activity.sql: definit les activités en base de données.

View File

@ -17,6 +17,7 @@ using System.Text;
using System.Net;
using System.Configuration;
using Yavsc.Model;
using Yavsc.Model.WorkFlow;
namespace Yavsc.Controllers
{
@ -251,11 +252,24 @@ namespace Yavsc.Controllers
if (id == null)
id = Membership.GetUser ().UserName;
ViewData ["UserName"] = id;
ProfileEdition model = new ProfileEdition (ProfileBase.Create (id));
model.RememberMe = FormsAuthentication.GetAuthCookie (id, true) == null;
SetMEACodeViewData (model);
return View (model);
}
private void SetMEACodeViewData(Profile model) {
var activities = WorkFlowManager.FindActivity ("%", false);
var items = new List<SelectListItem> ();
items.Add (new SelectListItem () { Selected = model.MEACode == null, Text = LocalizedText.DoNotPublishMyActivity, Value=null });
foreach (var a in activities) {
items.Add(new SelectListItem() { Selected = model.MEACode == a.Id,
Text = string.Format("{1} : {0}",a.Title,a.Id),
Value = a.Id });
}
ViewData ["MEACode"] = items;
}
/// <summary>
@ -336,6 +350,7 @@ namespace Yavsc.Controllers
prf.SetPropertyValue ("BankedKey", model.BankedKey);
prf.SetPropertyValue ("gcalid", model.GoogleCalendar);
prf.SetPropertyValue ("UITheme", model.UITheme);
prf.SetPropertyValue ("MEACode", model.MEACode);
prf.Save ();
if (editsTheUserName) {
@ -345,6 +360,7 @@ namespace Yavsc.Controllers
}
YavscHelpers.Notify(ViewData, "Profile enregistré"+((editsTheUserName)?", nom public inclu.":""));
}
SetMEACodeViewData (model);
return View (model);
}
/// <summary>

View File

@ -266,6 +266,18 @@ namespace Yavsc.Controllers
return View (skills);
}
public ActionResult Activities (string search, bool toPower = false)
{
if (search == null)
search = "%";
var activities = WorkFlowManager.FindActivity(search,!toPower);
return View (activities);
}
public ActionResult Activity(string id)
{
return View(WorkFlowManager.GetActivity (id));
}
/// <summary>
/// Display and should
/// offer Ajax edition of
@ -273,20 +285,16 @@ namespace Yavsc.Controllers
/// </summary>
/// <param name="usp">the User Skills Profile.</param>
[Authorize()]
public ActionResult UserSkills (PerformerProfile usp)
public ActionResult UserSkills (string id)
{
if (usp.UserName == null)
// this is not a call to update,
// and this can not concern another user
// than the current logged one.
usp = new PerformerProfile( User.Identity.Name );
// if (usp.UserName was null) {
usp = SkillManager.GetUserSkills (usp.UserName);
if (id == null)
id = User.Identity.Name ;
// TODO or not to do, handle a skills profile update,
// actually performed via the Web API :-°
// else if (ModelState.IsValid) {}
var usp = SkillManager.GetUserSkills (id);
var skills = SkillManager.FindSkill ("%");
ViewData ["SiteSkills"] = skills;
// TODO or not to do, handle a skills profile update,
// actually performed via the Web API :-°
// } else if (ModelState.IsValid) {}
return View (usp);
}

View File

@ -91,6 +91,7 @@ namespace Yavsc.Controllers
// TODO specialyze BlogEntry creating a PhotoEntry
ViewData [tagname] = ti;
}
return View ();
}
/// <summary>

View File

@ -1,36 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Yavsc.Model;
using System.Configuration;
namespace Yavsc.Controllers
{
/// <summary>
/// Module controller.
/// </summary>
public class ModuleController : Controller
{
/// <summary>
/// Initialize the specified requestContext.
/// </summary>
/// <param name="requestContext">Request context.</param>
protected override void Initialize (System.Web.Routing.RequestContext requestContext)
{
base.Initialize (requestContext);
ConfigurationManager.GetSection ("ymodules");
}
// List<IModule> modules = new List<IModule> ();
/// <summary>
/// Index this instance.
/// </summary>
public ActionResult Index()
{
return View ();
}
}
}

View File

@ -1,4 +1,4 @@
<%@ Master Language="C#" Inherits="System.Web.Mvc.ViewMasterPage" %>
<%@ Master Language="C#" Inherits="System.Web.Mvc.ViewMasterPage" EnableTheming="true"%>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<% ViewState["orgtitle"] = Html.Translate(Page.Title); %>

View File

@ -5,26 +5,19 @@
</asp:Content>
<asp:Content ID="MainContentContent" ContentPlaceHolderID="MainContent" runat="server">
<style>
table.layout { border-width: 0; }
table.layout TR TD { max-width:40%; }
</style>
<% if (Roles.IsUserInRole((string)ViewData ["UserName"],"Admin")) {
// TODO View all roles
%><aside>This user is Admin.</aside>
<% } %>
<aside>
<%= Html.ActionLink("Changer de mot de passe","ChangePassword", "Account",null, new { @class="actionlink" })%>
<%= Html.ActionLink("Désincription", "Unregister", "Account", new { id = ViewData["UserName"] } , new { @class="actionlink" })%>
</aside>
<aside>
<% if (Roles.IsUserInRole((string)ViewData ["UserName"],"Admin")) {
// TODO View all roles
%>
This user is Admin.
<% } %>
<code>HasBankAccount:<%= Model.HasBankAccount %></code>
<code>Compte bancaire:<%= Model.HasBankAccount %></code>
<% if (!Model.HasBankAccount) { %><span class="hint">
IBAN+BIC ou Codes banque, guichet, compte et clé RIB</span>
<% } %>, <code>IsBillable:<%=Model.IsBillable%></code>
<% } %>, <code>Adressable:<%=Model.IsBillable%></code>
<% if (!Model.IsBillable) { %>
<span class="hint">un nom et au choix, une adresse postale valide,
ou un téléphone, ou un email, ou un Mobile</span> <% } %>
@ -37,7 +30,10 @@ table.layout TR TD { max-width:40%; }
<%= Html.Hidden("UserName",ViewData["ProfileUserName"]) %>
<fieldset><legend>Informations publiques</legend>
<%= Html.LabelFor(model => model.MEACode) %> :
<%= Html.DropDownList("MEACode") %>
<%= Html.ValidationMessage("MEACode", "*") %>
<br>
<%= Html.LabelFor(model => model.NewUserName) %> :
<%= Html.TextBox("NewUserName") %>
@ -54,12 +50,15 @@ Avatar : <img src="<%=Url.AvatarUrl(HttpContext.Current.User.Identity.Name)%>" a
<input type="file" id="AvatarFile" name="AvatarFile"/>
<%= Html.ValidationMessage("AvatarFile", "*") %>
</fieldset>
<fieldset><legend>Informations administratives</legend>
<%= Html.LabelFor(model => model.Name) %> :
<%= Html.TextBox("Name") %>
<%= Html.ValidationMessage("Name", "*") %>
</fieldset>
<fieldset><legend>Blog</legend>
<div class="spanel">
<%= Html.LabelFor(model => model.BlogVisible) %> :

View File

@ -0,0 +1,43 @@
<%@ Page Language="C#" MasterPageFile="~/Models/App.master" Inherits="System.Web.Mvc.ViewPage<IEnumerable<Activity>>" %>
<asp:Content ID="headContent" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="MainContentContent" ContentPlaceHolderID="MainContent" runat="server">
<div id="activities">
<% foreach (var a in Model) { %>
<%= Html.Partial("Activity",a) %>
<% } %>
<aside class="control">
<form method="post" action="DeclareActivity">
<fieldset>
<input type="text" name="meacode" id="meacode" >
<input type="text" name="activityname" id="activityname" >
<input type="text" name="comment" id="comment" >
<input type="button" value="Créer l'activité" id="btncreate" >
</fieldset>
</form>
<script type="text/javascript">
$(document).ready(function () {
$('#btncreate').click( function() {
var activity = {
Title: $('#activityname').val(),
Id: $('#meacode').val(),
Comment: $('#comment').val(),
};
console.log(Yavsc.dumpprops(activity));
Yavsc.ajax( 'FrontOffice/RegisterActivity', activity,
function() {
var na = $('<p></p>').addClass('activity');
$.get('FrontOffice/Activity/'+activity.meacode, function(data) {
na.replaceWith(data);
$('#activityname').val('');
$('#meacode').val('');
$('#comment').val('');
na.appendTo('#activities');
});
}); } ); });
</script>
</aside>
</div>
</asp:Content>

View File

@ -0,0 +1,9 @@
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<Activity>" %>
<h1 class="activity">
<%=Html.Icon("act"+Model.Id)%>
<%=Html.Markdown(Model.Title)%></h1>
<i>(<%=Html.Markdown(Model.Id)%>)</i>
<p>
<%=Html.Markdown(Model.Comment)%>
</p>

View File

@ -23,7 +23,6 @@
$('#btncreate').click( function() {
var $sname = $('#SkillName').val();
Skills.createSkill($sname, function(sid) {
console.log(' Skill created id : '+sid);
$('<li>'+$sname+'</li>').data('sid',sid).addClass('skillname').appendTo('#skills');
$('#SkillName').val('');
}); } ); });

View File

@ -9,8 +9,5 @@
<asp:Content ContentPlaceHolderID="MainContent" ID="MainContentContent" runat="server">
<%= Html.Partial("TagPanel",ViewData["Accueil"]) %>
<%= Html.Partial("TagPanel",ViewData["Yavsc"]) %>
<%= Html.Partial("TagPanel",ViewData["Événements"]) %>
<%= Html.Partial("TagPanel",ViewData["Mentions légales"]) %>
</asp:Content>

View File

@ -49,6 +49,10 @@ http://msdn2.microsoft.com/en-us/library/b5ysx397.aspx
<add assembly="System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
<add assembly="System.Web.WebPages.Razor, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
<add assembly="nunit.framework, Version=2.6.3.0, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77" />
<add assembly="EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<add assembly="System.IdentityModel.Selectors, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<add assembly="System.Web.WebPages.Deployment, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
<add assembly="Microsoft.Web.Infrastructure, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
</assemblies>
</compilation>
<customErrors mode="Off">

View File

@ -105,6 +105,13 @@
<Reference Include="Microsoft.Web.XmlTransform">
<HintPath>..\packages\Mono.Web.Xdt.1.0.0\lib\Net40\Microsoft.Web.XmlTransform.dll</HintPath>
</Reference>
<Reference Include="EntityFramework" />
<Reference Include="System.Data.Entity" />
<Reference Include="System.IdentityModel.Selectors" />
<Reference Include="System.IdentityModel" />
<Reference Include="System.Web.DynamicData" />
<Reference Include="System.Web.WebPages.Deployment" />
<Reference Include="Microsoft.Web.Infrastructure" />
</ItemGroup>
<ItemGroup>
<Folder Include="Admin\" />
@ -141,9 +148,9 @@
<Folder Include="Views\Admin\" />
<Folder Include="Views\BackOffice\" />
<Folder Include="Views\PayPal\" />
<Folder Include="Views\Modules\" />
<Folder Include="xmldoc\" />
<Folder Include="App_Code\" />
<Folder Include="App_Themes\base\" />
</ItemGroup>
<ItemGroup>
<Compile Include="Controllers\HomeController.cs" />
@ -167,7 +174,6 @@
<Compile Include="Formatters\SimpleFormatter.cs" />
<Compile Include="ValidateAjaxAttribute.cs" />
<Compile Include="Controllers\GoogleController.cs" />
<Compile Include="Controllers\ModuleController.cs" />
<Compile Include="Settings\ThanksConfigurationSection.cs" />
<Compile Include="Settings\ThanksConfigurationCollection.cs" />
<Compile Include="Settings\ThanksConfigurationElement.cs" />
@ -510,6 +516,8 @@
<Content Include="Views\FrontOffice\EavyBooking.aspx" />
<Content Include="App_Themes\blue\style.tablesorter.css" />
<Content Include="App_Themes\clear\style.css" />
<Content Include="Views\FrontOffice\Activities.aspx" />
<Content Include="Views\FrontOffice\Activity.ascx" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<Import Project="$(MSBuildExtensionsPath)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" />

Binary file not shown.

View File

@ -22,7 +22,7 @@ namespace Yavsc.Model.Blogs
static BlogProvider Provider {
get {
if (provider == null)
provider = ManagerHelper.GetDefaultProvider<BlogProvider>
provider = ManagerHelper.CreateDefaultProvider<BlogProvider>
("system.web/blog");
return provider;
}

View File

@ -1,3 +1,40 @@
2015-11-25 Paul Schneider <paul@pschneider.fr>
* BlogManager.cs: refactorisation
* Activity.cs: implémente un type de commande à associer à une
activité.
* LocalizedText.fr.resx:
* LocalizedText.Designer.cs:
* LocalizedText.fr.Designer.cs: La traduction de "ne pas
publier mon activité"
* LocalizedText.resx: La traduction de "ne pas publier mon
activité", et de "Votre activité"
* ManagerHelper.cs: refabrique l'instanciation des
fournisseurs du workflow,
pour avoir une liste de toutes les activité prises en charges
par tous les fournisseurs de contenu.
* Profile.cs: Implement le code activité de l'objet `Profile`
* ProfileEdition.cs: xmldoc
* SkillManager.cs: Formattage du code source
* IContentProvider.cs: reformattage du code+
propriété "Name" du fournisseur +
definition des methodes relatives à la gestion des activités
* WorkFlowManager.cs: Methodes de recupperation des activités
fournies auprés des fournisseurs de contenu
* YavscModel.csproj: renommage
2015-11-23 Paul Schneider <paul@pschneider.fr>
* Estimate.cs:

View File

@ -22,9 +22,16 @@ using System;
namespace Yavsc.Model.FrontOffice
{
/// <summary>
/// Activity.
/// </summary>
public class Activity: IComment<string>, ITitle
{
#region ITitle implementation
/// <summary>
/// Gets or sets the title.
/// </summary>
/// <value>The title.</value>
public string Title {
get;
set;
@ -32,18 +39,55 @@ namespace Yavsc.Model.FrontOffice
#endregion
#region IComment implementation
/// <summary>
/// Gets or sets the comment.
/// </summary>
/// <value>The comment.</value>
public string Comment {
get;
set;
}
#endregion
#region IIdentified implementation
/// <summary>
/// Gets or sets the identifier.
/// </summary>
/// <value>The identifier.</value>
public string Id {
get;
set;
}
#endregion
/// <summary>
/// Gets or sets the type of the command.
/// </summary>
/// <value>The type of the command.</value>
public Type CommandType {
get;
set;
}
/// <summary>
/// The activity object has a static value during the
/// most of the application life,
/// They are not supposed to vary, they should are legal values.
/// As a result, they are identified by their identifier,
/// and are said equal since their id are equal.
/// Determines whether the specified <see cref="System.Object"/> is equal to the current <see cref="Yavsc.Model.FrontOffice.Activity"/>.
/// </summary>
/// <param name="obj">The <see cref="System.Object"/> to compare with the current <see cref="Yavsc.Model.FrontOffice.Activity"/>.</param>
/// <returns><c>true</c> if the specified <see cref="System.Object"/> is equal to the current
/// <see cref="Yavsc.Model.FrontOffice.Activity"/>; otherwise, <c>false</c>.</returns>
public override bool Equals (object obj)
{
if (base.Equals (obj))
return true;
if (obj == null)
return false;
if (GetType().IsAssignableFrom(obj.GetType()))
if (((Activity)obj).Id == this.Id)
return true;
return false;
}
}
}

View File

@ -58,9 +58,9 @@ namespace Yavsc.Model {
}
}
public static string ProviderId {
public static string I_understood {
get {
return ResourceManager.GetString("ProviderId", resourceCulture);
return ResourceManager.GetString("I_understood", resourceCulture);
}
}
@ -70,9 +70,9 @@ namespace Yavsc.Model {
}
}
public static string Circles {
public static string access_denied {
get {
return ResourceManager.GetString("Circles", resourceCulture);
return ResourceManager.GetString("access_denied", resourceCulture);
}
}
@ -94,15 +94,15 @@ namespace Yavsc.Model {
}
}
public static string none {
public static string Circles {
get {
return ResourceManager.GetString("none", resourceCulture);
return ResourceManager.GetString("Circles", resourceCulture);
}
}
public static string ProviderName {
public static string My_Estimates {
get {
return ResourceManager.GetString("ProviderName", resourceCulture);
return ResourceManager.GetString("My_Estimates", resourceCulture);
}
}
@ -178,9 +178,9 @@ namespace Yavsc.Model {
}
}
public static string access_denied {
public static string ProviderName {
get {
return ResourceManager.GetString("access_denied", resourceCulture);
return ResourceManager.GetString("ProviderName", resourceCulture);
}
}
@ -208,6 +208,12 @@ namespace Yavsc.Model {
}
}
public static string none {
get {
return ResourceManager.GetString("none", resourceCulture);
}
}
public static string entries {
get {
return ResourceManager.GetString("entries", resourceCulture);
@ -250,12 +256,24 @@ namespace Yavsc.Model {
}
}
public static string Remove {
get {
return ResourceManager.GetString("Remove", resourceCulture);
}
}
public static string Title {
get {
return ResourceManager.GetString("Title", resourceCulture);
}
}
public static string DoNotPublishMyActivity {
get {
return ResourceManager.GetString("DoNotPublishMyActivity", resourceCulture);
}
}
public static string Tex_version {
get {
return ResourceManager.GetString("Tex_version", resourceCulture);
@ -310,12 +328,6 @@ namespace Yavsc.Model {
}
}
public static string My_Estimates {
get {
return ResourceManager.GetString("My_Estimates", resourceCulture);
}
}
public static string Location {
get {
return ResourceManager.GetString("Location", resourceCulture);
@ -328,12 +340,6 @@ namespace Yavsc.Model {
}
}
public static string I_understood {
get {
return ResourceManager.GetString("I_understood", resourceCulture);
}
}
public static string Bill_removal {
get {
return ResourceManager.GetString("Bill_removal", resourceCulture);
@ -352,15 +358,15 @@ namespace Yavsc.Model {
}
}
public static string Remove {
public static string MEACode {
get {
return ResourceManager.GetString("Remove", resourceCulture);
return ResourceManager.GetString("MEACode", resourceCulture);
}
}
public static string AnIMessageHasbeenSent {
public static string DoTag {
get {
return ResourceManager.GetString("AnIMessageHasbeenSent", resourceCulture);
return ResourceManager.GetString("DoTag", resourceCulture);
}
}
@ -442,6 +448,12 @@ namespace Yavsc.Model {
}
}
public static string ProviderId {
get {
return ResourceManager.GetString("ProviderId", resourceCulture);
}
}
public static string Role {
get {
return ResourceManager.GetString("Role", resourceCulture);
@ -508,9 +520,9 @@ namespace Yavsc.Model {
}
}
public static string DoTag {
public static string Hide_source {
get {
return ResourceManager.GetString("DoTag", resourceCulture);
return ResourceManager.GetString("Hide_source", resourceCulture);
}
}
@ -574,12 +586,6 @@ namespace Yavsc.Model {
}
}
public static string Hide_source {
get {
return ResourceManager.GetString("Hide_source", resourceCulture);
}
}
public static string UsersInRole {
get {
return ResourceManager.GetString("UsersInRole", resourceCulture);
@ -592,6 +598,12 @@ namespace Yavsc.Model {
}
}
public static string AnIMessageHasbeenSent {
get {
return ResourceManager.GetString("AnIMessageHasbeenSent", resourceCulture);
}
}
public static string Profile_edition {
get {
return ResourceManager.GetString("Profile_edition", resourceCulture);

View File

@ -58,9 +58,9 @@ namespace Yavsc.Model {
}
}
public static string ProviderId {
public static string I_understood {
get {
return ResourceManager.GetString("ProviderId", resourceCulture);
return ResourceManager.GetString("I_understood", resourceCulture);
}
}
@ -94,9 +94,9 @@ namespace Yavsc.Model {
}
}
public static string ProviderName {
public static string My_Estimates {
get {
return ResourceManager.GetString("ProviderName", resourceCulture);
return ResourceManager.GetString("My_Estimates", resourceCulture);
}
}
@ -172,6 +172,12 @@ namespace Yavsc.Model {
}
}
public static string ProviderName {
get {
return ResourceManager.GetString("ProviderName", resourceCulture);
}
}
public static string access_denied {
get {
return ResourceManager.GetString("access_denied", resourceCulture);
@ -244,12 +250,24 @@ namespace Yavsc.Model {
}
}
public static string Remove {
get {
return ResourceManager.GetString("Remove", resourceCulture);
}
}
public static string Title {
get {
return ResourceManager.GetString("Title", resourceCulture);
}
}
public static string DoNotPublishMyActivity {
get {
return ResourceManager.GetString("DoNotPublishMyActivity", resourceCulture);
}
}
public static string Tex_version {
get {
return ResourceManager.GetString("Tex_version", resourceCulture);
@ -298,12 +316,6 @@ namespace Yavsc.Model {
}
}
public static string My_Estimates {
get {
return ResourceManager.GetString("My_Estimates", resourceCulture);
}
}
public static string Location {
get {
return ResourceManager.GetString("Location", resourceCulture);
@ -316,12 +328,6 @@ namespace Yavsc.Model {
}
}
public static string I_understood {
get {
return ResourceManager.GetString("I_understood", resourceCulture);
}
}
public static string Bill_removal {
get {
return ResourceManager.GetString("Bill_removal", resourceCulture);
@ -334,9 +340,9 @@ namespace Yavsc.Model {
}
}
public static string Remove {
public static string MEACode {
get {
return ResourceManager.GetString("Remove", resourceCulture);
return ResourceManager.GetString("MEACode", resourceCulture);
}
}
@ -424,6 +430,12 @@ namespace Yavsc.Model {
}
}
public static string ProviderId {
get {
return ResourceManager.GetString("ProviderId", resourceCulture);
}
}
public static string Role {
get {
return ResourceManager.GetString("Role", resourceCulture);

View File

@ -28,6 +28,7 @@
<data name="Comment"><value>Commentaire</value></data>
<data name="DB"><value>Base de données</value></data>
<data name="DoComment"><value>Commenter</value></data>
<data name="DoNotPublishMyActivity"><value>Ne pas publier mon activité</value></data>
<data name="Create"><value>Créer</value></data>
<data name="Date_search"><value>Demande de rendez-vous</value></data>
<data name="DocTemplateException"><value>Une erreur est survenue à la génération de votre document</value></data>
@ -55,6 +56,7 @@
<data name="Location"><value>Lieu</value></data>
<data name="Logout"><value>Déconnection</value></data>
<data name="MaxDate"><value>Date maximale du rendez-vous</value></data>
<data name="MEACode"><value>Votre activité</value></data>
<data name="Members"><value>Membres</value></data>
<data name="Message_sent"><value>Votre message a été envoyé</value></data>
<data name="MinDate"><value>Date minimale du rendez-vous</value></data>

View File

@ -34,6 +34,7 @@
<data name="Description"><value>Description</value></data>
<data name="DisplayName"><value>Display Name</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="DoTag"><value>Tag</value></data>
<data name="DuplicateEmail"><value>This email adress is already used ({0}).</value></data>
<data name="DuplicateUserName"><value>This user name is already used ({0}).</value></data>
@ -58,6 +59,7 @@
<data name="Location"><value>Location</value></data>
<data name="Logout"><value>Logout</value></data>
<data name="MaxDate"><value>Maximal date for the rendez-vous</value></data>
<data name="MEACode"><value>Mainly Exerted Activity</value></data>
<data name="Members"><value>Members</value></data>
<data name="Message_sent"><value>Your message has been sent.</value></data>
<data name="MinDate"><value>Minimal date for the rendez-vous</value></data>
@ -111,4 +113,5 @@
{0} should be available for this booking</value></data>
<data name="younotadmin"><value>You're not administrator</value></data>
<data name="yourquerytransmitted"><value>your query has been transmitted</value></data>
</root>

View File

@ -1,68 +0,0 @@
//
// Manager.cs
//
// Author:
// Paul Schneider <paul@pschneider.fr>
//
// Copyright (c) 2015 GNU GPL
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
using System;
using System.Configuration;
using System.Reflection;
using System.Configuration.Provider;
namespace Yavsc.Model {
/// <summary>
/// Manager.
/// </summary>
public static class ManagerHelper {
/// <summary>
/// Gets the provider.
/// </summary>
/// <value>The provider.</value>
public static TProvider GetDefaultProvider<TProvider> (string configSetion) where TProvider: ProviderBase
{
DataProviderConfigurationSection config = ConfigurationManager.GetSection (configSetion) as DataProviderConfigurationSection;
if (config == null)
throw new ConfigurationErrorsException (
string.Format(
"The providers configuration bloc `{0}` was not found",
configSetion));
ProviderSettings celt =
config.Providers [config.DefaultProvider];
if (config == null)
throw new ConfigurationErrorsException (
string.Format (
"The default provider `{0}` was not found ",
config.DefaultProvider));
Type provtype = Type.GetType (celt.Type);
if (provtype == null)
throw new ProviderException (
string.Format (
"Provider type '{0}' was not found",celt.Type));
ConstructorInfo ci = provtype.GetConstructor (Type.EmptyTypes);
ProviderBase bp = ci.Invoke (Type.EmptyTypes) as ProviderBase;
bp.Initialize (celt.Name, celt.Parameters);
return bp as TProvider;
}
public static ProviderBase GetDefaultProvider (string configSetion)
{
return GetDefaultProvider<ProviderBase>(configSetion);
}
}
}

109
yavscModel/ManagerHelper.cs Normal file
View File

@ -0,0 +1,109 @@
//
// Manager.cs
//
// Author:
// Paul Schneider <paul@pschneider.fr>
//
// Copyright (c) 2015 GNU GPL
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
using System;
using System.Configuration;
using System.Reflection;
using System.Configuration.Provider;
using System.Collections.Specialized;
using System.Linq;
using System.Collections.Generic;
namespace Yavsc.Model {
/// <summary>
/// Manager.
/// </summary>
public static class ManagerHelper {
/// <summary>
/// Gets the provider.
/// </summary>
/// <value>The provider.</value>
public static TProvider CreateDefaultProvider<TProvider> (string configSetion) where TProvider: ProviderBase
{
var config = GetConfiguration (configSetion);
ProviderSettings celt =
config.Providers [config.DefaultProvider];
return CreateProvider<TProvider> (celt.Type, celt.Name, celt.Parameters);
}
/// <summary>
/// Creates the providers.
/// </summary>
/// <returns>The providers.</returns>
/// <param name="configSetion">Config setion.</param>
/// <typeparam name="TProvider">The 1st type parameter.</typeparam>
public static TProvider [] CreateProviders<TProvider> (string configSetion) where TProvider: ProviderBase
{
var config = GetConfiguration (configSetion);
List<TProvider> providers = new List<TProvider> ();
foreach (ProviderSettings provConfig in config.Providers) {
var prov = CreateProvider<TProvider>
(provConfig.Type, provConfig.Name, provConfig.Parameters);
providers.Add (prov);
}
return providers.ToArray ();
}
private static DataProviderConfigurationSection GetConfiguration(string configSetion) {
DataProviderConfigurationSection config = ConfigurationManager.GetSection (configSetion) as DataProviderConfigurationSection;
if (config == null)
throw new ConfigurationErrorsException (
string.Format(
"The providers configuration bloc `{0}` was not found",
configSetion));
return config;
}
private static TProvider CreateProvider<TProvider>(string type, string name,
NameValueCollection config) where TProvider: ProviderBase {
Type provtype = Type.GetType (type);
if (provtype == null)
throw new ProviderException (
string.Format (
"Provider type '{0}' was not found",type));
ConstructorInfo ci = provtype.GetConstructor (Type.EmptyTypes);
TProvider bp = ci.Invoke (Type.EmptyTypes) as TProvider;
bp.Initialize (name, config);
return bp;
}
/// <summary>
/// Gets the default provider.
/// </summary>
/// <returns>The default provider.</returns>
/// <param name="configSetion">Config setion.</param>
public static ProviderBase CreateDefaultProvider (string configSetion)
{
return CreateDefaultProvider<ProviderBase>(configSetion);
}
/// <summary>
/// Creates the providers.
/// </summary>
/// <returns>The providers.</returns>
/// <param name="configSetion">Config setion.</param>
public static ProviderBase[] CreateProviders (string configSetion)
{
return CreateProviders<ProviderBase>(configSetion);
}
}
}

View File

@ -5,6 +5,9 @@ using System.Web.Profile;
using System.Web.Security;
using System.Web;
using System.Configuration;
using System.Collections.Generic;
using System.Web.Mvc;
using Yavsc.Model.WorkFlow;
namespace Yavsc.Model.RolesAndMembers
{
@ -269,9 +272,21 @@ namespace Yavsc.Model.RolesAndMembers
BIC = (string)profile.GetPropertyValue ("BIC");
WicketCode = (string) profile.GetPropertyValue ("WicketCode");
AccountNumber = (string) profile.GetPropertyValue ("AccountNumber");
BankedKey = (int) profile.GetPropertyValue ("BankedKey");;
BankedKey = (int) profile.GetPropertyValue ("BankedKey");
GoogleCalendar = (string) profile.GetPropertyValue ("gcalid");
MEACode = (string) profile.GetPropertyValue ("MEACode");
}
/// <summary>
/// Gets or sets the MEA code.
/// </summary>
/// <value>The MEA code.</value>
[Localizable(true), Required(ErrorMessage = "S'il vous plait, entrez un code APE valide")
,Display(ResourceType=typeof(LocalizedText),Name="MEACode"),
RegularExpression(@"[a-zA-Z0-9 \-_.~/\\]+")
]
public string MEACode { get; set; }
}
}

View File

@ -22,6 +22,9 @@ using System;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.Web.Profile;
using System.Collections.Generic;
using System.Web.Mvc;
using Yavsc.Model.WorkFlow;
namespace Yavsc.Model.RolesAndMembers
{
@ -36,7 +39,10 @@ namespace Yavsc.Model.RolesAndMembers
public ProfileEdition()
{}
/// <summary>
/// Initializes a new instance of the <see cref="Yavsc.Model.RolesAndMembers.ProfileEdition"/> class.
/// </summary>
/// <param name="pr">Pr.</param>
public ProfileEdition(ProfileBase pr): base(pr)
{
NewUserName = UserName;
@ -51,6 +57,9 @@ namespace Yavsc.Model.RolesAndMembers
RegularExpression("([a-z]|[A-Z]|[\\s-_.~]|[0-9])+")
]
public string NewUserName { get; set; }
}
}

View File

@ -40,7 +40,7 @@ namespace Yavsc.Model.Skill
private static SkillProvider Provider {
get {
if (provider == null)
provider = ManagerHelper.GetDefaultProvider<SkillProvider>
provider = ManagerHelper.CreateDefaultProvider<SkillProvider>
("system.web/skillProviders");
return provider;
}

View File

@ -11,7 +11,6 @@ namespace Yavsc.Model.WorkFlow
/// </summary>
public interface IContentProvider : IDbModule, IDisposable, IDataProvider<Estimate,long>
{
/// <summary>
/// Gets the different status labels.
/// 0 is the starting status. Each status is an integer and the 0-based index
@ -25,6 +24,52 @@ namespace Yavsc.Model.WorkFlow
/// </summary>
/// <value>The final statuses.</value>
bool [] FinalStatuses { get; }
string Name { get; }
/// <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>
Estimate CreateEstimate (string responsible, string client, string title, string description);
/// <summary>
/// Drops the writting.
/// </summary>
/// <param name="wrid">Wrid.</param>
void DropWritting (long wrid);
/// <summary>
/// Drops the estimate.
/// </summary>
/// <param name="estid">Estid.</param>
void DropEstimate (long estid);
/// <summary>
/// Drops the tag writting.
/// </summary>
/// <param name="wrid">Wrid.</param>
/// <param name="tag">Tag.</param>
void DropWrittingTag (long wrid,string tag);
/// <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>
Activity [] FindActivity (string pattern, bool exerted);
/// <summary>
/// Gets the activity.
/// </summary>
/// <returns>The activity.</returns>
/// <param name="MEACode">MAE code.</param>
Activity GetActivity (string MEACode);
/// <summary>
/// Gets the writting status changes.
/// </summary>
@ -36,17 +81,80 @@ namespace Yavsc.Model.WorkFlow
/// </summary>
/// <returns>The estimate statuses.</returns>
/// <param name="estid">Estid.</param>
StatusChange[] GetEstimateStatuses (long estid);
StatusChange[] GetEstimateStatuses (long estid); /// <summary>
/// <summary>
/// Creates the estimate.
/// Gets the estimates.
/// </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>
Estimate CreateEstimate (string responsible, string client, string title, string description);
/// <returns>The estimates.</returns>
/// <param name="username">Username.</param>
Estimate [] GetEstimates(string username);
/// <summary>
/// Registers the activity.
/// </summary>
/// <param name="activity">Activity.</param>
/// <param name="code">Code.</param>
void RegisterActivity (string activityName, string meacode, string comment);
/// <summary>
/// Gets the estimates.
/// </summary>
/// <returns>The estimates.</returns>
/// <param name="client">Client.</param>
/// <param name="responsible">Responsible.</param>
Estimate [] GetEstimates(string client, string responsible);
/// <summary>
/// Gets the commands.
/// </summary>
/// <returns>The commands.</returns>
/// <param name="username">Username.</param>
CommandSet GetCommands (string username);
/// <summary>
/// Gets the stock status.
/// </summary>
/// <returns>The stock status.</returns>
/// <param name="productReference">Product reference.</param>
StockStatus GetStockStatus (string productReference);
/// <summary>
/// Registers the command.
/// </summary>
/// <returns>The command id in db.</returns>
/// <param name="com">COM.</param>
long RegisterCommand (Command com);
/// <summary>
/// Sets the writting status.
/// </summary>
/// <param name="wrtid">Wrtid.</param>
/// <param name="status">Status.</param>
/// <param name="username">Username.</param>
void SetWrittingStatus (long wrtid,int status,string username);
/// <summary>
/// Sets the estimate status.
/// </summary>
/// <param name="estid">Estid.</param>
/// <param name="status">Status.</param>
/// <param name="username">Username.</param>
void SetEstimateStatus (long estid,int status,string username);
/// <summary>
/// Tags the writting.
/// </summary>
/// <param name="wrid">Wrid.</param>
/// <param name="tag">Tag.</param>
void TagWritting (long wrid,string tag);
/// <summary>
/// Updates the writting.
/// </summary>
/// <param name="wr">Wr.</param>
void UpdateWritting (Writting wr);
/// Add a line to the specified estimate by id,
/// using the specified desc, ucost, count and productid.
/// </summary>
@ -57,79 +165,6 @@ namespace Yavsc.Model.WorkFlow
/// <param name="productid">Product identifier.</param>
long Write (long estid, string desc, decimal ucost, int count, string productid);
/// <summary>
/// Gets the estimates created by
/// or for the given user by user name.
/// </summary>
/// <returns>The estimates.</returns>
/// <param name="username">user name.</param>
Estimate [] GetEstimates(string username);
/// <summary>
/// Gets the estimates.
/// </summary>
/// <returns>The estimates.</returns>
/// <param name="client">Client.</param>
/// <param name="responsible">Responsible.</param>
Estimate [] GetEstimates(string client, string responsible);
/// <summary>
/// Drops the writting.
/// </summary>
/// <param name="wrid">Wrid.</param>
void DropWritting (long wrid);
/// <summary>
/// Drops the estimate.
/// </summary>
/// <param name="estid">Estid.</param>
void DropEstimate (long estid);
/// <summary>
/// Tags the writting.
/// </summary>
/// <param name="wrid">Wrid.</param>
/// <param name="tag">Tag.</param>
void TagWritting (long wrid,string tag);
/// <summary>
/// Drops the tag writting.
/// </summary>
/// <param name="wrid">Wrid.</param>
/// <param name="tag">Tag.</param>
void DropWrittingTag (long wrid,string tag);
/// <summary>
/// Updates the writting.
/// </summary>
/// <param name="wr">Wr.</param>
void UpdateWritting (Writting wr);
/// <summary>
/// Sets the writting status.
/// </summary>
/// <param name="wrtid">Wrtid.</param>
/// <param name="status">Status.</param>
/// <param name="username">Username.</param>
void SetWrittingStatus (long wrtid,int status,string username);
/// <summary>
/// Sets the estimate status.
/// </summary>
/// <param name="estid">Estid.</param>
/// <param name="status">Status.</param>
/// <param name="username">Username.</param>
void SetEstimateStatus (long estid,int status,string username);
/// <summary>
/// Registers the command.
/// </summary>
/// <returns>The command id in db.</returns>
/// <param name="com">COM.</param>
long RegisterCommand (Command com);
/// <summary>
/// Gets the commands.
/// </summary>
/// <returns>The commands.</returns>
/// <param name="username">Username.</param>
CommandSet GetCommands (string username);
/// <summary>
/// Gets the stock status.
/// </summary>
/// <returns>The stock status.</returns>
/// <param name="productReference">Product reference.</param>
StockStatus GetStockStatus (string productReference);
}
}

View File

@ -21,19 +21,26 @@ namespace Yavsc.Model.WorkFlow
/// </summary>
/// <returns>The activity.</returns>
/// <param name="pattern">Pattern.</param>
public static IEnumerable<Activity> FindActivity(string pattern = "%")
/// <param name="exerted">If set to <c>true</c> exerted.</param>
public static Activity[] FindActivity(string pattern = "%", bool exerted=true)
{
throw new NotImplementedException ();
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>
/// Gets the activity.
/// </summary>
/// <returns>The activity.</returns>
/// <param name="MAECode">MAE code.</param>
public static Activity GetActivity (string MAECode)
/// <param name="meacode">MAE code.</param>
public static Activity GetActivity (string meacode)
{
throw new NotImplementedException ();
return DefaultProvider.GetActivity (meacode);
}
/// <summary>
@ -49,7 +56,7 @@ namespace Yavsc.Model.WorkFlow
/// <param name="com">COM.</param>
public static long RegisterCommand(Command com)
{
return ContentProvider.RegisterCommand (com);
return DefaultProvider.RegisterCommand (com);
}
/// <summary>
@ -58,7 +65,7 @@ namespace Yavsc.Model.WorkFlow
/// <param name="estim">Estim.</param>
public static void UpdateEstimate (Estimate estim)
{
ContentProvider.Update (estim);
DefaultProvider.Update (estim);
}
/// <summary>
/// Gets the estimate.
@ -67,7 +74,7 @@ namespace Yavsc.Model.WorkFlow
/// <param name="estid">Estid.</param>
public static Estimate GetEstimate (long estid)
{
return ContentProvider.Get (estid);
return DefaultProvider.Get (estid);
}
/// <summary>
/// Gets the estimates, refering the
@ -77,7 +84,7 @@ namespace Yavsc.Model.WorkFlow
/// <param name="responsible">Responsible.</param>
public static Estimate [] GetResponsibleEstimates (string responsible)
{
return ContentProvider.GetEstimates (null, responsible);
return DefaultProvider.GetEstimates (null, responsible);
}
/// <summary>
@ -87,7 +94,7 @@ namespace Yavsc.Model.WorkFlow
/// <param name="client">Client.</param>
public static Estimate [] GetClientEstimates (string client)
{
return ContentProvider.GetEstimates (client, null);
return DefaultProvider.GetEstimates (client, null);
}
/// <summary>
@ -97,7 +104,7 @@ namespace Yavsc.Model.WorkFlow
/// <param name="username">Username.</param>
public static Estimate [] GetUserEstimates (string username)
{
return ContentProvider.GetEstimates (username);
return DefaultProvider.GetEstimates (username);
}
/// <summary>
@ -107,7 +114,7 @@ namespace Yavsc.Model.WorkFlow
/// <param name="productReference">Product reference.</param>
public static StockStatus GetStock(string productReference)
{
return ContentProvider.GetStockStatus (productReference);
return DefaultProvider.GetStockStatus (productReference);
}
/// <summary>
@ -116,7 +123,7 @@ namespace Yavsc.Model.WorkFlow
/// <param name="wr">Wr.</param>
public static void UpdateWritting (Writting wr)
{
ContentProvider.UpdateWritting (wr);
DefaultProvider.UpdateWritting (wr);
}
/// <summary>
@ -125,7 +132,7 @@ namespace Yavsc.Model.WorkFlow
/// <param name="wrid">Wrid.</param>
public static void DropWritting (long wrid)
{
ContentProvider.DropWritting (wrid);
DefaultProvider.DropWritting (wrid);
}
/// <summary>
/// Drops the estimate.
@ -133,25 +140,38 @@ namespace Yavsc.Model.WorkFlow
/// <param name="estid">Estid.</param>
public static void DropEstimate (long estid)
{
ContentProvider.DropEstimate(estid);
DefaultProvider.DropEstimate(estid);
}
static IContentProvider contentProvider;
static IContentProvider defaultProvider;
/// <summary>
/// Gets the content provider.
/// </summary>
/// <value>The content provider.</value>
public static IContentProvider ContentProvider {
public static IContentProvider DefaultProvider {
get {
if (contentProvider == null)
contentProvider = ManagerHelper.GetDefaultProvider
if (defaultProvider == null)
defaultProvider = ManagerHelper.CreateDefaultProvider
("system.web/workflow") as IContentProvider;
return contentProvider;
return defaultProvider;
}
}
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.
@ -163,7 +183,7 @@ namespace Yavsc.Model.WorkFlow
/// <param name="description">Description.</param>
public static Estimate CreateEstimate(string responsible, string client, string title, string description)
{
Estimate created = ContentProvider.CreateEstimate (responsible, client, title, description);
Estimate created = DefaultProvider.CreateEstimate (responsible, client, title, description);
return created;
}
@ -187,7 +207,7 @@ namespace Yavsc.Model.WorkFlow
throw new Exception ("Product not found");
// TODO new EstimateChange Event
}
return ContentProvider.Write(estid, desc, ucost, count, productid);
return DefaultProvider.Write(estid, desc, ucost, count, productid);
}
/// <summary>
@ -198,7 +218,7 @@ namespace Yavsc.Model.WorkFlow
/// <param name="username">Username.</param>
public static void SetEstimateStatus(long estid, int status, string username)
{
ContentProvider.SetEstimateStatus (estid, status, username);
DefaultProvider.SetEstimateStatus (estid, status, username);
}
/// <summary>
/// Gets the commands.
@ -207,14 +227,12 @@ namespace Yavsc.Model.WorkFlow
/// <param name="username">Username.</param>
public static CommandSet GetCommands(string username)
{
return ContentProvider.GetCommands (username);
return DefaultProvider.GetCommands (username);
}
public static string [] APEDisponibles
public static void RegisterActivity (string activityName, string meacode, string comment)
{
get {
return new string[]{ "Chanteur", "DJ", "Musicien", "Clown" };
}
DefaultProvider.RegisterActivity (activityName, meacode, comment);
}
}
}

View File

@ -183,7 +183,6 @@
<Compile Include="Skill\SkillRating.cs" />
<Compile Include="Skill\SkillProvider.cs" />
<Compile Include="Skill\SkillManager.cs" />
<Compile Include="Manager.cs" />
<Compile Include="Skill\UserSkill.cs" />
<Compile Include="Skill\UserSkillComment.cs" />
<Compile Include="Skill\UserSkillDeclaration.cs" />
@ -201,6 +200,7 @@
<Compile Include="ITagBackup.cs" />
<Compile Include="ITitle.cs" />
<Compile Include="Calendar\BaseEvent.cs" />
<Compile Include="ManagerHelper.cs" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<ItemGroup>