[WIP] Live flow
This commit is contained in:
@ -39,11 +39,13 @@ namespace Yavsc.Controllers
|
||||
_dbContext = context;
|
||||
_logger = loggerFactory.CreateLogger<LiveApiController>();
|
||||
}
|
||||
[HttpGet("filenamehint/{id}")]
|
||||
public async Task<string[]> GetFileNameHint(string id)
|
||||
{
|
||||
return await _dbContext.Tags.Where( t=> t.Name.StartsWith(id)).Select(t=>t.Name).Take(25).ToArrayAsync();
|
||||
}
|
||||
|
||||
[HttpGet("live/{id}")]
|
||||
public async Task<IActionResult> GetLive(string id)
|
||||
{
|
||||
if (!HttpContext.WebSockets.IsWebSocketRequest) return new BadRequestResult();
|
||||
@ -59,91 +61,10 @@ namespace Yavsc.Controllers
|
||||
return HttpBadRequest("Listeners.TryAdd returned false");
|
||||
}
|
||||
|
||||
public async Task<IActionResult> Cast(long id)
|
||||
{
|
||||
// ensure this request is for a websocket
|
||||
if (!HttpContext.WebSockets.IsWebSocketRequest) return new BadRequestResult();
|
||||
|
||||
var uname = User.GetUserName();
|
||||
// ensure uniqueness of casting stream from this user
|
||||
var existent = Casters[uname];
|
||||
if (existent != null)
|
||||
{
|
||||
ModelState.AddModelError("error","not supported, you already casting, there's support for one live streaming only");
|
||||
return new BadRequestObjectResult(ModelState);
|
||||
}
|
||||
var uid = User.GetUserId();
|
||||
// get some setup from user
|
||||
var flow = _dbContext.LiveFlow.Include(f=>f.Owner).SingleOrDefault(f=> (f.OwnerId==uid && f.Id == id));
|
||||
if (flow == null)
|
||||
{
|
||||
ModelState.AddModelError("error",$"You don't own any flow with the id {id}");
|
||||
return new BadRequestObjectResult (ModelState);
|
||||
}
|
||||
|
||||
// Accept the socket
|
||||
var meta = new LiveCastMeta { Socket = await HttpContext.WebSockets.AcceptWebSocketAsync() };
|
||||
// Dispatch the flow
|
||||
using (meta.Socket)
|
||||
{
|
||||
if (meta.Socket != null && meta.Socket.State == WebSocketState.Open)
|
||||
{
|
||||
Casters[uname] = meta;
|
||||
// TODO: Handle the socket here.
|
||||
// Find receivers: others in the chat room
|
||||
// send them the flow
|
||||
|
||||
byte[] buffer = new byte[1024];
|
||||
WebSocketReceiveResult received = await meta.Socket.ReceiveAsync
|
||||
(new ArraySegment<byte>(buffer), CancellationToken.None);
|
||||
|
||||
var hubContext = GlobalHost.ConnectionManager.GetHubContext<ChatHub>();
|
||||
|
||||
hubContext.Clients.All.addPublicStream(new { id = flow.Id, sender = flow.Owner.UserName, title = flow.Title, url = flow.GetFileUrl(),
|
||||
mediaType = flow.MediaType }, $"{flow.Owner.UserName} is starting a stream!");
|
||||
|
||||
// FIXME do we really need to close those one in invalid state ?
|
||||
Stack<string> ToClose = new Stack<string>();
|
||||
|
||||
while (received.MessageType != WebSocketMessageType.Close)
|
||||
{
|
||||
_logger.LogInformation($"Echoing {received.Count} bytes received in a {received.MessageType} message; Fin={received.EndOfMessage}");
|
||||
// Echo anything we receive
|
||||
// and send to all listner found
|
||||
foreach (var cliItem in meta.Listeners)
|
||||
{
|
||||
var listenningSocket = cliItem.Value;
|
||||
if (listenningSocket.State == WebSocketState.Open)
|
||||
await listenningSocket.SendAsync(new ArraySegment<byte>
|
||||
(buffer, 0, received.Count), received.MessageType, received.EndOfMessage, CancellationToken.None);
|
||||
else ToClose.Push(cliItem.Key);
|
||||
}
|
||||
received = await meta.Socket.ReceiveAsync(new ArraySegment<byte>(buffer), CancellationToken.None);
|
||||
|
||||
string no;
|
||||
do
|
||||
{
|
||||
no = ToClose.Pop();
|
||||
WebSocket listenningSocket;
|
||||
if (meta.Listeners.TryRemove(no, out listenningSocket))
|
||||
await listenningSocket.CloseAsync(WebSocketCloseStatus.EndpointUnavailable, "State != WebSocketState.Open", CancellationToken.None);
|
||||
|
||||
} while (no != null);
|
||||
}
|
||||
await meta.Socket.CloseAsync(received.CloseStatus.Value, received.CloseStatusDescription, CancellationToken.None);
|
||||
Casters[uname] = null;
|
||||
}
|
||||
else _logger.LogInformation($"failed (meta.Socket != null && meta.Socket.State == WebSocketState.Open)");
|
||||
}
|
||||
|
||||
return Ok();
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Lists user's live castings
|
||||
/// </summary>
|
||||
/// <param name="id">user id</param>
|
||||
/// <param name="meta/id">user id</param>
|
||||
/// <returns></returns>
|
||||
public IActionResult Index(long? id)
|
||||
{
|
||||
@ -158,7 +79,7 @@ namespace Yavsc.Controllers
|
||||
}
|
||||
|
||||
|
||||
[HttpGet("{id}", Name = "GetLiveFlow")]
|
||||
[HttpGet("meta/{id}")]
|
||||
public async Task<IActionResult> GetLiveFlow([FromRoute] long id)
|
||||
{
|
||||
if (!ModelState.IsValid)
|
||||
@ -176,7 +97,7 @@ namespace Yavsc.Controllers
|
||||
return Ok(liveFlow);
|
||||
}
|
||||
|
||||
[HttpPut("{id}")]
|
||||
[HttpPut("meta/{id}")]
|
||||
public async Task<IActionResult> PutLiveFlow([FromRoute] long id, [FromBody] LiveFlow liveFlow)
|
||||
{
|
||||
if (!ModelState.IsValid)
|
||||
@ -216,7 +137,7 @@ namespace Yavsc.Controllers
|
||||
return new HttpStatusCodeResult(StatusCodes.Status204NoContent);
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[HttpPost("meta")]
|
||||
public async Task<IActionResult> PostLiveFlow([FromBody] LiveFlow liveFlow)
|
||||
{
|
||||
if (!ModelState.IsValid)
|
||||
@ -248,7 +169,7 @@ namespace Yavsc.Controllers
|
||||
}
|
||||
|
||||
// DELETE: api/LiveApi/5
|
||||
[HttpDelete("{id}")]
|
||||
[HttpDelete("meta/{id}")]
|
||||
public async Task<IActionResult> DeleteLiveFlow([FromRoute] long id)
|
||||
{
|
||||
if (!ModelState.IsValid)
|
||||
|
183
src/Yavsc/Controllers/LiveFlowController.cs
Normal file
183
src/Yavsc/Controllers/LiveFlowController.cs
Normal file
@ -0,0 +1,183 @@
|
||||
using System.Linq;
|
||||
using System.Security.Claims;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNet.Authorization;
|
||||
using Microsoft.AspNet.Mvc;
|
||||
using Microsoft.AspNet.Mvc.Rendering;
|
||||
using Microsoft.Data.Entity;
|
||||
using Yavsc.Models;
|
||||
using Yavsc.Models.Streaming;
|
||||
|
||||
namespace Yavsc.Controllers
|
||||
{
|
||||
public class LiveFlowController : Controller
|
||||
{
|
||||
private ApplicationDbContext _context;
|
||||
|
||||
public LiveFlowController(ApplicationDbContext context)
|
||||
{
|
||||
_context = context;
|
||||
}
|
||||
|
||||
// GET: LiveFlow
|
||||
public async Task<IActionResult> Index()
|
||||
{
|
||||
var uid = User.GetUserId();
|
||||
var applicationDbContext = _context.LiveFlow.Where(f=>f.OwnerId == uid);
|
||||
return View(await applicationDbContext.ToListAsync());
|
||||
}
|
||||
|
||||
public async Task<IActionResult> AdminIndex()
|
||||
{
|
||||
var applicationDbContext = _context.LiveFlow.Include(l => l.Owner);
|
||||
return View(await applicationDbContext.ToListAsync());
|
||||
}
|
||||
|
||||
// GET: LiveFlow/Details/5
|
||||
public async Task<IActionResult> Details(long? id)
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
|
||||
LiveFlow liveFlow = await _context.LiveFlow.SingleAsync(m => m.Id == id);
|
||||
if (liveFlow == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
|
||||
return View(liveFlow);
|
||||
}
|
||||
|
||||
// GET: LiveFlow/Create
|
||||
public IActionResult Create()
|
||||
{
|
||||
ViewData["OwnerId"] = new SelectList(_context.ApplicationUser, "Id", "Owner");
|
||||
return View();
|
||||
}
|
||||
|
||||
// POST: LiveFlow/Create
|
||||
[HttpPost]
|
||||
[ValidateAntiForgeryToken]
|
||||
public async Task<IActionResult> Create(LiveFlow liveFlow)
|
||||
{
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
_context.LiveFlow.Add(liveFlow);
|
||||
await _context.SaveChangesAsync();
|
||||
return RedirectToAction("Index");
|
||||
}
|
||||
ViewData["OwnerId"] = new SelectList(_context.ApplicationUser, "Id", "Owner", liveFlow.OwnerId);
|
||||
return View(liveFlow);
|
||||
}
|
||||
|
||||
// GET: LiveFlow/Edit/5
|
||||
public async Task<IActionResult> Edit(long? id)
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
|
||||
LiveFlow liveFlow = await _context.LiveFlow.SingleAsync(m => m.Id == id);
|
||||
if (liveFlow == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
|
||||
return View(liveFlow);
|
||||
}
|
||||
|
||||
public async Task<IActionResult> AdminEdit(long? id)
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
|
||||
LiveFlow liveFlow = await _context.LiveFlow.SingleAsync(m => m.Id == id);
|
||||
if (liveFlow == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
|
||||
ViewBag.OwnerId = _context.ApplicationUser.Select
|
||||
(u=> new SelectListItem(){Text=u.UserName,Value=u.Id,Selected=liveFlow.OwnerId==u.Id});
|
||||
return View("AdminEdit", liveFlow);
|
||||
}
|
||||
// POST: LiveFlow/Edit/5
|
||||
[HttpPost]
|
||||
[ValidateAntiForgeryToken]
|
||||
public async Task<IActionResult> Edit(LiveFlow liveFlow)
|
||||
{
|
||||
if (User.GetUserId()!=liveFlow.OwnerId)
|
||||
{
|
||||
ModelState.AddModelError("OwnerId","denied");
|
||||
}
|
||||
else if (ModelState.IsValid)
|
||||
{
|
||||
_context.Update(liveFlow);
|
||||
await _context.SaveChangesAsync();
|
||||
return RedirectToAction("Index");
|
||||
}
|
||||
return View(liveFlow);
|
||||
}
|
||||
|
||||
|
||||
// POST: LiveFlow/Edit/5
|
||||
[HttpPost]
|
||||
[ValidateAntiForgeryToken]
|
||||
[Authorize("AdministratorOnly")]
|
||||
public async Task<IActionResult> AdminEdit(LiveFlow liveFlow)
|
||||
{
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
_context.Update(liveFlow);
|
||||
await _context.SaveChangesAsync();
|
||||
return RedirectToAction("Index");
|
||||
}
|
||||
ViewData["OwnerId"] = new SelectList(_context.ApplicationUser, "Id", "Owner", liveFlow.OwnerId);
|
||||
return View(liveFlow);
|
||||
}
|
||||
|
||||
// GET: LiveFlow/Delete/5
|
||||
[ActionName("Delete")]
|
||||
public async Task<IActionResult> Delete(long? id)
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
LiveFlow liveFlow = await _context.LiveFlow.SingleAsync(m => m.Id == id);
|
||||
|
||||
if (liveFlow == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
else if (User.GetUserId()!=liveFlow.OwnerId)
|
||||
{
|
||||
ModelState.AddModelError("OwnerId","denied");
|
||||
}
|
||||
|
||||
return View(liveFlow);
|
||||
}
|
||||
|
||||
// POST: LiveFlow/Delete/5
|
||||
[HttpPost, ActionName("Delete")]
|
||||
[ValidateAntiForgeryToken]
|
||||
public async Task<IActionResult> DeleteConfirmed(long id)
|
||||
{
|
||||
LiveFlow liveFlow = await _context.LiveFlow.SingleAsync(m => m.Id == id);
|
||||
if (User.GetUserId()!=liveFlow.OwnerId)
|
||||
{
|
||||
ModelState.AddModelError("OwnerId","denied");
|
||||
} else
|
||||
{
|
||||
_context.LiveFlow.Remove(liveFlow);
|
||||
await _context.SaveChangesAsync();
|
||||
}
|
||||
return RedirectToAction("Index");
|
||||
}
|
||||
}
|
||||
}
|
1996
src/Yavsc/Migrations/20190204162909_liveFlowSeqnum.Designer.cs
generated
Normal file
1996
src/Yavsc/Migrations/20190204162909_liveFlowSeqnum.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
855
src/Yavsc/Migrations/20190204162909_liveFlowSeqnum.cs
Normal file
855
src/Yavsc/Migrations/20190204162909_liveFlowSeqnum.cs
Normal file
@ -0,0 +1,855 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.Data.Entity.Migrations;
|
||||
|
||||
namespace Yavsc.Migrations
|
||||
{
|
||||
public partial class liveFlowSeqnum : 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_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_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_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<int>(
|
||||
name: "SequenceNumber",
|
||||
table: "LiveFlow",
|
||||
nullable: false,
|
||||
defaultValue: 0);
|
||||
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_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_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_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_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_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_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: "SequenceNumber", table: "LiveFlow");
|
||||
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_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_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_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);
|
||||
}
|
||||
}
|
||||
}
|
@ -1171,16 +1171,22 @@ namespace Yavsc.Migrations
|
||||
b.Property<long>("Id")
|
||||
.ValueGeneratedOnAdd();
|
||||
|
||||
b.Property<string>("DifferedFileName");
|
||||
b.Property<string>("DifferedFileName")
|
||||
.HasAnnotation("MaxLength", 255);
|
||||
|
||||
b.Property<string>("MediaType");
|
||||
b.Property<string>("MediaType")
|
||||
.HasAnnotation("MaxLength", 127);
|
||||
|
||||
b.Property<string>("OwnerId")
|
||||
.IsRequired();
|
||||
|
||||
b.Property<string>("Pitch");
|
||||
b.Property<string>("Pitch")
|
||||
.HasAnnotation("MaxLength", 1023);
|
||||
|
||||
b.Property<string>("Title");
|
||||
b.Property<int>("SequenceNumber");
|
||||
|
||||
b.Property<string>("Title")
|
||||
.HasAnnotation("MaxLength", 255);
|
||||
|
||||
b.HasKey("Id");
|
||||
});
|
||||
|
@ -90,7 +90,8 @@ namespace Yavsc {
|
||||
SiteSettings settingsOptions, ILogger logger) {
|
||||
|
||||
app.UseIdentity ();
|
||||
app.UseWhen (context => context.Request.Path.StartsWithSegments ("/api"),
|
||||
app.UseWhen (context => context.Request.Path.StartsWithSegments ("/api")
|
||||
|| context.Request.Path.StartsWithSegments ("/live"),
|
||||
branch => {
|
||||
branch.UseJwtBearerAuthentication (
|
||||
options => {
|
||||
@ -104,7 +105,7 @@ namespace Yavsc {
|
||||
);
|
||||
|
||||
});
|
||||
app.UseWhen (context => !context.Request.Path.StartsWithSegments ("/api"),
|
||||
app.UseWhen (context => !context.Request.Path.StartsWithSegments ("/api") && !context.Request.Path.StartsWithSegments ("/live"),
|
||||
branch => {
|
||||
// External authentication shared cookie:
|
||||
branch.UseCookieAuthentication (options => {
|
||||
|
@ -1,5 +1,11 @@
|
||||
using System;
|
||||
using System.Net.WebSockets;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNet.Builder;
|
||||
using Microsoft.AspNet.Hosting;
|
||||
using Microsoft.AspNet.Http;
|
||||
using Microsoft.AspNet.WebSockets.Server;
|
||||
|
||||
namespace Yavsc
|
||||
{
|
||||
@ -8,8 +14,31 @@ namespace Yavsc
|
||||
public void ConfigureWebSocketsApp(IApplicationBuilder app,
|
||||
SiteSettings siteSettings, IHostingEnvironment env)
|
||||
{
|
||||
app.UseWebSockets();
|
||||
var webSocketOptions = new WebSocketOptions()
|
||||
{
|
||||
KeepAliveInterval = TimeSpan.FromSeconds(120),
|
||||
ReceiveBufferSize = 4 * 1024,
|
||||
ReplaceFeature = true
|
||||
};
|
||||
app.UseWebSockets(webSocketOptions);
|
||||
app.UseSignalR(Constants.SignalRPath);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
private async Task Echo(HttpContext context, WebSocket webSocket)
|
||||
{
|
||||
var buffer = new byte[1024 * 4];
|
||||
WebSocketReceiveResult result = await webSocket.ReceiveAsync(new ArraySegment<byte>(buffer), CancellationToken.None);
|
||||
while (!result.CloseStatus.HasValue)
|
||||
{
|
||||
await webSocket.SendAsync(new ArraySegment<byte>(buffer, 0, result.Count), result.MessageType, result.EndOfMessage, CancellationToken.None);
|
||||
|
||||
result = await webSocket.ReceiveAsync(new ArraySegment<byte>(buffer), CancellationToken.None);
|
||||
}
|
||||
await webSocket.CloseAsync(result.CloseStatus.Value, result.CloseStatusDescription, CancellationToken.None);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -16,7 +16,6 @@ using Microsoft.AspNet.Mvc.Razor;
|
||||
using Microsoft.Data.Entity;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.Extensions.OptionsModel;
|
||||
using Microsoft.Extensions.PlatformAbstractions;
|
||||
using Microsoft.Net.Http.Headers;
|
||||
@ -25,16 +24,26 @@ using Newtonsoft.Json;
|
||||
namespace Yavsc
|
||||
{
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Net.WebSockets;
|
||||
using System.Security.Claims;
|
||||
using System.Threading;
|
||||
using Formatters;
|
||||
using Google.Apis.Util.Store;
|
||||
using Microsoft.AspNet.Http;
|
||||
using Microsoft.AspNet.Identity;
|
||||
using Microsoft.AspNet.SignalR;
|
||||
using Microsoft.Extensions.Localization;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Models;
|
||||
using PayPal.Manager;
|
||||
using Services;
|
||||
using Yavsc.Abstract.FileSystem;
|
||||
using Yavsc.AuthorizationHandlers;
|
||||
using Yavsc.Controllers;
|
||||
using Yavsc.Helpers;
|
||||
using Yavsc.ViewModels.Streaming;
|
||||
using static System.Environment;
|
||||
|
||||
public partial class Startup
|
||||
@ -51,6 +60,10 @@ namespace Yavsc
|
||||
public static PayPalSettings PayPalSettings { get; private set; }
|
||||
private static ILogger logger;
|
||||
|
||||
// leave the final slash
|
||||
|
||||
PathString liveCastingPath = "/live/cast";
|
||||
|
||||
public Startup(IHostingEnvironment env, IApplicationEnvironment appEnv)
|
||||
{
|
||||
var devtag = env.IsDevelopment()?"D":"";
|
||||
@ -397,11 +410,10 @@ namespace Yavsc
|
||||
|
||||
ConfigureOAuthApp(app, SiteSetup, logger);
|
||||
ConfigureFileServerApp(app, SiteSetup, env, authorizationService);
|
||||
ConfigureWebSocketsApp(app, SiteSetup, env);
|
||||
ConfigureWorkflow(app, SiteSetup, logger);
|
||||
app.UseRequestLocalization(localizationOptions.Value, (RequestCulture) new RequestCulture((string)"en-US"));
|
||||
|
||||
|
||||
ConfigureWorkflow(app, SiteSetup, logger);
|
||||
ConfigureWebSocketsApp(app, SiteSetup, env);
|
||||
app.UseMvc(routes =>
|
||||
{
|
||||
routes.MapRoute(
|
||||
@ -409,7 +421,105 @@ namespace Yavsc
|
||||
template: "{controller=Home}/{action=Index}/{id?}");
|
||||
});
|
||||
logger.LogInformation("LocalApplicationData: "+Environment.GetFolderPath(SpecialFolder.LocalApplicationData, SpecialFolderOption.DoNotVerify));
|
||||
app.Use(async (context, next) =>
|
||||
{
|
||||
var liveCasting = context.Request.Path.StartsWithSegments(liveCastingPath);
|
||||
if (liveCasting)
|
||||
{
|
||||
|
||||
// ensure this request is for a websocket
|
||||
if (context.WebSockets.IsWebSocketRequest)
|
||||
{
|
||||
if (!context.User.Identity.IsAuthenticated)
|
||||
context.Response.StatusCode = 403;
|
||||
else {
|
||||
// get the flow id from request path
|
||||
var castid = long.Parse(context.Request.Path.Value.Substring(liveCastingPath.Value.Length+1));
|
||||
|
||||
|
||||
var uname = context.User.GetUserName();
|
||||
// ensure uniqueness of casting stream from this user
|
||||
if (LiveApiController.Casters.ContainsKey(uname))
|
||||
{
|
||||
logger.LogWarning("already casting: "+uname);
|
||||
context.Response.StatusCode = 400;
|
||||
}
|
||||
else {
|
||||
|
||||
var uid = context.User.GetUserId();
|
||||
// get some setup from user
|
||||
var flow = _dbContext.LiveFlow.Include(f=>f.Owner).SingleOrDefault(f=> (f.OwnerId==uid && f.Id == castid));
|
||||
if (flow == null)
|
||||
{
|
||||
context.Response.StatusCode = 400;
|
||||
}
|
||||
else {
|
||||
// Accept the socket
|
||||
var meta = new LiveCastMeta { Socket = await context.WebSockets.AcceptWebSocketAsync() };
|
||||
logger.LogInformation("Accepted web socket");
|
||||
// Dispatch the flow
|
||||
|
||||
if (meta.Socket != null && meta.Socket.State == WebSocketState.Open)
|
||||
{
|
||||
LiveApiController.Casters[uname] = meta;
|
||||
// TODO: Handle the socket here.
|
||||
// Find receivers: others in the chat room
|
||||
// send them the flow
|
||||
|
||||
var sBuffer = System.Net.WebSockets.WebSocket.CreateServerBuffer(1024);
|
||||
logger.LogInformation("Receiving bytes...");
|
||||
|
||||
WebSocketReceiveResult received = await meta.Socket.ReceiveAsync(sBuffer, CancellationToken.None);
|
||||
logger.LogInformation("Received bytes!!!!");
|
||||
|
||||
var hubContext = GlobalHost.ConnectionManager.GetHubContext<ChatHub>();
|
||||
|
||||
hubContext.Clients.All.addPublicStream(new { id = flow.Id, sender = flow.Owner.UserName, title = flow.Title, url = flow.GetFileUrl(),
|
||||
mediaType = flow.MediaType }, $"{flow.Owner.UserName} is starting a stream!");
|
||||
|
||||
// FIXME do we really need to close those one in invalid state ?
|
||||
Stack<string> ToClose = new Stack<string>();
|
||||
|
||||
while (received.MessageType != WebSocketMessageType.Close)
|
||||
{
|
||||
logger.LogInformation($"Echoing {received.Count} bytes received in a {received.MessageType} message; Fin={received.EndOfMessage}");
|
||||
// Echo anything we receive
|
||||
// and send to all listner found
|
||||
foreach (var cliItem in meta.Listeners)
|
||||
{
|
||||
var listenningSocket = cliItem.Value;
|
||||
if (listenningSocket.State == WebSocketState.Open)
|
||||
await listenningSocket.SendAsync(
|
||||
sBuffer, received.MessageType, received.EndOfMessage, CancellationToken.None);
|
||||
else ToClose.Push(cliItem.Key);
|
||||
}
|
||||
received = await meta.Socket.ReceiveAsync(sBuffer, CancellationToken.None);
|
||||
|
||||
string no;
|
||||
do
|
||||
{
|
||||
no = ToClose.Pop();
|
||||
WebSocket listenningSocket;
|
||||
if (meta.Listeners.TryRemove(no, out listenningSocket))
|
||||
await listenningSocket.CloseAsync(WebSocketCloseStatus.EndpointUnavailable, "State != WebSocketState.Open", CancellationToken.None);
|
||||
|
||||
} while (no != null);
|
||||
}
|
||||
await meta.Socket.CloseAsync(received.CloseStatus.Value, received.CloseStatusDescription, CancellationToken.None);
|
||||
LiveApiController.Casters[uname] = null;
|
||||
}
|
||||
else { // not meta.Socket != null && meta.Socket.State == WebSocketState.Open
|
||||
if (meta.Socket != null)
|
||||
logger.LogError($"meta.Socket.State: {meta.Socket.State.ToString()} ");
|
||||
else logger.LogError("socket object is null");
|
||||
}
|
||||
}}}}}
|
||||
else
|
||||
{
|
||||
await next();
|
||||
}
|
||||
|
||||
});
|
||||
CheckApp(app, SiteSetup, env, loggerFactory);
|
||||
}
|
||||
|
||||
|
68
src/Yavsc/Views/LiveFlow/AdminEdit.cshtml
Normal file
68
src/Yavsc/Views/LiveFlow/AdminEdit.cshtml
Normal file
@ -0,0 +1,68 @@
|
||||
@model Yavsc.Models.Streaming.LiveFlow
|
||||
|
||||
@{
|
||||
ViewData["Title"] = SR["Edit"];
|
||||
}
|
||||
|
||||
<h2>Edit</h2>
|
||||
|
||||
<form asp-action="AdminEdit">
|
||||
<div class="form-horizontal">
|
||||
<h4>LiveFlow</h4>
|
||||
<hr />
|
||||
<div asp-validation-summary="ValidationSummary.ModelOnly" class="text-danger"></div>
|
||||
<input type="hidden" asp-for="Id" />
|
||||
<div class="form-group">
|
||||
<label asp-for="DifferedFileName" class="col-md-2 control-label"></label>
|
||||
<div class="col-md-10">
|
||||
<input asp-for="DifferedFileName" class="form-control" />
|
||||
<span asp-validation-for="DifferedFileName" class="text-danger" ></span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="MediaType" class="col-md-2 control-label"></label>
|
||||
<div class="col-md-10">
|
||||
<input asp-for="MediaType" class="form-control" />
|
||||
<span asp-validation-for="MediaType" class="text-danger" ></span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="OwnerId" class="control-label col-md-2">OwnerId</label>
|
||||
<div class="col-md-10">
|
||||
<select asp-for="OwnerId" class="form-control" asp-items="@ViewBag.OwnerId"></select>
|
||||
<span asp-validation-for="OwnerId" class="text-danger" ></span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="Pitch" class="col-md-2 control-label"></label>
|
||||
<div class="col-md-10">
|
||||
<input asp-for="Pitch" class="form-control" />
|
||||
<span asp-validation-for="Pitch" class="text-danger" ></span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="SequenceNumber" class="col-md-2 control-label"></label>
|
||||
<div class="col-md-10">
|
||||
<input asp-for="SequenceNumber" class="form-control" />
|
||||
<span asp-validation-for="SequenceNumber" class="text-danger" ></span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="Title" class="col-md-2 control-label"></label>
|
||||
<div class="col-md-10">
|
||||
<input asp-for="Title" class="form-control" />
|
||||
<span asp-validation-for="Title" class="text-danger" ></span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<div class="col-md-offset-2 col-md-10">
|
||||
<input type="submit" value="Save" class="btn btn-default" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<div>
|
||||
<a asp-action="Index">Back to List</a>
|
||||
</div>
|
||||
|
62
src/Yavsc/Views/LiveFlow/AdminIndex.cshtml
Normal file
62
src/Yavsc/Views/LiveFlow/AdminIndex.cshtml
Normal file
@ -0,0 +1,62 @@
|
||||
@model IEnumerable<Yavsc.Models.Streaming.LiveFlow>
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "Index";
|
||||
}
|
||||
|
||||
<h2>Index</h2>
|
||||
|
||||
<p>
|
||||
<a asp-action="Create">Create New</a>
|
||||
</p>
|
||||
<table class="table">
|
||||
<tr>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.DifferedFileName)
|
||||
</th>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.MediaType)
|
||||
</th>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.Pitch)
|
||||
</th>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.SequenceNumber)
|
||||
</th>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.Title)
|
||||
</th>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.Owner)
|
||||
</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
|
||||
@foreach (var item in Model) {
|
||||
<tr>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.DifferedFileName)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.MediaType)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.Pitch)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.SequenceNumber)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.Title)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.Owner)
|
||||
</td>
|
||||
<td>
|
||||
<a asp-action="AdminEdit" asp-route-id="@item.Id">Edit</a> |
|
||||
<a asp-action="Details" asp-route-id="@item.Id">Details</a> |
|
||||
<a asp-action="Delete" asp-route-id="@item.Id">Delete</a>
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
</table>
|
56
src/Yavsc/Views/LiveFlow/Create.cshtml
Normal file
56
src/Yavsc/Views/LiveFlow/Create.cshtml
Normal file
@ -0,0 +1,56 @@
|
||||
@model Yavsc.Models.Streaming.LiveFlow
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "Create";
|
||||
}
|
||||
|
||||
<h2>Create</h2>
|
||||
|
||||
<form asp-action="Create">
|
||||
<div class="form-horizontal">
|
||||
<h4>LiveFlow</h4>
|
||||
<hr />
|
||||
<div asp-validation-summary="ValidationSummary.All" class="text-danger"></div>
|
||||
<div class="form-group">
|
||||
<label asp-for="DifferedFileName" class="col-md-2 control-label"></label>
|
||||
<div class="col-md-10">
|
||||
<input asp-for="DifferedFileName" class="form-control" />
|
||||
<span asp-validation-for="DifferedFileName" class="text-danger" ></span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="MediaType" class="col-md-2 control-label"></label>
|
||||
<div class="col-md-10">
|
||||
<input asp-for="MediaType" class="form-control" />
|
||||
<span asp-validation-for="MediaType" class="text-danger" ></span>
|
||||
</div>
|
||||
</div>
|
||||
<input type="hidden" asp-for="OwnerId" class ="form-control"
|
||||
value="@User.GetUserId()" />
|
||||
|
||||
<div class="form-group">
|
||||
<label asp-for="Pitch" class="col-md-2 control-label"></label>
|
||||
<div class="col-md-10">
|
||||
<input asp-for="Pitch" class="form-control" />
|
||||
<span asp-validation-for="Pitch" class="text-danger" ></span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="Title" class="col-md-2 control-label"></label>
|
||||
<div class="col-md-10">
|
||||
<input asp-for="Title" class="form-control" />
|
||||
<span asp-validation-for="Title" class="text-danger" ></span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<div class="col-md-offset-2 col-md-10">
|
||||
<input type="submit" value="Create" class="btn btn-default" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<div>
|
||||
<a asp-action="Index">Back to List</a>
|
||||
</div>
|
||||
|
52
src/Yavsc/Views/LiveFlow/Delete.cshtml
Normal file
52
src/Yavsc/Views/LiveFlow/Delete.cshtml
Normal file
@ -0,0 +1,52 @@
|
||||
@model Yavsc.Models.Streaming.LiveFlow
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "Delete";
|
||||
}
|
||||
|
||||
<h2>Delete</h2>
|
||||
|
||||
<h3>Are you sure you want to delete this?</h3>
|
||||
<div>
|
||||
<h4>LiveFlow</h4>
|
||||
<hr />
|
||||
<dl class="dl-horizontal">
|
||||
<dt>
|
||||
@Html.DisplayNameFor(model => model.DifferedFileName)
|
||||
</dt>
|
||||
<dd>
|
||||
@Html.DisplayFor(model => model.DifferedFileName)
|
||||
</dd>
|
||||
<dt>
|
||||
@Html.DisplayNameFor(model => model.MediaType)
|
||||
</dt>
|
||||
<dd>
|
||||
@Html.DisplayFor(model => model.MediaType)
|
||||
</dd>
|
||||
<dt>
|
||||
@Html.DisplayNameFor(model => model.Pitch)
|
||||
</dt>
|
||||
<dd>
|
||||
@Html.DisplayFor(model => model.Pitch)
|
||||
</dd>
|
||||
<dt>
|
||||
@Html.DisplayNameFor(model => model.SequenceNumber)
|
||||
</dt>
|
||||
<dd>
|
||||
@Html.DisplayFor(model => model.SequenceNumber)
|
||||
</dd>
|
||||
<dt>
|
||||
@Html.DisplayNameFor(model => model.Title)
|
||||
</dt>
|
||||
<dd>
|
||||
@Html.DisplayFor(model => model.Title)
|
||||
</dd>
|
||||
</dl>
|
||||
|
||||
<form asp-action="Delete">
|
||||
<div class="form-actions no-color">
|
||||
<input type="submit" value="Delete" class="btn btn-default" /> |
|
||||
<a asp-action="Index">Back to List</a>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
48
src/Yavsc/Views/LiveFlow/Details.cshtml
Normal file
48
src/Yavsc/Views/LiveFlow/Details.cshtml
Normal file
@ -0,0 +1,48 @@
|
||||
@model Yavsc.Models.Streaming.LiveFlow
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "Details";
|
||||
}
|
||||
|
||||
<h2>Details</h2>
|
||||
|
||||
<div>
|
||||
<h4>LiveFlow</h4>
|
||||
<hr />
|
||||
<dl class="dl-horizontal">
|
||||
<dt>
|
||||
@Html.DisplayNameFor(model => model.DifferedFileName)
|
||||
</dt>
|
||||
<dd>
|
||||
@Html.DisplayFor(model => model.DifferedFileName)
|
||||
</dd>
|
||||
<dt>
|
||||
@Html.DisplayNameFor(model => model.MediaType)
|
||||
</dt>
|
||||
<dd>
|
||||
@Html.DisplayFor(model => model.MediaType)
|
||||
</dd>
|
||||
<dt>
|
||||
@Html.DisplayNameFor(model => model.Pitch)
|
||||
</dt>
|
||||
<dd>
|
||||
@Html.DisplayFor(model => model.Pitch)
|
||||
</dd>
|
||||
<dt>
|
||||
@Html.DisplayNameFor(model => model.SequenceNumber)
|
||||
</dt>
|
||||
<dd>
|
||||
@Html.DisplayFor(model => model.SequenceNumber)
|
||||
</dd>
|
||||
<dt>
|
||||
@Html.DisplayNameFor(model => model.Title)
|
||||
</dt>
|
||||
<dd>
|
||||
@Html.DisplayFor(model => model.Title)
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
<p>
|
||||
<a asp-action="Edit" asp-route-id="@Model.Id">Edit</a> |
|
||||
<a asp-action="Index">Back to List</a>
|
||||
</p>
|
62
src/Yavsc/Views/LiveFlow/Edit.cshtml
Normal file
62
src/Yavsc/Views/LiveFlow/Edit.cshtml
Normal file
@ -0,0 +1,62 @@
|
||||
@model Yavsc.Models.Streaming.LiveFlow
|
||||
|
||||
@{
|
||||
ViewData["Title"] = SR["Edit"];
|
||||
}
|
||||
|
||||
<h2>Edit</h2>
|
||||
|
||||
<form asp-action="Edit">
|
||||
<div class="form-horizontal">
|
||||
<h4>LiveFlow</h4>
|
||||
<hr />
|
||||
<div asp-validation-summary="ValidationSummary.All" class="text-danger"></div>
|
||||
<input type="hidden" asp-for="Id" />
|
||||
<div class="form-group">
|
||||
<label asp-for="DifferedFileName" class="col-md-2 control-label"></label>
|
||||
<div class="col-md-10">
|
||||
<input asp-for="DifferedFileName" class="form-control" />
|
||||
<span asp-validation-for="DifferedFileName" class="text-danger" ></span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="MediaType" class="col-md-2 control-label"></label>
|
||||
<div class="col-md-10">
|
||||
<input asp-for="MediaType" class="form-control" />
|
||||
<span asp-validation-for="MediaType" class="text-danger" ></span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="Pitch" class="col-md-2 control-label"></label>
|
||||
<div class="col-md-10">
|
||||
<input asp-for="Pitch" class="form-control" />
|
||||
<span asp-validation-for="Pitch" class="text-danger" ></span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="SequenceNumber" class="col-md-2 control-label"></label>
|
||||
<div class="col-md-10">
|
||||
<input asp-for="SequenceNumber" class="form-control" />
|
||||
<span asp-validation-for="SequenceNumber" class="text-danger" ></span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="Title" class="col-md-2 control-label"></label>
|
||||
<div class="col-md-10">
|
||||
<input asp-for="Title" class="form-control" />
|
||||
<span asp-validation-for="Title" class="text-danger" ></span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<div class="col-md-offset-2 col-md-10">
|
||||
<input type="submit" value="Save" class="btn btn-default" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<input type="hidden" asp-for="OwnerId" >
|
||||
</form>
|
||||
|
||||
<div>
|
||||
<a asp-action="Index">Back to List</a>
|
||||
</div>
|
||||
|
56
src/Yavsc/Views/LiveFlow/Index.cshtml
Normal file
56
src/Yavsc/Views/LiveFlow/Index.cshtml
Normal file
@ -0,0 +1,56 @@
|
||||
@model IEnumerable<Yavsc.Models.Streaming.LiveFlow>
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "Index";
|
||||
}
|
||||
|
||||
<h2>Index</h2>
|
||||
|
||||
<p>
|
||||
<a asp-action="Create">Create New</a>
|
||||
</p>
|
||||
<table class="table">
|
||||
<tr>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.DifferedFileName)
|
||||
</th>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.MediaType)
|
||||
</th>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.Pitch)
|
||||
</th>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.SequenceNumber)
|
||||
</th>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.Title)
|
||||
</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
|
||||
@foreach (var item in Model) {
|
||||
<tr>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.DifferedFileName)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.MediaType)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.Pitch)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.SequenceNumber)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.Title)
|
||||
</td>
|
||||
<td>
|
||||
<a asp-action="Edit" asp-route-id="@item.Id">Edit</a> |
|
||||
<a asp-action="Details" asp-route-id="@item.Id">Details</a> |
|
||||
<a asp-action="Delete" asp-route-id="@item.Id">Delete</a>
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
</table>
|
@ -151,7 +151,7 @@
|
||||
"yavsc": "Microsoft.AspNet.Server.Kestrel --server.urls http://localhost:86",
|
||||
"coiffure": "Microsoft.AspNet.Server.Kestrel --server.urls http://localhost:88",
|
||||
"freefield": "Microsoft.AspNet.Server.Kestrel --server.urls http://localhost:89",
|
||||
"web": "Microsoft.AspNet.Hosting --server Microsoft.AspNet.Server.Kestrel --server.urls https://localhost:5000"
|
||||
"web": "Microsoft.AspNet.Hosting --server Microsoft.AspNet.Server.Kestrel --server.urls https://*:5000"
|
||||
},
|
||||
"frameworks": {
|
||||
"dnx451": {
|
||||
|
Reference in New Issue
Block a user