Deprecated: Function get_magic_quotes_gpc() is deprecated in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 99

Deprecated: The each() function is deprecated. This message will be suppressed on further calls in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 619

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1169

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176
8000 Fix export additional data by nhathoang989 · Pull Request #505 · mixcore/mix.core · GitHub
Nothing Special   »   [go: up one dir, main page]

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 47 additions & 14 deletions src/Mix.Cms.Lib/ViewModels/MixDatabaseDatas/Helper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,34 +74,67 @@ public static async Task SendMail(string mixDatabase, string culture, JObject da
if (getEdmInfo.IsSucceed)
{
var edm = getEdmInfo.Data;
string body = GetEdmBody(edm.Property<string>("template"), data);
MixService.SendMail(
edm.Property<string>("title"),
body,
edm.Property<string>("recipients"),
edm.Property<string>("from")
);
bool sendToSender = edm.Property<bool>("sendToSender");
string senderColumnName = edm.Property<string>("senderColumnName");
string recipients = edm.Property<string>("recipients");
string senderEmail = GetJToken(senderColumnName, data)?.Value<string>();

if (sendToSender && !string.IsNullOrEmpty(senderEmail))
{
string senderBody = GetEdmBody(edm.Property<string>("senderTemplate"), data);
MixService.SendMail(
edm.Property<string>("title"),
senderBody,
senderEmail,
edm.Property<string>("from")
);
}

if (!string.IsNullOrEmpty(recipients))
{
string senderBody = GetEdmBody(edm.Property<string>("adminTemplate"), data);
MixService.SendMail(
edm.Property<string>("title"),
senderBody,
senderEmail,
edm.Property<string>("from")
);
}
}
}

private static string GetEdmBody(string template, JObject data)
{
string regex = @"(\[\[)(\w+)(\]\])";
Regex rgx = new Regex(regex, RegexOptions.IgnoreCase);
while (rgx.IsMatch(template))
var matches = rgx.Matches(template);
if (matches.Count > 0)
{
Match m = rgx.Match(template);
JToken val = data;
string[] names = m.Groups[2].Value.Split('.');
foreach (var name in names)
foreach (Match m in matches)
{
val = val[name];
var colName = m.Groups[2].Value;
JToken val = GetJToken(m.Groups[2].Value, data);
template = template.Replace($"[[{colName}]]", val?.Value<string>() ?? m.Groups[0].Value);
}
template = rgx.Replace(template, val.Value<string>());
}
return template;
}

private static JToken GetJToken(string path, JObject data)
{
JToken result = data;
string[] names = path.Split('.');
foreach (var name in names)
{
result = result[name];
if (result is null)
{
break;
}
}
return result;
}

public static async Task<RepositoryResponse<AdditionalViewModel>> GetAdditionalData(
MixDatabaseParentType parentType, string parentId,
HttpRequest request, string culture = null,
Expand Down
10 changes: 10 additions & 0 deletions src/Mix.Cms.Lib/ViewModels/MixDatabaseDatas/ImportViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,16 @@ public ImportViewModel(MixDatabaseData model, MixCmsContext _context = null, IDb

public override void ExpandView(MixCmsContext _context = null, IDbContextTransaction _transaction = null)
{
var database = MixDatabases.UpdateViewModel.Repository.GetSingleModel(m => m.Id == MixDatabaseId, _context, _transaction);
Columns = database.Data.Columns;
var getValues = MixDatabaseDataValues.UpdateViewModel
.Repository.GetModelListBy(a => a.DataId == Id && a.Specificulture == Specificulture, _context, _transaction);
Columns.AddRange(
getValues.Data
.Where(v => v.Column != null && !Columns.Any(f => f.Id == v.Column?.Id))
.Select(v => v.Column)
.ToList());
Columns = Columns.OrderBy(c => c.Priority).ToList();
if (Obj == null)
{
Obj = Helper.ParseData(Id, Specificulture, _context, _transaction);
Expand Down
8 changes: 4 additions & 4 deletions src/Mix.Cms.Lib/ViewModels/MixDatabases/ImportViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ public class ImportViewModel

#region Views

[JsonProperty("fields")]
public List<Lib.ViewModels.MixDatabaseColumns.UpdateViewModel> Fields { get; set; }
[JsonProperty("columns")]
public List<Lib.ViewModels.MixDatabaseColumns.UpdateViewModel> Columns { get; set; }

[JsonIgnore]
[JsonProperty("data")]
Expand Down Expand Up @@ -135,7 +135,7 @@ public override async Task<RepositoryResponse<bool>> SaveSubModelsAsync(MixDatab
var result = new RepositoryResponse<bool>() { IsSucceed = true };
if (result.IsSucceed)
{
foreach (var item in Fields)
foreach (var item in Columns)
{
if (result.IsSucceed)
{
Expand All @@ -158,7 +158,7 @@ public override RepositoryResponse<bool> SaveSubModels(MixDatabase parent, MixCm
var result = new RepositoryResponse<bool>() { IsSucceed = true };
if (result.IsSucceed)
{
foreach (var item in Fields)
foreach (var item in Columns)
{
if (result.IsSucceed)
{
Expand Down
12 changes: 6 additions & 6 deletions src/Mix.Cms.Lib/ViewModels/SiteStructureViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -154,9 +154,9 @@ private void ExportMixDatabasesAsync(MixCmsContext context, IDbContextTransactio
{
foreach (var item in MixDatabases)
{
item.Fields = MixDatabaseColumns.UpdateViewModel.Repository.GetModelListBy(a => a.MixDatabaseId == item.Id, context, transaction).Data?.OrderBy(a => a.Priority).ToList();
item.Columns = MixDatabaseColumns.UpdateViewModel.Repository.GetModelListBy(a => a.MixDatabaseId == item.Id, context, transaction).Data?.OrderBy(a => a.Priority).ToList();
// Filter list reference field => Add to Export Data if not exist
var refFields = item.Fields.Where(f => f.DataType == MixDataType.Reference);
var refFields = item.Columns.Where(f => f.DataType == MixDataType.Reference);

foreach (var field in refFields)
{
Expand Down Expand Up @@ -274,7 +274,7 @@ private void ExportAdditionalData(string id, MixDatabaseParentType type, MixCmsC
{
if (!RelatedData.Any(m => m.ParentId == id && m.ParentType == type))
{
var getRelatedData = MixDatabaseDataAssociations.ImportViewModel.Repository.GetSingleModel(
var getRelatedData = MixDatabaseDataAssociations.ImportViewModel.Repository.GetFirstModel(
m => m.Specificulture == Specificulture && m.ParentType == type
&& m.ParentId == id, context, transaction);
if (getRelatedData.IsSucceed)
Expand Down Expand Up @@ -543,7 +543,7 @@ private async Task<RepositoryResponse<bool>> ImportMixDatabasesAsync(MixCmsConte
dicMixDatabaseIds.Add(set.Id, startId);
set.Id = startId;
set.CreatedDateTime = DateTime.UtcNow;
mixDatabaseColumns.AddRange(set.Fields
mixDatabaseColumns.AddRange(set.Columns
.Where(m => !mixDatabaseColumns.Any(n => n.Id == m.Id))
.ToList());
var saveResult = await set.SaveModelAsync(false, context, transaction);
Expand Down Expand Up @@ -839,12 +839,12 @@ private async Task<RepositoryResponse<bool>> ImportMixDatabaseDatas(string destC
{
item.MixDatabaseId = dicMixDatabaseIds[item.MixDatabaseId];
}
item.Columns = item.Columns ?? MixDatabases.FirstOrDefault(m => m.Name == item.MixDatabaseName).Fields;
item.Columns = item.Columns ?? MixDatabases.FirstOrDefault(m => m.Name == item.MixDatabaseName).Columns;
foreach (var field in item.Columns)
{
field.Specificulture = destCulture;
var newSet = MixDatabases.FirstOrDefault(m => m.Name == field.MixDatabaseName);
var newField = newSet?.Fields.FirstOrDefault(m => m.Name == field.Name);
var newField = newSet?.Columns.FirstOrDefault(m => m.Name == field.Name);
if (newField != null)
{
field.Id = newField.Id;
Expand Down
Loading
0