diff --git a/NpgsqlBlogProvider/ChangeLog b/NpgsqlBlogProvider/ChangeLog index 8765f36b..e154e49b 100644 --- a/NpgsqlBlogProvider/ChangeLog +++ b/NpgsqlBlogProvider/ChangeLog @@ -1,3 +1,7 @@ +2015-11-28 Paul Schneider + + * NpgsqlBlogProvider.cs: xml doc + 2015-11-26 Paul Schneider * NpgsqlBlogProvider.csproj: nouvelles configurations de diff --git a/NpgsqlBlogProvider/NpgsqlBlogProvider.cs b/NpgsqlBlogProvider/NpgsqlBlogProvider.cs index 53f9fb78..91ae6611 100644 --- a/NpgsqlBlogProvider/NpgsqlBlogProvider.cs +++ b/NpgsqlBlogProvider/NpgsqlBlogProvider.cs @@ -20,7 +20,10 @@ namespace Npgsql.Web.Blog string connectionString; #region implemented abstract members of BlogProvider - + /// + /// Updates the post. + /// + /// Be. public override void UpdatePost (BlogEntry be) { // TODO Tags and rate should not be ignored diff --git a/NpgsqlContentProvider/ChangeLog b/NpgsqlContentProvider/ChangeLog index 05dad7d5..bed69b58 100644 --- a/NpgsqlContentProvider/ChangeLog +++ b/NpgsqlContentProvider/ChangeLog @@ -1,3 +1,11 @@ +2015-11-28 Paul Schneider + + * NpgsqlContentProvider.cs: implemente un listing des + prestataire du code APE en base. + + * NpgsqlSkillProvider.cs: implemente un listing des domaines + de compétence du préstataire en base. + 2015-11-26 Paul Schneider * NpgsqlContentProvider.csproj: nouvelles configurations de diff --git a/NpgsqlContentProvider/NpgsqlContentProvider.cs b/NpgsqlContentProvider/NpgsqlContentProvider.cs index 793fde44..2ee8fd71 100644 --- a/NpgsqlContentProvider/NpgsqlContentProvider.cs +++ b/NpgsqlContentProvider/NpgsqlContentProvider.cs @@ -21,6 +21,48 @@ namespace Yavsc /// public class NpgsqlContentProvider: ProviderBase, IContentProvider { + /// + /// Finds the performer. + /// + /// The performer. + /// MEA code. + public PerformerProfile[] FindPerformer (string MEACode) + { + var result = new List (); + + using (NpgsqlConnection cnx = CreateConnection ()) { + cnx.Open (); + + using (NpgsqlCommand cmd = cnx.CreateCommand ()) { + cmd.CommandText = @"SELECT d.uniqueid, u.username, u.email, d.rate + FROM profiledata d, profiles p, users u + WHERE u.username = p.username + AND u.applicationname = p.applicationname + AND p.uniqueid = d.uniqueid + AND u.isapproved = TRUE + AND u.islockedout = FALSE + AND d.meacode = :mea + AND u.applicationname = :app + ORDER BY u.username "; + cmd.Parameters.AddWithValue ("mea", NpgsqlTypes.NpgsqlDbType.Varchar, MEACode); + cmd.Parameters.AddWithValue ("app", NpgsqlTypes.NpgsqlDbType.Varchar, applicationName); + + using (var rdr = cmd.ExecuteReader ()) { + if (rdr.HasRows) { + while (rdr.Read ()) { + var profile = new PerformerProfile (); + profile.Id = rdr.GetInt64 (0); + profile.UserName = rdr.GetString (1); + profile.EMail = rdr.GetString (2); + result.Add (profile); + } + } + } + } + } + return result.ToArray (); + } + /// /// Gets the activity. /// @@ -32,7 +74,7 @@ namespace Yavsc using (NpgsqlConnection cnx = CreateConnection ()) { cnx.Open (); using (NpgsqlCommand cmd = cnx.CreateCommand ()) { - cmd.CommandText = @"select meacode, title, cmnt, photo + cmd.CommandText = @"select distinct meacode, title, cmnt, photo from activity where meacode = :code and applicationname = :app"; cmd.Parameters.AddWithValue ("code", MEACode); cmd.Parameters.AddWithValue ("app", applicationName); diff --git a/NpgsqlContentProvider/NpgsqlSkillProvider.cs b/NpgsqlContentProvider/NpgsqlSkillProvider.cs index 8bc236ae..4447d582 100644 --- a/NpgsqlContentProvider/NpgsqlSkillProvider.cs +++ b/NpgsqlContentProvider/NpgsqlSkillProvider.cs @@ -41,6 +41,7 @@ namespace WorkFlowProvider { } + string connectionString = null; string applicationName = null; @@ -59,6 +60,7 @@ namespace WorkFlowProvider } #region implemented abstract members of SkillProvider + /// /// Gets the user skills. /// @@ -66,30 +68,31 @@ namespace WorkFlowProvider /// Username. public override PerformerProfile GetUserSkills (string username) { - var skills = new List (); + var skills = new List (); var profile = new PerformerProfile (username); - using (NpgsqlConnection cnx=new NpgsqlConnection(connectionString)) { + using (NpgsqlConnection cnx = new NpgsqlConnection (connectionString)) { cnx.Open (); using (NpgsqlCommand cmd = cnx.CreateCommand ()) { cmd.CommandText = " select u._id, u.skillid, s.name, " + - " u.comment, u.rate from userskills u, " + - " skill s " + - " where u.skillid = s._id and " + - " u.username = :uname " + - " and applicationname = :app " + - " order by u.rate desc"; + " u.comment, u.rate from userskills u, " + + " skill s " + + " where u.skillid = s._id and " + + " u.username = :uname " + + " and applicationname = :app " + + " order by u.rate desc"; cmd.Parameters.AddWithValue ("uname", NpgsqlTypes.NpgsqlDbType.Varchar, username); cmd.Parameters.AddWithValue ("app", NpgsqlTypes.NpgsqlDbType.Varchar, applicationName); cmd.Prepare (); using (var rdr = cmd.ExecuteReader ()) { - if (rdr.HasRows) while (rdr.Read ()) { + if (rdr.HasRows) + while (rdr.Read ()) { skills.Add (new UserSkill () { Id = rdr.GetInt64 (0), SkillId = rdr.GetInt64 (1), SkillName = rdr.GetString (2), Comment = rdr.GetString (3), - Rate = rdr.GetInt32(4) + Rate = rdr.GetInt32 (4) }); } profile.Skills = skills.ToArray (); @@ -97,10 +100,17 @@ namespace WorkFlowProvider } using (NpgsqlCommand cmd = cnx.CreateCommand ()) { cmd.CommandText = - "select uniqueid from profiles where username = :user and applicationname = :app"; + "select p.uniqueid, d.rate from profiles p, profiledata d where " + + " username = :user and applicationname = :app " + + " and p.uniqueid = d.uniqueid "; cmd.Parameters.AddWithValue ("user", NpgsqlTypes.NpgsqlDbType.Varchar, username); cmd.Parameters.AddWithValue ("app", NpgsqlTypes.NpgsqlDbType.Varchar, applicationName); - profile.Id = (long) cmd.ExecuteScalar (); + + using (var rdr = cmd.ExecuteReader ()) { + rdr.Read (); + profile.Id = rdr.GetInt64 (0); + profile.Rate = rdr.GetInt32 (1); + } } cnx.Close (); } @@ -114,14 +124,18 @@ namespace WorkFlowProvider public override long Declare (SkillEntity skill) { long res = 0; - using (NpgsqlConnection cnx=new NpgsqlConnection(connectionString)) { + using (NpgsqlConnection cnx = new NpgsqlConnection (connectionString)) { cnx.Open (); if (skill.Id == 0) { using (NpgsqlCommand cmd = cnx.CreateCommand ()) { - cmd.CommandText = "insert into skill (name,rate) values (:name,:rate) returning _id"; + cmd.CommandText = "insert into skill (name,meacode,rate,applicationname) " + + " values (:name,:mea,:rate,:app) " + + " returning _id "; cmd.Parameters.AddWithValue ("name", NpgsqlTypes.NpgsqlDbType.Varchar, skill.Name); + cmd.Parameters.AddWithValue ("mea", NpgsqlTypes.NpgsqlDbType.Varchar, skill.MEACode); cmd.Parameters.AddWithValue ("rate", NpgsqlTypes.NpgsqlDbType.Integer, skill.Rate); + cmd.Parameters.AddWithValue ("app", NpgsqlTypes.NpgsqlDbType.Varchar, applicationName); res = (long)cmd.ExecuteScalar (); } } else { @@ -145,8 +159,8 @@ namespace WorkFlowProvider /// userskill. public override long Declare (UserSkillDeclaration userskill) { - long res=0; - using (NpgsqlConnection cnx=new NpgsqlConnection(connectionString)) { + long res = 0; + using (NpgsqlConnection cnx = new NpgsqlConnection (connectionString)) { cnx.Open (); if (userskill.Id == 0) { using (NpgsqlCommand cmd = cnx.CreateCommand ()) { @@ -198,23 +212,23 @@ namespace WorkFlowProvider // and a client rating that goes into the // `statisfaction` table. long usid = 0; - using (NpgsqlConnection cnx=new NpgsqlConnection(connectionString)) { + using (NpgsqlConnection cnx = new NpgsqlConnection (connectionString)) { cnx.Open (); using (NpgsqlCommand cmd = cnx.CreateCommand ()) { if (userSkill.Id == 0) { cmd.CommandText = "insert into userskills " + - " ( skillid, rate, username, applicationname ) " + - " values ( :sid, :rate, :uname, :app ) " + - " returning _id "; + " ( skillid, rate, username, applicationname ) " + + " values ( :sid, :rate, :uname, :app ) " + + " returning _id "; cmd.Parameters.AddWithValue ("sid", NpgsqlDbType.Bigint, userSkill.Id); cmd.Parameters.AddWithValue ("rate", NpgsqlDbType.Integer, userSkill.Rate); cmd.Parameters.AddWithValue ("uname", NpgsqlDbType.Varchar, userSkill.Performer); cmd.Parameters.AddWithValue ("app", NpgsqlDbType.Varchar, applicationName); - usid = (long) cmd.ExecuteScalar (); + usid = (long)cmd.ExecuteScalar (); } else { cmd.CommandText = "update userskills " + - " set rate = :rate " + - " where _id = :usid "; + " set rate = :rate " + + " where _id = :usid "; cmd.Parameters.AddWithValue ("rate", NpgsqlDbType.Integer, userSkill.Rate); cmd.Parameters.AddWithValue ("usid", NpgsqlDbType.Bigint, userSkill.Id); cmd.ExecuteNonQuery (); @@ -243,7 +257,7 @@ namespace WorkFlowProvider // it's concerning a rating on a need of the Author // if not, it's a need of the site - using (NpgsqlConnection cnx=new NpgsqlConnection(connectionString)) { + using (NpgsqlConnection cnx = new NpgsqlConnection (connectionString)) { cnx.Open (); using (NpgsqlCommand cmd = cnx.CreateCommand ()) { cmd.CommandText = "update skill set rate = :rate where _id = :sid"; @@ -254,28 +268,43 @@ namespace WorkFlowProvider cnx.Close (); } } + /// - /// Finds the skill identifier. + /// Finds the skills. /// /// The skill identifier. /// Pattern. - public override SkillEntity[] FindSkill (string pattern) + /// MEA Code. + public override SkillEntity[] FindSkill (string pattern, string MEACode) { List skills = new List (); - using (NpgsqlConnection cnx=new NpgsqlConnection(connectionString)) { + using (NpgsqlConnection cnx = new NpgsqlConnection (connectionString)) { cnx.Open (); using (NpgsqlCommand cmd = cnx.CreateCommand ()) { - cmd.CommandText = "select _id, name, rate from skill where name like :name order by rate desc"; + + cmd.CommandText = "select _id, name, rate, meacode " + + " from skill " + + " where name like :name "; + if (MEACode != null) + cmd.CommandText += + " and meacode = :mea "; + cmd.CommandText += " and applicationname = :app " + + " order by rate desc"; cmd.Parameters.AddWithValue ("name", NpgsqlTypes.NpgsqlDbType.Varchar, pattern); + if (MEACode != null) + cmd.Parameters.AddWithValue ("mea", NpgsqlTypes.NpgsqlDbType.Varchar, MEACode); + cmd.Parameters.AddWithValue ("app", NpgsqlTypes.NpgsqlDbType.Varchar, applicationName); cmd.Prepare (); using (var rdr = cmd.ExecuteReader ()) { - if (rdr.HasRows) while (rdr.Read ()) { - skills.Add (new SkillEntity () { - Id = (long)rdr.GetInt64 (0), - Name = (string)rdr.GetString (1), - Rate = (int) rdr.GetInt32(2) - }); - } + if (rdr.HasRows) + while (rdr.Read ()) { + skills.Add (new SkillEntity () { + Id = (long)rdr.GetInt64 (0), + Name = (string)rdr.GetString (1), + Rate = (int)rdr.GetInt32 (2), + MEACode = (string)rdr.GetString (3), + }); + } } } cnx.Close (); @@ -292,25 +321,57 @@ namespace WorkFlowProvider { var res = new List (); - using (NpgsqlConnection cnx=new NpgsqlConnection(connectionString)) { + using (NpgsqlConnection cnx = new NpgsqlConnection (connectionString)) { cnx.Open (); using (NpgsqlCommand cmd = cnx.CreateCommand ()) { - cmd.CommandText = " select username from userskills " + - " where skillid = :sid " + - " order by rate desc "; + cmd.CommandText = " select u.username " + + " from userskills s, profiledata p, profile q, users u " + + " where s.username = u.username " + + " and s.applicationname = u.applicationanme " + + " and s.skillid = :sid " + + " and u.username = q.username " + + " and u.applicationname = q.applicationanme " + + " and p.uniqueid = q.uniqueid " + + " and u.applicationanme = :app " + + " and u.islockedout = FALSE " + + " and u.isapproved = TRUE " + + " order by s.rate desc "; + + cmd.Parameters.AddWithValue ("sid", NpgsqlDbType.Bigint, 0); cmd.Prepare (); - foreach ( long sid in skillIds ) - { + foreach (long sid in skillIds) { cmd.Parameters ["sid"].Value = sid; using (var rdr = cmd.ExecuteReader ()) { string uname = rdr.GetString (0); - if (!res.Contains(uname)) + if (!res.Contains (uname)) res.Add (uname); } } + // TODO implement a configuration parameter + if (res.Count < 10) { + cmd.CommandText = " select u.username " + + " from skill s, profiledata p , profile q, users u " + + " where u.username = q.username " + + " and u.applicationname = q.applicationanme " + + " and p.uniqueid = q.uniqueid " + + " and p.meacode = s.meacode " + + " and s._id = :sid " + + " and u.applicationanme = :app " + + " and u.islockedout = FALSE " + + " and u.isapproved = TRUE" + + " order by s.rate desc " ; + foreach (long sid in skillIds) { + cmd.Parameters ["sid"].Value = sid; + using (var rdr = cmd.ExecuteReader ()) { + string uname = rdr.GetString (0); + if (!res.Contains (uname)) + res.Add (uname); + } + } + } } cnx.Close (); } @@ -323,12 +384,12 @@ namespace WorkFlowProvider /// Skill identifier. public override void DeleteSkill (long skillId) { - using (NpgsqlConnection cnx=new NpgsqlConnection(connectionString)) { + using (NpgsqlConnection cnx = new NpgsqlConnection (connectionString)) { cnx.Open (); using (NpgsqlCommand cmd = cnx.CreateCommand ()) { cmd.CommandText = " delete from skill " + - " where _id = :sid "; - cmd.Parameters.AddWithValue ("sid", NpgsqlTypes.NpgsqlDbType.Bigint,skillId); + " where _id = :sid "; + cmd.Parameters.AddWithValue ("sid", NpgsqlTypes.NpgsqlDbType.Bigint, skillId); cmd.ExecuteNonQuery (); } cnx.Close (); @@ -339,18 +400,20 @@ namespace WorkFlowProvider /// Deletes the user skill. /// /// User skill identifier. - public override void DeleteUserSkill(long userSkillId) { - using (NpgsqlConnection cnx=new NpgsqlConnection(connectionString)) { + public override void DeleteUserSkill (long userSkillId) + { + using (NpgsqlConnection cnx = new NpgsqlConnection (connectionString)) { cnx.Open (); using (NpgsqlCommand cmd = cnx.CreateCommand ()) { cmd.CommandText = " delete from userskills " + - " where _id = :usid "; - cmd.Parameters.AddWithValue ("usid", NpgsqlTypes.NpgsqlDbType.Bigint,userSkillId); + " where _id = :usid "; + cmd.Parameters.AddWithValue ("usid", NpgsqlTypes.NpgsqlDbType.Bigint, userSkillId); cmd.ExecuteNonQuery (); } cnx.Close (); } } + #endregion } } diff --git a/SalesCatalog/ChangeLog b/SalesCatalog/ChangeLog index 30937a6c..2a88d965 100644 --- a/SalesCatalog/ChangeLog +++ b/SalesCatalog/ChangeLog @@ -1,3 +1,15 @@ +2015-11-28 Paul Schneider + + * XmlCatalogProvider.cs: Le catalogue de vente implémente + mainenant l'interface d'un fournisseur de donnée comme les + autres. + Il pourrait par exemple vouloir définir des activité et des + compétences. + Pour l'instant, il n'est pas activé par la configuration, et + reste le fournisseur du catalogue legacy (voir + ). + + 2015-11-26 Paul Schneider * SalesCatalog.csproj: nouvelles configurations de déploiement diff --git a/SalesCatalog/XmlImplementation/XmlCatalogProvider.cs b/SalesCatalog/XmlImplementation/XmlCatalogProvider.cs index ea6eb00b..19bd35f5 100644 --- a/SalesCatalog/XmlImplementation/XmlCatalogProvider.cs +++ b/SalesCatalog/XmlImplementation/XmlCatalogProvider.cs @@ -15,8 +15,46 @@ namespace SalesCatalog.XmlImplementation /// public class XmlCatalogProvider: CatalogProvider { + #region implemented abstract members of CatalogProvider - #region implemented abstract members of SalesCatalog.CatalogProvider + /// + /// Gets the activity. + /// + /// The activity. + /// MAE code. + public override Yavsc.Model.FrontOffice.Activity GetActivity (string MEACode) + { + throw new NotImplementedException (); + } + /// + /// Registers the activity. + /// + /// Activity name. + /// Meacode. + /// Comment. + public override void RegisterActivity (string activityName, string meacode, string comment) + { + throw new NotImplementedException (); + } + /// + /// Finds the activity. + /// + /// The activity. + /// Pattern. + /// If set to true exerted. + public override Yavsc.Model.FrontOffice.Activity[] FindActivity (string pattern, bool exerted) + { + throw new NotImplementedException (); + } + /// + /// Finds the performer. + /// + /// The performer. + /// MEA code. + public override Yavsc.Model.FrontOffice.PerformerProfile[] FindPerformer (string MEACode) + { + throw new NotImplementedException (); + } /// /// Gets the catalog, loading it from /// the file system at a first call, diff --git a/web/ApiControllers/BackOfficeController.cs b/web/ApiControllers/BackOfficeController.cs index 37fcf075..a535c1b3 100644 --- a/web/ApiControllers/BackOfficeController.cs +++ b/web/ApiControllers/BackOfficeController.cs @@ -25,8 +25,9 @@ using Yavsc.Helpers; using Yavsc.Model.Circles; using System.Collections.Generic; using System.Web.Profile; -using Yavsc.Helpers.Google; using System.Web.Security; +using Yavsc.Model.Google.Api; +using Yavsc.Model.Google.Api.Messaging; namespace Yavsc.ApiControllers { diff --git a/web/ApiControllers/FrontOfficeController.cs b/web/ApiControllers/FrontOfficeController.cs index 7560c639..082cd526 100644 --- a/web/ApiControllers/FrontOfficeController.cs +++ b/web/ApiControllers/FrontOfficeController.cs @@ -205,8 +205,6 @@ namespace Yavsc.ApiControllers public void RateSkill (SkillRating rate) { throw new NotImplementedException (); } - - } } diff --git a/web/App_Code/Global.asax.cs b/web/App_Code/Global.asax.cs index b159a86c..1687c6ee 100644 --- a/web/App_Code/Global.asax.cs +++ b/web/App_Code/Global.asax.cs @@ -40,6 +40,13 @@ namespace Yavsc routes.IgnoreRoute ("favicon.ico"); // favorite icon routes.IgnoreRoute ("favicon.png"); // favorite icon routes.IgnoreRoute ("robots.txt"); // for search engine robots + + routes.MapRoute ( + "FrontOffice", + "do/{action}/{MEACode}/{Id}", + new { controller = "FrontOffice", action = "Index", MEACode = UrlParameter.Optional, Id = UrlParameter.Optional } + ); + routes.MapRoute ( "Titles", "title/{title}", diff --git a/web/App_Code/Sql/Skills.sql b/web/App_Code/Sql/Skills.sql deleted file mode 100644 index 17a152a7..00000000 --- a/web/App_Code/Sql/Skills.sql +++ /dev/null @@ -1,68 +0,0 @@ - --- Table: skill - --- DROP TABLE skill; - -CREATE TABLE skill -( - _id bigserial NOT NULL, - name character varying(2024) NOT NULL, - rate integer NOT NULL DEFAULT 50, - CONSTRAINT skill_pkey PRIMARY KEY (_id), - CONSTRAINT skill_name_key UNIQUE (name) -) -WITH ( - OIDS=FALSE -); - - --- Table: userskills - --- DROP TABLE userskills; - -CREATE TABLE userskills -( - applicationname character varying(512) NOT NULL, - username character varying(512) NOT NULL, - comment character varying, - skillid bigint NOT NULL, -- Skill identifier - rate integer NOT NULL, - _id bigserial NOT NULL, -- The id ... - CONSTRAINT userskills_pkey PRIMARY KEY (applicationname, username, skillid), - CONSTRAINT userskills_applicationname_fkey FOREIGN KEY (applicationname, username) - REFERENCES users (applicationname, username) MATCH SIMPLE - ON UPDATE CASCADE ON DELETE CASCADE, - CONSTRAINT userskills_skillid_fkey FOREIGN KEY (skillid) - REFERENCES skill (_id) MATCH SIMPLE - ON UPDATE CASCADE ON DELETE CASCADE, - CONSTRAINT userskills__id_key UNIQUE (_id) -) -WITH ( - OIDS=FALSE -); -COMMENT ON COLUMN userskills.skillid IS 'Skill identifier'; -COMMENT ON COLUMN userskills._id IS 'The id ...'; - --- Table: satisfaction - --- DROP TABLE satisfaction; - -CREATE TABLE satisfaction -( - _id bigserial NOT NULL, - userskillid bigint, -- the user's skill reference - rate integer, -- The satisfaction rating associated by a client to an user's skill - comnt character varying(8192), -- The satisfaction textual comment associated by a client to an user's skill, it could be formatted ala Markdown - CONSTRAINT satisfaction_pkey PRIMARY KEY (_id), - CONSTRAINT satisfaction_userskillid_fkey FOREIGN KEY (userskillid) - REFERENCES userskills (_id) MATCH SIMPLE - ON UPDATE CASCADE ON DELETE CASCADE -) -WITH ( - OIDS=FALSE -); -COMMENT ON COLUMN satisfaction.userskillid IS 'the user''s skill reference'; -COMMENT ON COLUMN satisfaction.rate IS 'The satisfaction rating associated by a client to an user''s skill'; -COMMENT ON COLUMN satisfaction.comnt IS 'The satisfaction textual comment associated by a client to an user''s skill, it could be formatted ala Markdown'; - - diff --git a/web/App_Code/Sql/activity.sql b/web/App_Code/Sql/activity.sql index c07008eb..58db0be4 100644 --- a/web/App_Code/Sql/activity.sql +++ b/web/App_Code/Sql/activity.sql @@ -1,6 +1,9 @@ --- Table: activity +DROP TABLE satisfaction; +DROP TABLE userskills; +DROP TABLE skill; +DROP TABLE activity; + --- DROP TABLE activity; CREATE TABLE activity ( @@ -8,7 +11,8 @@ CREATE TABLE activity applicationname character varying(255) NOT NULL, cmnt character varying, -- a long description for this activity meacode character varying(512) NOT NULL, -- Identifiant de l'activité, à terme, il faudrait ajouter un champ à cette id: le code pays.... - photo character varying(512) -- a photo url, as a front image for this activity + photo character varying(512) NOT NULL DEFAULT 'none'::character varying, -- a photo url, as a front image for this activity + CONSTRAINT activity_pkey PRIMARY KEY (meacode, applicationname) ) WITH ( OIDS=FALSE @@ -27,3 +31,113 @@ Exemple: ''71.12B'' => "Ingénierie, études techniques" '; COMMENT ON COLUMN activity.photo IS 'a photo url, as a front image for this activity'; + +INSERT INTO activity( + title, applicationname, cmnt, meacode, photo) + VALUES ( +'Édition de logiciels applicatifs', +'/', +'Vente d''applications logicielles', +'6829C', +'http://www.janua.fr/wp-content/uploads/2014/02/born2code-xavier-niel-developpeurs-formation.jpg' +); + +INSERT INTO activity( + title, applicationname, cmnt, meacode, photo) + VALUES ( +'Artiste', +'/', +'Anime votre mariage, un anniversaire ou autre événnement.', +'Artiste', +'http://www.dancefair.tv/wp-content/uploads/2015/05/How-to-secure-DJ-gig.jpg' +); + + +-- Table: skill + +-- DROP TABLE skill; + +CREATE TABLE skill +( + _id bigserial NOT NULL, + name character varying(2024) NOT NULL, + rate integer NOT NULL DEFAULT 50, + meacode character varying(256) NOT NULL, + applicationname character varying(255), + CONSTRAINT skill_pkey PRIMARY KEY (_id), + CONSTRAINT skill_app FOREIGN KEY (applicationname, meacode) + REFERENCES activity (applicationname, meacode) MATCH SIMPLE + ON UPDATE CASCADE ON DELETE CASCADE, + CONSTRAINT skill_name_meacode_applicationname_key UNIQUE (name, meacode, applicationname) +) +WITH ( + OIDS=FALSE +); + +-- Index: fki_skill_app + +-- DROP INDEX fki_skill_app; + +CREATE INDEX fki_skill_app + ON skill + USING btree + (applicationname COLLATE pg_catalog."default", meacode COLLATE pg_catalog."default"); + + + +-- Table: userskills + +-- DROP TABLE userskills; + +CREATE TABLE userskills +( + applicationname character varying(512) NOT NULL, + username character varying(512) NOT NULL, + comment character varying, + skillid bigint NOT NULL, -- Skill identifier + rate integer NOT NULL, + _id bigserial NOT NULL, -- The id ... + CONSTRAINT userskills_pkey PRIMARY KEY (applicationname, username, skillid), + CONSTRAINT userskills_applicationname_fkey FOREIGN KEY (applicationname, username) + REFERENCES users (applicationname, username) MATCH SIMPLE + ON UPDATE CASCADE ON DELETE CASCADE, + CONSTRAINT userskills_skillid_fkey FOREIGN KEY (skillid) + REFERENCES skill (_id) MATCH SIMPLE + ON UPDATE CASCADE ON DELETE CASCADE, + CONSTRAINT userskills__id_key UNIQUE (_id) +) +WITH ( + OIDS=FALSE +); +COMMENT ON COLUMN userskills.skillid IS 'Skill identifier'; +COMMENT ON COLUMN userskills._id IS 'The id ...'; + +-- Table: satisfaction + +-- DROP TABLE satisfaction; + +CREATE TABLE satisfaction +( + _id bigserial NOT NULL, + userskillid bigint, -- the user's skill reference + rate integer, -- The satisfaction rating associated by a client to an user's skill + comnt character varying(8192), -- The satisfaction textual comment associated by a client to an user's skill, it could be formatted ala Markdown + CONSTRAINT satisfaction_pkey PRIMARY KEY (_id), + CONSTRAINT satisfaction_userskillid_fkey FOREIGN KEY (userskillid) + REFERENCES userskills (_id) MATCH SIMPLE + ON UPDATE CASCADE ON DELETE CASCADE +) +WITH ( + OIDS=FALSE +); + +COMMENT ON COLUMN satisfaction.userskillid IS 'the user''s skill reference'; +COMMENT ON COLUMN satisfaction.rate IS 'The satisfaction rating associated by a client to an user''s skill'; +COMMENT ON COLUMN satisfaction.comnt IS 'The satisfaction textual comment associated by a client to an user''s skill, it could be formatted ala Markdown'; + +ALTER TABLE satisfaction OWNER TO lua; +ALTER TABLE userskills OWNER TO lua; +ALTER TABLE skill OWNER TO lua; +ALTER TABLE activity OWNER TO lua; + + diff --git a/web/App_Themes/dark/style.css b/web/App_Themes/dark/style.css index 32f2bfff..3a45b06a 100644 --- a/web/App_Themes/dark/style.css +++ b/web/App_Themes/dark/style.css @@ -26,7 +26,7 @@ input, textarea, checkbox { } header { - background: url("/App_Themes/images/star-939235_1280.jpg") -3em -3em no-repeat fixed; + background: url("http://s448140597.onlinehome.us/wp-content/uploads/2014/12/project-management1.jpg") -20em -20em repeat fixed; } header h1, header a { @@ -38,7 +38,7 @@ nav { } main { - background: url("/App_Themes/images/p8-av4.png") 50% 20em no-repeat fixed ; + background: url("/App_Themes/images/p8-av4.l.jpg") 50% 50% no-repeat fixed ; } footer { @@ -138,7 +138,6 @@ input:hover, textarea:hover { header { padding-top:1em; padding-bottom:1em; - background: url("/App_Themes/images/star-939235_1280.s.jpg") 0 0 no-repeat fixed; } #avatar { @@ -155,7 +154,7 @@ header h1, header a , .actionlink, .menuitem, a { padding:.5em;} main { margin: 1em; padding: 1em; - background: url("/App_Themes/images/p8-av4.s.jpg") 50% 20em no-repeat fixed ; + background: url("/App_Themes/images/p8-av4.jpg") 50% 50% no-repeat fixed ; } footer { background: url("/App_Themes/images/helix-nebula-1400x1400.s.jpg") 50% 90% repeat fixed ; @@ -194,7 +193,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;} @@ -207,7 +205,7 @@ header h1, header a { padding:.2em;} main { margin: .5em; padding: .5em; - background: url("/App_Themes/images/p8-av4.xxs.jpg") 50% 20em repeat fixed ; + background: url("/App_Themes/images/p8-av4.s.jpg") 50% 50% no-repeat fixed ; } footer { background: url("/App_Themes/images/helix-nebula-1400x1400.xxs.jpg") 50% 10% repeat fixed ; diff --git a/web/App_Themes/images/p8-av4.s.jpg b/web/App_Themes/images/p8-av4.s.jpg index dadca053..ac046305 100644 Binary files a/web/App_Themes/images/p8-av4.s.jpg and b/web/App_Themes/images/p8-av4.s.jpg differ diff --git a/web/App_Themes/images/p8-av4.xxs.jpg b/web/App_Themes/images/p8-av4.xxs.jpg deleted file mode 100644 index 75a1d010..00000000 Binary files a/web/App_Themes/images/p8-av4.xxs.jpg and /dev/null differ diff --git a/web/App_Themes/images/p8-av4.xxs.png b/web/App_Themes/images/p8-av4.xxs.png deleted file mode 100644 index 629f7bcd..00000000 Binary files a/web/App_Themes/images/p8-av4.xxs.png and /dev/null differ diff --git a/web/ChangeLog b/web/ChangeLog index 2a7ab94b..efacd404 100644 --- a/web/ChangeLog +++ b/web/ChangeLog @@ -1,3 +1,91 @@ +2015-11-28 Paul Schneider + + * p8-av4.xxs.jpg: + * p8-av4.xxs.png: inutile + + * NoLogin.master: + * Entity.cs: + * OAuth2.cs: + * ApiClient.cs: + * PeopleApi.cs: + * MapTracks.cs: + * Skills.aspx: + * CalendarApi.cs: + * EntityQuery.cs: + * GoogleHelpers.cs: + * EventPub.aspx: + * GoogleController.cs: + * SimpleJsonPostMethod.cs: + * UserSkills.aspx: + * BackOfficeController.cs: + * BackOfficeController.cs: refabrication + + * FrontOfficeController.cs: format du code + + * Global.asax.cs: Une route customisée pour le Front Office : + /do (genre, ici, ça bouge.) + + + * activity.sql: implémente en base de donnée le modèle des + activités et compétences, + ajoute aussi deux activités : l'edition logicielle et + "Artiste" + + + * style.css: changement de mes images de fond ... tombées du + camion de Xavier et onlinehome.us + + * p8-av4.s.jpg: changement de taille + + * AccountController.cs: Met le code MEA à "none" quand il est + spécifié non disponible. + + * BlogsController.cs: fixe un bug de l'edition d'un billet + + * FrontOfficeController.cs: implemente le contrôle booking + simple + + * HomeController.cs: ajoute l'assemblage du catalog dans le + listing dédié + + * YavscAjaxHelper.cs: Implemente un outil de representation + JSon des objets côté serveur + + * parallax.js: deux fois plus de mouvement autout de x dans le + parallax + + * yavsc.rate.js: imlemente un callback JS pour le rating + + * Activities.aspx: Des labels au formulaire de déclaration des + activités + + * Activity.ascx: un panneau activité descent + + * Booking.aspx: implemente l'UI web du booking simple. + + * EavyBooking.aspx: refabrication du booking lourd + + * Index.aspx: supprime le panneau du tag Accueil, affiche les + activités en cours du site (avec au moins un préstataire + valide pour cette activité) + + * Web.config: Implemente une cote utilisateur, par une + nouvelle valeur de son profile (Rate). + + + * Yavsc.csproj: refabrique du code API Google, qui part dans + le model. + + * MarkdownDeep.dll: le tag

ne convenait pas, le remplacer + par le tag non plus. + Maintenant ça devrait être correct, c'est un div, mais que en + cas de tag englobant non défini. + + * Skills.sql: vient de passer dans activity.Sql + + * T.cs: la traduction est faite plus simple à appeler (sans + cast vers `string`). + 2015-11-26 Paul Schneider * Yavsc.csproj: nouvelles configurations de diff --git a/web/Controllers/AccountController.cs b/web/Controllers/AccountController.cs index 69bd7815..20beca03 100644 --- a/web/Controllers/AccountController.cs +++ b/web/Controllers/AccountController.cs @@ -262,7 +262,7 @@ namespace Yavsc.Controllers private void SetMEACodeViewData(Profile model) { var activities = WorkFlowManager.FindActivity ("%", false); var items = new List (); - items.Add (new SelectListItem () { Selected = model.MEACode == null, Text = LocalizedText.DoNotPublishMyActivity, Value=null }); + items.Add (new SelectListItem () { Selected = model.MEACode == null, Text = LocalizedText.DoNotPublishMyActivity, Value="none" }); foreach (var a in activities) { items.Add(new SelectListItem() { Selected = model.MEACode == a.Id, Text = string.Format("{1} : {0}",a.Title,a.Id), @@ -271,7 +271,6 @@ namespace Yavsc.Controllers ViewData ["MEACode"] = items; } - ///

/// Profile the specified id, model and AvatarFile. /// diff --git a/web/Controllers/BackOfficeController.cs b/web/Controllers/BackOfficeController.cs index e390c4f7..e028d3a9 100644 --- a/web/Controllers/BackOfficeController.cs +++ b/web/Controllers/BackOfficeController.cs @@ -5,9 +5,9 @@ using System.Web; using System.Web.Mvc; using Yavsc.Admin; using Yavsc.Model.Calendar; -using Yavsc.Helpers.Google; using Yavsc.Model.Circles; using System.Web.Security; +using Yavsc.Model.Google.Api; namespace Yavsc.Controllers diff --git a/web/Controllers/BlogsController.cs b/web/Controllers/BlogsController.cs index 8d52a1c0..c13b1f47 100644 --- a/web/Controllers/BlogsController.cs +++ b/web/Controllers/BlogsController.cs @@ -302,7 +302,7 @@ namespace Yavsc.Controllers Membership.GetUser ().UserName).Select (x => new SelectListItem { Value = x.Id.ToString(), Text = x.Title, - Selected = model.AllowedCircles.Contains (x.Id) + Selected = (model.AllowedCircles==null)? false : model.AllowedCircles.Contains (x.Id) }); return View ("Edit", model); } diff --git a/web/Controllers/FrontOfficeController.cs b/web/Controllers/FrontOfficeController.cs index bc8f0320..9c1e9f82 100644 --- a/web/Controllers/FrontOfficeController.cs +++ b/web/Controllers/FrontOfficeController.cs @@ -17,6 +17,10 @@ using System.Configuration; using Yavsc.Helpers; using Yavsc.Model.FrontOffice.Catalog; using Yavsc.Model.Skill; +using System.Web.Profile; +using Yavsc.Model.Google.Api; +using System.Net; +using System.Linq; namespace Yavsc.Controllers { @@ -33,6 +37,7 @@ namespace Yavsc.Controllers { return View (); } + /// /// Pub the Event /// @@ -42,6 +47,7 @@ namespace Yavsc.Controllers { return View (model); } + /// /// Estimates released to this client /// @@ -53,7 +59,7 @@ namespace Yavsc.Controllers throw new ConfigurationErrorsException ("no redirection to any login page"); string username = u.UserName; - Estimate [] estims = WorkFlowManager.GetUserEstimates (username); + Estimate[] estims = WorkFlowManager.GetUserEstimates (username); ViewData ["UserName"] = username; ViewData ["ResponsibleCount"] = Array.FindAll ( @@ -61,8 +67,8 @@ namespace Yavsc.Controllers x => x.Responsible == username).Length; ViewData ["ClientCount"] = Array.FindAll ( - estims, - x => x.Client == username).Length; + estims, + x => x.Client == username).Length; return View (estims); } @@ -76,7 +82,7 @@ namespace Yavsc.Controllers Estimate f = WorkFlowManager.GetEstimate (id); if (f == null) { ModelState.AddModelError ("Id", "Wrong Id"); - return View (new Estimate () { Id=id } ); + return View (new Estimate () { Id = id }); } return View (f); } @@ -89,9 +95,9 @@ namespace Yavsc.Controllers [Authorize] public ActionResult Estimate (Estimate model, string submit) { - string username = Membership.GetUser().UserName; + string username = Membership.GetUser ().UserName; // Obsolete, set in master page - ViewData ["WebApiBase"] = Url.Content(Yavsc.WebApiConfig.UrlPrefixRelative); + ViewData ["WebApiBase"] = Url.Content (Yavsc.WebApiConfig.UrlPrefixRelative); ViewData ["WABASEWF"] = ViewData ["WebApiBase"] + "/WorkFlow"; if (submit == null) { if (model.Id > 0) { @@ -107,7 +113,7 @@ namespace Yavsc.Controllers && !Roles.IsUserInRole ("FrontOffice")) throw new UnauthorizedAccessException ("You're not allowed to view this estimate"); } else if (model.Id == 0) { - if (string.IsNullOrWhiteSpace(model.Responsible)) + if (string.IsNullOrWhiteSpace (model.Responsible)) model.Responsible = username; } } else { @@ -116,7 +122,7 @@ namespace Yavsc.Controllers if (string.IsNullOrWhiteSpace (model.Responsible)) model.Responsible = username; if (username != model.Responsible - && !Roles.IsUserInRole ("FrontOffice")) + && !Roles.IsUserInRole ("FrontOffice")) throw new UnauthorizedAccessException ("You're not allowed to modify this estimate"); if (ModelState.IsValid) { @@ -172,7 +178,7 @@ namespace Yavsc.Controllers throw new Exception ("No catalog"); var brand = cat.GetBrand (brandid); if (brand == null) - throw new Exception ("Not a brand id: "+brandid); + throw new Exception ("Not a brand id: " + brandid); var pcat = brand.GetProductCategory (pcid); if (pcat == null) throw new Exception ("Not a product category id in this brand: " + pcid); @@ -194,7 +200,7 @@ namespace Yavsc.Controllers ViewData ["ProdRef"] = pref; Catalog cat = CatalogManager.GetCatalog (); if (cat == null) { - YavscHelpers.Notify(ViewData, "Catalog introuvable"); + YavscHelpers.Notify (ViewData, "Catalog introuvable"); ViewData ["RefType"] = "Catalog"; return View ("ReferenceNotFound"); } @@ -236,11 +242,11 @@ namespace Yavsc.Controllers try { // Add specified product command to the basket, // saves it in db - new Command(collection,HttpContext.Request.Files); - YavscHelpers.Notify(ViewData, LocalizedText.Item_added_to_basket); + new Command (collection, HttpContext.Request.Files); + YavscHelpers.Notify (ViewData, LocalizedText.Item_added_to_basket); return View (collection); } catch (Exception e) { - YavscHelpers.Notify(ViewData,"Exception:" + e.Message); + YavscHelpers.Notify (ViewData, "Exception:" + e.Message); return View (collection); } } @@ -257,7 +263,7 @@ namespace Yavsc.Controllers /// /// Skills the specified model. /// - [Authorize(Roles="Admin")] + [Authorize (Roles = "Admin")] public ActionResult Skills (string search) { if (search == null) @@ -266,16 +272,28 @@ namespace Yavsc.Controllers return View (skills); } + /// + /// Performers on this MEA. + /// fr + /// Liste des prestataires dont + /// l'activité principale est celle spécifiée + /// + /// Identifiant APE de l'activité. + public ActionResult Performers (string id) + { + throw new NotImplementedException (); + } + /// /// Activities the specified search and toPower. /// /// Search. /// If set to true to power. - public ActionResult Activities (string search, bool toPower = false) + public ActionResult Activities (string id, bool toPower = false) { - if (search == null) - search = "%"; - var activities = WorkFlowManager.FindActivity(search,!toPower); + if (id == null) + id = "%"; + var activities = WorkFlowManager.FindActivity (id, !toPower); return View (activities); } @@ -283,21 +301,22 @@ namespace Yavsc.Controllers /// Activity at the specified id. ///
/// Identifier. - public ActionResult Activity(string id) + public ActionResult Activity (string id) { - return View(WorkFlowManager.GetActivity (id)); + return View (WorkFlowManager.GetActivity (id)); } + /// /// Display and should /// offer Ajax edition of /// user's skills. /// /// the User name. - [Authorize()] + [Authorize ()] public ActionResult UserSkills (string id) { - if (id == null) - id = User.Identity.Name ; + 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) {} @@ -307,16 +326,132 @@ namespace Yavsc.Controllers return View (usp); } + /// + /// Dates the query. + /// + /// The query. + /// Model. + [Authorize,HttpPost] + public ActionResult Book (BookingQuery model) + { + DateTime mindate = DateTime.Now; + if (model.StartDate.Date < mindate.Date) { + ModelState.AddModelError ("StartDate", LocalizedText.FillInAFutureDate); + } + if (model.EndDate < model.StartDate) + ModelState.AddModelError ("EndDate", LocalizedText.StartDateAfterEndDate); + + if (ModelState.IsValid) { + + var result = new List (); + + foreach (string meacode in model.MEACodes) { + foreach (PerformerProfile profile in WorkFlowManager.FindPerformer(meacode)) { + try { + var events = ProfileBase.Create (profile.UserName).GetEvents (model.StartDate, model.EndDate); + if (events.items.Length == 0) + result.Add (profile); + } catch (WebException ex) { + string response; + using (var stream = ex.Response.GetResponseStream ()) { + using (var reader = new StreamReader (stream)) { + response = reader.ReadToEnd (); + stream.Close (); + } + YavscHelpers.Notify (ViewData, + string.Format ( + "Google calendar API exception {0} : {1}
{2}
", + ex.Status.ToString (), + ex.Message, + response)); + } + } + } + } + return View ("Performers", result.ToArray ()); + } + return View (model); + } + /// /// Booking the specified model. /// + /// MEA Code. /// Model. - public ActionResult Booking (string id, SimpleBookingQuery model) + public ActionResult Booking (SimpleBookingQuery model) { - if (model.Needs == null) - model.Needs = SkillManager.FindSkill ("%"); - model.MAECode = id; + + // In order to present this form + // with no need selected and without + // validation error display, + // we only check the need here, not at validation time. + // Although, the need is indeed cruxial requirement, + // but we already have got a MEA code + if (ModelState.IsValid) + if (model.Needs != null) { + var result = new List (); + foreach (PerformerProfile profile in WorkFlowManager.FindPerformer(model.MEACode)) { + if (profile.HasCalendar ()) { + try { + var events = ProfileBase.Create (profile.UserName) + .GetEvents ( + model.PreferedDate.Date, + model.PreferedDate.AddDays (1).Date); + // TODO replace (events.items.Length == 0) + // with a descent computing of dates and times claims, calendar, + // AND performer preferences, perhaps also client preferences + result.Add (profile.CreateAvailability (model.PreferedDate, (events.items.Length == 0))); + } catch (WebException ex) { + HandleWebException (ex, "Google Calendar Api"); + } + } else + result.Add (profile.CreateAvailability (model.PreferedDate, false)); + + } + return View ("Performers", result.ToArray ()); + } else { + // A first Get + var needs = SkillManager.FindSkill ("%", model.MEACode); + ViewData ["Needs"] = needs; + model.Needs = needs.Select ( + x => string.Format ("{0}:{1}", x.Id, x.Rate)).ToArray (); + } + + var activity = WorkFlowManager.GetActivity (model.MEACode); + ViewData ["Activity"] = activity; + ViewData ["Title"] = activity.Title; + ViewData ["Comment"] = activity.Comment; + ViewData ["Photo"] = activity.Photo; + if (model.PreferedDate < DateTime.Now) + model.PreferedDate = DateTime.Now; return View (model); } + + private void HandleWebException (WebException ex, string context) + { + + string response = ""; + using (var stream = ex.Response.GetResponseStream ()) { + if (stream.CanRead) { + var reader = new StreamReader (stream); + response = reader.ReadToEnd (); + reader.Close (); + reader.DiscardBufferedData (); + reader.Dispose (); + } + stream.Close (); + stream.Dispose (); + + } + YavscHelpers.Notify (ViewData, + string.Format ( + "{3} exception {0} : {1}
{2}
", + ex.Status.ToString (), + ex.Message, + response, + context + )); + } + } } diff --git a/web/Controllers/GoogleController.cs b/web/Controllers/GoogleController.cs index 7d8ae296..a75b552b 100644 --- a/web/Controllers/GoogleController.cs +++ b/web/Controllers/GoogleController.cs @@ -15,9 +15,12 @@ using Newtonsoft.Json; using Yavsc.Model; using Yavsc.Model.Google; using Yavsc.Model.RolesAndMembers; -using Yavsc.Helpers.Google; using Yavsc.Model.Calendar; using Yavsc.Helpers; +using Yavsc.Model.WorkFlow; +using Yavsc.Model.FrontOffice; +using Yavsc.Model.Google.Api; +using Yavsc.Model.Skill; namespace Yavsc.Controllers { @@ -303,44 +306,10 @@ namespace Yavsc.Controllers return View (model); } - /// - /// Dates the query. - /// - /// The query. - /// Model. - [Authorize,HttpPost] - public ActionResult Book (BookingQuery model) + + + public ActionResult Book (SimpleBookingQuery model) { - DateTime mindate = DateTime.Now; - if (model.StartDate.Date < mindate.Date){ - ModelState.AddModelError ("StartDate", LocalizedText.FillInAFutureDate); - } - if (model.EndDate < model.StartDate) - ModelState.AddModelError ("EndDate", LocalizedText.StartDateAfterEndDate); - - if (ModelState.IsValid) { - foreach (string rolename in model.Roles) { - foreach (string username in Roles.GetUsersInRole(rolename)) { - try { - var pr = ProfileBase.Create(username); - var events = pr.GetEvents(model.StartDate,model.EndDate); - } catch (WebException ex) { - string response; - using (var stream = ex.Response.GetResponseStream()) - using (var reader = new StreamReader(stream)) - { - response = reader.ReadToEnd(); - } - YavscHelpers.Notify (ViewData, - string.Format( - "Google calendar API exception {0} : {1}
{2}
", - ex.Status.ToString(), - ex.Message, - response)); - } - } - } - } return View (model); } } diff --git a/web/Controllers/HomeController.cs b/web/Controllers/HomeController.cs index 674fbd70..5b0ff763 100644 --- a/web/Controllers/HomeController.cs +++ b/web/Controllers/HomeController.cs @@ -15,6 +15,8 @@ using Yavsc; using System.Web.Mvc; using Yavsc.Model.Blogs; using Yavsc.Model.WorkFlow; +using Yavsc.WebControls; +using SalesCatalog.XmlImplementation; namespace Yavsc.Controllers { @@ -47,10 +49,13 @@ namespace Yavsc.Controllers { Assembly[] aslist = { GetType ().Assembly, + typeof(BlogsController).Assembly, typeof(ITCPNpgsqlProvider).Assembly, typeof(NpgsqlMembershipProvider).Assembly, typeof(NpgsqlContentProvider).Assembly, - typeof(NpgsqlBlogProvider).Assembly + typeof(NpgsqlBlogProvider).Assembly, + typeof(InputUserName).Assembly, + typeof(XmlCatalog).Assembly }; List asnlist = new List (); diff --git a/web/Helpers/Google/ApiClient.cs b/web/Helpers/Google/ApiClient.cs deleted file mode 100644 index 6c4ca425..00000000 --- a/web/Helpers/Google/ApiClient.cs +++ /dev/null @@ -1,78 +0,0 @@ -// -// Manager.cs -// -// Author: -// Paul Schneider -// -// Copyright (c) 2015 Paul Schneider -// -// 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 . - -using System; -using Yavsc.Helpers; -using System.Web.Profile; -using Yavsc.Model.Google; -using System.Net; -using System.IO; -using System.Text; -using Newtonsoft.Json; - -namespace Yavsc.Helpers.Google -{ - /// - /// Google base API client. - /// This class implements the identification values for a Google Api, - /// and provides some scope values. - /// - public class ApiClient - { - /// - /// The CLIENT Id. - /// - public static string CLIENT_ID { get ; set ; } - - /// - /// The CLIENt SECREt - /// - public static string CLIENT_SECRET { get ; set ; } - - /// - /// The API KEY. - /// - public static string API_KEY { get ; set ; } - /* // to use in descendence - * - protected static string getPeopleUri = "https://www.googleapis.com/plus/v1/people"; - private static string authUri = "https://accounts.google.com/o/oauth2/auth"; - */ - /// - /// The Map tracks scope . - /// - protected static string scopeTracks = "https://www.googleapis.com/auth/tracks"; - /// - /// The calendar scope. - /// - protected static string scopeCalendar = "https://www.googleapis.com/auth/calendar"; - - /// - /// The scope openid. - /// - protected static string[] scopeOpenid = { - "openid", - "profile", - "email" - }; - } - -} diff --git a/web/Helpers/Google/CalendarApi.cs b/web/Helpers/Google/CalendarApi.cs deleted file mode 100644 index a0d5d1cf..00000000 --- a/web/Helpers/Google/CalendarApi.cs +++ /dev/null @@ -1,134 +0,0 @@ -// -// Calendar.cs -// -// Author: -// Paul Schneider -// -// Copyright (c) 2015 Paul Schneider -// -// 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 . - -using System; -using Yavsc.Helpers; -using System.Web.Profile; -using Yavsc.Model.Google; -using System.Net; -using System.IO; -using System.Text; -using Newtonsoft.Json; -using System.Web; -using System.Runtime.Serialization.Json; -using Yavsc.Model; - -namespace Yavsc.Helpers.Google -{ - /// - /// Google Calendar API client. - /// - public class CalendarApi : ApiClient - { - public CalendarApi(string apiKey) - { - API_KEY = apiKey; - } - /// - /// The get cal list URI. - /// - protected static string getCalListUri = "https://www.googleapis.com/calendar/v3/users/me/calendarList"; - /// - /// The get cal entries URI. - /// - protected static string getCalEntriesUri = "https://www.googleapis.com/calendar/v3/calendars/{0}/events"; - - /// - /// The date format. - /// - private static string dateFormat = "yyyy-MM-ddTHH:mm:ss"; - - /// - /// The time zone. TODO Fixme with machine time zone - /// - private string timeZone = "+01:00"; - - /// - /// Gets the calendar list. - /// - /// The calendars. - /// Cred. - public CalendarList GetCalendars (string cred) - { - CalendarList res = null; - HttpWebRequest webreq = WebRequest.CreateHttp (getCalListUri); - webreq.Headers.Add (HttpRequestHeader.Authorization, cred); - webreq.Method = "GET"; - webreq.ContentType = "application/http"; - using (WebResponse resp = webreq.GetResponse ()) { - using (Stream respstream = resp.GetResponseStream ()) { - res = (CalendarList) new DataContractJsonSerializer(typeof(CalendarList)).ReadObject (respstream); - } - resp.Close (); - } - webreq.Abort (); - return res; - } - - /// - /// Gets a calendar. - /// - /// The calendar. - /// Calid. - /// Mindate. - /// Maxdate. - /// Upr. - public CalendarEventList GetCalendar (string calid, DateTime mindate, DateTime maxdate,string cred) - { - if (string.IsNullOrWhiteSpace (calid)) - throw new Exception ("the calendar identifier is not specified"); - - string uri = string.Format ( - getCalEntriesUri, HttpUtility.UrlEncode (calid)) + - string.Format ("?orderBy=startTime&singleEvents=true&timeMin={0}&timeMax={1}&key=" + API_KEY, - HttpUtility.UrlEncode (mindate.ToString (dateFormat) + timeZone), - HttpUtility.UrlEncode (maxdate.ToString (dateFormat) + timeZone)); - - HttpWebRequest webreq = WebRequest.CreateHttp (uri); - - webreq.Headers.Add (HttpRequestHeader.Authorization, cred); - webreq.Method = "GET"; - webreq.ContentType = "application/http"; - CalendarEventList res = null; - try { - using (WebResponse resp = webreq.GetResponse ()) { - using (Stream respstream = resp.GetResponseStream ()) { - try { - res = (CalendarEventList) new DataContractJsonSerializer(typeof(CalendarEventList)).ReadObject (respstream); - } catch (Exception ) { - respstream.Close (); - resp.Close (); - webreq.Abort (); - throw ; - } - } - resp.Close (); - } - } catch (WebException ) { - webreq.Abort (); - throw; - } - webreq.Abort (); - return res; - } - - } -} diff --git a/web/Helpers/Google/Entity.cs b/web/Helpers/Google/Entity.cs deleted file mode 100644 index 73ee123f..00000000 --- a/web/Helpers/Google/Entity.cs +++ /dev/null @@ -1,56 +0,0 @@ -// -// Entity.cs -// -// Author: -// Paul Schneider -// -// Copyright (c) 2015 Paul Schneider -// -// 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 . - -using System; -using Yavsc.Helpers; -using System.Web.Profile; -using Yavsc.Model.Google; -using System.Net; -using System.IO; -using System.Text; -using Newtonsoft.Json; - -namespace Yavsc.Helpers.Google -{ - /// - /// Entity. - /// - public class Entity - { - /// - /// The I. - /// - public string ID; - /// - /// The name. - /// - public string Name; - - /// - /// The type: AUTOMOBILE: A car or passenger vehicle. - /// * TRUCK: A truck or cargo vehicle. - /// * WATERCRAFT: A boat or other waterborne vehicle. - /// * PERSON: A person. - /// - public string Type; - } - -} diff --git a/web/Helpers/Google/EntityQuery.cs b/web/Helpers/Google/EntityQuery.cs deleted file mode 100644 index 9b393e7f..00000000 --- a/web/Helpers/Google/EntityQuery.cs +++ /dev/null @@ -1,46 +0,0 @@ -// -// EntityQuery.cs -// -// Author: -// Paul Schneider -// -// Copyright (c) 2015 Paul Schneider -// -// 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 . - -using System; -using Yavsc.Helpers; -using System.Web.Profile; -using Yavsc.Model.Google; -using System.Net; -using System.IO; -using System.Text; -using Newtonsoft.Json; - -namespace Yavsc.Helpers.Google -{ - /// - /// Entity query. - /// - public class EntityQuery { - /// - /// The entity identifiers. - /// - public string [] EntityIds; - /// - /// The minimum identifier. - /// - public string MinId; - } -} diff --git a/web/Helpers/Google/GoogleHelpers.cs b/web/Helpers/Google/GoogleHelpers.cs deleted file mode 100644 index fc71aa5a..00000000 --- a/web/Helpers/Google/GoogleHelpers.cs +++ /dev/null @@ -1,137 +0,0 @@ -// -// GoogleHelpers.cs -// -// Author: -// Paul Schneider -// -// 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 . -using System; -using Yavsc.Model.Google; -using System.Web.Profile; -using System.Configuration; -using System.Web; -using Yavsc.Model.Calendar; -using Yavsc.Model.Circles; -using System.Collections.Generic; -using System.Web.Security; - -namespace Yavsc.Helpers.Google -{ - /// - /// Google helpers. - /// - public static class GoogleHelpers - { - /// - /// Gets the events. - /// - /// The events. - /// Profile. - /// Mindate. - /// Maxdate. - public static CalendarEventList GetEvents(this ProfileBase profile, DateTime mindate, DateTime maxdate) - { - string gcalid = (string) profile.GetPropertyValue ("gcalid"); - if (string.IsNullOrWhiteSpace (gcalid)) - throw new ArgumentException ("NULL gcalid"); - CalendarApi c = new CalendarApi (clientApiKey); - string creds = OAuth2.GetFreshGoogleCredential (profile); - return c.GetCalendar (gcalid, mindate, maxdate, creds); - } - /// - /// Gets the calendars. - /// - /// The calendars. - /// Profile. - public static CalendarList GetCalendars (this ProfileBase profile) - { - string cred = OAuth2.GetFreshGoogleCredential (profile); - CalendarApi c = new CalendarApi (clientApiKey); - return c.GetCalendars (cred); - } - - private static string clientId = ConfigurationManager.AppSettings ["GOOGLE_CLIENT_ID"]; - private static string clientSecret = ConfigurationManager.AppSettings ["GOOGLE_CLIENT_SECRET"]; - private static string clientApiKey = ConfigurationManager.AppSettings ["GOOGLE_API_KEY"]; - /// - /// Login the specified response, state and callBack. - /// - /// Response. - /// State. - /// Call back. - public static void Login(this HttpResponseBase response, string state, string callBack) - { - OAuth2 oa = new OAuth2 (callBack, clientId,clientSecret); - oa.Login (response, state); - } - /// - /// Cals the login. - /// - /// Response. - /// State. - /// Call back. - public static void CalLogin(this HttpResponseBase response, string state, string callBack) - { - OAuth2 oa = new OAuth2 (callBack,clientId,clientSecret); - oa.GetCalendarScope (response, state); - } - /// - /// Creates the O auth2. - /// - /// The O auth2. - /// Call back. - public static OAuth2 CreateOAuth2(string callBack) - { - return new OAuth2 (callBack,clientId,clientSecret); - } - - /// - /// Notifies the event. - /// - /// The event. - /// Evpub. - public static MessageWithPayloadResponse NotifyEvent(EventPub evpub) { - using (SimpleJsonPostMethod,MessageWithPayloadResponse> r = - new SimpleJsonPostMethod,MessageWithPayloadResponse>( - "https://gcm-http.googleapis.com/gcm/send")) { - var users = Circle.Union (evpub.CircleIds); - var regids = new List (); - var to = new List (); - foreach (var u in users) { - var p = ProfileBase.Create (u); - if (p != null) { - var regid = p.GetPropertyValue("gregid"); - if (regid == null) { - var muser = Membership.GetUser (u); - to.Add (muser.Email); - } - else regids.Add ((string)regid); - } - } - if (regids.Count == 0) - throw new InvalidOperationException - ("No recipient where found for this circle list"); - - var msg = new MessageWithPayload () { - notification = new Notification() { title = evpub.Title, body = evpub.Description, icon = "event" }, - data = new YaEvent[] { (YaEvent)evpub }, registration_ids = regids.ToArray() }; - return r.Invoke (msg); - } - } - - } -} - diff --git a/web/Helpers/Google/MapTracks.cs b/web/Helpers/Google/MapTracks.cs deleted file mode 100644 index 388e40c2..00000000 --- a/web/Helpers/Google/MapTracks.cs +++ /dev/null @@ -1,81 +0,0 @@ -// -// Google.cs -// -// Author: -// Paul Schneider -// -// Copyright (c) 2015 Paul Schneider -// -// 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 . -using System; -using Yavsc.Helpers; -using System.Web.Profile; -using Yavsc.Model.Google; -using System.Net; -using System.IO; -using System.Text; -using Newtonsoft.Json; - -namespace Yavsc.Helpers.Google -{ - /// - /// Google Map tracks Api client. - /// - public class MapTracks:ApiClient { - - /// - /// The google map tracks path (uri of the service). - /// - protected static string googleMapTracksPath = "https://www.googleapis.com/tracks/v1/"; - // entities/[create|list|delete] - // collections/[list|create|[add|remove]entities|delete] - // crumbs/[record|getrecent|gethistory|report|summarize|getlocationinfo|delete - - - // entities/[create|list|delete] - // collections/[list|create|[add|remove]entities|delete] - // crumbs/[record|getrecent|gethistory|report|summarize|getlocationinfo|delete - - /// - /// Creates the entity. - /// - /// The entity. - /// Entities. - public static string [] CreateEntity( Entity[] entities ) { - string [] ans = null; - using (SimpleJsonPostMethod< Entity[] ,string []> wr = - new SimpleJsonPostMethod< Entity[] ,string[]> (googleMapTracksPath + "entities/create")) - { - ans = wr.Invoke (entities); - } - return ans; - } - - /// - /// Lists the entities. - /// - /// The entities. - /// Eq. - static Entity[] ListEntities (EntityQuery eq) - { - Entity [] ans = null; - using (SimpleJsonPostMethod wr = - new SimpleJsonPostMethod (googleMapTracksPath + "entities/create")) - { - ans = wr.Invoke (eq); - } - return ans; - } - } -} diff --git a/web/Helpers/Google/OAuth2.cs b/web/Helpers/Google/OAuth2.cs deleted file mode 100644 index aae35812..00000000 --- a/web/Helpers/Google/OAuth2.cs +++ /dev/null @@ -1,252 +0,0 @@ -// -// OAuth2.cs -// -// Author: -// Paul Schneider -// -// Copyright (c) 2015 Paul Schneider -// -// 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 . -using System; -using System.IO; -using System.Net; -using System.Text; -using Newtonsoft.Json; -using Yavsc.Model.Google; -using System.Web.Profile; -using System.Web; -using Yavsc.Model; -using System.Runtime.Serialization.Json; -using Yavsc.Helpers.Google; - -namespace Yavsc.Helpers.Google -{ - - /// - /// Google O auth2 client. - /// - public class OAuth2 : ApiClient - { - /// - /// The URI used to get tokens. - /// - protected static string tokenUri = "https://accounts.google.com/o/oauth2/token"; - - /// - /// The URI used to get authorized to. - /// - protected static string authUri = "https://accounts.google.com/o/oauth2/auth"; - - /// - /// Gets or sets the redirect URI sent to Google. - /// - /// The redirect URI. - public string RedirectUri { get; set; } - - /// - /// Initializes a new instance of the class. - /// - /// Redirect URI. - /// Client identifier. - /// Client secret. - public OAuth2 (string redirectUri, string clientId, string clientSecret) - { - RedirectUri = redirectUri; - CLIENT_ID = clientId; - CLIENT_SECRET = clientSecret; - } - - /// - /// Login with Google - /// by redirecting the specified http web response bresp, - /// and using the specified session state. - /// - /// Bresp. - /// State. - public void Login (HttpResponseBase bresp, string state) - { - string scope = string.Join ("%20", scopeOpenid); - - string prms = String.Format ("response_type=code&client_id={0}&redirect_uri={1}&scope={2}&state={3}&include_granted_scopes=false&approval_prompt=force", - CLIENT_ID, RedirectUri, scope, state); - GetAuthResponse (bresp, prms); - } - - /// - /// Gets the cal authorization. - /// - /// Bresp. - /// State. - public void GetCalendarScope (HttpResponseBase bresp, string state) - { - string prms = String.Format ("response_type=code&client_id={0}&redirect_uri={1}&scope={2}&state={3}&include_granted_scopes=true&access_type=offline&approval_prompt=force", - CLIENT_ID, RedirectUri, scopeCalendar, state); - GetAuthResponse (bresp, prms); - } - - private void GetAuthResponse (HttpResponseBase bresp, string prms) - { - string cont = null; - WebRequest wr = WebRequest.Create (authUri + "?" + prms); - wr.Method = "GET"; - using (WebResponse response = wr.GetResponse ()) { - string resQuery = response.ResponseUri.Query; - cont = HttpUtility.ParseQueryString (resQuery) ["continue"]; - response.Close (); - } - wr.Abort (); - bresp.Redirect (cont); - } - - /// - /// Builds the post data, from code given - /// by Google in the request parameters, - /// and using the given redirectUri. - /// This request body is used to get a new - /// OAuth2 token from Google, it is Url encoded. - /// - /// The post data from code. - /// Redirect URI. - /// Code. - public static string TokenPostDataFromCode (string redirectUri, string code) - { - string postdata = - string.Format ( - "redirect_uri={0}&client_id={1}&client_secret={2}&code={3}&grant_type=authorization_code", - HttpUtility.UrlEncode (redirectUri), - HttpUtility.UrlEncode (CLIENT_ID), - HttpUtility.UrlEncode (CLIENT_SECRET), - HttpUtility.UrlEncode (code)); - return postdata; - } - - /// - /// Gets the Google Authorization token. - /// - /// The token. - /// Rq. - /// State. - /// Message. - public AuthToken GetToken (HttpRequestBase rq, string state, out string message) - { - string code = OAuth2.GetCodeFromRequest (rq, state, out message); - string postdata = OAuth2.TokenPostDataFromCode (RedirectUri, code); - return GetTokenPosting (postdata); - } - - internal static AuthToken GetTokenPosting (string postdata) - { - HttpWebRequest webreq = WebRequest.CreateHttp (tokenUri); - webreq.Method = "POST"; - webreq.Accept = "application/json"; - webreq.ContentType = "application/x-www-form-urlencoded"; - Byte[] bytes = System.Text.Encoding.UTF8.GetBytes (postdata); - webreq.ContentLength = bytes.Length; - - using (Stream dataStream = webreq.GetRequestStream ()) { - dataStream.Write (bytes, 0, bytes.Length); - dataStream.Close (); - } - - AuthToken gat = null; - using (WebResponse response = webreq.GetResponse ()) { - using (Stream responseStream = response.GetResponseStream ()) { - gat = (AuthToken)new DataContractJsonSerializer (typeof(AuthToken)).ReadObject (responseStream); - responseStream.Close (); - } - response.Close (); - } - webreq.Abort (); - return gat; - } - - /// - /// Gets the code from the Google request. - /// - /// The code from request. - /// Rq. - /// State. - /// Message. - public static string GetCodeFromRequest (HttpRequestBase rq, string state, out string message) - { - message = ""; - string code = rq.Params ["code"]; - string error = rq.Params ["error"]; - if (error != null) { - message = - string.Format (LocalizedText.Google_error, - LocalizedText.ResourceManager.GetString (error)); - return null; - } - string rqstate = rq.Params ["state"]; - if (state != null && string.Compare (rqstate, state) != 0) { - message = - LocalizedText.ResourceManager.GetString ("invalid request state"); - return null; - } - return code; - } - - /// - /// Invalid O auth2 refresh token. - /// - public class InvalidOAuth2RefreshToken: Exception - { - /// - /// Initializes a new instance of the class. - /// - /// Message. - public InvalidOAuth2RefreshToken(string message):base(message) - { - } - /// - /// Initializes a new instance of the class. - /// - /// Message. - /// Inner exception. - public InvalidOAuth2RefreshToken(string message,Exception innerException):base(message,innerException) - { - } - } - - /// - /// Gets fresh google credential. - /// - /// The fresh google credential. - /// Pr. - public static string GetFreshGoogleCredential (ProfileBase pr) - { - string token = (string)pr.GetPropertyValue ("gtoken"); - string token_type = (string) pr.GetPropertyValue ("gtokentype"); - DateTime token_exp = (DateTime) pr.GetPropertyValue ("gtokenexpir"); - if (token_exp < DateTime.Now) { - object ort = pr.GetPropertyValue ("grefreshtoken"); - if (ort is DBNull || string.IsNullOrWhiteSpace((string)ort)) { - throw new InvalidOAuth2RefreshToken ("Google"); - } - string refresh_token = ort as string; - AuthToken gat = OAuth2.GetTokenPosting ( - string.Format ("grant_type=refresh_token&client_id={0}&client_secret={1}&refresh_token={2}", - CLIENT_ID, CLIENT_SECRET, refresh_token)); - token = gat.access_token; - pr.SetPropertyValue ("gtoken", token); - pr.Save (); - // ASSERT gat.token_type == pr.GetPropertyValue("gtokentype") - } - return token_type + " " + token; - } - - } -} - diff --git a/web/Helpers/Google/PeopleApi.cs b/web/Helpers/Google/PeopleApi.cs deleted file mode 100644 index 791fd07b..00000000 --- a/web/Helpers/Google/PeopleApi.cs +++ /dev/null @@ -1,68 +0,0 @@ -// -// PeopleApi.cs -// -// Author: -// Paul Schneider -// -// 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 . - -using System; -using System.IO; -using System.Net; -using System.Text; -using Newtonsoft.Json; -using Yavsc.Model.Google; -using System.Web.Profile; -using System.Web; -using Yavsc.Model; -using System.Runtime.Serialization.Json; -using Yavsc.Helpers.Google; - -namespace Yavsc.Helpers.Google -{ - /// - /// Google People API. - /// - public class PeopleApi: ApiClient - { - private static string getPeopleUri = "https://www.googleapis.com/plus/v1/people"; - - /// - /// Gets the People object associated to the given Google Access Token - /// - /// The me. - /// The Google Access Token object class. - public static People GetMe (AuthToken gat) - { - People me; - DataContractJsonSerializer ppser = new DataContractJsonSerializer (typeof(People)); - HttpWebRequest webreppro = WebRequest.CreateHttp (getPeopleUri + "/me"); - webreppro.ContentType = "application/http"; - webreppro.Headers.Add (HttpRequestHeader.Authorization, gat.token_type + " " + gat.access_token); - webreppro.Method = "GET"; - using (WebResponse proresp = webreppro.GetResponse ()) { - using (Stream prresponseStream = proresp.GetResponseStream ()) { - me = (People)ppser.ReadObject (prresponseStream); - prresponseStream.Close (); - } - proresp.Close (); - } - webreppro.Abort (); - return me; - } - } - -} diff --git a/web/Helpers/SimpleJsonPostMethod.cs b/web/Helpers/SimpleJsonPostMethod.cs deleted file mode 100644 index 76071852..00000000 --- a/web/Helpers/SimpleJsonPostMethod.cs +++ /dev/null @@ -1,108 +0,0 @@ -// -// PostJson.cs -// -// Author: -// Paul Schneider -// -// Copyright (c) 2015 Paul Schneider -// -// 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 . -using System; -using System.Net; -using System.Text; -using System.IO; -using System.Runtime.Serialization.Json; - -namespace Yavsc.Helpers -{ - /// - /// Simple json post method. - /// - public class SimpleJsonPostMethod: IDisposable - { - internal HttpWebRequest request = null; - internal HttpWebRequest Request { get { return request; } } - - string CharSet { - get { return Request.TransferEncoding; } - set { Request.TransferEncoding=value;} - } - string Method { get { return Request.Method; } } - /// - /// Gets the path. - /// - /// The path. - public string Path { - get{ return Request.RequestUri.ToString(); } - } - /// - /// Sets the credential. - /// - /// Cred. - public void SetCredential(string cred) { - Request.Headers.Set(HttpRequestHeader.Authorization,cred); - } - - /// - /// Initializes a new instance of the Yavsc.Helpers.SimpleJsonPostMethod class. - /// - /// Path to method. - public SimpleJsonPostMethod (string pathToMethod) - { - // ASSERT Request == null - request = WebRequest.CreateHttp (pathToMethod); - - Request.Method = "POST"; - Request.Accept = "application/json"; - Request.ContentType = "application/json"; - Request.SendChunked = true; - Request.TransferEncoding = "UTF-8"; - } - /// - /// Invoke the specified query. - /// - /// Query. - public TAnswer Invoke(TQuery query) - { - - DataContractJsonSerializer serquery = new DataContractJsonSerializer (typeof(TQuery)); - DataContractJsonSerializer seransw = new DataContractJsonSerializer (typeof(TAnswer)); - - using (MemoryStream streamQuery = new MemoryStream ()) { - serquery.WriteObject (streamQuery, query); - } - - TAnswer ans = default (TAnswer); - using (WebResponse response = Request.GetResponse ()) { - using (Stream responseStream = response.GetResponseStream ()) { - ans = (TAnswer) seransw.ReadObject(responseStream); - } - response.Close(); - } - return ans; - } - - #region IDisposable implementation - - /// - /// Releases all resource used by the Yavsc.Helpers.SimpleJsonPostMethod object. - /// - public void Dispose () - { - if (Request != null) Request.Abort (); - } - #endregion - } -} - diff --git a/web/Helpers/T.cs b/web/Helpers/T.cs index 36428a98..4261a9f4 100644 --- a/web/Helpers/T.cs +++ b/web/Helpers/T.cs @@ -33,10 +33,10 @@ namespace Yavsc.Helpers /// /// Helper. /// Text. - public static IHtmlString Translate(this HtmlHelper helper, string text) + public static IHtmlString Translate(this HtmlHelper helper, object text) { // Just call the other one, to avoid having two copies (we don't use the HtmlHelper). - return new MvcHtmlString(helper.Encode(GetString(text))); + return new MvcHtmlString(helper.Encode(GetString((string)text))); } } diff --git a/web/Helpers/YavscAjaxHelper.cs b/web/Helpers/YavscAjaxHelper.cs index d7dedfd2..642a52f6 100644 --- a/web/Helpers/YavscAjaxHelper.cs +++ b/web/Helpers/YavscAjaxHelper.cs @@ -22,6 +22,9 @@ using System; using System.Web.Mvc; using System.Collections.Generic; using Yavsc.Model.Messaging; +using System.Runtime.Serialization.Json; +using System.IO; +using System.Text; namespace Yavsc.Helpers { @@ -61,10 +64,36 @@ namespace Yavsc.Helpers return "\"" + tmpstr + "\""; return "'" + tmpstr + "'"; } + /// + /// Js the son string. + /// + /// The son string. + /// Helper. + /// Object. + public static string JSonString(this AjaxHelper helper, object obj) + { + string result = null; + DataContractJsonSerializer ser = new DataContractJsonSerializer (obj.GetType()); + var e = Encoding.UTF8; + using (MemoryStream streamQuery = new MemoryStream ()) { + ser.WriteObject (streamQuery, obj); + streamQuery.Seek (0, SeekOrigin.Begin); + using (StreamReader sr = new StreamReader (streamQuery)) { + result = sr.ReadToEnd (); + } + } + return result; + } - public static string JString(this AjaxHelper helper, object str) + /// + /// Js the string. + /// + /// The string. + /// Helper. + /// Text. + public static string JString(this AjaxHelper helper, object text) { - return QuoteJavascriptString (str); + return QuoteJavascriptString ((string)text); } } } diff --git a/web/Models/NoLogin.master b/web/Models/NoLogin.master index 522b627f..284ba7ea 100644 --- a/web/Models/NoLogin.master +++ b/web/Models/NoLogin.master @@ -24,7 +24,7 @@ Page.StyleSheetTheme = (string) Profile.UITheme; %> <%=Ajax.GlobalizationScript()%> diff --git a/web/Scripts/parallax.js b/web/Scripts/parallax.js index 23e47bdf..e540c027 100644 --- a/web/Scripts/parallax.js +++ b/web/Scripts/parallax.js @@ -85,7 +85,7 @@ $(document).ready(function(){ if ($stwidth>320 && $stheight>320) { window.addEventListener('deviceorientation', function(event) { tiltLR = $stwidth*Math.sin(event.gamma*Math.PI/180); - titleFB = $stheight*Math.sin(event.beta*Math.PI/180); + titleFB = $stheight*Math.sin(event.beta*Math.PI/90); onPos($bgobj,tiltLR,titleFB); },false); } $(window).mousemove(function(e) { diff --git a/web/Scripts/yavsc.rate.js b/web/Scripts/yavsc.rate.js index febdc9a7..49fdb3c1 100644 --- a/web/Scripts/yavsc.rate.js +++ b/web/Scripts/yavsc.rate.js @@ -2,11 +2,16 @@ (function(jQuery) { return jQuery.widget('Yavsc.rate', { options: { - target: null, + webTarget: null, + jsTarget: null, disabled: false }, sendRate: function (rating,callback) { - Yavsc.ajax(this.options.target+'/Rate', rating, callback); + if (this.options.webTarget) + Yavsc.ajax(this.options.webTarget+'/Rate', rating, callback); + if (this.options.jsTarget) + if (this.options.jsTarget(rating)) + if (callback) callback(); }, _create: function() { var $ratectl = $(this.element); diff --git a/web/Views/FrontOffice/Activities.aspx b/web/Views/FrontOffice/Activities.aspx index 4f0852e3..ca84bedb 100644 --- a/web/Views/FrontOffice/Activities.aspx +++ b/web/Views/FrontOffice/Activities.aspx @@ -11,9 +11,12 @@