public void InitEpisode(int entityid, int epno, decimal votevalue, enEpisodeType epType)
        {
            // allow the user to enter a vote value between 1 and 10
            // can be 9.5 etc
            // then multiple by 100 to get anidb value

            // type: 1=anime, 2=anime tmpvote, 3=group
            // entity: anime, episode, or group
            // for episode voting add epno on type=1
            // value: negative number means revoke, 0 means retrieve (default), 100-1000 are valid vote values, rest is illegal
            // votes will be updated automatically (no questions asked)
            // tmpvoting when there exist a perm vote is not possible

            this.entityID      = entityid;
            this.episodeNumber = epno;
            if (votevalue > 0)
            {
                this.voteValue = (int)(votevalue * 100);
            }
            else
            {
                this.voteValue = (int)votevalue;
            }
            this.voteType    = enAniDBVoteType.Episode;
            this.episodeType = epType;

            commandID = entityID.ToString();

            int iVoteType = 1;

            string epNumberFormatted = episodeNumber.ToString();

            switch (epType)
            {
            case enEpisodeType.Credits:
                epNumberFormatted = "C" + epno.ToString();
                break;

            case enEpisodeType.Special:
                epNumberFormatted = "S" + epno.ToString();
                break;

            case enEpisodeType.Other:
                epNumberFormatted = "0" + epno.ToString();
                break;

            case enEpisodeType.Trailer:
                epNumberFormatted = "T" + epno.ToString();
                break;

            case enEpisodeType.Parody:
                epNumberFormatted = "P" + epno.ToString();
                break;
            }

            commandText  = "VOTE type=" + iVoteType.ToString();
            commandText += "&id=" + entityID.ToString();
            commandText += "&value=" + voteValue.ToString();
            commandText += "&epno=" + epNumberFormatted;
        }
Beispiel #2
0
        public bool VoteAnime(int animeID, decimal voteValue, enAniDBVoteType voteType)
        {
            if (!Login())
            {
                return(false);
            }

            enHelperActivityType ev      = enHelperActivityType.NoSuchVote;
            AniDBCommand_Vote    cmdVote = null;

            AniDB_VoteRepository repVotes = new AniDB_VoteRepository();

            lock (lockAniDBConnections)
            {
                Pause();

                cmdVote = new AniDBCommand_Vote();
                cmdVote.Init(animeID, voteValue, voteType);
                SetWaitingOnResponse(true);
                ev = cmdVote.Process(ref soUdp, ref remoteIpEndPoint, curSessionID, new UnicodeEncoding(true, false));
                SetWaitingOnResponse(false);
                if (ev == enHelperActivityType.Voted || ev == enHelperActivityType.VoteUpdated)
                {
                    List <AniDB_Vote> dbVotes  = repVotes.GetByEntity(cmdVote.EntityID);
                    AniDB_Vote        thisVote = null;
                    foreach (AniDB_Vote dbVote in dbVotes)
                    {
                        // we can only have anime permanent or anime temp but not both
                        if (cmdVote.VoteType == enAniDBVoteType.Anime || cmdVote.VoteType == enAniDBVoteType.AnimeTemp)
                        {
                            if (dbVote.VoteType == (int)enAniDBVoteType.Anime || dbVote.VoteType == (int)enAniDBVoteType.AnimeTemp)
                            {
                                thisVote = dbVote;
                            }
                        }
                        else
                        {
                            thisVote = dbVote;
                        }
                    }

                    if (thisVote == null)
                    {
                        thisVote          = new AniDB_Vote();
                        thisVote.EntityID = cmdVote.EntityID;
                    }
                    thisVote.VoteType  = (int)cmdVote.VoteType;
                    thisVote.VoteValue = cmdVote.VoteValue;
                    repVotes.Save(thisVote);
                }
            }

            return(false);
        }
        public void Init(int entityid, decimal votevalue, enAniDBVoteType votetype)
        {
            // allow the user to enter a vote value between 1 and 10
            // can be 9.5 etc
            // then multiple by 100 to get anidb value

            // type: 1=anime, 2=anime tmpvote, 3=group
            // entity: anime, episode, or group
            // for episode voting add epno on type=1
            // value: negative number means revoke, 0 means retrieve (default), 100-1000 are valid vote values, rest is illegal
            // votes will be updated automatically (no questions asked)
            // tmpvoting when there exist a perm vote is not possible

            this.entityID      = entityid;
            this.episodeNumber = -1;
            if (votevalue > 0)
            {
                this.voteValue = (int)(votevalue * 100);
            }
            else
            {
                this.voteValue = (int)votevalue;
            }
            this.voteType    = votetype;
            this.episodeType = enEpisodeType.Episode;

            commandID = entityID.ToString();

            int iVoteType = 1;

            switch (voteType)
            {
            case enAniDBVoteType.Anime:
                iVoteType = 1;
                break;

            case enAniDBVoteType.AnimeTemp:
                iVoteType = 2;
                break;

            case enAniDBVoteType.Group:
                iVoteType = 3;
                break;

            case enAniDBVoteType.Episode:
                iVoteType = 1;
                break;
            }

            commandText  = "VOTE type=" + iVoteType.ToString();
            commandText += "&id=" + entityID.ToString();
            commandText += "&value=" + voteValue.ToString();
        }
Beispiel #4
0
		public void ProcessEpisode(XmlNode node)
		{
			NumberStyles style = NumberStyles.Number;
			CultureInfo culture = CultureInfo.CreateSpecificCulture("en-GB");

			this.VoteType = enAniDBVoteType.Episode;
			this.EntityID = int.Parse(node.Attributes["eid"].Value);
			double val = 0;
			double.TryParse(node.InnerText.Trim(), style, culture, out val);
			int ival = 0;
			int.TryParse((val * (double)100).ToString(), out ival);
			VoteValue = ival;
		}
        public void ProcessEpisode(XmlNode node)
        {
            NumberStyles style   = NumberStyles.Number;
            CultureInfo  culture = CultureInfo.CreateSpecificCulture("en-GB");

            this.VoteType = enAniDBVoteType.Episode;
            this.EntityID = int.Parse(node.Attributes["eid"].Value);
            double val = 0;

            double.TryParse(node.InnerText.Trim(), style, culture, out val);
            int ival = 0;

            int.TryParse((val * (double)100).ToString(), out ival);
            VoteValue = ival;
        }
        public void Init(int entityid, decimal votevalue, enAniDBVoteType votetype)
        {
            // allow the user to enter a vote value between 1 and 10
            // can be 9.5 etc
            // then multiple by 100 to get anidb value

            // type: 1=anime, 2=anime tmpvote, 3=group
            // entity: anime, episode, or group
            // for episode voting add epno on type=1
            // value: negative number means revoke, 0 means retrieve (default), 100-1000 are valid vote values, rest is illegal
            // votes will be updated automatically (no questions asked)
            // tmpvoting when there exist a perm vote is not possible

            this.entityID = entityid;
            this.episodeNumber = -1;
            if (votevalue > 0)
                this.voteValue = (int) (votevalue*100);
            else
                this.voteValue = (int) votevalue;
            this.voteType = votetype;
            this.episodeType = enEpisodeType.Episode;

            commandID = entityID.ToString();

            int iVoteType = 1;
            switch (voteType)
            {
                case enAniDBVoteType.Anime:
                    iVoteType = 1;
                    break;
                case enAniDBVoteType.AnimeTemp:
                    iVoteType = 2;
                    break;
                case enAniDBVoteType.Group:
                    iVoteType = 3;
                    break;
                case enAniDBVoteType.Episode:
                    iVoteType = 1;
                    break;
            }

            commandText = "VOTE type=" + iVoteType.ToString();
            commandText += "&id=" + entityID.ToString();
            commandText += "&value=" + voteValue.ToString();
        }
        // constructor
        // sRecMessage is the message received from ANIDB file info command
        public void ProcessVoteFoundAnime(string sRecMessage, int animeID, enAniDBVoteType vtype)
        {
            // remove the header info
            string[] sDetails = sRecMessage.Substring(15).Split('|');

            // 261 VOTE FOUNDCode Geass Hangyaku no Lelouch|900|1|4521

            // 261 VOTE FOUND
            // 0. Code Geass Hangyaku no Lelouch
            // 1. 900 ** vote value
            // 2. 1 ** vote type
            // 3. 4521 ** animeid

            this.EntityID = animeID;
            this.EpisodeNumber = -1;
            this.VoteValue = int.Parse(sDetails[1].Trim());
            this.VoteType = (int) vtype;
            this.EpisodeType = (int) enEpisodeType.Episode;
        }
Beispiel #8
0
        // constructor
        // sRecMessage is the message received from ANIDB file info command


        public void ProcessVoteFoundAnime(string sRecMessage, int animeID, enAniDBVoteType vtype)
        {
            // remove the header info
            string[] sDetails = sRecMessage.Substring(15).Split('|');

            // 261 VOTE FOUNDCode Geass Hangyaku no Lelouch|900|1|4521


            // 261 VOTE FOUND
            // 0. Code Geass Hangyaku no Lelouch
            // 1. 900 ** vote value
            // 2. 1 ** vote type
            // 3. 4521 ** animeid

            this.EntityID      = animeID;
            this.EpisodeNumber = -1;
            this.VoteValue     = int.Parse(sDetails[1].Trim());
            this.VoteType      = (int)vtype;
            this.EpisodeType   = (int)enEpisodeType.Episode;
        }
Beispiel #9
0
 public void VoteAnimeRevoke(int animeID, enAniDBVoteType voteType)
 {
     VoteAnime(animeID, -1, voteType);
 }
 public Raw_AniDB_Vote_HTTP()
 {
     EntityID  = -1;
     VoteValue = -1;
     VoteType  = enAniDBVoteType.Anime;
 }
Beispiel #11
0
		public void InitEpisode(int entityid, int epno, decimal votevalue, enEpisodeType epType)
		{
			// allow the user to enter a vote value between 1 and 10
			// can be 9.5 etc
			// then multiple by 100 to get anidb value

			// type: 1=anime, 2=anime tmpvote, 3=group
			// entity: anime, episode, or group
			// for episode voting add epno on type=1
			// value: negative number means revoke, 0 means retrieve (default), 100-1000 are valid vote values, rest is illegal
			// votes will be updated automatically (no questions asked)
			// tmpvoting when there exist a perm vote is not possible

			this.entityID = entityid;
			this.episodeNumber = epno;
			if (votevalue > 0)
				this.voteValue = (int)(votevalue * 100);
			else
				this.voteValue = (int)votevalue;
			this.voteType = enAniDBVoteType.Episode;
			this.episodeType = epType;

			commandID = entityID.ToString();

			int iVoteType = 1;

			string epNumberFormatted = episodeNumber.ToString();
			switch (epType)
			{
				case enEpisodeType.Credits: epNumberFormatted = "C" + epno.ToString(); break;
				case enEpisodeType.Special: epNumberFormatted = "S" + epno.ToString(); break;
				case enEpisodeType.Other: epNumberFormatted = "0" + epno.ToString(); break;
				case enEpisodeType.Trailer: epNumberFormatted = "T" + epno.ToString(); break;
				case enEpisodeType.Parody: epNumberFormatted = "P" + epno.ToString(); break;
			}

			commandText = "VOTE type=" + iVoteType.ToString();
			commandText += "&id=" + entityID.ToString();
			commandText += "&value=" + voteValue.ToString();
			commandText += "&epno=" + epNumberFormatted;
		}
Beispiel #12
0
		public bool VoteAnime(int animeID, decimal voteValue, enAniDBVoteType voteType)
		{
			if (!Login()) return false;

			enHelperActivityType ev = enHelperActivityType.NoSuchVote;
			AniDBCommand_Vote cmdVote = null;

			AniDB_VoteRepository repVotes = new AniDB_VoteRepository();

			lock (lockAniDBConnections)
			{
				Pause();

				cmdVote = new AniDBCommand_Vote();
				cmdVote.Init(animeID, voteValue, voteType);
				SetWaitingOnResponse(true);
				ev = cmdVote.Process(ref soUdp, ref remoteIpEndPoint, curSessionID, new UnicodeEncoding(true, false));
				SetWaitingOnResponse(false);
				if (ev == enHelperActivityType.Voted || ev == enHelperActivityType.VoteUpdated)
				{
					List<AniDB_Vote> dbVotes = repVotes.GetByEntity(cmdVote.EntityID);
					AniDB_Vote thisVote = null;
					foreach (AniDB_Vote dbVote in dbVotes)
					{
						// we can only have anime permanent or anime temp but not both
						if (cmdVote.VoteType == enAniDBVoteType.Anime || cmdVote.VoteType == enAniDBVoteType.AnimeTemp)
						{
							if (dbVote.VoteType == (int)enAniDBVoteType.Anime || dbVote.VoteType == (int)enAniDBVoteType.AnimeTemp)
							{
								thisVote = dbVote;
							}
						}
						else
						{
							thisVote = dbVote;
						}
					}

					if (thisVote == null)
					{
						thisVote = new AniDB_Vote();
						thisVote.EntityID = cmdVote.EntityID;
					}
					thisVote.VoteType = (int)cmdVote.VoteType;
					thisVote.VoteValue = cmdVote.VoteValue;
					repVotes.Save(thisVote);
				}
			}

			return false;
		}
Beispiel #13
0
		public void VoteAnimeRevoke(int animeID, enAniDBVoteType voteType)
		{
			VoteAnime(animeID, -1, voteType);
		}
Beispiel #14
0
		public Raw_AniDB_Vote_HTTP()
		{
			EntityID = -1;
			VoteValue = -1;
			VoteType = enAniDBVoteType.Anime;
		}