Chat rooms

vnext
Paul Schneider 5 years ago
parent 3adff3b155
commit 7a84e2965b
23 changed files with 3641 additions and 341 deletions

@ -44,7 +44,7 @@ project.lock.json: project.json
$(dnu) restore
watch: project.lock.json
MONO_MANAGED_WATCHER=enabled ASPNET_ENV=$(ASPNET_ENV) ASPNET_LOG_LEVEL=$(ASPNET_LOG_LEVEL) dnx-watch web --configuration=$(CONFIGURATION)
MONO_OPTIONS=--debug MONO_MANAGED_WATCHER=enabled ASPNET_ENV=$(ASPNET_ENV) ASPNET_LOG_LEVEL=$(ASPNET_LOG_LEVEL) dnx-watch web --configuration=$(CONFIGURATION)
clean:
rm -rf bin obj

@ -1,7 +1,9 @@
namespace Yavsc.Abstract.Chat
{
public enum ChatRoomAccessLevel: int {
Op=1,
HalfOp=2
None=0,
Voice,
Op,
HalfOp
}
}

@ -0,0 +1,12 @@
namespace Yavsc
{
/// <summary>
/// Chat User Flags
/// </summary>
public enum ChatUserFlags : byte
{
away = 1,
invisible = 2,
cop = 4
}
}

@ -61,9 +61,8 @@ namespace Yavsc
public const string HubGroupAnonymous = "anonymous";
public const string HubGroupCops= "cops";
public const int MaxChanelName = 255;
}
public static class NotificationTypes {
public const string Connected = "connected";
public const string DisConnected = "disconnected";
public const string AnonymousUserNamePrefix = "?";
public const string KeyParamChatUserName = "username";
}
}

@ -0,0 +1,6 @@
namespace Yavsc
{
public static class ErrorMessages {
public const string ContactRefused = "contact refused";
}
}

@ -15,8 +15,11 @@ namespace Yavsc.Models.Access
[Required]
public string OwnerId { get; set; }
[ForeignKey("OwnerId"),JsonIgnore]
[ForeignKey("OwnerId"), JsonIgnore]
public virtual ApplicationUser Owner { get; set; }
[ForeignKey("UserId"), JsonIgnore]
public virtual ApplicationUser User { get; set; }
}
}

@ -1,12 +1,14 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Newtonsoft.Json;
using Yavsc.Abstract.Chat;
namespace Yavsc.Models.Chat
{
public class ChatRoom: IChatRoom<ChatRoomAccess>
public class ChatRoom: IChatRoom<ChatRoomAccess>, IBaseTrackedEntity
{
public string Topic { get; set; }
@ -16,11 +18,17 @@ namespace Yavsc.Models.Chat
public string OwnerId { get; set; }
[ForeignKey("OwnerId")]
[ForeignKey("OwnerId")][JsonIgnore]
public virtual ApplicationUser Owner { get; set; }
[InverseProperty("Room")]
[InverseProperty("Room")][JsonIgnore]
public virtual List<ChatRoomAccess> Moderation { get; set; }
public DateTime LatestJoinPart { get; set;}
public DateTime DateCreated { get; set; }
public string UserCreated { get; set; }
public DateTime DateModified { get; set;}
public string UserModified { get; set; }
}
}

@ -25,8 +25,6 @@ namespace Yavsc.Models.Chat
get; set;
}
[ForeignKey("UserId")]
public virtual ApplicationUser User { get; set; }
}

@ -0,0 +1,13 @@
namespace Yavsc
{
public static class NotificationTypes {
public const string Connected = "connected";
public const string DisConnected = "disconnected";
public const string Reconnected = "reconnected";
public const string UserPart = "userpart";
public const string UserJoin = "userjoin";
public const string PrivateMessageDenied = "deniedpv";
public const string Error = "error";
}
}

@ -0,0 +1,33 @@
namespace Yavsc
{
public static class ServerCommands {
public const string whois = nameof(whois);
public const string whowas = nameof(whowas);
/// <summary>
/// modify a chan or an user
/// </summary>
/// <returns></returns>
public const string mode = nameof(mode);
/// <summary>
/// register a channel
/// </summary>
/// <returns></returns>
public const string register = nameof(register);
/// <summary>
/// kick some user
/// </summary>
/// <returns></returns>
public const string kick = nameof(kick);
/// <summary>
/// ban an user
/// </summary>
/// <returns></returns>
public const string ban = nameof(ban);
}
}

@ -24,7 +24,7 @@ namespace Yavsc.Controllers
protected UserManager<ApplicationUser> _userManager;
protected ApplicationDbContext _context;
protected GoogleAuthSettings _googleSettings;
protected IYavscMessageSender _GCMSender;
protected IYavscMessageSender _MessageSender;
protected IEmailSender _emailSender;
protected IStringLocalizer _localizer;
protected SiteSettings _siteSettings;
@ -44,7 +44,7 @@ namespace Yavsc.Controllers
ILoggerFactory loggerFactory)
{
_context = context;
_GCMSender = GCMSender;
_MessageSender = GCMSender;
_emailSender = emailSender;
_googleSettings = googleSettings.Value;
_userManager = userManager;
@ -165,47 +165,39 @@ namespace Yavsc.Controllers
var yaev = command.CreateEvent(_localizer, "NewCommand");
MessageWithPayloadResponse grep = null;
MessageWithPayloadResponse nrep = null;
if (pro.AcceptNotifications
&& pro.AcceptPublicContact)
{
try
{
_logger.LogInformation("sending GCM");
if (pro.Performer.DeviceDeclarations.Count > 0)
{
var regids = command.PerformerProfile.Performer
.DeviceDeclarations.Select(d => d.DeviceId);
grep = await _GCMSender.NotifyBookQueryAsync(regids, yaev);
}
_logger.LogInformation("sending message");
var regids = new [] { command.PerformerProfile.Performer.Id };
nrep = await _MessageSender.NotifyBookQueryAsync(regids, yaev);
// TODO setup a profile choice to allow notifications
// both on mailbox and mobile
// if (grep==null || grep.success<=0 || grep.failure>0)
ViewBag.GooglePayload = grep;
ViewBag.MessagingResponsePayload = nrep;
}
catch (Exception ex)
{
_logger.LogError(ex.Message);
_logger.LogError("Message sending failed with: "+ex.Message);
throw;
}
try
{
ViewBag.EmailSent = await _emailSender.SendEmailAsync(
command.PerformerProfile.Performer.UserName,
command.PerformerProfile.Performer.Email,
$"{command.Client.UserName} (un client) vous demande un rendez-vous",
$"{yaev.CreateBody()}\r\n-- \r\n{yaev.Previsional}\r\n{yaev.EventDate}\r\n"
);
}
catch (Exception ex)
{
_logger.LogError(ex.Message);
}
}
else {
nrep = new MessageWithPayloadResponse { failure=1, results = new MessageWithPayloadResponse.Result[] {
new MessageWithPayloadResponse.Result
{
error=ErrorMessages.ContactRefused,
registration_id= pro.PerformerId
}
} };
_logger.LogInformation("Command.Create && ( !pro.AcceptNotifications || |pro.AcceptPublicContact ) ");
}
ViewBag.MessagingResponsePayload = nrep;
ViewBag.Activity = _context.Activities.FirstOrDefault(a => a.Code == command.ActivityCode);
ViewBag.GoogleSettings = _googleSettings;
return View("CommandConfirmation", command);

@ -104,7 +104,7 @@ namespace Yavsc.Controllers
{
var regids = command.PerformerProfile.Performer
.DeviceDeclarations.Select(d => d.DeviceId);
grep = await _GCMSender.NotifyAsync(regids, yaev);
grep = await _MessageSender.NotifyAsync(regids, yaev);
}
// TODO setup a profile choice to allow notifications
// both on mailbox and mobile
@ -271,7 +271,7 @@ namespace Yavsc.Controllers
if (pro.Performer.DeviceDeclarations.Count > 0)
{
var regids = pro.Performer.DeviceDeclarations.Select(d => d.DeviceId);
grep = await _GCMSender.NotifyHairCutQueryAsync(regids, yaev);
grep = await _MessageSender.NotifyHairCutQueryAsync(regids, yaev);
}
// TODO setup a profile choice to allow notifications
// both on mailbox and mobile
@ -431,7 +431,7 @@ namespace Yavsc.Controllers
{
var regids = command.PerformerProfile.Performer
.DeviceDeclarations.Select(d => d.DeviceId);
grep = await _GCMSender.NotifyHairCutQueryAsync(regids, yaev);
grep = await _MessageSender.NotifyHairCutQueryAsync(regids, yaev);
}
// TODO setup a profile choice to allow notifications
// both on mailbox and mobile, and to allow calendar event insertion.

@ -19,6 +19,7 @@
// 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 Microsoft.AspNet.SignalR;
using Microsoft.AspNet.SignalR.Hosting;
using System.Threading.Tasks;
using System.Collections.Generic;
using System.Linq;
@ -26,7 +27,8 @@ using System.Linq;
namespace Yavsc
{
using System;
using Microsoft.AspNet.Authorization;
using System.Collections.Concurrent;
using Microsoft.AspNet.WebUtilities;
using Microsoft.Data.Entity;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
@ -37,12 +39,12 @@ namespace Yavsc
{
ApplicationDbContext _dbContext;
ILogger _logger;
IUserIdProvider _userIdProvider;
public ChatHub(IUserIdProvider userIdProvider)
public ChatHub()
{
_userIdProvider = userIdProvider;
var scope = Startup.Services.GetRequiredService<IServiceScopeFactory>().CreateScope();
_dbContext = scope.ServiceProvider.GetService<ApplicationDbContext>();
var loggerFactory = scope.ServiceProvider.GetService<ILoggerFactory>();
_logger = loggerFactory.CreateLogger<ChatHub>();
@ -51,11 +53,10 @@ namespace Yavsc
public override async Task OnConnected()
{
bool isAuth = false;
string userName = null;
string userName = setUserName();
if (Context.User != null)
{
isAuth = Context.User.Identity.IsAuthenticated;
userName = Context.User.Identity.Name;
var group = isAuth ?
Constants.HubGroupAuthenticated : Constants.HubGroupAnonymous;
@ -63,6 +64,10 @@ namespace Yavsc
await Groups.Add(Context.ConnectionId, group);
if (isAuth)
{
_logger.LogInformation("Authenticated chat user");
var userId = _dbContext.Users.First(u=>u.UserName == userName).Id;
var userHadConnections = _dbContext.ChatConnection.Any(accx => accx.ConnectionId == Context.ConnectionId);
if (userHadConnections) {
@ -72,134 +77,276 @@ namespace Yavsc
else
_dbContext.ChatConnection.Add(new ChatConnection
{
ApplicationUserId = userId,
ConnectionId = Context.ConnectionId,
UserAgent = Context.Request.Headers["User-Agent"],
Connected = true
});
_dbContext.SaveChanges();
var userId = _userIdProvider.GetUserId(this.Context.Request);
Clients.CallerState.BlackListedBy = await _dbContext.BlackListed.Where(r=>r.UserId == userId).Select(r=>r.OwnerId).ToArrayAsync();
// TODO ChatHubConnectioinFlags
// TODO ChatHubConnectioinFlags
}
else
{
// FIXME is this line reached ?
await Groups.Add(Context.ConnectionId, Constants.HubGroupAnonymous);
_logger.LogInformation("Anonymous chat user (first use case)");
throw new NotSupportedException();
}
}
else await Groups.Add(Context.ConnectionId, Constants.HubGroupAnonymous);
else {
// TODO var uname = Context.Request.QueryString[Constants.KeyParamChatUserName] ?? "anon";
await Groups.Add(Context.ConnectionId, Constants.HubGroupAnonymous);
}
// TODO only notify followers
Clients.Group(Constants.HubGroupAuthenticated).notify(NotificationTypes.Connected, Context.ConnectionId, userName);
await base.OnConnected();
}
static ConcurrentDictionary <string,string> ChatUserNames
= new ConcurrentDictionary<string, string>();
string setUserName()
{
if (Context.User!=null)
if (Context.User.Identity.IsAuthenticated)
{
ChatUserNames[Context.ConnectionId]=Context.User.Identity.Name;
_logger.LogInformation($"chat user name set to : {Context.User.Identity.Name}");
return Context.User.Identity.Name;
}
anonymousSequence++;
var aname = $"{Constants.AnonymousUserNamePrefix}{anonymousSequence}";
ChatUserNames[Context.ConnectionId]=aname;
_logger.LogInformation($"Anonymous chat user name set to : {aname}");
return aname;
}
static long anonymousSequence=0;
public override Task OnDisconnected(bool stopCalled)
{
string userName = Context.User?.Identity.Name;
Clients.Group("authenticated").notify("disconnected", Context.ConnectionId, userName);
Clients.Group("authenticated").notify(NotificationTypes.DisConnected, Context.ConnectionId, userName);
if (userName != null)
{
using (var db = new ApplicationDbContext()) {
var cx = db.ChatConnection.SingleOrDefault(c => c.ConnectionId == Context.ConnectionId);
if (cx != null)
var cx = _dbContext.ChatConnection.SingleOrDefault(c => c.ConnectionId == Context.ConnectionId);
if (cx != null)
{
if (stopCalled)
{
if (stopCalled)
{
var user = db.Users.Single(u => u.UserName == userName);
user.Connections.Remove(cx);
}
else
{
cx.Connected = false;
}
db.SaveChanges();
var user = _dbContext.Users.Single(u => u.UserName == userName);
user.Connections.Remove(cx);
}
else
{
cx.Connected = false;
}
_dbContext.SaveChanges();
}
}
return base.OnDisconnected(stopCalled);
}
public override Task OnReconnected()
{
string userName = Context.User?.Identity.Name;
if (userName != null)
if (Context.User != null) if (Context.User.Identity.IsAuthenticated)
{
var userName = Context.User.Identity.Name;
var user = _dbContext.Users.FirstOrDefault(u=>u.UserName == userName);
if (user == null)
_logger.LogWarning($"null user with <{userName}> & Context.User.Identity.IsAuthenticated");
var userId = user.Id;
var userHadConnections = _dbContext.ChatConnection.Any(accx => accx.ConnectionId == Context.ConnectionId);
var user = _dbContext.Users.Single(u => u.UserName == userName);
if (userHadConnections) {
var ccx = _dbContext.ChatConnection.First(c=> c.ConnectionId == Context.ConnectionId);
ccx.Connected=true;
}
else
_dbContext.ChatConnection.Add(new ChatConnection
{
ApplicationUserId = userId,
ConnectionId = Context.ConnectionId,
UserAgent = Context.Request.Headers["User-Agent"],
Connected = true
});
_dbContext.SaveChanges();
Clients.Group("authenticated").notify(NotificationTypes.Reconnected, Context.ConnectionId, userName);
}
return base.OnReconnected();
}
if (user.Connections==null) user.Connections = new List<ChatConnection>();
static ConcurrentDictionary<string, ChatRoomInfo> Channels = new ConcurrentDictionary<string, ChatRoomInfo>();
public class ChatRoomInfo {
public string Name ;
public Dictionary<string,string> Users = new Dictionary<string, string>();
public string Topic;
}
var cx = user.Connections.SingleOrDefault(c => c.ConnectionId == Context.ConnectionId);
if (cx != null)
{
cx.Connected = true;
_dbContext.SaveChanges();
public void Join(string roomName)
{
_logger.LogInformation("a client for "+roomName);
var userName = ChatUserNames[Context.ConnectionId];
_logger.LogInformation($" chat user : {userName}");
var roomGroupName = "room_"+roomName;
ChatRoomInfo chanInfo;
if (Channels.ContainsKey(roomName))
{
if (Channels.TryGetValue(roomName, out chanInfo)) {
_logger.LogInformation("room is avaible.");
if (chanInfo.Users.ContainsKey(Context.ConnectionId))
_logger.LogWarning("user already joined.");
else {
chanInfo.Users.Add(Context.ConnectionId, userName);
Groups.Add(Context.ConnectionId,roomGroupName);
}
else cx = new ChatConnection { ConnectionId = Context.ConnectionId,
UserAgent = Context.Request.Headers["User-Agent"],
Connected = true };
Clients.Caller.onJoined(chanInfo);
Clients.Group("room_"+roomName).notify( NotificationTypes.UserJoin, Context.ConnectionId, Clients.Caller.UserName);
_logger.LogInformation("exiting ok.");
return;
}
else {
_logger.LogInformation("room seemd to be avaible ... but we could get no info on it.");
Clients.Caller.notify(NotificationTypes.Error, "join get chan failed ...");
return;
}
}
// chan was almost empty
_logger.LogInformation("joining empty chan.");
return base.OnReconnected();
var room = _dbContext.ChatRoom.FirstOrDefault(r => r.Name == roomName);
chanInfo = new ChatRoomInfo();
chanInfo.Users.Add(Context.ConnectionId, userName);
if (room!=null)
{
_logger.LogInformation("existent room.");
chanInfo.Topic = room.Topic;
chanInfo.Name = room.Name;
}
else { // a first join, we create it.
_logger.LogInformation("room creation.");
chanInfo.Name = roomName;
chanInfo.Topic = "<just created>";
}
if (Channels.TryAdd(roomName, chanInfo))
{
Groups.Add(Context.ConnectionId, roomGroupName);
Clients.Caller.onJoined(chanInfo);
}
else _logger.LogError("Chan create failed unexpectly...");
}
public void Send(string name, string message)
[Authorize]
public void Register (string room )
{
string uname = (Context.User != null) ?
$"[{Context.User.Identity.Name}]" :
$"?{name}";
Clients.All.addMessage(uname, message);
var existent = _dbContext.ChatRoom.Any(r => r.Name == room);
if (existent) {
Clients.Caller.notify(NotificationTypes.Error, "already registered.");
return;
}
string userName = Context.User.Identity.Name;
var user = _dbContext.Users.FirstOrDefault(u=>u.UserName == userName);
var newroom = new ChatRoom { Name = room, OwnerId = user.Id };
ChatRoomInfo chanInfo;
if (Channels.TryGetValue(room, out chanInfo))
{
// TODO get and require some admin status for current user on this chan
newroom.Topic = chanInfo.Topic;
}
newroom.LatestJoinPart = DateTime.Now;
_dbContext.ChatRoom.Add(newroom);
_dbContext.SaveChanges(user.Id);
}
/** TODO chan register on server command
room = new ChatRoom { Name = roomName, OwnerId = uid };
_dbContext.ChatRoom.Add(room);
_dbContext.SaveChanges(uid);
room.LatestJoinPart = DateTime.Now;
chanInfo.Topic = room.Topic;
*/
[Authorize]
public void SendPV(string connectionId, string message)
public void Part (string roomName, string reason)
{
if (Clients.CallerState.BlackListedBy!=null)
foreach (string destId in Clients.CallerState.BlackListedBy)
{
if (_dbContext.ChatConnection.Any(c => c.ConnectionId == connectionId && c.ApplicationUserId == destId ))
ChatRoomInfo chanInfo;
if (Channels.TryGetValue(roomName, out chanInfo))
{
var roomGroupName = "room_"+roomName;
Groups.Remove(Context.ConnectionId, roomGroupName);
var group = Clients.Group(roomGroupName);
var username = ChatUserNames[Context.ConnectionId];
group.notify( NotificationTypes.UserPart, Context.ConnectionId, new { username, reason } );
chanInfo.Users.Remove(Context.ConnectionId);
ChatRoomInfo deadchanInfo;
if (chanInfo.Users.Count==0)
if (Channels.TryRemove(roomName, out deadchanInfo))
{
_logger.LogInformation($"PV aborted by black list");
Clients.Caller.send("denied");
return ;
var room = _dbContext.ChatRoom.FirstOrDefault(r => r.Name == roomName);
room.LatestJoinPart = DateTime.Now;
_dbContext.SaveChanges();
}
}
var cli = Clients.Client(connectionId);
cli.addPV(Context.User.Identity.Name, message);
}
else {
Clients.Caller.notify(NotificationTypes.Error, "not joint");
}
}
private async Task<bool> AllowPv(string destConnectionId)
{
if (Context.User.IsInRole(Constants.BlogModeratorGroupName))
if (Context.User.IsInRole(Constants.BlogModeratorGroupName)
|| Context.User.IsInRole(Constants.AdminGroupName))
return true;
if (!Context.User.Identity.IsAuthenticated)
return false;
string senderId = (await _dbContext.ChatConnection.SingleAsync (c=>c.ConnectionId == Context.ConnectionId)).ApplicationUserId;
public void Send(string roomName, string message)
{
var groupname = "room_"+roomName;
ChatRoomInfo chanInfo;
if (Channels.TryGetValue(roomName, out chanInfo))
{
if (!chanInfo.Users.ContainsKey(Context.ConnectionId)){
Clients.Caller.notify(NotificationTypes.Error, $"could not join channel ({roomName})");
return;
}
string uname = ChatUserNames[Context.ConnectionId];
Clients.Group(groupname).addMessage(uname, roomName, message);
}
else
{
Clients.Caller.notify(NotificationTypes.Error, $"could not join channel ({roomName})");
return;
}
}
if (_dbContext.Ban.Any(b=>b.TargetId == senderId)) return false;
var destChatUser = await _dbContext.ChatConnection.SingleAsync (c=>c.ConnectionId == destConnectionId);
[Authorize]
public void SendPV(string connectionId, string message)
{
if (!Context.User.IsInRole(Constants.AdminGroupName))
{
var bl = _dbContext.BlackListed
.Include(r => r.User)
.Where(r=>r.User.UserName == Context.User.Identity.Name)
.Select(r=>r.OwnerId);
if (_dbContext.BlackListed.Any(b=>b.OwnerId == destChatUser.ApplicationUserId && b.UserId == senderId)) return false;
var destUser = await _dbContext.Performers.FirstOrDefaultAsync( u=> u.PerformerId == destChatUser.ApplicationUserId);
return destUser?.AcceptPublicContact ?? true;
if (bl!=null) foreach (string uid in bl)
{
if (_dbContext.ChatConnection.Any(cx => cx.ApplicationUserId==uid && cx.Connected))
Clients.Caller.notify(NotificationTypes.PrivateMessageDenied, connectionId);
return ;
}
}
var cli = Clients.Client(connectionId);
cli.addPV(Context.User.Identity.Name, message);
}
[Authorize]
public void SendStream(string connectionId, long streamId, string message)
{
var sender = Context.User.Identity.Name;
// TODO personal black|white list +
// Contact list allowed only +
// only pro
var hubCxContext = Clients.User(connectionId);
var cli = Clients.Client(connectionId);
cli.addStreamInfo(sender, streamId, message);
}

File diff suppressed because it is too large Load Diff

@ -0,0 +1,941 @@
using System;
using System.Collections.Generic;
using Microsoft.Data.Entity.Migrations;
namespace Yavsc.Migrations
{
public partial class chanDates : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(name: "FK_IdentityRoleClaim<string>_IdentityRole_RoleId", table: "AspNetRoleClaims");
migrationBuilder.DropForeignKey(name: "FK_IdentityUserClaim<string>_ApplicationUser_UserId", table: "AspNetUserClaims");
migrationBuilder.DropForeignKey(name: "FK_IdentityUserLogin<string>_ApplicationUser_UserId", table: "AspNetUserLogins");
migrationBuilder.DropForeignKey(name: "FK_IdentityUserRole<string>_IdentityRole_RoleId", table: "AspNetUserRoles");
migrationBuilder.DropForeignKey(name: "FK_IdentityUserRole<string>_ApplicationUser_UserId", table: "AspNetUserRoles");
migrationBuilder.DropForeignKey(name: "FK_Ban_ApplicationUser_TargetId", table: "Ban");
migrationBuilder.DropForeignKey(name: "FK_BlackListed_ApplicationUser_OwnerId", table: "BlackListed");
migrationBuilder.DropForeignKey(name: "FK_CircleAuthorizationToBlogPost_BlogPost_BlogPostId", table: "CircleAuthorizationToBlogPost");
migrationBuilder.DropForeignKey(name: "FK_CircleAuthorizationToBlogPost_Circle_CircleId", table: "CircleAuthorizationToBlogPost");
migrationBuilder.DropForeignKey(name: "FK_AccountBalance_ApplicationUser_UserId", table: "AccountBalance");
migrationBuilder.DropForeignKey(name: "FK_BalanceImpact_AccountBalance_BalanceId", table: "BalanceImpact");
migrationBuilder.DropForeignKey(name: "FK_CommandLine_Estimate_EstimateId", table: "CommandLine");
migrationBuilder.DropForeignKey(name: "FK_Estimate_ApplicationUser_ClientId", table: "Estimate");
migrationBuilder.DropForeignKey(name: "FK_BlogTag_BlogPost_PostId", table: "BlogTag");
migrationBuilder.DropForeignKey(name: "FK_BlogTag_Tag_TagId", table: "BlogTag");
migrationBuilder.DropForeignKey(name: "FK_Comment_ApplicationUser_AuthorId", table: "Comment");
migrationBuilder.DropForeignKey(name: "FK_Comment_BlogPost_PostId", table: "Comment");
migrationBuilder.DropForeignKey(name: "FK_Schedule_ApplicationUser_OwnerId", table: "Schedule");
migrationBuilder.DropForeignKey(name: "FK_ChatConnection_ApplicationUser_ApplicationUserId", table: "ChatConnection");
migrationBuilder.DropForeignKey(name: "FK_ChatRoomAccess_ApplicationUser_UserId", table: "ChatRoomAccess");
migrationBuilder.DropForeignKey(name: "FK_BrusherProfile_PerformerProfile_UserId", table: "BrusherProfile");
migrationBuilder.DropForeignKey(name: "FK_HairCutQuery_Activity_ActivityCode", table: "HairCutQuery");
migrationBuilder.DropForeignKey(name: "FK_HairCutQuery_ApplicationUser_ClientId", table: "HairCutQuery");
migrationBuilder.DropForeignKey(name: "FK_HairCutQuery_PerformerProfile_PerformerId", table: "HairCutQuery");
migrationBuilder.DropForeignKey(name: "FK_HairCutQuery_HairPrestation_PrestationId", table: "HairCutQuery");
migrationBuilder.DropForeignKey(name: "FK_HairMultiCutQuery_Activity_ActivityCode", table: "HairMultiCutQuery");
migrationBuilder.DropForeignKey(name: "FK_HairMultiCutQuery_ApplicationUser_ClientId", table: "HairMultiCutQuery");
migrationBuilder.DropForeignKey(name: "FK_HairMultiCutQuery_PerformerProfile_PerformerId", table: "HairMultiCutQuery");
migrationBuilder.DropForeignKey(name: "FK_HairPrestationCollectionItem_HairPrestation_PrestationId", table: "HairPrestationCollectionItem");
migrationBuilder.DropForeignKey(name: "FK_HairPrestationCollectionItem_HairMultiCutQuery_QueryId", table: "HairPrestationCollectionItem");
migrationBuilder.DropForeignKey(name: "FK_HairTaint_Color_ColorId", table: "HairTaint");
migrationBuilder.DropForeignKey(name: "FK_HairTaintInstance_HairPrestation_PrestationId", table: "HairTaintInstance");
migrationBuilder.DropForeignKey(name: "FK_HairTaintInstance_HairTaint_TaintId", table: "HairTaintInstance");
migrationBuilder.DropForeignKey(name: "FK_DimissClicked_Notification_NotificationId", table: "DimissClicked");
migrationBuilder.DropForeignKey(name: "FK_DimissClicked_ApplicationUser_UserId", table: "DimissClicked");
migrationBuilder.DropForeignKey(name: "FK_Instrumentation_Instrument_InstrumentId", table: "Instrumentation");
migrationBuilder.DropForeignKey(name: "FK_PayPalPayment_ApplicationUser_ExecutorId", table: "PayPalPayment");
migrationBuilder.DropForeignKey(name: "FK_CircleMember_Circle_CircleId", table: "CircleMember");
migrationBuilder.DropForeignKey(name: "FK_CircleMember_ApplicationUser_MemberId", table: "CircleMember");
migrationBuilder.DropForeignKey(name: "FK_Contact_PostalAddress_AddressId", table: "Contact");
migrationBuilder.DropForeignKey(name: "FK_LiveFlow_ApplicationUser_OwnerId", table: "LiveFlow");
migrationBuilder.DropForeignKey(name: "FK_CommandForm_Activity_ActivityCode", table: "CommandForm");
migrationBuilder.DropForeignKey(name: "FK_PerformerProfile_Location_OrganizationAddressId", table: "PerformerProfile");
migrationBuilder.DropForeignKey(name: "FK_PerformerProfile_ApplicationUser_PerformerId", table: "PerformerProfile");
migrationBuilder.DropForeignKey(name: "FK_RdvQuery_Activity_ActivityCode", table: "RdvQuery");
migrationBuilder.DropForeignKey(name: "FK_RdvQuery_ApplicationUser_ClientId", table: "RdvQuery");
migrationBuilder.DropForeignKey(name: "FK_RdvQuery_PerformerProfile_PerformerId", table: "RdvQuery");
migrationBuilder.DropForeignKey(name: "FK_UserActivity_Activity_DoesCode", table: "UserActivity");
migrationBuilder.DropForeignKey(name: "FK_UserActivity_PerformerProfile_UserId", table: "UserActivity");
migrationBuilder.DropForeignKey(name: "FK_MailingTemplate_ApplicationUser_ManagerId", table: "MailingTemplate");
migrationBuilder.DropForeignKey(name: "FK_MailingTemplate_ApplicationUser_SuccessorId", table: "MailingTemplate");
migrationBuilder.DropForeignKey(name: "FK_Project_Activity_ActivityCode", table: "Project");
migrationBuilder.DropForeignKey(name: "FK_Project_ApplicationUser_ClientId", table: "Project");
migrationBuilder.DropForeignKey(name: "FK_Project_GitRepositoryReference_GitId", table: "Project");
migrationBuilder.DropForeignKey(name: "FK_Project_PerformerProfile_PerformerId", table: "Project");
migrationBuilder.DropForeignKey(name: "FK_ProjectBuildConfiguration_Project_ProjectId", table: "ProjectBuildConfiguration");
migrationBuilder.AddColumn<DateTime>(
name: "DateCreated",
table: "ChatRoom",
nullable: false,
defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified));
migrationBuilder.AddColumn<DateTime>(
name: "DateModified",
table: "ChatRoom",
nullable: false,
defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified));
migrationBuilder.AddColumn<DateTime>(
name: "LatestJoinPart",
table: "ChatRoom",
nullable: false,
defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified));
migrationBuilder.AddColumn<string>(
name: "UserCreated",
table: "ChatRoom",
nullable: true);
migrationBuilder.AddColumn<string>(
name: "UserModified",
table: "ChatRoom",
nullable: true);
migrationBuilder.AddForeignKey(
name: "FK_IdentityRoleClaim<string>_IdentityRole_RoleId",
table: "AspNetRoleClaims",
column: "RoleId",
principalTable: "AspNetRoles",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_IdentityUserClaim<string>_ApplicationUser_UserId",
table: "AspNetUserClaims",
column: "UserId",
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_IdentityUserLogin<string>_ApplicationUser_UserId",
table: "AspNetUserLogins",
column: "UserId",
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_IdentityUserRole<string>_IdentityRole_RoleId",
table: "AspNetUserRoles",
column: "RoleId",
principalTable: "AspNetRoles",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_IdentityUserRole<string>_ApplicationUser_UserId",
table: "AspNetUserRoles",
column: "UserId",
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_Ban_ApplicationUser_TargetId",
table: "Ban",
column: "TargetId",
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_BlackListed_ApplicationUser_OwnerId",
table: "BlackListed",
column: "OwnerId",
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_CircleAuthorizationToBlogPost_BlogPost_BlogPostId",
table: "CircleAuthorizationToBlogPost",
column: "BlogPostId",
principalTable: "BlogPost",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_CircleAuthorizationToBlogPost_Circle_CircleId",
table: "CircleAuthorizationToBlogPost",
column: "CircleId",
principalTable: "Circle",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_AccountBalance_ApplicationUser_UserId",
table: "AccountBalance",
column: "UserId",
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_BalanceImpact_AccountBalance_BalanceId",
table: "BalanceImpact",
column: "BalanceId",
principalTable: "AccountBalance",
principalColumn: "UserId",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_CommandLine_Estimate_EstimateId",
table: "CommandLine",
column: "EstimateId",
principalTable: "Estimate",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_Estimate_ApplicationUser_ClientId",
table: "Estimate",
column: "ClientId",
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_BlogTag_BlogPost_PostId",
table: "BlogTag",
column: "PostId",
principalTable: "BlogPost",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_BlogTag_Tag_TagId",
table: "BlogTag",
column: "TagId",
principalTable: "Tag",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_Comment_ApplicationUser_AuthorId",
table: "Comment",
column: "AuthorId",
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_Comment_BlogPost_PostId",
table: "Comment",
column: "PostId",
principalTable: "BlogPost",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_Schedule_ApplicationUser_OwnerId",
table: "Schedule",
column: "OwnerId",
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_ChatConnection_ApplicationUser_ApplicationUserId",
table: "ChatConnection",
column: "ApplicationUserId",
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_ChatRoomAccess_ApplicationUser_UserId",
table: "ChatRoomAccess",
column: "UserId",
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_BrusherProfile_PerformerProfile_UserId",
table: "BrusherProfile",
column: "UserId",
principalTable: "PerformerProfile",
principalColumn: "PerformerId",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_HairCutQuery_Activity_ActivityCode",
table: "HairCutQuery",
column: "ActivityCode",
principalTable: "Activity",
principalColumn: "Code",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_HairCutQuery_ApplicationUser_ClientId",
table: "HairCutQuery",
column: "ClientId",
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_HairCutQuery_PerformerProfile_PerformerId",
table: "HairCutQuery",
column: "PerformerId",
principalTable: "PerformerProfile",
principalColumn: "PerformerId",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_HairCutQuery_HairPrestation_PrestationId",
table: "HairCutQuery",
column: "PrestationId",
principalTable: "HairPrestation",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_HairMultiCutQuery_Activity_ActivityCode",
table: "HairMultiCutQuery",
column: "ActivityCode",
principalTable: "Activity",
principalColumn: "Code",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_HairMultiCutQuery_ApplicationUser_ClientId",
table: "HairMultiCutQuery",
column: "ClientId",
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_HairMultiCutQuery_PerformerProfile_PerformerId",
table: "HairMultiCutQuery",
column: "PerformerId",
principalTable: "PerformerProfile",
principalColumn: "PerformerId",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_HairPrestationCollectionItem_HairPrestation_PrestationId",
table: "HairPrestationCollectionItem",
column: "PrestationId",
principalTable: "HairPrestation",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_HairPrestationCollectionItem_HairMultiCutQuery_QueryId",
table: "HairPrestationCollectionItem",
column: "QueryId",
principalTable: "HairMultiCutQuery",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_HairTaint_Color_ColorId",
table: "HairTaint",
column: "ColorId",
principalTable: "Color",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_HairTaintInstance_HairPrestation_PrestationId",
table: "HairTaintInstance",
column: "PrestationId",
principalTable: "HairPrestation",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_HairTaintInstance_HairTaint_TaintId",
table: "HairTaintInstance",
column: "TaintId",
principalTable: "HairTaint",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_DimissClicked_Notification_NotificationId",
table: "DimissClicked",
column: "NotificationId",
principalTable: "Notification",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_DimissClicked_ApplicationUser_UserId",
table: "DimissClicked",
column: "UserId",
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_Instrumentation_Instrument_InstrumentId",
table: "Instrumentation",
column: "InstrumentId",
principalTable: "Instrument",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_PayPalPayment_ApplicationUser_ExecutorId",
table: "PayPalPayment",
column: "ExecutorId",
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_CircleMember_Circle_CircleId",
table: "CircleMember",
column: "CircleId",
principalTable: "Circle",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_CircleMember_ApplicationUser_MemberId",
table: "CircleMember",
column: "MemberId",
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_Contact_PostalAddress_AddressId",
table: "Contact",
column: "AddressId",
principalTable: "PostalAddress",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_LiveFlow_ApplicationUser_OwnerId",
table: "LiveFlow",
column: "OwnerId",
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_CommandForm_Activity_ActivityCode",
table: "CommandForm",
column: "ActivityCode",
principalTable: "Activity",
principalColumn: "Code",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_PerformerProfile_Location_OrganizationAddressId",
table: "PerformerProfile",
column: "OrganizationAddressId",
principalTable: "Location",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_PerformerProfile_ApplicationUser_PerformerId",
table: "PerformerProfile",
column: "PerformerId",
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_RdvQuery_Activity_ActivityCode",
table: "RdvQuery",
column: "ActivityCode",
principalTable: "Activity",
principalColumn: "Code",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_RdvQuery_ApplicationUser_ClientId",
table: "RdvQuery",
column: "ClientId",
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_RdvQuery_PerformerProfile_PerformerId",
table: "RdvQuery",
column: "PerformerId",
principalTable: "PerformerProfile",
principalColumn: "PerformerId",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_UserActivity_Activity_DoesCode",
table: "UserActivity",
column: "DoesCode",
principalTable: "Activity",
principalColumn: "Code",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_UserActivity_PerformerProfile_UserId",
table: "UserActivity",
column: "UserId",
principalTable: "PerformerProfile",
principalColumn: "PerformerId",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_MailingTemplate_ApplicationUser_ManagerId",
table: "MailingTemplate",
column: "ManagerId",
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_MailingTemplate_ApplicationUser_SuccessorId",
table: "MailingTemplate",
column: "SuccessorId",
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_Project_Activity_ActivityCode",
table: "Project",
column: "ActivityCode",
principalTable: "Activity",
principalColumn: "Code",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_Project_ApplicationUser_ClientId",
table: "Project",
column: "ClientId",
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_Project_GitRepositoryReference_GitId",
table: "Project",
column: "GitId",
principalTable: "GitRepositoryReference",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_Project_PerformerProfile_PerformerId",
table: "Project",
column: "PerformerId",
principalTable: "PerformerProfile",
principalColumn: "PerformerId",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_ProjectBuildConfiguration_Project_ProjectId",
table: "ProjectBuildConfiguration",
column: "ProjectId",
principalTable: "Project",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(name: "FK_IdentityRoleClaim<string>_IdentityRole_RoleId", table: "AspNetRoleClaims");
migrationBuilder.DropForeignKey(name: "FK_IdentityUserClaim<string>_ApplicationUser_UserId", table: "AspNetUserClaims");
migrationBuilder.DropForeignKey(name: "FK_IdentityUserLogin<string>_ApplicationUser_UserId", table: "AspNetUserLogins");
migrationBuilder.DropForeignKey(name: "FK_IdentityUserRole<string>_IdentityRole_RoleId", table: "AspNetUserRoles");
migrationBuilder.DropForeignKey(name: "FK_IdentityUserRole<string>_ApplicationUser_UserId", table: "AspNetUserRoles");
migrationBuilder.DropForeignKey(name: "FK_Ban_ApplicationUser_TargetId", table: "Ban");
migrationBuilder.DropForeignKey(name: "FK_BlackListed_ApplicationUser_OwnerId", table: "BlackListed");
migrationBuilder.DropForeignKey(name: "FK_CircleAuthorizationToBlogPost_BlogPost_BlogPostId", table: "CircleAuthorizationToBlogPost");
migrationBuilder.DropForeignKey(name: "FK_CircleAuthorizationToBlogPost_Circle_CircleId", table: "CircleAuthorizationToBlogPost");
migrationBuilder.DropForeignKey(name: "FK_AccountBalance_ApplicationUser_UserId", table: "AccountBalance");
migrationBuilder.DropForeignKey(name: "FK_BalanceImpact_AccountBalance_BalanceId", table: "BalanceImpact");
migrationBuilder.DropForeignKey(name: "FK_CommandLine_Estimate_EstimateId", table: "CommandLine");
migrationBuilder.DropForeignKey(name: "FK_Estimate_ApplicationUser_ClientId", table: "Estimate");
migrationBuilder.DropForeignKey(name: "FK_BlogTag_BlogPost_PostId", table: "BlogTag");
migrationBuilder.DropForeignKey(name: "FK_BlogTag_Tag_TagId", table: "BlogTag");
migrationBuilder.DropForeignKey(name: "FK_Comment_ApplicationUser_AuthorId", table: "Comment");
migrationBuilder.DropForeignKey(name: "FK_Comment_BlogPost_PostId", table: "Comment");
migrationBuilder.DropForeignKey(name: "FK_Schedule_ApplicationUser_OwnerId", table: "Schedule");
migrationBuilder.DropForeignKey(name: "FK_ChatConnection_ApplicationUser_ApplicationUserId", table: "ChatConnection");
migrationBuilder.DropForeignKey(name: "FK_ChatRoomAccess_ApplicationUser_UserId", table: "ChatRoomAccess");
migrationBuilder.DropForeignKey(name: "FK_BrusherProfile_PerformerProfile_UserId", table: "BrusherProfile");
migrationBuilder.DropForeignKey(name: "FK_HairCutQuery_Activity_ActivityCode", table: "HairCutQuery");
migrationBuilder.DropForeignKey(name: "FK_HairCutQuery_ApplicationUser_ClientId", table: "HairCutQuery");
migrationBuilder.DropForeignKey(name: "FK_HairCutQuery_PerformerProfile_PerformerId", table: "HairCutQuery");
migrationBuilder.DropForeignKey(name: "FK_HairCutQuery_HairPrestation_PrestationId", table: "HairCutQuery");
migrationBuilder.DropForeignKey(name: "FK_HairMultiCutQuery_Activity_ActivityCode", table: "HairMultiCutQuery");
migrationBuilder.DropForeignKey(name: "FK_HairMultiCutQuery_ApplicationUser_ClientId", table: "HairMultiCutQuery");
migrationBuilder.DropForeignKey(name: "FK_HairMultiCutQuery_PerformerProfile_PerformerId", table: "HairMultiCutQuery");
migrationBuilder.DropForeignKey(name: "FK_HairPrestationCollectionItem_HairPrestation_PrestationId", table: "HairPrestationCollectionItem");
migrationBuilder.DropForeignKey(name: "FK_HairPrestationCollectionItem_HairMultiCutQuery_QueryId", table: "HairPrestationCollectionItem");
migrationBuilder.DropForeignKey(name: "FK_HairTaint_Color_ColorId", table: "HairTaint");
migrationBuilder.DropForeignKey(name: "FK_HairTaintInstance_HairPrestation_PrestationId", table: "HairTaintInstance");
migrationBuilder.DropForeignKey(name: "FK_HairTaintInstance_HairTaint_TaintId", table: "HairTaintInstance");
migrationBuilder.DropForeignKey(name: "FK_DimissClicked_Notification_NotificationId", table: "DimissClicked");
migrationBuilder.DropForeignKey(name: "FK_DimissClicked_ApplicationUser_UserId", table: "DimissClicked");
migrationBuilder.DropForeignKey(name: "FK_Instrumentation_Instrument_InstrumentId", table: "Instrumentation");
migrationBuilder.DropForeignKey(name: "FK_PayPalPayment_ApplicationUser_ExecutorId", table: "PayPalPayment");
migrationBuilder.DropForeignKey(name: "FK_CircleMember_Circle_CircleId", table: "CircleMember");
migrationBuilder.DropForeignKey(name: "FK_CircleMember_ApplicationUser_MemberId", table: "CircleMember");
migrationBuilder.DropForeignKey(name: "FK_Contact_PostalAddress_AddressId", table: "Contact");
migrationBuilder.DropForeignKey(name: "FK_LiveFlow_ApplicationUser_OwnerId", table: "LiveFlow");
migrationBuilder.DropForeignKey(name: "FK_CommandForm_Activity_ActivityCode", table: "CommandForm");
migrationBuilder.DropForeignKey(name: "FK_PerformerProfile_Location_OrganizationAddressId", table: "PerformerProfile");
migrationBuilder.DropForeignKey(name: "FK_PerformerProfile_ApplicationUser_PerformerId", table: "PerformerProfile");
migrationBuilder.DropForeignKey(name: "FK_RdvQuery_Activity_ActivityCode", table: "RdvQuery");
migrationBuilder.DropForeignKey(name: "FK_RdvQuery_ApplicationUser_ClientId", table: "RdvQuery");
migrationBuilder.DropForeignKey(name: "FK_RdvQuery_PerformerProfile_PerformerId", table: "RdvQuery");
migrationBuilder.DropForeignKey(name: "FK_UserActivity_Activity_DoesCode", table: "UserActivity");
migrationBuilder.DropForeignKey(name: "FK_UserActivity_PerformerProfile_UserId", table: "UserActivity");
migrationBuilder.DropForeignKey(name: "FK_MailingTemplate_ApplicationUser_ManagerId", table: "MailingTemplate");
migrationBuilder.DropForeignKey(name: "FK_MailingTemplate_ApplicationUser_SuccessorId", table: "MailingTemplate");
migrationBuilder.DropForeignKey(name: "FK_Project_Activity_ActivityCode", table: "Project");
migrationBuilder.DropForeignKey(name: "FK_Project_ApplicationUser_ClientId", table: "Project");
migrationBuilder.DropForeignKey(name: "FK_Project_GitRepositoryReference_GitId", table: "Project");
migrationBuilder.DropForeignKey(name: "FK_Project_PerformerProfile_PerformerId", table: "Project");
migrationBuilder.DropForeignKey(name: "FK_ProjectBuildConfiguration_Project_ProjectId", table: "ProjectBuildConfiguration");
migrationBuilder.DropColumn(name: "DateCreated", table: "ChatRoom");
migrationBuilder.DropColumn(name: "DateModified", table: "ChatRoom");
migrationBuilder.DropColumn(name: "LatestJoinPart", table: "ChatRoom");
migrationBuilder.DropColumn(name: "UserCreated", table: "ChatRoom");
migrationBuilder.DropColumn(name: "UserModified", table: "ChatRoom");
migrationBuilder.AddForeignKey(
name: "FK_IdentityRoleClaim<string>_IdentityRole_RoleId",
table: "AspNetRoleClaims",
column: "RoleId",
principalTable: "AspNetRoles",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
migrationBuilder.AddForeignKey(
name: "FK_IdentityUserClaim<string>_ApplicationUser_UserId",
table: "AspNetUserClaims",
column: "UserId",
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
migrationBuilder.AddForeignKey(
name: "FK_IdentityUserLogin<string>_ApplicationUser_UserId",
table: "AspNetUserLogins",
column: "UserId",
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
migrationBuilder.AddForeignKey(
name: "FK_IdentityUserRole<string>_IdentityRole_RoleId",
table: "AspNetUserRoles",
column: "RoleId",
principalTable: "AspNetRoles",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
migrationBuilder.AddForeignKey(
name: "FK_IdentityUserRole<string>_ApplicationUser_UserId",
table: "AspNetUserRoles",
column: "UserId",
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
migrationBuilder.AddForeignKey(
name: "FK_Ban_ApplicationUser_TargetId",
table: "Ban",
column: "TargetId",
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
migrationBuilder.AddForeignKey(
name: "FK_BlackListed_ApplicationUser_OwnerId",
table: "BlackListed",
column: "OwnerId",
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
migrationBuilder.AddForeignKey(
name: "FK_CircleAuthorizationToBlogPost_BlogPost_BlogPostId",
table: "CircleAuthorizationToBlogPost",
column: "BlogPostId",
principalTable: "BlogPost",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
migrationBuilder.AddForeignKey(
name: "FK_CircleAuthorizationToBlogPost_Circle_CircleId",
table: "CircleAuthorizationToBlogPost",
column: "CircleId",
principalTable: "Circle",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
migrationBuilder.AddForeignKey(
name: "FK_AccountBalance_ApplicationUser_UserId",
table: "AccountBalance",
column: "UserId",
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
migrationBuilder.AddForeignKey(
name: "FK_BalanceImpact_AccountBalance_BalanceId",
table: "BalanceImpact",
column: "BalanceId",
principalTable: "AccountBalance",
principalColumn: "UserId",
onDelete: ReferentialAction.Restrict);
migrationBuilder.AddForeignKey(
name: "FK_CommandLine_Estimate_EstimateId",
table: "CommandLine",
column: "EstimateId",
principalTable: "Estimate",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
migrationBuilder.AddForeignKey(
name: "FK_Estimate_ApplicationUser_ClientId",
table: "Estimate",
column: "ClientId",
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
migrationBuilder.AddForeignKey(
name: "FK_BlogTag_BlogPost_PostId",
table: "BlogTag",
column: "PostId",
principalTable: "BlogPost",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
migrationBuilder.AddForeignKey(
name: "FK_BlogTag_Tag_TagId",
table: "BlogTag",
column: "TagId",
principalTable: "Tag",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
migrationBuilder.AddForeignKey(
name: "FK_Comment_ApplicationUser_AuthorId",
table: "Comment",
column: "AuthorId",
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
migrationBuilder.AddForeignKey(
name: "FK_Comment_BlogPost_PostId",
table: "Comment",
column: "PostId",
principalTable: "BlogPost",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
migrationBuilder.AddForeignKey(
name: "FK_Schedule_ApplicationUser_OwnerId",
table: "Schedule",
column: "OwnerId",
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
migrationBuilder.AddForeignKey(
name: "FK_ChatConnection_ApplicationUser_ApplicationUserId",
table: "ChatConnection",
column: "ApplicationUserId",
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
migrationBuilder.AddForeignKey(
name: "FK_ChatRoomAccess_ApplicationUser_UserId",
table: "ChatRoomAccess",
column: "UserId",
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
migrationBuilder.AddForeignKey(
name: "FK_BrusherProfile_PerformerProfile_UserId",
table: "BrusherProfile",
column: "UserId",
principalTable: "PerformerProfile",
principalColumn: "PerformerId",
onDelete: ReferentialAction.Restrict);
migrationBuilder.AddForeignKey(
name: "FK_HairCutQuery_Activity_ActivityCode",
table: "HairCutQuery",
column: "ActivityCode",
principalTable: "Activity",
principalColumn: "Code",
onDelete: ReferentialAction.Restrict);
migrationBuilder.AddForeignKey(
name: "FK_HairCutQuery_ApplicationUser_ClientId",
table: "HairCutQuery",
column: "ClientId",
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
migrationBuilder.AddForeignKey(
name: "FK_HairCutQuery_PerformerProfile_PerformerId",
table: "HairCutQuery",
column: "PerformerId",
principalTable: "PerformerProfile",
principalColumn: "PerformerId",
onDelete: ReferentialAction.Restrict);
migrationBuilder.AddForeignKey(
name: "FK_HairCutQuery_HairPrestation_PrestationId",
table: "HairCutQuery",
column: "PrestationId",
principalTable: "HairPrestation",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
migrationBuilder.AddForeignKey(
name: "FK_HairMultiCutQuery_Activity_ActivityCode",
table: "HairMultiCutQuery",
column: "ActivityCode",
principalTable: "Activity",
principalColumn: "Code",
onDelete: ReferentialAction.Restrict);
migrationBuilder.AddForeignKey(
name: "FK_HairMultiCutQuery_ApplicationUser_ClientId",
table: "HairMultiCutQuery",
column: "ClientId",
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
migrationBuilder.AddForeignKey(
name: "FK_HairMultiCutQuery_PerformerProfile_PerformerId",
table: "HairMultiCutQuery",
column: "PerformerId",
principalTable: "PerformerProfile",
principalColumn: "PerformerId",
onDelete: ReferentialAction.Restrict);
migrationBuilder.AddForeignKey(
name: "FK_HairPrestationCollectionItem_HairPrestation_PrestationId",
table: "HairPrestationCollectionItem",
column: "PrestationId",
principalTable: "HairPrestation",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
migrationBuilder.AddForeignKey(
name: "FK_HairPrestationCollectionItem_HairMultiCutQuery_QueryId",
table: "HairPrestationCollectionItem",
column: "QueryId",
principalTable: "HairMultiCutQuery",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
migrationBuilder.AddForeignKey(
name: "FK_HairTaint_Color_ColorId",
table: "HairTaint",
column: "ColorId",
principalTable: "Color",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
migrationBuilder.AddForeignKey(
name: "FK_HairTaintInstance_HairPrestation_PrestationId",
table: "HairTaintInstance",
column: "PrestationId",
principalTable: "HairPrestation",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
migrationBuilder.AddForeignKey(
name: "FK_HairTaintInstance_HairTaint_TaintId",
table: "HairTaintInstance",
column: "TaintId",
principalTable: "HairTaint",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
migrationBuilder.AddForeignKey(
name: "FK_DimissClicked_Notification_NotificationId",
table: "DimissClicked",
column: "NotificationId",
principalTable: "Notification",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
migrationBuilder.AddForeignKey(
name: "FK_DimissClicked_ApplicationUser_UserId",
table: "DimissClicked",
column: "UserId",
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
migrationBuilder.AddForeignKey(
name: "FK_Instrumentation_Instrument_InstrumentId",
table: "Instrumentation",
column: "InstrumentId",
principalTable: "Instrument",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
migrationBuilder.AddForeignKey(
name: "FK_PayPalPayment_ApplicationUser_ExecutorId",
table: "PayPalPayment",
column: "ExecutorId",
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
migrationBuilder.AddForeignKey(
name: "FK_CircleMember_Circle_CircleId",
table: "CircleMember",
column: "CircleId",
principalTable: "Circle",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
migrationBuilder.AddForeignKey(
name: "FK_CircleMember_ApplicationUser_MemberId",
table: "CircleMember",
column: "MemberId",
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
migrationBuilder.AddForeignKey(
name: "FK_Contact_PostalAddress_AddressId",
table: "Contact",
column: "AddressId",
principalTable: "PostalAddress",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
migrationBuilder.AddForeignKey(
name: "FK_LiveFlow_ApplicationUser_OwnerId",
table: "LiveFlow",
column: "OwnerId",
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
migrationBuilder.AddForeignKey(
name: "FK_CommandForm_Activity_ActivityCode",
table: "CommandForm",
column: "ActivityCode",
principalTable: "Activity",
principalColumn: "Code",
onDelete: ReferentialAction.Restrict);
migrationBuilder.AddForeignKey(
name: "FK_PerformerProfile_Location_OrganizationAddressId",
table: "PerformerProfile",
column: "OrganizationAddressId",
principalTable: "Location",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
migrationBuilder.AddForeignKey(
name: "FK_PerformerProfile_ApplicationUser_PerformerId",
table: "PerformerProfile",
column: "PerformerId",
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
migrationBuilder.AddForeignKey(
name: "FK_RdvQuery_Activity_ActivityCode",
table: "RdvQuery",
column: "ActivityCode",
principalTable: "Activity",
principalColumn: "Code",
onDelete: ReferentialAction.Restrict);
migrationBuilder.AddForeignKey(
name: "FK_RdvQuery_ApplicationUser_ClientId",
table: "RdvQuery",
column: "ClientId",
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
migrationBuilder.AddForeignKey(
name: "FK_RdvQuery_PerformerProfile_PerformerId",
table: "RdvQuery",
column: "PerformerId",
principalTable: "PerformerProfile",
principalColumn: "PerformerId",
onDelete: ReferentialAction.Restrict);
migrationBuilder.AddForeignKey(
name: "FK_UserActivity_Activity_DoesCode",
table: "UserActivity",
column: "DoesCode",
principalTable: "Activity",
principalColumn: "Code",
onDelete: ReferentialAction.Restrict);
migrationBuilder.AddForeignKey(
name: "FK_UserActivity_PerformerProfile_UserId",
table: "UserActivity",
column: "UserId",
principalTable: "PerformerProfile",
principalColumn: "PerformerId",
onDelete: ReferentialAction.Restrict);
migrationBuilder.AddForeignKey(
name: "FK_MailingTemplate_ApplicationUser_ManagerId",
table: "MailingTemplate",
column: "ManagerId",
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
migrationBuilder.AddForeignKey(
name: "FK_MailingTemplate_ApplicationUser_SuccessorId",
table: "MailingTemplate",
column: "SuccessorId",
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
migrationBuilder.AddForeignKey(
name: "FK_Project_Activity_ActivityCode",
table: "Project",
column: "ActivityCode",
principalTable: "Activity",
principalColumn: "Code",
onDelete: ReferentialAction.Restrict);
migrationBuilder.AddForeignKey(
name: "FK_Project_ApplicationUser_ClientId",
table: "Project",
column: "ClientId",
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
migrationBuilder.AddForeignKey(
name: "FK_Project_GitRepositoryReference_GitId",
table: "Project",
column: "GitId",
principalTable: "GitRepositoryReference",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
migrationBuilder.AddForeignKey(
name: "FK_Project_PerformerProfile_PerformerId",
table: "Project",
column: "PerformerId",
principalTable: "PerformerProfile",
principalColumn: "PerformerId",
onDelete: ReferentialAction.Restrict);
migrationBuilder.AddForeignKey(
name: "FK_ProjectBuildConfiguration_Project_ProjectId",
table: "ProjectBuildConfiguration",
column: "ProjectId",
principalTable: "Project",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
}
}
}

@ -1,6 +1,8 @@
using System;
using Microsoft.Data.Entity;
using Microsoft.Data.Entity.Infrastructure;
using Microsoft.Data.Entity.Metadata;
using Microsoft.Data.Entity.Migrations;
using Yavsc.Models;
namespace Yavsc.Migrations
@ -544,10 +546,20 @@ namespace Yavsc.Migrations
b.Property<string>("Name")
.HasAnnotation("MaxLength", 255);
b.Property<DateTime>("DateCreated");
b.Property<DateTime>("DateModified");
b.Property<DateTime>("LatestJoinPart");
b.Property<string>("OwnerId");
b.Property<string>("Topic");
b.Property<string>("UserCreated");
b.Property<string>("UserModified");
b.HasKey("Name");
});

@ -63,6 +63,8 @@ namespace Yavsc.Models
builder.Entity<Models.Cratie.Option>().HasKey(o => new { o.Code, o.CodeScrutin });
builder.Entity<Notification>().Property(n => n.icon).HasDefaultValue("exclam");
builder.Entity<ChatRoomAccess>().HasKey(p => new { room = p.ChannelName, user = p.UserId });
builder.Entity<BlackListed>().HasOne<ApplicationUser>(bl => bl.User);
builder.Entity<BlackListed>().HasOne<ApplicationUser>(bl => bl.Owner);
foreach (var et in builder.Model.GetEntityTypes())
{

@ -1,8 +0,0 @@
namespace Yavsc.Services
{
// This class is used by the application to send Email and SMS
// when you turn on two-factor authentication in ASP.NET Identity.
// For more details see this link http://go.microsoft.com/fwlink/?LinkID=532713
}

@ -47,13 +47,13 @@ namespace Yavsc.Services
throw new Exception("Spécifier un expéditeur");
if (userIds == null )
throw new NotImplementedException("Notify e No user id");
throw new Exception("Notify e No user id");
MessageWithPayloadResponse response = new MessageWithPayloadResponse();
var raa = userIds.ToArray();
if (raa.Length<1)
throw new NotImplementedException("No GCM reg ids");
throw new Exception("No dest id");
try {
_logger.LogInformation($"Sending to {string.Join(" ",raa)} using signalR : "+JsonConvert.SerializeObject(ev));
@ -68,30 +68,44 @@ namespace Yavsc.Services
var user = _dbContext.Users.FirstOrDefault(u=> u.Id == clientId);
if (user==null)
{
response.failure++;
result.error = "no such user.";
continue;
}
if (!user.EmailConfirmed){
response.failure++;
result.error = "user has not confirmed his email address.";
continue;
}
var body = ev.CreateBody();
var mailSent = await _emailSender.SendEmailAsync(
user.UserName,
user.Email,
$"{ev.Sender} (un client) vous demande un rendez-vous",
$"{ev.CreateBody()}\r\n"
);
var sent = await _emailSender.SendEmailAsync(ev.Sender, user.Email,
ev.Topic, body
);
result.message_id = sent.MessageId;
if (!sent.Sent) {
result.message_id = sent.MessageId;
result.error = sent.ErrorMessage;
response.failure++;
}
else
{
result.message_id = mailSent.MessageId;
response.success++;
}
}
else {
// we assume that each hub connected client will handle this signal
hubClient.notify(ev);
result.message_id=hubClient.notify(ev);
response.success++;
}
results.Add(result);
}
response.results = results.ToArray();
return response;

@ -129,7 +129,6 @@ namespace Yavsc {
options.AutomaticAuthenticate = true;
options.ExpireTimeSpan = TimeSpan.FromMinutes (5);
options.LoginPath = new PathString (Constants.LoginPath.Substring (1));
// TODO implement an access denied page
options.AccessDeniedPath = new PathString (Constants.LoginPath.Substring (1));
});

@ -1,59 +1,23 @@
@{ ViewBag.Title = "Chat"; }
<h2>Chat </h2>
<h2>@ViewBag.Title</h2>
<label><input type="checkbox" id="mute" />Muet</label>
<div class="container" id="chatview" class="disabled" >
<input type="hidden" id="displayname" />
<div class="panel">
<em>Salons</em>
<ul>
<li id="pubChan"><button>Public</button></li>
</ul>
<em>Utilisateurs</em>
<ul id="userlist" style="list-style:none;">
</ul>
<ul id="discussion">
</ul>
<div id="targets" >
<div id="sendmessagebox">
<div class="col-md-10">
<div class="row">
<div class='col-sm-9'> <input type="text" id="message" class="form-control"/></div>
<div class='col-sm-3'>
<input type="button" id="sendmessage" value="@SR["Send"]" class="btn btn-default"/>
</div></div></div>
</div>
@if (ViewBag.IsAuthenticated) {
<div id="sendpvbox">
<div class="col-md-10">
<div class="row">
<div class='col-sm-9'>
<input type="text" id="pv" class="form-control" />
</div>
<div class='col-sm-3'>
<button type="submit" id="sendpv" class="btn btn-default">@SR["Send a private message"] @SR["to"]
<div id="sendpvdest" ></div> </button>
</div></div></div>
</div>
}
<input type="hidden" id="mySignalRConnectionIdHidden" value="" />
</div>
</div>
</div>
<div class="container disabled panel" id="chatview" data="fullchatview"
data-chans="yavsc" data-mutectl="mute" ></div>
@section scripts {
<!--Reference the autogenerated SignalR hub script. -->
<script src="~/api/signalr/hubs"></script>
<!-- SignalR script to update the chat page and send messages.-->
@if (!ViewBag.IsAuthenticated) { // Get the user name and store it to prepend to messages.
<script>
$('#displayname').val(prompt('Entrez votre nom:', ''));
$('#chatview').data("anonuname", prompt('Entrez votre nom:', ''));
</script>
}
<script src="~/js/chat.js"></script>
<script>
</script>
}

@ -1,184 +1,303 @@
+(function ($) {
var pvuis
/*
# chat control ids
var audio = new Audio('/sounds/bell.mp3')
## inputs
function addULI (uname, cxids) {
$('<li class="user"><button><img src="/Avatars/' + uname + '.xs.png"> ' + uname + '</button></li>')
.data('name', uname)
.data('cxids', cxids)
.css('cursor', 'pointer')
.click(function () { setPrivate(this); })
.appendTo('#userlist')
}
* msg_<rname> : input providing a room message
* pv_<uname> : input providing a private message
* command : input providing server command
* roomname : input (hidden or not) providing a room name
function getUsers () {
$('#userlist').empty()
$('#to').empty()
$.get('/api/chat/users').done(
function (users) {
$.each(users, function () {
var user = this
var existent = $('#userlist li').filterByData('name', user.UserName)
if (existent.length > 0) existent.remove()
var cxids = []
$.each(user.Connections, function () {
cxids.push(this.ConnectionId)
})
addULI(user.UserName, cxids)
})
}
)
}
## persistent containers
function onCx () {
setTimeout(function () {
getUsers()
}, 120),
$('#chatview').removeClass('disabled')
$('#sendmessage').prop('disabled',false);
$('#sendpv').prop('disabled',false);
}
function onDisCx () {
$('#chatview').addClass('disabled');
$('#sendmessage').prop('disabled',true);
$('#sendpv').prop('disabled',true);
* chatview : the global container
* rooms : container from room displays
* pvs : container from pv displays
* server : container for server messages
}
// This optional function html-encodes messages for display in the page.
function htmlEncode (value) {
var encodedValue = $('<div />').text(value).html()
return encodedValue
}
## temporary containers
var setPrivate = function (li) {
$('#sendmessagebox').addClass('hidden')
$('#sendpvbox').removeClass('hidden')
pvuis = { CXs: $(li).data('cxids'), UserName: $(li).data('name') }
$('#sendpvdest').html(pvuis.UserName)
$('#pv').focus()
}
var setPublic = function () {
$('#sendmessagebox').removeClass('hidden')
$('#sendpvbox').addClass('hidden')
$('#message').focus()
}
$('#pubChan').css('cursor', 'pointer')
$('#pubChan').click(setPublic)
setPublic()
// Reference the auto-generated proxy for the hub.
var chat = $.connection.chatHub
// Create a function that the hub can call back to display messages.
chat.client.addMessage = function (name, message) {
// Add the message to the page.
$('#discussion').append('<li class="discussion"><strong>' + htmlEncode(name)
+ '</strong>: ' + htmlEncode(message) + '</li>')
}
chat.client.addPV = function (name, message) {
if (!$('#mute').prop('checked')) {
audio.play()
}
// Add the pv to the page.
$('#discussion').append('<li class="pv"><strong>' + htmlEncode(name)
+ '</strong>: ' + htmlEncode(message) + '</li>')
}
$.fn.filterByData = function (prop, val) {
return this.filter(
function () { return $(this).data(prop) == val; }
)
}
* room_<rname> : room message list
* pv_<uname> : private discussion display
var onUserDisconnected = function (cxid) {
$('#userlist li').filter(function () {
var nids = $(this).data('cxids').filter(function () {
return $(this) !== cxid
})
if (nids.Length == 0) $(this).remove()
else $(this).data('cxids', nids)
})
}
var onUserConnected = function (cxid, username) {
var connected = $('#userlist li').filterByData('name', username)
if (connected.length > 0) {
var ids = connected.data('cxids')
ids.push(cxid)
connected.data('cxids', ids)
} else {
addULI(username, [cxid])
## css classes
* form-control
* btn btn-default
*/
var ChatView = function ($view, full)
{
if (!full) throw "not implemented";
var chat = $.connection.chatHub
// Create a function that the hub can call back to display messages.
chat.client.addMessage = function (name, room, message) {
// Add the message to the page.
$('#room_'+room).append('<li class="discussion"><strong>' + htmlEncode(name)
+ '</strong>: ' + htmlEncode(message) + '</li>')
}
}
chat.client.notify = function (tag, message, data) {
if (data) {
// Add the pv to the page.
if (tag === 'connected') {
onUserConnected(message, data)
$('#discussion').append('<li class="notif"><i>' + htmlEncode(tag)
+ '</i> ' + htmlEncode(data) + '</li>')
chat.client.addPV = function (name, message) {
if (!$('#mute').prop('checked')) {
audio.play()
}
else if (tag === 'disconnected') {
onUserDisconnected(message, data)
$('#discussion').append('<li class="notif"><i>' + htmlEncode(tag)
+ '</i> ' + htmlEncode(data) + '</li>')
}else {
$('#discussion').append('<li class="notif"><i>' + htmlEncode(tag)
+ '</i> ' + htmlEncode(message) + ' : ' + htmlEncode(data) + '</li>')
// Add the pv to the page.
$('#pv_'+name).append('<li class="pv"><strong>' + htmlEncode(name)
+ '</strong>: ' + htmlEncode(message) + '</li>')
}
chat.client.notify = function (tag, message, data) {
if (data) {
// Add the notification to the page.
if (tag === 'connected') {
onUserConnected(ulist, message, data)
$('#notifications').append('<li class="notif"><i>' + htmlEncode(tag)
+ '</i> ' + htmlEncode(data) + '</li>')
}
else if (tag === 'disconnected') {
onUserDisconnected(ulist, message, data)
$('#notifications').append('<li class="notif"><i>' + htmlEncode(tag)
+ '</i> ' + htmlEncode(data) + '</li>')
} // reconnected userpart userjoin deniedpv
else {
$('#notifications').append('<li class="notif"><i>' + htmlEncode(tag)
+ '</i> ' + htmlEncode(message) + ' : <code>' + htmlEncode(data) + '</code></li>')
}
}
}
}
var sendMessage = function () {
chat.server.send($('#displayname').val(), $('#message').val())
// Clear text box and reset focus for next comment.
$('#message').val('')
}
chat.client.onJoined = function (rinfo)
{
console.log(rinfo);
$('#inp_'+rinfo.Name).prop('enable',true)
}
$.fn.filterByData = function (prop, val) {
return this.filter(
function () { return $(this).data(prop) == val; }
)
}
var roomlist = $("<div class='roomlist' border='dashed'></div>");
roomlist.appendTo($view);
var buildRoom = function (room)
{
console.log('building:'+room);
var roomTag = $("<a>"+room+"</a>");
roomTag.addClass('btn').addClass('default')
.click(function(){
setRoom(room)
});
var roomview = $("<div></div>");
roomTag.appendTo(roomlist);
roomview.prop('id',"vroom_"+room);
var msglist = $("<ul class=\"mesglist\"></ul>");
msglist.prop('id',"room_"+room);
msglist.appendTo(roomview);
$("<input type=\"text\">")
.prop('id','inp_'+room)
.prop('enable',false)
.prop('hint','hello')
.prop('title','send to '+room)
.keydown(function(ev){
if (ev.which == 13) {
console.log('sending:'+room+' '+this.value);
chat.server.send(room, this.value)
this.value=""
}
}).appendTo(roomview);
chans.push(room);
roomview.appendTo($view);
console.log('done with built:');
console.log(chans);
}
// build a channel list
var chans = Array();
$view.data("chans").split(",").forEach(function(chan) {
buildRoom(chan)
});
function onCx () {
setTimeout(function () {
getUsers()
}, 120),
$('#chatview').removeClass('disabled');
chans.forEach(function(room) {
chat.server.join(room);
})
}
function onDisCx () {
$('#chatview').addClass('disabled');
}
var sendPV = function () {
var msg = $('#pv').val()
// Call the Send method on the hub.
$.each(pvuis.CXs, function () {
chat.server.sendPV(this, msg)
// Start the connection.
$.connection.hub.start().done(function () {
onCx()
})
$('#discussion').append('<li class="pv">' + htmlEncode(pvuis.UserName)
+ '<< ' + htmlEncode(msg) + '</li>')
// Clear text box and reset focus for next comment.
$('#pv').val('')
}
// Start the connection.
$.connection.hub.start().done(function () {
onCx()
$('#sendmessage').click(function () {
// Call the Send method on the hub.
sendMessage()
$('#message').focus()
$.connection.hub.disconnected(function () {
onDisCx()
setTimeout(function () {
$.connection.hub.start().done(function () {
// $('#mySignalRConnectionIdHidden').val($.connection.hub.id)
onCx()
}, 30000); // Re-start connection after 30 seconds
})
})
$('#message').keydown(function (event) {
$("<label for=\"channame\">&gt;&nbsp;</label>")
.appendTo($view);
var chanName = $("<input name=\"channame\" title=\"channel name\" hint=\"yavsc\">");
chanName.appendTo($view);
chanName.keydown(
function (event) {
if (event.which == 13) {
sendMessage()
buildRoom(this.value);
this.value=""
} else {
// TODO showRoomInfo(this.value);
}
})
});
var ulist = $("<ul></ul>").addClass('userlist');
ulist.appendTo($view);
var activeRoom;
var setRoom = function(room) {
if (activeRoom) {
// TODO animate
activeRoom.addClass("hidden");
}
activeRoom=$("#vroom_"+room);
activeRoom.removeClass("hidden")
}
var pvuis
// TODO get this data from the chatview element
var audio = new Audio('/sounds/bell.mp3')
var sendPV = function () {
var msg = $('#pv').val()
// Call the Send method on the hub.
$.each(pvuis.CXs, function () {
chat.server.sendPV(this, msg)
})
$('#discussion').append('<li class="pv">' + htmlEncode(pvuis.UserName)
+ '<< ' + htmlEncode(msg) + '</li>')
// Clear text box and reset focus for next comment.
$('#pv').val('')
}
$('#pv').keydown(function (event) {
if (event.which == 13) {
sendPV()
}
})
$('#sendpv').click(function () {
// Call the Send method on the hub.
sendPV()
$('#sendpv').focus()
})
})
$.connection.hub.disconnected(function () {
onDisCx()
setTimeout(function () {
$.connection.hub.start().done(function () {
$('#mySignalRConnectionIdHidden').val($.connection.hub.id)
onCx()
}, 30000); // Re-start connection after 30 seconds
$('#command').keydown(function (event) {
if (event.which == 13) {
sendCommand()
}
})
})
$(window).unload(function () { chat.server.abort(); })
function addChatUser (ulist, uname, cxids) {
$('<li class="user"><img src="/Avatars/' + uname + '.xs.png"> ' + uname + '</li>')
.data('name', uname)
.data('cxids', cxids)
.css('cursor', 'pointer')
.click(function () { setPrivateTarget(this); })
.appendTo(ulist)
}
function getUsers (ulist) {
$('#userlist').empty()
$('#to').empty()
$.get('/api/chat/users').done(
function (users) {
$.each(users, function () {
var user = this
var existent = $('#userlist li').filterByData('name', user.UserName)
if (existent.length > 0) existent.remove()
var cxids = []
$.each(user.Connections, function () {
cxids.push(this.ConnectionId)
})
addChatUser(ulist,user.UserName, cxids)
})
}
)
}
// This optional function html-encodes messages for display in the page.
function htmlEncode (value) {
var encodedValue = $('<div />').text(value).html()
return encodedValue
}
var setPrivateTarget = function (li) {
$('#rooms').addClass('hidden')
$('#sendpvbox').removeClass('hidden')
pvuis = { CXs: $(li).data('cxids'), UserName: $(li).data('name') }
$('#sendpvdest').html(pvuis.UserName)
$('#pvs').focus()
}
var setPublic = function () {
$('#rooms').removeClass('hidden')
$('#sendpvbox').addClass('hidden')
$('#message').focus()
}
$('#pubChan').css('cursor', 'pointer')
$('#pubChan').click(setPublic)
setPublic()
// Reference the auto-generated proxy for the hub.
var onUserDisconnected = function (cxid) {
$('#userlist li').filter(function () {
var nids = $(this).data('cxids').filter(function () {
return $(this) !== cxid
});
if (nids.length==0) $(this).remove()
else $(this).data('cxids', nids)
})
}
var onUserConnected = function (ulist, cxid, username) {
var connected = $('#userlist li').filterByData('name', username)
if (connected.length > 0) {
var ids = connected.data('cxids')
ids.push(cxid)
connected.data('cxids', ids)
} else {
addChatUser(ulist, username, [cxid])
}
}
$(window).unload(function () { chat.server.abort(); })
}
$(document).ready(function($){
ChatView($('#chatview'),true);
});
})(jQuery);

@ -26,6 +26,9 @@ $(document).ready(function($){
var $stheight = $(window).height();
var onPos = function (bgobj,ax,ay) {
// save pos for scrolling
tiltLR=ax;
titleFB=ay;
var speed = bgobj.data('speed');
var dx=($window.scrollLeft()+ax-$stwidth/2)/speed;
var dy=($window.scrollTop()+ay-$stheight/2)/speed;
@ -83,13 +86,9 @@ $(document).ready(function($){
if (window.DeviceOrientationEvent) {
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/90);
onPos($bgobj,tiltLR,titleFB);
onPos($bgobj,$stwidth*Math.sin(event.gamma*Math.PI/180),$stheight*Math.sin(event.beta*Math.PI/90));
},false); }
$(window).mousemove(function(e) {
tiltLR = e.pageX;
titleFB = e.pageY;
onPos($bgobj,e.pageX,e.pageY);
});
}

Loading…