* Makefile:
* CatalogManager.cs: Let the catalog manager ensure all command form are instancied * PhysicalProduct.cs: A better ToString method * SaleForm.cs: doc * NpgsqlContentProvider.cs: registers a command * FrontOfficeApiController.cs: Set the catalog referer uri in each command form found in the catalog * FrontOfficeController.cs: creates the catalog with referer uri * instdbws.sql: the command has got a client, as registered user * Commande.cs: The command has an id and a product reference * IContentProvider.cs: new RegisterCommand method * WorkFlowManager.cs: yavscModel/WorkFlow/IContentProvider.cs
This commit is contained in:
parent
85346d0e00
commit
b835053e5f
11 changed files with 122 additions and 19 deletions
14
Makefile
14
Makefile
|
|
@ -3,8 +3,10 @@ VERSION=1.1
|
||||||
CONFIG=Debug
|
CONFIG=Debug
|
||||||
DESTDIR=build/web/$(CONFIG)
|
DESTDIR=build/web/$(CONFIG)
|
||||||
COPYUNCHANGED="false"
|
COPYUNCHANGED="false"
|
||||||
PREPRODHOSTDIR=localhost:/srv/www/yavsc
|
LOCALHOSTDIR=localhost:/srv/www/lua
|
||||||
PRODHOSTDIR=localhost:/srv/www/lua
|
TESTHOSTDIR=localhost:/srv/www/yavsc
|
||||||
|
PREPRODHOSTDIR=lua.localdomain:/srv/yavsc
|
||||||
|
PRODHOSTDIR=lua.localdomain:/srv/www/lua
|
||||||
all: deploy
|
all: deploy
|
||||||
|
|
||||||
ddir:
|
ddir:
|
||||||
|
|
@ -24,12 +26,20 @@ clean:
|
||||||
xbuild /t:Clean
|
xbuild /t:Clean
|
||||||
rm -rf $(DESTDIR)
|
rm -rf $(DESTDIR)
|
||||||
|
|
||||||
|
rsync-local: deploy
|
||||||
|
rsync -ravu build/web/$(CONFIG)/ root@$(LOCALHOSTDIR)
|
||||||
|
|
||||||
|
rsync-test: deploy
|
||||||
|
rsync -ravu build/web/$(CONFIG)/ root@$(TESTHOSTDIR)
|
||||||
|
|
||||||
rsync-preprod: deploy
|
rsync-preprod: deploy
|
||||||
rsync -ravu build/web/$(CONFIG)/ root@$(PREPRODHOSTDIR)
|
rsync -ravu build/web/$(CONFIG)/ root@$(PREPRODHOSTDIR)
|
||||||
|
|
||||||
rsync-prod: deploy
|
rsync-prod: deploy
|
||||||
rsync -ravu build/web/$(CONFIG)/ root@$(PRODHOSTDIR)
|
rsync -ravu build/web/$(CONFIG)/ root@$(PRODHOSTDIR)
|
||||||
|
|
||||||
|
rsync-all: rsync-local rsync-test rsync-preprod rsync-prod
|
||||||
|
|
||||||
sourcepkg:
|
sourcepkg:
|
||||||
git archive --format=tar --prefix=yavsc-$(CONFIG)/ $(CONFIG) | bzip2 > yavsc-$(CONFIG).tar.bz2
|
git archive --format=tar --prefix=yavsc-$(CONFIG)/ $(CONFIG) | bzip2 > yavsc-$(CONFIG).tar.bz2
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -10,15 +10,29 @@ namespace SalesCatalog
|
||||||
public static class CatalogManager
|
public static class CatalogManager
|
||||||
{
|
{
|
||||||
private static CatalogProvider defaultProvider = null;
|
private static CatalogProvider defaultProvider = null;
|
||||||
public static Catalog GetCatalog ()
|
public static Catalog GetCatalog (string catalogUri)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (defaultProvider == null) {
|
if (defaultProvider == null) {
|
||||||
if (CatalogHelper.Config == null)
|
if (CatalogHelper.Config == null)
|
||||||
CatalogHelper.LoadConfig ();
|
CatalogHelper.LoadConfig ();
|
||||||
defaultProvider = CatalogHelper.GetDefaultProvider ();
|
defaultProvider = CatalogHelper.GetDefaultProvider ();
|
||||||
|
|
||||||
}
|
}
|
||||||
return defaultProvider.GetCatalog ();
|
Catalog res = defaultProvider.GetCatalog ();
|
||||||
|
|
||||||
|
// Assert res.Brands.All( x => x.DefaultForm != null );
|
||||||
|
// Sanity fixes
|
||||||
|
foreach (Brand b in res.Brands) {
|
||||||
|
if (b.DefaultForm.CatalogReference==null)
|
||||||
|
b.DefaultForm.CatalogReference = catalogUri;
|
||||||
|
foreach (ProductCategory pc in b.Categories) {
|
||||||
|
foreach (Product p in pc.Products) {
|
||||||
|
if (p.CommandForm == null)
|
||||||
|
p.CommandForm = b.DefaultForm;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return res;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@ namespace SalesCatalog.Model
|
||||||
|
|
||||||
public override string ToString ()
|
public override string ToString ()
|
||||||
{
|
{
|
||||||
return string.Format ("[PhysicalProduct: UnitaryPrice={0}]", UnitaryPrice);
|
return string.Format ("[PhysicalProduct: Reference:{0} UnitaryPrice={1}]", Reference, UnitaryPrice);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,15 +5,35 @@ namespace SalesCatalog.Model
|
||||||
{
|
{
|
||||||
public class SaleForm
|
public class SaleForm
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the catalog reference.
|
||||||
|
/// It must be non null,
|
||||||
|
/// it is an Uri, returning the Xml
|
||||||
|
/// Catalog at Http GET request
|
||||||
|
/// </summary>
|
||||||
|
/// <value>The catalog reference.</value>
|
||||||
|
public string CatalogReference { get; set; }
|
||||||
|
|
||||||
public SaleForm ()
|
public SaleForm ()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the action, that is,
|
||||||
|
/// the Method of the FrontOffice controller
|
||||||
|
/// called to post this Command form.
|
||||||
|
/// It defaults to "Command"
|
||||||
|
/// </summary>
|
||||||
|
/// <value>The action.</value>
|
||||||
public string Action {
|
public string Action {
|
||||||
get;
|
get;
|
||||||
set;
|
set;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the input values of this command form.
|
||||||
|
/// </summary>
|
||||||
|
/// <value>The items.</value>
|
||||||
public FormElement[] Items { get; set; }
|
public FormElement[] Items { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,22 @@ namespace WorkFlowProvider
|
||||||
{
|
{
|
||||||
public class NpgsqlContentProvider: ProviderBase, IContentProvider
|
public class NpgsqlContentProvider: ProviderBase, IContentProvider
|
||||||
{
|
{
|
||||||
|
public long RegisterCommand (Commande com)
|
||||||
|
{
|
||||||
|
long id;
|
||||||
|
using (NpgsqlConnection cnx = CreateConnection ()) {
|
||||||
|
using (NpgsqlCommand cmd = cnx.CreateCommand ()) {
|
||||||
|
cmd.CommandText =
|
||||||
|
"insert into commandes (pref,creation) values (@pref,@creat) returning _id";
|
||||||
|
cmd.Parameters.Add ("@pref", com.ProdRef);
|
||||||
|
cmd.Parameters.Add ("@creat", com.CreationDate);
|
||||||
|
cnx.Open ();
|
||||||
|
com.Id = id = (long)cmd.ExecuteScalar ();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
public StatusChange[] GetWrittingStatuses (long wrid)
|
public StatusChange[] GetWrittingStatuses (long wrid)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException ();
|
throw new NotImplementedException ();
|
||||||
|
|
|
||||||
|
|
@ -41,14 +41,14 @@ namespace Yavsc.ApiControllers
|
||||||
[AcceptVerbs("GET")]
|
[AcceptVerbs("GET")]
|
||||||
public Catalog Catalog ()
|
public Catalog Catalog ()
|
||||||
{
|
{
|
||||||
Catalog c = CatalogManager.GetCatalog ();
|
Catalog c = CatalogManager.GetCatalog (Request.RequestUri.AbsolutePath);
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
[AcceptVerbs("GET")]
|
[AcceptVerbs("GET")]
|
||||||
public ProductCategory GetProductCategorie (string brandName, string prodCategorie)
|
public ProductCategory GetProductCategorie (string brandName, string prodCategorie)
|
||||||
{
|
{
|
||||||
return CatalogManager.GetCatalog ().GetBrand (brandName).GetProductCategory (prodCategorie)
|
return CatalogManager.GetCatalog (Request.RequestUri.AbsolutePath).GetBrand (brandName).GetProductCategory (prodCategorie)
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
|
|
|
||||||
|
|
@ -91,7 +91,7 @@ namespace Yavsc.Controllers
|
||||||
public ActionResult Catalog ()
|
public ActionResult Catalog ()
|
||||||
{
|
{
|
||||||
return View (
|
return View (
|
||||||
CatalogManager.GetCatalog ()
|
CatalogManager.GetCatalog (Request.Url.AbsolutePath)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -101,7 +101,7 @@ namespace Yavsc.Controllers
|
||||||
[AcceptVerbs("GET")]
|
[AcceptVerbs("GET")]
|
||||||
public ActionResult Brand (string id)
|
public ActionResult Brand (string id)
|
||||||
{
|
{
|
||||||
Catalog c = CatalogManager.GetCatalog ();
|
Catalog c = CatalogManager.GetCatalog (Request.Url.AbsolutePath);
|
||||||
ViewData ["BrandName"] = id;
|
ViewData ["BrandName"] = id;
|
||||||
return View ( c.GetBrand (id) );
|
return View ( c.GetBrand (id) );
|
||||||
}
|
}
|
||||||
|
|
@ -117,7 +117,7 @@ namespace Yavsc.Controllers
|
||||||
{
|
{
|
||||||
ViewData ["BrandName"] = id;
|
ViewData ["BrandName"] = id;
|
||||||
return View (
|
return View (
|
||||||
CatalogManager.GetCatalog ().GetBrand (id).GetProductCategory (pc)
|
CatalogManager.GetCatalog (Request.Url.AbsolutePath).GetBrand (id).GetProductCategory (pc)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -128,7 +128,7 @@ namespace Yavsc.Controllers
|
||||||
ViewData ["BrandName"] = id;
|
ViewData ["BrandName"] = id;
|
||||||
ViewData ["ProdCatRef"] = pc;
|
ViewData ["ProdCatRef"] = pc;
|
||||||
ViewData ["ProdRef"] = pref;
|
ViewData ["ProdRef"] = pref;
|
||||||
Catalog cat = CatalogManager.GetCatalog ();
|
Catalog cat = CatalogManager.GetCatalog (Request.Url.AbsolutePath);
|
||||||
if (cat == null) {
|
if (cat == null) {
|
||||||
ViewData ["Message"] = "Catalog introuvable";
|
ViewData ["Message"] = "Catalog introuvable";
|
||||||
ViewData ["RefType"] = "Catalog";
|
ViewData ["RefType"] = "Catalog";
|
||||||
|
|
@ -189,7 +189,7 @@ namespace Yavsc.Controllers
|
||||||
Session["Basket"]=new List<Commande>();
|
Session["Basket"]=new List<Commande>();
|
||||||
List<Commande> basket = Session["Basket"] as List<Commande>;
|
List<Commande> basket = Session["Basket"] as List<Commande>;
|
||||||
// Add specified product command to the basket,
|
// Add specified product command to the basket,
|
||||||
basket.Add(new Commande(0,0,collection));
|
basket.Add(Commande.Create(collection));
|
||||||
return View (collection);
|
return View (collection);
|
||||||
} catch (Exception e)
|
} catch (Exception e)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -202,17 +202,40 @@ COMMENT ON COLUMN blfiles.blid IS 'Blog entry identifier (foreign key)';
|
||||||
|
|
||||||
CREATE TABLE commandes
|
CREATE TABLE commandes
|
||||||
(
|
(
|
||||||
id bigint NOT NULL, -- Identifiant unique de commande e, cours
|
id bigserial NOT NULL, -- Identifiant unique de commande e, cours
|
||||||
validation date, -- Date de validation
|
validation date, -- Date de validation
|
||||||
prdref character varying(255) NOT NULL, -- Product reference from the unique valid catalog at the validation date
|
prdref character varying(255) NOT NULL, -- Product reference from the unique valid catalog at the validation date
|
||||||
CONSTRAINT commandes_pkey PRIMARY KEY (id)
|
creation timestamp with time zone, -- creation date
|
||||||
|
clientname character varying(255), -- user who created the command, client of this command
|
||||||
|
applicationname character varying(255), -- application concerned by this command
|
||||||
|
CONSTRAINT commandes_pkey PRIMARY KEY (id),
|
||||||
|
CONSTRAINT commforeignuser FOREIGN KEY (clientname, applicationname)
|
||||||
|
REFERENCES users (username, applicationname) MATCH SIMPLE
|
||||||
|
ON UPDATE CASCADE ON DELETE CASCADE
|
||||||
)
|
)
|
||||||
WITH (
|
WITH (
|
||||||
OIDS=FALSE
|
OIDS=FALSE
|
||||||
);
|
);
|
||||||
|
ALTER TABLE commandes
|
||||||
|
OWNER TO yavsc;
|
||||||
COMMENT ON COLUMN commandes.id IS 'Identifiant unique de commande e, cours';
|
COMMENT ON COLUMN commandes.id IS 'Identifiant unique de commande e, cours';
|
||||||
COMMENT ON COLUMN commandes.validation IS 'Date de validation';
|
COMMENT ON COLUMN commandes.validation IS 'Date de validation';
|
||||||
COMMENT ON COLUMN commandes.prdref IS 'Product reference from the unique valid catalog at the validation date';
|
COMMENT ON COLUMN commandes.prdref IS 'Product reference from the unique valid catalog at the validation date';
|
||||||
|
COMMENT ON COLUMN commandes.creation IS 'creation date';
|
||||||
|
COMMENT ON COLUMN commandes.clientname IS 'user who created the command, client of this command';
|
||||||
|
COMMENT ON COLUMN commandes.applicationname IS 'application concerned by this command';
|
||||||
|
|
||||||
|
|
||||||
|
-- Index: fki_commforeignuser
|
||||||
|
|
||||||
|
-- DROP INDEX fki_commforeignuser;
|
||||||
|
|
||||||
|
CREATE INDEX fki_commforeignuser
|
||||||
|
ON commandes
|
||||||
|
USING btree
|
||||||
|
(clientname COLLATE pg_catalog."default", applicationname COLLATE pg_catalog."default");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
-- Table: comment
|
-- Table: comment
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -10,11 +10,20 @@ namespace Yavsc.Model.WorkFlow
|
||||||
public class Commande
|
public class Commande
|
||||||
{
|
{
|
||||||
public DateTime CreationDate { get; set; }
|
public DateTime CreationDate { get; set; }
|
||||||
long Id { get; set; }
|
public long Id { get; set; }
|
||||||
public Commande(long catid, long pref, NameValueCollection collection)
|
public string ProdRef { get; set; }
|
||||||
|
public Commande() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Commande Create(NameValueCollection collection)
|
||||||
{
|
{
|
||||||
CreationDate = DateTime.Now;
|
Commande cmd = new Commande ();
|
||||||
//TODO save it and get the id
|
// string catref=collection["catref"]; // Catalog Url from which formdata has been built
|
||||||
|
cmd.ProdRef=collection["prodref"]; // Required product reference
|
||||||
|
cmd.CreationDate = DateTime.Now;
|
||||||
|
WorkFlowManager wm = new WorkFlowManager ();
|
||||||
|
wm.RegisterCommand (cmd); // sets cmd.Id
|
||||||
|
return cmd;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -112,6 +112,12 @@ namespace Yavsc.Model.WorkFlow
|
||||||
/// <param name="status">Status.</param>
|
/// <param name="status">Status.</param>
|
||||||
/// <param name="username">Username.</param>
|
/// <param name="username">Username.</param>
|
||||||
void SetEstimateStatus (long estid,int status,string username);
|
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 (Commande com);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,11 @@ namespace Yavsc.Model.WorkFlow
|
||||||
{
|
{
|
||||||
public static Catalog Catalog { get; set; }
|
public static Catalog Catalog { get; set; }
|
||||||
|
|
||||||
|
public long RegisterCommand(Commande com)
|
||||||
|
{
|
||||||
|
return ContentProvider.RegisterCommand (com);
|
||||||
|
}
|
||||||
|
|
||||||
public void UpdateEstimate (Estimate estim)
|
public void UpdateEstimate (Estimate estim)
|
||||||
{
|
{
|
||||||
ContentProvider.UpdateEstimate (estim);
|
ContentProvider.UpdateEstimate (estim);
|
||||||
|
|
@ -105,7 +110,7 @@ namespace Yavsc.Model.WorkFlow
|
||||||
{
|
{
|
||||||
if (!string.IsNullOrWhiteSpace(productid)) {
|
if (!string.IsNullOrWhiteSpace(productid)) {
|
||||||
if (Catalog == null)
|
if (Catalog == null)
|
||||||
Catalog = SalesCatalog.CatalogManager.GetCatalog ();
|
Catalog = SalesCatalog.CatalogManager.GetCatalog ("/WorkFlowApi");
|
||||||
if (Catalog == null)
|
if (Catalog == null)
|
||||||
throw new Exception ("No catalog");
|
throw new Exception ("No catalog");
|
||||||
Product p = Catalog.FindProduct (productid);
|
Product p = Catalog.FindProduct (productid);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue