Example #1
0
        public Dashbord UserDashBoardById(string name)
        {
            //Dashbord van ingelogde gebruiker ophalen
            try
            {
                //ApplicationUser appUser = aMgr.FindById(User.Identity.GetUserId());
                //string userName = appUser.UserName;
                Gebruiker user = gMgr.FindUser(name);

                Dashbord dashbord = dashMgr.GetDashboardWithFollows(user);
                dashbord = dashMgr.UpdateDashboard(dashbord); // <-- zien dat elk DashItem minstens 3h up-to-date is

                var list = JsonConvert.SerializeObject(dashbord, Formatting.None, new JsonSerializerSettings()
                {
                    ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore
                });

                return(dashbord);
            }
            catch
            {
                return(null);
            }
        }
        public ActionResult Dashboard()
        {
            //try
            //{
            //    ApplicationUser appUser = aMgr.FindById(User.Identity.GetUserId());
            //    string userName = appUser.UserName;
            //    Gebruiker user = gMgr.FindUser(userName);

            //    Dashbord dashbord = dashMgr.GetDashboardWithFollows(user);
            //    dashbord = dashMgr.UpdateDashboard(dashbord); // <-- zien dat elk DashItem up-to-date is
            //}
            //catch
            //{
            //}

            bool ingelogd = false;

            IEnumerable <Persoon> ObjList = dMgr.GetPersonen().ToList();
            List <string>         names   = ObjList.Select(p => p.Naam).ToList();

            ViewData["names"] = names;

            Persoon persoon      = dMgr.GetPersoon(170);
            int     aantalTweets = dMgr.GetNumber(persoon);

            //int aantalTweets = 69;
            ViewBag.NUMMER1 = aantalTweets;
            ViewBag.naam1   = persoon.Naam;
            //System.Diagnostics.Debug.WriteLine("tweets per dag"+aantalTweets);
            int[] init = { 0, 1, 3, 2, 8, 6, 5, 4, 9, 7 };
            //ViewData["init"] = init;
            List <double> spark = dMgr.GetTotalMessagesSparkline();

            spark.Reverse();
            ViewBag.msgsSpark = spark;
            ViewBag.percent   = dMgr.GetstijgingTweets();

            //List<GraphData> data = dMgr.GetTweetsPerDagList(persoon, 20);
            //ViewBag.DATA = data;


            ApplicationUser currUser = aMgr.FindById(System.Web.HttpContext.Current.User.Identity.GetUserId());

            Dashbord dash;

            if (currUser != null)
            {
                string    userName = currUser.UserName;
                Gebruiker user     = gMgr.FindUser(userName);
                dash     = dashMgr.GetDashboardWithFollows(user);
                ingelogd = true;
            }
            else
            {
                //not jet ready
                //have to add defaultdash
                string    userName = "******";
                Gebruiker user     = gMgr.FindUser(userName);
                dash = dashMgr.GetDashboardWithFollows(user);
            }

            ViewBag.Ingelogd = ingelogd;
            ViewBag.INIT     = dash.ZonesOrder;
            //dashMgr.GetDashItems().Where(d => d.AdminGraph == true);
            ViewBag.AANTAL = dashMgr.GetDashItems().Where(d => d.AdminGraph == true).Count();
            //GraphDataViewModel model = new GraphDataViewModel { dash = dash,
            //};
            return(View(dash));
        }
        public ActionResult CreateGrafiekLine(string automplete, string automplete2)
        {
            string naam = automplete;

            ViewBag.naam = automplete;

            //Zie dat je bent ingelogd
            //TODO: redirect naar inlog pagina <--
            ApplicationUser currUser = _userManager.FindById(System.Web.HttpContext.Current.User.Identity.GetUserId());
            string          userName = currUser.UserName;
            Gebruiker       user     = _gebrManager.FindUser(userName);

            int nDagen = 10; // <-- voorlopig default

            //////////////////////////////////////////////////////////////////
            try
            {
                Persoon p = _dataManager.GetPersoon(naam);
                // =============== Opslaan grafiek : opgesplitst om te debuggen =================== //
                List <IP3_8IEN.BL.Domain.Dashboard.GraphData> graphDataList = _dataManager.GetTweetsPerDag(p, nDagen);
                IP3_8IEN.BL.Domain.Dashboard.DashItem         newDashItem   = _dashManager.CreateDashitem(true, "Line", naam);
                IP3_8IEN.BL.Domain.Dashboard.Follow           follow        = _dashManager.CreateFollow(newDashItem.DashItemId, p.OnderwerpId);
                IP3_8IEN.BL.Domain.Dashboard.DashItem         dashItem      = _dashManager.SetupDashItem(user, follow);
                _dashManager.LinkGraphsToUser(graphDataList, dashItem.DashItemId);
                // ================================================================================ //
                _dashManager.SyncWithAdmins(user.GebruikerId, dashItem.DashItemId);
            }
            catch { }
            try
            {
                Organisatie o = _dataManager.GetOrganisaties().ToList().FirstOrDefault(org => org.Naam == naam);
                List <IP3_8IEN.BL.Domain.Dashboard.GraphData> graphDataList;
                IP3_8IEN.BL.Domain.Dashboard.DashItem         newDashItem;
                // =============== Opslaan grafiek : opgesplitst om te debuggen =================== //
                if (automplete2 != null)
                {
                    graphDataList = _dataManager.GetTweetsPerDag(o, automplete2, nDagen);
                    newDashItem   = _dashManager.CreateDashitem(true, "Line", naam, automplete2);
                }
                else
                {
                    graphDataList = _dataManager.GetTweetsPerDag(o, nDagen);
                    newDashItem   = _dashManager.CreateDashitem(true, "Line", naam);
                }

                IP3_8IEN.BL.Domain.Dashboard.Follow   follow   = _dashManager.CreateFollow(newDashItem.DashItemId, o.OnderwerpId);
                IP3_8IEN.BL.Domain.Dashboard.DashItem dashItem = _dashManager.SetupDashItem(user, follow);
                _dashManager.LinkGraphsToUser(graphDataList, dashItem.DashItemId);
                // ================================================================================ //
                _dashManager.SyncWithAdmins(user.GebruikerId, dashItem.DashItemId);
            }
            catch { }
            try
            {
                Thema            thema         = _dataManager.GetThemas().ToList().FirstOrDefault(t => t.Naam == naam);
                List <GraphData> graphDataList = _dataManager.GetTweetsPerDag(thema, nDagen);
                DashItem         newDashItem   = _dashManager.CreateDashitem(true, "Line", naam);
                Follow           follow        = _dashManager.CreateFollow(newDashItem.DashItemId, thema.OnderwerpId);
                DashItem         dashItem      = _dashManager.SetupDashItem(user, follow);
                _dashManager.LinkGraphsToUser(graphDataList, dashItem.DashItemId);
                // ================================================================================ //
                _dashManager.SyncWithAdmins(user.GebruikerId, dashItem.DashItemId);
            }
            catch { }
            ////////////////////////////////////////////////////////////////



            Dashbord dash = _dashManager.GetDashboardWithFollows(user);

            return(View());
        }