Last active
September 18, 2018 13:58
-
-
Save warpech/9c624c954afbbb70f28c77dec9702261 to your computer and use it in GitHub Desktop.
Convert ObjectNo to ObjectId
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.Linq; | |
//Usage examples: | |
// | |
//star Convert.cs 6513 | |
//star Convert.cs Blx | |
// | |
//Warning: the output goes to Starcounter Administrator | |
namespace Convert | |
{ | |
public class Program | |
{ | |
static void Main(string[] args) | |
{ | |
if (args.Length > 0) | |
{ | |
var input = args[0]; | |
if (input.All(char.IsDigit)) | |
{ | |
UInt64 inputNo = Convert.ToUInt64(input); | |
string no = Starcounter.DbHelper.Base64EncodeObjectNo(inputNo); | |
Console.WriteLine("Base64-encoding " + input + " => " + no); | |
} | |
else | |
{ | |
UInt64 inputNo = Starcounter.DbHelper.Base64DecodeObjectID(input); | |
Console.WriteLine("Base-64 decoding " + input + " => " + inputNo); | |
} | |
} | |
else | |
{ | |
Console.WriteLine("Provide an argument that is either an ObjectID or ObjectNo"); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment