ResxManager: export file
This commit is contained in:
parent
e32c19bde3
commit
acb990ca87
@ -100,13 +100,14 @@ namespace ASC.Resource.Manager
|
||||
}
|
||||
}
|
||||
|
||||
public static void Export(string project, string module, string language, string exportPath, string key = null)
|
||||
public static void Export(string project, string module, string fName, string language, string exportPath, string key = null)
|
||||
{
|
||||
var filter = new ResCurrent
|
||||
{
|
||||
Project = new ResProject { Name = project },
|
||||
Module = new ResModule { Name = module },
|
||||
Language = new ResCulture { Title = language }
|
||||
Language = new ResCulture { Title = language },
|
||||
Word = new ResWord() { ResFile = new ResFile() { FileName = fName } }
|
||||
};
|
||||
|
||||
var words = ResourceData.GetListResWords(filter, string.Empty).GroupBy(x => x.ResFile.FileID).ToList();
|
||||
|
@ -10,6 +10,9 @@ namespace ASC.Resource.Manager
|
||||
[Option('m', "module", Required = false, HelpText = "Module")]
|
||||
public string Module { get; set; }
|
||||
|
||||
[Option("fp", Required = false, HelpText = "File Path")]
|
||||
public string FilePath { get; set; }
|
||||
|
||||
[Option('e', "exportpath", Required = false, HelpText = "Export Path", Default = "..\\..\\..\\..\\ASC.Common\\")]
|
||||
public string ExportPath { get; set; }
|
||||
|
||||
@ -22,7 +25,7 @@ namespace ASC.Resource.Manager
|
||||
[Option('k', "key", Required = false, HelpText = "Key", Default = "")]
|
||||
public string Key { get; set; }
|
||||
|
||||
public void Deconstruct(out string project, out string module, out string exportPath, out string culture, out string format, out string key)
|
||||
=> (project, module, exportPath, culture, format, key) = (Project, Module, ExportPath, Culture, Format, Key);
|
||||
public void Deconstruct(out string project, out string module, out string filePath, out string exportPath, out string culture, out string format, out string key)
|
||||
=> (project, module, filePath, exportPath, culture, format, key) = (Project, Module, FilePath, ExportPath, Culture, Format, Key);
|
||||
}
|
||||
}
|
||||
|
@ -30,13 +30,14 @@ namespace ASC.Resource.Manager
|
||||
var cultures = new List<string>();
|
||||
var projects = new List<ResFile>();
|
||||
var enabledSettings = new EnabledSettings();
|
||||
Action<string, string, string, string, string> export = null;
|
||||
Action<string, string, string, string, string, string> export = null;
|
||||
|
||||
try
|
||||
{
|
||||
var (project, module, exportPath, culture, format, key) = options;
|
||||
var (project, module, filePath, exportPath, culture, format, key) = options;
|
||||
|
||||
if(format == "json")
|
||||
|
||||
if (format == "json")
|
||||
{
|
||||
export = JsonManager.Export;
|
||||
}
|
||||
@ -65,7 +66,7 @@ namespace ASC.Resource.Manager
|
||||
cultures = ResourceData.GetCultures().Where(r => r.Available).Select(r => r.Title).Intersect(enabledSettings.Langs).ToList();
|
||||
projects = ResourceData.GetAllFiles();
|
||||
|
||||
ExportWithProject(project, module, culture, exportPath, key);
|
||||
ExportWithProject(project, module, filePath, culture, exportPath, key);
|
||||
|
||||
Console.WriteLine("The data has been successfully exported!");
|
||||
}
|
||||
@ -74,44 +75,58 @@ namespace ASC.Resource.Manager
|
||||
Console.WriteLine(err);
|
||||
}
|
||||
|
||||
void ExportWithProject(string projectName, string moduleName, string culture, string exportPath, string key = null)
|
||||
void ExportWithProject(string projectName, string moduleName, string fileName, string culture, string exportPath, string key = null)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(projectName))
|
||||
{
|
||||
ExportWithModule(projectName, moduleName, culture, exportPath, key);
|
||||
ExportWithModule(projectName, moduleName, fileName, culture, exportPath, key);
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (var p in projects.Select(r => r.ProjectName).Intersect(enabledSettings.Projects))
|
||||
{
|
||||
ExportWithModule(p, moduleName, culture, exportPath, key);
|
||||
ExportWithModule(p, moduleName, fileName, culture, exportPath, key);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ExportWithModule(string projectName, string moduleName, string culture, string exportPath, string key = null)
|
||||
void ExportWithModule(string projectName, string moduleName, string fileName, string culture, string exportPath, string key = null)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(moduleName))
|
||||
{
|
||||
ExportWithCulture(projectName, moduleName, culture, exportPath, key);
|
||||
ExportWithFile(projectName, moduleName, fileName, culture, exportPath, key);
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (var m in projects.Where(r => r.ProjectName == projectName).Select(r => r.ModuleName))
|
||||
{
|
||||
ExportWithCulture(projectName, m, culture, exportPath, key);
|
||||
ExportWithFile(projectName, m, fileName, culture, exportPath, key);
|
||||
}
|
||||
}
|
||||
}
|
||||
void ExportWithCulture(string projectName, string moduleName, string culture, string exportPath, string key = null)
|
||||
void ExportWithFile(string projectName, string moduleName, string fileName, string culture, string exportPath, string key = null)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(culture))
|
||||
if (!string.IsNullOrEmpty(fileName))
|
||||
{
|
||||
export(projectName, moduleName, culture, exportPath, key);
|
||||
ExportWithCulture(projectName, moduleName, fileName, culture, exportPath, key);
|
||||
}
|
||||
else
|
||||
{
|
||||
ParallelEnumerable.ForAll(cultures.AsParallel(), c => export(projectName, moduleName, c, exportPath, key));
|
||||
foreach (var f in projects.Where(r => r.ProjectName == projectName && r.ModuleName == moduleName).Select(r => r.FileName))
|
||||
{
|
||||
ExportWithCulture(projectName, moduleName, f, culture, exportPath, key);
|
||||
}
|
||||
}
|
||||
}
|
||||
void ExportWithCulture(string projectName, string moduleName, string fileName, string culture, string exportPath, string key)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(culture))
|
||||
{
|
||||
export(projectName, moduleName, fileName, culture, exportPath, key);
|
||||
}
|
||||
else
|
||||
{
|
||||
ParallelEnumerable.ForAll(cultures.AsParallel(), c => export(projectName, moduleName, fileName, c, exportPath, key));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -285,15 +285,28 @@ namespace ASC.Resource.Manager
|
||||
.Select("rd1.title", "rd1.fileid", "rd1.textValue", "rd1.description", "rd1.flag", "rd1.link", "rf.resName", "rd2.id", "rd2.flag", "rd2.textValue")
|
||||
.LeftOuterJoin(ResDataTable + " rd2", Exp.EqColumns("rd1.fileid", "rd2.fileid") & Exp.EqColumns("rd1.title", "rd2.title") & Exp.Eq("rd2.cultureTitle", current.Language.Title))
|
||||
.InnerJoin(ResFilesTable + " rf", Exp.EqColumns("rf.ID", "rd1.fileID"))
|
||||
.Where("rf.moduleName", current.Module.Name)
|
||||
.Where("rf.projectName", current.Project.Name)
|
||||
.Where("rd1.cultureTitle", "Neutral")
|
||||
.Where("rd1.flag != 4")
|
||||
.Where("rd1.resourceType", "text")
|
||||
.Where(!Exp.Like("rd1.title", @"del\_", SqlLike.StartWith) & !Exp.Exists(exist))
|
||||
.OrderBy("rd1.id", true);
|
||||
|
||||
if (!String.IsNullOrEmpty(search))
|
||||
if(current.Module != null && !string.IsNullOrEmpty(current.Module.Name))
|
||||
{
|
||||
sql.Where("rf.moduleName", current.Module.Name);
|
||||
}
|
||||
|
||||
if(current.Project != null && !string.IsNullOrEmpty(current.Project.Name))
|
||||
{
|
||||
sql.Where("rf.projectName", current.Project.Name);
|
||||
}
|
||||
|
||||
if(current.Word != null && current.Word.ResFile != null && !string.IsNullOrEmpty(current.Word.ResFile.FileName))
|
||||
{
|
||||
sql.Where("rf.resName", current.Word.ResFile.FileName);
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(search))
|
||||
sql.Where(Exp.Like("rd1.textvalue", search));
|
||||
|
||||
return dbManager.ExecuteList(sql).ConvertAll(r =>
|
||||
|
@ -35,13 +35,14 @@ namespace ASC.Resource.Manager
|
||||
{
|
||||
public class ResxManager
|
||||
{
|
||||
public static void Export(string project, string module, string language, string exportPath, string key = null)
|
||||
public static void Export(string project, string module, string fName, string language, string exportPath, string key = null)
|
||||
{
|
||||
var filter = new ResCurrent
|
||||
{
|
||||
Project = new ResProject { Name = project },
|
||||
Module = new ResModule { Name = module },
|
||||
Language = new ResCulture { Title = language }
|
||||
Language = new ResCulture { Title = language },
|
||||
Word = new ResWord() { ResFile = new ResFile() { FileName = fName } }
|
||||
};
|
||||
|
||||
var words = ResourceData.GetListResWords(filter, string.Empty).GroupBy(x => x.ResFile.FileID).ToList();
|
||||
@ -78,7 +79,7 @@ namespace ASC.Resource.Manager
|
||||
using var resXResourceReader = new ResXResourceReader(zipFileName);
|
||||
foreach (var v in resXResourceReader.Cast<DictionaryEntry>())
|
||||
{
|
||||
toAdd.Add(new ResWord { Title = v.Key.ToString(), ValueFrom = v.Value?.ToString() });
|
||||
toAdd.Add(new ResWord { Title = v.Key.ToString(), ValueTo = v.Value?.ToString() });
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user