Ejemplo n.º 1
0
		public static int UpdateAniDBFileData(bool missingInfo, bool outOfDate, bool countOnly)
		{
			List<int> vidsToUpdate = new List<int>();
			try
			{
				AniDB_FileRepository repFiles = new AniDB_FileRepository();
				VideoLocalRepository repVids = new VideoLocalRepository();

				if (missingInfo)
				{
					List<VideoLocal> vids = repVids.GetByAniDBResolution("0x0");

					foreach (VideoLocal vid in vids)
					{
						if (!vidsToUpdate.Contains(vid.VideoLocalID))
							vidsToUpdate.Add(vid.VideoLocalID);
					}
				}

				if (outOfDate)
				{
					List<VideoLocal> vids = repVids.GetByInternalVersion(1);

					foreach (VideoLocal vid in vids)
					{
						if (!vidsToUpdate.Contains(vid.VideoLocalID))
							vidsToUpdate.Add(vid.VideoLocalID);
					}
				}

				if (!countOnly)
				{
					foreach (int id in vidsToUpdate)
					{
						CommandRequest_GetFile cmd = new CommandRequest_GetFile(id, true);
						cmd.Save();
					}
				}
			}
			catch (Exception ex)
			{
				logger.ErrorException(ex.ToString(), ex);
			}

			return vidsToUpdate.Count;
		}