You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

75 lines
2.8 KiB

namespace CounsellorBL.BLStructure
{
using CounsellorBL.Helper;
using MonumentDefine;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using OT.COM.LogisticsUtil;
using SoldierData.EnterprizeV4;
using System;
using System.Collections.Generic;
public class ScheduleRange
{
public DateTime Start { get; set; }
public DateTime End { get; set; }
public static string ParseLogStartEnd(string i_sTarget, JArray i_jaData, out ScheduleRange o_srResult,
[System.Runtime.CompilerServices.CallerLineNumber] int i_nCodeLine = 0,
[System.Runtime.CompilerServices.CallerMemberName] string i_sMemberName = "",
[System.Runtime.CompilerServices.CallerFilePath] string i_sSourcePath = "")
{
string sMsg = null;
int nStartLim = 14;
if (SystemSettingHelper.GetSetting(BLWording.LOG_RANGE, out tb_sys_system_setting sResult) == null &&
Int32.TryParse(sResult.key_value, out int nStartSetting))
{
nStartLim = nStartSetting;
}
DateTime dtToday = DateTime.Now.Date;
DateTime dtLim = dtToday.AddDays(-1 * nStartLim);
ScheduleRange sr = new ScheduleRange() { Start = dtLim, End = dtToday.AddYears(1) };
try
{
do
{
if (i_jaData == null || i_jaData.Count == 0)
{
sMsg = MessageWording.PARAM_NOT_EXPECTED;
break;
}
Dictionary<string, object> dicWhere = i_jaData[0][BLWording.WHEREDATA].ToObject<Dictionary<string, object>>();
if (dicWhere.ContainsKey(i_sTarget + "_start") && DateTime.TryParse(dicWhere[i_sTarget + "_start"].ToString(), out DateTime dtParsed) && dtParsed > sr.Start)
{
sr.Start = dtParsed;
}
if (dicWhere.ContainsKey(i_sTarget + "_end") && DateTime.TryParse(dicWhere[i_sTarget + "_end"].ToString(), out DateTime dtParsed2) && dtParsed2 > dtLim)
{
sr.End = dtParsed2;
}
// End Add 1
sr.End = sr.End.AddDays(1);
}
while (false);
}
catch (Exception ex)
{
LogHelper.DBLog(Util.GetLastExceptionMsg(ex), i_nCodeLine, i_sMemberName, i_sSourcePath);
sMsg = $"{nameof(ParseLogStartEnd)} unknwon exception. i_jaData={JsonConvert.SerializeObject(i_jaData)}. Call from {i_sMemberName} {i_sSourcePath}({i_nCodeLine}).";
#if DEBUG
System.Diagnostics.Debug.WriteLine(sMsg);
#endif
}
o_srResult = sr;
return sMsg;
}
}
}