Files
parr_api/PARR.BLL/Helpers/TemplateHelpers.cs

40 lines
1.4 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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);
}
}
}