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:
parent
f3bc91289d
commit
2fcaa1ded4
37 changed files with 804 additions and 341 deletions
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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"] ?? "/";
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue