Created
September 1, 2020 17:30
-
-
Save joecastelo/451bc1672056aae1b390fd8c5a463093 to your computer and use it in GitHub Desktop.
Structure Id Checking 👽
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
using System.Threading.Tasks; | |
using VMS.TPS.Common.Model.API; | |
namespace StructureOnWPF | |
{ | |
public class Helpers | |
{ | |
public static string CheckStructureIds(StructureSet ss, string wantedId) | |
{ | |
var maxLength = 16; | |
if (ss.Structures.Any(e=>e.Id.ToLower() == wantedId.ToLower())) | |
{ | |
wantedId = limitChars(new Random().Next(0, 9).ToString() + "_" + wantedId, maxLength); | |
} | |
return wantedId; | |
} | |
public static string limitChars(string wantedId, int maxLength) | |
{ | |
return wantedId.Length <= maxLength ? wantedId : wantedId.Substring(0, maxLength); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment