Ejemplo n.º 1
0
        public ActionResult Calculate(RatingType ratingType = RatingType.Universal)
        {
            var setRatingViewModel = new SetRatingViewModel
            {
                Questions   = _mapper.Map <IEnumerable <QuestionViewModel> >(_ratingService.GetQuestions(ratingType)),
                RatingType  = ratingType.ToString(),
                RaitngTypes = GetRatings()
            };

            return(View("Create", setRatingViewModel));
        }
Ejemplo n.º 2
0
        public ActionResult Index(RatingType ratingType = RatingType.Universal, int?top = null)
        {
            var ratingsStatistic = _ratingService.GetResults(ratingType, top);

            var statisticViewModel = new StatisticsViewModel
            {
                RatingType  = ratingType.ToString(),
                Ratings     = _mapper.Map <IEnumerable <RatingViewModel> >(ratingsStatistic),
                RaitngTypes = GetRatings()
            };

            return(View(statisticViewModel));
        }
Ejemplo n.º 3
0
        static public bool SubmitRating(RatingType type, string itemId, int rating)
        {
            string account = DBOption.GetOptions(DBOption.cOnlineUserID);

            if (String.IsNullOrEmpty(account))
            {
                string[] lines = new string[] { Translation.TVDB_INFO_ACCOUNTID_1, Translation.TVDB_INFO_ACCOUNTID_2 };
                //TVSeriesPlugin.ShowDialogOk(Translation.TVDB_INFO_TITLE, lines); //trakt.tv also listens to this, also can store ratings locally.
                MPTVSeriesLog.Write("Cannot submit rating to thetvdb.com, this requires your Account Identifier to be set.");
                return(false);
            }

            if (itemId == "0" || rating < 0 || rating > 10)
            {
                MPTVSeriesLog.Write("Cannot submit rating, invalid values...this is most likely a programming error");
                return(false);
            }

            if (!DBOnlineMirror.IsMirrorsAvailable)
            {
                // Server maybe available now.
                DBOnlineMirror.Init();
                if (!DBOnlineMirror.IsMirrorsAvailable)
                {
                    GUIDialogOK dlgOK = ( GUIDialogOK )GUIWindowManager.GetWindow(( int )GUIWindow.Window.WINDOW_DIALOG_OK);
                    dlgOK.SetHeading(Translation.TVDB_ERROR_TITLE);
                    if (!TVSeriesPlugin.IsNetworkAvailable)
                    {
                        string[] lines = new string[] { Translation.NETWORK_ERROR_UNAVAILABLE_1, Translation.NETWORK_ERROR_UNAVAILABLE_2 };
                        TVSeriesPlugin.ShowDialogOk(Translation.TVDB_ERROR_TITLE, lines);
                    }
                    else
                    {
                        string[] lines = new string[] { Translation.TVDB_ERROR_UNAVAILABLE_1, Translation.TVDB_ERROR_UNAVAILABLE_2 };
                        TVSeriesPlugin.ShowDialogOk(Translation.TVDB_ERROR_TITLE, lines);
                    }

                    MPTVSeriesLog.Write("Cannot submit rating, the online database is unavailable");
                    return(false);
                }
            }
            // ok we're good
            MPTVSeriesLog.Write(string.Format("Submitting Rating of {2} for {0} {1}", type.ToString(), itemId, rating), MPTVSeriesLog.LogLevel.Debug);
            Generic(string.Format(apiURIs.SubmitRating, account, type.ToString(), itemId, rating), true, false, Format.NoExtension);
            return(true);
        }
Ejemplo n.º 4
0
        // http://stackoverflow.com/q/424366
        /// <summary>
        /// Gets the link to avatar by Gravatar.
        /// </summary>
        /// <param name="content">The content (email).</param>
        /// <param name="size">The size of avatar.</param>
        /// <param name="ratingType">Type of the rating.</param>
        /// <param name="defaultImage">The type of default image.</param>
        /// <returns></returns>
        /// <exception cref="System.ArgumentNullException">content</exception>
        /// <exception cref="System.ArgumentOutOfRangeException">size;The image size should be between 1 and 2048</exception>
        public static string Get(string content, int size = 80, RatingType ratingType = RatingType.PG, DefaultImage defaultImage = DefaultImage.MM)
        {
            if (content == null)
            {
                throw new ArgumentNullException("content");
            }

            if (size < 1 | size > 2048)
            {
                throw new ArgumentOutOfRangeException("size",
                                                      "The image size should be between 1 and 2048");
            }

            return(String.Format("{0}?gravatar_id={1}&s={2}&r={3}&d={4}",
                                 Url,
                                 MD5.GetHashString(content.ToLower()),
                                 size,
                                 ratingType.ToString("G"),
                                 defaultImage.ToString("G")).ToLower());
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Initializes an instrument rating object
        /// </summary>
        /// <param name="szTitle">Title</param>
        /// <param name="szBaseFAR">Base FAR</param>
        /// <param name="ratingSought">Specific rating being sought</param>
        protected virtual void Init(string szTitle, string szBaseFAR, RatingType ratingSought, string farLink)
        {
            Title        = szTitle;
            BaseFAR      = szBaseFAR;
            FARLink      = farLink;
            RatingSought = ratingSought;

            FTDTimeRemaining = MaxFTDTime;

            string szAircraftCategory;

            switch (RatingSought)
            {
            case RatingType.InstrumentAirplane:
                szAircraftCategory = Resources.MilestoneProgress.ratingAirplane;
                break;

            case RatingType.InstrumentHelicopter:
                szAircraftCategory = Resources.MilestoneProgress.ratingHelicopter;
                break;

            case RatingType.InstrumentPoweredLift:
                szAircraftCategory = Resources.MilestoneProgress.ratingPoweredLift;
                break;

            default:
                throw new MyFlightbookException(String.Format(CultureInfo.InvariantCulture, "Unallowed rating for 61.65: {0}", RatingSought.ToString()));
            }

            // 61.65(def)(1)
            miMinXCTime         = new MilestoneItem(Resources.MilestoneProgress.MinInstrumentPICXC, ResolvedFAR("(1)"), Resources.MilestoneProgress.NoteXCTime, MilestoneItem.MilestoneType.Time, 50.0M);
            miMinTimeInCategory = new MilestoneItem(String.Format(CultureInfo.CurrentCulture, Resources.MilestoneProgress.MinInstrumentPICInCategory, szAircraftCategory), ResolvedFAR("(1)"), String.Empty, MilestoneItem.MilestoneType.Time, 10.0M);

            // 61.65(def)(2) - total instrument time
            miMinIMCTime = new MilestoneItem(Resources.MilestoneProgress.MinInstrumentTime, ResolvedFAR("(2)"), Branding.ReBrand(Resources.MilestoneProgress.NoteInstrumentTime), MilestoneItem.MilestoneType.Time, 40.0M);

            // 61.65(def)(2) - Instrument training
            miInstrumentTraining = new MilestoneItem(Resources.MilestoneProgress.MinInstrumentTraining, ResolvedFAR("(2)"), Branding.ReBrand(Resources.MilestoneProgress.MinInstrumentTrainingNote), MilestoneItem.MilestoneType.Time, 15.0M);

            // 61.65(def)(2)(i) - recent test prep
            miMinIMCTestPrep = new MilestoneItemDecayable(String.Format(CultureInfo.CurrentCulture, Resources.MilestoneProgress.MinInstrumentTestPrep, szAircraftCategory), ResolvedFAR("(2)(i)"), Branding.ReBrand(Resources.MilestoneProgress.NoteTestPrep), MilestoneItem.MilestoneType.Time, 3.0M, 2);

            // 61.65(def)(2)(ii) - cross-country
            miIMCXC = new MilestoneItem(String.Format(CultureInfo.CurrentCulture, Resources.MilestoneProgress.MinInstrumentXC, szAircraftCategory, MinXCDistance), ResolvedFAR("(2)(ii)"), Branding.ReBrand(Resources.MilestoneProgress.NoteInstrumentXC), MilestoneItem.MilestoneType.AchieveOnce, 1.0M);
        }
Ejemplo n.º 6
0
        public static bool SubmitRating(RatingType type, string itemId, int rating)
        {
            string account = DBOption.GetOptions(DBOption.cOnlineUserID);
            if (String.IsNullOrEmpty(account))
            {
            // if there is no tvdb account identifier, but we are using follwit. dont display the
            // "please fill in ID" error.
            if (FollwitConnector.Enabled) {
                return false;
            }

            string[] lines = new string[] { Translation.TVDB_INFO_ACCOUNTID_1, Translation.TVDB_INFO_ACCOUNTID_2 };
            TVSeriesPlugin.ShowDialogOk(Translation.TVDB_INFO_TITLE, lines);
            MPTVSeriesLog.Write("Cannot submit rating, make sure you have your Account identifier set!");
            return false;
            }

            if (itemId == "0" || rating < 0 || rating > 10)
            {
            MPTVSeriesLog.Write("Cannot submit rating, invalid values.....this is most likely a programming error");
            return false;
            }

            if (!DBOnlineMirror.IsMirrorsAvailable)
            {
            // Server maybe available now.
            DBOnlineMirror.Init();
            if (!DBOnlineMirror.IsMirrorsAvailable)
            {
                GUIDialogOK dlgOK = (GUIDialogOK)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_OK);
                dlgOK.SetHeading(Translation.TVDB_ERROR_TITLE);
                if (!TVSeriesPlugin.IsNetworkAvailable)
                {
                    string[] lines = new string[] { Translation.NETWORK_ERROR_UNAVAILABLE_1, Translation.NETWORK_ERROR_UNAVAILABLE_2 };
                    TVSeriesPlugin.ShowDialogOk(Translation.TVDB_ERROR_TITLE, lines);
                }
                else
                {
                    string[] lines = new string[] { Translation.TVDB_ERROR_UNAVAILABLE_1, Translation.TVDB_ERROR_UNAVAILABLE_2 };
                    TVSeriesPlugin.ShowDialogOk(Translation.TVDB_ERROR_TITLE, lines);
                }

                MPTVSeriesLog.Write("Cannot submit rating, the online database is unavailable");
                return false;
            }
            }
            // ok we're good
            MPTVSeriesLog.Write(string.Format("Submitting Rating of {2} for {0} {1}", type.ToString(), itemId, rating), MPTVSeriesLog.LogLevel.Debug);
            Generic(string.Format(apiURIs.SubmitRating, account, type.ToString(), itemId, rating), true, false, Format.NoExtension);
            return true;
        }
Ejemplo n.º 7
0
        // http://stackoverflow.com/q/424366
        /// <summary>
        /// Gets the link to avatar by gravatar.
        /// </summary>
        /// <param name="content">The content (email).</param>
        /// <param name="size">The size of avatar.</param>
        /// <param name="ratingType">Type of the rating.</param>
        /// <param name="defaultImage">The type of default image.</param>
        /// <returns></returns>
        /// <exception cref="System.ArgumentNullException">content</exception>
        /// <exception cref="System.ArgumentOutOfRangeException">size;The image size should be between 1 and 2048</exception>
        public static string Get(string content, int size = 80, RatingType ratingType = RatingType.PG, DefaultImage defaultImage = DefaultImage.MM)
        {
            if (content == null) throw new ArgumentNullException("content");

            if (size < 1 | size > 2048)
                throw new ArgumentOutOfRangeException("size",
                    "The image size should be between 1 and 2048");

            return String.Format("{0}?gravatar_id={1}&s={2}&r={3}&d={4}",
                Url,
                MD5.GetHashString(content.ToLower()),
                size,
                ratingType.ToString("G"),
                defaultImage.ToString("G")).ToLower();
        }
Ejemplo n.º 8
0
    static public bool SubmitRating(RatingType type, string itemId, int rating)
    {
        string account = DBOption.GetOptions(DBOption.cOnlineUserID);
        if (String.IsNullOrEmpty(account))
        {
            string[] lines = new string[] { Translation.TVDB_INFO_ACCOUNTID_1, Translation.TVDB_INFO_ACCOUNTID_2 };
            //TVSeriesPlugin.ShowDialogOk(Translation.TVDB_INFO_TITLE, lines); //trakt.tv also listens to this, also can store ratings locally.
            MPTVSeriesLog.Write("Cannot submit rating to thetvdb.com, this requires your Account Identifier to be set.");
            return false;
        }

        if (itemId == "0" || rating < 0 || rating > 10)
        {
            MPTVSeriesLog.Write("Cannot submit rating, invalid values...this is most likely a programming error");
            return false;
        }

        if (!DBOnlineMirror.IsMirrorsAvailable)
        {
            // Server maybe available now.
            DBOnlineMirror.Init();
            if (!DBOnlineMirror.IsMirrorsAvailable)
            {
                GUIDialogOK dlgOK = (GUIDialogOK)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_OK);
                dlgOK.SetHeading(Translation.TVDB_ERROR_TITLE);
                if (!TVSeriesPlugin.IsNetworkAvailable)
                {
                    string[] lines = new string[] { Translation.NETWORK_ERROR_UNAVAILABLE_1, Translation.NETWORK_ERROR_UNAVAILABLE_2 };
                    TVSeriesPlugin.ShowDialogOk(Translation.TVDB_ERROR_TITLE, lines);
                }
                else
                {
                    string[] lines = new string[] { Translation.TVDB_ERROR_UNAVAILABLE_1, Translation.TVDB_ERROR_UNAVAILABLE_2 };
                    TVSeriesPlugin.ShowDialogOk(Translation.TVDB_ERROR_TITLE, lines);
                }
                
                MPTVSeriesLog.Write("Cannot submit rating, the online database is unavailable");
                return false;
            }
        }
        // ok we're good
        MPTVSeriesLog.Write(string.Format("Submitting Rating of {2} for {0} {1}", type.ToString(), itemId, rating), MPTVSeriesLog.LogLevel.Debug);
        Generic(string.Format(apiURIs.SubmitRating, account, type.ToString(), itemId, rating), true, false, Format.NoExtension);
        return true;
    }