private bool TryGetTime() { if (!IsConnected && !Connect()) { return(false); } try { Logger.AddEvent("Определение диапазона источника"); var cmd = new OleDbCommand("Exec RT_ARCHDATE", Connection); using (OleDbDataReader rec = cmd.ExecuteReader()) { if (rec == null) { return(false); } rec.Read(); BeginTime = (DateTime)rec[0]; EndTime = (DateTime)rec[1]; TimeIntervals.Clear(); TimeIntervals.Add(new TimeInterval(BeginTime, EndTime)); Logger.AddEvent("Диапазон источника определен", BeginTime + " - " + EndTime); return(BeginTime.ToString() != "0:00:00"); } } catch (Exception ex) { Logger.AddError("Ошибка определения диапазона архива ПТК Космотроника", ex); IsConnected = false; return(false); } }
private void TimeCalculate() { if (TimeNeedsToRecalculate) { if (TimeIntervals == null) { TimeIntervals = new List <double>(); } TimeIntervals.Clear(); //DateTime time = DateTime.Now; for (double i = StartTime; i <= EndTime + TimeStep / 2.0; i += TimeStep) { double interval = Math.Round(i, 6); TimeIntervals.Add(interval); } //_tTime = (DateTime.Now - time).TotalMilliseconds; TimeNeedsToRecalculate = false; FrequencyNeedsToRecalculate = true; } }
//Получение времени источника public TimeInterval GetTime() { TimeIntervals.Clear(); TimeInterval t = null; try { if (IsOriginal) { t = new TimeInterval(Different.MinDate.AddYears(1), DateTime.Now); } else { using (var sys = new SysTabl(DatabaseFile, false)) t = new TimeInterval(DateTime.Parse(sys.Value("BeginInterval")), DateTime.Parse(sys.Value("EndInterval"))); } TimeIntervals.Add(t); } catch (Exception ex) { AddError("Ошибка определения диапазона источника", ex); IsConnected = false; } return(t); }
//Получение времени источника public TimeInterval GetTime() { TimeIntervals.Clear(); var t = new TimeInterval(Different.MinDate.AddYears(1), DateTime.Now); TimeIntervals.Add(t); return(t); }
//Получение диапазона архива по блокам истории public TimeInterval GetTime() { TimeIntervals.Clear(); var ti = new TimeInterval(Different.MinDate, Different.MaxDate); TimeIntervals.Add(ti); return(ti); }
//Получение диапазона клона public TimeInterval GetTime() { if (CloneFile.IsEmpty()) { return(new TimeInterval(Different.MinDate, Different.MaxDate)); } using (var sys = new SysTabl(CloneFile)) { TimeIntervals.Clear(); var t = new TimeInterval(sys.Value("BeginInterval").ToDateTime(), IsHandInput ? DateTime.Now : sys.Value("EndInterval").ToDateTime()); TimeIntervals.Add(t); return(t); } }
//Получение диапазона клона public TimeInterval GetTime() { try { using (var rec = new DataSetSql(SqlProps, "SysTabl")) { rec.FindFirst("ParamName", "BeginInterval"); TimeIntervals.Clear(); var t = new TimeInterval(rec.GetString("ParamValue").ToDateTime(), DateTime.Now); TimeIntervals.Add(t); return(t); } } catch { return(new TimeInterval(Different.MinDate, Different.MaxDate)); } }
//Получение диапазона архива по блокам истории public TimeInterval GetTime() { TimeIntervals.Clear(); DateTime mind = Different.MaxDate, maxd = Different.MinDate; DateTime mint = Different.MaxDate, maxt = Different.MinDate; try { using (var rec = new ReaderAdo(SqlProps, "SELECT FromDate, ToDate FROM v_HistoryBlock ORDER BY FromDate, ToDate DESC")) while (rec.Read()) { var fromd = rec.GetTime("FromDate"); var tod = rec.GetTime("ToDate"); if (fromd < mind) { mind = fromd; } if (fromd.Subtract(maxt).TotalMinutes > 1) { if (maxt != Different.MinDate) { TimeIntervals.Add(new TimeInterval(mint, maxt)); } mint = fromd; } if (maxd < tod) { maxd = tod; } if (maxt < tod) { maxt = tod; } } } catch (Exception ex) { Logger.AddError("Ошибка при получении диапазона источника", ex); } if (mind == Different.MaxDate && maxd == Different.MinDate) { return(new TimeInterval(Different.MinDate, Different.MaxDate)); } Logger.AddEvent("Диапазон источника определен", mind + " - " + maxd); return(new TimeInterval(mind, maxd)); }
private void TimeCalculate() { if (TimeNeedsToRecalculate) { if (TimeIntervals == null) { TimeIntervals = new List <double>(); } TimeIntervals.Clear(); for (double i = StartTime; i <= EndTime + TimeStep / 2.0; i += TimeStep) { double interval = Math.Round(i, 6); TimeIntervals.Add(interval); } TimeNeedsToRecalculate = false; } }
//Получение диапазона архива public TimeInterval GetTime() { var pdic = Archive.ReadProjects(ReportType.Calc); var t = new TimeInterval(Different.MaxDate, Different.MinDate); foreach (var pr in pdic.Values) { var dic = Archive.ReadRanges(pr.Code, ReportType.Calc); AddIntervalTime(dic, IntervalType.Day, t); AddIntervalTime(dic, IntervalType.Hour, t); AddIntervalTime(dic, IntervalType.Base, t); AddIntervalTime(dic, IntervalType.Moments, t); AddIntervalTime(dic, IntervalType.AbsoluteDay, t); } TimeIntervals.Clear(); TimeIntervals.Add(t); BeginTime = t.Begin; EndTime = t.End; return(t); }