Beispiel #1
0
		private static void CreateImportFolders2()
		{
			logger.Debug("Creating shares...");
			ImportFolderRepository repNetShares = new ImportFolderRepository();

			ImportFolder sn = repNetShares.GetByImportLocation(@"F:\Anime1");
			if (sn == null)
			{
				sn = new ImportFolder();
				sn.ImportFolderType = (int)ImportFolderType.HDD;
				sn.ImportFolderName = "Anime1";
				sn.ImportFolderLocation = @"F:\Anime1";
				repNetShares.Save(sn);
			}

			sn = repNetShares.GetByImportLocation(@"H:\Anime2");
			if (sn == null)
			{
				sn = new ImportFolder();
				sn.ImportFolderType = (int)ImportFolderType.HDD;
				sn.ImportFolderName = "Anime2";
				sn.ImportFolderLocation = @"H:\Anime2";
				repNetShares.Save(sn);
			}

			sn = repNetShares.GetByImportLocation(@"G:\Anime3");
			if (sn == null)
			{
				sn = new ImportFolder();
				sn.ImportFolderType = (int)ImportFolderType.HDD;
				sn.ImportFolderName = "Anime3";
				sn.ImportFolderLocation = @"G:\Anime3";
				repNetShares.Save(sn);
			}

			logger.Debug("Creating shares complete!");
		}
Beispiel #2
0
		private static void CreateImportFolders_Test()
		{
			logger.Debug("Creating import folders...");
			ImportFolderRepository repImportFolders = new ImportFolderRepository();

			ImportFolder sn = repImportFolders.GetByImportLocation(@"M:\[ Anime Test ]");
			if (sn == null)
			{
				sn = new ImportFolder();
				sn.ImportFolderName = "Anime";
				sn.ImportFolderType = (int)ImportFolderType.HDD;
				sn.ImportFolderLocation = @"M:\[ Anime Test ]";
				repImportFolders.Save(sn);
			}

			logger.Debug("Complete!");
		}
Beispiel #3
0
		private static void CreateImportFolders()
		{
			logger.Debug("Creating shares...");
			ImportFolderRepository repNetShares = new ImportFolderRepository();

			ImportFolder sn = repNetShares.GetByImportLocation(@"M:\[ Anime 2011 ]");
			if (sn == null)
			{
				sn = new ImportFolder();
				sn.ImportFolderType = (int)ImportFolderType.HDD;
				sn.ImportFolderName = "Anime 2011";
				sn.ImportFolderLocation = @"M:\[ Anime 2011 ]";
				repNetShares.Save(sn);
			}

			sn = repNetShares.GetByImportLocation(@"M:\[ Anime - DVD and Bluray IN PROGRESS ]");
			if (sn == null)
			{
				sn = new ImportFolder();
				sn.ImportFolderType = (int)ImportFolderType.HDD;
				sn.ImportFolderName = "Anime - DVD and Bluray IN PROGRESS";
				sn.ImportFolderLocation = @"M:\[ Anime - DVD and Bluray IN PROGRESS ]";
				repNetShares.Save(sn);
			}

			sn = repNetShares.GetByImportLocation(@"M:\[ Anime - DVD and Bluray COMPLETE ]");
			if (sn == null)
			{
				sn = new ImportFolder();
				sn.ImportFolderType = (int)ImportFolderType.HDD;
				sn.ImportFolderName = "Anime - DVD and Bluray COMPLETE";
				sn.ImportFolderLocation = @"M:\[ Anime - DVD and Bluray COMPLETE ]";
				repNetShares.Save(sn);
			}

			sn = repNetShares.GetByImportLocation(@"M:\[ Anime ]");
			if (sn == null)
			{
				sn = new ImportFolder();
				sn.ImportFolderType = (int)ImportFolderType.HDD;
				sn.ImportFolderName = "Anime";
				sn.ImportFolderLocation = @"M:\[ Anime ]";
				repNetShares.Save(sn);
			}

			logger.Debug("Creating shares complete!");
		}
Beispiel #4
0
        public Contract_ImportFolder_SaveResponse SaveImportFolder(Contract_ImportFolder contract)
        {
            Contract_ImportFolder_SaveResponse response = new Contract_ImportFolder_SaveResponse();
            response.ErrorMessage = "";
            response.ImportFolder = null;

            try
            {

                ImportFolderRepository repNS = new ImportFolderRepository();
                ImportFolder ns = null;
                if (contract.ImportFolderID.HasValue)
                {
                    // update
                    ns = repNS.GetByID(contract.ImportFolderID.Value);
                    if (ns == null)
                    {
                        response.ErrorMessage = "Could not find Import Folder ID: " + contract.ImportFolderID.Value.ToString();
                        return response;
                    }
                }
                else
                {
                    // create
                    ns = new ImportFolder();
                }

                if (string.IsNullOrEmpty(contract.ImportFolderName))
                {
                    response.ErrorMessage = "Must specify an Import Folder name";
                    return response;
                }

                if (string.IsNullOrEmpty(contract.ImportFolderLocation))
                {
                    response.ErrorMessage = "Must specify an Import Folder location";
                    return response;
                }

                if (!Directory.Exists(contract.ImportFolderLocation))
                {
                    response.ErrorMessage = "Cannot find Import Folder location";
                    return response;
                }

                if (!contract.ImportFolderID.HasValue)
                {
                    ImportFolder nsTemp = repNS.GetByImportLocation(contract.ImportFolderLocation);
                    if (nsTemp != null)
                    {
                        response.ErrorMessage = "An entry already exists for the specified Import Folder location";
                        return response;
                    }
                }

                if (contract.IsDropDestination == 1 && contract.IsDropSource == 1)
                {
                    response.ErrorMessage = "A folder cannot be a drop source and a drop destination at the same time";
                    return response;
                }

                // check to make sure we don't have multiple drop folders
                List<ImportFolder> allFolders = repNS.GetAll();

                if (contract.IsDropDestination == 1)
                {
                    foreach (ImportFolder imf in allFolders)
                    {
                        if (imf.IsDropDestination == 1 && (!contract.ImportFolderID.HasValue || (contract.ImportFolderID.Value != imf.ImportFolderID)))
                        {
                            imf.IsDropDestination = 0;
                            repNS.Save(imf);
                        }
                    }
                }

                ns.ImportFolderName = contract.ImportFolderName;
                ns.ImportFolderLocation = contract.ImportFolderLocation;
                ns.IsDropDestination = contract.IsDropDestination;
                ns.IsDropSource = contract.IsDropSource;
                ns.IsWatched = contract.IsWatched;
                repNS.Save(ns);

                response.ImportFolder = ns.ToContract();

                MainWindow.StopWatchingFiles();
                MainWindow.StartWatchingFiles();

                return response;
            }
            catch (Exception ex)
            {
                logger.ErrorException(ex.ToString(), ex);
                response.ErrorMessage = ex.Message;
                return response;
            }
        }