public ActionResult <string> Get() { try { var seconds = _dateHelper.GetSeconds(); var fnItems = _dataStorage.GetData <Data.TransferData.FnItems>(); var itemsList = new List <string>() { GetToken(), seconds.ToString(), ((fnItems?.Source ?? TransferData.SourceEnum.None) == TransferData.SourceEnum.Server && (fnItems?.Valid ?? false) ? fnItems.ID : string.Empty) }; AddItemToList(itemsList, Data.TransferData.ButtonPressEnum.Termostat1, fnItems); AddItemToList(itemsList, Data.TransferData.ButtonPressEnum.Termostat2, fnItems); AddItemToList(itemsList, Data.TransferData.ButtonPressEnum.ElHeating, fnItems); AddItemToList(itemsList, Data.TransferData.ButtonPressEnum.Water, fnItems); AddItemToList(itemsList, Data.TransferData.ButtonPressEnum.Cams, fnItems); AddItemToList(itemsList, Data.TransferData.ButtonPressEnum.Alarm, fnItems); var cmdItems = _dataStorage.GetData <TransferData.CmdItems>(); itemsList.Add((cmdItems?.Source ?? TransferData.SourceEnum.None) == TransferData.SourceEnum.Server && (cmdItems?.Valid ?? false) ? cmdItems.ID : string.Empty); AddCmdItemToList(itemsList, TransferData.ButtonPressEnum.GSM, cmdItems); AddCmdItemToList(itemsList, TransferData.ButtonPressEnum.WIFI, cmdItems); AddCmdItemToList(itemsList, TransferData.ButtonPressEnum.AlarmOff, cmdItems); var resStr = string.Join('|', itemsList); return(Ok($"{{{resStr}}}")); } catch (Exception ex) { _errors.ErrorList.Add(new ErrorModel(ex.ToString())); } return(Ok()); }
public ActionResult <string> Get() { var now = DateTime.Now.AddHours(1); //get last march sunday var marchDays = DateTime.DaysInMonth(now.Year, 3); var lastDayOfMarch = new DateTime(now.Year, 3, marchDays); var marchSpan = -(int)lastDayOfMarch.DayOfWeek; var summerBegin = lastDayOfMarch.AddDays(marchSpan); //get last october sunday var octDays = DateTime.DaysInMonth(now.Year, 10); var lastDayOfOct = new DateTime(now.Year, 10, octDays); var octSpan = -(int)lastDayOfOct.DayOfWeek; var summerEnd = lastDayOfOct.AddDays(octSpan); if (now >= summerBegin && now < summerEnd) { now = now.AddHours(1); } var year = now.Year; var firstInYear = new DateTime(year, 1, 1); var seconds = _dateHelper.GetSeconds(); return(Ok($"{{{seconds}}}")); }