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();
        }
    }
Example #2
0
    protected async void lnkSaveGoogleDrive_Click(object sender, EventArgs e)
    {
        MyFlightbook.Profile pf = MyFlightbook.Profile.GetUser(Page.User.Identity.Name);
        LogbookBackup        lb = new LogbookBackup(pf);

        if (pf.GoogleDriveAccessToken == null || String.IsNullOrEmpty(pf.GoogleDriveAccessToken.RefreshToken))
        {
            return;
        }

        try
        {
            GoogleDrive gd = new GoogleDrive(pf.GoogleDriveAccessToken);

            await lb.BackupToGoogleDrive(gd).ConfigureAwait(false);

            if (ckIncludeImages.Checked)
            {
                await lb.BackupImagesToGoogleDrive(gd).ConfigureAwait(false);
            }

            // if we are here we were successful, so save the updated refresh token
            pf.GoogleDriveAccessToken = gd.AuthState;
            pf.FCommit();

            lblDropBoxSuccess.Visible = true;
        }
        catch (Exception ex) when(!(ex is OutOfMemoryException))
        {
            ShowDropboxError(ex.Message);
        }
    }
Example #3
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);
            }
        }
    }
    /// <summary>
    /// Sets up things like decimal vs. hhMM mode, alternat category classes list, etc.
    /// </summary>
    protected void InitBasicControls()
    {
        if (Session[keyTailwheelList] != null && cmbAircraft.Items.Count > 0) // we've already initialized...
        {
            m_rgTailwheelAircraft = (ArrayList)Session[keyTailwheelList];
            return;
        }

        if (Request.IsMobileDevice())
        {
            cmbAircraft.Width = txtRoute.Width = txtComments.Width = Unit.Pixel(130);
        }

        ckUpdateTwitter.Checked = mfbTwitter.FDefaultTwitterCheckboxState && (FlightID > 0);  // don't default the facebook/twitter checkboxes on if this is editing an existing flight.
        ckFacebook.Checked      = mfbFacebook1.FDefaultFacebookCheckboxState && (FlightID > 0);

        // Use the desired editing mode.
        MyFlightbook.Profile             pf = MyFlightbook.Profile.GetUser(Page.User.Identity.Name);
        Controls_mfbDecimalEdit.EditMode em = pf.UsesHHMM ? Controls_mfbDecimalEdit.EditMode.HHMMFormat : Controls_mfbDecimalEdit.EditMode.Decimal;
        decCFI.EditingMode           = decDual.EditingMode = decGrndSim.EditingMode = decIMC.EditingMode =
            decNight.EditingMode     = decPIC.EditingMode = decSIC.EditingMode = decSimulatedIFR.EditingMode =
                decTotal.EditingMode = decXC.EditingMode = em;

        // And enable/disable facebook/twitter:
        ckFacebook.Visible      = pf.CanPostFacebook();
        ckUpdateTwitter.Visible = pf.CanTweet();
        mvFacebook.SetActiveView(pf.CanPostFacebook() ? vwFacebookActive : vwFacebookInactive);
        mvTwitter.SetActiveView(pf.CanTweet() ? vwTwitterActive : vwTwitterInactive);

        mfbEditPropSet1.CrossFillSourceClientID = decCFI.CrossFillSourceClientID = decDual.CrossFillSourceClientID = decGrndSim.CrossFillSourceClientID = decIMC.CrossFillSourceClientID =
            decNight.CrossFillSourceClientID    = decPIC.CrossFillSourceClientID = decSIC.CrossFillSourceClientID = decSimulatedIFR.CrossFillSourceClientID = decXC.CrossFillSourceClientID = decTotal.EditBox.ClientID;
    }
    /// <summary>
    /// Sets up things like decimal vs. hhMM mode, alternat category classes list, etc.
    /// </summary>
    protected void InitBasicControls()
    {
        if (Session[keyTailwheelList] != null && cmbAircraft.Items.Count > 0) // we've already initialized...
        {
            m_rgTailwheelAircraft = (List <int>)Session[keyTailwheelList];
            return;
        }

        if (Request.IsMobileDevice())
        {
            cmbAircraft.Width = txtRoute.Width = txtComments.Width = Unit.Pixel(130);
        }

        // Use the desired editing mode.
        MyFlightbook.Profile             pf = MyFlightbook.Profile.GetUser(Page.User.Identity.Name);
        Controls_mfbDecimalEdit.EditMode em = pf.UsesHHMM ? Controls_mfbDecimalEdit.EditMode.HHMMFormat : Controls_mfbDecimalEdit.EditMode.Decimal;
        decCFI.EditingMode           = decDual.EditingMode = decGrndSim.EditingMode = decIMC.EditingMode =
            decNight.EditingMode     = decPIC.EditingMode = decSIC.EditingMode = decSimulatedIFR.EditingMode =
                decTotal.EditingMode = decXC.EditingMode = em;

        mfbEditPropSet1.CrossFillSourceClientID = decCFI.CrossFillSourceClientID = decDual.CrossFillSourceClientID = decGrndSim.CrossFillSourceClientID = decIMC.CrossFillSourceClientID =
            decNight.CrossFillSourceClientID    = decPIC.CrossFillSourceClientID = decSIC.CrossFillSourceClientID = decSimulatedIFR.CrossFillSourceClientID = decXC.CrossFillSourceClientID = decTotal.EditBox.ClientID;

        mfbMFUFlightImages.AllowGoogleImport = pf.PreferenceExists(GooglePhoto.PrefKeyAuthToken);
    }
Example #6
0
    protected void Page_Init(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            for (int i = 3; i <= 20; i++)
            {
                cmbFlightsPerPage.Items.Add(new ListItem(String.Format(CultureInfo.CurrentCulture, Resources.LocalizedText.PrintViewXPerPage, i), i.ToString(CultureInfo.InvariantCulture))
                {
                    Selected = (i == 15)
                });
            }

            MyFlightbook.Profile      pf        = MyFlightbook.Profile.GetUser(Page.User.Identity.Name);
            List <CustomPropertyType> rgcptUser = new List <CustomPropertyType>(CustomPropertyType.GetCustomPropertyTypes(Page.User.Identity.Name));
            rgcptUser.RemoveAll(cpt => !cpt.IsFavorite && !pf.BlacklistedProperties.Contains(cpt.PropTypeID));
            List <CustomPropertyType> rgcptUserOptionalColumns = rgcptUser.FindAll(cpt => (cpt.Type == CFPPropertyType.cfpDecimal || cpt.Type == CFPPropertyType.cfpInteger) && !cpt.IsNoSum);
            rgcptUser.Sort((cpt1, cpt2) => { return(cpt1.Title.CompareCurrentCultureIgnoreCase(cpt2.Title)); });
            cklProperties.DataSource = rgcptUser;
            cklProperties.DataBind();
            expPropertiesToExclude.Visible = rgcptUser.Count > 0;

            // By default, exclude "Additional flight remarks"
            foreach (ListItem li in cklProperties.Items)
            {
                if (Convert.ToInt32(li.Value, CultureInfo.InvariantCulture) == (int)CustomPropertyType.KnownProperties.IDPropAdditionalFlightRemarks)
                {
                    li.Selected = true;
                }
            }

            List <ListItem> lstOptionalColumnDropdowns = new List <ListItem>()
            {
                new ListItem(Resources.LocalizedText.PrintViewOptionalColumnNone, string.Empty),
                new ListItem(Resources.Makes.IsComplex, OptionalColumnType.Complex.ToString()),
                new ListItem(Resources.Makes.IsRetract, OptionalColumnType.Retract.ToString()),
                new ListItem(Resources.Makes.IsTailwheel, OptionalColumnType.Tailwheel.ToString()),
                new ListItem(Resources.Makes.IsHighPerf, OptionalColumnType.HighPerf.ToString()),
                new ListItem(Resources.Makes.IsTurboprop, OptionalColumnType.TurboProp.ToString()),
                new ListItem(Resources.Makes.IsTurbine, OptionalColumnType.Turbine.ToString()),
                new ListItem(Resources.Makes.IsJet, OptionalColumnType.Jet.ToString()),
            };
            rgcptUserOptionalColumns.Sort((cpt1, cpt2) => { return(cpt1.Title.CompareCurrentCultureIgnoreCase(cpt2.Title)); });
            foreach (CustomPropertyType cpt in rgcptUserOptionalColumns)
            {
                lstOptionalColumnDropdowns.Add(new ListItem(cpt.Title, cpt.PropTypeID.ToString(CultureInfo.InvariantCulture)));
            }
            foreach (DropDownList ddl in OptionalColumnDropDowns)
            {
                ddl.DataSource = lstOptionalColumnDropdowns;
                ddl.DataBind();
            }
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            // verify that we have a valid user (should never be a problem)
            if (!Page.User.Identity.IsAuthenticated)
            {
                return;
            }

            MyFlightbook.Profile pf = MyFlightbook.Profile.GetUser(Page.User.Identity.Name);

            cmbFieldToview.Items.FindByValue("CFI").Enabled = pf.IsInstructor;
            cmbFieldToview.Items.FindByValue("SIC").Enabled = pf.TracksSecondInCommandTime;
        }
        else if (Visible)
        {
            RefreshChartAndTable();
        }
    }
    protected async void lnkSaveGoogleDrive_Click(object sender, EventArgs e)
    {
        MyFlightbook.Profile pf = MyFlightbook.Profile.GetUser(Page.User.Identity.Name);
        LogbookBackup        lb = new LogbookBackup(pf);

        if (pf.GoogleDriveAccessToken == null || String.IsNullOrEmpty(pf.GoogleDriveAccessToken.RefreshToken))
        {
            return;
        }

        try
        {
            GoogleDrive gd = new GoogleDrive(pf.GoogleDriveAccessToken);

            if (await gd.RefreshAccessToken())
            {
                pf.FCommit();
            }

            await lb.BackupToGoogleDrive(gd);

            if (ckIncludeImages.Checked)
            {
                await lb.BackupImagesToGoogleDrive(gd);
            }

            lblDropBoxSuccess.Visible = true;
        }
        catch (MyFlightbookException ex)
        {
            ShowDropboxError(ex.Message);
        }
        catch (System.Net.Http.HttpRequestException ex)
        {
            ShowDropboxError(ex.Message);
        }
        catch (Exception ex)
        {
            ShowDropboxError(ex.Message);
        }
    }
Example #9
0
    protected void RefreshLogbookData()
    {
        MyFlightbook.Profile pf = MyFlightbook.Profile.GetUser(Page.User.Identity.Name);
        PrintingOptions      printingOptions = PrintOptions1.Options;

        mvLayouts.ActiveViewIndex = (int)printingOptions.Layout;
        List <LogbookEntryDisplay> lstFlights = LogbookEntryDisplay.GetFlightsForQuery(LogbookEntry.QueryCommand(mfbSearchForm1.Restriction, fAsc: true), pf.UserName, string.Empty, SortDirection.Ascending, pf.UsesHHMM, pf.UsesUTCDateOfFlight);

        IPrintingTemplate pt = ActiveTemplate;

        PrintLayout pl = PrintLayout.LayoutForType(printingOptions.Layout, CurrentUser);
        bool        fCanIncludeImages = pl.SupportsImages;

        List <int> lstPropsToExclude = new List <int>(printingOptions.ExcludedPropertyIDs);
        string     szPropSeparator   = printingOptions.PropertySeparatorText;

        // set up properties per flight, and compute rough lineheight
        foreach (LogbookEntryDisplay led in lstFlights)
        {
            // Fix up properties according to the printing options
            List <CustomFlightProperty> lstProps = new List <CustomFlightProperty>(led.CustomProperties);
            lstProps.RemoveAll(cfp => lstPropsToExclude.Contains(cfp.PropTypeID));

            led.CustomProperties    = lstProps.ToArray();
            led.CustPropertyDisplay = CustomFlightProperty.PropListDisplay(lstProps, pf.UsesHHMM, szPropSeparator);

            if (printingOptions.IncludeImages)
            {
                led.PopulateImages(true);
            }

            led.RowHeight = pl.RowHeight(led);
        }

        Master.PrintingCSS = pl.CSSPath.ToAbsoluteURL(Request).ToString();

        pt.BindPages(LogbookPrintedPage.Paginate(lstFlights, printingOptions.FlightsPerPage, printingOptions.OptionalColumns), CurrentUser, printingOptions.IncludeImages, !SuppressFooter, printingOptions.OptionalColumns);

        pnlResults.Visible = true;
    }
Example #10
0
    protected async void lnkSaveOneDrive_Click(object sender, EventArgs e)
    {
        MyFlightbook.Profile pf = MyFlightbook.Profile.GetUser(Page.User.Identity.Name);
        LogbookBackup        lb = new LogbookBackup(pf);

        if (pf.OneDriveAccessToken == null || String.IsNullOrEmpty(pf.OneDriveAccessToken.RefreshToken))
        {
            return;
        }
        try
        {
            OneDrive od = new OneDrive(pf.OneDriveAccessToken);
            await lb.BackupToOneDrive(od);

            if (ckIncludeImages.Checked)
            {
                await lb.BackupImagesToOneDrive(od);
            }

            // if we are here we were successful, so save the updated refresh token
            pf.OneDriveAccessToken.RefreshToken = od.AuthState.RefreshToken;
            pf.FCommit();

            lblDropBoxSuccess.Visible = true;
        }
        catch (OneDriveException ex)
        {
            ShowDropboxError(OneDrive.MessageForException(ex));
        }
        catch (MyFlightbookException ex)
        {
            ShowDropboxError(ex.Message);
        }
        catch (Exception ex)
        {
            ShowDropboxError(ex.Message);
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        this.Master.SelectedTab = tabID.tabTraining;
        this.Master.Title       = String.Format(CultureInfo.CurrentCulture, Resources.LocalizedText.TitleProfile, Branding.CurrentBrand.AppName);

        string szReq = util.GetStringParam(Request, "req");

        try
        {
            if (szReq.Length == 0)
            {
                throw new MyFlightbookValidationException(Resources.LocalizedText.AddRelationshipErrInvalidRequest);
            }

            m_smr = new CFIStudentMapRequest();
            m_smr.DecryptRequest(szReq);

            MyFlightbook.Profile pfRequestor = MyFlightbook.Profile.GetUser(m_smr.RequestingUser);
            if (!pfRequestor.IsValid())
            {
                throw new MyFlightbookValidationException(Resources.LocalizedText.AddRelationshipErrInvalidUser);
            }

            MyFlightbook.Profile pfCurrent = MyFlightbook.Profile.GetUser(User.Identity.Name);
            if (String.Compare(m_smr.TargetUser, pfCurrent.Email, StringComparison.OrdinalIgnoreCase) != 0)
            {
                throw new MyFlightbookValidationException(String.Format(CultureInfo.CurrentCulture, Resources.LocalizedText.AddRelationshipErrNotTargetUser, m_smr.TargetUser, pfCurrent.Email));
            }

            m_sm = new CFIStudentMap(User.Identity.Name);

            switch (m_smr.Requestedrole)
            {
            case CFIStudentMapRequest.RoleType.RoleStudent:
                lblRequestDesc.Text = String.Format(CultureInfo.CurrentCulture, Resources.LocalizedText.AddRelationshipRequestStudent, Branding.CurrentBrand.AppName, HttpUtility.HtmlEncode(pfRequestor.UserFullName));
                if (m_sm.IsStudentOf(m_smr.RequestingUser))
                {
                    throw new MyFlightbookValidationException(String.Format(CultureInfo.CurrentCulture, Resources.LocalizedText.AddRelationshipErrAlreadyStudent, pfRequestor.UserFullName));
                }
                break;

            case CFIStudentMapRequest.RoleType.RoleCFI:
                lblRequestDesc.Text = String.Format(CultureInfo.CurrentCulture, Resources.LocalizedText.AddRelationshipRequestInstructor, Branding.CurrentBrand.AppName, HttpUtility.HtmlEncode(pfRequestor.UserFullName));
                if (m_sm.IsInstructorOf(m_smr.RequestingUser))
                {
                    throw new MyFlightbookValidationException(String.Format(CultureInfo.CurrentCulture, Resources.LocalizedText.AddRelationshipErrAlreadyInstructor, pfRequestor.UserFullName));
                }
                break;

            case CFIStudentMapRequest.RoleType.RoleInviteJoinClub:
                if (m_smr.ClubToJoin == null)
                {
                    throw new MyFlightbookValidationException(Resources.Club.errNoClubInRequest);
                }
                if (m_smr.ClubToJoin.HasMember(pfCurrent.UserName))
                {
                    throw new MyFlightbookValidationException(String.Format(CultureInfo.CurrentCulture, Resources.Club.errAlreadyMember, m_smr.ClubToJoin.Name));
                }
                lblRequestDesc.Text = String.Format(CultureInfo.CurrentCulture, Resources.Club.AddMemberFromInvitation, m_smr.ClubToJoin.Name);
                break;

            case CFIStudentMapRequest.RoleType.RoleRequestJoinClub:
                if (m_smr.ClubToJoin == null)
                {
                    throw new MyFlightbookValidationException(Resources.Club.errNoClubInRequest);
                }
                if (m_smr.ClubToJoin.HasMember(pfRequestor.UserName))
                {
                    throw new MyFlightbookValidationException(String.Format(CultureInfo.CurrentCulture, Resources.Club.errAlreadyAddedMember, pfRequestor.UserFullName, m_smr.ClubToJoin.Name));
                }
                lblRequestDesc.Text = String.Format(CultureInfo.CurrentCulture, Resources.Club.AddMemberFromRequest, HttpUtility.HtmlEncode(pfRequestor.UserFullName), m_smr.ClubToJoin.Name);
                break;
            }
        }
        catch (MyFlightbookValidationException ex)
        {
            pnlReviewRequest.Visible = false;
            lblError.Text            = ex.Message;
            pnlConfirm.Visible       = false;
        }
    }
Example #12
0
    protected void RefreshLogbookData()
    {
        MyFlightbook.Profile pf = MyFlightbook.Profile.GetUser(Page.User.Identity.Name);
        PrintingOptions      printingOptions = PrintOptions1.Options;

        mvLayouts.ActiveViewIndex = (int)printingOptions.Layout;
        List <LogbookEntryDisplay> lstFlights = LogbookEntryDisplay.GetFlightsForQuery(LogbookEntry.QueryCommand(mfbSearchForm1.Restriction, fAsc: true), pf.UserName, string.Empty, SortDirection.Ascending, pf.UsesHHMM, pf.UsesUTCDateOfFlight);

        IPrintingTemplate pt = ActiveTemplate;

        PrintLayout pl = PrintLayout.LayoutForType(printingOptions.Layout, CurrentUser);
        bool        fCanIncludeImages = pl.SupportsImages;

        // Exclude both excluded properties and properties that have been moved to their own columns
        HashSet <int> lstPropsToExclude    = new HashSet <int>(printingOptions.ExcludedPropertyIDs);
        HashSet <int> lstPropsInOwnColumns = new HashSet <int>();

        foreach (OptionalColumn oc in printingOptions.OptionalColumns)
        {
            if (oc.ColumnType == OptionalColumnType.CustomProp)
            {
                lstPropsInOwnColumns.Add(oc.IDPropType);
            }
        }
        string szPropSeparator = printingOptions.PropertySeparatorText;

        // set up properties per flight, and compute rough lineheight
        foreach (LogbookEntryDisplay led in lstFlights)
        {
            // Fix up properties according to the printing options
            List <CustomFlightProperty> lstProps = new List <CustomFlightProperty>(led.CustomProperties);

            // And fix up model as well.
            switch (printingOptions.DisplayMode)
            {
            case PrintingOptions.ModelDisplayMode.Full:
                break;

            case PrintingOptions.ModelDisplayMode.Short:
                led.ModelDisplay = led.ShortModelName;
                break;

            case PrintingOptions.ModelDisplayMode.ICAO:
                led.ModelDisplay = led.FamilyName;
                break;
            }


            // Remove from the total property set all explicitly excluded properties...
            lstProps.RemoveAll(cfp => lstPropsToExclude.Contains(cfp.PropTypeID));

            // ...and then additionally exclude from the display any that's in its own column to avoid redundancy.
            lstProps.RemoveAll(cfp => lstPropsInOwnColumns.Contains(cfp.PropTypeID));
            led.CustPropertyDisplay = CustomFlightProperty.PropListDisplay(lstProps, pf.UsesHHMM, szPropSeparator);

            if (printingOptions.IncludeImages)
            {
                led.PopulateImages(true);
            }

            if (!printingOptions.IncludeSignatures)
            {
                led.CFISignatureState = LogbookEntryBase.SignatureState.None;
            }
            led.RowHeight = pl.RowHeight(led);
        }

        Master.PrintingCSS = pl.CSSPath.ToAbsoluteURL(Request).ToString();

        pt.BindPages(LogbookPrintedPage.Paginate(lstFlights, printingOptions), CurrentUser, printingOptions, !SuppressFooter);

        pnlResults.Visible = true;
    }
    /// <summary>
    /// Fills in the form to edit a flight based on a LogbookEntry object
    /// </summary>
    /// <param name="le">The logbook entry object</param>
    private void InitFormFromLogbookEntry(LogbookEntry le)
    {
        mfbDate.Date = le.Date;

        if (le.AircraftID != Aircraft.idAircraftUnknown)
        {
            // try to select the aircraft based on the flight aircraft
            try { cmbAircraft.SelectedValue = le.AircraftID.ToString(CultureInfo.InvariantCulture); }
            catch (ArgumentOutOfRangeException) { cmbAircraft.SelectedIndex = 0; }
        }
        else
        {
            cmbAircraft.SelectedIndex = 0;
        }

        intApproaches.IntValue       = le.Approaches;
        intLandings.IntValue         = le.Landings;
        intFullStopLandings.IntValue = le.FullStopLandings;
        intNightLandings.IntValue    = le.NightLandings;
        decNight.Value        = le.Nighttime;
        decPIC.Value          = le.PIC;
        decSimulatedIFR.Value = le.SimulatedIFR;
        decGrndSim.Value      = le.GroundSim;
        decDual.Value         = le.Dual;
        decXC.Value           = le.CrossCountry;
        decIMC.Value          = le.IMC;
        decCFI.Value          = le.CFI;
        decSIC.Value          = le.SIC;
        decTotal.Value        = le.TotalFlightTime;
        ckHold.Checked        = le.fHoldingProcedures;
        txtRoute.Text         = le.Route;
        txtComments.Text      = le.Comment;
        ckPublic.Checked      = le.fIsPublic;

        mfbFlightInfo1.FlightID      = le.FlightID;
        mfbFlightInfo1.HobbsStart    = le.HobbsStart;
        mfbFlightInfo1.HobbsEnd      = le.HobbsEnd;
        mfbFlightInfo1.EngineStart   = le.EngineStart;
        mfbFlightInfo1.EngineEnd     = le.EngineEnd;
        mfbFlightInfo1.FlightStart   = le.FlightStart;
        mfbFlightInfo1.FlightEnd     = le.FlightEnd;
        mfbFlightInfo1.HasFlightData = le.HasFlightData;
        if (le.HasFlightData)
        {
            mfbFlightInfo1.Telemetry = le.FlightData;
        }
        AltCatClass = le.CatClassOverride;

        if (util.GetIntParam(Request, "oldProps", 0) != 0)
        {
            mvPropEdit.SetActiveView(vwLegacyProps);
            mfbFlightProperties1.Enabled = true;
            mfbFlightProperties1.SetFlightProperties(le.CustomProperties);
        }
        else
        {
            mfbEditPropSet1.SetFlightProperties(le.CustomProperties);
        }

        MyFlightbook.Profile pf = MyFlightbook.Profile.GetUser(Page.User.Identity.Name);
        divCFI.Visible = pf.IsInstructor;
        divSIC.Visible = pf.TracksSecondInCommandTime;
    }
Example #14
0
    protected void wzRequestSigs_FinishButtonClick(object sender, WizardNavigationEventArgs e)
    {
        IEnumerable <LogbookEntry> lstFlights = SelectedFlights;

        string szCFIUsername = String.Empty;
        string szCFIEmail    = String.Empty;

        MyFlightbook.Profile pfCFI = null;


        bool fIsNewCFI = String.IsNullOrEmpty(cmbInstructors.SelectedValue);

        // Check In case the named email is already an instructor.
        CFIStudentMap sm = new CFIStudentMap(User.Identity.Name);

        if (fIsNewCFI && sm.IsStudentOf(txtCFIEmail.Text))
        {
            fIsNewCFI = false;
            foreach (InstructorStudent inst in sm.Instructors)
            {
                if (String.Compare(inst.Email, txtCFIEmail.Text, StringComparison.CurrentCultureIgnoreCase) == 0)
                {
                    pfCFI = inst;
                    break;
                }
            }
        }
        else
        {
            pfCFI = MyFlightbook.Profile.GetUser(cmbInstructors.SelectedValue);
        }

        if (fIsNewCFI)
        {
            szCFIEmail = txtCFIEmail.Text;
        }
        else
        {
            szCFIUsername = pfCFI.UserName;
        }

        // check if we already know the email

        foreach (LogbookEntry le in lstFlights)
        {
            le.RequestSignature(szCFIUsername, szCFIEmail);
        }

        // Now send the email
        if (fIsNewCFI)
        {
            CFIStudentMapRequest smr = sm.GetRequest(CFIStudentMapRequest.RoleType.RoleCFI, szCFIEmail);
            smr.Send();
        }
        else
        {
            Profile pf = MyFlightbook.Profile.GetUser(User.Identity.Name);
            using (MailMessage msg = new MailMessage())
            {
                msg.From = new MailAddress(Branding.CurrentBrand.EmailAddress, String.Format(System.Globalization.CultureInfo.CurrentCulture, Resources.SignOff.EmailSenderAddress, Branding.CurrentBrand.AppName, pf.UserFullName));
                msg.ReplyToList.Add(new MailAddress(pf.Email, pf.UserFullName));
                msg.To.Add(new MailAddress(pfCFI.Email, pfCFI.UserFullName));
                msg.Subject = String.Format(System.Globalization.CultureInfo.CurrentCulture, Resources.SignOff.SignRequestSubject, pf.UserFullName, Branding.CurrentBrand.AppName);

                string szURL = String.Format(System.Globalization.CultureInfo.InvariantCulture, "https://{0}{1}/{2}", Request.Url.Host, ResolveUrl("~/Member/Training.aspx"), tabID.instStudents.ToString());

                msg.Body = Branding.ReBrand(Resources.SignOff.SignInvitationExisting).Replace("<% SignPendingFlightsLink %>", szURL).Replace("<% Requestor %>", pf.UserFullName);
                util.SendMessage(msg);
            }
        }

        Response.Redirect(String.Format(System.Globalization.CultureInfo.InvariantCulture, "~/Member/Training.aspx/{0}", tabID.instSignFlights));
    }
    protected void SetPropsForUser()
    {
        MyFlightbook.Profile      pf        = MyFlightbook.Profile.GetUser(UserName);
        List <CustomPropertyType> rgcptUser = new List <CustomPropertyType>(CustomPropertyType.GetCustomPropertyTypes(pf.UserName));

        rgcptUser.RemoveAll(cpt => !cpt.IsFavorite && !pf.BlocklistedProperties.Contains(cpt.PropTypeID));
        List <CustomPropertyType> rgcptUserOptionalColumns = rgcptUser.FindAll(cpt => (cpt.Type == CFPPropertyType.cfpDecimal || cpt.Type == CFPPropertyType.cfpInteger) && !cpt.IsNoSum);

        rgcptUser.Sort((cpt1, cpt2) => { return(cpt1.Title.CompareCurrentCultureIgnoreCase(cpt2.Title)); });
        cklProperties.DataSource = rgcptUser;
        cklProperties.DataBind();
        ckCheckAll.Visible             = rgcptUser.Count > 4;
        expPropertiesToExclude.Visible = rgcptUser.Count > 0;

        // By default, exclude "Additional flight remarks"
        foreach (ListItem li in cklProperties.Items)
        {
            if (Convert.ToInt32(li.Value, CultureInfo.InvariantCulture) == (int)CustomPropertyType.KnownProperties.IDPropAdditionalFlightRemarks)
            {
                li.Selected = true;
            }
        }

        List <ListItem> lstOptionalColumnDropdowns = new List <ListItem>()
        {
            new ListItem(Resources.LocalizedText.PrintViewOptionalColumnNone, string.Empty),
            new ListItem(Resources.Makes.IsComplex, OptionalColumnType.Complex.ToString()),
            new ListItem(Resources.Makes.IsRetract, OptionalColumnType.Retract.ToString()),
            new ListItem(Resources.Makes.IsTailwheel, OptionalColumnType.Tailwheel.ToString()),
            new ListItem(Resources.Makes.IsHighPerf, OptionalColumnType.HighPerf.ToString()),
            new ListItem(Resources.Makes.IsTAA, OptionalColumnType.TAA.ToString()),
            new ListItem(Resources.Makes.IsTurboprop, OptionalColumnType.TurboProp.ToString()),
            new ListItem(Resources.Makes.IsTurbine, OptionalColumnType.Turbine.ToString()),
            new ListItem(Resources.Makes.IsJet, OptionalColumnType.Jet.ToString()),
            new ListItem(Resources.LocalizedText.DropDownListSeparator, string.Empty),
            new ListItem(OptionalColumn.TitleForType(OptionalColumnType.ATD), OptionalColumnType.ATD.ToString()),
            new ListItem(OptionalColumn.TitleForType(OptionalColumnType.FTD), OptionalColumnType.FTD.ToString()),
            new ListItem(OptionalColumn.TitleForType(OptionalColumnType.FFS), OptionalColumnType.FFS.ToString()),
            new ListItem(Resources.LocalizedText.DropDownListSeparator, string.Empty),
            new ListItem(OptionalColumn.TitleForType(OptionalColumnType.ASEL), OptionalColumnType.ASEL.ToString()),
            new ListItem(OptionalColumn.TitleForType(OptionalColumnType.AMEL), OptionalColumnType.AMEL.ToString()),
            new ListItem(OptionalColumn.TitleForType(OptionalColumnType.ASES), OptionalColumnType.ASES.ToString()),
            new ListItem(OptionalColumn.TitleForType(OptionalColumnType.AMES), OptionalColumnType.AMES.ToString()),
            new ListItem(OptionalColumn.TitleForType(OptionalColumnType.Helicopter), OptionalColumnType.Helicopter.ToString()),
            new ListItem(OptionalColumn.TitleForType(OptionalColumnType.Glider), OptionalColumnType.Glider.ToString()),
        };

        if (rgcptUserOptionalColumns.Count > 0)
        {
            lstOptionalColumnDropdowns.Add(new ListItem(Resources.LocalizedText.DropDownListSeparator, string.Empty));
        }
        rgcptUserOptionalColumns.Sort((cpt1, cpt2) => { return(cpt1.Title.CompareCurrentCultureIgnoreCase(cpt2.Title)); });
        foreach (CustomPropertyType cpt in rgcptUserOptionalColumns)
        {
            lstOptionalColumnDropdowns.Add(new ListItem(cpt.Title, cpt.PropTypeID.ToString(CultureInfo.InvariantCulture)));
        }

        foreach (DropDownList ddl in OptionalColumnDropDowns)
        {
            ddl.DataSource = lstOptionalColumnDropdowns;
            ddl.DataBind();
        }
    }