Exemple #1
0
        /// <summary>
        /// Update current data
        /// </summary>
        protected void RefreshCurData()
        {
            try {
                var utcNowDT = DateTime.UtcNow;
                if (utcNowDT - curDataRefrDT > DataValidSpan)   // data is out of date
                {
                    curDataRefrDT = utcNowDT;
                    var newCurTableAge = serverComm.ReceiveFileAge(ServerComm.Dirs.Cur, SrezAdapter.CurTableName);

                    if (newCurTableAge == DateTime.MinValue)
                    {
                        // the slice file does not exist or there is no connection to the server
                        tblCur.Clear();
                        tblCur.FileModTime = DateTime.MinValue;
                        log.WriteError("Unable to receive the current data file modification time.");
                    }
                    else if (tblCur.FileModTime != newCurTableAge)     // slice file changed
                    {
                        if (serverComm.ReceiveSrezTable(SrezAdapter.CurTableName, tblCur))
                        {
                            tblCur.FileModTime  = newCurTableAge;
                            tblCur.LastFillTime = utcNowDT;
                        }
                        else
                        {
                            tblCur.FileModTime = DateTime.MinValue;
                        }
                    }
                }
            } catch (Exception ex) {
                tblCur.FileModTime = DateTime.MinValue;
                log.WriteException(ex, "Error refreshing the current data");
            }
        }
Exemple #2
0
        /// <summary>
        /// Обновить текущие данные
        /// </summary>
        protected void RefreshCurData()
        {
            try
            {
                DateTime utcNowDT = DateTime.UtcNow;
                if (utcNowDT - curDataRefrDT > DataValidSpan) // данные устарели
                {
                    curDataRefrDT = utcNowDT;
                    DateTime newCurTableAge = serverComm.ReceiveFileAge(ServerComm.Dirs.Cur, SrezAdapter.CurTableName);

                    if (newCurTableAge == DateTime.MinValue) // файл среза не существует или нет связи с сервером
                    {
                        tblCur.Clear();
                        tblCur.FileModTime = DateTime.MinValue;
                        log.WriteError(Localization.UseRussian ?
                                       "Не удалось принять время изменения файла текущих данных." :
                                       "Unable to receive the current data file modification time.");
                    }
                    else if (tblCur.FileModTime != newCurTableAge) // файл среза изменён
                    {
                        if (serverComm.ReceiveSrezTable(SrezAdapter.CurTableName, tblCur))
                        {
                            tblCur.FileModTime  = newCurTableAge;
                            tblCur.LastFillTime = utcNowDT;
                        }
                        else
                        {
                            tblCur.FileModTime = DateTime.MinValue;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                tblCur.FileModTime = DateTime.MinValue;
                log.WriteException(ex, Localization.UseRussian ?
                                   "Ошибка при обновлении текущих данных" :
                                   "Error refreshing the current data");
            }
        }