using System.Text.RegularExpressions;
public const string PROCESSTYPE = "processrecords";
public const string SHAREPOINTFOLDER = "SharePoint.Folder";
public const string SHAREPOINTLIBRARY = "SharePoint.Library";
public static void Main()
var itemId = "https:||southeastwater.sharepoint.com|sites|org-00270|waterarchive|hydraulic assessment thinktank|new section 1.one";
var parentId = string.Empty;
var recordType = SHAREPOINTFOLDER;
var partitionKey = string.Format("{0:D19}", DateTime.UtcNow.Ticks);
var tasks = JsonConvert.SerializeObject(new QueueFileRecordType(recordType));
var queueItem = new QueueItem()
PartitionKey = partitionKey,
RowKey = CleanTableKey(itemId),
QueuedDate = DateTime.UtcNow,
UpdatedDate = DateTime.UtcNow,
Parent = string.IsNullOrEmpty(parentId) ? "unmanagedfile" : CleanTableKey(parentId),
BatchId = Guid.Empty.ToString(),
Console.WriteLine(JsonConvert.SerializeObject(queueItem));
public static string CleanTableKey(string keyToClean)
throw new ApplicationException("TableKey is null");
string cleanKey = string.Empty;
cleanKey = System.Web.HttpUtility.HtmlDecode(keyToClean);
cleanKey = System.Web.HttpUtility.UrlDecode(cleanKey);
string patternCarriageReturn = @"\r";
Regex regCarriageReturn = new Regex(patternCarriageReturn);
string patternLineFeed = @"\n";
Regex regLineFeed = new Regex(patternLineFeed);
string patternTab = @"\t";
Regex regTab = new Regex(patternTab);
cleanKey = regCarriageReturn.Replace(cleanKey.ToLower(), "");
cleanKey = regLineFeed.Replace(cleanKey.ToLower(), "");
cleanKey = regTab.Replace(cleanKey.ToLower(), "");
string patternForwardSlash = @"\\";
Regex regForwardSlash = new Regex(patternForwardSlash);
string patternBackSlash = "/";
Regex regBackSlash = new Regex(patternBackSlash);
string patternHash = "#";
Regex regHash = new Regex(patternHash);
string patternQuestionMark = @"\?";
Regex regQuestionMark = new Regex(patternQuestionMark);
cleanKey = cleanKey.ToLower();
cleanKey = regForwardSlash.Replace(cleanKey, "|");
cleanKey = regBackSlash.Replace(cleanKey, "|");
cleanKey = regHash.Replace(cleanKey, "|");
cleanKey = regQuestionMark.Replace(cleanKey, "|");
public class QueueFileRecordType
public string RecordType { get; set; }
public QueueFileRecordType()
RecordType = string.Empty;
public QueueFileRecordType(string recordType)
QueuedDate = DateTime.Parse("1601-01-01T00:00:00+00:00").ToUniversalTime();
UpdatedDate = DateTime.Parse("1601-01-01T00:00:00+00:00").ToUniversalTime();
public string PartitionKey { get; set; }
public string RowKey { get; set; }
public string Parent { get; set; }
public string Status { get; set; }
public DateTime QueuedDate { get; set; }
public DateTime UpdatedDate { get; set; }
public string BatchId { get; set; }
public string Tasks { get; set; }
public int Retries { get; set; }
public string Data { get; set; }