Esempio n. 1
0
        public ActionResult Index(PhotosViewModel vm)
        {
            //HttpCookie stdsCook = new HttpCookie("selStudios", selStr)
            //{
            //    Expires = DateTime.Now.AddDays(5)
            //};
            //Response.AppendCookie(stdsCook);

            var dirs = vm.Dirs.Where(d => d.IsSelected).Select(d => d.ID).ToList();

            if (vm.Playlists != null) // none defined
            {
                var pres = ExpandPlaylists(vm.Dir, vm.Playlists.Where(d => d.IsSelected).Select(d => d.ID));

                dirs.AddRange(pres);
            }

            if (dirs.Count() == 0)
                return RedirectToAction("Index");

            var fileArr = ExtractDirsFiles(vm.Dir, dirs, vm.RandomSequence);

            ViewBag.IntervalAsMiliseconds = vm.IntervalSeconds * 1000;
            ViewBag.HoldSeconds = vm.IntervalSeconds;
            ViewBag.Dir = vm.Dir;

            return View("Photos", fileArr.Select(f => vm.Dir + f).Select(f => f.Replace("\\", "/")));
        }
Esempio n. 2
0
        // GET: Photos
        public ActionResult Index(string id)
        {
            var dbgStr = new StringBuilder();

            //var cookie = Request.Cookies["selStudios"];

            ViewBag.Title = "Family";
            var dirName = "~/media/Family/"; // the default
            var isGallery = false;

            var pcm = new PhotosConfigModel(Server.MapPath("~/App_Data/Photos.config"));

            dbgStr.AppendLine(Server.MapPath("~/App_Data/Photos.config"));
            dbgStr.AppendLine(Server.MapPath(dirName));
            //dbgStr.AppendLine(Server.MapPath(Directory.GetCurrentDirectory()));

            if (id != null)
            {
                var play = pcm.Galleries.Where(q => q.ID == id.ToLower()).SingleOrDefault();

                if (play != null)
                {
                    ViewBag.Title = play.Text;
                    dirName = "~/media/" + play.Root + "/";

                    isGallery = true;
                }
            }
            var vm = new PhotosViewModel(Server, dirName);
            ViewBag.IntervalAsMiliseconds = vm.IntervalSeconds * 1000;
            ViewBag.HoldSeconds = vm.IntervalSeconds;

            if (id != null && !isGallery)
            {
                var isPlaylist = vm.PlaylistNames.Select(s => s.ToLower()).Contains(id.ToLower()+".txt");
                var isDir = vm.DirNames.Select(s => s.ToLower()).Contains(id.ToLower());
                var allFiles = new List<string>();

                if (isPlaylist)
                {
                    var dirs = ExpandPlaylists(dirName, new[] { id + ".txt" }); //Enumerable.Repeat(item, 1);

                    allFiles.AddRange(ExtractDirsFiles(dirName, dirs));
                }
                else if (isDir)
                {
                    allFiles.AddRange(ExtractDirsFiles(dirName, new[] { id }));
                }

                if (allFiles.Count > 0) // otherwise just fall through defaults below
                {
                    var mapDir = Server.MapPath(dirName);

                    return View("Photos", allFiles.Select(f=> dirName + f).Select(f=>f.Replace("\\","/")));
                }
            }
            vm.IntervalSelList = new SelectList(pcm.Intervals, "NumSeconds", "Text", vm.IntervalSeconds);

            ViewBag.DbgStr = dbgStr.ToString();
            return View(vm);
            //var ppm = new PhotosPlaylistModel();

            //ppm.Duration = PhotosViewModel.Intervals.Secs30;
            //ppm.Sequence = PhotosViewModel.Orders.Sequential;

            //ppm.DirName = new List<string> { "A.png", "B.jpg", "C.gif" };
            //var s = ppm.AsJson();
            //var ppm2 = PhotosPlaylistModel.CreateFromJson(s);
        }