case 4504
This commit is contained in:
111
server/DataList/SubscriptionsDataList.cs
Normal file
111
server/DataList/SubscriptionsDataList.cs
Normal file
@@ -0,0 +1,111 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Sockeye.Biz;
|
||||
using Sockeye.Models;
|
||||
|
||||
namespace Sockeye.DataList
|
||||
{
|
||||
internal class SubscriptionDataList : DataListProcessingBase, IDataListInternalCriteria
|
||||
{
|
||||
public SubscriptionDataList(long translationId)
|
||||
{
|
||||
DefaultListAType = SockType.Subscription;
|
||||
SQLFrom = @"FROM asubscription LEFT JOIN acustomer ON (asubscription.customerid = acustomer.id)";
|
||||
|
||||
var RoleSet = BizRoles.GetRoleSet(DefaultListAType);
|
||||
AllowedRoles = RoleSet.ReadFullRecord | RoleSet.Change;
|
||||
DefaultColumns = new List<string>() { "name", "Customer", "active" };
|
||||
DefaultSortBy = new Dictionary<string, string>() { { "Customer", "-" } };
|
||||
FieldDefinitions = new List<DataListFieldDefinition>();
|
||||
|
||||
FieldDefinitions.Add(new DataListFieldDefinition
|
||||
{
|
||||
TKey = "Name",
|
||||
FieldKey = "name",
|
||||
SockType = (int)SockType.Subscription,
|
||||
UiFieldDataType = (int)UiFieldDataType.Text,
|
||||
SqlIdColumnName = "asubscription.id",
|
||||
SqlValueColumnName = "asubscription.name",
|
||||
IsRowId = true
|
||||
});
|
||||
|
||||
FieldDefinitions.Add(new DataListFieldDefinition
|
||||
{
|
||||
TKey = "Customer",
|
||||
FieldKey = "Customer",
|
||||
SockType = (int)SockType.Customer,
|
||||
UiFieldDataType = (int)UiFieldDataType.Text,
|
||||
SqlIdColumnName = "asubscription.customerid",
|
||||
SqlValueColumnName = "acustomer.name"
|
||||
});
|
||||
|
||||
FieldDefinitions.Add(new DataListFieldDefinition
|
||||
{
|
||||
TKey = "Active",
|
||||
FieldKey = "active",
|
||||
UiFieldDataType = (int)UiFieldDataType.Bool,
|
||||
SqlValueColumnName = "asubscription.active"
|
||||
});
|
||||
|
||||
FieldDefinitions.Add(new DataListFieldDefinition
|
||||
{
|
||||
TKey = "Tags",
|
||||
FieldKey = "tags",
|
||||
UiFieldDataType = (int)UiFieldDataType.Tags,
|
||||
SqlValueColumnName = "asubscription.tags"
|
||||
});
|
||||
|
||||
//META column
|
||||
FieldDefinitions.Add(new DataListFieldDefinition
|
||||
{
|
||||
FieldKey = "metacustomer",
|
||||
UiFieldDataType = (int)UiFieldDataType.InternalId,
|
||||
SqlIdColumnName = "asubscription.customerid",
|
||||
SqlValueColumnName = "asubscription.customerid",
|
||||
IsMeta = true
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
public List<DataListFilterOption> DataListInternalCriteria(long currentUserId, AuthorizationRoles userRoles, string clientCriteria)
|
||||
{
|
||||
List<DataListFilterOption> ret = new List<DataListFilterOption>();
|
||||
|
||||
//ClientCriteria format for this list is "OBJECTID,AYATYPE"
|
||||
var crit = (clientCriteria ?? "").Split(',').Select(z => z.Trim()).ToArray();
|
||||
if (crit.Length > 1)
|
||||
{
|
||||
//will be filtered from different types, show all records from Customer and nothing else at this time
|
||||
int nType = 0;
|
||||
if (!int.TryParse(crit[1], out nType)) return ret;
|
||||
SockType forType = (SockType)nType;
|
||||
if (forType != SockType.Customer) return ret;//only supports customer for now see workorderdatalist for alts
|
||||
|
||||
long lId = 0;
|
||||
if (!long.TryParse(crit[0], out lId)) return ret;
|
||||
if (lId == 0) return ret;
|
||||
|
||||
//Have valid type, have an id, so filter away
|
||||
switch (forType)
|
||||
{
|
||||
case SockType.Customer:
|
||||
{
|
||||
DataListFilterOption FilterOption = new DataListFilterOption() { Column = "metacustomer" };
|
||||
FilterOption.Items.Add(new DataListColumnFilter() { value = crit[0], op = DataListFilterComparisonOperator.Equality });
|
||||
ret.Add(FilterOption);
|
||||
}
|
||||
break;
|
||||
// case AyaType.Project:
|
||||
// {
|
||||
// DataListFilterOption FilterOption = new DataListFilterOption() { Column = "metaproject" };
|
||||
// FilterOption.Items.Add(new DataListColumnFilter() { value = crit[0], op = DataListFilterComparisonOperator.Equality });
|
||||
// ret.Add(FilterOption);
|
||||
// }
|
||||
// break;
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
}//eoc
|
||||
}//eons
|
||||
@@ -43,6 +43,7 @@ namespace Sockeye.Biz
|
||||
//
|
||||
internal async Task<Subscription> CreateAsync(Subscription newObject)
|
||||
{
|
||||
|
||||
await ValidateAsync(newObject, null);
|
||||
if (HasErrors)
|
||||
return null;
|
||||
@@ -151,7 +152,7 @@ namespace Sockeye.Biz
|
||||
await ct.SaveChangesAsync();
|
||||
|
||||
//Log event
|
||||
await EventLogProcessor.DeleteObjectLogAsync(UserId, BizType, dbObject.Id, dbObject.Name, ct);
|
||||
await EventLogProcessor.DeleteObjectLogAsync(UserId, BizType, dbObject.Id, "subscription", ct);
|
||||
await Search.ProcessDeletedObjectKeywordsAsync(dbObject.Id, BizType, ct);
|
||||
await TagBiz.ProcessDeleteTagsInRepositoryAsync(ct, dbObject.Tags);
|
||||
await FileUtil.DeleteAttachmentsForObjectAsync(BizType, dbObject.Id, ct);
|
||||
@@ -189,7 +190,7 @@ namespace Sockeye.Biz
|
||||
public void DigestSearchText(Subscription obj, Search.SearchIndexProcessObjectParameters searchParams)
|
||||
{
|
||||
if (obj != null)
|
||||
searchParams.AddText(obj.Name)
|
||||
searchParams.AddText(obj.Subsite)
|
||||
.AddText(obj.Tags)
|
||||
.AddText(obj.Notes);
|
||||
}
|
||||
|
||||
@@ -14,10 +14,9 @@ namespace Sockeye.Models
|
||||
public long Id { get; set; }
|
||||
public uint Concurrency { get; set; }
|
||||
|
||||
[Required]
|
||||
public string Name { get; set; }
|
||||
public string Subsite { get; set; } //always null unless customer has multiple sites with same pgroup type subscription
|
||||
public bool Active { get; set; }
|
||||
[Required]
|
||||
[Required]
|
||||
public ProductGroup PGroup { get; set; }
|
||||
public long CustomerId { get; set; }
|
||||
[NotMapped]
|
||||
@@ -28,6 +27,10 @@ namespace Sockeye.Models
|
||||
|
||||
public List<SubscriptionItem> Items { get; set; } = new List<SubscriptionItem>();
|
||||
|
||||
//workaround for notification
|
||||
[NotMapped, JsonIgnore]
|
||||
public string Name { get; set; }
|
||||
|
||||
[NotMapped, JsonIgnore]
|
||||
public SockType SType { get => SockType.Subscription; }
|
||||
|
||||
|
||||
@@ -1500,7 +1500,7 @@ $BODY$ LANGUAGE PLPGSQL STABLE");
|
||||
LogUpdateMessage(log);
|
||||
|
||||
//SUBSCRIPTION
|
||||
await ExecQueryAsync("CREATE TABLE asubscription (id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, name TEXT NOT NULL UNIQUE, active BOOL NOT NULL, notes TEXT, "
|
||||
await ExecQueryAsync("CREATE TABLE asubscription (id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, subsite TEXT, active BOOL NOT NULL, notes TEXT, "
|
||||
+ "customerid BIGINT REFERENCES acustomer(id) ON DELETE CASCADE, pgroup INTEGER NOT NULL DEFAULT 4, tags VARCHAR(255) ARRAY )");
|
||||
|
||||
//SUBSCRIPTIONITEM
|
||||
@@ -1511,21 +1511,25 @@ $BODY$ LANGUAGE PLPGSQL STABLE");
|
||||
await ExecQueryAsync("INSERT INTO atranslationitem(translationid,key,display) SELECT t.id, 'Subscription', 'Subscription' FROM atranslation t where t.baselanguage = 'en'");
|
||||
await ExecQueryAsync("INSERT INTO atranslationitem(translationid,key,display) SELECT t.id, 'SubscriptionItem', 'SubscriptionItem' FROM atranslation t where t.baselanguage = 'en'");
|
||||
await ExecQueryAsync("INSERT INTO atranslationitem(translationid,key,display) SELECT t.id, 'SubscriptionList', 'Subscriptions' FROM atranslation t where t.baselanguage = 'en'");
|
||||
await ExecQueryAsync("INSERT INTO atranslationitem(translationid,key,display) SELECT t.id, 'SubSite', 'Sub-site' FROM atranslation t where t.baselanguage = 'en'");
|
||||
|
||||
//spanish translations
|
||||
await ExecQueryAsync("INSERT INTO atranslationitem(translationid,key,display) SELECT t.id, 'Subscription', 'Subscription' FROM atranslation t where t.baselanguage = 'es'");
|
||||
await ExecQueryAsync("INSERT INTO atranslationitem(translationid,key,display) SELECT t.id, 'SubscriptionItem', 'SubscriptionItem' FROM atranslation t where t.baselanguage = 'es'");
|
||||
await ExecQueryAsync("INSERT INTO atranslationitem(translationid,key,display) SELECT t.id, 'SubscriptionList', 'Subscriptions' FROM atranslation t where t.baselanguage = 'es'");
|
||||
await ExecQueryAsync("INSERT INTO atranslationitem(translationid,key,display) SELECT t.id, 'SubSite', 'Sub-site' FROM atranslation t where t.baselanguage = 'es'");
|
||||
|
||||
//french translations
|
||||
await ExecQueryAsync("INSERT INTO atranslationitem(translationid,key,display) SELECT t.id, 'Subscription', 'Subscription' FROM atranslation t where t.baselanguage = 'fr'");
|
||||
await ExecQueryAsync("INSERT INTO atranslationitem(translationid,key,display) SELECT t.id, 'SubscriptionItem', 'SubscriptionItem' FROM atranslation t where t.baselanguage = 'fr'");
|
||||
await ExecQueryAsync("INSERT INTO atranslationitem(translationid,key,display) SELECT t.id, 'SubscriptionList', 'Subscriptions' FROM atranslation t where t.baselanguage = 'fr'");
|
||||
await ExecQueryAsync("INSERT INTO atranslationitem(translationid,key,display) SELECT t.id, 'SubSite', 'Sub-site' FROM atranslation t where t.baselanguage = 'fr'");
|
||||
|
||||
//german translations
|
||||
await ExecQueryAsync("INSERT INTO atranslationitem(translationid,key,display) SELECT t.id, 'Subscription', 'Subscription' FROM atranslation t where t.baselanguage = 'de'");
|
||||
await ExecQueryAsync("INSERT INTO atranslationitem(translationid,key,display) SELECT t.id, 'SubscriptionItem', 'SubscriptionItem' FROM atranslation t where t.baselanguage = 'de'");
|
||||
await ExecQueryAsync("INSERT INTO atranslationitem(translationid,key,display) SELECT t.id, 'SubscriptionList', 'Subscriptions' FROM atranslation t where t.baselanguage = 'de'");
|
||||
await ExecQueryAsync("INSERT INTO atranslationitem(translationid,key,display) SELECT t.id, 'SubSite', 'Sub-site' FROM atranslation t where t.baselanguage = 'de'");
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user