This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.AspNetCore.Routing;
|
using Microsoft.AspNetCore.Routing;
|
||||||
@@ -7,7 +8,7 @@ using Microsoft.Extensions.Logging;
|
|||||||
using Sockeye.Models;
|
using Sockeye.Models;
|
||||||
using Sockeye.Api.ControllerHelpers;
|
using Sockeye.Api.ControllerHelpers;
|
||||||
using Sockeye.Biz;
|
using Sockeye.Biz;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
namespace Sockeye.Api.Controllers
|
namespace Sockeye.Api.Controllers
|
||||||
{
|
{
|
||||||
@@ -102,39 +103,43 @@ namespace Sockeye.Api.Controllers
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
// /// <summary>
|
/// <summary>
|
||||||
// /// Get the top level ancestor of provided type and id
|
/// Get the top level ancestor of provided type and id
|
||||||
// /// (e.g. find the WorkOrder principle for a WorkOrderItemPart object descendant)
|
/// (e.g. find the WorkOrder principle for a WorkOrderItemPart object descendant)
|
||||||
// /// </summary>
|
/// </summary>
|
||||||
// /// <param name="sockType"></param>
|
/// <param name="sockType"></param>
|
||||||
// /// <param name="id"></param>
|
/// <param name="id"></param>
|
||||||
// /// <returns>A type and id of ancestor</returns>
|
/// <returns>A type and id of ancestor</returns>
|
||||||
// [HttpGet("ancestor/{sockType}/{id}")]
|
[HttpGet("ancestor/{sockType}/{id}")]
|
||||||
// public async Task<IActionResult> GetAncestor([FromRoute] SockType sockType, [FromRoute] long id)
|
public async Task<IActionResult> GetAncestor([FromRoute] SockType sockType, [FromRoute] long id)
|
||||||
// {
|
{
|
||||||
// if (serverState.IsClosed)
|
if (serverState.IsClosed)
|
||||||
// return StatusCode(503, new ApiErrorResponse(serverState.ApiErrorCode, null, serverState.Reason));
|
return StatusCode(503, new ApiErrorResponse(serverState.ApiErrorCode, null, serverState.Reason));
|
||||||
|
|
||||||
// //since this is for opening an entire object it's appropriate to check if they have any role first
|
//since this is for opening an entire object it's appropriate to check if they have any role first
|
||||||
// if (!Authorized.HasAnyRole(HttpContext.Items, sockType))
|
if (!Authorized.HasAnyRole(HttpContext.Items, sockType))
|
||||||
// return StatusCode(403, new ApiNotAuthorizedResponse());
|
return StatusCode(403, new ApiNotAuthorizedResponse());
|
||||||
|
|
||||||
// if (!ModelState.IsValid)
|
if (!ModelState.IsValid)
|
||||||
// return BadRequest(new ApiErrorResponse(ModelState));
|
return BadRequest(new ApiErrorResponse(ModelState));
|
||||||
// if (id == 0)
|
if (id == 0)
|
||||||
// return BadRequest(new ApiErrorResponse(ApiErrorCode.VALIDATION_INVALID_VALUE, null, "id can't be zero"));
|
return BadRequest(new ApiErrorResponse(ApiErrorCode.VALIDATION_INVALID_VALUE, null, "id can't be zero"));
|
||||||
|
|
||||||
// switch (sockType)
|
switch (sockType)
|
||||||
// {
|
{
|
||||||
|
|
||||||
|
case SockType.SubscriptionItem:
|
||||||
|
{
|
||||||
|
var subId = await ct.SubscriptionItem.AsNoTracking().Where(z => z.Id == id).Select(z => z.SubscriptionId).SingleOrDefaultAsync();
|
||||||
|
return Ok(ApiOkResponse.Response(new { SockType = (int)SockType.Subscription, Id = subId }));
|
||||||
|
}
|
||||||
|
|
||||||
|
default:
|
||||||
|
return BadRequest(new ApiErrorResponse(ApiErrorCode.VALIDATION_INVALID_VALUE, null, "Only types with ancestors are valid"));
|
||||||
|
|
||||||
// default:
|
}
|
||||||
// return BadRequest(new ApiErrorResponse(ApiErrorCode.VALIDATION_INVALID_VALUE, null, "Only types with ancestors are valid"));
|
|
||||||
|
|
||||||
// }
|
}
|
||||||
|
|
||||||
// }
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -17,8 +17,8 @@ LEFT JOIN acustomer ON (asubscription.customerid = acustomer.id)";
|
|||||||
|
|
||||||
var RoleSet = BizRoles.GetRoleSet(DefaultListAType);
|
var RoleSet = BizRoles.GetRoleSet(DefaultListAType);
|
||||||
AllowedRoles = RoleSet.ReadFullRecord | RoleSet.Change;
|
AllowedRoles = RoleSet.ReadFullRecord | RoleSet.Change;
|
||||||
DefaultColumns = new List<string>() { "PurchaseExpireDate", "Product", "SubSite", "Customer", "active" };
|
DefaultColumns = new List<string>() { "PurchaseExpireDate", "Product", "Customer", "active" };
|
||||||
DefaultSortBy = new Dictionary<string, string>() { { "PurchaseExpireDate", "-" } };
|
DefaultSortBy = new Dictionary<string, string>() { { "PurchaseExpireDate", "+" } };
|
||||||
FieldDefinitions = new List<DataListFieldDefinition>();
|
FieldDefinitions = new List<DataListFieldDefinition>();
|
||||||
|
|
||||||
|
|
||||||
@@ -41,16 +41,18 @@ LEFT JOIN acustomer ON (asubscription.customerid = acustomer.id)";
|
|||||||
SockType = (int)SockType.SubscriptionItem,
|
SockType = (int)SockType.SubscriptionItem,
|
||||||
UiFieldDataType = (int)UiFieldDataType.DateTime,
|
UiFieldDataType = (int)UiFieldDataType.DateTime,
|
||||||
SqlValueColumnName = "asubscriptionitem.originalorderdate",
|
SqlValueColumnName = "asubscriptionitem.originalorderdate",
|
||||||
SqlIdColumnName = "asubscriptionitem.id",
|
SqlIdColumnName = "asubscriptionitem.id"
|
||||||
IsRowId = true
|
|
||||||
});
|
});
|
||||||
|
|
||||||
FieldDefinitions.Add(new DataListFieldDefinition
|
FieldDefinitions.Add(new DataListFieldDefinition
|
||||||
{
|
{
|
||||||
TKey = "PurchaseExpireDate",
|
TKey = "PurchaseExpireDate",
|
||||||
FieldKey = "PurchaseExpireDate",
|
FieldKey = "PurchaseExpireDate",
|
||||||
|
SockType = (int)SockType.SubscriptionItem,
|
||||||
UiFieldDataType = (int)UiFieldDataType.DateTime,
|
UiFieldDataType = (int)UiFieldDataType.DateTime,
|
||||||
SqlValueColumnName = "asubscriptionitem.expiredate"
|
SqlValueColumnName = "asubscriptionitem.expiredate",
|
||||||
|
SqlIdColumnName = "asubscriptionitem.id",
|
||||||
|
IsRowId = true
|
||||||
});
|
});
|
||||||
|
|
||||||
//SUBSCRIPTION
|
//SUBSCRIPTION
|
||||||
@@ -82,13 +84,7 @@ LEFT JOIN acustomer ON (asubscription.customerid = acustomer.id)";
|
|||||||
SqlValueColumnName = "asubscriptionitem.active"
|
SqlValueColumnName = "asubscriptionitem.active"
|
||||||
});
|
});
|
||||||
|
|
||||||
FieldDefinitions.Add(new DataListFieldDefinition
|
|
||||||
{
|
|
||||||
TKey = "Tags",
|
|
||||||
FieldKey = "tags",
|
|
||||||
UiFieldDataType = (int)UiFieldDataType.Tags,
|
|
||||||
SqlValueColumnName = "asubscription.tags"
|
|
||||||
});
|
|
||||||
|
|
||||||
//META column
|
//META column
|
||||||
FieldDefinitions.Add(new DataListFieldDefinition
|
FieldDefinitions.Add(new DataListFieldDefinition
|
||||||
|
|||||||
@@ -667,6 +667,19 @@ namespace Sockeye.Biz
|
|||||||
Select = AuthorizationRoles.All
|
Select = AuthorizationRoles.All
|
||||||
});
|
});
|
||||||
|
|
||||||
|
roles.Add(SockType.SubscriptionItem, new BizRoleSet()
|
||||||
|
{
|
||||||
|
Change = AuthorizationRoles.BizAdmin
|
||||||
|
| AuthorizationRoles.Service
|
||||||
|
| AuthorizationRoles.Sales
|
||||||
|
| AuthorizationRoles.Accounting,
|
||||||
|
ReadFullRecord = AuthorizationRoles.BizAdminRestricted
|
||||||
|
| AuthorizationRoles.ServiceRestricted
|
||||||
|
| AuthorizationRoles.Tech
|
||||||
|
| AuthorizationRoles.SalesRestricted
|
||||||
|
,
|
||||||
|
Select = AuthorizationRoles.All
|
||||||
|
});
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
#endregion all roles init
|
#endregion all roles init
|
||||||
|
|
||||||
@@ -683,12 +696,12 @@ namespace Sockeye.Biz
|
|||||||
//And seperately, set the JSON variable so can copy from debug variable "value" property for lastRoles here to compare
|
//And seperately, set the JSON variable so can copy from debug variable "value" property for lastRoles here to compare
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
||||||
string json = Newtonsoft.Json.JsonConvert.SerializeObject(roles, Newtonsoft.Json.Formatting.None);
|
string json = Newtonsoft.Json.JsonConvert.SerializeObject(roles, Newtonsoft.Json.Formatting.None);
|
||||||
System.Diagnostics.Debugger.Log(1, "JSONFRAGMENTFORCLIENT", "BizRoles.cs -> biz-role-rights.js Client roles JSON fragment:\n\n");
|
System.Diagnostics.Debugger.Log(1, "JSONFRAGMENTFORCLIENT", "BizRoles.cs -> biz-role-rights.js Client roles JSON fragment:\n\n");
|
||||||
System.Diagnostics.Debugger.Log(1, "JSONFRAGMENTFORCLIENT", json + "\n\n");
|
System.Diagnostics.Debugger.Log(1, "JSONFRAGMENTFORCLIENT", json + "\n\n");
|
||||||
var lastRoles = "{\"Customer\":{\"Change\":32842,\"ReadFullRecord\":65797,\"Select\":131071},\"CustomerNote\":{\"Change\":32842,\"ReadFullRecord\":65797,\"Select\":131071},\"CustomerNotifySubscription\":{\"Change\":10,\"ReadFullRecord\":65797,\"Select\":131071},\"HeadOffice\":{\"Change\":32842,\"ReadFullRecord\":65797,\"Select\":131071},\"Global\":{\"Change\":2,\"ReadFullRecord\":1,\"Select\":0},\"GlobalOps\":{\"Change\":16384,\"ReadFullRecord\":8192,\"Select\":0},\"User\":{\"Change\":2,\"ReadFullRecord\":1,\"Select\":131071},\"UserOptions\":{\"Change\":2,\"ReadFullRecord\":1,\"Select\":0},\"ServerState\":{\"Change\":16384,\"ReadFullRecord\":131071,\"Select\":0},\"LogFile\":{\"Change\":0,\"ReadFullRecord\":24576,\"Select\":0},\"Backup\":{\"Change\":16384,\"ReadFullRecord\":8195,\"Select\":0},\"FileAttachment\":{\"Change\":2,\"ReadFullRecord\":3,\"Select\":0},\"ServerJob\":{\"Change\":16384,\"ReadFullRecord\":8195,\"Select\":0},\"OpsNotificationSettings\":{\"Change\":16384,\"ReadFullRecord\":8195,\"Select\":0},\"ServerMetrics\":{\"Change\":16384,\"ReadFullRecord\":24576,\"Select\":0},\"Translation\":{\"Change\":2,\"ReadFullRecord\":1,\"Select\":131071},\"DataListSavedFilter\":{\"Change\":2,\"ReadFullRecord\":131071,\"Select\":0},\"FormUserOptions\":{\"Change\":131071,\"ReadFullRecord\":131071,\"Select\":0},\"FormCustom\":{\"Change\":2,\"ReadFullRecord\":131071,\"Select\":0},\"PickListTemplate\":{\"Change\":2,\"ReadFullRecord\":131071,\"Select\":0},\"BizMetrics\":{\"Change\":2,\"ReadFullRecord\":98369,\"Select\":0},\"Notification\":{\"Change\":131071,\"ReadFullRecord\":131071,\"Select\":0},\"NotifySubscription\":{\"Change\":131071,\"ReadFullRecord\":131071,\"Select\":0},\"Report\":{\"Change\":3,\"ReadFullRecord\":131071,\"Select\":131071},\"Memo\":{\"Change\":124927,\"ReadFullRecord\":124927,\"Select\":124927},\"Reminder\":{\"Change\":124927,\"ReadFullRecord\":124927,\"Select\":124927},\"Review\":{\"Change\":124927,\"ReadFullRecord\":124927,\"Select\":124927},\"Integration\":{\"Change\":49514,\"ReadFullRecord\":49514,\"Select\":49514},\"License\":{\"Change\":32842,\"ReadFullRecord\":65797,\"Select\":131071},\"TrialLicenseRequest\":{\"Change\":32842,\"ReadFullRecord\":65797,\"Select\":131071},\"SubscriptionServer\":{\"Change\":32842,\"ReadFullRecord\":65797,\"Select\":131071},\"Purchase\":{\"Change\":32842,\"ReadFullRecord\":65797,\"Select\":131071},\"Product\":{\"Change\":32842,\"ReadFullRecord\":65797,\"Select\":131071},\"GZCase\":{\"Change\":32842,\"ReadFullRecord\":65797,\"Select\":131071}}";
|
var lastRoles = "{\"Customer\":{\"Change\":32842,\"ReadFullRecord\":65797,\"Select\":131071},\"CustomerNote\":{\"Change\":32842,\"ReadFullRecord\":65797,\"Select\":131071},\"CustomerNotifySubscription\":{\"Change\":10,\"ReadFullRecord\":65797,\"Select\":131071},\"HeadOffice\":{\"Change\":32842,\"ReadFullRecord\":65797,\"Select\":131071},\"Global\":{\"Change\":2,\"ReadFullRecord\":1,\"Select\":0},\"GlobalOps\":{\"Change\":16384,\"ReadFullRecord\":8192,\"Select\":0},\"User\":{\"Change\":2,\"ReadFullRecord\":1,\"Select\":131071},\"UserOptions\":{\"Change\":2,\"ReadFullRecord\":1,\"Select\":0},\"ServerState\":{\"Change\":16384,\"ReadFullRecord\":131071,\"Select\":0},\"LogFile\":{\"Change\":0,\"ReadFullRecord\":24576,\"Select\":0},\"Backup\":{\"Change\":16384,\"ReadFullRecord\":8195,\"Select\":0},\"FileAttachment\":{\"Change\":2,\"ReadFullRecord\":3,\"Select\":0},\"ServerJob\":{\"Change\":16384,\"ReadFullRecord\":8195,\"Select\":0},\"OpsNotificationSettings\":{\"Change\":16384,\"ReadFullRecord\":8195,\"Select\":0},\"ServerMetrics\":{\"Change\":16384,\"ReadFullRecord\":24576,\"Select\":0},\"Translation\":{\"Change\":2,\"ReadFullRecord\":1,\"Select\":131071},\"DataListSavedFilter\":{\"Change\":2,\"ReadFullRecord\":131071,\"Select\":0},\"FormUserOptions\":{\"Change\":131071,\"ReadFullRecord\":131071,\"Select\":0},\"FormCustom\":{\"Change\":2,\"ReadFullRecord\":131071,\"Select\":0},\"PickListTemplate\":{\"Change\":2,\"ReadFullRecord\":131071,\"Select\":0},\"BizMetrics\":{\"Change\":2,\"ReadFullRecord\":98369,\"Select\":0},\"Notification\":{\"Change\":131071,\"ReadFullRecord\":131071,\"Select\":0},\"NotifySubscription\":{\"Change\":131071,\"ReadFullRecord\":131071,\"Select\":0},\"Report\":{\"Change\":3,\"ReadFullRecord\":131071,\"Select\":131071},\"Memo\":{\"Change\":124927,\"ReadFullRecord\":124927,\"Select\":124927},\"Reminder\":{\"Change\":124927,\"ReadFullRecord\":124927,\"Select\":124927},\"Review\":{\"Change\":124927,\"ReadFullRecord\":124927,\"Select\":124927},\"Integration\":{\"Change\":49514,\"ReadFullRecord\":49514,\"Select\":49514},\"Vendor\":{\"Change\":32842,\"ReadFullRecord\":65797,\"Select\":131071},\"License\":{\"Change\":32842,\"ReadFullRecord\":65797,\"Select\":131071},\"TrialLicenseRequest\":{\"Change\":32842,\"ReadFullRecord\":65797,\"Select\":131071},\"SubscriptionServer\":{\"Change\":32842,\"ReadFullRecord\":65797,\"Select\":131071},\"Purchase\":{\"Change\":32842,\"ReadFullRecord\":65797,\"Select\":131071},\"VendorNotification\":{\"Change\":32842,\"ReadFullRecord\":65797,\"Select\":131071},\"Product\":{\"Change\":32842,\"ReadFullRecord\":65797,\"Select\":131071},\"GZCase\":{\"Change\":32842,\"ReadFullRecord\":65797,\"Select\":131071},\"Subscription\":{\"Change\":32842,\"ReadFullRecord\":65797,\"Select\":131071},\"SubscriptionItem\":{\"Change\":32842,\"ReadFullRecord\":65797,\"Select\":131071}}";
|
||||||
Dictionary<SockType, BizRoleSet> lastRolesDeserialized = Newtonsoft.Json.JsonConvert.DeserializeObject<Dictionary<SockType, BizRoleSet>>(lastRoles);
|
Dictionary<SockType, BizRoleSet> lastRolesDeserialized = Newtonsoft.Json.JsonConvert.DeserializeObject<Dictionary<SockType, BizRoleSet>>(lastRoles);
|
||||||
if (lastRolesDeserialized.Count != roles.Count)
|
if (lastRolesDeserialized.Count != roles.Count)
|
||||||
{
|
{
|
||||||
@@ -697,8 +710,8 @@ namespace Sockeye.Biz
|
|||||||
((ILogger)Sockeye.Util.ApplicationLogging.CreateLogger("BizRoles.cs")).LogWarning("BizRoles::Constructor - roles were modified from last snapshot for client!!!");
|
((ILogger)Sockeye.Util.ApplicationLogging.CreateLogger("BizRoles.cs")).LogWarning("BizRoles::Constructor - roles were modified from last snapshot for client!!!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
#endregion
|
#endregion
|
||||||
|
|||||||
Reference in New Issue
Block a user