Exemplo n.º 1
0
        private void LVLocations_CellEditStarting(object sender, CellEditEventArgs e)
        {
            var item = e.RowObject as LocationForDisplay;

            if (item != null && e.SubItemIndex == 1)
            {
                var bases         = LocationPersistence.ListBases();
                var control       = new ComboBox();
                int selectedIndex = -1;
                for (int i = 0; i < bases.Count; i++)
                {
                    var b = bases[i];
                    control.Items.Add(new ComboBoxItem(b.Id, b.Name));
                    if (b.Id == item.LocationBaseId)
                    {
                        selectedIndex = i;
                    }
                }

                control.SelectedIndex = selectedIndex;
                control.Width         = e.Column.Width;
                control.Left          = e.Control.Left;
                e.Control             = control;
            }
        }
        public Locations()
        {
            InitializeComponent();
            var locations = LocationPersistence.ListBases();

            LVLocations.VirtualMode = false;
            LVLocations.SetObjects(locations);
        }
Exemplo n.º 3
0
 public ActionResult Set(SetRequest rq)
 {
     if (rq == null)
     {
         throw new ArgumentNullException("rq");
     }
     rq.Persist <LocationBase>(LocationBase.Delete);
     return(Json(SetRequest.FromPoco(LocationPersistence.ListBases()), JsonRequestBehavior.AllowGet));
 }
Exemplo n.º 4
0
        private void LVLocations_ButtonClick(object sender, BrightIdeasSoftware.CellClickEventArgs e)
        {
            var location = e.Model as LocationForDisplay;

            if (location == null)
            {
                return;
            }
            var device = CbxDevices.SelectedItem as Device;

            if (device == null)
            {
                return;
            }
            LocationPersistence.Run(device.Id, location.TitleId);
        }
Exemplo n.º 5
0
        private void DisplayTitleInfo(Title title)
        {
            m_currentTitle = title;
            LVLocations.ClearObjects();
            LVRatings.ClearObjects();
            m_imageIndex = 0;

            if (title != null)
            {
                TbxReleaseYear.Text = title.Year.ToString("##");
                TbxDescription.Text = title.Description;
                TbxImdbId.Text      = title.ImdbId;
                TbxSeason.Text      = title.Season.ToString("##");
                TbxDisk.Text        = title.Disk.ToString("##");
                TbxEpisode.Text     = title.EpisodeOrTrack.ToString("##");

                TbxTitleName.Text = title.TitleName;
                CbxKind.SetSelectedKey(title.Kind);

                LVLocations.AddObjects(LocationPersistence.ListTitleLocations(title.Id));
                LVRatings.AddObjects(TitlePersistence.GetRatings(title.Id));
                SetEpisodeControlsState(m_currentTitle.Kind);
                m_images = MediaSamplePersistence.GetSamples(title.Id, MediaSampleKind.Image);
                DisplayImage();
            }
            else
            {
                TbxReleaseYear.Text = "";
                TbxDescription.Text = "";
                TbxImdbId.Text      = "";
                TbxSeason.Text      = "";
                TbxDisk.Text        = "";
                TbxEpisode.Text     = "";

                TbxTitleName.Text     = "";
                CbxKind.SelectedIndex = -1;
                SetEpisodeControlsState(TitleKind.Title);
                m_images = null;
                SetImageNavigationControls();
                PbxImage.Clear();
            }
        }
        public ActionResult GetLocations(long id)
        {
            var res = LocationPersistence.ListTitleLocations(id);

            return(Json(res, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 7
0
        public ActionResult GetLocations(int id)
        {
            var res = LocationPersistence.GetLocationsForBase(id);

            return(Json(res, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 8
0
        //
        // GET: /Location/

        public ActionResult Index()
        {
            return(View("~/Views/LocationBases.cshtml", SetRequest.FromPoco(LocationPersistence.ListBases())));
        }
        public static RescanResults Run(long locationBaseId, long deviceId)
        {
            var res = new RescanResults();

            //DEVICE_KIND = 1 - PC
            const string SQL = @"SELECT dl.LOCATION_MAPPING
					FROM device_location_map dl
					JOIN device d
					  ON d.DEVICE_ID = dl.DEVICE_ID
					 AND d.DEVICE_KIND = 1
					WHERE dl.LOCATION_BASE_ID = @0
					  AND dl.DEVICE_ID = @1"                    ;

            string basePath;
            List <TitleLocation> databaseStorage;

            using (var db = DB.GetDatabase())
            {
                basePath        = db.Fetch <string>(SQL, locationBaseId, deviceId).FirstOrDefault();
                databaseStorage = LocationPersistence.GetLocationForBase(locationBaseId, db);
            }

            //Don't process images and unknown files
            var fileStorage = SearchFileStorage.Generate(basePath, locationBaseId).Where((f) => { return(f.DataType != MediaType.Picture && f.DataType != MediaType.Unknown && f.DataType != MediaType.PictureFolder); }).ToList();

            /*if (fileStorage.Count == 0)
             * {
             *      res.ErrorCode = "NO_MEDIA_FILES_FOUND";
             *      return res;
             * } */

            fileStorage.Sort();
            databaseStorage.Sort();             //Sorting here to have exactly the same order

            int basePathLen = basePath.Length;

            int idxFile = 0;
            int idxDb   = 0;

            while (idxFile < fileStorage.Count && idxDb < databaseStorage.Count)
            {
                //In real world likely there will be more files on disk than in DB, so there is no optimization for removed files
                string filePath = fileStorage[idxFile].RelativePath;
                //if (!filePath.StartsWith(basePath)) throw new ApplicationException(string.Format("Path {0} doesn't start with {1}", filePath, basePath));
                string relPath = filePath;                 //.Substring(basePath.Length);

                int cmp = relPath.CompareTo(databaseStorage[idxDb].LocationData);
                if (cmp == 0)
                {
                    //cool - match found
                    idxDb++;
                    idxFile++;
                }
                else if (cmp < 0)
                {
                    //fileStorage precedes -> not in the DB
                    res.NewFiles.Add(fileStorage[idxFile]);
                    idxFile++;
                }
                else
                {
                    //InFiles precedes -> not in the DB
                    res.MissingFiles.Add(databaseStorage[idxDb]);
                    idxDb++;
                }
            }

            //Leftovers after one of the lists is fully processed
            for (; idxFile < fileStorage.Count; idxFile++)
            {
                res.NewFiles.Add(fileStorage[idxFile]);
            }
            for (; idxDb < databaseStorage.Count; idxDb++)
            {
                res.MissingFiles.Add(databaseStorage[idxDb]);
            }

            res.RetrieveMissingTitleInfo();
            return(res);
        }