Adding socket debug page

This commit is contained in:
Rick Falkvinge
2018-10-22 15:26:11 +02:00
parent fa37a4dab1
commit 325e6076d1
3 changed files with 240 additions and 0 deletions
@@ -0,0 +1,47 @@
<%@ Page Title="" Language="C#" MasterPageFile="~/Master-v5.master" AutoEventWireup="true" Inherits="Swarmops.Frontend.Pages.Admin.Debug.Sockets" Codebehind="DebugSockets.aspx.cs" %>
<%@ Register src="~/Controls/v5/Base/ComboGeographies.ascx" tagname="ComboGeographies" tagprefix="Swarmops5" %>
<asp:Content ID="Content1" ContentPlaceHolderID="PlaceHolderHead" Runat="Server">
<script type="text/javascript">
$(document).ready(function () {
});
</script>
<style type="text/css">
.datagrid-row-selected,.datagrid-row-over{
background:transparent;
}
</style>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="PlaceHolderMain" Runat="Server">
<div class="entryFields" style="padding-top:4px">
&nbsp;
</div>
<div class="entryLabels" style="padding-top:10px">
&nbsp;
</div>
<h2 style="padding-top:15px"><asp:Label ID="LabelMatchingPeopleInX" runat="server" /> (<span id="spanHitCount">0</span>)</h2>
<table id="TableSearchResults" class="easyui-datagrid" style="width:680px;height:500px"
data-options="rownumbers:false,singleSelect:false,nowrap:false,fit:false,loading:false,selectOnCheck:true,checkOnSelect:true"
idField="itemId">
<thead>
<tr>
<th data-options="field:'name',width:210"><asp:Label ID="LabelGridHeaderName" runat="server" Text="XYZ Name"/></th>
<th data-options="field:'geographyName',width:150,sortable:true"><asp:Label ID="LabelGridHeaderGeography" runat="server" Text="XYZ Geography" /></th>
<th data-options="field:'mail',width:105,sortable:true"><asp:Label ID="LabelGridHeaderMail" runat="server" Text="XYZ Mail" /></th>
<th data-options="field:'phone',width:100,sortable:true"><asp:Label ID="LabelGridHeaderPhone" runat="server" Text="XYZ Phone" /></th>
<th data-options="field:'notes',width:50"><asp:Label ID="LabelGridHeaderNotes" runat="server" Text="XYZ Notes" /></th>
<th data-options="field:'actions',width:43,align:'center'"><asp:Label ID="LabelGridHeaderAction" runat="server" Text="XYZ Actions" /></th>
</tr>
</thead>
</table>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="PlaceHolderSide" Runat="Server">
</asp:Content>
@@ -0,0 +1,115 @@
using System;
using System.Security;
using System.Web;
using System.Web.Services;
using Resources;
using Swarmops.Common.Enums;
using Swarmops.Logic.Financial;
using Swarmops.Logic.Security;
using Swarmops.Logic.Support;
namespace Swarmops.Frontend.Pages.Admin.Debug
{
public partial class DebugSockets : PageV5Base
{
protected void Page_Load (object sender, EventArgs e)
{
PageIcon = "iconshock-group-search";
this.PageAccessRequired = new Access (CurrentOrganization, AccessAspect.PersonalData, AccessType.Read);
if (!Page.IsPostBack)
{
Localize();
}
RegisterControl (EasyUIControl.Tree | EasyUIControl.DataGrid);
}
private void Localize()
{
PageTitle = @"Debug Sockets";
InfoBoxLiteral = @"This troubleshoots socket connections by showing which connections are live.";
/* no localization for debug pages */
}
[WebMethod]
public static ConfirmPayoutResult ConfirmPayout (string protoIdentity)
{
protoIdentity = HttpUtility.UrlDecode (protoIdentity);
AuthenticationData authData = GetAuthenticationDataAndCulture();
if (
!authData.Authority.HasAccess (new Access (AccessAspect.System, AccessType.Read)))
{
throw new SecurityException("Insufficient privileges for operation");
}
ConfirmPayoutResult result = new ConfirmPayoutResult();
Payout payout = Payout.CreateFromProtoIdentity (authData.CurrentUser, protoIdentity);
PWEvents.CreateEvent (EventSource.PirateWeb, EventType.PayoutCreated,
authData.CurrentUser.Identity, 1, 1, 0, payout.Identity,
protoIdentity);
// Create result and return it
result.AssignedId = payout.Identity;
result.DisplayMessage = String.Format (Resources.Pages.Financial.PayOutMoney_PayoutCreated, payout.Identity,
payout.Recipient);
result.DisplayMessage = CommonV5.JavascriptEscape(result.DisplayMessage);
return result;
}
[WebMethod]
public static UndoPayoutResult UndoPayout (int databaseId)
{
AuthenticationData authData = GetAuthenticationDataAndCulture();
UndoPayoutResult result = new UndoPayoutResult();
Payout payout = Payout.FromIdentity (databaseId);
if (!payout.Open)
{
// this payout has already been settled, or picked up for settling
result.Success = false;
result.DisplayMessage = String.Format (Resources.Pages.Financial.PayOutMoney_PayoutCannotUndo,
databaseId);
return result;
}
payout.UndoPayout();
result.DisplayMessage =
HttpUtility.UrlEncode (String.Format (Resources.Pages.Financial.PayOutMoney_PayoutUndone, databaseId))
.Replace ("+", "%20");
result.Success = true;
return result;
}
public struct ConfirmPayoutResult
{
public int AssignedId;
public string DisplayMessage;
};
public struct UndoPayoutResult
{
public string DisplayMessage;
public bool Success;
}
// ReSharper disable once InconsistentNaming
public string Localized_NoticeTooManyHits
{
get { return JavascriptEscape(Resources.Pages.Swarm.ListFindPeople_TooManyHits); }
}
}
}
+78
View File
@@ -0,0 +1,78 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace Swarmops.Frontend.Pages.Admin.Debug {
public partial class Sockets {
/// <summary>
/// LabelMatchingPeopleInX control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.WebControls.Label LabelMatchingPeopleInX;
/// <summary>
/// LabelGridHeaderName control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.WebControls.Label LabelGridHeaderName;
/// <summary>
/// LabelGridHeaderGeography control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.WebControls.Label LabelGridHeaderGeography;
/// <summary>
/// LabelGridHeaderMail control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.WebControls.Label LabelGridHeaderMail;
/// <summary>
/// LabelGridHeaderPhone control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.WebControls.Label LabelGridHeaderPhone;
/// <summary>
/// LabelGridHeaderNotes control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.WebControls.Label LabelGridHeaderNotes;
/// <summary>
/// LabelGridHeaderAction control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.WebControls.Label LabelGridHeaderAction;
}
}