40 lines
1.4 KiB
C#
40 lines
1.4 KiB
C#
using System.Text.RegularExpressions;
|
||
|
||
namespace PARR.BLL.Helpers
|
||
{
|
||
public static class TemplateHelpers
|
||
{
|
||
/// <summary>
|
||
/// Генерация имени шаблона
|
||
/// </summary>
|
||
/// <param name="prefix">%PREFIX% для замены в шаблоне настроек</param>
|
||
/// <param name="settingsPrefix">берется из настроек</param>
|
||
/// <param name="ek"></param>
|
||
/// <param name="work"></param>
|
||
/// <returns></returns>
|
||
public static string GenerateTemplateName(string prefix, string settingsPrefix, string ek, string work)
|
||
{
|
||
if (string.IsNullOrEmpty(prefix))
|
||
prefix = "ОБЩЕЕ";
|
||
|
||
if (string.IsNullOrEmpty(settingsPrefix))
|
||
settingsPrefix = "%PREFIX%-ЭИТИ-ПАРР";
|
||
|
||
var joinedPrefix = settingsPrefix.Replace("%PREFIX%", prefix);
|
||
|
||
var splitter = "__";
|
||
return joinedPrefix + splitter + ek + splitter + work.Replace(" ", "-").ToUpper();
|
||
}
|
||
|
||
|
||
public static string GenerateTemplateNameWithResponseArea(string responseAreaCode, string settingsPrefix, string ek, string work)
|
||
{
|
||
var shortName = new Regex("[А-я]+$").Match(responseAreaCode).Value;
|
||
|
||
return GenerateTemplateName(shortName, settingsPrefix, ek, work);
|
||
}
|
||
|
||
|
||
}
|
||
}
|