static PublicClass() { formAuroraMain = new AuroraMain(); formMyCmd = new MyCmd(); formLocker = new Locker(); formTimeLevel = new TimeLevel(); }
/// <summary> /// Ajoute un compteur. /// </summary> /// <param name="counter">Compteur.</param> /// <param name="mergeTimeAxis">Indique si l'axe de temps doit être mergé.</param> /// <param name="mergeDate">Date à utiliser pour le merge.</param> internal void AddCounter(CounterData counter, bool mergeTimeAxis, DateTime mergeDate) { // Alimentation du dictionnaire des axes. string axis = counter.Axis; if (!_axis.ContainsKey(axis)) { _axis.Add(axis, null); } if (_counters == null) { // Alimentation de la base de données des compteurs. string counterCode = counter.CounterCode; if (counterCode != null && !_counterDefinitions.ContainsKey(counterCode)) { _counterDefinitions.Add( counterCode, new CounterDefinition(counterCode, counter.CounterLabel, 1, 0, 0)); } } // Alimentation du cube de données. DateTime startDate = mergeTimeAxis ? mergeDate : counter.StartDate; CubeKey key = new CubeKey(startDate, axis, TimeLevel.ValueOf(counter.Level)); ICube cube; if (!_cubes.TryGetValue(key, out cube)) { cube = new ExternalCube(_name, key); _cubes.Add(key, cube); } ((ExternalCube)cube).AddCounter(counter); }
/// <summary> /// Réalise le rendu d'un cude. /// </summary> /// <param name="hyperCube">HyperCupe à rendre.</param> /// <param name="context">Context courant de la requête.</param> /// <param name="s">Stream de sortie.</param> internal static void RenderGraph(IHyperCube hyperCube, Context context, Stream s) { TimeLevel level = TimeLevel.ValueOf(context.Level); CounterCubeCriteria criteria = new CounterCubeCriteria(context.RequestName, level); if (context.Content.Equals("sparklines.png")) { HtmlGraphHelper.RenderGraphSparklines(context, hyperCube, criteria, s); } else { throw new NotSupportedException(); } }
public static DateTime ToDateTime(this DateTime dateTime, TimeLevel timeLevel = TimeLevel.Minute) { int year = dateTime.Year, month = dateTime.Month, day = dateTime.Day, hour = dateTime.Hour, minute = dateTime.Minute; switch (timeLevel) { case TimeLevel.Minute: return(new DateTime(year, month, day, hour, minute, 0, DateTimeKind.Utc)); case TimeLevel.Hour: return(new DateTime(year, month, day, hour, 0, 0, DateTimeKind.Utc)); case TimeLevel.Day: return(new DateTime(year, month, day, 0, 0, 0, DateTimeKind.Utc)); } return(dateTime); }
public static DateTime ToDateTime(this DateTime dateTime,TimeLevel timeLevel=TimeLevel.Minute) { int year = dateTime.Year,month=dateTime.Month, day=dateTime.Day,hour=dateTime.Hour,minute=dateTime.Minute; switch (timeLevel) { case TimeLevel.Minute: return new DateTime(year, month, day, hour, minute, 0, DateTimeKind.Utc); case TimeLevel.Hour: return new DateTime(year, month, day, hour, 0, 0, DateTimeKind.Utc); case TimeLevel.Day: return new DateTime(year,month,day,0,0,0,DateTimeKind.Utc); } return dateTime; }
/// <summary> /// 计算时差的,按级别时间数。比如两个时间差是1时15分,两个时间差是1天5小时20分 /// </summary> /// <param name="self"></param> /// <param name="timeLevel"></param> /// <returns></returns> public static string TimeDiffStr(this TimeSpan self, TimeLevel timeLevel) { if (self.IsNull()) { return("0"); } var tms = self.TotalMilliseconds; var currTimeLevel = TimeLevelMap.E2E(timeLevel); var resultStr = ""; var m_day = self.Days; var m_hou = self.Hours; var m_min = self.Minutes; var m_sec = self.Seconds; var m_mse = self.Milliseconds; var hEnum = TimeLevelMap.E2E(TimeLevel.Hour); var mEnum = TimeLevelMap.E2E(TimeLevel.Minute); var sEnum = TimeLevelMap.E2E(TimeLevel.Second); var msEnum = TimeLevelMap.E2E(TimeLevel.Millisecond); switch (currTimeLevel.Enum) { case TimeLevel.None: resultStr = $"{tms}{msEnum.Name}"; break; case TimeLevel.Year: var s_day1 = $"{m_day}{currTimeLevel.Name}"; var s_hou1 = $"{m_hou}{hEnum.Name}"; var s_min1 = $"{m_min}{mEnum.Name}"; var s_sec1 = $"{m_sec}{sEnum.Name}"; var s_mse1 = $"{m_mse}{msEnum.Name}"; resultStr = $"{s_day1}{s_hou1}{s_min1}{s_sec1}{s_mse1}"; break; case TimeLevel.Month: var s_day2 = $"{m_day}{currTimeLevel.Name}"; var s_hou2 = $"{m_hou}{hEnum.Name}"; var s_min2 = $"{m_min}{mEnum.Name}"; var s_sec2 = $"{m_sec}{sEnum.Name}"; var s_mse2 = $"{m_mse}{msEnum.Name}"; resultStr = $"{s_day2}{s_hou2}{s_min2}{s_sec2}{s_mse2}"; break; case TimeLevel.Day: var s_day3 = $"{m_day}{currTimeLevel.Name}"; var s_hou3 = $"{m_hou}{hEnum.Name}"; var s_min3 = $"{m_min}{mEnum.Name}"; var s_sec3 = $"{m_sec}{sEnum.Name}"; var s_mse3 = $"{m_mse}{msEnum.Name}"; resultStr = $"{s_day3}{s_hou3}{s_min3}{s_sec3}{s_mse3}"; break; case TimeLevel.Hour: var t_hou4 = m_hou + m_day * 24; var s_hou4 = $"{t_hou4}{currTimeLevel.Name}"; var s_min4 = $"{m_min}{mEnum.Name}"; var s_sec4 = $"{m_sec}{sEnum.Name}"; var s_mse4 = $"{m_mse}{msEnum.Name}"; resultStr = $"{s_hou4}{s_min4}{s_sec4}{s_mse4}"; break; case TimeLevel.Minute: var t_min5 = m_min + m_hou * 60 + m_day * 1440; var s_min5 = $"{t_min5}{currTimeLevel.Name}"; var s_sec5 = $"{m_sec}{sEnum.Name}"; var s_mse5 = $"{m_mse}{msEnum.Name}"; resultStr = $"{s_min5}{s_sec5}{s_mse5}"; break; case TimeLevel.Second: var t_sec6 = m_sec + m_min * 60 + m_hou * 3600 + m_day * 86400; var s_sec6 = $"{t_sec6}{currTimeLevel.Name}"; var s_mse6 = $"{m_mse}{msEnum.Name}"; resultStr = $"{s_sec6}{s_mse6}"; break; case TimeLevel.Millisecond: double t_mse7 = m_mse + m_sec * 1000 + m_min * 60000 + m_hou * 3600000 + m_day * 86400000; var s_mse7 = $"{t_mse7}{currTimeLevel.Name}"; resultStr = $"{s_mse7}"; break; default: resultStr = $"{tms}{msEnum.Name}"; break; } return(resultStr); }
/** * Constructor. * <p> * Calculates the pivot point based on the time level parameter. * @param series the time series with adequate endTime of each bar for the given time level. * @param timeLevel the corresponding {@link TimeLevel} for pivot calculation: * <ul> * <li>1-, 5-, 10- and 15-Minute charts use the prior days high, low and close: <b>timeLevelId</b> = TimeLevel.DAY</li> * <li>30- 60- and 120-Minute charts use the prior week's high, low, and close: <b>timeLevelId</b> = TimeLevel.WEEK</li> * <li>Pivot Points for daily charts use the prior month's high, low and close: <b>timeLevelId</b> = TimeLevel.MONTH</li> * <li>Pivot Points for weekly and monthly charts use the prior year's high, low and close: <b>timeLevelId</b> = TimeLevel.YEAR (= 4)</li> * <li> If you want to use just the last bar data: <b>timeLevelId</b> = TimeLevel.BARBASED</li> * </ul> * The user has to make sure that there are enough previous bars to Calculate correct pivots at the first bar that matters. For example for PIVOT_TIME_LEVEL_ID_MONTH * there will be only correct pivot point values (and reversals) after the first complete month */ public PivotPointIndicator(ITimeSeries series, TimeLevel timeLevel) : base(series) { _timeLevel = timeLevel; }