protected void onAutofill(object sender, EventArgs e)
    {
        if (this.AutoFill != null)
        {
            int             takeoffSpeed = Convert.ToInt32(rblTakeOffSpeed.SelectedValue, CultureInfo.InvariantCulture);
            AutoFillOptions afo          = new AutoFillOptions()
            {
                TimeZoneOffset     = mfbTimeZone1.TimeZoneOffset,
                TakeOffSpeed       = takeoffSpeed,
                LandingSpeed       = AutoFillOptions.BestLandingSpeedForTakeoffSpeed(takeoffSpeed),
                IncludeHeliports   = ckIncludeHeliports.Checked,
                AutoSynthesizePath = ckEstimateNight.Checked,
                Night        = (AutoFillOptions.NightCritera)Enum.Parse(typeof(AutoFillOptions.NightCritera), rblNightCriteria.SelectedValue, true),
                NightLanding = (AutoFillOptions.NightLandingCriteria)Enum.Parse(typeof(AutoFillOptions.NightLandingCriteria), rblNightLandingCriteria.SelectedValue, true),
                RoundToTenth = ckRoundNearest10th.Checked,
                IgnoreErrors = true
            };

            afo.ToCookies(Response.Cookies);

            string szTelemetry = Telemetry;
            // Load from the DB if needed
            if (String.IsNullOrEmpty(szTelemetry) && !LogbookEntry.IsNewFlightID(FlightID))
            {
                szTelemetry = new LogbookEntry(FlightID, Page.User.Identity.Name, LogbookEntry.LoadTelemetryOption.LoadAll).FlightData;
            }

            this.AutoFill(this, new AutofillEventArgs(afo, szTelemetry));
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.User.Identity.IsAuthenticated)
        {
            throw new UnauthorizedAccessException("You must be signed in to view this page.");
        }

        InitWizard(wzFlightsFromTelemetry);
        if (IsPostBack)
        {
            Session[SessionKeyTZ]  = TimeZone.SelectedTimeZone;
            Session[SessionKeyOpt] = AutofillOptionsChooser.Options;
        }
        else
        {
            Profile pf = Profile.GetUser(Page.User.Identity.Name);
            if (pf.PreferredTimeZone != null && Session[SessionKeyTZ] == null)
            {
                Session[SessionKeyTZ] = pf.PreferredTimeZone;
            }

            if (Session[SessionKeyTZ] != null)
            {
                TimeZone.SelectedTimeZone = (TimeZoneInfo)Session[SessionKeyTZ];
            }

            AutoFillOptions afo = AutoFillOptions.DefaultOptionsForUser(Page.User.Identity.Name);
            afo.SaveForUser(Page.User.Identity.Name);
            Session[SessionKeyOpt] = afo;
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            AutoFillOptions afo = new AutoFillOptions(Request.Cookies);

            foreach (int speed in AutoFillOptions.DefaultSpeeds)
            {
                ListItem li = new ListItem(String.Format(CultureInfo.CurrentCulture, Resources.FlightData.KnotsTemplate, speed), speed.ToString(CultureInfo.InvariantCulture))
                {
                    Selected = (speed == afo.TakeOffSpeed)
                };
                rblTakeOffSpeed.Items.Add(li);
            }
            ckIncludeHeliports.Checked            = afo.IncludeHeliports;
            ckEstimateNight.Checked               = afo.AutoSynthesizePath;
            ckRoundNearest10th.Checked            = afo.RoundToTenth;
            rblNightCriteria.SelectedValue        = afo.Night.ToString();
            rblNightLandingCriteria.SelectedValue = afo.NightLanding.ToString();

            lblEngine.Text = Resources.LogbookEntry.FieldEngineUTC.IndicateUTCOrCustomTimeZone(UserTimeZone);
            lblFlight.Text = Resources.LogbookEntry.FieldFlightUTC.IndicateUTCOrCustomTimeZone(UserTimeZone);
            if (UserTimeZone.Id.CompareCurrentCultureIgnoreCase(TimeZoneInfo.Utc.Id) == 0)
            {
                lblEngine.ToolTip = lblFlight.ToolTip = string.Empty;
            }
            else
            {
                lblEngine.ToolTip = lblFlight.ToolTip = UserTimeZone.DisplayName;
            }
        }
    }
Exemple #4
0
        private static void AutoComplete(LogbookEntry le)
        {
            // Issue #939: autofill cross-country/night, when possible.
            AutoFillOptions afo = AutoFillOptions.DefaultOptionsForUser(le.User);

            if (afo != null && le.CrossCountry == 0.0M)
            {
                if (le.Nighttime == 0.0M)
                {
                    using (FlightData fd = new FlightData())
                        fd.AutoFill(le, afo);
                }
                else  // just do xc time based on part 121 xc
                {
                    CannedQuery fq = new CannedQuery()
                    {
                        Distance = FlightQuery.FlightDistance.NonLocalOnly
                    };
                    if (fq.IsAirportMatch(le))
                    {
                        le.CrossCountry = le.TotalFlightTime;
                    }
                }
            }
        }
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         Options = AutoFillOptions.DefaultOptionsForUser(Page.User.Identity.Name);
         Options.TimeZoneOffset = TimeZoneOffset;
     }
 }
Exemple #6
0
        private void OnEnable()
        {
            themeNameProp    = serializedObject.FindProperty("themeName");
            typeProp         = serializedObject.FindProperty("type");
            baseVariantsProp = serializedObject.FindProperty("baseVariants");

            fillOptions = new AutoFillOptions();
        }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            AutoFillOptions afo = new AutoFillOptions(Request.Cookies);

            foreach (int speed in AutoFillOptions.DefaultSpeeds)
            {
                ListItem li = new ListItem(String.Format(CultureInfo.CurrentCulture, Resources.FlightData.KnotsTemplate, speed), speed.ToString(CultureInfo.InvariantCulture))
                {
                    Selected = (speed == afo.TakeOffSpeed)
                };
                rblTakeOffSpeed.Items.Add(li);
            }
            ckIncludeHeliports.Checked            = afo.IncludeHeliports;
            ckEstimateNight.Checked               = afo.AutoSynthesizePath;
            ckRoundNearest10th.Checked            = afo.RoundToTenth;
            rblNightCriteria.SelectedValue        = afo.Night.ToString();
            rblNightLandingCriteria.SelectedValue = afo.NightLanding.ToString();
        }
    }
Exemple #8
0
    protected void PreviewData()
    {
        lblError.Text = "";

        mvPreviewResults.SetActiveView(vwPreviewResults);                       // default to showing results.

        mfbImportAircraft1.CandidatesForImport = new AircraftImportMatchRow[0]; // start fresh every time.

        byte[] rgb = CurrentCSVSource;
        if (rgb == null || rgb.Length == 0)
        {
            lblFileRequired.Text = Resources.LogbookEntry.errImportInvalidCSVFile;
            SetWizardStep(wsUpload);
            return;
        }

        // issue #280: some files have \r\r\n as line separators!
        rgb = Encoding.UTF8.GetBytes(Encoding.UTF8.GetString(rgb).Replace("\r\r\n", "\r\n"));

        // Validate the file
        ExternalFormatImporter efi = ExternalFormatImporter.GetImporter(rgb);

        if (efi != null)
        {
            rgb           = efi.PreProcess(rgb);
            IsPendingOnly = efi.IsPendingOnly;
        }

        MemoryStream ms = new MemoryStream(rgb);

        try
        {
            pnlConverted.Visible = pnlAudit.Visible = false;
            lblAudit.Text        = string.Empty;
            using (CSVAnalyzer csvAnalyzer = new CSVAnalyzer(ms))
            {
                ms = null;  // Avoid CA2202
                CSVAnalyzer.CSVStatus result = csvAnalyzer.Status;
                hdnAuditState.Value = result.ToString();

                if (result != CSVAnalyzer.CSVStatus.Broken)
                {
                    string szCSV = null;
                    if (efi == null)    // was already CSV - only update it if it was fixed (vs. broken)
                    {
                        if (result == CSVAnalyzer.CSVStatus.Fixed)
                        {
                            szCSV = csvAnalyzer.DataAsCSV;
                        }
                    }
                    else  // But if it was converted, ALWAYS update the CSV.
                    {
                        szCSV = efi.CSVFromDataTable(csvAnalyzer.Data);
                    }

                    if (szCSV != null)
                    {
                        CurrentCSVSource = rgb = System.Text.Encoding.UTF8.GetBytes(szCSV);
                    }

                    // And show conversion, if it was converted
                    if (efi != null)
                    {
                        lblFileWasConverted.Text = String.Format(CultureInfo.CurrentCulture, Resources.LogbookEntry.importLabelFileWasConverted, efi.Name);
                        pnlConverted.Visible     = true;
                    }
                }

                if (result != CSVAnalyzer.CSVStatus.OK)
                {
                    pnlAudit.Visible = true;
                }
                lblAudit.Text = csvAnalyzer.Audit;

                pnlAudit.Visible = pnlConverted.Visible || !String.IsNullOrEmpty(lblAudit.Text);
            }
        }
        finally
        {
            if (ms != null)
            {
                ms.Dispose();
            }
        }

        ErrorContext.Clear();
        CSVImporter csvimporter = CurrentImporter = new CSVImporter()
        {
            ModelNameMappings = mfbImportAircraft1.ModelMapping
        };
        AutoFillOptions afo = ckAutofill.Checked ? new AutoFillOptions(Request.Cookies)
        {
            IncludeHeliports = true
        } : null;

        using (MemoryStream ms2 = new MemoryStream(rgb))
            csvimporter.FInitFromStream(ms2, User.Identity.Name, AddSuccessRow, AddErrorRow, afo);

        if (csvimporter.FlightsToImport == null)
        {
            lblFileRequired.Text = csvimporter.ErrorMessage;
            SetWizardStep(wsUpload);
            return;
        }

        rptPreview.DataSource = csvimporter.FlightsToImport;
        rptPreview.DataBind();
        mvPreview.SetActiveView(csvimporter.FlightsToImport.Count > 0 ? vwPreview : vwNoResults);

        mvMissingAircraft.SetActiveView(vwNoMissingAircraft); // default state.

        if (csvimporter.FlightsToImport.Count > 0)
        {
            if (csvimporter.HasErrors)
            {
                if (!IsPendingOnly)
                {
                    lblError.Text = String.Format(CultureInfo.InvariantCulture, "<p>{0}</p><p>{1}</p>", Resources.LogbookEntry.ImportPreviewNotSuccessful, lblError.Text);
                }

                List <AircraftImportMatchRow> missing = new List <AircraftImportMatchRow>(csvimporter.MissingAircraft);
                if (missing.Count > 0)
                {
                    mfbImportAircraft1.CandidatesForImport = missing;
                    mvMissingAircraft.SetActiveView(vwAddMissingAircraft);
                }

                ((Button)wzImportFlights.FindControl("FinishNavigationTemplateContainerID$btnNewFile")).Visible = true;
            }

            ((AjaxControlToolkit.ConfirmButtonExtender)wzImportFlights.FindControl("FinishNavigationTemplateContainerID$confirmImportWithErrors")).Enabled = csvimporter.HasErrors;
        }
    }