Exemplo n.º 1
0
        public IList <IntervalType> GetActiveIntervalTypes()
        {
            IList <IntervalType> intervalTypes = null;

            try
            {
                DataTable dt = Db.GetDataTable("SP_INTERVALTYPE_GET", null);

                if (dt != null && dt.Rows.Count > 0)
                {
                    intervalTypes = new List <IntervalType>();
                    foreach (DataRow row in dt.Rows)
                    {
                        IntervalType intervalType = new IntervalType();

                        intervalType.IntervalTypeId = Db.ToInteger(row["IntervalTypeId"]);
                        intervalType.Name           = Db.ToString(row["Name"]);
                        intervalTypes.Add(intervalType);
                    }
                }
            }
            catch (Exception ex)
            {
                //CommonFunctions.LogError(ex, ErrorLog.LogSeverity.Error);
            }
            return(intervalTypes);
        }
Exemplo n.º 2
0
        private static IntervalType ConvertToIntervalType(string intrevalTypeString)
        {
            IntervalType result = IntervalType.Milliseconds;

            if (string.Compare(intrevalTypeString, IntervalType.Days.ToString(), true) == 0)
            {
                result = IntervalType.Days;
            }

            if (string.Compare(intrevalTypeString, IntervalType.Hours.ToString(), true) == 0)
            {
                result = IntervalType.Hours;
            }

            if (string.Compare(intrevalTypeString, IntervalType.Minutes.ToString(), true) == 0)
            {
                result = IntervalType.Minutes;
            }

            if (string.Compare(intrevalTypeString, IntervalType.Seconds.ToString(), true) == 0)
            {
                result = IntervalType.Seconds;
            }

            if (string.Compare(intrevalTypeString, IntervalType.Milliseconds.ToString(), true) == 0)
            {
                result = IntervalType.Milliseconds;
            }

            return(result);
        }
Exemplo n.º 3
0
        public static void ScheduleJob(string id, DateTime startTime, IntervalType intervalType, int interval = 1)
        {
            var startTimer = TimerHelper.GetInitialTimer(startTime);
            var scheduler  = _schedulerFactory.New(id, startTimer);

            scheduler.Timer.Elapsed += (sender, e) => _eventHandler.HandleStartEvent(id, SchedulerType.Parent, intervalType, interval);
        }
Exemplo n.º 4
0
        public static double Getinterval(IntervalType type, int interval)
        {
            double delay = DefaultDelay.Hourly;

            switch (type)
            {
            case IntervalType.Minutely:
            {
                delay = (interval * DefaultDelay.Minutely);
                break;
            }

            case IntervalType.Hourly:
            {
                delay = (interval * DefaultDelay.Hourly);
                break;
            }

            case IntervalType.Daily:
            {
                delay = (interval * DefaultDelay.Daily);
                break;
            }

            case IntervalType.Weekly:
            {
                delay = (interval * DefaultDelay.Weekly);
                break;
            }

            default: break;
            }
            return(delay);
        }
Exemplo n.º 5
0
        public static int GetInterval(IntervalType intervalType, int interval)
        {
            int result = 0;

            switch (intervalType)
            {
            case IntervalType.Days:
                result = interval * 24 * 60 * 60 * 1000;
                break;

            case IntervalType.Hours:
                result = interval * 60 * 60 * 1000;
                break;

            case IntervalType.Minutes:
                result = interval * 60 * 1000;
                break;

            case IntervalType.Seconds:
                result = interval * 1000;
                break;

            case IntervalType.Milliseconds:
                result = interval;
                break;
            }

            return(result);
        }
Exemplo n.º 6
0
        /// <summary>
        /// 策略添加按钮
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnAddStrategy_Click(object sender, RoutedEventArgs e)
        {
            Type         strategyType = (Type)this.cbxStrategyName.SelectedItem;
            Strategy     strategy     = (Strategy)Activator.CreateInstance(strategyType);
            string       instrumentID = this.cbxStrategyInstrumentID.Text.ToString();
            IntervalType intervalType = (IntervalType)Enum.Parse(typeof(IntervalType), this.cbxStrategyIntervalType.Text.ToString());
            int          interval     = int.Parse(this.cbxStrategyInterval.Text);

            //调用参数Form
            using (FormParams fp = new FormParams())
            {
                ////从文本中做参数赋值
                //string ss = "(MaxLoss:1)";
                //foreach (var v in ss.Trim('(', ')').Split(','))
                //{
                //    strategy.SetParameterValue(v.Split(':')[0], v.Split(':')[1]);
                //}
                //策略参数配置
                fp.propertyGrid1.SelectedObject = strategy;
                fp.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
                if (fp.ShowDialog() != System.Windows.Forms.DialogResult.OK)
                {
                    return;
                }
                strategy.Notify("");
            }

            //将策略添加到DictStrategies
            string name = strategyType.Name + "_" + instrumentID + "_" + interval +
                          "_" + intervalType.ToString() + strategy.GetParams();

            this.AddStrategy(strategy, name, instrumentID, interval, intervalType);
        }
        private int GetRequiredQueueLengthFromIntervalType(IntervalType intervalType, int iterationTimeInMinutes)
        {
            var intervalinMinutes = float.Parse(((int)intervalType).ToString(), NumberStyles.Integer);
            var rawQueuSize       = intervalinMinutes / iterationTimeInMinutes;

            return((int)Math.Round(rawQueuSize, MidpointRounding.AwayFromZero));
        }
Exemplo n.º 8
0
        //private void txtInterval_TextChanged(object sender, EventArgs e)
        //{
        //    //if (!_isOpenXML)
        //    //    CalcSliceRange();
        //}

        private void CalcSliceRange()
        {
            if (_isInit)
            {
                return;
            }
            if (!CheckMaxMinValue())
            {
                return;
            }
            if (!CheckInterval())
            {
                return;
            }
            if (StringToNumberHelper.isFloatPointNumber(txtInterval.Text))
            {
                IntervalType = IntervalType.FloatType;
            }
            else
            {
                IntervalType = IntervalType.IntType;
            }
            float numValue = (float)(_maxValue - _minValue) / _interval;

            numSliceRange.Value = (decimal)Math.Ceiling(numValue <= 0 ? 1 :
                                                        numValue > (float)numSliceRange.Maximum ? numSliceRange.Maximum : (decimal)numValue);
        }
Exemplo n.º 9
0
 private void txtMax_Leave(object sender, EventArgs e)
 {
     if (StringToNumberHelper.isFloatPointNumber(txtMax.Text))
     {
         _intervalType = IntervalType.FloatType;
     }
 }
Exemplo n.º 10
0
        private void CalcMinMax()
        {
            double pdfMin = 0;
            double pdfMax = 0;

            try
            {
                _progress.Reset("正在统计端值...", 100);
                _progress.Start(false);
                IRasterBand band = _drawing.DataProviderCopy.GetRasterBand(_selectBand);
                band.ComputeMinMax(out pdfMin, out pdfMax, false,
                                   (idx, tip) => { _progress.Boost(idx); });
            }
            finally
            {
                _progress.Finish();
            }
            this.txtMin.Text = Math.Round(pdfMin, 2).ToString();
            this.txtMax.Text = Math.Round(pdfMax, 2).ToString();
            if (StringToNumberHelper.isFloatPointNumber(txtMin.Text) || StringToNumberHelper.isFloatPointNumber(txtMax.Text))
            {
                _intervalType = IntervalType.FloatType;
            }
            else
            {
                _intervalType = IntervalType.IntType;
            }
            _min_value = (int)pdfMin;
            _max_value = (int)pdfMax;
            _minValue  = (float)Math.Round(pdfMin, 2);
            _maxValue  = (float)Math.Round(pdfMax, 2);
        }
Exemplo n.º 11
0
        private List <DensityRange> InitRange(int range)
        {
            ConstructColorList();
            if (ckInterval.Checked)
            {
                if (StringToNumberHelper.isFloatPointNumber(txtInterval.Text))
                {
                    _intervalType = IntervalType.FloatType;
                }
                else
                {
                    _intervalType = IntervalType.IntType;
                }
            }
            else
            {
                _interval = (float)Math.Round((_maxValue - _minValue) / (float)numSliceRange.Value, 2);
            }
            if (_intervalType == IntervalType.IntType)
            {
                _interval = (int)Math.Ceiling(_interval);
            }
            List <DensityRange> m_RangeList = new List <DensityRange>();

            for (int i = 0; i < range; i++)
            {
                int          color_idx  = i > colorList.Length - 1 ? i % (colorList.Length - 1) : i;
                Color        rangeColor = colorList[color_idx];
                DensityRange r          = (i == 0) ?
                                          new DensityRange(_minValue + (i * _interval), _minValue + ((i + 1) * _interval), rangeColor.R, rangeColor.G, rangeColor.B) :
                                          new DensityRange(_minValue + (i * _interval), _minValue + ((i + 1) * _interval), rangeColor.R, rangeColor.G, rangeColor.B);
                m_RangeList.Add(r);
            }
            return(m_RangeList);
        }
Exemplo n.º 12
0
 /// <summary>
 /// Initializes new instance of a time interval from the interfaces an upper and a lower interval reference values.
 /// </summary>
 /// <param name="upper">The interface to the upper interval boundary to set the interval with.</param>
 /// <param name="lower">The interface to the lower interval boundary to set the interval with.</param>
 /// <param name="type">The time interval flexibility mode to set to the time interval.</param>
 public TimeInterval(IIntervalUpper <DateTime> upper, IIntervalLower <DateTime> lower, IntervalType type = IntervalType.Flex)
 {
     _limits = IntervalLimits.Lower | IntervalLimits.Upper;
     if (upper != null)
     {
         if (upper.UpperInclude)
         {
             _limits &= ~IntervalLimits.Lower;
         }
         _lower = upper.Upper;
     }
     if (lower != null)
     {
         if (upper == null)
         {
             _lower = lower.Lower;
         }
         if (lower.LowerInclude)
         {
             _limits &= ~IntervalLimits.Upper;
         }
         _upper = lower.Lower;
     }
     _span = _upper - _lower;
     Type  = type;
 }
Exemplo n.º 13
0
        /// <summary>
        /// 根据日期类型和时间获取经过处理后的TimeKey
        /// </summary>
        /// <param name="value"></param>
        /// <returns></returns>
        public static string GetCalenderFormatTimeKey(string value, IntervalType interval)
        {
            string timeKey = string.Empty;

            switch (interval)
            {
            case IntervalType.Year:
                timeKey = value.Substring(0, 4);
                break;

            case IntervalType.Month:
                timeKey = value.Substring(0, 4) + "/" + value.Substring(4, 2);
                break;

            case IntervalType.Week:
            case IntervalType.Day:
                timeKey = value.Substring(0, 4) + "/" + value.Substring(4, 2) + "/" + value.Substring(6, 2);
                break;

            case IntervalType.Minute:
                timeKey = value.Substring(8, 2) + ":" + value.Substring(10, 2);
                break;

            case IntervalType.Second:
                timeKey = value.Substring(8, 2) + ":" + value.Substring(10, 2) + ":" + value.Substring(12, 2);
                break;
            }
            return(timeKey);
        }
Exemplo n.º 14
0
        /// <summary>
        /// Determines whether a given point is contained in the interval, with the left and right endpoints
        /// separately specififed as closed or open.
        /// </summary>
        /// <param name="x">The point.</param>
        /// <param name="leftEndpointType">Specifier of whether the interval should be considered as including its left endpoint.</param>
        /// <param name="rightEndpointType">Specifier of whether the interval should be considered as including its right endpoint.</param>
        /// <returns><see langword="true"/> if <paramref name="x"/> is contained in the interval as specified,
        /// otherwise <see langword="false"/></returns>
        public bool Contains(double x, IntervalType leftEndpointType, IntervalType rightEndpointType)
        {
            bool leftSatisfied  = leftEndpointType == IntervalType.Closed ? x >= a : x > a;
            bool rightSatisfied = rightEndpointType == IntervalType.Closed ? x <= b : x < b;

            return(leftSatisfied && rightSatisfied);
        }
Exemplo n.º 15
0
 public void OnIntervalPropertyChange(string id, IntervalType mode, string intervalName = null, string taskName = null)
 {
     if (DoesExist)
     {
         Instance.OnIntervalPropertyChange(id, mode, intervalName, taskName);
     }
 }
Exemplo n.º 16
0
 public ArchiveInterval(IntervalType type, DateTime begin, DateTime end, string name = "")
     : base(begin, end)
 {
     Type       = type;
     Name       = name ?? "";
     TimeChange = Different.MinDate;
 }
Exemplo n.º 17
0
        public double GetIntervalInHours(IntervalType intervalType, int interval)
        {
            double intervalInHours;

            switch (intervalType)
            {
            case IntervalType.DAYS:
                intervalInHours = (double)interval * 24;
                break;

            case IntervalType.HOURS:
                intervalInHours = (double)interval;
                break;

            case IntervalType.MINTURES:
                intervalInHours = (double)interval / 60;
                break;

            case IntervalType.SECONDS:
                intervalInHours = (double)interval / 3600;
                break;

            default:
                intervalInHours = 0;
                break;
            }
            return(intervalInHours);
        }
Exemplo n.º 18
0
        private void SetPosition(IComponent componentToPosition)
        {
            Composite compositeToPosition;

            compositeToPosition = componentToPosition as Composite;

            if (compositeToPosition != null)
            {
                foreach (IComponent component in compositeToPosition)
                {
                    if (component is IComposite)
                    {
                        SetPosition(component);
                    }

                    IIntervalComponent ic = component as IIntervalComponent;
                    if (ic != null && ic.Interval != null)
                    {
                        IntervalType i = ic.Interval;
                        i.XStart = (i.StartDateTime.Ticks - _offset) / _res;
                        i.XEnd   = (i.EndDateTime.Value.Ticks - _offset) / _res; // TODO: null check
                        i.Y      = _y += LineHeight;
                    }

                    IComposite composite = component as IComposite;
                    if (composite != null)
                    {
                        composite.YCoord = _y += LineHeight;
                    }
                }
            }
        }
Exemplo n.º 19
0
        private bool NeedsScan(SlurpSchedule item, DateTime?lastDate)
        {
            if (lastDate == null)
            {
                lastDate = DateTime.MinValue;
            }

            IntervalType interval = (IntervalType)item.IntervalType;

            switch (interval)
            {
            case IntervalType.Minutes:
                lastDate.Value.AddMinutes(item.Interval);
                break;

            case IntervalType.Days:
                lastDate.Value.AddDays(item.Interval);
                break;

            case IntervalType.Hours:
                lastDate.Value.AddHours(item.Interval);
                break;

            case IntervalType.Months:
                lastDate.Value.AddMonths(item.Interval);
                break;

            case IntervalType.Years:
                lastDate.Value.AddYears(item.Interval);
                break;
            }
            return(DateTime.Now > lastDate.Value);
        }
Exemplo n.º 20
0
 //Если провайдер позволяет, чтение из таблицы архива
 public ArchiveInterval(IRecordRead rec, IntervalType type) : base(rec)
 {
     Type       = type;
     Name       = rec.GetString("IntervalName");
     Id         = rec.GetInt("IntervalId");
     TimeChange = rec.GetTime("TimeChange");
 }
Exemplo n.º 21
0
        /// <summary>
        /// Update / create a bar watch using the information in the form
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        public void SubscribeBars(string symbol, IntervalType intervalType, int intervalValue, int numberOfDaysBack = 1, string beginFilterTime = "", string endFilterTime = "", DateTime?beginDateTime = null)
        {
            string sBeginDateTime = "19700101000000";       // 1/1/1970 00:00:00

            if (beginDateTime != null)
            {
                sBeginDateTime = beginDateTime.Value.ToIQString();
            }

            // the command we need to send to turn on news is wSYMBOL\r\n
            string sCommand;

            sCommand = String.Format("BW,{0},{1},{2},{3},{4},{5},{6},{7},{8},,{9}\r\n",
                                     symbol,
                                     intervalValue,
                                     sBeginDateTime,
                                     numberOfDaysBack,
                                     this.MaxDatapointsToReceive,
                                     beginFilterTime,
                                     endFilterTime,
                                     this.RequestID,
                                     GetIntervalType(intervalType),
                                     this.UpdateIntervalInSeconds);

            SendRequestToIQFeed(sCommand);
        }
Exemplo n.º 22
0
        public static Tnum IntervalsUntil(Tdate startDate, Tdate endDate, IntervalType interval, int startAt)
        {
            // Handle unknowns
            Hstate top = PrecedingState(startDate.FirstValue, endDate.FirstValue);

            if (top != Hstate.Known)
            {
                return(new Tnum(new Hval(null, top)));
            }

            DateTime start = startDate.ToDateTime;
            DateTime end   = endDate.ToDateTime;

            Tnum result = new Tnum();

            DateTime indexDate   = end;
            int      indexNumber = startAt - 1;

            while (indexDate > start)
            {
                if (indexNumber != startAt - 1)
                {
                    result.AddState(indexDate, Convert.ToString(indexNumber));
                }
                indexNumber++;
                indexDate = indexDate.SubtractInterval(interval);
            }

            result.AddState(Time.DawnOf, 0);
            result.AddState(start, Convert.ToString(indexNumber));
            result.AddState(end, 0);

            return(result);
        }
Exemplo n.º 23
0
        /**********************************************************/

        /// <summary>
        /// add an interval to the report, return the UID of the interval
        /// after adding an interval, ReportPayloads can be added to the interval through
        /// the returned uid
        /// </summary>
        /// <param name="reportSpecifierID"></param>
        /// <param name="startUTC"></param>
        /// <param name="durationMinutes"></param>
        /// <returns></returns>
        public int addInterval(string reportSpecifierID, DateTime startUTC, int duration, DurationModifier durationModifier)
        {
            IntervalType intervalType = new IntervalType();


            intervalType.dtstart          = new dtstart();
            intervalType.dtstart.datetime = startUTC;

            intervalType.duration          = new DurationPropType();
            intervalType.duration.duration = "PT" + duration.ToString() + durationModifier.Value;

            List <IntervalType> reportIntervals = (_reportIntervals.ContainsKey(reportSpecifierID) ? _reportIntervals[reportSpecifierID] : null);

            if (reportIntervals == null)
            {
                reportIntervals = new List <IntervalType>();

                _reportIntervals.Add(reportSpecifierID, reportIntervals);
            }

            int uid = reportIntervals.Count;

            IntervalTypeUidUid intervalTypeUID = new IntervalTypeUidUid();

            intervalTypeUID.text = uid.ToString();

            intervalType.Item = intervalTypeUID;

            reportIntervals.Add(intervalType);

            return(uid);
        }
Exemplo n.º 24
0
 // TODO: options - retry logic and immediatly execute at start
 private Scheduler(IMonik monik, Action work, IntervalType interval, string name)
 {
     _monik   = monik;
     _action  = work;
     _name    = name;
     Interval = interval;
 }
Exemplo n.º 25
0
        public static void GetInterval(IntervalType intervalType, out int start, out int end)
        {
            switch (intervalType)
            {
            case IntervalType.LE10:
                start = 1;
                end   = 10;
                break;

            case IntervalType.LE20:
                start = 1;
                end   = 20;
                break;

            case IntervalType.LE50:
                start = 1;
                end   = 50;
                break;

            case IntervalType.LE100:
                start = 1;
                end   = 100;
                break;

            default:
                start = 1;
                end   = 10;
                break;
            }
        }
Exemplo n.º 26
0
        public IEnumerable<KlimaTemperaturPeriod> GroupTemperaturByPeriods(
            IEnumerable<KlimaTemperatur> klimaTemperaturs, 
            DateTime startDate, 
            IntervalType intervalType = IntervalType.M24)
        {
            var endDate = startDate.GetPastDate((int)intervalType);

            var datumVon1 = startDate.GetPastDate(12);
            var datumBis1 = startDate.GetLastDayOfMonth();
            var datumVon2 = endDate;
            var datumBis2 = startDate.GetPastDate(13).GetLastDayOfMonth();

            //For dayCounter important only month and day (used in chart X-Axis)
            var dayCounter = datumVon1; 
            var result = klimaTemperaturs
                .Where(p => !(p.Datum.Month == 2 && p.Datum.Day == 29 )) 
                .OrderBy( p=> p.Datum)
                .GroupBy(p => new { p.Datum.Day, p.Datum.Month })
                .Select((gr, index) => new KlimaTemperaturPeriod
                {
                    Datum = dayCounter.AddDays(index),
                    Period1 = gr.Where(p => p.Datum.IsBetween(datumVon1, datumBis1)).Select(p => p.Temperatur).FirstOrDefault(),
                    Period2= gr.Where(p => p.Datum.IsBetween(datumVon2, datumBis2)).Select(p => p.Temperatur).FirstOrDefault(),
                    Heizgrenztemperatur = 15
                });
            return  result;
        }
Exemplo n.º 27
0
        public static Tnum IntervalsSince(Tdate startDate, Tdate endDate, IntervalType interval, int? startAt)
        {
            // Handle unknowns
            Hstate top = PrecedingState(startDate.FirstValue, endDate.FirstValue);
            if (top != Hstate.Known) return new Tnum(new Hval(null,top));

            DateTime start = startDate.ToDateTime;
            DateTime end = endDate.ToDateTime;

            Tnum result = new Tnum();

            if (start != Time.DawnOf)
            {
                result.AddState(Time.DawnOf,0);
            }

            DateTime indexDate = start;
            int? indexNumber = startAt;

            while (indexDate < end)
            {
                result.AddState(indexDate,Convert.ToDecimal(indexNumber));
                indexNumber++;
                indexDate = indexDate.AddInterval(interval, 1);
            }

            if (end < Time.EndOf) result.AddState(end, 0);
            return result;
        }
Exemplo n.º 28
0
        public async Task <IActionResult> CreateTemplateInterBankTransfer(CreateTemplateInterBankTransferViewModel model)
        {
            Account receiver = accountService.OurBankAccount();
            User    user     = userService.FindUserByName(HttpContext.User.Identity.Name);
            await validationService.ValidateInterTransfer(model.Transfer.Transfer, user, receiver, ModelState);

            validationService.ValidatePaymentSchedule(model.Template, ModelState);
            if (ModelState.IsValid)
            {
                decimal amount = decimal.Parse(model.Transfer.Transfer.Amount);
                Account sender = await accountService.FindAccountById(model.Transfer.Transfer.AccountSenderId.Value);

                Template template = _templateServiceService.CreateTemplateInnerTransfer(sender, receiver, amount, model.Transfer.Transfer.Comment, user);
                _templateServiceService.AddTemplateNameDisc(template, model.Template);
                _templateServiceService.CreateTemplateInterTransfer(template, model.Transfer);
                if (model.Template.IsSetSchedule)
                {
                    IntervalType interval = await paymentScheduleService.FindIntervalTypeByIntervalCode(model.Template.PaymentScheduleViewModel.IntervalCode.Value);

                    paymentScheduleService.CreatePaymentSchedule(template, interval,
                                                                 model.Template.PaymentScheduleViewModel.DateStart,
                                                                 model.Template.PaymentScheduleViewModel.DateEnd);
                }
                return(RedirectToAction("Index", "Template"));
            }
            model.Transfer.Banks       = selectListService.GetBankList();
            model.Transfer.PaymentCode = selectListService.GetPayemntCodeList();
            model.Transfer.Transfer    = transferService.GetMethodInnerTransfer(user, model.Transfer.Transfer);
            model.Template.PaymentScheduleViewModel.IntervalTypes = selectListService.GetIntervalTypes();
            return(View(model));
        }
Exemplo n.º 29
0
        public static List<string> GetZeitraumeFormatted(
            DateTime stichTag,
            IntervalType intervalType = IntervalType.M24,
            string dayFormat = "MMM. yyyy")
        {
            var datumVon1 = stichTag.GetPastDate(12);
            var datumBis1 = stichTag;
            var datumVon2 = datumVon1.AddYears(-1);
            var datumBis2 = datumBis1.AddYears(-1);
            var datumVon3 = datumVon1.AddYears(-2);
            var datumBis3 = datumBis1.AddYears(-2);

            var periodFormat = "{0:" + dayFormat + "} - {1:" + dayFormat + "}";

            var result = new List<string>();
           
            if (intervalType == IntervalType.M36)
            {
                result.Add("Vorvorjahr " + string.Format(periodFormat, datumVon3, datumBis3));
            }
            result.Add("Vorjahr " +  string.Format(periodFormat, datumVon2, datumBis2));
            result.Add("Aktuelles Jahr " + string.Format(periodFormat, datumVon1, datumBis1));
           
            return result;
        }
Exemplo n.º 30
0
        /**********************************************************/

        public oadrReportType generateReport(string reportRequestID)
        {
            oadrReportType report = new oadrReportType();

            report.createdDateTime = DateTime.UtcNow;

            report.reportName = m_reportName.Name;

            report.reportRequestID = reportRequestID;

            report.reportSpecifierID = ReportSpecifierID;

            report.createdDateTime = DateTime.UtcNow;

            // the report does not have any descriptors
            if (m_reportIntervals.Count == 0)
            {
                return(report);
            }

            List <IntervalType> reportIntervals = m_reportIntervals.Values.ToList().OrderBy(o => o.dtstart.datetime).ToList();

            reportIntervals.Reverse();

            // the dtstart of the report must match the dtstart of the first interval
            report.dtstart          = new dtstart();
            report.dtstart.datetime = reportIntervals[0].dtstart.datetime;

            IntervalType[] intervalsArray = new IntervalType[m_reportIntervals.Count];

            int intervalIndex = 0;

            foreach (IntervalType interval in reportIntervals)
            {
                intervalsArray[intervalIndex] = interval;
                string key = interval.dtstart.datetime.ToString();

                List <StreamPayloadBaseType> intervalPayloads = m_reportIntervalPayloads[key];

                interval.streamPayloadBase = new StreamPayloadBaseType[intervalPayloads.Count];

                int intervalPayloadIndex = 0;
                foreach (StreamPayloadBaseType intervalPayload in intervalPayloads)
                {
                    interval.streamPayloadBase[intervalPayloadIndex] = intervalPayload;
                    intervalPayloadIndex++;
                }

                intervalIndex++;
            }

            m_reportIntervals.Clear();
            m_reportIntervalPayloads.Clear();

            report.oadrReportDescription = null;
            report.intervals             = intervalsArray;

            return(report);
        }
Exemplo n.º 31
0
 //Название таблицы строковых значений архива по типу интервала
 public static string ToStrValuesTable(this IntervalType t)
 {
     if (t.IsNamed())
     {
         return("NamedStrValues");
     }
     return(t.ToEnglish() + "StrValues");
 }
Exemplo n.º 32
0
 public static string GetDateDuration(IntervalType intervalType, DateTime requestFromDate, DateTime requestToDate)
 {
     return(intervalType == IntervalType.DurringSomeDays
         ? requestFromDate.Year == requestToDate.Year
             ? string.Format("{0:dd.MM} - {1:dd.MM.yyyy}", requestFromDate, requestToDate)
             : string.Format("{0:dd.MM.yyyy} - {1:dd.MM.yyyy}", requestFromDate, requestToDate)
         : requestFromDate.ToString("dd.MM.yyyy"));
 }
Exemplo n.º 33
0
 //Название таблицы интервалов архива по типу интервала
 public static string ToIntervalsTable(this IntervalType t)
 {
     if (t.IsNamed())
     {
         return("NamedIntervals");
     }
     return(t.ToEnglish() + "Intervals");
 }
Exemplo n.º 34
0
        public ChartService(DateTime startDate, int search, RequestType requestType)
        {
            this.StartDate = DateTimeExtensions.GetFirstDayOfMonth(startDate);
            this._search = search;
            this._requestType = requestType;

            this._interval = IntervalType.M24;

            this.EndDate = DateTimeExtensions.GetPastDate(this.StartDate, (int)this._interval);
        }
Exemplo n.º 35
0
        public async Task<IEnumerable<MeteoGtzPeriod>> GetGtzByPeriods(
            CalculateRequest calculateRequest,
            IntervalType intervalType = IntervalType.M36)
        {
            var meteoGtzDatas =  await this.GetMeteoGtz(calculateRequest, intervalType);

            var startDate = calculateRequest.Stichtag;
            var datumVon1 = startDate.GetPastDate(12);
            var datumBis1 = startDate;
            var datumVon2 = datumVon1.AddYears(-1);
            var datumBis2 = datumBis1.AddYears(-1);
            var datumVon3 = datumVon2.AddYears(-1);
            var datumBis3 = datumBis2.AddYears(-1);

            var result = meteoGtzDatas.GroupBy(
                p => new
                {
                    p.Monat,
                    p.Lgtz,
                    p.Promille
                }).Select(
                    (gr, index) => new MeteoGtzPeriod
                    {
                        Monat = gr.Key.Monat,
                        Lgtz = gr.Key.Lgtz,
                        Promille = gr.Key.Promille,
                        Period1 =
                            gr.Where(p => this.GetDate(p.Jahr, p.Monat).IsBetween(datumVon1, datumBis1))
                                .Select(p => p.Gtz)
                                .FirstOrDefault(),
                        Period2 =
                            gr.Where(p => this.GetDate(p.Jahr, p.Monat).IsBetween(datumVon2, datumBis2))
                                .Select(p => p.Gtz)
                                .FirstOrDefault(),
                        Period3 =
                            gr.Where(p => this.GetDate(p.Jahr, p.Monat).IsBetween(datumVon3, datumBis3))
                                .Select(p => p.Gtz)
                                .FirstOrDefault()
                    });
            return result;
        }
Exemplo n.º 36
0
        public async Task<IEnumerable<KlimaTemperatur>> GetTemperatur(CalculateRequest calculateRequest, IntervalType intervalType = IntervalType.M24)
        {
            var startDate = calculateRequest.Stichtag.GetPastDate((int)intervalType);
            var endDate = calculateRequest.Stichtag.GetLastDayOfMonth();
            
           IEnumerable<KlimaTemperatur> temperaturs = null;

           switch (calculateRequest.RequestType)
            {
                case RequestType.Plz:
                    var station = await wetterStationRepository.GetByPlz(calculateRequest.Value);
                    if (station == null) return new List<KlimaTemperatur>();
                    temperaturs = await this.GetTemperaturByPlz(station.WsCode, startDate, endDate);
                    break;
                case RequestType.Bundesland:
                    temperaturs = await this.GetTemperaturByBundesland(calculateRequest.Value, startDate, endDate);
                    break;
                case RequestType.Deutschland:
                    temperaturs = await this.GetTemperaturDeutschland(startDate, endDate);
                    break;
            }
            return temperaturs;
        }
Exemplo n.º 37
0
        public static int GetInterval(IntervalType intervalType, int interval)
        {
            int result = 0;
            switch (intervalType)
            {
                case IntervalType.Days:
                    result = interval * 24 * 60 * 60 * 1000;
                    break;
                case IntervalType.Hours:
                    result = interval * 60 * 60 * 1000;
                    break;
                case IntervalType.Minutes:
                    result = interval * 60 * 1000;
                    break;
                case IntervalType.Seconds:
                    result = interval * 1000;
                    break;
                case IntervalType.Milliseconds:
                    result = interval;
                    break;
            }

            return result;
        }
Exemplo n.º 38
0
        public async Task<IEnumerable<MeteoGtzData>> GetMeteoGtz(
            CalculateRequest calculateRequest,
            IntervalType intervalType = IntervalType.M36)
        {
            var startDate = calculateRequest.Stichtag.GetPastDate((int)intervalType);
            var endDate = calculateRequest.Stichtag.GetLastDayOfMonth();

            IEnumerable<MeteoGtzData> meteoGtzDatas = null;

            switch (calculateRequest.RequestType)
            {
                case RequestType.Plz:
                    meteoGtzDatas = await  this.GetGtzByPlz(calculateRequest.Value, startDate, endDate);
                    break;
                case RequestType.Bundesland:
                    meteoGtzDatas = await this.GetGtzByBundesland(calculateRequest.Value, startDate, endDate);
                    break;
                case RequestType.Deutschland:
                    meteoGtzDatas = await this.GetGtzDeutschland(startDate, endDate);
                    break;
            }
            return meteoGtzDatas;
        }
Exemplo n.º 39
0
        public async Task<double?> GetJahrBedarfWithPromille(
            CalculateRequest calculateRequest,
            bool isHeizperiode,
            IntervalType intervalType = IntervalType.M36)
        {
            var source = await this.GetGtzByPeriods(calculateRequest, intervalType);

            source = isHeizperiode ? source.Where(p => p.Monat.IsHeizMonat()) : source;

            var sum = source.Aggregate<MeteoGtzPeriod, double?>(
                0.0,
                (current, item) => current + item.Period1 / item.Period2 * item.Promille);

            var result = (sum / 97 - 1) * 100;

            return result;
        }
Exemplo n.º 40
0
        private static void TimerTickHandler(object sender, EventArgs e)
        {
            if (_isInAdjustMode)
            {
                _display.Clear();

                DrawIntervalType();

                if (_shouldDrawTime)
                {
                    switch (_currentIntervalType)
                    {
                        case IntervalType.LongInterval:
                            DrawSeconds(LongIntervalTime);
                            break;
                        case IntervalType.MediumInterval:
                            DrawSeconds(MediumIntervalTime);
                            break;
                        case IntervalType.ShortInterval:
                            DrawSeconds(ShortIntervalTime);
                            break;
                    }
                }
                _shouldDrawTime = !_shouldDrawTime;

                _display.Flush();
            }
            else
            {
                _secondsLeft--;
                DrawTimerDisplay(_secondsLeft);

                if (_secondsLeft <= 0)
                {
                    _currentIntervalType = (IntervalType)((int)(_currentIntervalType + 1) % 3);

                    switch (_currentIntervalType)
                    {
                        case IntervalType.LongInterval:
                            _secondsLeft = LongIntervalTime;
                            break;
                        case IntervalType.MediumInterval:
                            _secondsLeft = MediumIntervalTime;
                            break;
                        case IntervalType.ShortInterval:
                            _secondsLeft = ShortIntervalTime;
                            break;
                    }
                }
            }
        }
Exemplo n.º 41
0
        public static List<Zeitraum> GetZeitraume(
            DateTime stichTag,
            IntervalType intervalType = IntervalType.M24)
        {
            var datumVon1 = stichTag.GetPastDate(12);
            var datumBis1 = stichTag;
            var datumVon2 = datumVon1.AddYears(-1);
            var datumBis2 = datumBis1.AddYears(-1);
            var datumVon3 = datumVon1.AddYears(-2);
            var datumBis3 = datumBis1.AddYears(-2);

            var result = new List<Zeitraum>
            {
                new Zeitraum
                {
                    Name = "Aktuelles Jahr",
                    Start = datumVon1,
                    End = datumBis1
                },
                new Zeitraum
                {
                    Name = "Vorjahr",
                    Start = datumVon2,
                    End = datumBis2
                }
            };

            if (intervalType == IntervalType.M36)
            {
                result.Add(new Zeitraum { Name = "Vorvorjahr", Start = datumVon3, End = datumBis3 });
            }

            return result;
        }
Exemplo n.º 42
0
		public void InsertEmptyPoints (double interval, IntervalType intervalType, double intervalOffset, IntervalType intervalOffsetType, string seriesName)
		{
			throw new NotImplementedException ();
		}
 private void MakeChartWithProdus(Produs produs, DateTime beginDate, DateTime endDate, IntervalType interval = IntervalType.Zilnic)
 {
     string comparer = "";
     switch (interval)
     {
         case IntervalType.Zilnic:
             comparer = "dd/MM/yyyy";
             break;
         case IntervalType.Lunar:
             comparer = "MM/yyyy";
             break;
     }
     chartVanzari.Series.Clear();
     var vanzariPeProdus = new List<VanzareProdus>();
     while (beginDate.Date <= endDate.Date)
     {
         var result = from poz in PozitieFacturaIesire.GetAll()
                      where poz.FacturaIesireObject.Data.ToString(comparer) == beginDate.Date.ToString(comparer) && poz.StocObject.IdProdus == produs.ID
                      group poz by poz.FacturaIesireObject.Data.ToString(comparer) into poz_nou
                      select new VanzareProdus
                      {
                          Cantitate = poz_nou.Sum(p => p.Cantitate).ToString("0.00"),
                          DataVanzarii = beginDate.Date.ToString(comparer)
                      };
         VanzareProdus vanzare = null;
         vanzare = result.FirstOrDefault() == null ? new VanzareProdus { Cantitate = "0", DataVanzarii = beginDate.Date.ToString(comparer) } : result.FirstOrDefault();
         vanzariPeProdus.Add(vanzare);
         switch (interval)
         {
             case IntervalType.Zilnic:
                 beginDate = beginDate.AddDays(1);
                 break;
             case IntervalType.Lunar:
                 beginDate = beginDate.AddMonths(1);
                 break;
         }
     }
     var series = new Series(produs.Nume);
     series.XValueMember = "DataVanzarii";
     series.XValueType = ChartValueType.Date;
     series.YValueMembers = "Cantitate";
     series.YValueType = ChartValueType.String;
     chartVanzari.DataSource = vanzariPeProdus.ToList();
     chartVanzari.Series.Add(series);
 }
Exemplo n.º 44
0
 private static void EnterTimerMode()
 {
     _isInAdjustMode = false;
     StopTimer();
     SetTimerModeButtons();
     _currentIntervalType = IntervalType.LongInterval;
     _secondsLeft = LongIntervalTime;
     _clock.ChangePeriod(1000);
     DrawTimerDisplay(_secondsLeft);
 }
Exemplo n.º 45
0
        public async Task<MeteoGtzYear> GetYearsDataRelativeToCurrentYear(
            CalculateRequest calculateRequest,
            bool isHeizperiode,
            IntervalType intervalType = IntervalType.M36)
        {
            var meteoGtzSumYears = await this.GetGtzYearsSum(calculateRequest, isHeizperiode, intervalType);
            var result = meteoGtzSumYears.ToRelativeData();

            return result;
        }
Exemplo n.º 46
0
        public async Task<IEnumerable<MeteoGtzPeriodRelative>> GetRelativeVerteilung(
            CalculateRequest calculateRequest,
            bool isHeizperiode,
            IntervalType intervalType = IntervalType.M36)
        {
            var source = await this.GetGtzByPeriods(calculateRequest, intervalType);
            source = isHeizperiode ? source.Where(p => p.Monat.IsHeizMonat()) : source;

            var meteoGtzPeriods = source.ToList();

            double sumLgtz = meteoGtzPeriods.Sum(p => p.Lgtz);

            var result = meteoGtzPeriods.Select(
                p => new MeteoGtzPeriodRelative
                {
                    Monat = p.Monat,
                    Promille = p.Promille,
                    Period1 = (p.Lgtz - p.Period1) / sumLgtz * 100,
                    Period2 = (p.Lgtz - p.Period2) / sumLgtz * 100,
                });

            return result;
        }
Exemplo n.º 47
0
        public async Task<IEnumerable<KlimaTemperaturPeriod>> GetTemperaturMohtsDrill(CalculateRequest calculateRequest, int selectedMonth, 
            IntervalType intervalType = IntervalType.M24)
        {
            var temperaturGrouperByPeriods = await GetTemperaturGroupedByPeriods(calculateRequest);

            var stichTag = calculateRequest.Stichtag;
            int month1 = 0, month3 = 0;
            var month2 = selectedMonth;

            var startMonth = stichTag.Month;
            int endMonth = stichTag.GetPastDate((int)intervalType).Month;

            if (selectedMonth != startMonth)
            {
                month3 = selectedMonth == 12 ? 1 : selectedMonth + 1;
            }
            if (selectedMonth != endMonth)
            {
                month1 = selectedMonth == 1 ? 12 : selectedMonth - 1;
            }

            var result =
                 temperaturGrouperByPeriods.Where(
                    p => p.Datum.Month == month1 || p.Datum.Month == month2 || p.Datum.Month == month3);
         
            return result;
        }
Exemplo n.º 48
0
        void DrawChart(DataTable data, DateTime from, DateTime to, IntervalType interval, ValueRepresentation representation)
        {
            List<Interval> _intervals = new List<Interval>();

            if (interval == IntervalType.Day || interval == IntervalType.Week)
            {
                // Day by day or week by week
                for (int i = 0; i < (to.Subtract(from).TotalDays / (int)interval); i++)
                {
                    //Response.Write(i + 1);
                    //Response.Write(":   ");
                    //Response.Write((i * (int)interval) + 1);
                    //Response.Write(" - ");
                    //Response.Write((i * (int)interval) + 1 + 7);
                    //Response.Write("   |   ");
                    //Response.Write(from.AddDays((i * (int)interval) + 1 - 1));
                    //Response.Write(" - ");
                    //Response.Write(from.AddDays((i * (int)interval) + 1 - 1));
                    //Response.Write("<br>");

                    _intervals.Add(new Interval(from.AddDays((i * (int)interval) + 1 - 1), from.AddDays((i * (int)interval) + (int)interval + 1 - 1)));

                }
            }
            if (interval == IntervalType.Month)
            {
                for (int i = 0; i < to.Month - from.Month + ((to.Year - from.Year) * 12) + 1; i++)
                {
                    //Response.Write(i + 1);
                    //Response.Write(":   ");
                    //Response.Write(new DateTime(from.Year, from.Month, 1).AddMonths(i));
                    //Response.Write(" - ");
                    //Response.Write(new DateTime(from.Year, from.Month, 1).AddMonths(i+1).AddDays(-1));
                    //Response.Write("<br>");

                    _intervals.Add(new Interval(new DateTime(from.Year, from.Month, 1).AddMonths(i), new DateTime(from.Year, from.Month, 1).AddMonths(i + 1).AddDays(-1)));
                }
            }
            //List<>

            // Draw chart here item by item in _intervals

            WebChartControl chart = new WebChartControl();
            chart.EnableViewState = false;
            ChartTitle title = new ChartTitle();
            title.Text = "pokus";
            title.Font = new System.Drawing.Font("Tahoma", 10);
            chart.Titles.Add(title);
            chart.FillStyle.FillMode = FillMode.Solid;
            Dictionary<int, Series> series = new Dictionary<int, Series>();

            //foreach (int channelId in channels)
            //{
            //    Channel channel = db.Channels.Where(c => c.ChannelId == channelId).FirstOrDefault();
            //    if (channel == null) continue;
            //    Series s = new Series(channel.ChannelName, ViewType.Line);
            //    s.ValueScaleType = ScaleType.Numerical;
            //    s.ArgumentScaleType = ScaleType.DateTime;
            //    series.Add(channelId, s);
            //}

            using (SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["CanonConnectionStringMain"].ConnectionString))
            {
                conn.Open();

                List<string> seriesNames = new List<string>();

                int k = 0;
                // Create series
                using (SqlCommand cmd = new SqlCommand())
                {
                    cmd.Connection = conn;
                    cmd.CommandText = string.Format("SELECT DISTINCT {0} FROM PivotTable WHERE DateSale >= @Start AND DateSale < @End", ddlYGroupBy.SelectedValue);
                    cmd.Parameters.Add(new SqlParameter("@Start", SqlDbType.DateTime) { Value = _intervals[0].Start });
                    cmd.Parameters.Add(new SqlParameter("@End", SqlDbType.DateTime) { Value = _intervals[_intervals.Count - 1].End });

                    SqlDataReader reader = cmd.ExecuteReader();
                    while (reader.Read())
                    {
                        Series s = new Series(reader[0].ToString(), ViewType.Line);
                        s.ValueScaleType = ScaleType.Numerical;
                        s.ArgumentScaleType = ScaleType.DateTime;
                        seriesNames.Add(reader[0].ToString());
                        series.Add(k, s);
                        k++;
                    }
                    reader.Close();
                }

                // Draw series
                foreach (Interval i in _intervals)
                {
                    for (int j = 0; j < seriesNames.Count; j++ )
                    {
                        using (SqlCommand command = GenerateReportCommand(i.Start, i.End, seriesNames[j]))
                        {
                            command.Connection = conn;
                            SqlDataReader dr = command.ExecuteReader();

                            while (dr.Read())
                            {
                                // Here it comes
                                //Response.Write(dr[0]);
                                //Response.Write(" - ");
                                //Response.Write(dr[1]);
                                //Response.Write("<br>");
                                if (dr[0] is DBNull)
                                {
                                    series[j].Points.Add(new SeriesPoint(i.Start, new double[] { 0 }));
                                }
                                else
                                {
                                    series[j].Points.Add(new SeriesPoint(i.Start, new double[] { Convert.ToDouble(dr[0]) }));
                                }
                            }
                            dr.Close();
                        }
                    }
                }
            }

            foreach (KeyValuePair<int, Series> serie in series)
                chart.Series.Add(serie.Value);
            //diagram
            DevExpress.XtraCharts.XYDiagram xyDiagram = new XYDiagram();
            xyDiagram.AxisY.Title.Font = new System.Drawing.Font("Tahoma", 8);
            xyDiagram.AxisY.Title.Text = "CZK";
            xyDiagram.AxisY.Label.Staggered = false;
            xyDiagram.AxisY.Title.Visible = true;
            xyDiagram.AxisY.Range.SideMarginsEnabled = true;
            xyDiagram.AxisY.Interlaced = true;

            xyDiagram.AxisX.Title.Font = new System.Drawing.Font("Tahoma", 8);
            xyDiagram.AxisX.Label.Staggered = true;
            xyDiagram.AxisX.Range.SideMarginsEnabled = true;
            xyDiagram.AxisX.Tickmarks.MinorVisible = false;

            xyDiagram.AxisX.Range.MinValue = from;
            xyDiagram.AxisX.Range.MaxValue = to;

            switch (interval)
            {
                case IntervalType.Day:
                    xyDiagram.AxisX.DateTimeMeasureUnit = DateTimeMeasurementUnit.Day;
                    break;
                case IntervalType.Week:
                    xyDiagram.AxisX.DateTimeMeasureUnit = DateTimeMeasurementUnit.Day;
                    xyDiagram.AxisX.GridSpacingAuto = false;
                    xyDiagram.AxisX.GridSpacing = 7;
                    break;
                case IntervalType.Month:
                    xyDiagram.AxisX.DateTimeMeasureUnit = DateTimeMeasurementUnit.Month;
                    break;
            }

            //xyDiagram.AxisX.DateTimeMeasureUnit = DateTimeMeasurementUnit.Month;
            xyDiagram.EnableZooming = true;

            chart.Diagram = xyDiagram;
            chart.Width = 800;
            chart.Height = 500;
            chart.DataBind();
            pnlGraph.Controls.Add(chart);
        }
Exemplo n.º 49
0
            public Interval Interval(IntervalType type, object start, object end)
            {
                Interval i;

                switch (type)
                {
                   case IntervalType.ROW:
                  i.Start = (int)start;
                  i.End = (int)end;
                  break;
                   case IntervalType.DATETIME:
                  i.Start = Index((DateTime)start, SearchType.FIND_EXACTLY_OR_NEXT);
                  i.End = Index((DateTime)end, SearchType.FIND_EXACTLY_OR_PRIOR);
                  break;
                   case IntervalType.RELATIVE:
                  i.Start = Index((double)start, SearchType.FIND_EXACTLY_OR_NEXT);
                  i.End = Index((double)end, SearchType.FIND_EXACTLY_OR_PRIOR);
                  break;
                   default:
                  throw new Exception("Invalid Interval Type.");
                }

                return i;
            }
Exemplo n.º 50
0
		public void Group (string formula, double interval, IntervalType intervalType, string inputSeriesName, string outputSeriesName)
		{
			throw new NotImplementedException ();
		}
Exemplo n.º 51
0
		public void Group (string formula, double interval, IntervalType intervalType, double intervalOffset, IntervalType intervalOffsetType, Series inputSeries, Series outputSeries)
		{
			throw new NotImplementedException ();
		}
Exemplo n.º 52
0
		public void InsertEmptyPoints (double interval, IntervalType intervalType, double intervalOffset, IntervalType intervalOffsetType, double fromXValue, double toXValue, Series series)
		{
			throw new NotImplementedException ();
		}
Exemplo n.º 53
0
        public async Task<MeteoGtzYear> GetGtzYearsSum(
            CalculateRequest calculateRequest,
            bool isHeizperiode,
            IntervalType intervalType = IntervalType.M36)
        {
            var source = await this.GetGtzByPeriods(calculateRequest, intervalType);
            source = isHeizperiode ? source.Where(p => p.Monat.IsHeizMonat()) : source;

            var meteoGtzPeriods = source.ToList();

            if (meteoGtzPeriods.Count == 0)
            {
                return null;
            }

            var result = new MeteoGtzYear
            {
                //IsHeizperiode = isHeizperiode,
                Period1 = meteoGtzPeriods.Sum(p => p.Period1),
                Period2 = meteoGtzPeriods.Sum(p => p.Period2),
                Period3 = meteoGtzPeriods.Sum(p => p.Period3),
                Lgtz = meteoGtzPeriods.Sum(p => p.Lgtz)
            };
            return result;
        }
Exemplo n.º 54
0
        public static Tnum IntervalsUntil(Tdate startDate, Tdate endDate, IntervalType interval, int startAt)
        {
            // Handle unknowns
            Hstate top = PrecedingState(startDate.FirstValue, endDate.FirstValue);
            if (top != Hstate.Known) return new Tnum(new Hval(null,top));

            DateTime start = startDate.ToDateTime;
            DateTime end = endDate.ToDateTime;

            Tnum result = new Tnum();

            DateTime indexDate = end;
            int indexNumber = startAt-1;

            while (indexDate > start)
            {
                if (indexNumber != startAt-1)
                {
                    result.AddState(indexDate,Convert.ToString(indexNumber));
                }
                indexNumber++;
                indexDate = indexDate.SubtractInterval(interval);
            }

            result.AddState(Time.DawnOf, 0);
            result.AddState(start,Convert.ToString(indexNumber));
            result.AddState(end, 0);

            return result;
        }
Exemplo n.º 55
0
        //*********************************************************************
        // TEMPORAL "RECURRENCE" FUNCTIONS
        //*********************************************************************
        /// <summary>
        /// Loops (cycles) through numbers over time (e.g. 1 2 3 4 1 2 3 4 ...)
        /// </summary>
        public static Tnum Recurrence(Tdate startDate, Tdate endDate, IntervalType interval, int min, int max)
        {
            // Handle unknowns
            Hstate top = PrecedingState(startDate.FirstValue, endDate.FirstValue);
            if (top != Hstate.Known) return new Tnum(new Hval(null,top));

            DateTime start = startDate.ToDateTime;
            DateTime end = endDate.ToDateTime;

            Tnum result = new Tnum();

            if (start != Time.DawnOf)
            {
                result.AddState(Time.DawnOf, 0);
            }

            DateTime indexDate = start;
            int indexNumber = min;

            while (indexDate < end)
            {
                result.AddState(indexDate,Convert.ToString(indexNumber));
                indexDate = indexDate.AddInterval(interval, 1);

                // Reset sequence
                indexNumber++;
                if (indexNumber > max)
                {
                    indexNumber = min;
                }
            }

            result.AddState(end, 0);
            return result;
        }
Exemplo n.º 56
0
 //*********************************************************************
 // TEMPORAL "STEP" FUNCTIONS
 //*********************************************************************
 /// <summary>
 /// Returns the number of intervals since a given date (step up function)
 /// (e.g. 1 2 3 4 5 6 7 8 9 ...)
 /// </summary>
 public static Tnum IntervalsSince(Tdate start, Tdate end, IntervalType interval)
 {
     return IntervalsSince(start, end, interval, 0);
 }
Exemplo n.º 57
0
        private static void EnterAdjustMode(uint data1, uint data2, DateTime time)
        {
            _isInAdjustMode = true;
            _clock.Stop();
            SetAdjustModeButtons();

            _currentIntervalType = IntervalType.LongInterval;

            _clock.ChangePeriod(250);
            _clock.Start(0);
        }
Exemplo n.º 58
0
 public async Task<IEnumerable<KlimaTemperaturPeriod>> GetTemperaturGroupedByPeriods(CalculateRequest calculateRequest, IntervalType intervalType = IntervalType.M24)
 {
     var temperaturs = await GetTemperatur(calculateRequest);
     var result = this.GroupTemperaturByPeriods(temperaturs, calculateRequest.Stichtag);
     return result;
 }
Exemplo n.º 59
0
        void DrawChart(DataTable data, DateTime from, DateTime to, IntervalType interval, ValueRepresentation representation, bool ajax)
        {
            List<Interval> _intervals = new List<Interval>();

                if (interval == IntervalType.Day || interval == IntervalType.Week)
                {
                    // Day by day or week by week
                    for (int i = 0; i < (to.Subtract(from).TotalDays / (int)interval); i++)
                    {
                        _intervals.Add(new Interval(from.AddDays((i * (int)interval) + 1 - 1), from.AddDays((i * (int)interval) + (int)interval + 1 - 1)));

                    }
                }
                if (interval == IntervalType.Month)
                {
                    for (int i = 0; i < to.Month - from.Month + ((to.Year - from.Year) * 12) + 1; i++)
                    {
                        _intervals.Add(new Interval(new DateTime(from.Year, from.Month, 1).AddMonths(i), new DateTime(from.Year, from.Month, 1).AddMonths(i + 1).AddDays(-1)));
                    }
                }

                if (interval == IntervalType.Year)
                {
                    for (int i = 0; i < to.Year - from.Year + 1; i++)
                    {
                        _intervals.Add(new Interval(new DateTime(from.Year, from.Month, 1).AddYears(i), new DateTime(from.Year, from.Month, 1).AddYears(i + 1).AddDays(-1)));
                    }
                }
            //foreach (Interval ii in _intervals)
            //{
            //    Response.Write(ii.Start);
            //    Response.Write(" - ");
            //    Response.Write(ii.End);
            //    Response.Write("<br>");
            //}

            // Draw chart here item by item in _intervals

            WebChartControl chart = new WebChartControl();

            if (!ajax)
            {
                chart.EnableViewState = false;
                ChartTitle title = new ChartTitle();
                title.Text = "Graf dle " + ddlYGroupBy.SelectedItem.Text.ToLower() + ":";
                title.Font = new System.Drawing.Font("Tahoma", 10);
                chart.Titles.Add(title);
                chart.FillStyle.FillMode = FillMode.Solid;
            }
            Dictionary<int, Series> series = new Dictionary<int, Series>();

            List<bool> seriesVisibilities = new List<bool>();
            using (SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["CanonConnectionStringMain"].ConnectionString))
            {
                conn.Open();

                List<string> seriesNames = new List<string>();
                List<string> seriesCriteria = new List<string>();

                int k = 0;
                Culture = "cs-CZ";
                // Create series
                using (SqlCommand cmd = new SqlCommand())
                {
                    cmd.Connection = conn;

                    StringBuilder text = new StringBuilder("");

            #warning extract to function
                    if (ddlYFilterType.SelectedIndex > 0)
                    {
                        if (_filerYValues.Count > 0)
                        {
                            text.Append(" AND (");
                            // Y Filter
                            int i = 0;
                            foreach (string s in _filerYValues)
                            {
                                text.Append(ddlYFilterType.SelectedValue);
                                text.Append(" = '");
                                text.Append(s);
                                text.Append("' ");
                                if (i < _filerYValues.Count - 1)
                                {
                                    text.Append("OR ");
                                }
                                i++;
                            }
                            text.Append(") ");
                        }
                    }
                    string top = "";
                    if (chbTop.Checked)
                    {
                        int tp = Convert.ToInt32(txtTop.Text);
                        if (!ajax)
                        {
                            tp += 1;
                        }
                        top = "TOP " + tp;
                    }

                    cmd.CommandText = string.Format("SELECT {2} {0}, {0} AS Value FROM PivotTable WHERE DateSale >= @Start AND DateSale < @End {1} GROUP BY {0} ORDER BY Sum(CAST(replace(TurnoverEUR, ',', '.') as Decimal)) DESC", ddlYGroupBy.SelectedValue, text, top);

                    cmd.Parameters.Add(new SqlParameter("@Start", SqlDbType.DateTime) { Value = _intervals[0].Start });
                    cmd.Parameters.Add(new SqlParameter("@End", SqlDbType.DateTime) { Value = _intervals[_intervals.Count - 1].End });

                    SqlDataReader reader = cmd.ExecuteReader();
                    while (reader.Read())
                    {
                        if (ddlYGroupBy.SelectedValue == "ReselerGroupJoined")
                        {
                            seriesNames.Add(reader[1].ToString().Trim() == "" ? "NO-NAME" : reader[1].ToString());
                        }
                        else
                        {
                            seriesNames.Add(reader[1].ToString().Trim() == "" ? "(neuvedeno)" : reader[1].ToString());
                        }

                        if (!ajax)
                        {
                            Series s;
                            if (rblValueDisplayMode.SelectedValue == "2" || ddlXValueType.SelectedValue == "Data")
                            {
                                s = new Series(reader[1].ToString(), ViewType.StackedBar);
                            }
                            else
                            {
                                s = new Series(reader[1].ToString(), ViewType.Line);
                            }
                            s.ValueScaleType = ScaleType.Numerical;
                            if (ddlXValueType.SelectedValue == "Time")
                            {
                                s.ArgumentScaleType = ScaleType.DateTime;
                            }
                            if (ddlXValueType.SelectedValue == "Data")
                            {
                                s.ArgumentScaleType = ScaleType.Qualitative;
                            }

                            if (ddlYValueType.SelectedValue == "4")
                            {
                                if (rblValueDisplayMode.SelectedValue != "2")
                                {
                                    s.PointOptions.ValueNumericOptions.Format = NumericFormat.Currency;
                                }
                                if (rblValueDisplayMode.SelectedValue == "2")
                                {
                                    s.PointOptions.ValueNumericOptions.Format = NumericFormat.Percent;
                                }
                            }
                            //s.PointOptions.ValueNumericOptions.Format = NumericFormat.Currency;
                            seriesCriteria.Add(reader[0].ToString());
                            seriesVisibilities.Add(false);
                            series.Add(k, s);
                            k++;
                        }
                    }
                    reader.Close();
                }

                // Draw series
                // By Time

                // Enumerate series here and send them via ajax
                if (ajax)
                {
                    lbYHaving.Items.Clear();
                    lbYHaving.Items.Add(allValues);
                    foreach (string s in seriesNames)
                    {
                        lbYHaving.Items.Add(s);
                    }
                    DataBind(lbYHaving);

                    return;
                }

                if (ddlXValueType.SelectedValue == "Time")
                {
                    foreach (Interval i in _intervals)
                    {
                        for (int j = 0; j < seriesNames.Count; j++)
                        {
                            using (SqlCommand command = GenerateReportCommand(i.Start, i.End, seriesCriteria[j]))
                            {
                                command.Connection = conn;
                                SqlDataReader dr = command.ExecuteReader();

                                while (dr.Read())
                                {
                                    // Here it comes
                                    if (dr[0] is DBNull)
                                    {
                                        series[j].Points.Add(new SeriesPoint(i.Start, new double[] { 0 }));
                                    }
                                    else
                                    {
                                        series[j].Points.Add(new SeriesPoint(i.Start, new double[] { Convert.ToDouble(dr[0]) }));
                                        seriesVisibilities[j] = true;
                                    }
                                }
                                dr.Close();
                            }
                        }
                    }
                }
                if (ddlXValueType.SelectedValue == "Data")
                {
                    using (SqlCommand command_data = new SqlCommand())
                    {
                        command_data.Connection = conn;
                        command_data.CommandText = "SELECT DISTINCT " + ddlXGroupByData.SelectedValue + " FROM PivotTable WHERE DateSale >= @Start AND DateSale < @End";
                        command_data.Parameters.Add(new SqlParameter("@Start", SqlDbType.DateTime) { Value = _intervals[0].Start });
                        command_data.Parameters.Add(new SqlParameter("@End", SqlDbType.DateTime) { Value = _intervals[_intervals.Count - 1].End });

                        SqlDataReader reader = command_data.ExecuteReader();
                        List<string> xData = new List<string>();

                        while (reader.Read())
                        {
                            xData.Add(reader[0].ToString());
                        }
                        reader.Close();

                        foreach(string xd in xData)
                        {
                            for (int j = 0; j < seriesNames.Count; j++)
                            {
                                using (SqlCommand command = GenerateReportCommandByData(xd, seriesCriteria[j]))
                                {
                                    command.Connection = conn;
                                    SqlDataReader dr = command.ExecuteReader();

                                    while (dr.Read())
                                    {
                                        // Here it comes
                                        if (dr[0] is DBNull)
                                        {
                                            series[j].Points.Add(new SeriesPoint(xd, new double[] { 0 }));
                                        }
                                        else
                                        {
                                            series[j].Points.Add(new SeriesPoint(xd, new double[] { Convert.ToDouble(dr[0]) }));
                                            seriesVisibilities[j] = true;
                                        }
                                    }
                                    dr.Close();
                                }
                            }
                        }
                    }
                }
            }

            int l = 0;
            object yHaving = Request[lbYHaving.ClientID.Replace('_', '$')];

            if (yHaving == null)
            {
                yHaving = allValues;
            }

            lbYHaving.Items.Clear();

            if (yHaving.ToString() != allValues)
            {
                {
                    for (int i = 0; i < series.Count; i++)
                    {
                        if (seriesVisibilities[i])
                        {
                            lbYHaving.Items.Add(series[i].Name);
                            foreach (string s in yHaving.ToString().Split(','))
                            {
                                if (s == series[i].Name)
                                {
                                    lbYHaving.Items[l].Selected = true;
                                    seriesVisibilities[i] = true;
                                    break;
                                }
                                else
                                {
                                    seriesVisibilities[i] = false;
                                }
                            }
                            l++;
                        }
                    }
                }
            }
            else
            {
                for (int i = 0; i < series.Count; i++)
                {
                    if (seriesVisibilities[i] && yHaving.ToString() != allValues)
                    {
                        lbYHaving.Items.Add(series[i].Name);
                    }
                }
            }

            lbYHaving.Items.Insert(0, allValues);
            if (yHaving.ToString() == allValues)
            {
                lbYHaving.Items[0].Selected = true;
            }

            // Other
            for (int i = 0; i < series.Count; i++)
            {
                if (seriesVisibilities[i])
                {

                    if (seriesVisibilities[i] && yHaving.ToString() == allValues)
                    {
                        lbYHaving.Items.Add(series[i].Name);
                    }
                    chart.Series.Add(series[i]);
                }
            }

            #region Compute sum

            Series suma = new Series("Suma", ViewType.Line);
            suma.ValueScaleType = ScaleType.Numerical;
            suma.ArgumentScaleType = ScaleType.DateTime;
            if (ddlYValueType.SelectedValue == "4")
            {
                if (rblValueDisplayMode.SelectedValue != "2")
                {
                    suma.PointOptions.ValueNumericOptions.Format = NumericFormat.Currency;
                }
                if (rblValueDisplayMode.SelectedValue == "2")
                {
                    suma.PointOptions.ValueNumericOptions.Format = NumericFormat.Percent;
                }
            }

            DataTable grid = new DataTable();
            string xArgumentName = ddlXValueType.SelectedItem.Text + " - dle ";

            if (ddlXValueType.SelectedValue == "Time")
            {
                xArgumentName += ddlXGroupByTime.SelectedItem.Text.ToLower();
            }
            else
            {
                xArgumentName += ddlXGroupByData.SelectedItem.Text.ToLower();
            }

            grid.Columns.Add(new DataColumn(xArgumentName));
            for (int i = 0; i < chart.Series.Count; i++)
            {
                grid.Columns.Add(new DataColumn(chart.Series[i].Name));
            }

            double sum;
            for (int j = 0; j < chart.Series[0].Points.Count; j++)
            {
                sum = 0;
                DataRow dr = grid.NewRow();
                if (ddlXValueType.SelectedValue == "Time")
                {
                    dr[0] = Convert.ToDateTime(chart.Series[0].Points[j].Argument).ToString("dd.MM.yyyy");
                }
                else
                {
                    dr[0] = chart.Series[0].Points[j].Argument;
                }
                for (int i = 0; i < chart.Series.Count; i++)
                {
                    dr[i+1] = chart.Series[i].Points[j].Values[0];
                    sum += chart.Series[i].Points[j].Values[0];
                }
                grid.Rows.Add(dr);
                suma.Points.Add(new SeriesPoint(chart.Series[0].Points[j].Argument, new double[] { sum }));

                // Percent
                if (rblValueDisplayMode.SelectedValue == "2")
                {
                    for (int i = 0; i < chart.Series.Count; i++)
                    {
                        if (sum == 0)
                        {
                            chart.Series[i].Points[j].Values[0] = 0;
                        }
                        else
                        {
                            chart.Series[i].Points[j].Values[0] = Math.Round(((chart.Series[i].Points[j].Values[0] / sum) * 1), 2);
                        }
                    }
                }

                if (rblValueDisplayMode.SelectedValue == "3")
                {
                    if (j > 0)
                    {
                        for (int i = 0; i < chart.Series.Count; i++)
                        {
                            chart.Series[i].Points[j].Values[0] = chart.Series[i].Points[j].Values[0] - chart.Series[i].Points[j - 1].Values[0];
                        }
                    }
                    else
                    {
                        for (int i = 0; i < chart.Series.Count; i++)
                        {
                            chart.Series[i].Points[j].Values[0] = 0;
                        }
                    }

                }
            }
            suma.View.Color = System.Drawing.Color.Black;
            series.Add(series.Count, suma);
            if (rblValueDisplayMode.SelectedValue == "1")
            {
                chart.Series.Add(series[series.Count - 1]);
            }

            if (chbShowSum.Checked && rblValueDisplayMode.SelectedValue == "1" && ddlXValueType.SelectedValue == "Time")
            {
                int toBeRemoved = chart.Series.Count - 1;
                for (int j = 0; j < toBeRemoved; j++)
                {
                    chart.Series.RemoveAt(0);
                }
            }

            // Show grid

            DataRow drSum = grid.NewRow();
            for(int i = 1; i < grid.Columns.Count; i++)
            {
                double dSum = 0;
                for (int j = 0; j < grid.Rows.Count; j++)
                {
                    dSum += Convert.ToDouble(grid.Rows[j][i]);
                }
                drSum[i] = dSum;
            }
            grid.Columns.Add(new DataColumn("Součet za svislou osu"));
            for (int i = 0; i < grid.Rows.Count; i++)
            {
                double dSum = 0;
                for (int j = 1; j < grid.Columns.Count - 1; j++)
                {
                    dSum += Convert.ToDouble(grid.Rows[i][j] == null ? "0" : grid.Rows[i][j]);
                }
                if (rblValueDisplayMode.SelectedValue == "2")
                {
                    for (int j = 1; j < grid.Columns.Count - 1; j++)
                    {
                        if (dSum == 0)
                        {
                            grid.Rows[i][j] = "0";
                        }
                        else
                        {
                            grid.Rows[i][j] = (Math.Round(Convert.ToDouble(grid.Rows[i][j] == null ? "0" : grid.Rows[i][j]) / dSum, 4) * 100).ToString() + " %";
                        }
                    }
                }
                grid.Rows[i][grid.Columns[grid.Columns.Count-1]] = dSum;
            }
            grid.Rows.Add(drSum);
            grid.Rows[grid.Rows.Count - 1][0] = "Součet za vodorovnou osu";
            gvGrid.DataSource = grid;
            gvGrid.DataBind();

            #endregion

            #region Customize chart

            DevExpress.XtraCharts.XYDiagram xyDiagram = new XYDiagram();

            if (ddlYValueType.SelectedIndex == 0)
            {
                xyDiagram.AxisY.Title.Text = "EUR";
            }
            if (ddlYValueType.SelectedIndex == 1)
            {
                xyDiagram.AxisY.Title.Text = "Kusů";
            }

            xyDiagram.AxisY.Title.Font = new System.Drawing.Font("Tahoma", 8);
            xyDiagram.AxisY.Label.Staggered = false;
            xyDiagram.AxisY.Title.Visible = true;
            xyDiagram.AxisY.Range.SideMarginsEnabled = true;
            xyDiagram.AxisY.Interlaced = true;

            xyDiagram.AxisX.Title.Font = new System.Drawing.Font("Tahoma", 8);
            xyDiagram.AxisX.Label.Staggered = true;
            xyDiagram.AxisX.Range.SideMarginsEnabled = true;
            xyDiagram.AxisX.Tickmarks.MinorVisible = false;

            xyDiagram.AxisX.Range.MinValue = from;
            xyDiagram.AxisX.Range.MaxValue = to;

            switch (interval)
            {
                case IntervalType.Day:
                    xyDiagram.AxisX.DateTimeMeasureUnit = DateTimeMeasurementUnit.Day;
                    break;
                case IntervalType.Week:
                    xyDiagram.AxisX.DateTimeMeasureUnit = DateTimeMeasurementUnit.Day;
                    xyDiagram.AxisX.GridSpacingAuto = false;
                    xyDiagram.AxisX.GridSpacing = 7;
                    break;
                case IntervalType.Month:
                    xyDiagram.AxisX.DateTimeMeasureUnit = DateTimeMeasurementUnit.Month;
                    break;
                case IntervalType.Year:
                    xyDiagram.AxisX.DateTimeMeasureUnit = DateTimeMeasurementUnit.Year;
                    break;
            }
            xyDiagram.EnableZooming = true;

            chart.Diagram = xyDiagram;
            chart.Width = Convert.ToInt32(txtScreenWidth.Text) - 50;
            chart.Height = 602;
            //chart.Height = Convert.ToInt32(txtScreenHeight.Text) - 230;

            #endregion

            chart.DataBind();
            pnlGraph.Controls.Add(chart);
        }
Exemplo n.º 60
0
		public void InsertEmptyPoints (double interval, IntervalType intervalType, Series series)
		{
			throw new NotImplementedException ();
		}