Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@warpech
Last active September 18, 2018 13:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save warpech/9c624c954afbbb70f28c77dec9702261 to your computer and use it in GitHub Desktop.
Save warpech/9c624c954afbbb70f28c77dec9702261 to your computer and use it in GitHub Desktop.
Convert ObjectNo to ObjectId
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