public Contract_ServerSettings GetServerSettings()
		{
			Contract_ServerSettings contract = new Contract_ServerSettings();

			try
			{
				return ServerSettings.ToContract();
			}
			catch (Exception ex)
			{
				logger.ErrorException(ex.ToString(), ex);
			}
			return contract;
		}
Beispiel #2
0
        public Contract_ServerSettings_SaveResponse SaveServerSettings(Contract_ServerSettings contractIn)
        {
            Contract_ServerSettings_SaveResponse contract = new Contract_ServerSettings_SaveResponse();
            contract.ErrorMessage = "";

            try
            {
                // validate the settings
                bool anidbSettingsChanged = false;
                if (contractIn.AniDB_ClientPort != ServerSettings.AniDB_ClientPort)
                {
                    anidbSettingsChanged = true;
                    int cport = 0;
                    int.TryParse(contractIn.AniDB_ClientPort, out cport);
                    if (cport <= 0)
                    {
                        contract.ErrorMessage = "AniDB Client Port must be numeric and greater than 0" + Environment.NewLine;
                    }
                }

                if (contractIn.AniDB_ServerPort != ServerSettings.AniDB_ServerPort)
                {
                    anidbSettingsChanged = true;
                    int sport = 0;
                    int.TryParse(contractIn.AniDB_ServerPort, out sport);
                    if (sport <= 0)
                    {
                        contract.ErrorMessage = "AniDB Server Port must be numeric and greater than 0" + Environment.NewLine;
                    }
                }

                if (contractIn.AniDB_Username != ServerSettings.AniDB_Username)
                {
                    anidbSettingsChanged = true;
                    if (string.IsNullOrEmpty(contractIn.AniDB_Username))
                    {
                        contract.ErrorMessage = "AniDB User Name must have a value" + Environment.NewLine;
                    }
                }

                if (contractIn.AniDB_Password != ServerSettings.AniDB_Password)
                {
                    anidbSettingsChanged = true;
                    if (string.IsNullOrEmpty(contractIn.AniDB_Password))
                    {
                        contract.ErrorMessage = "AniDB Password must have a value" + Environment.NewLine;
                    }
                }

                if (contractIn.AniDB_ServerAddress != ServerSettings.AniDB_ServerAddress)
                {
                    anidbSettingsChanged = true;
                    if (string.IsNullOrEmpty(contractIn.AniDB_ServerAddress))
                    {
                        contract.ErrorMessage = "AniDB Server Address must have a value" + Environment.NewLine;
                    }
                }

                if (contract.ErrorMessage.Length > 0) return contract;

                ServerSettings.AniDB_ClientPort = contractIn.AniDB_ClientPort;
                ServerSettings.AniDB_Password = contractIn.AniDB_Password;
                ServerSettings.AniDB_ServerAddress = contractIn.AniDB_ServerAddress;
                ServerSettings.AniDB_ServerPort = contractIn.AniDB_ServerPort;
                ServerSettings.AniDB_Username = contractIn.AniDB_Username;
                ServerSettings.AniDB_AVDumpClientPort = contractIn.AniDB_AVDumpClientPort;
                ServerSettings.AniDB_AVDumpKey = contractIn.AniDB_AVDumpKey;

                ServerSettings.AniDB_DownloadRelatedAnime = contractIn.AniDB_DownloadRelatedAnime;
                ServerSettings.AniDB_DownloadReleaseGroups = contractIn.AniDB_DownloadReleaseGroups;
                ServerSettings.AniDB_DownloadReviews = contractIn.AniDB_DownloadReviews;
                ServerSettings.AniDB_DownloadSimilarAnime = contractIn.AniDB_DownloadSimilarAnime;

                ServerSettings.AniDB_MyList_AddFiles = contractIn.AniDB_MyList_AddFiles;
                ServerSettings.AniDB_MyList_ReadUnwatched = contractIn.AniDB_MyList_ReadUnwatched;
                ServerSettings.AniDB_MyList_ReadWatched = contractIn.AniDB_MyList_ReadWatched;
                ServerSettings.AniDB_MyList_SetUnwatched = contractIn.AniDB_MyList_SetUnwatched;
                ServerSettings.AniDB_MyList_SetWatched = contractIn.AniDB_MyList_SetWatched;
                ServerSettings.AniDB_MyList_StorageState = (AniDBFileStatus)contractIn.AniDB_MyList_StorageState;
                ServerSettings.AniDB_MyList_DeleteType = (AniDBFileDeleteType)contractIn.AniDB_MyList_DeleteType;

                ServerSettings.AniDB_MyList_UpdateFrequency = (ScheduledUpdateFrequency)contractIn.AniDB_MyList_UpdateFrequency;
                ServerSettings.AniDB_Calendar_UpdateFrequency = (ScheduledUpdateFrequency)contractIn.AniDB_Calendar_UpdateFrequency;
                ServerSettings.AniDB_Anime_UpdateFrequency = (ScheduledUpdateFrequency)contractIn.AniDB_Anime_UpdateFrequency;
                ServerSettings.AniDB_MyListStats_UpdateFrequency = (ScheduledUpdateFrequency)contractIn.AniDB_MyListStats_UpdateFrequency;
                ServerSettings.AniDB_File_UpdateFrequency = (ScheduledUpdateFrequency)contractIn.AniDB_File_UpdateFrequency;

                ServerSettings.AniDB_DownloadCharacters = contractIn.AniDB_DownloadCharacters;
                ServerSettings.AniDB_DownloadCreators = contractIn.AniDB_DownloadCreators;

                // Web Cache
                ServerSettings.WebCache_Address = contractIn.WebCache_Address;
                ServerSettings.WebCache_Anonymous = contractIn.WebCache_Anonymous;
                ServerSettings.WebCache_XRefFileEpisode_Get = contractIn.WebCache_XRefFileEpisode_Get;
                ServerSettings.WebCache_XRefFileEpisode_Send = contractIn.WebCache_XRefFileEpisode_Send;
                ServerSettings.WebCache_TvDB_Get = contractIn.WebCache_TvDB_Get;
                ServerSettings.WebCache_TvDB_Send = contractIn.WebCache_TvDB_Send;
                ServerSettings.WebCache_Trakt_Get = contractIn.WebCache_Trakt_Get;
                ServerSettings.WebCache_Trakt_Send = contractIn.WebCache_Trakt_Send;
                ServerSettings.WebCache_MAL_Get = contractIn.WebCache_MAL_Get;
                ServerSettings.WebCache_MAL_Send = contractIn.WebCache_MAL_Send;
                ServerSettings.WebCache_UserInfo = contractIn.WebCache_UserInfo;

                // TvDB
                ServerSettings.TvDB_AutoFanart = contractIn.TvDB_AutoFanart;
                ServerSettings.TvDB_AutoFanartAmount = contractIn.TvDB_AutoFanartAmount;
                ServerSettings.TvDB_AutoPosters = contractIn.TvDB_AutoPosters;
                ServerSettings.TvDB_AutoPostersAmount = contractIn.TvDB_AutoPostersAmount;
                ServerSettings.TvDB_AutoWideBanners = contractIn.TvDB_AutoWideBanners;
                ServerSettings.TvDB_AutoWideBannersAmount = contractIn.TvDB_AutoWideBannersAmount;
                ServerSettings.TvDB_UpdateFrequency = (ScheduledUpdateFrequency)contractIn.TvDB_UpdateFrequency;
                ServerSettings.TvDB_Language = contractIn.TvDB_Language;

                // MovieDB
                ServerSettings.MovieDB_AutoFanart = contractIn.MovieDB_AutoFanart;
                ServerSettings.MovieDB_AutoFanartAmount = contractIn.MovieDB_AutoFanartAmount;
                ServerSettings.MovieDB_AutoPosters = contractIn.MovieDB_AutoPosters;
                ServerSettings.MovieDB_AutoPostersAmount = contractIn.MovieDB_AutoPostersAmount;

                // Import settings
                ServerSettings.VideoExtensions = contractIn.VideoExtensions;
                ServerSettings.Import_UseExistingFileWatchedStatus = contractIn.Import_UseExistingFileWatchedStatus;
                ServerSettings.AutoGroupSeries = contractIn.AutoGroupSeries;
                ServerSettings.RunImportOnStart = contractIn.RunImportOnStart;
                ServerSettings.ScanDropFoldersOnStart = contractIn.ScanDropFoldersOnStart;
                ServerSettings.Hash_CRC32 = contractIn.Hash_CRC32;
                ServerSettings.Hash_MD5 = contractIn.Hash_MD5;
                ServerSettings.Hash_SHA1 = contractIn.Hash_SHA1;

                // Language
                ServerSettings.LanguagePreference = contractIn.LanguagePreference;
                ServerSettings.LanguageUseSynonyms = contractIn.LanguageUseSynonyms;
                ServerSettings.EpisodeTitleSource = (DataSourceType)contractIn.EpisodeTitleSource;
                ServerSettings.SeriesDescriptionSource = (DataSourceType)contractIn.SeriesDescriptionSource;
                ServerSettings.SeriesNameSource = (DataSourceType)contractIn.SeriesNameSource;

                // Trakt
                ServerSettings.Trakt_IsEnabled = contractIn.Trakt_IsEnabled;
                ServerSettings.Trakt_AuthToken = contractIn.Trakt_AuthToken;
                ServerSettings.Trakt_RefreshToken = contractIn.Trakt_RefreshToken;
                ServerSettings.Trakt_TokenExpirationDate = contractIn.Trakt_TokenExpirationDate;
                ServerSettings.Trakt_UpdateFrequency = (ScheduledUpdateFrequency)contractIn.Trakt_UpdateFrequency;
                ServerSettings.Trakt_SyncFrequency = (ScheduledUpdateFrequency)contractIn.Trakt_SyncFrequency;
                ServerSettings.Trakt_DownloadEpisodes = contractIn.Trakt_DownloadEpisodes;
                ServerSettings.Trakt_DownloadFanart = contractIn.Trakt_DownloadFanart;
                ServerSettings.Trakt_DownloadPosters = contractIn.Trakt_DownloadPosters;

                // MAL
                ServerSettings.MAL_Username = contractIn.MAL_Username;
                ServerSettings.MAL_Password = contractIn.MAL_Password;
                ServerSettings.MAL_UpdateFrequency = (ScheduledUpdateFrequency)contractIn.MAL_UpdateFrequency;
                ServerSettings.MAL_NeverDecreaseWatchedNums = contractIn.MAL_NeverDecreaseWatchedNums;

                if (anidbSettingsChanged)
                {
                    JMMService.AnidbProcessor.ForceLogout();
                    JMMService.AnidbProcessor.CloseConnections();

                    Thread.Sleep(1000);
                    JMMService.AnidbProcessor.Init(ServerSettings.AniDB_Username, ServerSettings.AniDB_Password, ServerSettings.AniDB_ServerAddress,
                    ServerSettings.AniDB_ServerPort, ServerSettings.AniDB_ClientPort);
                }

            }
            catch (Exception ex)
            {
                contract.ErrorMessage = ex.Message;
                logger.ErrorException(ex.ToString(), ex);
            }
            return contract;
        }
Beispiel #3
0
        public static Contract_ServerSettings ToContract()
        {
            Contract_ServerSettings contract = new Contract_ServerSettings();

            contract.AniDB_Username = ServerSettings.AniDB_Username;
            contract.AniDB_Password = ServerSettings.AniDB_Password;
            contract.AniDB_ServerAddress = ServerSettings.AniDB_ServerAddress;
            contract.AniDB_ServerPort = ServerSettings.AniDB_ServerPort;
            contract.AniDB_ClientPort = ServerSettings.AniDB_ClientPort;
            contract.AniDB_AVDumpClientPort = ServerSettings.AniDB_AVDumpClientPort;
            contract.AniDB_AVDumpKey = ServerSettings.AniDB_AVDumpKey;

            contract.AniDB_DownloadRelatedAnime = ServerSettings.AniDB_DownloadRelatedAnime;
            contract.AniDB_DownloadSimilarAnime = ServerSettings.AniDB_DownloadSimilarAnime;
            contract.AniDB_DownloadReviews = ServerSettings.AniDB_DownloadReviews;
            contract.AniDB_DownloadReleaseGroups = ServerSettings.AniDB_DownloadReleaseGroups;

            contract.AniDB_MyList_AddFiles = ServerSettings.AniDB_MyList_AddFiles;
            contract.AniDB_MyList_StorageState = (int)ServerSettings.AniDB_MyList_StorageState;
            contract.AniDB_MyList_DeleteType = (int)ServerSettings.AniDB_MyList_DeleteType;
            contract.AniDB_MyList_ReadWatched = ServerSettings.AniDB_MyList_ReadWatched;
            contract.AniDB_MyList_ReadUnwatched = ServerSettings.AniDB_MyList_ReadUnwatched;
            contract.AniDB_MyList_SetWatched = ServerSettings.AniDB_MyList_SetWatched;
            contract.AniDB_MyList_SetUnwatched = ServerSettings.AniDB_MyList_SetUnwatched;

            contract.AniDB_MyList_UpdateFrequency = (int)ServerSettings.AniDB_MyList_UpdateFrequency;
            contract.AniDB_Calendar_UpdateFrequency = (int)ServerSettings.AniDB_Calendar_UpdateFrequency;
            contract.AniDB_Anime_UpdateFrequency = (int)ServerSettings.AniDB_Anime_UpdateFrequency;
            contract.AniDB_MyListStats_UpdateFrequency = (int)ServerSettings.AniDB_MyListStats_UpdateFrequency;
            contract.AniDB_File_UpdateFrequency = (int)ServerSettings.AniDB_File_UpdateFrequency;

            contract.AniDB_DownloadCharacters = ServerSettings.AniDB_DownloadCharacters;
            contract.AniDB_DownloadCreators = ServerSettings.AniDB_DownloadCreators;

            // Web Cache
            contract.WebCache_Address = ServerSettings.WebCache_Address;
            contract.WebCache_Anonymous = ServerSettings.WebCache_Anonymous;
            contract.WebCache_XRefFileEpisode_Get = ServerSettings.WebCache_XRefFileEpisode_Get;
            contract.WebCache_XRefFileEpisode_Send = ServerSettings.WebCache_XRefFileEpisode_Send;
            contract.WebCache_TvDB_Get = ServerSettings.WebCache_TvDB_Get;
            contract.WebCache_TvDB_Send = ServerSettings.WebCache_TvDB_Send;
            contract.WebCache_Trakt_Get = ServerSettings.WebCache_Trakt_Get;
            contract.WebCache_Trakt_Send = ServerSettings.WebCache_Trakt_Send;
            contract.WebCache_MAL_Get = ServerSettings.WebCache_MAL_Get;
            contract.WebCache_MAL_Send = ServerSettings.WebCache_MAL_Send;
            contract.WebCache_UserInfo = ServerSettings.WebCache_UserInfo;

            // TvDB
            contract.TvDB_AutoFanart = ServerSettings.TvDB_AutoFanart;
            contract.TvDB_AutoFanartAmount = ServerSettings.TvDB_AutoFanartAmount;
            contract.TvDB_AutoPosters = ServerSettings.TvDB_AutoPosters;
            contract.TvDB_AutoPostersAmount = ServerSettings.TvDB_AutoPostersAmount;
            contract.TvDB_AutoWideBanners = ServerSettings.TvDB_AutoWideBanners;
            contract.TvDB_AutoWideBannersAmount = ServerSettings.TvDB_AutoWideBannersAmount;
            contract.TvDB_UpdateFrequency = (int)ServerSettings.TvDB_UpdateFrequency;
            contract.TvDB_Language = ServerSettings.TvDB_Language;

            // MovieDB
            contract.MovieDB_AutoFanart = ServerSettings.MovieDB_AutoFanart;
            contract.MovieDB_AutoFanartAmount = ServerSettings.MovieDB_AutoFanartAmount;
            contract.MovieDB_AutoPosters = ServerSettings.MovieDB_AutoPosters;
            contract.MovieDB_AutoPostersAmount = ServerSettings.MovieDB_AutoPostersAmount;

            // Import settings
            contract.VideoExtensions = ServerSettings.VideoExtensions;
            contract.AutoGroupSeries = ServerSettings.AutoGroupSeries;
            contract.Import_UseExistingFileWatchedStatus = ServerSettings.Import_UseExistingFileWatchedStatus;
            contract.RunImportOnStart = ServerSettings.RunImportOnStart;
            contract.ScanDropFoldersOnStart = ServerSettings.ScanDropFoldersOnStart;
            contract.Hash_CRC32 = ServerSettings.Hash_CRC32;
            contract.Hash_MD5 = ServerSettings.Hash_MD5;
            contract.Hash_SHA1 = ServerSettings.Hash_SHA1;

            // Language
            contract.LanguagePreference = ServerSettings.LanguagePreference;
            contract.LanguageUseSynonyms = ServerSettings.LanguageUseSynonyms;
            contract.EpisodeTitleSource = (int)ServerSettings.EpisodeTitleSource;
            contract.SeriesDescriptionSource = (int)ServerSettings.SeriesDescriptionSource;
            contract.SeriesNameSource = (int)ServerSettings.SeriesNameSource;

            // trakt
            contract.Trakt_IsEnabled = ServerSettings.Trakt_IsEnabled;
            contract.Trakt_AuthToken = ServerSettings.Trakt_AuthToken;
            contract.Trakt_RefreshToken = ServerSettings.Trakt_RefreshToken;
            contract.Trakt_TokenExpirationDate = ServerSettings.Trakt_TokenExpirationDate;
            contract.Trakt_UpdateFrequency = (int)ServerSettings.Trakt_UpdateFrequency;
            contract.Trakt_SyncFrequency = (int)ServerSettings.Trakt_SyncFrequency;
            contract.Trakt_DownloadEpisodes = ServerSettings.Trakt_DownloadEpisodes;
            contract.Trakt_DownloadFanart = ServerSettings.Trakt_DownloadFanart;
            contract.Trakt_DownloadPosters = ServerSettings.Trakt_DownloadPosters;

            // MAL
            contract.MAL_Username = ServerSettings.MAL_Username;
            contract.MAL_Password = ServerSettings.MAL_Password;
            contract.MAL_UpdateFrequency = (int)ServerSettings.MAL_UpdateFrequency;
            contract.MAL_NeverDecreaseWatchedNums = ServerSettings.MAL_NeverDecreaseWatchedNums;

            return contract;
        }