Piscal client - check status and retrieve file skeleton in place

This commit is contained in:
2016-02-19 11:45:16 -05:00
parent 6534fc142b
commit 75fa448a0f
13 changed files with 345 additions and 107 deletions
+28
View File
@@ -0,0 +1,28 @@
using System;
using System.Text.RegularExpressions;
using LeafWeb.Core.Entities;
using LeafWeb.Core.Utility;
namespace LeafWeb.Core.Remote
{
public static class PiscalUtility
{
public static string GetPiscalDirectoryName(int id, string name, string identifier)
{
return $"{id}_{name.FilterAlphaNumeric()}_{identifier.FilterAlphaNumeric()}";
}
public static string GetPiscalDirectoryName(LeafInputFile leafInputFile)
{
return GetPiscalDirectoryName(leafInputFile.Id, leafInputFile.LeafInput.Name, leafInputFile.LeafInput.Identifier);
}
public static int GetIdFromDirectoryName(string directoryName)
{
var match = Regex.Match(directoryName, @"\d_");
if (!match.Success)
throw new FormatException("DirectoryName expected to be formatted {number}_{name}_{identifier}: " + directoryName);
return int.Parse(match.Captures[0].Value);
}
}
}