using System.Collections.Generic;
public string outputObjToJson(object obj) {
string jsonString = Newtonsoft.Json.JsonConvert.SerializeObject(obj);
public string Protocol{get; set;}
public string Treatment{get;set;}
public string Action {get; set;}
public string AttributeName {get; set;}
public string Value {get; set;}
public string Quantity {get; set;}
public string DeviceID {get; set;}
public string UserID {get; set;}
public DateTime LogDate {get; set;}
public List<Attribute> Attributes {get; set;}
public void AddAttribute(string attributeName, string val, string quantity)
if (this.Attributes == null)
this.Attributes = new List<Attribute>();
Attributes.Add(new Attribute{AttributeName = attributeName, Value = val, Quantity = quantity});
public class ConfigCsvViewModel
public List<string> HeaderColumns { get; set; }
public List<string> Columns { get; set; }
public class ConfigViewModel
public ConfigCsvViewModel CSVFormat { get; set; }
public string UrlQueue { get; set; }
public string UrlPost { get; set; }
public string DataFileName { get; set; }
public string CsvFolderPath { get; set; }
public string CsvFileNamePattern { get; set; }
public string CsvArchiveDirectory { get; set; }
public bool UseCsv {get; set;}
public static void Main()
ConfigCsvViewModel csvVm = new ConfigCsvViewModel();
List<string> headerCols = new List<string>();
headerCols.Add("DeviceID");
headerCols.Add("UserID");
headerCols.Add("Revision");
headerCols.Add("SoftwareVersion");
headerCols.Add("Configuration");
headerCols.Add("Country");
csvVm.HeaderColumns = headerCols;
List<string> activityCols = new List<string>();
activityCols.Add("LogDate");
activityCols.Add("Mode");
activityCols.Add("Treatment");
activityCols.Add("Step");
activityCols.Add("MotorTime");
activityCols.Add("PumpValue");
activityCols.Add("RFID");
csvVm.Columns = activityCols;
ConfigViewModel config = new ConfigViewModel();
config.UrlPost = "https://hydrafacial.premioinc.com/api/Activity";
config.UrlQueue = "https://hydrafacial.premioinc.com/api/Queue";
config.DataFileName = "Activity.log";
config.CsvFolderPath = "c:\\premio\\";
config.CsvFileNamePattern = "HMD";
config.CsvArchiveDirectory = "c:\\Premio\\Archive\\";
config.CSVFormat = csvVm;
string outputString4 = Newtonsoft.Json.JsonConvert.SerializeObject(config);
Console.WriteLine(outputString4);
string str = "2018321".Substring(0,4);
string formatString = "yyyyMMddHHmmss";
string sample = "20100611221912";
DateTime dt = DateTime.ParseExact(sample,formatString,null);
string []format = new string []{"yyyy-MM-dd HH:mm:ss"};
string value = "120180213120022";
if (DateTime.TryParseExact(value, formatString, System.Globalization.CultureInfo.InvariantCulture,System.Globalization.DateTimeStyles.NoCurrentDateDefault , out datetime))
Console.WriteLine("Valid : " + datetime);
Console.WriteLine("Invalid");