コード例 #1
0
ファイル: ScreenController.cs プロジェクト: CivilPol/Vodigi
        private string ValidateInput(Screen screen)
        {
            if (screen.AccountID == 0)
                return "Account ID is not valid.";

            if (String.IsNullOrEmpty(screen.ScreenName))
                return "Screen Name is required.";

            if (screen.SlideShowID == 0 && screen.PlayListID == 0)
                return "You must select a Slide Show or Play List.";

            if (screen.SlideShowID != 0 && screen.PlayListID != 0)
                return "Select a Slide Show or Play List. You cannot select both.";

            if (screen.IsInteractive && screen.ButtonImageID == 0)
                return "You must select a Button Image.";

            return String.Empty;
        }
コード例 #2
0
ファイル: ScreenController.cs プロジェクト: CivilPol/Vodigi
        private Screen FillNulls(Screen screen)
        {
            if (screen.ScreenDescription == null) screen.ScreenDescription = String.Empty;

            return screen;
        }
コード例 #3
0
ファイル: ScreenController.cs プロジェクト: CivilPol/Vodigi
        private Screen CreateNewScreen()
        {
            Screen screen = new Screen();
            screen.ScreenID = 0;
            screen.AccountID = 0;
            screen.ScreenName = String.Empty;
            screen.ScreenDescription = String.Empty;
            screen.SlideShowID = 0;
            screen.PlayListID = 0;
            screen.IsInteractive = false;
            screen.ButtonImageID = 0;
            screen.IsActive = true;
            screen.TimelineID = 0;

            return screen;
        }
コード例 #4
0
        private string GetSchedulesByDayHour(List<PlayerGroupSchedule> schedules, int day, int hour)
        {
            try
            {
                string html = String.Empty;
                IScreenRepository screenrep = new EntityScreenRepository();
                string uri = Request.Url.AbsoluteUri;
                if (uri.Contains("?"))
                    uri = uri.Substring(0, uri.IndexOf('?'));

                foreach (PlayerGroupSchedule schedule in schedules)
                {
                    if (schedule.Day == day && schedule.Hour == hour)
                    {
                        Screen screen = new Screen();
                        if (schedule.ScreenID == 0)
                        {
                            screen.ScreenID = 0;
                            screen.ScreenName = "Blank Screen";
                        }
                        else
                        {
                            screen = screenrep.GetScreen(schedule.ScreenID);
                        }
                        if (screen != null)
                        {
                            html += "<div class=\"schedule\">" + screen.ScreenName + "</br>" +
                                String.Format("{0:00}", schedule.Hour) + ":" + String.Format("{0:00}", schedule.Minute) +
                                "&nbsp;&nbsp;<span id=\"schedulelink\"><a href=\"" + uri + "?delete=" + schedule.PlayerGroupScheduleID.ToString() + "\">Delete</a></span></div>";
                        }
                    }
                }

                return html;
            }
            catch { return String.Empty; }
        }
コード例 #5
0
ファイル: ScreenController.cs プロジェクト: CivilPol/Vodigi
        public ActionResult Edit(Screen screen)
        {
            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";

                if (ModelState.IsValid)
                {
                    // Set NULLs to Empty Strings
                    screen = FillNulls(screen);
                    screen.SlideShowID = Convert.ToInt32(Request.Form["lstSlideShow"]);
                    screen.PlayListID = Convert.ToInt32(Request.Form["lstPlayList"]);
                    string buttonimageguid = Request.Form["lstButtonImage"];

                    IImageRepository imgrep = new EntityImageRepository();
                    Image img = imgrep.GetImageByGuid(Convert.ToInt32(Session["UserAccountID"]), buttonimageguid);
                    if (img != null)
                        screen.ButtonImageID = img.ImageID;
                    else
                        screen.ButtonImageID = 0;

                    string validation = ValidateInput(screen);
                    if (!String.IsNullOrEmpty(validation))
                    {
                        ViewData["ValidationMessage"] = validation;
                        ViewData["ImageList"] = new SelectList(BuildImageList(Request.Form["lstButtonImage"]), "Value", "Text", Request.Form["lstButtonImage"]);
                        ViewData["ImageUrl"] = selectedfile;
                        ViewData["SlideShowList"] = new SelectList(BuildSlideShowList(), "Value", "Text", Request.Form["lstSlideShow"]);
                        ViewData["PlayListList"] = new SelectList(BuildPlayListList(), "Value", "Text", Request.Form["lstPlayList"]);

                        int accountid = 0;
                        if (Session["UserAccountID"] != null)
                            accountid = Convert.ToInt32(Session["UserAccountID"]);
                        ViewData["ImageFolder"] = ConfigurationManager.AppSettings["MediaRootFolder"] + Convert.ToString(Session["UserAccountID"]) + @"/Images/";

                        return View(screen);
                    }
                    else
                    {
                        // Update the screen
                        repository.UpdateScreen(screen);

                        CommonMethods.CreateActivityLog((User)Session["User"], "Screen", "Edit",
                            "Edited screen '" + screen.ScreenName + "' - ID: " + screen.ScreenID.ToString());

                        IScreenScreenContentXrefRepository xrefrep = new EntityScreenScreenContentXrefRepository();

                        // Delete existing xrefs for the screen
                        xrefrep.DeleteScreenScreenContentXrefs(screen.ScreenID);

                        // Create a xref for each screen content in the screen
                        IScreenScreenContentXrefRepository sscrep = new EntityScreenScreenContentXrefRepository();
                        string[] ids = Request.Form["txtScreenScreenContent"].ToString().Split('|');
                        int i = 1;
                        foreach (string id in ids)
                        {
                            if (!String.IsNullOrEmpty(id.Trim()))
                            {
                                ScreenScreenContentXref ssc = new ScreenScreenContentXref();
                                ssc.DisplayOrder = i;
                                ssc.ScreenID = screen.ScreenID;
                                ssc.ScreenContentID = Convert.ToInt32(id);
                                sscrep.CreateScreenScreenContentXref(ssc);
                                i += 1;
                            }
                        }

                        return RedirectToAction("Index");
                    }
                }

                return View(screen);
            }
            catch (Exception ex)
            {
                Helpers.SetupApplicationError("Screen", "Edit POST", ex.Message);
                return RedirectToAction("Index", "ApplicationError");
            }
        }
コード例 #6
0
 public void UpdateScreen(Screen screen)
 {
     db.Entry(screen).State = EntityState.Modified;
     db.SaveChanges();
 }
コード例 #7
0
 public void CreateScreen(Screen screen)
 {
     db.Screens.Add(screen);
     db.SaveChanges();
 }
コード例 #8
0
        private Screen CreateExampleScreen(int accountid, int buttonimageid, int playlistid, int slideshowid, int timelineid, string screenname, List<ScreenContent> screencontents)
        {
            try
            {
                IScreenRepository screenrep = new EntityScreenRepository();
                IScreenScreenContentXrefRepository sscxrefrep = new EntityScreenScreenContentXrefRepository();

                Screen screen = new Screen();
                screen.ButtonImageID = buttonimageid;
                screen.AccountID = accountid;
                screen.IsInteractive = true;
                screen.PlayListID = playlistid;
                screen.SlideShowID = slideshowid;
                screen.TimelineID = timelineid;
                screen.ScreenName = screenname;
                screen.ScreenDescription = String.Empty;
                screen.IsActive = true;
                screenrep.CreateScreen(screen);

                int i = 1;
                foreach (ScreenContent screencontent in screencontents)
                {
                    ScreenScreenContentXref sscxref = new ScreenScreenContentXref();
                    sscxref.ScreenID = screen.ScreenID;
                    sscxref.ScreenContentID = screencontent.ScreenContentID;
                    sscxref.DisplayOrder = i;
                    sscxrefrep.CreateScreenScreenContentXref(sscxref);
                    i += 1;
                }

                return screen;
            }
            catch { return null; }
        }
コード例 #9
0
        public ActionResult Step1(Screen screen)
        {
            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";

                if (ModelState.IsValid)
                {
                    // Set NULLs to Empty Strings
                    screen = FillNulls(screen);
                    screen.AccountID = Convert.ToInt32(Session["UserAccountID"]);

                    string validation = ValidateInput(screen);
                    if (!String.IsNullOrEmpty(validation))
                    {
                        ViewData["ValidationMessage"] = validation;
                        ViewData["MainFeatureTypeList"] = new SelectList(BuildMainFeatureTypeList(), "Value", "Text", Request.Form["lstMainFeatureType"]);

                        return View(screen);
                    }
                    else
                    {
                        string mainfeaturetype = Request.Form["lstMainFeatureType"];

                        if (mainfeaturetype == "Slide Show")
                        {
                            if (screen.SlideShowID <= 0)
                                screen.SlideShowID = -1;
                            screen.PlayListID = 0;
                            screen.TimelineID = 0;
                        }
                        else if (mainfeaturetype == "Play List")
                        {
                            screen.SlideShowID = 0;
                            if (screen.PlayListID <= 0)
                                screen.PlayListID = -1;
                            screen.TimelineID = 0;
                        }
                        else if (mainfeaturetype == "Media Timeline")
                        {
                            screen.SlideShowID = 0;
                            screen.PlayListID = 0;
                            if (screen.TimelineID <= 0)
                                screen.TimelineID = -1;
                        }

                        if (screen.ScreenID == 0)
                            repository.CreateScreen(screen);
                        else
                            repository.UpdateScreen(screen);

                        CommonMethods.CreateActivityLog((User)Session["User"], "Screen", "Wizard Step 1",
                            "Step 1 '" + screen.ScreenName + "' - ID: " + screen.ScreenID.ToString());

                        return RedirectToAction("Step2", new { id = screen.ScreenID });
                    }
                }

                return View(screen);
            }
            catch (Exception ex)
            {
                Helpers.SetupApplicationError("ScreenWizard", "Step 1 POST", ex.Message);
                return RedirectToAction("Index", "ApplicationError");
            }
        }
コード例 #10
0
        private string ValidateInput(Screen screen)
        {
            if (screen.AccountID == 0)
                return "Account ID is not valid.";

            if (String.IsNullOrEmpty(screen.ScreenName))
                return "Screen Name is required.";

            return String.Empty;
        }
コード例 #11
0
        public ActionResult Step4(Screen screen)
        {
            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";

                if (ModelState.IsValid)
                {
                    // Set NULLs to Empty Strings
                    screen = FillNulls(screen);
                    screen.AccountID = Convert.ToInt32(Session["UserAccountID"]);

                    if (String.IsNullOrEmpty(Request.Form["txtScreenScreenContent"]))
                    {
                        ViewData["ScreenScreenContent"] = String.Empty;
                        ViewData["ScreenContentList"] = new SelectList(BuildScreenContentList(), "Value", "Text", "");
                        ViewData["ScreenScreenContentList"] = new SelectList(BuildScreenScreenContentList(screen.ScreenID), "Value", "Text", "");
                        ViewData["ScreenID"] = screen.ScreenID;
                        ViewData["ValidationMessage"] = "Please select one or more screen content items";
                        return View(screen);
                    }
                    else
                    {
                        // Delete and recreate the screen/screen content xrefs
                        IScreenScreenContentXrefRepository xrefrep = new EntityScreenScreenContentXrefRepository();
                        xrefrep.DeleteScreenScreenContentXrefs(screen.ScreenID);

                        // Create a xref for each screen content in the screen
                        IScreenScreenContentXrefRepository sscrep = new EntityScreenScreenContentXrefRepository();
                        string[] ids = Request.Form["txtScreenScreenContent"].ToString().Split('|');
                        int i = 1;
                        foreach (string id in ids)
                        {
                            if (!String.IsNullOrEmpty(id.Trim()))
                            {
                                ScreenScreenContentXref ssc = new ScreenScreenContentXref();
                                ssc.DisplayOrder = i;
                                ssc.ScreenID = screen.ScreenID;
                                ssc.ScreenContentID = Convert.ToInt32(id);
                                sscrep.CreateScreenScreenContentXref(ssc);
                                i += 1;
                            }
                        }

                        CommonMethods.CreateActivityLog((User)Session["User"], "Screen", "Wizard Step 4",
                            "Step 4 '" + screen.ScreenName + "' - ID: " + screen.ScreenID.ToString());

                        return RedirectToAction("Index", "Screen");
                    }
                }

                return View(screen);
            }
            catch (Exception ex)
            {
                Helpers.SetupApplicationError("ScreenWizard", "Step 3 POST", ex.Message);
                return RedirectToAction("Index", "ApplicationError");
            }
        }
コード例 #12
0
        public ActionResult Step3(Screen screen)
        {
            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";

                if (ModelState.IsValid)
                {
                    // Set NULLs to Empty Strings
                    screen = FillNulls(screen);
                    screen.AccountID = Convert.ToInt32(Session["UserAccountID"]);

                    string buttonimageguid = Request.Form["lstButtonImage"];

                    IImageRepository imgrep = new EntityImageRepository();
                    Image img = imgrep.GetImageByGuid(Convert.ToInt32(Session["UserAccountID"]), buttonimageguid);
                    if (img != null)
                        screen.ButtonImageID = img.ImageID;
                    else
                        screen.ButtonImageID = 0;

                    string validation = ValidateInput(screen);
                    if (!String.IsNullOrEmpty(validation))
                    {
                        ViewData["ValidationMessage"] = validation;
                        ViewData["ScreenID"] = screen.ScreenID;
                        if (img == null)
                            ViewData["ImageList"] = new SelectList(BuildImageList(""), "Value", "Text", "");
                        else
                            ViewData["ImageList"] = new SelectList(BuildImageList(img.StoredFilename), "Value", "Text", img.StoredFilename);
                        if (!String.IsNullOrEmpty(selectedfile))
                            ViewData["ImageUrl"] = selectedfile;
                        else
                            ViewData["ImageUrl"] = firstfile;

                        int accountid = 0;
                        if (Session["UserAccountID"] != null)
                            accountid = Convert.ToInt32(Session["UserAccountID"]);
                        ViewData["ImageFolder"] = ConfigurationManager.AppSettings["MediaRootFolder"] + Convert.ToString(Session["UserAccountID"]) + @"/Images/";

                        return View(screen);
                    }
                    else
                    {
                        repository.UpdateScreen(screen);

                        CommonMethods.CreateActivityLog((User)Session["User"], "Screen", "Wizard Step 3",
                            "Step 3 '" + screen.ScreenName + "' - ID: " + screen.ScreenID.ToString());

                        if (screen.IsInteractive)
                            return RedirectToAction("Step4", new { id = screen.ScreenID });
                        else
                            return RedirectToAction("Index", "Screen");
                    }
                }

                return View(screen);
            }
            catch (Exception ex)
            {
                Helpers.SetupApplicationError("ScreenWizard", "Step 3 POST", ex.Message);
                return RedirectToAction("Index", "ApplicationError");
            }
        }