diff --git a/IOB-MAN/utils.cs b/IOB-MAN/utils.cs index 3a77cc1d..7778251d 100644 --- a/IOB-MAN/utils.cs +++ b/IOB-MAN/utils.cs @@ -40,13 +40,16 @@ namespace IOB_MAN /// Helper formattazione durata human readable /// /// + /// textMode = come linguaggio scritto /// - public static string FormatTimeSpan(TimeSpan timeSpan) + public static string FormatTimeSpan(TimeSpan timeSpan, bool textMode=false) { - //Func, string> tupleFormatter = t => $"{t.Item1} {t.Item2}{(t.Item1 == 1 ? string.Empty : "s")}"; - //Func, string> tupleFormatter = t => $"{t.Item1}{t.Item2}"; - Func, string> tupleFormatter = t => $"{t.Item1} {(t.Item1 == 1 ? t.Item2 : t.Item2.Replace("giorno", "giorni").Replace("ora", "ore"))}"; - var components = new List> + if (textMode) + { + //Func, string> tupleFormatter = t => $"{t.Item1} {t.Item2}{(t.Item1 == 1 ? string.Empty : "s")}"; + //Func, string> tupleFormatter = t => $"{t.Item1}{t.Item2}"; + Func, string> tupleFormatter = t => $"{t.Item1} {(t.Item1 == 1 ? t.Item2 : t.Item2.Replace("giorno", "giorni").Replace("ora", "ore"))}"; + var components = new List> { Tuple.Create((int) timeSpan.TotalDays, "giorno"), Tuple.Create(timeSpan.Hours, "ora"), @@ -54,18 +57,36 @@ namespace IOB_MAN Tuple.Create(timeSpan.Seconds, "sec"), }; - components.RemoveAll(i => i.Item1 == 0); + components.RemoveAll(i => i.Item1 == 0); - string extra = ""; + string extra = ""; - if (components.Count > 1) - { - var finalComponent = components[components.Count - 1]; - components.RemoveAt(components.Count - 1); - extra = $" e {tupleFormatter(finalComponent)}"; + if (components.Count > 1) + { + var finalComponent = components[components.Count - 1]; + components.RemoveAt(components.Count - 1); + extra = $" e {tupleFormatter(finalComponent)}"; + } + + return $"{string.Join(", ", components.Select(tupleFormatter))}{extra}"; } + else + { + //Func, string> tupleFormatter = t => $"{t.Item1} {t.Item2}{(t.Item1 == 1 ? string.Empty : "s")}"; + //Func, string> tupleFormatter = t => $"{t.Item1}{t.Item2}"; + Func, string> tupleFormatter = t => $"{t.Item1:00}"; + var components = new List> + { + Tuple.Create((int) timeSpan.TotalDays, "g"), + Tuple.Create(timeSpan.Hours, ""), + Tuple.Create(timeSpan.Minutes, ""), + Tuple.Create(timeSpan.Seconds, ""), + }; - return $"{string.Join(", ", components.Select(tupleFormatter))}{extra}"; + //components.RemoveAll(i => i.Item1 == 0); + + return $"{string.Join(":", components.Select(tupleFormatter))}"; + } } #region utils lettura app.config diff --git a/Jenkinsfile b/Jenkinsfile index d2b773c6..ffe1b1b1 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -9,7 +9,7 @@ pipeline { steps { /* calcolo numero versione... diverso x branch MASTER/DEVELOP */ script { - withEnv(['NEXT_BUILD_NUMBER=667']) { + withEnv(['NEXT_BUILD_NUMBER=669']) { // env.versionNumber = VersionNumber(versionNumberString : '3.0.${BUILD_DATE_FORMATTED, "yyMM"}.${BUILDS_ALL_TIME}', projectStartDate : '2006-01-01', skipFailedBuilds: true) env.versionNumber = VersionNumber(versionNumberString : '3.0.${BUILD_DATE_FORMATTED, "yyMM"}.${BUILDS_ALL_TIME}', projectStartDate : '2006-01-01', skipFailedBuilds: true, overrideBuildsAllTime: '${NEXT_BUILD_NUMBER}') env.APP_NAME = 'MAPO-IOB-WIN'