Esempio n. 1
0
        public ActionResult Validate(FormCollection collection)
        {
            try
            {
                // Validate the login
                User user = repository.ValidateLogin(Request.Form["txtUsername"].ToString(), Request.Form["txtPassword"].ToString());

                ViewData["FreeLinks"] = "";
                if (ConfigurationManager.AppSettings["ShowFreeLinks"] == "true")
                    ViewData["FreeLinks"] = BuildFreeLinks();

                // Display the system messages, if any
                ViewData["SystemMessages"] = BuildSystemMessages();

                if (user == null)
                {
                    ViewData["Username"] = Request.Form["txtUsername"].ToString();
                    ViewData["Password"] = String.Empty;
                    ViewData["ValidationMessage"] = "Invalid Login. Please try again.";
                    ViewData["LoginInfo"] = "Please log in.";

                    return View();
                }
                else
                {
                    Session["User"] = user;
                    Session["UserAccountID"] = user.AccountID;

                    IAccountRepository acctrep = new EntityAccountRepository();
                    Account account = acctrep.GetAccount(user.AccountID);
                    Session["UserAccountName"] = account.AccountName;

                    // Make sure the Account Folders exist
                    string serverpath = Server.MapPath("~/UploadedFiles");
                    if (!serverpath.EndsWith(@"\"))
                        serverpath += @"\";
                    System.IO.Directory.CreateDirectory(serverpath + user.AccountID.ToString() + @"\Images");
                    System.IO.Directory.CreateDirectory(serverpath + user.AccountID.ToString() + @"\Videos");
                    System.IO.Directory.CreateDirectory(serverpath + user.AccountID.ToString() + @"\Music");

                    serverpath = Server.MapPath("~/Media");
                    if (!serverpath.EndsWith(@"\"))
                        serverpath += @"\";
                    System.IO.Directory.CreateDirectory(serverpath + user.AccountID.ToString() + @"\Images");
                    System.IO.Directory.CreateDirectory(serverpath + user.AccountID.ToString() + @"\Videos");
                    System.IO.Directory.CreateDirectory(serverpath + user.AccountID.ToString() + @"\Music");

                    // If no player groups have been defined, create sample account data
                    IPlayerGroupRepository pgrep = new EntityPlayerGroupRepository();
                    IEnumerable<PlayerGroup> pgs = pgrep.GetAllPlayerGroups(account.AccountID);
                    if (pgs == null || pgs.Count() == 0)
                    {
                        acctrep.CreateSampleData(account.AccountID);
                    }

                    // Log the login
                    ILoginLogRepository llrep = new EntityLoginLogRepository();
                    LoginLog loginlog = new LoginLog();
                    loginlog.AccountID = user.AccountID;
                    loginlog.UserID = user.UserID;
                    loginlog.Username = user.Username;
                    loginlog.LoginDateTime = DateTime.Now.ToUniversalTime();
                    llrep.CreateLoginLog(loginlog);

                    return RedirectToAction("Index", "PlayerGroup");

                }
            }
            catch (Exception ex)
            {
                Helpers.SetupApplicationError("Login", "Validate POST", ex.Message);
                return RedirectToAction("Index", "ApplicationError");
            }
        }
Esempio n. 2
0
        private List<SelectListItem> BuildPlayerGroupList(bool addAllItem)
        {
            // Build the player group list
            List<SelectListItem> pgitems = new List<SelectListItem>();

            // Add an 'All' item at the top
            if (addAllItem)
            {
                SelectListItem all = new SelectListItem();
                all.Text = "All Player Groups";
                all.Value = "0";
                pgitems.Add(all);
            }

            IPlayerGroupRepository pgrep = new EntityPlayerGroupRepository();
            IEnumerable<PlayerGroup> pgs = pgrep.GetAllPlayerGroups(Convert.ToInt32(Session["UserAccountID"]));
            foreach (PlayerGroup pg in pgs)
            {
                SelectListItem item = new SelectListItem();
                item.Text = pg.PlayerGroupName;
                item.Value = pg.PlayerGroupID.ToString();

                pgitems.Add(item);
            }

            return pgitems;
        }
        public ActionResult Edit(PlayerGroupSchedule playergroupschedule)
        {
            try
            {
                if (Session["UserAccountID"] == null)
                    return RedirectToAction("Validate", "Login");
                User user = (User)Session["User"];
                ViewData["LoginInfo"] = Utility.BuildUserAccountString(user.Username, Convert.ToString(Session["UserAccountName"]));
                if (user.IsAdmin)
                    ViewData["txtIsAdmin"] = "true";
                else
                    ViewData["txtIsAdmin"] = "false";

                int playergroupid = Convert.ToInt32(Request.Form["txtPlayerGroupID"]);
                int screenid = Convert.ToInt32(Request.Form["lstScreen"]);
                int hour = Convert.ToInt32(Request.Form["lstHour"]);
                int minute = Convert.ToInt32(Request.Form["lstMinute"]);

                if (!String.IsNullOrEmpty(Request.Form["chkSunday"]))
                    CreatePlayerGroupSchedule(playergroupid, screenid, 0, hour, minute);
                if (!String.IsNullOrEmpty(Request.Form["chkMonday"]))
                    CreatePlayerGroupSchedule(playergroupid, screenid, 1, hour, minute);
                if (!String.IsNullOrEmpty(Request.Form["chkTuesday"]))
                    CreatePlayerGroupSchedule(playergroupid, screenid, 2, hour, minute);
                if (!String.IsNullOrEmpty(Request.Form["chkWednesday"]))
                    CreatePlayerGroupSchedule(playergroupid, screenid, 3, hour, minute);
                if (!String.IsNullOrEmpty(Request.Form["chkThursday"]))
                    CreatePlayerGroupSchedule(playergroupid, screenid, 4, hour, minute);
                if (!String.IsNullOrEmpty(Request.Form["chkFriday"]))
                    CreatePlayerGroupSchedule(playergroupid, screenid, 5, hour, minute);
                if (!String.IsNullOrEmpty(Request.Form["chkSaturday"]))
                    CreatePlayerGroupSchedule(playergroupid, screenid, 6, hour, minute);

                IPlayerGroupRepository pgrep = new EntityPlayerGroupRepository();
                PlayerGroup playergroup = pgrep.GetPlayerGroup(playergroupid);
                ViewData["PlayerGroupID"] = playergroupid;
                ViewData["PlayerGroupName"] = playergroup.PlayerGroupName;

                ViewData["ScreenList"] = new SelectList(BuildScreenList(), "Value", "Text", "");
                ViewData["HourList"] = new SelectList(BuildHourList(), "Value", "Text", "");
                ViewData["MinuteList"] = new SelectList(BuildMinuteList(), "Value", "Text", "");

                ViewData["ScheduleHTML"] = BuildScheduleTable(playergroupid);

                return View(playergroupschedule);
            }
            catch (Exception ex)
            {
                Helpers.SetupApplicationError("PlayerGroupSchedule", "Edit", ex.Message);
                return RedirectToAction("Index", "ApplicationError");
            }
        }
Esempio n. 4
0
        //
        // GET: /Player/
        public ActionResult Index()
        {
            try
            {
                if (Session["UserAccountID"] == null)
                    return RedirectToAction("Validate", "Login");
                User user = (User)Session["User"];
                ViewData["LoginInfo"] = Utility.BuildUserAccountString(user.Username, Convert.ToString(Session["UserAccountName"]));
                if (user.IsAdmin)
                    ViewData["txtIsAdmin"] = "true";
                else
                    ViewData["txtIsAdmin"] = "false";

                // Initialize or get the page state using session
                PlayerPageState pagestate = GetPageState();

                // Get the account id
                int accountid = 0;
                if (Session["UserAccountID"] != null)
                    accountid = Convert.ToInt32(Session["UserAccountID"]);

                // Set and save the page state to the submitted form values if any values are passed
                if (Request.Form["lstAscDesc"] != null)
                {
                    pagestate.AccountID = accountid;
                    pagestate.PlayerGroupID = Convert.ToInt32(Request.Form["lstPlayerGroup"].ToString().Trim());
                    pagestate.PlayerName = Request.Form["txtPlayerName"].ToString().Trim();
                    if (Request.Form["chkIncludeInactive"].ToLower().StartsWith("true"))
                        pagestate.IncludeInactive = true;
                    else
                        pagestate.IncludeInactive = false;
                    pagestate.SortBy = Request.Form["lstSortBy"].ToString().Trim();
                    pagestate.AscDesc = Request.Form["lstAscDesc"].ToString().Trim();
                    pagestate.PageNumber = Convert.ToInt32(Request.Form["txtPageNumber"].ToString().Trim());
                    SavePageState(pagestate);
                }

                // Add the session values to the view data so they can be populated in the form
                ViewData["AccountID"] = pagestate.AccountID;
                ViewData["PlayerGroupID"] = pagestate.PlayerGroupID;
                ViewData["PlayerName"] = pagestate.PlayerName;
                ViewData["IncludeInactive"] = pagestate.IncludeInactive;
                ViewData["SortBy"] = pagestate.SortBy;
                ViewData["PlayerGroupList"] = new SelectList(BuildPlayerGroupList(true), "Value", "Text", pagestate.PlayerGroupID);
                ViewData["SortByList"] = new SelectList(BuildSortByList(), "Value", "Text", pagestate.SortBy);
                ViewData["AscDescList"] = new SelectList(BuildAscDescList(), "Value", "Text", pagestate.AscDesc);

                // Determine asc/desc
                bool isdescending = false;
                if (pagestate.AscDesc.ToLower().StartsWith("d"))
                    isdescending = true;

                // Get a Count of all filtered records
                int recordcount = repository.GetPlayerRecordCount(pagestate.AccountID, pagestate.PlayerGroupID, pagestate.PlayerName, pagestate.IncludeInactive);

                // Determine the page count
                int pagecount = 1;
                if (recordcount > 0)
                {
                    pagecount = recordcount / Constants.PageSize;
                    if (recordcount % Constants.PageSize != 0) // Add a page if there are more records
                    {
                        pagecount = pagecount + 1;
                    }
                }

                // Make sure the current page is not greater than the page count
                if (pagestate.PageNumber > pagecount)
                {
                    pagestate.PageNumber = pagecount;
                    SavePageState(pagestate);
                }

                // Set the page number and account in viewdata
                ViewData["PageNumber"] = Convert.ToString(pagestate.PageNumber);
                ViewData["PageCount"] = Convert.ToString(pagecount);
                ViewData["RecordCount"] = Convert.ToString(recordcount);

                // We need to add the player group name
                IEnumerable<Player> players = repository.GetPlayerPage(pagestate.AccountID, pagestate.PlayerGroupID, pagestate.PlayerName, pagestate.IncludeInactive, pagestate.SortBy, isdescending, pagestate.PageNumber, pagecount);
                List<PlayerView> playerviews = new List<PlayerView>();
                IPlayerGroupRepository pgrep = new EntityPlayerGroupRepository();
                foreach (Player player in players)
                {
                    PlayerView playerview = new PlayerView();
                    playerview.PlayerID = player.PlayerID;
                    playerview.AccountID = player.AccountID;
                    playerview.PlayerGroupID = player.PlayerGroupID;
                    playerview.PlayerName = player.PlayerName;
                    playerview.PlayerLocation = player.PlayerLocation;
                    playerview.PlayerDescription = player.PlayerDescription;
                    playerview.IsActive = player.IsActive;
                    PlayerGroup pg = pgrep.GetPlayerGroup(player.PlayerGroupID);
                    playerview.PlayerGroupName = pg.PlayerGroupName;

                    playerviews.Add(playerview);
                }

                ViewResult result = View(playerviews);
                result.ViewName = "Index";
                return result;
            }
            catch (Exception ex)
            {
                Helpers.SetupApplicationError("Player", "Index", ex.Message);
                return RedirectToAction("Index", "ApplicationError");
            }
        }
        public void CreateSampleData(int accountid)
        {
            // Initialize the sample data for a new account so there is data available
            try
            {
                // Copy the five images for the sample
                CopySampleImage(accountid, "6f5e187f-52a2-4799-bdac-2e9199580b98.png");
                CopySampleImage(accountid, "60255096-6a72-409e-b905-4d98ee717bb0.jpg");
                CopySampleImage(accountid, "612bb76c-e16e-4fe8-87f2-bddc7eb59300.jpg");
                CopySampleImage(accountid, "69f99c47-d1b0-4123-b62b-8f18bdc5702f.jpg");
                CopySampleImage(accountid, "626c6a35-4523-46aa-9d0a-c2687b581e27.jpg");

                // Create the image records
                IImageRepository imagerep = new EntityImageRepository();

                Image img1 = new Image();
                img1.AccountID = accountid;
                img1.ImageName = "Visit Las Vegas Button";
                img1.OriginalFilename = "vegasbutton.png";
                img1.StoredFilename = "6f5e187f-52a2-4799-bdac-2e9199580b98.png";
                img1.Tags = "Las Vegas";
                img1.IsActive = true;
                imagerep.CreateImage(img1);

                Image img2 = new Image();
                img2.AccountID = accountid;
                img2.ImageName = "Vegas 01";
                img2.OriginalFilename = "vegas01.jpg";
                img2.StoredFilename = "60255096-6a72-409e-b905-4d98ee717bb0.jpg";
                img2.Tags = "Las Vegas";
                img2.IsActive = true;
                imagerep.CreateImage(img2);

                Image img3 = new Image();
                img3.AccountID = accountid;
                img3.ImageName = "Vegas 02";
                img3.OriginalFilename = "vegas02.jpg";
                img3.StoredFilename = "612bb76c-e16e-4fe8-87f2-bddc7eb59300.jpg";
                img3.Tags = "Las Vegas";
                img3.IsActive = true;
                imagerep.CreateImage(img3);

                Image img4 = new Image();
                img4.AccountID = accountid;
                img4.ImageName = "Vegas 03";
                img4.OriginalFilename = "vegas03.jpg";
                img4.StoredFilename = "69f99c47-d1b0-4123-b62b-8f18bdc5702f.jpg";
                img4.Tags = "Las Vegas";
                img4.IsActive = true;
                imagerep.CreateImage(img4);

                Image img5 = new Image();
                img5.AccountID = accountid;
                img5.ImageName = "Vegas 04";
                img5.OriginalFilename = "vegas04.jpg";
                img5.StoredFilename = "626c6a35-4523-46aa-9d0a-c2687b581e27.jpg";
                img5.Tags = "Las Vegas";
                img5.IsActive = true;
                imagerep.CreateImage(img5);

                // Create a slideshow with the four images
                ISlideShowRepository slideshowrep = new EntitySlideShowRepository();
                ISlideShowImageXrefRepository ssixrefrep = new EntitySlideShowImageXrefRepository();

                SlideShow slideshow = new SlideShow();
                slideshow.AccountID = accountid;
                slideshow.SlideShowName = "Visit Vegas Slideshow";
                slideshow.Tags = "Las Vegas";
                slideshow.TransitionType = "Fade";
                slideshow.IntervalInSecs = 10;
                slideshow.IsActive = true;
                slideshowrep.CreateSlideShow(slideshow);

                SlideShowImageXref xref1 = new SlideShowImageXref();
                xref1.PlayOrder = 1;
                xref1.SlideShowID = slideshow.SlideShowID;
                xref1.ImageID = img2.ImageID;
                ssixrefrep.CreateSlideShowImageXref(xref1);

                SlideShowImageXref xref2 = new SlideShowImageXref();
                xref2.PlayOrder = 2;
                xref2.SlideShowID = slideshow.SlideShowID;
                xref2.ImageID = img3.ImageID;
                ssixrefrep.CreateSlideShowImageXref(xref2);

                SlideShowImageXref xref3 = new SlideShowImageXref();
                xref3.PlayOrder = 3;
                xref3.SlideShowID = slideshow.SlideShowID;
                xref3.ImageID = img4.ImageID;
                ssixrefrep.CreateSlideShowImageXref(xref3);

                SlideShowImageXref xref4 = new SlideShowImageXref();
                xref4.PlayOrder = 4;
                xref4.SlideShowID = slideshow.SlideShowID;
                xref4.ImageID = img5.ImageID;
                ssixrefrep.CreateSlideShowImageXref(xref4);

                // Create one screencontent item for each image
                IScreenContentRepository screencontentrep = new EntityScreenContentRepository();

                ScreenContent content1 = new ScreenContent();
                content1.AccountID = accountid;
                content1.ScreenContentName = "Vegas 01 Image";
                content1.ScreenContentTitle = "Las Vegas Is Fun!";
                content1.ScreenContentTypeID = 1000000;
                content1.ThumbnailImageID = img2.ImageID;
                content1.CustomField1 = img2.ImageID.ToString();
                content1.CustomField2 = String.Empty;
                content1.CustomField3 = String.Empty;
                content1.CustomField4 = String.Empty;
                content1.IsActive = true;
                screencontentrep.CreateScreenContent(content1);

                ScreenContent content2 = new ScreenContent();
                content2.AccountID = accountid;
                content2.ScreenContentName = "Vegas 02 Image";
                content2.ScreenContentTitle = "Visit Las Vegas!";
                content2.ScreenContentTypeID = 1000000;
                content2.ThumbnailImageID = img3.ImageID;
                content2.CustomField1 = img3.ImageID.ToString();
                content2.CustomField2 = String.Empty;
                content2.CustomField3 = String.Empty;
                content2.CustomField4 = String.Empty;
                content2.IsActive = true;
                screencontentrep.CreateScreenContent(content2);

                ScreenContent content3 = new ScreenContent();
                content3.AccountID = accountid;
                content3.ScreenContentName = "Vegas 03 Image";
                content3.ScreenContentTitle = "There's so much to do in Vegas!";
                content3.ScreenContentTypeID = 1000000;
                content3.ThumbnailImageID = img4.ImageID;
                content3.CustomField1 = img4.ImageID.ToString();
                content3.CustomField2 = String.Empty;
                content3.CustomField3 = String.Empty;
                content3.CustomField4 = String.Empty;
                content3.IsActive = true;
                screencontentrep.CreateScreenContent(content3);

                ScreenContent content4 = new ScreenContent();
                content4.AccountID = accountid;
                content4.ScreenContentName = "Vegas 04 Image";
                content4.ScreenContentTitle = "Good times, day or night!";
                content4.ScreenContentTypeID = 1000000;
                content4.ThumbnailImageID = img5.ImageID;
                content4.CustomField1 = img5.ImageID.ToString();
                content4.CustomField2 = String.Empty;
                content4.CustomField3 = String.Empty;
                content4.CustomField4 = String.Empty;
                content4.IsActive = true;
                screencontentrep.CreateScreenContent(content4);

                // Create the screen with slideshow and four screen content items
                IScreenRepository screenrep = new EntityScreenRepository();
                IScreenScreenContentXrefRepository sscxrefrep = new EntityScreenScreenContentXrefRepository();

                Screen screen = new Screen();
                screen.ButtonImageID = img1.ImageID;
                screen.AccountID = accountid;
                screen.IsInteractive = true;
                screen.PlayListID = 0;
                screen.SlideShowID = slideshow.SlideShowID;
                screen.ScreenName = "Visit Las Vegas";
                screen.ScreenDescription = String.Empty;
                screen.IsActive = true;
                screenrep.CreateScreen(screen);

                ScreenScreenContentXref sscxref1 = new ScreenScreenContentXref();
                sscxref1.ScreenID = screen.ScreenID;
                sscxref1.ScreenContentID = content1.ScreenContentID;
                sscxref1.DisplayOrder = 1;
                sscxrefrep.CreateScreenScreenContentXref(sscxref1);

                ScreenScreenContentXref sscxref2 = new ScreenScreenContentXref();
                sscxref2.ScreenID = screen.ScreenID;
                sscxref2.ScreenContentID = content2.ScreenContentID;
                sscxref2.DisplayOrder = 2;
                sscxrefrep.CreateScreenScreenContentXref(sscxref2);

                ScreenScreenContentXref sscxref3 = new ScreenScreenContentXref();
                sscxref3.ScreenID = screen.ScreenID;
                sscxref3.ScreenContentID = content3.ScreenContentID;
                sscxref3.DisplayOrder = 3;
                sscxrefrep.CreateScreenScreenContentXref(sscxref3);

                ScreenScreenContentXref sscxref4 = new ScreenScreenContentXref();
                sscxref4.ScreenID = screen.ScreenID;
                sscxref4.ScreenContentID = content4.ScreenContentID;
                sscxref4.DisplayOrder = 4;
                sscxrefrep.CreateScreenScreenContentXref(sscxref4);

                // Create a PlayerGroup - My Players
                IPlayerGroupRepository playergrouprep = new EntityPlayerGroupRepository();
                PlayerGroup playergroup = new PlayerGroup();
                playergroup.AccountID = accountid;
                playergroup.PlayerGroupName = "My Players";
                playergroup.PlayerGroupDescription = String.Empty;
                playergroup.IsActive = true;
                playergrouprep.CreatePlayerGroup(playergroup);

                // Create a Player - My Player
                IPlayerRepository playerrep = new EntityPlayerRepository();
                Player player = new Player();
                player.AccountID = accountid;
                player.PlayerGroupID = playergroup.PlayerGroupID;
                player.PlayerName = "My Player";
                player.PlayerLocation = String.Empty;
                player.PlayerDescription = String.Empty;
                player.IsActive = true;
                playerrep.CreatePlayer(player);

                // Create the schedule for My Players player group
                IPlayerGroupScheduleRepository schedulerep = new EntityPlayerGroupScheduleRepository();

                PlayerGroupSchedule schedule1 = new PlayerGroupSchedule();
                schedule1.PlayerGroupID = playergroup.PlayerGroupID;
                schedule1.ScreenID = screen.ScreenID;
                schedule1.Day = 0;
                schedule1.Hour = 0;
                schedule1.Minute = 0;
                schedulerep.CreatePlayerGroupSchedule(schedule1);

                PlayerGroupSchedule schedule2 = new PlayerGroupSchedule();
                schedule2.PlayerGroupID = playergroup.PlayerGroupID;
                schedule2.ScreenID = screen.ScreenID;
                schedule2.Day = 1;
                schedule2.Hour = 0;
                schedule2.Minute = 0;
                schedulerep.CreatePlayerGroupSchedule(schedule2);

                PlayerGroupSchedule schedule3 = new PlayerGroupSchedule();
                schedule3.PlayerGroupID = playergroup.PlayerGroupID;
                schedule3.ScreenID = screen.ScreenID;
                schedule3.Day = 2;
                schedule3.Hour = 0;
                schedule3.Minute = 0;
                schedulerep.CreatePlayerGroupSchedule(schedule3);

                PlayerGroupSchedule schedule4 = new PlayerGroupSchedule();
                schedule4.PlayerGroupID = playergroup.PlayerGroupID;
                schedule4.ScreenID = screen.ScreenID;
                schedule4.Day = 3;
                schedule4.Hour = 0;
                schedule4.Minute = 0;
                schedulerep.CreatePlayerGroupSchedule(schedule4);

                PlayerGroupSchedule schedule5 = new PlayerGroupSchedule();
                schedule5.PlayerGroupID = playergroup.PlayerGroupID;
                schedule5.ScreenID = screen.ScreenID;
                schedule5.Day = 4;
                schedule5.Hour = 0;
                schedule5.Minute = 0;
                schedulerep.CreatePlayerGroupSchedule(schedule5);

                PlayerGroupSchedule schedule6 = new PlayerGroupSchedule();
                schedule6.PlayerGroupID = playergroup.PlayerGroupID;
                schedule6.ScreenID = screen.ScreenID;
                schedule6.Day = 5;
                schedule6.Hour = 0;
                schedule6.Minute = 0;
                schedulerep.CreatePlayerGroupSchedule(schedule6);

                PlayerGroupSchedule schedule7 = new PlayerGroupSchedule();
                schedule7.PlayerGroupID = playergroup.PlayerGroupID;
                schedule7.ScreenID = screen.ScreenID;
                schedule7.Day = 6;
                schedule7.Hour = 0;
                schedule7.Minute = 0;
                schedulerep.CreatePlayerGroupSchedule(schedule7);
            }
            catch { }
        }