示例#1
0
            public string ToJson()
            {
                JObject jo = new JObject();

                string formatDate = "yyyyMMdd";
                string formatTime = "HHmmss";

                AdvancedValue.SetDateTime(jo, new string[] { "start", "date" }, StartDate, formatDate);
                AdvancedValue.SetDateTime(jo, new string[] { "end", "date" }, EndDate, formatDate);
                AdvancedValue.SetDateTime(jo, new string[] { "time", "start" }, TimeStart, formatTime);
                AdvancedValue.SetDateTime(jo, new string[] { "time", "end" }, TimeEnd, formatTime);

                return(JsonConvert.SerializeObject(jo, Formatting.None));
            }
示例#2
0
            public static AdvancedValue ParseJson(string json)
            {
                // Check
                if (string.IsNullOrEmpty(json))
                {
                    return(null);
                }

                JObject jo = JObject.Parse(json);

                AdvancedValue v               = new AdvancedValue();
                string        formatDate      = "yyyyMMdd";
                string        formatTime      = "HHmmss";
                string        formatTimeShort = "HHmm";

                v.StartDate = AdvancedValue.ParseDateTime(jo, new string[] { "start", "date" }, formatDate);
                v.EndDate   = AdvancedValue.ParseDateTime(jo, new string[] { "end", "date" }, formatDate);
                v.TimeStart = AdvancedValue.ParseDateTime(jo, new string[] { "time", "start" }, formatTimeShort);
                v.TimeEnd   = AdvancedValue.ParseDateTime(jo, new string[] { "time", "end" }, formatTimeShort);

                return(v);
            }