Example #1
0
        public void Should_convert_monthly_bandwidth_timestamp_to_string()
        {
            var converter = new MonthlyTimestampValueConverter();

            var monthlyBandwidthValue = new MonthlyValue(new MonthlyBandwidth(2011, 1, 0, 0));

            var result = (string)converter.Convert(monthlyBandwidthValue, typeof(MonthlyValue), null, CultureInfo.InvariantCulture);

            Assert.AreEqual("1/2011", result);
        }
Example #2
0
        public override void ReadXml(XmlReader reader)
        {
            if (!reader.ReadToDescendant("CronTabs"))
            {
                throw new XmlException("Could not find CronTabs element");
            }
            var selTabName = reader.GetAttribute("SelectedCronBuilder");

            CronTab.SelectedTab = CronTab.TabPages[selTabName];

            if (!reader.ReadToFollowing("Minutes"))
            {
                throw new XmlException("Could not find Minutes element");
            }
            MinutesValue.ReadXml(reader);

            if (!reader.ReadToFollowing("Hourly"))
            {
                throw new XmlException("Could not find Hourly element");
            }
            HourlyValue.ReadXml(reader);

            if (!reader.ReadToFollowing("Daily"))
            {
                throw new XmlException("Could not find Daily element");
            }
            DailyValue.ReadXml(reader);

            if (!reader.ReadToFollowing("Weekly"))
            {
                throw new XmlException("Could not find Weekly element");
            }
            WeeklyValue.ReadXml(reader);

            if (!reader.ReadToFollowing("Monthly"))
            {
                throw new XmlException("Could not find Monthly element");
            }
            MonthlyValue.ReadXml(reader);

            if (!reader.ReadToFollowing("Yearly"))
            {
                throw new XmlException("Could not find Yearly element");
            }
            YearlyValue.ReadXml(reader);
        }
Example #3
0
        public override void WriteXml(XmlWriter writer)
        {
            writer.WriteStartElement("CronTabs");
            writer.WriteAttributeString("SelectedCronBuilder", CronTab.SelectedTab.Name);

            {
                writer.WriteStartElement("Minutes");
                MinutesValue.WriteXml(writer);
                writer.WriteEndElement();
            }

            {
                writer.WriteStartElement("Hourly");
                HourlyValue.WriteXml(writer);
                writer.WriteEndElement();
            }

            {
                writer.WriteStartElement("Daily");
                DailyValue.WriteXml(writer);
                writer.WriteEndElement();
            }

            {
                writer.WriteStartElement("Weekly");
                WeeklyValue.WriteXml(writer);
                writer.WriteEndElement();
            }

            {
                writer.WriteStartElement("Monthly");
                MonthlyValue.WriteXml(writer);
                writer.WriteEndElement();
            }

            {
                writer.WriteStartElement("Yearly");
                YearlyValue.WriteXml(writer);
                writer.WriteEndElement();
            }

            writer.WriteEndElement();
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="ReportDownloadedEventArgs"/> class.
        /// </summary>
        /// <param name="report">
        /// The report.
        /// </param>
        /// <param name="timestamp">
        /// The timestamp.
        /// </param>
        /// <param name="exception">Exception.</param>
        public ReportDownloadedEventArgs(BandwidthReport report, DateTime timestamp, Exception exception)
        {
            this.monthly = new List<MonthlyValue>();
            this.daily = new List<DailyValue>();
            this.Timestamp = timestamp;

            if (null != exception)
            {
                this.Error = exception;
                return;
            }

            report.Monthly.Each((value) =>
                {
                    var monthlyValue = new MonthlyValue(value);
                    this.monthly.Add(monthlyValue);
                });

            report.Daily.Each((value) =>
            {
                var dailyValue = new DailyValue(value);
                this.daily.Add(dailyValue);
            });
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="ReportDownloadedEventArgs"/> class.
        /// </summary>
        /// <param name="report">
        /// The report.
        /// </param>
        /// <param name="timestamp">
        /// The timestamp.
        /// </param>
        /// <param name="exception">Exception.</param>
        public ReportDownloadedEventArgs(BandwidthReport report, DateTime timestamp, Exception exception)
        {
            this.monthly   = new List <MonthlyValue>();
            this.daily     = new List <DailyValue>();
            this.Timestamp = timestamp;

            if (null != exception)
            {
                this.Error = exception;
                return;
            }

            report.Monthly.Each((value) =>
            {
                var monthlyValue = new MonthlyValue(value);
                this.monthly.Add(monthlyValue);
            });

            report.Daily.Each((value) =>
            {
                var dailyValue = new DailyValue(value);
                this.daily.Add(dailyValue);
            });
        }
        public ActionResult LifetimeMonthly()
        {
            var v = context.Orders.Where(i => i.OrderDate.HasValue)
                    .GroupBy(i => i.OrderDate.Value.Month)
                    .Select(g => new
            {
                Month = g.FirstOrDefault().OrderDate.Value.Month,
                Total = g.Sum(i => i.TotalAmount)
            });

            List <MonthlyValue> va = new List <MonthlyValue>();



            foreach (var m in v)
            {
                MonthlyValue val = new MonthlyValue();
                val.month = m.Month;
                val.sales = (int)m.Total;
                va.Add(val);
            }

            return(View(va));
        }