Пример #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                lnkFeatures.Text       = Branding.ReBrand(Resources.LocalizedText.AboutViewFeatures);
                lnkFacebook.Visible    = !String.IsNullOrEmpty(lnkFacebook.NavigateUrl = Branding.CurrentBrand.FacebookFeed);
                lnkTwitter.Visible     = !String.IsNullOrEmpty(lnkTwitter.NavigateUrl = Branding.CurrentBrand.TwitterFeed);
                lblFollowFacebook.Text = Branding.ReBrand(Resources.LocalizedText.FollowOnFacebook);
                lblFollowTwitter.Text  = Branding.ReBrand(Resources.LocalizedText.FollowOnTwitter);

                FlightStats fs = FlightStats.GetFlightStats();
                lblRecentFlightsStats.Text = fs.ToString();

                locRecentStats.Text = Branding.ReBrand(Resources.LocalizedText.DefaultPageRecentStats);
                List <string> lstStats = new List <string>()
                {
                    String.Format(CultureInfo.CurrentCulture, Resources.LocalizedText.DefaultPageRecentStatsFlights, fs.NumFlightsTotal),
                    String.Format(CultureInfo.CurrentCulture, Resources.LocalizedText.DefaultPageRecentStatsAircraft, fs.NumAircraft),
                    String.Format(CultureInfo.CurrentCulture, Resources.LocalizedText.DefaultPagerecentStatsModels, fs.NumModels)
                };

                rptStats.DataSource = lstStats;
                rptStats.DataBind();
            }
        }
Пример #2
0
        /// <summary>
        /// Refreshes the access token if (a) there is a refresh token, and (b) there is not an unexpired accesstoken
        /// </summary>
        /// <returns>True if the update happened and was successful</returns>
        public async Task <bool> RefreshAccessToken()
        {
            return(await Task.Run <bool>(() =>
            {
                // Don't refresh if no refresh token, or if current access token is still valid
                if (CheckAccessToken() || String.IsNullOrEmpty(AuthState.RefreshToken))
                {
                    return false;
                }

                WebServerClient client = Client();
                try
                {
                    client.RefreshAuthorization(AuthState);
                }
                catch (DotNetOpenAuth.Messaging.ProtocolException ex)
                {
                    GDriveError error = JsonConvert.DeserializeObject <GDriveError>(ExtractResponseString(ex.InnerException as WebException));
                    if (error == null)
                    {
                        throw;
                    }
                    else if (error.error.CompareCurrentCultureIgnoreCase("invalid_grant") == 0)
                    {
                        throw new MyFlightbookException(Branding.ReBrand(Resources.LocalizedText.GoogleDriveBadAuth), ex);
                    }
                    else
                    {
                        throw new MyFlightbookException(String.Format(CultureInfo.CurrentCulture, "Error from Google Drive: {0} {1} {2}", error.error, error.error_description, error.error_uri), ex);
                    }
                }
                return true;
            }));
        }
Пример #3
0
        public override string ReminderSubject(EarnedGrauity eg)
        {
            if (eg == null)
            {
                throw new ArgumentNullException("eg");
            }

            switch (eg.CurrentStatus)
            {
            default:
            case EarnedGrauity.EarnedGratuityStatus.OK:     // shouldn't even be called in this case
                return(string.Empty);

            case EarnedGrauity.EarnedGratuityStatus.ExpiringSoon:
                if (eg.ReminderCount == 0)
                {
                    return(Branding.ReBrand(Resources.LocalizedText.gratuityCloudStorageExpiring));
                }
                else
                {
                    return(string.Empty);
                }

            case EarnedGrauity.EarnedGratuityStatus.Expired:
                if (eg.ReminderCount <= 1)
                {
                    return(Branding.ReBrand(Resources.LocalizedText.gratuityCloudStorageExpired));
                }
                else
                {
                    return(string.Empty);
                }
            }
        }
Пример #4
0
    protected void btnSendFlight_Click(object sender, EventArgs e)
    {
        Page.Validate("valSendFlight");
        if (Page.IsValid)
        {
            LogbookEntry         le       = new LogbookEntry(Convert.ToInt32(hdnFlightToSend.Value, CultureInfo.InvariantCulture), Page.User.Identity.Name);
            MyFlightbook.Profile pfSender = MyFlightbook.Profile.GetUser(Page.User.Identity.Name);
            string szRecipient            = txtSendFlightEmail.Text;

            using (MailMessage msg = new MailMessage())
            {
                msg.Body = Branding.ReBrand(Resources.LogbookEntry.SendFlightBody.Replace("<% Sender %>", HttpUtility.HtmlEncode(pfSender.UserFullName))
                                            .Replace("<% Message %>", HttpUtility.HtmlEncode(txtSendFlightMessage.Text))
                                            .Replace("<% Date %>", le.Date.ToShortDateString())
                                            .Replace("<% Aircraft %>", HttpUtility.HtmlEncode(le.TailNumDisplay))
                                            .Replace("<% Route %>", HttpUtility.HtmlEncode(le.Route))
                                            .Replace("<% Comments %>", HttpUtility.HtmlEncode(le.Comment))
                                            .Replace("<% Time %>", le.TotalFlightTime.FormatDecimal(pfSender.UsesHHMM))
                                            .Replace("<% FlightLink %>", le.SendFlightUri(Branding.CurrentBrand.HostName, SendPageTarget).ToString()));

                msg.Subject = String.Format(CultureInfo.CurrentCulture, Resources.LogbookEntry.SendFlightSubject, pfSender.UserFullName);
                msg.From    = new MailAddress(Branding.CurrentBrand.EmailAddress, String.Format(CultureInfo.CurrentCulture, Resources.SignOff.EmailSenderAddress, Branding.CurrentBrand.AppName, pfSender.UserFullName));
                msg.ReplyToList.Add(new MailAddress(pfSender.Email));
                msg.To.Add(new MailAddress(szRecipient));
                msg.IsBodyHtml = true;
                util.SendMessage(msg);
            }

            modalPopupSendFlight.Hide();
        }
        else
        {
            modalPopupSendFlight.Show();
        }
    }
Пример #5
0
    protected void btnAddMember_Click(object sender, EventArgs e)
    {
        if (!Page.IsValid)
        {
            return;
        }

        if (CurrentClub.Status == Club.ClubStatus.Inactive)
        {
            lblErr.Text = Branding.ReBrand(Resources.Club.errClubInactive);
            return;
        }
        if (CurrentClub.Status == Club.ClubStatus.Expired)
        {
            lblErr.Text = Branding.ReBrand(Resources.Club.errClubPromoExpired);
            return;
        }

        try
        {
            new CFIStudentMapRequest(Page.User.Identity.Name, txtMemberEmail.Text, CFIStudentMapRequest.RoleType.RoleInviteJoinClub, CurrentClub).Send();
            lblAddMemberSuccess.Text     = String.Format(CultureInfo.CurrentCulture, Resources.Profile.EditProfileRequestHasBeenSent, System.Web.HttpUtility.HtmlEncode(txtMemberEmail.Text));
            lblAddMemberSuccess.CssClass = "success";
            txtMemberEmail.Text          = "";
        }
        catch (MyFlightbookException ex)
        {
            lblAddMemberSuccess.Text     = ex.Message;
            lblAddMemberSuccess.CssClass = "error";
        }
    }
Пример #6
0
    protected void Page_Load(object sender, EventArgs e)
    {
        Master.SelectedTab = tabID.lbtStartingTotals;
        InitWizard(wizStartingTotals);

        if (!IsPostBack)
        {
            this.Master.Title   = String.Format(CultureInfo.CurrentCulture, Resources.LocalizedText.LogbookForUserHeader, MyFlightbook.Profile.GetUser(User.Identity.Name).UserFullName);
            mfbTypeInDate1.Date = DateTime.Now.AddYears(-1);
            InitFlights(rbSimple, e);
            Aircraft[] rgac = (new UserAircraft(User.Identity.Name)).GetAircraftForUser();
            gvAircraft.DataSource = rgac;
            gvAircraft.DataBind();
            if (rgac.Length == 0)
            {
                cpeExistingAircraft.Collapsed = false;
            }

            locWhyStartingFlights.Text = Branding.ReBrand(Resources.LocalizedText.WhyStartingFlights);
        }
        else
        {
            UpdateFlightTable();
        }
    }
Пример #7
0
        protected void Page_Load(object sender, EventArgs e)
        {
            Master.SelectedTab = tabID.actMyClubs;

            if (!IsPostBack)
            {
                expandoCreateClub.ExpandoLabel.Font.Bold = true;
                UserState = Page.User.Identity.IsAuthenticated ? (EarnedGratuity.UserQualifies(Page.User.Identity.Name, Gratuity.GratuityTypes.CreateClub) ? AuthState.Authorized : AuthState.Unauthorized) : AuthState.Unauthenticated;

                vcNew.ActiveClub = new Club();

                switch (UserState)
                {
                case AuthState.Unauthenticated:
                    pnlCreateClub.Visible = pnlYourClubs.Visible = false;
                    lblTrialStatus.Text   = Branding.ReBrand(Resources.Club.MustBeMember);
                    break;

                case AuthState.Unauthorized:
                    lblTrialStatus.Text     = Branding.ReBrand(Resources.Club.ClubCreateTrial);
                    vcNew.ActiveClub.Status = Club.ClubStatus.Promotional;
                    break;

                case AuthState.Authorized:
                    lblTrialStatus.Text     = Branding.ReBrand(Resources.Club.ClubCreateNoTrial);
                    vcNew.ActiveClub.Status = Club.ClubStatus.OK;
                    break;
                }

                Refresh();
            }
        }
Пример #8
0
        protected void btnSendEmail_Click(object sender, EventArgs e)
        {
            Page.Validate("resetPassEmail");
            if (Page.IsValid)
            {
                lblEmailSent.Text = String.Format(CultureInfo.CurrentCulture, Resources.LocalizedText.ResetPassEmailSent, HttpUtility.HtmlEncode(txtEmail.Text));
                mvResetPass.SetActiveView(vwEmailSent);
                string szUser = Membership.GetUserNameByEmail(txtEmail.Text);
                if (String.IsNullOrEmpty(szUser))
                {
                    // fail silently - don't do anything to acknowledge the existence or lack thereof of an account
                }
                else
                {
                    PasswordResetRequest prr = new PasswordResetRequest()
                    {
                        UserName = szUser
                    };
                    prr.FCommit();

                    string szURL            = "https://" + Request.Url.Host + Request.RawUrl + (Request.RawUrl.Contains("?") ? "&" : "?") + "t=" + HttpUtility.UrlEncode(prr.ID);
                    string szEmailBody      = Branding.ReBrand(String.Format(CultureInfo.CurrentCulture, Resources.LocalizedText.ResetPassEmail)).Replace("<% RESET_LINK %>", szURL);
                    MyFlightbook.Profile pf = MyFlightbook.Profile.GetUser(szUser);

                    util.NotifyUser(Branding.ReBrand(Resources.LocalizedText.ResetPasswordSubjectNew), szEmailBody, new System.Net.Mail.MailAddress(pf.Email, pf.UserFullName), false, false);
                }
            }
        }
        public void InitCloudProviders()
        {
            List <StorageID> lstCloud       = new List <StorageID>(CurrentUser.AvailableCloudProviders);
            StorageID        defaultStorage = CurrentUser.BestCloudStorage;

            foreach (StorageID sid in lstCloud)
            {
                cmbDefaultCloud.Items.Add(new ListItem(CloudStorageBase.CloudStorageName(sid), sid.ToString())
                {
                    Selected = defaultStorage == sid
                });
            }
            pnlDefaultCloud.Visible = lstCloud.Count > 1;   // only show a choice if more than one cloud provider is set up

            mvDropBoxState.SetActiveView(lstCloud.Contains(StorageID.Dropbox) ? vwDeAuthDropbox : vwAuthDropBox);
            mvGDriveState.SetActiveView(lstCloud.Contains(StorageID.GoogleDrive) ? vwDeAuthGDrive : vwAuthGDrive);
            mvOneDriveState.SetActiveView(lstCloud.Contains(StorageID.OneDrive) ? vwDeAuthOneDrive : vwAuthOneDrive);

            locAboutCloudStorage.Text   = Branding.ReBrand(Resources.Profile.AboutCloudStorage);
            lnkAuthDropbox.Text         = Branding.ReBrand(Resources.Profile.AuthorizeDropbox);
            lnkDeAuthDropbox.Text       = Branding.ReBrand(Resources.Profile.DeAuthDropbox);
            locDropboxIsAuthed.Text     = Branding.ReBrand(Resources.Profile.DropboxIsAuthed);
            lnkAuthorizeGDrive.Text     = Branding.ReBrand(Resources.Profile.AuthorizeGDrive);
            lnkDeAuthGDrive.Text        = Branding.ReBrand(Resources.Profile.DeAuthGDrive);
            locGoogleDriveIsAuthed.Text = Branding.ReBrand(Resources.Profile.GDriveIsAuthed);
            lnkAuthorizeOneDrive.Text   = Branding.ReBrand(Resources.Profile.AuthorizeOneDrive);
            lnkDeAuthOneDrive.Text      = Branding.ReBrand(Resources.Profile.DeAuthOneDrive);
            locOneDriveIsAuthed.Text    = Branding.ReBrand(Resources.Profile.OneDriveIsAuthed);

            rblCloudBackupAppendDate.SelectedValue = CurrentUser.OverwriteCloudBackup.ToString(CultureInfo.InvariantCulture);
        }
Пример #10
0
        private void NotifyConflictingItems()
        {
            List <string> lst = new List <string>();
            Dictionary <string, Profile> dictAffectedUsers = new Dictionary <string, Profile>();

            ConflictingItems.ForEach((s) =>
            {
                if (!dictAffectedUsers.ContainsKey(s.OwningUser))
                {
                    dictAffectedUsers.Add(s.OwningUser, Profile.GetUser(s.OwningUser));
                }
                lst.Add(String.Format("{0}: {1:d} {2:t} ({3}){4}", dictAffectedUsers[s.OwningUser].UserFullName, s.LocalStart, s.LocalStart, s.DurationDisplay, String.IsNullOrEmpty(s.Body) ? string.Empty : String.Format(" - {0}", s.Body)));
            });

            if (ResourceAircraft == null)
            {
                ResourceAircraft = Club.ClubWithID(ClubID).MemberAircraft.FirstOrDefault(ca => ca.AircraftID.ToString().CompareTo(ResourceID) == 0);
            }

            string szMsgBody = Branding.ReBrand(Resources.Schedule.Resourcedoublebooked.Replace("<% ScheduleDetail %>", String.Join("  \r\n  ", lst.ToArray())).Replace("<% Creator %>", dictAffectedUsers[OwningUser].UserFullName).Replace("<% Resource %>", ResourceAircraft == null ? string.Empty : ResourceAircraft.DisplayTailnumber));

            foreach (string sz in dictAffectedUsers.Keys)
            {
                Profile pf = dictAffectedUsers[sz];
                util.NotifyUser(Branding.ReBrand(Resources.Schedule.DoubleBookNotificationSubject), szMsgBody, new System.Net.Mail.MailAddress(pf.Email, pf.UserFullName), false, false);
            }
        }
Пример #11
0
    protected void Page_Load(object sender, EventArgs e)
    {
        this.Master.SelectedTab = tabID.instProgressTowardsMilestones;

        if (!IsPostBack)
        {
            Master.ShowSponsoredAd            = false;
            lblTitle.Text                     = String.Format(CultureInfo.CurrentCulture, Resources.MilestoneProgress.PageTitle, MyFlightbook.Profile.GetUser(TargetUser).UserFullName);
            lblOverallProgressDisclaimer.Text = Branding.ReBrand(Resources.MilestoneProgress.OverallProgressDisclaimer);
            cmbMilestoneGroup.DataSource      = Milestones;
            cmbMilestoneGroup.DataBind();

            HttpCookie cookieLastGroup     = Request.Cookies[szCookieLastGroup];
            HttpCookie cookieLastMilestone = Request.Cookies[szCookieLastMilestone];
            if (cookieLastGroup != null && cookieLastMilestone != null && !String.IsNullOrEmpty(cookieLastGroup.Value) && !String.IsNullOrEmpty(cookieLastMilestone.Value))
            {
                try
                {
                    cmbMilestoneGroup.SelectedValue = cookieLastGroup.Value.Replace(szCommaCookieSub, ",");
                    cmbMilestoneGroup_SelectedIndexChanged(cmbMilestoneGroup, e);
                    cmbMilestones.SelectedValue = cookieLastMilestone.Value.Replace(szCommaCookieSub, ",");
                    Refresh();
                }
                catch (Exception ex) when(ex is ArgumentOutOfRangeException)
                {
                    ClearCookie();
                }
            }
        }
    }
Пример #12
0
    protected void btnSendMessage_Click(object sender, EventArgs e)
    {
        Profile pf = MyFlightbook.Profile.GetUser(Page.User.Identity.Name);
        IEnumerable <ClubMember> lst = ClubMember.AdminsForClub(CurrentClub.ID);

        using (MailMessage msg = new MailMessage())
        {
            MailAddress maFrom = new MailAddress(pf.Email, pf.UserFullName);
            msg.From = new MailAddress(Branding.CurrentBrand.EmailAddress, String.Format(CultureInfo.CurrentCulture, Resources.SignOff.EmailSenderAddress, Branding.CurrentBrand.AppName, pf.UserFullName));
            msg.ReplyToList.Add(maFrom);
            foreach (ClubMember cm in lst)
            {
                msg.To.Add(new MailAddress(cm.Email, cm.UserFullName));
            }
            msg.Subject    = String.Format(CultureInfo.CurrentCulture, Branding.ReBrand(Resources.Club.ContactSubjectTemplate), CurrentClub.Name);
            msg.Body       = txtContact.Text + "\r\n\r\n" + String.Format(CultureInfo.CurrentCulture, Resources.Club.MessageSenderTemplate, pf.UserFullName, pf.Email);
            msg.IsBodyHtml = false;
            util.SendMessage(msg);
        }
        if (ckRequestMembership.Checked)
        {
            foreach (ClubMember admin in lst)
            {
                new CFIStudentMapRequest(Page.User.Identity.Name, admin.Email, CFIStudentMapRequest.RoleType.RoleRequestJoinClub, CurrentClub).Send();
            }
        }

        mpuGuestContact.Hide();
        txtContact.Text             = string.Empty;
        ckRequestMembership.Checked = false;
        lblMessageStatus.Visible    = true;
    }
Пример #13
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                lnkFeatures.Text       = Branding.ReBrand(Resources.LocalizedText.AboutViewFeatures);
                lnkFacebook.Visible    = !String.IsNullOrEmpty(lnkFacebook.NavigateUrl = Branding.CurrentBrand.FacebookFeed);
                lnkTwitter.Visible     = !String.IsNullOrEmpty(lnkTwitter.NavigateUrl = Branding.CurrentBrand.TwitterFeed);
                lblFollowFacebook.Text = Branding.ReBrand(Resources.LocalizedText.FollowOnFacebook);
                lblFollowTwitter.Text  = Branding.ReBrand(Resources.LocalizedText.FollowOnTwitter);

                FlightStats fs = FlightStats.GetFlightStats();

                locRecentStats.Text = Branding.ReBrand(String.Format(CultureInfo.CurrentCulture, Resources.LocalizedText.DefaultPageRecentStatsHeader, fs.MaxDays));

                rptStats.DataSource = fs.Stats;
                rptStats.DataBind();

                if (fs.HasSlowInformation)
                {
                    List <AirportStats> lstTopAirports = new List <AirportStats>(fs.AirportsVisited);
                    if (lstTopAirports.Count > maxAirports)
                    {
                        lstTopAirports.RemoveRange(maxAirports, lstTopAirports.Count - maxAirports);
                    }
                    rptTopAirports.DataSource = lstTopAirports;
                    rptTopAirports.DataBind();

                    rptTopModels.DataSource = fs.ModelsUsed;
                    rptTopModels.DataBind();

                    pnlLazyStats.Visible = true;
                }
            }
        }
Пример #14
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         lblSignatureDisclaimer.Text = Branding.ReBrand(Resources.SignOff.SignedFlightDisclaimer);
     }
 }
Пример #15
0
    protected Boolean FCommitPass()
    {
        try
        {
            if (CurrentPassword.Text.Length == 0 || !Membership.ValidateUser(User.Identity.Name, CurrentPassword.Text))
            {
                throw new MyFlightbookException(Resources.Profile.errBadPasswordToChange);
            }
            if (NewPassword.Text.Length < 6)
            {
                throw new MyFlightbookException(Resources.Profile.errBadPasswordLength);
            }
            if (NewPassword.Text != ConfirmNewPassword.Text) // should never happen - validation should have caught this.
            {
                throw new MyFlightbookException(Resources.Profile.errPasswordsDontMatch);
            }
            if (!Membership.Provider.ChangePassword(Page.User.Identity.Name, CurrentPassword.Text, NewPassword.Text))
            {
                throw new MyFlightbookException(Resources.Profile.errChangePasswordFailed);
            }

            util.NotifyUser(String.Format(CultureInfo.CurrentCulture, Resources.Profile.PasswordChangedSubject, Branding.CurrentBrand.AppName),
                            Branding.ReBrand(Resources.EmailTemplates.PasswordChanged),
                            new System.Net.Mail.MailAddress(m_pf.Email, m_pf.UserFullName), false, false);
        }
        catch (MyFlightbookException ex)
        {
            lblPassChanged.Visible  = true;
            lblPassChanged.Text     = ex.Message;
            lblPassChanged.CssClass = "error";
            return(false);
        }

        return(true);
    }
Пример #16
0
    protected static bool IsValidCaller(int idClub, PrivilegeLevel level = PrivilegeLevel.ReadWrite)
    {
        // Check that you are authenticated - prevent cross-site scripting
        if (HttpContext.Current == null || HttpContext.Current.User == null || HttpContext.Current.User.Identity == null || !HttpContext.Current.User.Identity.IsAuthenticated || String.IsNullOrEmpty(HttpContext.Current.User.Identity.Name))
        {
            throw new MyFlightbookException("You must be authenticated to make this call");
        }

        if (idClub == Club.ClubIDNew)
        {
            throw new MyFlightbookException("Each scheduled item must be in the context of a club.");
        }

        Club c = Club.ClubWithID(idClub);

        if (c == null)
        {
            throw new MyFlightbookException("Invalid club specification - no such club.");
        }

        // Check that the user is a member of the specified club
        if (!c.HasMember(HttpContext.Current.User.Identity.Name))
        {
            throw new MyFlightbookException("You must be a member of the club to make this call");
        }

        if (level == PrivilegeLevel.ReadWrite && !c.CanWrite)
        {
            throw new MyFlightbookException(Branding.ReBrand(c.Status == Club.ClubStatus.Expired ? Resources.Club.errClubPromoExpired : Resources.Club.errClubInactive));
        }

        return(true);
    }
Пример #17
0
    protected override MFBImageInfo UploadForUser(string szUser, HttpPostedFile pf, string szComment)
    {
        string szTail     = Request.Form["txtAircraft"];
        int    idAircraft = Aircraft.idAircraftUnknown;
        bool   fUseID     = util.GetIntParam(Request, "id", 0) != 0;

        if (String.IsNullOrEmpty(szTail))
        {
            throw new MyFlightbookException(Resources.WebService.errBadTailNumber);
        }
        if (fUseID)
        {
            if (!int.TryParse(szTail, out idAircraft) || idAircraft == Aircraft.idAircraftUnknown)
            {
                throw new MyFlightbookException(Resources.WebService.errBadTailNumber);
            }
        }
        else if (szTail.Length > Aircraft.maxTailLength || szTail.Length < 3)
        {
            throw new MyFlightbookException(Resources.WebService.errBadTailNumber);
        }

        // Check if authorized for videos
        if (MFBImageInfo.ImageTypeFromFile(pf) == MFBImageInfo.ImageFileType.S3VideoMP4 && !EarnedGrauity.UserQualifies(szUser, Gratuity.GratuityTypes.Videos))
        {
            throw new MyFlightbookException(Branding.ReBrand(Resources.LocalizedText.errNotAuthorizedVideos));
        }

        UserAircraft ua = new UserAircraft(szUser);

        ua.InvalidateCache();   // in case the aircraft was added but cache is not refreshed.
        Aircraft[] rgac = ua.GetAircraftForUser();

        Aircraft ac = null;

        if (fUseID)
        {
            ac = new Aircraft(idAircraft);
        }
        else
        {
            string szTailNormal = Aircraft.NormalizeTail(szTail);

            // Look for the aircraft in the list of the user's aircraft (that way you get the right version if it's a multi-version aircraft and no ID was specified
            // Hack for backwards compatibility with mobile apps and anonymous aircraft
            // Look to see if the tailnumber matches the anonymous tail
            ac = Array.Find <Aircraft>(rgac, uac =>
                                       (String.Compare(Aircraft.NormalizeTail(szTailNormal), Aircraft.NormalizeTail(uac.TailNumber), StringComparison.CurrentCultureIgnoreCase) == 0 ||
                                        String.Compare(szTail, uac.HackDisplayTailnumber, StringComparison.CurrentCultureIgnoreCase) == 0));
        }

        if (ac == null || !ua.CheckAircraftForUser(ac))
        {
            throw new MyFlightbookException(Resources.WebService.errNotYourAirplane);
        }

        mfbImageAircraft.Key = ac.AircraftID.ToString(System.Globalization.CultureInfo.InvariantCulture);
        return(new MFBImageInfo(MFBImageInfo.ImageClass.Aircraft, mfbImageAircraft.Key, pf, szComment, null));
    }
Пример #18
0
    protected void Page_Load(object sender, EventArgs e)
    {
        Page.ClientScript.RegisterClientScriptInclude("ListDrag", ResolveClientUrl("~/Public/Scripts/listdrag.js?v=5"));
        Page.ClientScript.RegisterClientScriptInclude("filterDropdown", ResolveClientUrl("~/Public/Scripts/DropDownFilter.js?v=3"));
        searchProps.TextBoxControl.Attributes["onkeyup"] = String.Format(CultureInfo.InvariantCulture, "FilterProps(this, '{0}', '{1}', '{2}')", divAvailableProps.ClientID, lblFilteredLabel.ClientID, Resources.LogbookEntry.PropertiesFound);
        divAvailableProps.Attributes["ondrop"]           = String.Format(CultureInfo.InvariantCulture, "javascript:lstDropTemplate.moveProp(event, 'cptT', this, '{0}', '{1}')", hdnUsedProps.ClientID, hdnAvailableProps.ClientID);
        divCurrentProps.Attributes["ondrop"]             = String.Format(CultureInfo.InvariantCulture, "javascript:lstDropTemplate.moveProp(event, 'cptT', this, '{0}', '{1}')", hdnAvailableProps.ClientID, hdnUsedProps.ClientID);

        if (!IsPostBack)
        {
            if (ActiveTemplate == null)
            {
                ActiveTemplate = new UserPropertyTemplate()
                {
                    Owner = Page.User.Identity.Name, OriginalOwner = string.Empty
                }
            }
            ;

            PropertyTemplateGroup[] rgGroups = (PropertyTemplateGroup[])Enum.GetValues(typeof(PropertyTemplateGroup));

            foreach (PropertyTemplateGroup ptg in rgGroups)
            {
                if (ptg != PropertyTemplateGroup.Automatic)
                {
                    cmbCategories.Items.Add(new ListItem(PropertyTemplate.NameForGroup(ptg), ptg.ToString()));
                }
            }
            cmbCategories.SelectedIndex = 0;

            ToForm();

            locTemplateDescription1.Text = Branding.ReBrand(Resources.LogbookEntry.TemplateDescription);
            locTemplateDescription2.Text = Branding.ReBrand(Resources.LogbookEntry.TemplateDescription2);
        }
        else
        {
            if (ActiveTemplate == null)
            {
                throw new NullReferenceException("Active Template is null - how? ");
            }
            ActiveTemplate.PropertyTypes.Clear();
            if (hdnUsedProps.Value == null)
            {
                throw new NullReferenceException("hdnUsedProps.Value is null");
            }
            int[] props = JsonConvert.DeserializeObject <int[]>(hdnUsedProps.Value);
            if (props == null)
            {
                throw new NullReferenceException("props is null");
            }
            foreach (int propid in props)
            {
                ActiveTemplate.PropertyTypes.Add(propid);
            }
            UpdateLists();
        }
    }
Пример #19
0
        private async Task <bool> BackupGoogleDrive(LogbookBackup lb, Profile pf, StringBuilder sb, StringBuilder sbFailures)
        {
            try
            {
                if (pf.GoogleDriveAccessToken == null)
                {
                    throw new UnauthorizedAccessException();
                }

                GoogleDrive gd = new GoogleDrive(pf.GoogleDriveAccessToken);

                sb.AppendFormat(CultureInfo.CurrentCulture, "GoogleDrive: user {0} ", pf.UserName);
                GoogleDriveResultDictionary meta = await lb.BackupToGoogleDrive(gd, Branding.CurrentBrand).ConfigureAwait(false);

                if (meta != null)
                {
                    sb.AppendFormat(CultureInfo.CurrentCulture, "Logbook backed up for user {0}...", pf.UserName);
                }
                System.Threading.Thread.Sleep(0);
                meta = await lb.BackupImagesToGoogleDrive(gd, Branding.CurrentBrand).ConfigureAwait(false);

                System.Threading.Thread.Sleep(0);
                if (meta != null)
                {
                    sb.AppendFormat(CultureInfo.CurrentCulture, "and images backed up for user {0}.\r\n \r\n", pf.UserName);
                }

                // if we are here we were successful, so save the updated refresh token
                pf.GoogleDriveAccessToken = gd.AuthState;
                pf.FCommit();
            }
            catch (MyFlightbookException ex)
            {
                sbFailures.AppendFormat(CultureInfo.CurrentCulture, "GoogleDrive FAILED for user (MyFlightbookException) {0}: {1}\r\n\r\n", pf.UserName, ex.Message);
                util.NotifyUser(Branding.ReBrand(Resources.EmailTemplates.GoogleDriveFailureSubject, ActiveBrand),
                                Branding.ReBrand(String.Format(CultureInfo.CurrentCulture, Resources.EmailTemplates.GoogleDriveFailure, pf.UserFullName, ex.Message, string.Empty), ActiveBrand), new System.Net.Mail.MailAddress(pf.Email, pf.UserFullName), true, false);
            }
            catch (UnauthorizedAccessException ex)
            {
                // De-register GoogleDrive.
                pf.GoogleDriveAccessToken = null;
                pf.FCommit();
                sbFailures.AppendFormat(CultureInfo.CurrentCulture, "GoogleDrive FAILED for user (UnauthorizedAccess) {0}: {1}\r\n\r\n", pf.UserName, ex.Message);
                util.NotifyUser(Branding.ReBrand(Resources.EmailTemplates.GoogleDriveFailureSubject, ActiveBrand),
                                Branding.ReBrand(String.Format(CultureInfo.CurrentCulture, Resources.EmailTemplates.GoogleDriveFailure, pf.UserFullName, ex.Message, Resources.LocalizedText.DropboxErrorDeAuthorized), ActiveBrand), new System.Net.Mail.MailAddress(pf.Email, pf.UserFullName), true, false);
            }
            catch (System.IO.FileNotFoundException ex)
            {
                sbFailures.AppendFormat(CultureInfo.CurrentCulture, "GoogleDrive FAILED for user: FileNotFoundException, no notification sent {0}: {1} {2}\r\n\r\n", pf.UserName, ex.GetType().ToString(), ex.Message);
            }
            catch (Exception ex) when(!(ex is OutOfMemoryException))
            {
                sbFailures.AppendFormat(CultureInfo.CurrentCulture, "GoogleDrive FAILED for user (Unknown Exception), no notification sent {0}: {1} {2}\r\n\r\n", pf.UserName, ex.GetType().ToString(), ex.Message);
            }
            return(true);
        }
Пример #20
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         lblDesc1.Text         = Branding.ReBrand(Resources.LogbookEntry.TemplateBrowseHeaderDescription);
         UserPropertyTemplates = UserPropertyTemplate.TemplatesForUser(User.Identity.Name);
         PublicTemplates       = UserPropertyTemplate.PublicTemplates();
         Refresh();
     }
 }
Пример #21
0
    protected void Page_Load(object sender, EventArgs e)
    {
        Master.SelectedTab = tabID.tabHome;
        Master.Title       = String.Format(CultureInfo.CurrentCulture, Resources.Profile.WelcomeTitleWithDescription, Branding.CurrentBrand.AppName);

        string s = util.GetStringParam(Request, "m");

        if (s.Length > 0)
        {
            this.Master.SetMobile((string.Compare(s, "no", StringComparison.OrdinalIgnoreCase) != 0));
        }

        FlightStats fs = FlightStats.GetFlightStats();

        if (!IsPostBack)
        {
            List <AppAreaDescriptor> lst = new List <AppAreaDescriptor>()
            {
                new AppAreaDescriptor(Resources.Tabs.TabLogbook, "~/Member/LogbookNew.aspx", Branding.ReBrand(Resources.Profile.appDescriptionLogbook), tabID.tabLogbook),
                new AppAreaDescriptor(Resources.Tabs.TabAircraft, "~/Member/Aircraft.aspx", Branding.ReBrand(Resources.Profile.appDescriptionAircraft), tabID.tabAircraft),
                new AppAreaDescriptor(Resources.Tabs.TabAirports, "~/Public/MapRoute2.aspx", Branding.ReBrand(Resources.Profile.appDescriptionAirports), tabID.tabMaps),
                new AppAreaDescriptor(Resources.Tabs.TabInstruction, "~/Member/Training.aspx", Branding.ReBrand(Resources.Profile.appDescriptionTraining), tabID.tabTraining),
                new AppAreaDescriptor(Resources.Tabs.TabProfile, "~/Member/EditProfile.aspx", Branding.ReBrand(Resources.Profile.appDescriptionProfile), tabID.tabProfile)
            };
            rptFeatures.DataSource = lst;
            rptFeatures.DataBind();

            if (User.Identity.IsAuthenticated)
            {
                lblHeader.Text     = String.Format(CultureInfo.CurrentCulture, Resources.LocalizedText.DefaultPageWelcomeBack, HttpUtility.HtmlEncode(Profile.GetUser(User.Identity.Name).PreferredGreeting));
                pnlWelcome.Visible = false;
            }
            else
            {
                lblHeader.Text     = String.Format(CultureInfo.CurrentCulture, Resources.Profile.WelcomeTitle, Branding.CurrentBrand.AppName);
                pnlWelcome.Visible = true;
            }

            locRecentStats.Text = Branding.ReBrand(String.Format(CultureInfo.CurrentCulture, Resources.LocalizedText.DefaultPageRecentStatsHeader, fs.MaxDays));

            rptStats.DataSource = fs.Stats;
            rptStats.DataBind();
        }

        // redirect to a mobile view if this is from a mobile device UNLESS cookies suggest to do otherwise.
        if (this.Master.IsMobileSession())
        {
            if ((Request.Cookies[MFBConstants.keyClassic] == null || String.Compare(Request.Cookies[MFBConstants.keyClassic].Value, "yes", StringComparison.OrdinalIgnoreCase) != 0))
            {
                Response.Redirect("DefaultMini.aspx");
            }
        }

        PopulateRecentImages(fs.RecentPublicFlights);
    }
Пример #22
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         Profile pf = Profile.GetUser(Page.User.Identity.Name);
         mvCloudAhoy.SetActiveView(pf.CloudAhoyToken == null ? vwAuthCloudAhoy : vwDeAuthCloudAhoy);
         lnkAuthCloudAhoy.Text     = Branding.ReBrand(Resources.Profile.AuthorizeCloudAhoy);
         lnkDeAuthCloudAhoy.Text   = Branding.ReBrand(Resources.Profile.DeAuthCloudAhoy);
         locCloudAhoyIsAuthed.Text = Branding.ReBrand(Resources.Profile.CloudAhoyIsAuthed);
     }
 }
Пример #23
0
        public Part135243b() : base()
        {
            RatingSought = RatingType.Part135PIC;
            BaseFAR      = "135.243(b)(2)";
            string szFAR = ResolvedFAR(string.Empty);

            Title             = Resources.MilestoneProgress.Title135243PIC;
            GeneralDisclaimer = Branding.ReBrand(Resources.MilestoneProgress.Part135PICDisclaimer);
            miMinTimeAsPilot  = new MilestoneItem(String.Format(CultureInfo.CurrentCulture, Resources.MilestoneProgress.Part135PICMinTime, minTime), szFAR, string.Empty, MilestoneItem.MilestoneType.Time, minTime);
            miMinXCTime       = new MilestoneItem(String.Format(CultureInfo.CurrentCulture, Resources.MilestoneProgress.Part135PICXCMinTime, minXCTime), szFAR, Resources.MilestoneProgress.Part135XCNote, MilestoneItem.MilestoneType.Time, minXCTime);
            miMinXCNightTime  = new MilestoneItem(Resources.MilestoneProgress.Part135PICNightXCMinTime, szFAR, Resources.MilestoneProgress.Part135XCNote, MilestoneItem.MilestoneType.Time, minXCNightTime);
        }
Пример #24
0
    protected void btnSendInEmail_Click(object sender, EventArgs e)
    {
        string szPass = lblResetErr.Text;
        string szUser = lblPwdUsername.Text;

        if (!String.IsNullOrEmpty(szPass) && !String.IsNullOrEmpty(szUser))
        {
            string  szEmail = Branding.ReBrand(Resources.EmailTemplates.ChangePassEmail.Replace("<% Password %>", szPass));
            Profile pf      = MyFlightbook.Profile.GetUser(szUser);
            util.NotifyUser(String.Format(CultureInfo.CurrentCulture, Resources.LocalizedText.ResetPasswordEmailSubject, Branding.CurrentBrand.AppName), szEmail, new System.Net.Mail.MailAddress(pf.Email, pf.UserFullName), false, false);
        }
    }
Пример #25
0
 /// <summary>
 /// Generates a human-readable message for the user from a OneDriveException.
 /// </summary>
 /// <param name="ex">The Exception</param>
 /// <returns>A human-readable message</returns>
 public static string MessageForException(OneDriveException ex)
 {
     /*
      *
      *  See also https://dev.onedrive.com/misc/errors.htm
      *
      *     public enum OneDriveErrorCode
      * {
      * AccessDenied = 0,
      * ActivityLimitReached = 1,
      * AuthenticationCancelled = 2,
      * AuthenticationFailure = 3,
      * GeneralException = 4,
      * InvalidRange = 5,
      * InvalidRequest = 6,
      * ItemNotFound = 7,
      * MalwareDetected = 8,
      * MyFilesCapabilityNotFound = 9,
      * NameAlreadyExists = 10,
      * NotAllowed = 11,
      * NotSupported = 12,
      * ResourceModified = 13,
      * ResyncRequired = 14,
      * ServiceNotAvailable = 15,
      * Timeout = 16,
      * TooManyRedirects = 17,
      * QuotaLimitReached = 18,
      * Unauthenticated = 19,
      * UserDoesNotHaveMyFilesService = 20
      * }
      */
     if (ex == null)
     {
         return(string.Empty);
     }
     if (ex.IsMatch(OneDriveErrorCode.AccessDenied.ToString()) || ex.IsMatch(OneDriveErrorCode.AuthenticationCancelled.ToString()) || ex.IsMatch(OneDriveErrorCode.AuthenticationFailure.ToString()) || ex.IsMatch(OneDriveErrorCode.Unauthenticated.ToString()))
     {
         return(Branding.ReBrand(Resources.LocalizedText.OneDriveBadAuth));
     }
     else if (ex.IsMatch(OneDriveErrorCode.QuotaLimitReached.ToString()))
     {
         return(Resources.LocalizedText.OneDriveErrorOutOfSpace);
     }
     else if (ex.IsMatch(OneDriveErrorCode.Timeout.ToString()) || ex.IsMatch(OneDriveErrorCode.ServiceNotAvailable.ToString()))
     {
         return(Resources.LocalizedText.OneDriveCantReachService);
     }
     else
     {
         return(ex.Message);
     }
 }
Пример #26
0
        public EASALAPLSailplane() : base()
        {
            BaseFAR           = "FCL.110.S";
            Title             = Resources.MilestoneProgress.EASALAPLSailplaneTitle;
            RatingSought      = RatingType.EASALAPLSailplane;
            GeneralDisclaimer = Branding.ReBrand(Resources.MilestoneProgress.EASALAPLSailplaneTMGNote);

            miTotal        = new MilestoneItem(Resources.MilestoneProgress.EASALAPLSailplaneTotal, ResolvedFAR(string.Empty), Resources.MilestoneProgress.EASALAPLSailplaneNoteTMG, MilestoneItem.MilestoneType.Time, 15.0M);
            miDual         = new MilestoneItem(Resources.MilestoneProgress.EASALAPLSailplaneDual, ResolvedFAR("(1)"), string.Empty, MilestoneItem.MilestoneType.Time, 10.0M);
            miSolo         = new MilestoneItem(Resources.MilestoneProgress.EASALAPLSailplaneSolo, ResolvedFAR("(2)"), string.Empty, MilestoneItem.MilestoneType.Time, 2.0M);
            miLandings     = new MilestoneItem(Resources.MilestoneProgress.EASALAPLSailplaneLaunchesAndLandings, ResolvedFAR("(3)"), Resources.MilestoneProgress.EASALAPLSailplaneLaunchesNotes, MilestoneItem.MilestoneType.Count, 45);
            miCrossCountry = new MilestoneItem(Resources.MilestoneProgress.EASALAPLSailplaneXC, ResolvedFAR("(4)"), string.Empty, MilestoneItem.MilestoneType.AchieveOnce, 1);
        }
Пример #27
0
        protected void Page_Load(object sender, EventArgs e)
        {
            InitWizard(wzRequestSigs);
            Master.SelectedTab = tabID.instSignFlights;
            if (!IsPostBack)
            {
                lblName.Text = String.Format(CultureInfo.CurrentCulture, Resources.Profile.TrainingHeader, HttpUtility.HtmlEncode(Profile.GetUser(Page.User.Identity.Name).UserFullName));

                Master.Title = String.Format(CultureInfo.CurrentCulture, Resources.LocalizedText.TitleTraining, Branding.CurrentBrand.AppName);

                SetUpInstructorList(RefreshFlightsList(util.GetStringParam(Request, "id").Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries)));
                lblSignatureDisclaimer.Text = Branding.ReBrand(Resources.SignOff.SignedFlightDisclaimer);
            }
        }
Пример #28
0
        public EASALAPLHelicopter() : base(RatingType.EASALAPLHelicopter, "FCL.110.H", Resources.MilestoneProgress.TitleEASALAPLHelicopter)
        {
            AircraftClass        = Resources.MilestoneProgress.EASAClassHelicopter;
            CatClass             = CategoryClass.CatClassID.Helicopter;
            DualClassRestriction = Resources.MilestoneProgress.EASAClassHelicopter;
            MinTime         = 40.0M;
            MinDualInClass  = 20.0M;
            MinSolo         = 10.0M;
            MinSoloXC       = 5.0M;
            MinSoloDistance = 80;

            Init();
            miMinTime.Note = Branding.ReBrand(Resources.MilestoneProgress.EASAClassHelicopterNote);
        }
Пример #29
0
        /// <summary>
        /// Send the request via email
        /// </summary>
        public void Send()
        {
            Profile pf = Profile.GetUser(RequestingUser);

            using (MailMessage msg = new MailMessage())
            {
                msg.From = new MailAddress(Branding.CurrentBrand.EmailAddress, String.Format(CultureInfo.CurrentCulture, Resources.SignOff.EmailSenderAddress, Branding.CurrentBrand.AppName, pf.UserFullName));
                msg.ReplyToList.Add(new MailAddress(pf.Email, pf.UserFullName));
                msg.To.Add(new MailAddress(TargetUser));
                msg.Subject = String.Format(CultureInfo.CurrentCulture, Resources.SignOff.InvitationMessageSubject, Branding.CurrentBrand.AppName, pf.UserFullName);

                string szTemplate;
                string szRole = string.Empty;

                switch (Requestedrole)
                {
                case RoleType.RoleCFI:
                    szTemplate = Branding.ReBrand(Resources.SignOff.RoleInvitation);
                    szRole     = Resources.SignOff.RoleInstructor;
                    break;

                case RoleType.RoleStudent:
                    szTemplate = Branding.ReBrand(Resources.SignOff.RoleInvitation);
                    szRole     = Resources.SignOff.RoleStudent;
                    break;

                case RoleType.RoleInviteJoinClub:
                    szTemplate = Branding.ReBrand(Resources.Club.ClubInviteJoin);
                    break;

                case RoleType.RoleRequestJoinClub:
                    szTemplate = Branding.ReBrand(Resources.Club.ClubRequestJoin);
                    break;

                default:
                    throw new MyFlightbookException("Invalid role");
                }

                string szCallBackUrl = String.Format(CultureInfo.InvariantCulture, "http://{0}{1}/Member/AddRelationship.aspx?req={2}", HttpContext.Current.Request.Url.Host, HttpContext.Current.Request.ApplicationPath, HttpContext.Current.Server.UrlEncode(EncryptRequest()));

                string szRequestor = String.Format(CultureInfo.CurrentCulture, "{0} ({1})", pf.UserFullName, pf.Email);

                msg.Body       = String.Format(CultureInfo.InvariantCulture, @"<html>
                        <head><head>
                        <body>{0}</body>
                </html>", szTemplate.Replace("<% Requestor %>", szRequestor).Replace("<% Role %>", szRole).Replace("<% ConfirmRoleLink %>", szCallBackUrl).Replace("<% ClubName %>", ClubToJoin == null ? string.Empty : ClubToJoin.Name).Linkify(false).Replace("\r\n", "<br />"));
                msg.IsBodyHtml = true;
                util.SendMessage(msg);
            }
        }
    private void InitSocialNetworking()
    {
        // Sharing
        lnkMyFlights.Text = HttpUtility.HtmlEncode(m_pf.PublicFlightsURL(Request.Url.Host).AbsoluteUri);
        ClientScript.RegisterClientScriptInclude("copytoClip", ResolveClientUrl("~/public/Scripts/CopyClipboard.js"));
        imgCopyMyFlights.OnClientClick = String.Format(CultureInfo.InvariantCulture, "javascript:copyClipboard(null, '{0}', true, '{1}');return false;", lnkMyFlights.ClientID, lblMyFlightsCopied.ClientID);

        lblGPhotosDesc.Text    = Branding.ReBrand(Resources.LocalizedText.PrefSharingGooglePhotosDesc);
        lnkAuthGPhotos.Text    = Branding.ReBrand(Resources.LocalizedText.PrefSharingGooglePhotosAuthorize);
        lblGPhotosEnabled.Text = Branding.ReBrand(Resources.LocalizedText.PrefSharingGooglePhotosEnabled);
        lnkDeAuthGPhotos.Text  = Branding.ReBrand(Resources.LocalizedText.PrefSharingGooglePhotosDisable);

        mvGPhotos.SetActiveView(m_pf.PreferenceExists(GooglePhoto.PrefKeyAuthToken) ? vwGPhotosEnabled : vwGPhotosDisabled);
    }