Esempio n. 1
0
        private DashboardViewModels CreateDashboard_Pack83ViewModel(Models.Message deviceMessage)
        {
            DashboardViewModels dashboard = new DashboardViewModels();

            dashboard.DeviceId    = deviceMessage.DeviceId;
            dashboard.Name        = deviceMessage.Device.Name;
            dashboard.Package     = deviceMessage.Data;
            dashboard.TypePackage = deviceMessage.TypePackage;
            dashboard.Date        = deviceMessage.Date;
            dashboard.Country     = deviceMessage.Country;
            dashboard.Lqi         = deviceMessage.Lqi;
            dashboard.Bits        = deviceMessage.Bits;

            // set location on dashboard of device
            // DeviceLocation deviceLocation = GetDeviceLocationByDeviceId(dashboard.DeviceId);
            // if (deviceLocation != null)
            // {
            //     dashboard.Latitude = deviceLocation.Latitude.ToString();
            //     dashboard.Longitude = deviceLocation.Longitude.ToString();
            //     dashboard.Radius = deviceLocation.Radius;

            //     dashboard.LatitudeConverted = LocationDecimalToDegrees((decimal)deviceLocation.Latitude, "S");
            //     dashboard.LongitudeConverted = LocationDecimalToDegrees((decimal)deviceLocation.Longitude, "W");
            //     dashboard.RadiusConverted = RadiusFormated(deviceLocation.Radius);
            // }

            dashboard.Vazao = deviceMessage.Vazao;
            dashboard.TotalizacaoParcial = deviceMessage.TotalizacaoParcial;
            dashboard.Totalizacao        = deviceMessage.Totalizacao;
            dashboard.TempoParcial       = deviceMessage.TempoParcial;

            return(dashboard);
        }
Esempio n. 2
0
        // GET: ~/
        public async Task <ActionResult> Index()
        {
            DashboardViewModels dashboard = new DashboardViewModels();

            using (UrnDbContext db = new UrnDbContext())
            {
                dashboard.CompleteWorkOrders =
                    await db.UrnForms.Where(urn => urn.Status == "Completed" && urn.CompletedBy == HttpContext.User.Identity.Name).
                    AsNoTracking().CountAsync();

                dashboard.ShippedWorkOrders =
                    await db.UrnForms.Where(urn => urn.Status == "Shipped" && urn.CompletedBy == HttpContext.User.Identity.Name)
                    .AsNoTracking().CountAsync();

                dashboard.TotalWorkOrders = await db.UrnForms.AsNoTracking().CountAsync();

                dashboard.AllQueuedWorkOrders = await db.UrnForms.Where(urn => urn.Status == "Queued")
                                                .AsNoTracking().CountAsync();

                dashboard.AllCompletedWorkOrders = await db.UrnForms.Where(urn => urn.Status == "Completed")
                                                   .AsNoTracking().CountAsync();

                dashboard.AllIncompleteWorkOrders = await db.UrnForms.Where(urn => urn.Status == "Incomplete")
                                                    .AsNoTracking().CountAsync();

                dashboard.AllShippedWorkOrders = await db.UrnForms.Where(urn => urn.Status == "Shipped")
                                                 .AsNoTracking().CountAsync();

                dashboard.AllBackOrders = await db.UrnForms.Where(urn => urn.Status == "Backorder")
                                          .AsNoTracking().CountAsync();
            }

            return(View(dashboard));
        }
Esempio n. 3
0
        private DashboardViewModels CreateDashboard_Pack23ViewModel(Models.Message deviceMessage)
        {
            DashboardViewModels dashboard = new DashboardViewModels();

            dashboard.DeviceId    = deviceMessage.DeviceId;
            dashboard.Name        = deviceMessage.Device.Name;
            dashboard.Package     = deviceMessage.Data;
            dashboard.TypePackage = deviceMessage.TypePackage;
            dashboard.Date        = deviceMessage.Date;
            dashboard.Country     = deviceMessage.Country;
            dashboard.Lqi         = deviceMessage.Lqi;
            dashboard.Bits        = deviceMessage.Bits;
            dashboard.SeqNumber   = deviceMessage.SeqNumber;

            var _fluxoAgua   = FromFloatSafe(deviceMessage.FluxoAgua);
            var _consumoAgua = FromFloatSafe(deviceMessage.ConsumoAgua);

            dashboard.FluxoAgua   = String.Format("{0:0.0}", _fluxoAgua);
            dashboard.ConsumoAgua = String.Format("{0:0.0}", _consumoAgua);

            var _display = Consts.GetDisplayTRM10(dashboard.Bits.BAlertaMax, dashboard.Bits.ModoFechado, dashboard.Bits.ModoAberto);

            dashboard.Modo        = _display.DisplayModo;   // modo
            dashboard.Estado      = _display.DisplayEstado; // alerta
            dashboard.EstadoImage = _display.EstadoImage;
            dashboard.ModoImage   = _display.ModoImage;
            dashboard.Valvula     = _display.DisplayValvula;
            dashboard.EstadoColor = _display.EstadoColor;

            return(dashboard);
        }
Esempio n. 4
0
        public ActionResult Index()
        {
            DashboardViewModels model       = new DashboardViewModels();
            DateTime            dtToday     = DateTime.UtcNow.Date;
            DateTime            dtYesterday = DateTime.UtcNow.Date.AddDays(-1);
            int userId   = HttpContext.User.Identity.GetUserId <int>();
            var userRole = this._userService.GetUserRoleById(userId);

            model.BreakdownTodayCount     = _breakDownService.GetBreakdownCounts(dtToday);
            model.BreakdownYesterDayCount = _breakDownService.GetBreakdownCounts(dtYesterday);

            model.PMOverDueCount         = _pmServices.GetPMCounts(userId, 1);
            model.PMPendingCount         = _pmServices.GetPMCounts(userId, 2);
            model.PMShutdownCount        = _pmServices.GetPMCounts(userId, 5);
            model.BreakdownMonthPerCount = _breakDownService.CalcQOS();
            model.WhatsNewNotes          = this._userService.GetWhatsNewNotes();
            model.ReleaseVersion         = this._userService.GetVersion();

            model.NewFormulationRequestCount = this._formulationRequestService.GetFormulationCount(userId, 1);
            model.RMRequestCount             = this._formulationRequestService.GetFormulationCount(userId, 2);
            model.RMDispatchCount            = this._formulationRequestService.GetFormulationCount(userId, 3);
            model.ReadyForTestingCount       = this._formulationRequestService.GetFormulationCount(userId, 3);
            model.UserRole = userRole;

            return(View(model));
        }
        public IActionResult Dashboard()
        {
            var pedidos = pedidoRepository.ObterTodos();
            DashboardViewModels DashboardViewModel = new DashboardViewModels();

            foreach (var pedido in pedidos)
            {
                switch (pedido.Status)
                {
                case (uint)StatusPedido.APROVADO:
                    DashboardViewModel.PedidosAprovados++;
                    break;

                case (uint)StatusPedido.REPROVADO:
                    DashboardViewModel.PedidosReprovados++;
                    break;

                case (uint)StatusPedido.PENDENTE:
                    DashboardViewModel.PedidosReprovados++;
                    break;

                default:
                    DashboardViewModel.PedidosPendentes++;
                    DashboardViewModel.Pedido.Add(pedido);
                    // deixar na lista de pedido pendente
                    break;
                }
            }
            DashboardViewModel.NomeView     = "Dashboard";
            DashboardViewModel.UsuarioEmail = ObterUsuarioSession();
            return(View());
        }
Esempio n. 6
0
        public ActionResult Index(string Submit, DashboardViewModels model)
        {
            if (!string.IsNullOrEmpty(Submit))
            {
                if (Submit.Equals("Excel_ReportBank"))
                {
                    ExcelReportBank(model);
                }
                else if (Submit.Equals("Excel_ReportAccount"))
                {
                    ExcelReportAccount(model);
                }
                else if (Submit.Equals("Excel_CashIn"))
                {
                    ExcelReportCashIn(model);
                }
                else if (Submit.Equals("Excel_CashOut"))
                {
                    ExcelReportCashOut(model);
                }
            }

            ViewBag.FilterBankList    = common.ToSelectList(BankFacilityBusinessLogic.getInstance().getBankFacilityDDL(), "ID", "NAME", model.FilterReportBank);
            ViewBag.FilterAccountList = common.ToSelectList(AccountDetailsBusinessLogic.getInstance().getAccountDetailDDL(), "ID", "NAME", model.FilterReportAccount);
            ViewBag.FilterCashInList  = common.ToSelectList(AccountDetailsBusinessLogic.getInstance().getAccountDetailDDL(), "ID", "NAME", model.FilterReportCashIn);
            ViewBag.FilterCashOutList = common.ToSelectList(AccountDetailsBusinessLogic.getInstance().getAccountDetailDDL(), "ID", "NAME", model.FilterReportCashOut);
            return(View(model));
        }
Esempio n. 7
0
        // GET: Dashboard
        public ActionResult Index()
        {
            var users               = database.GetUsers();
            var teams               = tdatabase.GetTeams();
            var roleStore           = new RoleStore <IdentityRole>();
            var roleMngr            = new RoleManager <IdentityRole>(roleStore);
            var banks               = bank.GetBankHolidays();
            var vacations           = CreateVacationList();
            var vacationstates      = vacationstate.GetVacationStates();
            var actualUsermaxdays   = maxdays();
            var actualuservacations = actualUsermaxdays - actuservacations();



            var roles = roleMngr.Roles.ToList();
            DashboardViewModels dashboard = new DashboardViewModels()
            {
                Userlist          = users,
                TeamList          = teams,
                RoleList          = roles,
                VacationList      = vacations,
                VacationStateList = vacationstates,
                BankHollyDayList  = banks,
                ActualUserMaxDays = actualUsermaxdays,
                ActUserVacation   = Convert.ToInt32(actualuservacations)
            };

            return(View(dashboard));
        }
        // GET: Dashboard
        public ActionResult Index()
        {
            var DbUsers = db.UserDetailsModel.ToList();
            DashboardViewModels dashboardVM = new DashboardViewModels();

            UserDetailsRepository UDR = new UserDetailsRepository();

            dashboardVM.UserList = UDR.GetUsers();

            TeamRepository TR = new TeamRepository();

            dashboardVM.TeamList = TR.GetTeams();

            List <IdentityRole> roles = db.Roles.ToList();

            dashboardVM.RoleList = roles;

            VacationRepository    vac  = new VacationRepository();
            BankHolidayRepository bank = new BankHolidayRepository();

            CalendarViewModel calendar = new CalendarViewModel();

            calendar.BankHolidayList = bank.GetBankHolidays();
            calendar.VacationList    = vac.GetVacations();

            dashboardVM.Calendar = calendar;
            return(View(dashboardVM));
        }
Esempio n. 9
0
        // GET: Admin/Dashboard
        public ActionResult Index()
        {
            DashboardViewModels dashboardViewModels = new DashboardViewModels();

            try
            {
                dashboardViewModels.NewPaperAbstractCount     = db.Makalah.Where(x => x.PaperAbstractStatus == Enums.EPaperAbstractStatus.Baru).Count();
                dashboardViewModels.NewPaperAbstractEditCount = db.Makalah.Where(x => x.PaperAbstractStatus == Enums.EPaperAbstractStatus.Edit).Count();

                dashboardViewModels.NewFullPaperCount     = db.Makalah.Where(x => x.FullPaperStatus == Enums.EFullPaperStatus.Baru).Count();
                dashboardViewModels.NewFullPaperEditCount = db.Makalah.Where(x => x.FullPaperStatus == Enums.EFullPaperStatus.Edit).Count();


                var role = db.Roles.SingleOrDefault(m => m.Name == "Peserta");
                dashboardViewModels.NewParticipantCount = db.Users.Where(m => m.Roles.All(r => r.RoleId == role.Id)).Count();
                dashboardViewModels.NewParticipantPaymentConfirmationCount = db.Users.Where(x => x.ParticipantPaymentStatus == Enums.EParticipantPaymentStatus.KonfirmasiPembayaran).Count();

                dashboardViewModels.NewPaperPaymentConfirmationCount = db.Makalah.Where(x => x.PaperPaymentStatus == Enums.EPaperPaymentStatus.KonfirmasiPembayaran).Count();

                dashboardViewModels.NewMessagesCount = db.PesanPublikToAdmin.Where(x => x.DateAdminRead == null).Count();
            }
            catch (Exception ex)
            {
                ViewBag.ErrorMessage = ex.Message;
            }

            return(View(dashboardViewModels));
        }
        public ActionResult Dashboard(int?id, int?low)
        {
            //object of DashboardViewModels
            DashboardViewModels model = new DashboardViewModels();

            //get user Id
            var user = db.Users.Find(User.Identity.GetUserId());

            //get users of Household
            model.Households = db.Users.FirstOrDefault(u => u.UserName == User.Identity.Name).Households;

            if (model.Households == null)
            {
                return(RedirectToAction("Create", "Households"));
            }

            //get in descending order transactions
            model.Transactions = db.Transactions.Where(a => a.BankAccounts.HouseholdId == user.HouseholdId).OrderByDescending(a => a.Id).Take(6).ToList();
            //get all account for this household
            model.BankAccounts = db.BankAccounts.Where(a => a.HouseholdId == model.Households.Id).ToList();

            //get List of existing budgets in this household
            var getBudget = db.Budgets.Where(a => user.HouseholdId == a.HouseHoldId).ToList();

            if (model.Households.Budgets.Count == 0)
            {
                return(RedirectToAction("Index", "Budgets"));
            }

            //Get currentbudget for this
            var CurrentBudget = db.Budgets.First(a => a.HouseHoldId == model.Households.Id);

            if (id == null)
            {
                //Viewbag to get list of current existing budget
                ViewBag.BudgetId = new SelectList(getBudget, "Id", "Name", CurrentBudget.Id);
                //assign current budget id to existing var to hold the value
                model.GetBudgetId = CurrentBudget.Id;
                //assign the current budget to show on chart
                model.Budgets = CurrentBudget;
            }
            else
            {
                //dispaly current existing budget in household
                ViewBag.BudgetId = new SelectList(getBudget, "Id", "Name", id);
                //assign id to GetBudgetId
                model.GetBudgetId = (int)id;
                //get budget assign to id
                model.Budgets = db.Budgets.First(a => a.Id == id);
            }

            var currentDate = DateTime.Now;

            model.begin = new DateTime(currentDate.Year, currentDate.Month, 1);
            model.end   = currentDate;

            return(View(model));
        }
Esempio n. 11
0
        public IEnumerable <DashboardViewModels> GetReportDataAguamon(string id, int skip = 0, int top = 0, OptionalOutTotalCount totalCount = null)
        {
            List <DashboardViewModels> newData      = new List <DashboardViewModels>();
            IQueryable <Message>       reportsQuery = _context.Messages
                                                      .AsNoTracking().Include(i => i.Device)
                                                      .Where(w => w.DeviceId == id && (w.TypePackage.Equals("10"))).OrderByDescending(o => o.Id);

            try
            {
                if (totalCount != null)
                {
                    totalCount.Value = reportsQuery.Count();
                }

                if (skip != 0)
                {
                    reportsQuery = reportsQuery.Skip(skip);
                }

                if (top != 0)
                {
                    reportsQuery = reportsQuery.Take(top);
                }

                foreach (var report in reportsQuery)
                {
                    DashboardViewModels newItem = new DashboardViewModels();
                    newItem.DeviceId    = report.DeviceId;
                    newItem.Name        = report.Device.Name;
                    newItem.Package     = report.Data;
                    newItem.TypePackage = report.TypePackage;
                    newItem.Date        = report.Date;
                    newItem.Country     = report.Country;
                    newItem.Lqi         = report.Lqi;
                    newItem.Bits        = report.Bits;

                    newItem.Temperature        = (decimal.Parse(report.Temperature) * 100).ToString();
                    newItem.Temperature        = report.Temperature.ToString().Substring(0, report.Temperature.Length - 2);
                    newItem.Envio              = report.Envio;
                    newItem.PeriodoTransmissao = report.PeriodoTransmissao;
                    newItem.Alimentacao        = $"{report.Alimentacao},0";
                    newItem.AlimentacaoMinima  = $"{report.AlimentacaoMinima},0";

                    newData.Add(newItem);
                }

                return(newData.OrderByDescending(o => o.Date).ToArray());
            }
            catch (System.Exception)
            {
                return(newData);
            }
        }
        public async Task <IActionResult> Index()
        {
            var UserId         = HttpContext.Session.GetInt32(SD.UserId);
            var claimsIdentity = (ClaimsIdentity)User.Identity;
            var claim          = claimsIdentity.FindFirst(ClaimTypes.NameIdentifier);
            DashboardViewModels dashboardVM = new DashboardViewModels()
            {
                FileRecord = await filesValue.GetAllFiles(_db),
            };

            return(View(dashboardVM));
        }
Esempio n. 13
0
 public ActionResult ReportOfAccount(DashboardViewModels model)
 {
     try
     {
         return(Json(DashboardBusinessLogic.getInstance().getReportOfAccount(model), JsonRequestBehavior.AllowGet));
     }
     catch (Exception e)
     {
         Logging.getInstance().CreateLogError(e);
         return(Json(e.Message, JsonRequestBehavior.AllowGet));
     }
 }
Esempio n. 14
0
 public List <sp_ReportOfBank_Result> getReportOfBank(DashboardViewModels model)
 {
     if (!string.IsNullOrEmpty(model.PeriodeReportBank))
     {
         string[] strDate = model.PeriodeReportBank.Split('-');
         return(_db.sp_ReportOfBank(model.FilterReportBank, strDate[0].Trim(), strDate[1].Trim(), model.ViewByReportBank).ToList());
     }
     else
     {
         return(_db.sp_ReportOfBank(model.FilterReportBank, string.Empty, string.Empty, model.ViewByReportBank).ToList());
     }
 }
Esempio n. 15
0
 public List <sp_ReportOfAccountCashOut_Result> getReportOfCashOut(DashboardViewModels model)
 {
     if (!string.IsNullOrEmpty(model.PeriodeReportCashOut))
     {
         string[] strDate = model.PeriodeReportCashOut.Split('-');
         return(_db.sp_ReportOfAccountCashOut(model.FilterReportCashOut, strDate[0].Trim(), strDate[1].Trim(), model.ViewByReportCashOut).ToList());
     }
     else
     {
         return(_db.sp_ReportOfAccountCashOut(model.FilterReportCashOut, string.Empty, string.Empty, model.ViewByReportCashOut).ToList());
     }
 }
Esempio n. 16
0
        public ActionResult ViewedNews()
        {
            ViewBag.ViewedNews = true;
            ViewBag.ChanelId   = new SelectList(Db.Chanels.Where(x => x.Followers.Any(y => y.OwnerId == CurrentUser.Id)), "Id", "Name");

            var model = new DashboardViewModels();

            model.News = GetNews(false, true, null, 0);

            //return NotFound404();
            return(View("Index", model));
        }
Esempio n. 17
0
        public ActionResult Index()
        {
            DashboardViewModels models = new DashboardViewModels();

            models.HomeTileReport = HomeBusinessLogic.getInstance().GetHomeTile();

            ViewBag.FilterBankList    = common.ToSelectList(BankFacilityBusinessLogic.getInstance().getBankFacilityDDL(), "ID", "NAME", string.Empty);
            ViewBag.FilterAccountList = common.ToSelectList(AccountDetailsBusinessLogic.getInstance().getAccountDetailDDL(), "ID", "NAME", string.Empty);
            ViewBag.FilterCashInList  = common.ToSelectList(AccountDetailsBusinessLogic.getInstance().getAccountDetailDDL(), "ID", "NAME", string.Empty);
            ViewBag.FilterCashOutList = common.ToSelectList(AccountDetailsBusinessLogic.getInstance().getAccountDetailDDL(), "ID", "NAME", string.Empty);

            return(View(models));
        }
Esempio n. 18
0
        // GET: Dashboard
        public ActionResult Index()
        {
            DashboardViewModels model = new DashboardViewModels();

            model.AuctionCount  = DashboardServices.Instance.GetAuctionCount();
            model.UserCount     = DashboardServices.Instance.GetUserCount();
            model.BidCount      = DashboardServices.Instance.GetBidCount();
            model.CategoryCount = DashboardServices.Instance.GetCategoryCount();
            model.RoleCount     = DashboardServices.Instance.GetRoleCount();
            model.CommentCount  = DashboardServices.Instance.GetCommentCount();

            return(View(model));
        }
Esempio n. 19
0
        private DashboardViewModels CreateDashboard_Pack81_82ViewModel(Models.Message deviceMessageType81, Models.Message deviceMessageType82)
        {
            DashboardViewModels dashboard = new DashboardViewModels();

            dashboard.DeviceId = deviceMessageType81.DeviceId;
            dashboard.Name     = deviceMessageType81.Device.Name;
            if (deviceMessageType82 != null)
            {
                dashboard.Package = $"{deviceMessageType81.Data};{deviceMessageType82.Data}";
            }
            else
            {
                dashboard.Package = $"{deviceMessageType81.Data}";
            }

            if (deviceMessageType82 != null)
            {
                dashboard.TypePackage = $"{deviceMessageType81.TypePackage};{deviceMessageType82.TypePackage}";
            }
            else
            {
                dashboard.TypePackage = $"{deviceMessageType81.TypePackage}";
            }

            dashboard.Date    = deviceMessageType81.Date;
            dashboard.Country = deviceMessageType81.Country;
            dashboard.Lqi     = deviceMessageType81.Lqi;

            dashboard.Temperature = deviceMessageType81.Temperature;
            dashboard.Ph          = deviceMessageType81.Ph;

            dashboard.Fluor    = deviceMessageType81.Fluor;
            dashboard.Cloro    = deviceMessageType81.Cloro;
            dashboard.Turbidez = deviceMessageType81.Turbidez;

            if (deviceMessageType82 != null)
            {
                dashboard.Rele = new Rele()
                {
                    Rele1 = Utils.HexaToDecimal(deviceMessageType82.Package.Substring(0, 2)).ToString(),
                    Rele2 = Utils.HexaToDecimal(deviceMessageType82.Package.Substring(2, 2)).ToString(),
                    Rele3 = Utils.HexaToDecimal(deviceMessageType82.Package.Substring(4, 2)).ToString(),
                    Rele4 = Utils.HexaToDecimal(deviceMessageType82.Package.Substring(6, 2)).ToString(),
                    Rele5 = Utils.HexaToDecimal(deviceMessageType82.Package.Substring(8, 2)).ToString()
                };
            }

            return(dashboard);
        }
Esempio n. 20
0
        public ActionResult News(int?chanelId)
        {
            ViewBag.News = true;
            if (chanelId != null)
            {
                ViewBag.ChanelId = new SelectList(Db.Chanels.Where(x => x.Followers.Any(y => y.OwnerId == CurrentUser.Id)), "Id", "Name", chanelId);
            }
            else
            {
                ViewBag.ChanelId = new SelectList(Db.Chanels.Where(x => x.Followers.Any(y => y.OwnerId == CurrentUser.Id)), "Id", "Name");
            }

            var model = new DashboardViewModels();

            model.News = GetNews(false, false, chanelId, 0);

            return(View("Index", model));
        }
Esempio n. 21
0
        private DashboardViewModels CreateDashboard_Pack21ViewModel(Models.Message deviceMessage)
        {
            DashboardViewModels dashboard = new DashboardViewModels();

            dashboard.DeviceId    = deviceMessage.DeviceId;
            dashboard.Name        = deviceMessage.Device.Name;
            dashboard.Package     = deviceMessage.Data;
            dashboard.TypePackage = deviceMessage.TypePackage;
            dashboard.Date        = deviceMessage.Date;
            dashboard.Country     = deviceMessage.Country;
            dashboard.Lqi         = deviceMessage.Lqi;
            dashboard.Bits        = deviceMessage.Bits;

            var _entradaAnalogica = FromFloatSafe(deviceMessage.EntradaAnalogica);
            var _saidaAnalogica   = FromFloatSafe(deviceMessage.SaidaAnalogica);

            dashboard.EntradaAnalogica = String.Format("{0:0.0}", _entradaAnalogica);
            dashboard.SaidaAnalogica   = String.Format("{0:0.0}", _saidaAnalogica);

            return(dashboard);
        }
Esempio n. 22
0
        private DashboardViewModels CreateDashboard_Pack22_23ViewModel(Models.Message deviceMessageType22, Models.Message deviceMessageType23)
        {
            DashboardViewModels dashboard = new DashboardViewModels();

            dashboard.DeviceId           = deviceMessageType22.DeviceId;
            dashboard.Name               = deviceMessageType22.Device.Name;
            dashboard.Package            = $"{deviceMessageType22.Data};{deviceMessageType23.Data}";
            dashboard.TypePackage        = $"{deviceMessageType22.TypePackage};{deviceMessageType23.TypePackage}";
            dashboard.Date               = deviceMessageType22.Date;
            dashboard.Country            = deviceMessageType22.Country;
            dashboard.Lqi                = deviceMessageType22.Lqi;
            dashboard.Bits               = deviceMessageType22.Bits;
            dashboard.Level              = deviceMessageType22.Level;
            dashboard.Light              = deviceMessageType22.Light;
            dashboard.Temperature        = deviceMessageType22.Temperature;
            dashboard.Moisture           = deviceMessageType22.Moisture;
            dashboard.OxigenioDissolvido = deviceMessageType22.OxigenioDissolvido;
            dashboard.Ph                 = deviceMessageType23.Ph;
            dashboard.Condutividade      = deviceMessageType23.Condutividade;
            dashboard.PeriodoTransmissao = deviceMessageType23.PeriodoTransmissao;
            dashboard.BaseT              = deviceMessageType23.BaseT;

            // set location on dashboard of device
            DeviceLocation deviceLocation = GetDeviceLocationByDeviceId(dashboard.DeviceId);

            if (deviceLocation != null)
            {
                dashboard.Latitude  = deviceLocation.Latitude.ToString();
                dashboard.Longitude = deviceLocation.Longitude.ToString();
                dashboard.Radius    = deviceLocation.Radius;

                dashboard.LatitudeConverted  = LocationDecimalToDegrees((decimal)deviceLocation.Latitude, "S");
                dashboard.LongitudeConverted = LocationDecimalToDegrees((decimal)deviceLocation.Longitude, "W");
                dashboard.RadiusConverted    = RadiusFormated(deviceLocation.Radius);
            }

            return(dashboard);
        }
Esempio n. 23
0
        public JsonNetResult GetCounts()
        {
            var userId = System.Web.HttpContext.Current.User.Identity.GetUserId <int>();

            var    user = System.Web.HttpContext.Current.User.Identity.GetUserName();
            string firstName = "", lastName = "";
            DashboardViewModels model = new DashboardViewModels();

            //model.PMPendingCount = this._pmServices.GetPMCounts(userId, 2);
            //model.PMOverDueCount = this._pmServices.GetPMCounts(userId, 1);
            //model.PMShutdownCount = this._pmServices.GetPMCounts(userId, 5);
            //model.MaintenanceRequestOpenCount = this._mrServices.GetMaintenanceRequestOpenCount(userId);
            //model.MaintenanceRequestInProcessCount = this._mrServices.GetMaintenanceRequestInProcessCount(userId);
            _userService.GetFnameLname(user, out firstName, out lastName);
            model.FirstName = firstName;
            model.LastName  = lastName;

            model.NewFormulationRequestCount = this._formulationRequestService.GetFormulationCount(userId, 1);
            model.RMRequestCount             = this._formulationRequestService.GetFormulationCount(userId, 2);
            model.RMDispatchCount            = this._formulationRequestService.GetFormulationCount(userId, 3);
            model.ReadyForTestingCount       = this._formulationRequestService.GetFormulationCount(userId, 4);
            return(JsonNet(model, JsonRequestBehavior.AllowGet));
        }
Esempio n. 24
0
        public ActionResult Index()
        {
            var users = database.GetUsers();
            var teams = teamrep.GetTeams();

            var roles = databaseContext.Roles.ToList();

            DashboardViewModels dashboardVM = new DashboardViewModels();

            dashboardVM.UserList = users;
            dashboardVM.TeamList = teams;
            dashboardVM.Roles    = roles;

            CalendarViewModel calendar = new CalendarViewModel();
            AjaxDateModel     date     = new AjaxDateModel();

            date.year  = DateTime.Now.Year;
            date.month = DateTime.Now.Month;

            calendar = getMonthDays(date);

            dashboardVM.Calendar = calendar;
            return(View(dashboardVM));
        }
Esempio n. 25
0
        private DashboardViewModels CreateDashboard_Pack10ViewModel(Models.Message deviceMessage)
        {
            DashboardViewModels dashboard = new DashboardViewModels();

            dashboard.DeviceId    = deviceMessage.DeviceId;
            dashboard.Name        = deviceMessage.Device.Name;
            dashboard.Package     = deviceMessage.Data;
            dashboard.TypePackage = deviceMessage.TypePackage;
            dashboard.Date        = deviceMessage.Date;
            dashboard.Country     = deviceMessage.Country;
            dashboard.Lqi         = deviceMessage.Lqi;
            dashboard.Bits        = deviceMessage.Bits;

            // set location on dashboard of device
            DeviceLocation deviceLocation = GetDeviceLocationByDeviceId(dashboard.DeviceId);

            if (deviceLocation != null)
            {
                dashboard.Latitude  = deviceLocation.Latitude.ToString();
                dashboard.Longitude = deviceLocation.Longitude.ToString();
                dashboard.Radius    = deviceLocation.Radius;

                dashboard.LatitudeConverted  = LocationDecimalToDegrees((decimal)deviceLocation.Latitude, "S");
                dashboard.LongitudeConverted = LocationDecimalToDegrees((decimal)deviceLocation.Longitude, "W");
                dashboard.RadiusConverted    = RadiusFormated(deviceLocation.Radius);
            }

            dashboard.Temperature        = (decimal.Parse(deviceMessage.Temperature) * 100).ToString();
            dashboard.Temperature        = dashboard.Temperature.ToString().Substring(0, dashboard.Temperature.Length - 2);
            dashboard.Envio              = deviceMessage.Envio;
            dashboard.PeriodoTransmissao = deviceMessage.PeriodoTransmissao;
            dashboard.Alimentacao        = $"{deviceMessage.Alimentacao},0";
            dashboard.AlimentacaoMinima  = $"{deviceMessage.AlimentacaoMinima},0";

            return(dashboard);
        }
Esempio n. 26
0
        public IEnumerable <DashboardViewModels> GetReportDataTRM10(string id, int skip = 0, int top = 0, string de = null, string ate = null, OptionalOutTotalCount totalCount = null, bool isCallByGraphic = false)
        {
            List <DashboardViewModels> newData      = new List <DashboardViewModels>();
            IQueryable <Message>       reportsQuery = _context.Messages.AsNoTracking().Include(i => i.Device).Where(w => w.DeviceId == id && (w.TypePackage.Equals("23"))).OrderByDescending(o => o.Id);

            try
            {
                if (!de.Equals("null"))
                {
                    DateTime firstDate = Convert.ToDateTime(de).ToUniversalTime();
                    reportsQuery = reportsQuery.Where(c => c.OperationDate.Value.Year >= firstDate.Year && c.OperationDate.Value.Month >= firstDate.Month && c.OperationDate.Value.Day >= firstDate.Day);
                }
                if (!ate.Equals("null"))
                {
                    var lastDate = Convert.ToDateTime(ate).ToUniversalTime();
                    reportsQuery = reportsQuery.Where(c => c.OperationDate.Value.Year <= lastDate.Year && c.OperationDate.Value.Month <= lastDate.Month && c.OperationDate.Value.Day <= lastDate.Day);
                }

                if (totalCount != null)
                {
                    totalCount.Value = reportsQuery.Count();
                }

                if (skip != 0)
                {
                    reportsQuery = reportsQuery.Skip(skip);
                }

                if (top != 0)
                {
                    reportsQuery = reportsQuery.Take(top);
                }

                foreach (var report in reportsQuery)
                {
                    DashboardViewModels newItem = new DashboardViewModels();
                    newItem.DeviceId    = report.DeviceId;
                    newItem.Name        = report.Device.Name;
                    newItem.Package     = report.Data;
                    newItem.TypePackage = report.TypePackage;
                    newItem.Date        = report.Date;
                    newItem.Country     = report.Country;
                    newItem.Lqi         = report.Lqi;
                    newItem.Bits        = report.Bits;

                    var _fluxoAgua   = FromFloatSafe(report.FluxoAgua);
                    var _consumoAgua = FromFloatSafe(report.ConsumoAgua);

                    newItem.FluxoAgua   = String.Format("{0:0.0}", _fluxoAgua);
                    newItem.ConsumoAgua = String.Format("{0:0.0}", _consumoAgua);

                    if (!isCallByGraphic)
                    {
                        var _display = Consts.GetDisplayTRM10(newItem.Bits.BAlertaMax, newItem.Bits.ModoFechado, newItem.Bits.ModoAberto);
                        newItem.Modo        = _display.DisplayModo;    // modo
                        newItem.Estado      = _display.DisplayEstado;  // alerta
                        newItem.Valvula     = _display.DisplayValvula; // válvula
                        newItem.EstadoColor = _display.EstadoColor;
                    }

                    newData.Add(newItem);
                }

                return(newData.OrderBy(o => o.Date).ToArray());
            }
            catch (System.Exception ex)
            {
                _log.Log("Erro GetReportDataTRM.", ex.Message, true);
                return(newData);
            }
        }
Esempio n. 27
0
        public IEnumerable <DashboardViewModels> GetReportDataDJRF(string id, int skip = 0, int top = 0, string de = null, string ate = null, bool blocked = false, OptionalOutTotalCount totalCount = null, bool isCallByGraphic = false)
        {
            List <DashboardViewModels> newData  = new List <DashboardViewModels>();
            IQueryable <Message>       messages = _context.Messages
                                                  .AsNoTracking()
                                                  .Include(i => i.Device)
                                                  .Where(w => w.DeviceId == id && (w.TypePackage.Equals("12") || w.TypePackage.Equals("13")))
                                                  .OrderByDescending(o => o.Time);

            try
            {
                // verificar status de bloqueado ou has-out
                if (blocked)
                {
                    messages = messages.Where(c => c.Bits.EstadoBloqueio || c.Bits.EstadoSaidaRastreador);
                }

                if (!de.Equals("null"))
                {
                    var firstDate = Convert.ToDateTime(de).ToUniversalTime().AddHours(-3);
                    messages = messages.Where(c => c.Date >= firstDate);
                }
                if (!ate.Equals("null"))
                {
                    var lastDate = Convert.ToDateTime(ate).ToUniversalTime().AddHours(-3).AddDays(1);
                    messages = messages.Where(c => c.Date <= lastDate);
                }

                if (messages == null)
                {
                    return(null);
                }

                List <Message> tmpMessages = messages.ToList();
                if (totalCount != null)
                {
                    totalCount.Value = tmpMessages.Count();
                }

                if (isCallByGraphic)
                {
                    top = totalCount.Value;
                }

                while (tmpMessages.Count() > 0 && newData.Count() <= top)
                {
                    DashboardViewModels newItem = new DashboardViewModels();
                    var message12 = tmpMessages.FirstOrDefault(w => w.TypePackage.Equals("12"));
                    var message13 = tmpMessages.FirstOrDefault(w => w.TypePackage.Equals("13"));

                    // Convertendo os dados para pacote 12
                    if (message12 != null)
                    {
                        newItem.DeviceId           = message12.DeviceId;
                        newItem.Name               = message12.Device.Name;
                        newItem.Package            = message12.Data;
                        newItem.TypePackage        = message12.TypePackage;
                        newItem.Date               = message12.Date;
                        newItem.Country            = message12.Country;
                        newItem.Lqi                = message12.Lqi;
                        newItem.Bits               = message12.Bits;
                        newItem.EstadoDetector     = message12.EstadoDetector;
                        newItem.PeriodoTransmissao = message12.PeriodoTransmissao;
                        newItem.ContadorCarencias  = message12.ContadorCarencias;
                        newItem.ContadorBloqueios  = message12.ContadorBloqueios;
                    }

                    // Convertendo os dados para pacote 13
                    if (message13 != null)
                    {
                        var firstCaracter = message13.Temperature.Substring(0, message13.Temperature.Length - 1);
                        var lastCaracter  = message13.Temperature.Substring(message13.Temperature.Length - 1, 1);
                        newItem.Temperature = $"{firstCaracter},{lastCaracter}";
                        newItem.Alimentacao = message13.Alimentacao;
                    }

                    // set location on dashboard of device
                    // DeviceLocation deviceLocation = GetDeviceLocationByDeviceId(id);
                    // if (deviceLocation != null)
                    // {
                    //     newItem.Latitude = deviceLocation.Latitude.ToString();
                    //     newItem.Longitude = deviceLocation.Longitude.ToString();
                    //     newItem.Radius = deviceLocation.Radius;

                    //     newItem.LatitudeConverted = LocationDecimalToDegrees((decimal)deviceLocation.Latitude, "S");
                    //     newItem.LongitudeConverted = LocationDecimalToDegrees((decimal)deviceLocation.Longitude, "W");
                    //     newItem.RadiusConverted = RadiusFormated(deviceLocation.Radius);
                    // }

                    newData.Add(newItem);

                    tmpMessages.Remove(message12);
                    tmpMessages.Remove(message13);
                }

                if (skip != 0 && top != 0)
                {
                    if (isCallByGraphic)
                    {
                        return(newData.Skip(skip).Take(top).OrderBy(o => o.Date).ToArray());
                    }

                    return(newData.Skip(skip).Take(top).OrderByDescending(o => o.Date).ToArray());
                }

                if (skip != 0 && top == 0)
                {
                    if (isCallByGraphic)
                    {
                        return(newData.Skip(skip).OrderBy(o => o.Date).ToArray());
                    }

                    return(newData.Skip(skip).OrderByDescending(o => o.Date).ToArray());
                }

                if (skip == 0 && top != 0)
                {
                    if (isCallByGraphic)
                    {
                        return(newData.Take(top).OrderBy(o => o.Date).ToArray());
                    }

                    return(newData.Take(top).OrderByDescending(o => o.Date).ToArray());
                }

                if (isCallByGraphic)
                {
                    return(newData.OrderBy(o => o.Date).ToArray());
                }

                return(newData.OrderByDescending(o => o.Date).ToArray());
            }
            catch (System.Exception)
            {
                return(newData);
            }
        }
Esempio n. 28
0
        private void ExcelReportCashOut(DashboardViewModels model)
        {
            ExcelPackage   Package    = new ExcelPackage();
            ExcelWorksheet ws         = Package.Workbook.Worksheets.Add("Data");
            ExcelWorksheet wsComChart = Package.Workbook.Worksheets.Add("Chart");

            OfficeOpenXml.Style.ExcelBorderStyle DefaultBorder = OfficeOpenXml.Style.ExcelBorderStyle.Thin;
            Color colFromHex = System.Drawing.ColorTranslator.FromHtml("#00b0f0");

            ws.Cells["A1"].LoadFromText("Month");
            ws.Cells["A1"].Style.Font.SetFromFont(new Font("Cambria", 10));
            ws.Cells["A1"].Style.Font.Color.SetColor(Color.White);
            ws.Cells["A1"].Style.Font.Bold        = true;
            ws.Cells["A1"].Style.Fill.PatternType = ExcelFillStyle.Solid;
            ws.Cells["A1"].Style.Fill.BackgroundColor.SetColor(colFromHex);
            ws.Cells["A1"].Style.HorizontalAlignment = OfficeOpenXml.Style.ExcelHorizontalAlignment.Center;
            ws.Cells["A1"].Style.VerticalAlignment   = OfficeOpenXml.Style.ExcelVerticalAlignment.Center;
            ws.Cells["A1"].Style.Border.Bottom.Style = DefaultBorder;
            ws.Cells["A1"].Style.Border.Left.Style   = DefaultBorder;
            ws.Cells["A1"].Style.Border.Top.Style    = DefaultBorder;
            ws.Cells["A1"].Style.Border.Right.Style  = DefaultBorder;

            ws.Cells["B1"].LoadFromText("Operation");
            ws.Cells["B1"].Style.Font.SetFromFont(new Font("Cambria", 10));
            ws.Cells["B1"].Style.Font.Color.SetColor(Color.White);
            ws.Cells["B1"].Style.Font.Bold        = true;
            ws.Cells["B1"].Style.Fill.PatternType = ExcelFillStyle.Solid;
            ws.Cells["B1"].Style.Fill.BackgroundColor.SetColor(colFromHex);
            ws.Cells["B1"].Style.HorizontalAlignment = OfficeOpenXml.Style.ExcelHorizontalAlignment.Center;
            ws.Cells["B1"].Style.VerticalAlignment   = OfficeOpenXml.Style.ExcelVerticalAlignment.Center;
            ws.Cells["B1"].Style.Border.Bottom.Style = DefaultBorder;
            ws.Cells["B1"].Style.Border.Left.Style   = DefaultBorder;
            ws.Cells["B1"].Style.Border.Top.Style    = DefaultBorder;
            ws.Cells["B1"].Style.Border.Right.Style  = DefaultBorder;

            ws.Cells["C1"].LoadFromText("Accounting");
            ws.Cells["C1"].Style.Font.SetFromFont(new Font("Cambria", 10));
            ws.Cells["C1"].Style.Font.Color.SetColor(Color.White);
            ws.Cells["C1"].Style.Font.Bold        = true;
            ws.Cells["C1"].Style.Fill.PatternType = ExcelFillStyle.Solid;
            ws.Cells["C1"].Style.Fill.BackgroundColor.SetColor(colFromHex);
            ws.Cells["C1"].Style.HorizontalAlignment = OfficeOpenXml.Style.ExcelHorizontalAlignment.Center;
            ws.Cells["C1"].Style.VerticalAlignment   = OfficeOpenXml.Style.ExcelVerticalAlignment.Center;
            ws.Cells["C1"].Style.Border.Bottom.Style = DefaultBorder;
            ws.Cells["C1"].Style.Border.Left.Style   = DefaultBorder;
            ws.Cells["C1"].Style.Border.Top.Style    = DefaultBorder;
            ws.Cells["C1"].Style.Border.Right.Style  = DefaultBorder;

            int idx  = 1;
            var list = DashboardBusinessLogic.getInstance().getReportOfAccountCashIn(model);

            foreach (var item in list)
            {
                idx++;
                ws.Cells["A" + idx.ToString()].LoadFromText(item.Month);
                ws.Cells["A" + idx.ToString()].Style.Font.SetFromFont(new Font("Cambria", 10));
                ws.Cells["A" + idx.ToString()].Style.HorizontalAlignment = OfficeOpenXml.Style.ExcelHorizontalAlignment.Center;
                ws.Cells["A" + idx.ToString()].Style.VerticalAlignment   = OfficeOpenXml.Style.ExcelVerticalAlignment.Center;
                ws.Cells["A" + idx.ToString()].Style.Border.Bottom.Style = DefaultBorder;
                ws.Cells["A" + idx.ToString()].Style.Border.Left.Style   = DefaultBorder;
                ws.Cells["A" + idx.ToString()].Style.Border.Top.Style    = DefaultBorder;
                ws.Cells["A" + idx.ToString()].Style.Border.Right.Style  = DefaultBorder;

                ws.Cells["B" + idx.ToString()].LoadFromText((Convert.ToDecimal(item.Accounting)).ToString());
                ws.Cells["B" + idx.ToString()].Style.Numberformat.Format = "#,##";
                ws.Cells["B" + idx.ToString()].Style.Font.SetFromFont(new Font("Cambria", 10));
                ws.Cells["B" + idx.ToString()].Style.HorizontalAlignment = OfficeOpenXml.Style.ExcelHorizontalAlignment.Center;
                ws.Cells["B" + idx.ToString()].Style.VerticalAlignment   = OfficeOpenXml.Style.ExcelVerticalAlignment.Center;
                ws.Cells["B" + idx.ToString()].Style.Border.Bottom.Style = DefaultBorder;
                ws.Cells["B" + idx.ToString()].Style.Border.Left.Style   = DefaultBorder;
                ws.Cells["B" + idx.ToString()].Style.Border.Top.Style    = DefaultBorder;
                ws.Cells["B" + idx.ToString()].Style.Border.Right.Style  = DefaultBorder;

                ws.Cells["C" + idx.ToString()].LoadFromText((Convert.ToDecimal(item.Operation)).ToString());
                ws.Cells["C" + idx.ToString()].Style.Numberformat.Format = "#,##";
                ws.Cells["C" + idx.ToString()].Style.Font.SetFromFont(new Font("Cambria", 10));
                ws.Cells["C" + idx.ToString()].Style.HorizontalAlignment = OfficeOpenXml.Style.ExcelHorizontalAlignment.Center;
                ws.Cells["C" + idx.ToString()].Style.VerticalAlignment   = OfficeOpenXml.Style.ExcelVerticalAlignment.Center;
                ws.Cells["C" + idx.ToString()].Style.Border.Bottom.Style = DefaultBorder;
                ws.Cells["C" + idx.ToString()].Style.Border.Left.Style   = DefaultBorder;
                ws.Cells["C" + idx.ToString()].Style.Border.Top.Style    = DefaultBorder;
                ws.Cells["C" + idx.ToString()].Style.Border.Right.Style  = DefaultBorder;
            }

            List <DataSerie> SeriesList = new List <DataSerie>();

            SeriesList.Add(new DataSerie()
            {
                name = "Month", Series = ws.Cells["A" + (idx - 1) + ":A" + idx], xSeries = ws.Cells["B" + (idx - 1) + ":C" + idx]
            });
            SeriesList.Add(new DataSerie()
            {
                name = "Accounting", Series = ws.Cells["B" + (idx - 1) + ":B" + idx], xSeries = ws.Cells["B" + (idx - 1) + ":C" + idx]
            });
            SeriesList.Add(new DataSerie()
            {
                name = "Operation", Series = ws.Cells["C" + (idx - 1) + ":C" + idx], xSeries = ws.Cells["B" + (idx - 1) + ":C" + idx]
            });

            ExcelChart chart = AddBarChart(wsComChart, "ReportOfAccountCashOut", OfficeOpenXml.Drawing.Chart.eChartType.ColumnClustered, SeriesList);

            chart.Title.Text = "Report Of Account Cash Out";
            chart.SetPosition(0, 0, 0, 0);
            chart.SetSize(BarOptions.width, BarOptions.Height);

            Response.Clear();
            Response.Buffer      = true;
            Response.Charset     = "";
            Response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
            Response.AddHeader("content-disposition", "attachment;filename=ReportOfAccountCashOut_" + DateTime.Now.ToString("ddMMyyyyhhmmss") + ".xlsx");
            Response.BinaryWrite(Package.GetAsByteArray());
            Response.End();
        }
Esempio n. 29
0
        private DashboardViewModels CreateDashboard_Pack12ViewModel(Models.Message deviceMessage_12, Models.Message deviceMessage_13, DeviceRegistration deviceRegistration)
        {
            DashboardViewModels dashboard = new DashboardViewModels();

            dashboard.DeviceId    = deviceMessage_12.DeviceId;
            dashboard.Name        = deviceMessage_12.Device.Name;
            dashboard.Package     = deviceMessage_12.Data;
            dashboard.TypePackage = deviceMessage_12.TypePackage;
            dashboard.Date        = deviceMessage_12.Date;
            dashboard.Country     = deviceMessage_12.Country;
            dashboard.Lqi         = deviceMessage_12.Lqi;
            dashboard.Bits        = deviceMessage_12.Bits;

            // set location on dashboard of device
            DeviceLocation deviceLocation = GetDeviceLocationByDeviceId(dashboard.DeviceId);

            if (deviceLocation != null)
            {
                dashboard.Latitude  = deviceLocation.Latitude.ToString();
                dashboard.Longitude = deviceLocation.Longitude.ToString();
                dashboard.Radius    = deviceLocation.Radius;

                dashboard.LatitudeConverted  = LocationDecimalToDegrees((decimal)deviceLocation.Latitude, "S");
                dashboard.LongitudeConverted = LocationDecimalToDegrees((decimal)deviceLocation.Longitude, "W");
                dashboard.RadiusConverted    = RadiusFormated(deviceLocation.Radius);
            }

            // converter os bits deste
            dashboard.EstadoDetector     = deviceMessage_12.EstadoDetector;
            dashboard.PeriodoTransmissao = deviceMessage_12.PeriodoTransmissao;
            dashboard.AlertaFonteBaixa   = deviceMessage_12.AlertaFonteBaixa;

            dashboard.ContadorCarencias = deviceMessage_12.ContadorCarencias;
            dashboard.ContadorBloqueios = deviceMessage_12.ContadorBloqueios;

            var firstCaracter = deviceMessage_13.Temperature.Substring(0, deviceMessage_13.Temperature.Length - 1);
            var lastCaracter  = deviceMessage_13.Temperature.Substring(deviceMessage_13.Temperature.Length - 1, 1);

            dashboard.Temperature = $"{firstCaracter},{lastCaracter}";

            // dashboard.Alimentacao = deviceMessage_13.Alimentacao;
            if (deviceMessage_13.Alimentacao == "0")
            {
                if (deviceMessage_13.AlimentacaoH != "0")
                {
                    dashboard.Alimentacao = $"{deviceMessage_13.AlimentacaoL}{deviceMessage_13.AlimentacaoH}";
                }
                else
                {
                    dashboard.Alimentacao = deviceMessage_13.AlimentacaoL.Contains(",") ? $"{deviceMessage_13.AlimentacaoL}" : $"{deviceMessage_13.AlimentacaoL},0";
                }
            }
            else
            {
                dashboard.Alimentacao = deviceMessage_13.Alimentacao.Contains(",") ? $"{deviceMessage_13.Alimentacao}" : $"{deviceMessage_13.Alimentacao},0";
            }

            if (deviceRegistration.DataDownloadLink != null)
            {
                dashboard.Envio = deviceRegistration.Envio;
                dashboard.PeriodoTransmissao   = deviceRegistration.PeriodoTransmissao;
                dashboard.Bits.BaseTempoUpLink = deviceRegistration.BaseTempoUpLink;
                dashboard.TensaoMinima         = deviceRegistration.TensaoMinima;
            }

            return(dashboard);
        }
Esempio n. 30
0
        public ActionResult Index()

        {
            List <DashboardViewModel> dashboardItems = new List <DashboardViewModel>();
            List <DashboardViewModel> items          = new List <DashboardViewModel>();
            var viewModel = new DashboardViewModels();

            SupportService   supportService   = new SupportService();
            TimeSheetService timesheetService = new TimeSheetService();
            ExpenseService   expenseService   = new ExpenseService();
            LOAService       loaService       = new LOAService();

            var roles = ((ClaimsIdentity)User.Identity).Claims
                        .Where(c => c.Type == ClaimTypes.Role)
                        .Select(c => c.Value);

            if (roles.Contains("TimeSheetAdmin"))
            {
                viewModel.AdminPendingExpensesCount   = expenseService.GetPendingExpensesCount();
                viewModel.AdminPendingLOAsCount       = loaService.GetPendingLOAsCount();
                viewModel.AdminPendingTimesheetsCount = timesheetService.GetPendingTimesheetsCount();

                //    viewModel.DasboardList.AddRange(ExpenseModuleAdmin());
            }
            else if (roles.Contains("TimeSheetManager"))
            {
                viewModel.ManagerPendingTimesheetsCount = timesheetService.GetPendingTimesheetsCount();
                viewModel.MangerPendingExpensesCount    = expenseService.GetPendingExpensesCount();
                viewModel.MangerPendingLOAsCount        = loaService.GetPendingLOAsCount();
                //    viewModel.DasboardList.AddRange(TimeSheetModuleManager());
                //    viewModel.DasboardList.AddRange(LOAModuleManager());
                //    items.AddRange(ExpenseModuleManager());
            }

            if (roles.Contains("TimeSheetReportingManager"))
            {
                viewModel.ReportingManagerPendingExpensesCount   = expenseService.GetPendingExpensesCount(User.Identity.GetUserId());
                viewModel.ReportingManagerPendingLOAsCount       = loaService.GetPendingLOAsCount(User.Identity.GetUserId());
                viewModel.ReportingManagerPendingTimesheetsCount = timesheetService.GetPendingTimesheetsCount(User.Identity.GetUserId());
                //    viewModel.DasboardList.AddRange(TimeSheetModuleReportingManager());
                //    viewModel.DasboardList.AddRange(LOAModuleReportingManager());
                //    viewModel.DasboardList.AddRange(ExpenseModuleReportingManager());
            }

            if (roles.Contains("SupportUser"))
            {
                //viewModel.DasboardList.AddRange(SupportModuleUserPendingRequest());
                //viewModel.DasboardList.AddRange(SupportModuleUserDoneRequest());
                //viewModel.DasboardList.AddRange(SupportModuleUserClosedRequest());
                viewModel.MyPendingRequestsCount = supportService.GetMyPendingRequestsCount(User.Identity.GetUserId());
                viewModel.MyClosedRequestsCount  = supportService.GetMyClosedRequestsCount(User.Identity.GetUserId());
                viewModel.MyDoneRequestsCount    = supportService.GetMyDoneRequestsCount(User.Identity.GetUserId());
            }



            //viewModel.DasboardList.AddRange(items);

            //dashboardItems.AddRange(items);

            return(View(viewModel));
        }