void btnUpdateAniDBLogin_Click(object sender, RoutedEventArgs e)
 {
     InitialSetupForm frm = new InitialSetupForm();
     frm.Owner = this;
     frm.ShowDialog();
 }
Exemplo n.º 2
0
		void workerSetupDB_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
		{
			bool setupComplete = bool.Parse(e.Result.ToString());
			if (setupComplete)
			{
				ServerInfo.Instance.RefreshImportFolders();
				ServerState.Instance.CurrentSetupStatus = "Complete!";
				ServerState.Instance.ServerOnline = true;

				tabControl1.SelectedIndex = 0;
			}
			else
			{
				ServerState.Instance.ServerOnline = false;
				if (string.IsNullOrEmpty(ServerSettings.DatabaseType))
				{
					ServerSettings.DatabaseType = "SQLite";
					ShowDatabaseSetup();
				}
			}

			btnSaveDatabaseSettings.IsEnabled = true;
			cboDatabaseType.IsEnabled = true;
			btnRefreshMSSQLServerList.IsEnabled = true;

			if (setupComplete)
			{
				if (string.IsNullOrEmpty(ServerSettings.AniDB_Username) || string.IsNullOrEmpty(ServerSettings.AniDB_Password))
				{
					InitialSetupForm frm = new InitialSetupForm();
					frm.Owner = this;
					frm.ShowDialog();
				}

				ImportFolderRepository repFolders = new ImportFolderRepository();
				List<ImportFolder> folders = repFolders.GetAll();
				if (folders.Count == 0)
				{
					tabControl1.SelectedIndex = 1;
				}
			}

		}
Exemplo n.º 3
0
        public bool Login()
        {
            // check if we are already logged in
            if (isLoggedOn) return true;

            if (!ValidAniDBCredentials()) return false;

            AniDBCommand_Login login = new AniDBCommand_Login();
            login.Init(userName, password);

            string msg = login.commandText.Replace(userName, "******");
            msg = msg.Replace(password, "******");
            logger.Trace("udp command: {0}", msg);
            SetWaitingOnResponse(true);
            enHelperActivityType ev = login.Process(ref soUdp, ref remoteIpEndPoint, curSessionID,
                new UnicodeEncoding(true, false));
            SetWaitingOnResponse(false);

            if (login.errorOccurred)
                logger.Trace("error in login: {0}", login.errorMessage);
            //else
            //	logger.Info("socketResponse: {0}", login.socketResponse);

            Thread.Sleep(2200);

            if (ev != enHelperActivityType.LoggedIn)
            {
                Application.Current.Dispatcher.Invoke(() => {
                    MessageBox.Show(Properties.Resources.InitialSetup_LoginFail, Properties.Resources.Error,
                        MessageBoxButton.OK, MessageBoxImage.Error);

                    InitialSetupForm frm = new InitialSetupForm();
                    frm.ShowDialog();
                });

                //BaseConfig.MyAnimeLog.Write("ProcessCommands: Login Failed!");
                //OnAniDBStatusEvent(new AniDBStatusEventArgs(enHelperActivityType.LoginFailed, ""));
                //aniDBCommands.Clear();
                //OnQueueUpdateEvent(new QueueUpdateEventArgs(this.QueueCount));
                // this will exit the thread
                return false;
            }
            else
            {
                curSessionID = login.SessionID;
                encoding = login.Encoding;
                this.isLoggedOn = true;
                this.IsInvalidSession = false;
                return true;
            }
        }