Style updates, and removes unused usings
This commit is contained in:
@@ -264,72 +264,84 @@ namespace Umbraco.Core.Services
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public HttpResponseMessage ExportMemberData(Guid key)
|
public HttpResponseMessage ExportMemberData(Guid key)
|
||||||
{
|
{
|
||||||
|
var memberPropertyFilter = new List<string>
|
||||||
//Filters
|
|
||||||
List<string> memberPropFilter = new List<string>
|
|
||||||
{
|
{
|
||||||
"RawPasswordValue","ParentId","SortOrder", "Level", "Path", "CreatorId", "Version", "ContentTypeId", "HasIdentity",
|
"RawPasswordValue",
|
||||||
"PropertyGroups", "PropertyTypes", "ProviderUserKey", "ContentType"
|
"ParentId",
|
||||||
|
"SortOrder",
|
||||||
|
"Level",
|
||||||
|
"Path",
|
||||||
|
"CreatorId",
|
||||||
|
"Version",
|
||||||
|
"ContentTypeId",
|
||||||
|
"HasIdentity",
|
||||||
|
"PropertyGroups",
|
||||||
|
"PropertyTypes",
|
||||||
|
"ProviderUserKey",
|
||||||
|
"ContentType"
|
||||||
};
|
};
|
||||||
|
|
||||||
List<string> propertiesFilter = new List<string>
|
var propertiesFilter = new List<string>
|
||||||
{
|
{
|
||||||
"PropertyType", "Version", "Id", "HasIdentity", "Key"
|
"PropertyType",
|
||||||
|
"Version",
|
||||||
|
"Id",
|
||||||
|
"HasIdentity",
|
||||||
|
"Key"
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
//Get the member
|
|
||||||
var member = GetByKey(key);
|
var member = GetByKey(key);
|
||||||
var memberProperties = member.GetType().GetProperties();
|
var memberProperties = member.GetType().GetProperties();
|
||||||
|
var fileName = $"{member.Name}_{member.Email}.txt";
|
||||||
|
|
||||||
string fileName = member.Name + "_" + member.Email + ".txt";
|
using (var memoryStream = new MemoryStream())
|
||||||
|
|
||||||
using (MemoryStream ms = new MemoryStream())
|
|
||||||
{
|
{
|
||||||
using (TextWriter tw = new StreamWriter(ms))
|
using (var textWriter = new StreamWriter(memoryStream))
|
||||||
{
|
{
|
||||||
foreach (var memberProp in memberProperties)
|
foreach (var memberProp in memberProperties)
|
||||||
{
|
{
|
||||||
if (memberPropFilter.Contains(memberProp.Name)) continue;
|
if (memberPropertyFilter.Contains(memberProp.Name)) continue;
|
||||||
|
|
||||||
var propValue = memberProp.GetValue(member, null);
|
var propValue = memberProp.GetValue(member, null);
|
||||||
var type = propValue?.GetType();
|
var type = propValue?.GetType();
|
||||||
|
|
||||||
if (type == typeof(PropertyCollection))
|
if (type == typeof(PropertyCollection))
|
||||||
{
|
{
|
||||||
tw.WriteLine("");
|
textWriter.WriteLine("");
|
||||||
tw.WriteLine("PROPERTIES");
|
textWriter.WriteLine("PROPERTIES");
|
||||||
tw.WriteLine("**********");
|
textWriter.WriteLine("**********");
|
||||||
|
|
||||||
if (propValue is PropertyCollection pc)
|
if (propValue is PropertyCollection propertyCollection)
|
||||||
foreach (var prop in pc)
|
{
|
||||||
|
foreach (var property in propertyCollection)
|
||||||
{
|
{
|
||||||
var propProperties = prop.GetType().GetProperties();
|
var propProperties = property.GetType().GetProperties();
|
||||||
|
|
||||||
//Writing the proerty name
|
//Writing the proerty name
|
||||||
tw.WriteLine("Name : " + prop.PropertyType.Name);
|
textWriter.WriteLine("Name : " + property.PropertyType.Name);
|
||||||
|
|
||||||
foreach (var p in propProperties)
|
foreach (var p in propProperties)
|
||||||
{
|
{
|
||||||
if (propertiesFilter.Contains(p.Name)) continue;
|
if (propertiesFilter.Contains(p.Name)) continue;
|
||||||
var pValue = p.GetValue(prop, null);
|
var pValue = p.GetValue(property, null);
|
||||||
tw.WriteLine(p.Name + " : " + pValue);
|
textWriter.WriteLine(p.Name + " : " + pValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
tw.WriteLine("------------------------");
|
textWriter.WriteLine("------------------------");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
tw.WriteLine(memberProp.Name + " : " + propValue);
|
textWriter.WriteLine(memberProp.Name + " : " + propValue);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
tw.Flush();
|
textWriter.Flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
HttpResponseMessage httpResponseMessage = new HttpResponseMessage();
|
var httpResponseMessage = new HttpResponseMessage();
|
||||||
httpResponseMessage.Content = new ByteArrayContent(ms.ToArray());
|
httpResponseMessage.Content = new ByteArrayContent(memoryStream.ToArray());
|
||||||
httpResponseMessage.Content.Headers.Add("x-filename", fileName);
|
httpResponseMessage.Content.Headers.Add("x-filename", fileName);
|
||||||
httpResponseMessage.Content.Headers.ContentType = new MediaTypeHeaderValue("application/octet-stream");
|
httpResponseMessage.Content.Headers.ContentType = new MediaTypeHeaderValue("application/octet-stream");
|
||||||
httpResponseMessage.Content.Headers.ContentDisposition = new ContentDispositionHeaderValue("attachment");
|
httpResponseMessage.Content.Headers.ContentDisposition = new ContentDispositionHeaderValue("attachment");
|
||||||
|
|||||||
@@ -1,10 +1,5 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using umbraco.BasePages;
|
using umbraco.BasePages;
|
||||||
using umbraco.BusinessLogic.Actions;
|
|
||||||
using umbraco.interfaces;
|
using umbraco.interfaces;
|
||||||
|
|
||||||
namespace umbraco.cms.Actions
|
namespace umbraco.cms.Actions
|
||||||
|
|||||||
Reference in New Issue
Block a user