Esempio n. 1
0
        public override void Load()
        {
            IDbManager              dbManager = ObjectPool.Instance.Resolve <IDbManager>();
            IDataCommand            db        = dbManager.GetDatabase(ApplicationSettings.Instance.Database.DefaultConnection.Name);
            List <InvoiceDataValue> result    = db.Query <InvoiceDataValue>("GetDashboardInvoiceMonth", new { Year = this.Year });

            Total = 0;
            Order = 0;
            MutableObservableCollection <SeriesData <InvoiceDataValue> > model = new MutableObservableCollection <SeriesData <InvoiceDataValue> >();
            InvoiceDataValue item;

            for (int i = 1; i <= 12; i++)
            {
                item = result.Where(x => x.Name == i.ToString()).SingleOrDefault();
                model.Add(new SeriesData <InvoiceDataValue>()
                {
                    SeriesDisplayName = DateTimeFormatInfo.CurrentInfo.GetMonthName(i)
                });

                if (item != null)
                {
                    model[i - 1].Items.Add(new InvoiceDataValue()
                    {
                        Name   = DateTimeFormatInfo.CurrentInfo.GetMonthName(i),
                        Number = item.Number
                    });

                    Total           += item.Number;
                    Order           += item.Order;
                    OrderInstallment = item.OrderInstallment;
                    TotalInstallment = item.TotalInstallment;
                }
                else
                {
                    model[i - 1].Items.Add(new InvoiceDataValue()
                    {
                        Name   = DateTimeFormatInfo.CurrentInfo.GetMonthName(i),
                        Number = 0
                    });
                }
            }
            this.Source = model;
            db.Close();
        }
        public override void Load()
        {
            IDbManager dbManager = ObjectPool.Instance.Resolve<IDbManager>();
            IDataCommand db = dbManager.GetDatabase(ApplicationSettings.Instance.Database.DefaultConnection.Name);
            List<DataValue> result = db.Query<DataValue>("GetDashboardRemainingPerMonth", new { Year = this.Year, Month = this.Month }); 

            MutableObservableCollection<SeriesData<DataValue>> model = new MutableObservableCollection<SeriesData<DataValue>>();
            for (int i = 0; i < result.Count; i++)
            {
                model.Add(new SeriesData<DataValue>()
                {
                    SeriesDisplayName = result[i].Name
                });
                 
                model[i].Items.Add(new DataValue()
                {
                    Name = result[i].Name,
                    Number = result[i].Number
                });
            }
            this.Source = model;
            db.Close();
        }
Esempio n. 3
0
        public override void Load()
        {
            IDbManager       dbManager = ObjectPool.Instance.Resolve <IDbManager>();
            IDataCommand     db        = dbManager.GetDatabase(ApplicationSettings.Instance.Database.DefaultConnection.Name);
            List <DataValue> result    = db.Query <DataValue>("GetDashboardTopConsumer", new { Year = this.Year });

            MutableObservableCollection <SeriesData <DataValue> > model = new MutableObservableCollection <SeriesData <DataValue> >();

            for (int i = 0; i < result.Count; i++)
            {
                model.Add(new SeriesData <DataValue>()
                {
                    SeriesDisplayName = result[i].Name
                });

                model[i].Items.Add(new DataValue()
                {
                    Name   = result[i].Name,
                    Number = result[i].Number
                });
            }
            this.Source = model;
            db.Close();
        }
        public override void Load()
        {
            IDbManager dbManager = ObjectPool.Instance.Resolve<IDbManager>();
            IDataCommand db = dbManager.GetDatabase(ApplicationSettings.Instance.Database.DefaultConnection.Name);
            List<InvoiceDataValue> result = db.Query<InvoiceDataValue>("GetDashboardInvoiceMonth", new { Year = this.Year });

            Total = 0;
            Order = 0;
            MutableObservableCollection<SeriesData<InvoiceDataValue>> model = new MutableObservableCollection<SeriesData<InvoiceDataValue>>();
            InvoiceDataValue item;
            for (int i = 1; i <= 12; i++)
            {
                item = result.Where(x => x.Name == i.ToString()).SingleOrDefault();
                model.Add(new SeriesData<InvoiceDataValue>() 
                {
                    SeriesDisplayName  = DateTimeFormatInfo.CurrentInfo.GetMonthName(i)
                });
                
                if (item != null)
                { 
                    model[i - 1].Items.Add(new InvoiceDataValue()
                    {
                        Name = DateTimeFormatInfo.CurrentInfo.GetMonthName(i),
                        Number = item.Number
                    });

                    Total += item.Number;  
                    Order += item.Order;
                    OrderInstallment = item.OrderInstallment;
                    TotalInstallment = item.TotalInstallment;
                }
                else
                {
                    model[i - 1].Items.Add(new InvoiceDataValue()
                    {
                        Name = DateTimeFormatInfo.CurrentInfo.GetMonthName(i),
                        Number = 0
                    });
                } 
            }
            this.Source = model;
            db.Close();
        }
        protected void GetQueue(string sql, params object[] args)
        {
            IDbManager   dbManager = ObjectPool.Instance.Resolve <IDbManager>();
            IDataCommand db        = dbManager.GetDatabase(DatabaseNames.SMSGW);

            List <QueueWork> workItem = db.Query <QueueWork>(sql, args);
            MutableObservableCollection <ComposeMessageModel> buffer = new MutableObservableCollection <ComposeMessageModel>();

            if (workItem.Any())
            {
                List <DailyTrigger>         daily;
                List <WeeklyTrigger>        weekly;
                List <MonthlyTrigger>       monthly;
                CommandParser               parser;
                Dictionary <string, string> parsingCommand;
                DynamicData         parameters;
                ComposeMessageModel model;

                foreach (QueueWork item in workItem)
                {
                    model = new ComposeMessageModel();

                    parser         = new CommandParser();
                    parsingCommand = parser.Parse(item.Command);
                    parameters     = new DynamicData();
                    foreach (string key in parsingCommand.Keys)
                    {
                        if (!key.Equals("Command"))
                        {
                            parameters.Add(key, parsingCommand[key]);
                        }
                    }

                    model.Source      = item.Source;
                    model.SeqNbr      = item.SeqNbr;
                    model.Phonenumber = (string)parameters.GetDictionary()["number"];
                    model.Message     = (string)parameters.GetDictionary()["message"];
                    model.Date        = item.Created.ToString("dd/MM/yyyy");
                    model.Time        = item.Created.ToString("HH:mm");
                    model.Enabled     = item.Enabled;

                    if (item.NextExecuted.Ticks > 0)
                    {
                        model.NextExecuted = DateTime.Parse(item.NextExecuted.ToString("dd/MM/yyyy HH:mm"));
                    }

                    string triggerPrefix = string.Empty;
                    if (!string.IsNullOrEmpty(item.ScheduleID))
                    {
                        triggerPrefix = item.ScheduleID.Substring(0, 1);
                    }
                    switch (triggerPrefix)
                    {
                    case "D":
                        daily = db.Query <DailyTrigger>("GetDailyTriggerByID", new { ID = item.ScheduleID });
                        if (daily.Any())
                        {
                            model.TriggerOptions = TriggerOptions.Daily;
                            model.RecursDay      = daily[0].RecursEvery;
                        }
                        break;

                    case "W":
                        weekly = db.Query <WeeklyTrigger>("GetWeeklyTriggerByID", new { ID = item.ScheduleID });
                        if (weekly.Any())
                        {
                            model.TriggerOptions          = TriggerOptions.Weekly;
                            model.RecursWeek              = weekly[0].RecursEvery;
                            model.WeeklyOptions.Monday    = weekly[0].Monday;
                            model.WeeklyOptions.Tuesday   = weekly[0].Tuesday;
                            model.WeeklyOptions.Wednesday = weekly[0].Wednesday;
                            model.WeeklyOptions.Thursday  = weekly[0].Thursday;
                            model.WeeklyOptions.Friday    = weekly[0].Friday;
                            model.WeeklyOptions.Saturday  = weekly[0].Saturday;
                            model.WeeklyOptions.Sunday    = weekly[0].Sunday;
                        }
                        break;

                    case "M":
                        monthly = db.Query <MonthlyTrigger>("GetMonthlyTriggerByID", new { ID = item.ScheduleID });
                        if (monthly.Any())
                        {
                            model.TriggerOptions = TriggerOptions.Monthly;

                            model.Months[0].IsSelected  = monthly[0].January;
                            model.Months[1].IsSelected  = monthly[0].February;
                            model.Months[2].IsSelected  = monthly[0].March;
                            model.Months[3].IsSelected  = monthly[0].April;
                            model.Months[4].IsSelected  = monthly[0].May;
                            model.Months[5].IsSelected  = monthly[0].June;
                            model.Months[6].IsSelected  = monthly[0].July;
                            model.Months[7].IsSelected  = monthly[0].August;
                            model.Months[8].IsSelected  = monthly[0].September;
                            model.Months[9].IsSelected  = monthly[0].October;
                            model.Months[10].IsSelected = monthly[0].November;
                            model.Months[11].IsSelected = monthly[0].December;

                            string[] days = monthly[0].Days.Split(',');
                            foreach (string day in days)
                            {
                                model.Days[Convert.ToInt32(day)].IsSelected = 1;
                            }
                        }
                        break;

                    case "O":
                        model.TriggerOptions = TriggerOptions.OneTime;
                        break;
                    }
                    buffer.Add(model);
                }
            }
            Source = buffer;
        }