* avatar, username, city from Google profile

* refactoring
This commit is contained in:
Paul Schneider 2014-12-20 02:11:51 +01:00
commit c7f81699a4
55 changed files with 706 additions and 351 deletions

View file

@ -0,0 +1,64 @@
//
// GoogleAuthToken.cs
//
// Author:
// Paul Schneider <paulschneider@free.fr>
//
// Copyright (c) 2014 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 <http://www.gnu.org/licenses/>.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Threading;
using System.Web.Mvc;
using System.Configuration;
using System.Threading.Tasks;
using System.Text;
using System.Net;
using System.IO;
using Yavsc.Model;
namespace Yavsc.Model.Google
{
/*
"url": "https://plus.google.com/111395572362177872801",
"image": {
"url": "https://lh6.googleusercontent.com/-JqDVMPqafdA/AAAAAAAAAAI/AAAAAAAAADY/FamseW6_nl4/photo.jpg?sz=50",
"isDefault": false
},
"placesLived": [
{
"value": "Suresnes, France",
"primary": true
}
],
"isPlusUser": true,
"language": "fr",
"circledByCount": 0,
"verified": false
}
*/
public class AuthToken {
public string access_token { get; set; }
public string id_token { get; set; }
public int expires_in { get; set; }
public string token_type { get; set ; }
public string refresh_token { get; set; }
}
}

View file

@ -0,0 +1,70 @@
//
// People.cs
//
// Author:
// Paul Schneider <paulschneider@free.fr>
//
// Copyright (c) 2014 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 <http://www.gnu.org/licenses/>.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Threading;
using System.Web.Mvc;
using System.Configuration;
using System.Threading.Tasks;
using System.Text;
using System.Net;
using System.IO;
using Yavsc.Model;
namespace Yavsc.Model.Google
{
public class People {
public string kind { get; set; }
public string etag { get; set; }
public string gender { get; set; }
public class EMail{
public string value { get; set; }
public string type { get; set; }
}
public EMail[] emails { get; set; }
public string objectType { get; set; }
public string id { get; set; }
public string displayName { get; set; }
public class Name {
public string familyName { get; set; }
public string givenName { get; set; }
}
public Name name { get; set;}
public string url { get; set; }
public class Image {
public string url { get; set; }
public bool isDefault { get; set; }
}
public Image image { get; set; }
public class Place {
public string value { get; set; }
public bool primary { get; set; }
}
public Place[] placesLived { get; set; }
public bool isPlusUser { get; set; }
public string language { get; set; }
public int circledByCount { get; set; }
public bool verified { get; set; }
}
}

View file

@ -0,0 +1,35 @@
//
// SignIn.cs
//
// Author:
// Paul Schneider <paulschneider@free.fr>
//
// Copyright (c) 2014 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 <http://www.gnu.org/licenses/>.
using System;
namespace Yavsc.Model.Google
{
public class SignIn
{
public string UserName { get; set; }
public string Email { get; set; }
public SignIn ()
{
}
}
}

View file

@ -2,6 +2,7 @@
using System.Configuration;
using System.Collections.Specialized;
using System.Data;
using System.Web.Mvc;
namespace Yavsc.Model
{
@ -19,18 +20,14 @@ namespace Yavsc.Model
/// <param name="cnx">Cnx.</param>
/// <param name="removeConfig">If set to <c>true</c> remove config.</param>
void Uninstall(IDbConnection cnx,bool removeConfig);
ConfigurationSection DefaultConfig (string appName, string cnxStr);
/// <summary>
/// Gets or sets a value indicating whether this <see cref="Yavsc.Model.IModule"/> is active.
/// </summary>
/// <value><c>true</c> if active; otherwise, <c>false</c>.</value>
bool Active { get; set; }
/// <summary>
/// Gets or sets the name of the application.
/// </summary>
/// <value>The name of the application.</value>
string ApplicationName { get; set; }
void Initialize (string name, NameValueCollection config);
}
public interface IRenderer {
// Should set ViewData["Message|Author|Body"]
object Get(Controller c);
string Template { get; }
string Name { get; set; }
}
}

View file

@ -112,6 +112,12 @@ namespace Yavsc.Model {
}
}
public static string UserName {
get {
return ResourceManager.GetString("UserName", resourceCulture);
}
}
public static string Offline {
get {
return ResourceManager.GetString("Offline", resourceCulture);

View file

@ -32,4 +32,5 @@
<data name="User_name"><value>Nom d'utilisateur</value></data>
<data name="Google_error"><value>Erreur Google : {0}</value></data>
<data name="access_denied"><value>Accès refusé</value></data>
<data name="UserName"><value>Nom d'utilisateur</value></data>
</root>

View file

@ -32,4 +32,5 @@
<data name="User_name"><value>User name</value></data>
<data name="Google_error"><value>Google error : {0}</value></data>
<data name="access_denied"><value>Access denied</value></data>
<data name="UserName"><value>User name</value></data>
</root>

View file

@ -12,6 +12,9 @@ namespace Yavsc.Model.RolesAndMembers
[StringLength (1024)]
public string Name { get; set; }
[DisplayName("Avatar")]
public string avatar { get; set; }
[DisplayName ("Adresse")]
[StringLength (2047)]
public string Address { get; set; }
@ -75,6 +78,9 @@ namespace Yavsc.Model.RolesAndMembers
[DisplayName ("Clé RIB")]
public int BankedKey { get; set; }
[Display(Name="Google Calendar")]
public string GoogleCalendar { get; set; }
public bool IsBankable { get {
return IsBillable
&& !string.IsNullOrWhiteSpace (BankCode)
@ -108,6 +114,9 @@ namespace Yavsc.Model.RolesAndMembers
object s = profile.GetPropertyValue ("BlogTitle");
BlogTitle = (s is DBNull) ? null : (string)s;
s = profile.GetPropertyValue ("avatar");
avatar = (s is DBNull) ? null : (string)s;
s = profile.GetPropertyValue ("Address");
Address = (s is DBNull) ? null : (string)s;

View file

@ -7,7 +7,6 @@ namespace Yavsc.Model.RolesAndMembers
public class RegisterViewModel
{
[Localizable(true)]
[Display(Name="User name")]
[Required(ErrorMessage = "S'il vous plait, entrez un nom d'utilisateur")]
public string UserName { get; set; }

View file

@ -12,44 +12,41 @@ namespace Yavsc.Model.WorkFlow
/// It takes orders store them and raise some events for modules
/// It publishes estimates and invoices
/// </summary>
public static class WorkFlowManager
public class WorkFlowManager
{
public static Catalog Catalog { get; set; }
public static void UpdateEstimate (Estimate estim)
public void UpdateEstimate (Estimate estim)
{
ContentProvider.UpdateEstimate (estim);
}
public static event EventHandler NewOrder;
public static Estimate GetEstimate (long estid)
public Estimate GetEstimate (long estid)
{
return ContentProvider.GetEstimate (estid);
}
public static Estimate [] GetEstimates (string client)
public Estimate [] GetEstimates (string client)
{
return ContentProvider.GetEstimates (client);
}
public static void UpdateWritting (Writting wr)
public void UpdateWritting (Writting wr)
{
ContentProvider.UpdateWritting (wr);
}
public static void DropWritting (long wrid)
public void DropWritting (long wrid)
{
ContentProvider.DropWritting (wrid);
}
public static void DropEstimate (long estid)
public void DropEstimate (long estid)
{
ContentProvider.DropEstimate(estid);
}
static IContentProvider contentProvider;
IContentProvider contentProvider;
public static IContentProvider ContentProvider {
public IContentProvider ContentProvider {
get {
WorkflowConfiguration c = (WorkflowConfiguration) ConfigurationManager.GetSection ("system.web/workflow");
if (c == null)
@ -75,8 +72,6 @@ namespace Yavsc.Model.WorkFlow
System.Reflection.ConstructorInfo ci =cpt.GetConstructor (System.Type.EmptyTypes);
contentProvider = (IContentProvider)ci.Invoke (System.Type.EmptyTypes);
}
contentProvider.ApplicationName = confprov.ApplicationName;
NameValueCollection config = new NameValueCollection ();
config.Add ("name", confprov.Name);
@ -96,15 +91,13 @@ namespace Yavsc.Model.WorkFlow
/// <returns>The estimate identifier.</returns>
/// <param name="title">Title.</param>
public static Estimate CreateEstimate(string responsible, string client, string title, string description)
public Estimate CreateEstimate(string responsible, string client, string title, string description)
{
Estimate created = ContentProvider.CreateEstimate (responsible, client, title, description);
if (NewOrder != null)
NewOrder.Invoke(ContentProvider, new NewEstimateEvenArgs(created));
return created;
}
public static long Write(long estid, string desc, decimal ucost, int count, string productid)
public long Write(long estid, string desc, decimal ucost, int count, string productid)
{
if (!string.IsNullOrWhiteSpace(productid)) {
if (Catalog == null)
@ -112,12 +105,14 @@ namespace Yavsc.Model.WorkFlow
if (Catalog == null)
throw new Exception ("No catalog");
Product p = Catalog.FindProduct (productid);
if (p == null)
throw new Exception ("Product not found");
// TODO new EstimateChange Event
}
return ContentProvider.Write(estid, desc, ucost, count, productid);
}
public static void SetEstimateStatus(long estid, int status, string username)
public void SetEstimateStatus(long estid, int status, string username)
{
ContentProvider.SetEstimateStatus (estid, status, username);
}

View file

@ -9,6 +9,7 @@
<OutputType>Library</OutputType>
<RootNamespace>Yavsc.Model</RootNamespace>
<AssemblyName>YavscModel</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
@ -32,10 +33,10 @@
<Reference Include="System" />
<Reference Include="System.ComponentModel.DataAnnotations" />
<Reference Include="System.Web" />
<Reference Include="System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
<Reference Include="System.Configuration" />
<Reference Include="System.Data" />
<Reference Include="System.Web.ApplicationServices" />
<Reference Include="System.Web.Mvc" />
</ItemGroup>
<ItemGroup>
<Compile Include="Properties\AssemblyInfo.cs" />
@ -84,6 +85,9 @@
<Compile Include="LocalizedText.Designer.cs">
<DependentUpon>LocalizedText.resx</DependentUpon>
</Compile>
<Compile Include="Google\People.cs" />
<Compile Include="Google\AuthToken.cs" />
<Compile Include="Google\SignIn.cs" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<ItemGroup>
@ -92,6 +96,7 @@
<Folder Include="Blogs\" />
<Folder Include="Admin\" />
<Folder Include="FileSystem\" />
<Folder Include="Google\" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\SalesCatalog\SalesCatalog.csproj">