示例#1
0
        /// <summary>
        /// Get the import time of the last lesson/timetable or substitution import from Untis
        /// </summary>
        /// <returns>The returned Import Time</returns>
        public async Task <DateTime> GetLastImportTime()
        {
            //Get the JSON
            LastImportTime lastImport = new LastImportTime();

            //Send and receive JSON from WebUntis
            string requestJson  = JsonConvert.SerializeObject(lastImport);
            string responseJson = await SendJsonAndWait(requestJson, _url, SessionId);

            //Parse JSON to Class
            LastImportTimeResult result = JsonConvert.DeserializeObject <LastImportTimeResult>(responseJson);

            string errorMsg = wus.LastError.Message;

            if (!SuppressErrors && errorMsg != null)
            {
                Logger.Append(Logger.LogLevel.Error, errorMsg);
                throw new WebUntisException(errorMsg);
            }

            //Return the Last Imported Time (DateTime)
            return(result.Result);
        }
 public bool TryReimport()
 {
     return(LastImportTime.AddMilliseconds(WaitTime) <= DateTime.Now);
 }