protected void InitializeRestriction()
    {
        string szSearchParam  = util.GetStringParam(Request, "s");
        string szFQParam      = util.GetStringParam(Request, "fq");
        string szAirportParam = util.GetStringParam(Request, "ap");
        int    month          = util.GetIntParam(Request, "m", -1);
        int    year           = util.GetIntParam(Request, "y", -1);
        int    day            = util.GetIntParam(Request, "d", -1);
        int    week           = util.GetIntParam(Request, "w", -1);

        if (!String.IsNullOrEmpty(szFQParam))
        {
            try
            {
                Restriction = mfbSearchForm1.Restriction = FlightQuery.FromBase64CompressedJSON(szFQParam);
            }
            catch (ArgumentNullException) { }
            catch (FormatException) { }
            catch (JsonSerializationException) { }
            catch (JsonException) { }
        }
        else
        {
            Restriction = mfbSearchForm1.Restriction = new FlightQuery(Page.User.Identity.Name);
        }

        if (!String.IsNullOrEmpty(szSearchParam))
        {
            Restriction.GeneralText = szSearchParam;
        }
        if (!String.IsNullOrEmpty(szAirportParam))
        {
            Restriction.AirportList = MyFlightbook.Airports.AirportList.NormalizeAirportList(szAirportParam);
        }

        if (year > 1900)
        {
            if (month >= 0 && month < 12 && year > 1900)
            {
                DateTime dtStart = new DateTime(year, month + 1, day > 0 ? day : 1);
                DateTime dtEnd   = (day > 0) ? (week > 0 ? dtStart.AddDays(6) : dtStart) : dtStart.AddMonths(1).AddDays(-1);
                Restriction.DateRange = FlightQuery.DateRanges.Custom;
                Restriction.DateMin   = dtStart;
                Restriction.DateMax   = dtEnd;
            }
            else
            {
                Restriction.DateRange = FlightQuery.DateRanges.Custom;
                Restriction.DateMin   = new DateTime(year, 1, 1);
                Restriction.DateMax   = new DateTime(year, 12, 31);
            }
        }

        Refresh();
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        Master.SelectedTab = tabID.tabTraining;

        if (!IsPostBack)
        {
            hdnStudent.Value = Page.User.Identity.Name; //default
            string            szStudent = util.GetStringParam(Request, "student");
            CFIStudentMap     sm        = new CFIStudentMap(Page.User.Identity.Name);
            InstructorStudent student   = CFIStudentMap.GetInstructorStudent(sm.Students, szStudent);
            if (student == null)
            {
                lblErr.Text = Resources.SignOff.ViewStudentNoSuchStudent;
            }
            else
            {
                if (!student.CanViewLogbook)
                {
                    lblErr.Text = Master.Title = Resources.SignOff.ViewStudentLogbookUnauthorized;
                }
                else
                {
                    // If we're here, we are authorized
                    lblHeader.Text   = String.Format(System.Globalization.CultureInfo.CurrentCulture, Resources.SignOff.ViewStudentLogbookHeader, student.UserFullName);
                    hdnStudent.Value = student.UserName;
                    Restriction      = new FlightQuery(student.UserName);

                    if (mfbLogbook1.CanResignValidFlights = student.CanAddLogbook)
                    {
                        mfbEditFlight.FlightUser = student.UserName;
                        mfbEditFlight.SetUpNewOrEdit(LogbookEntry.idFlightNew);
                    }
                    else
                    {
                        apcNewFlight.Visible = false;
                    }

                    if (!String.IsNullOrEmpty(hdnStudent.Value))
                    {
                        UpdateForUser(hdnStudent.Value);
                    }

                    mfbSearchForm.Username = printOptions.UserName = student.UserName;
                    ResolvePrintLink();
                }
            }

            pnlLogbook.Visible = (lblErr.Text.Length == 0);
        }

        if (pnlLogbook.Visible && mfbChartTotals.Visible)
        {
            mfbChartTotals.HistogramManager = LogbookEntryDisplay.GetHistogramManager(mfbLogbook1.Data, hdnStudent.Value);   // do this every time, since charttotals doesn't persist its data.
        }
    }
Exemple #3
0
 /// <summary>
 /// A currency object that requires 3 landings in the previous 90 days
 /// </summary>
 /// <param name="szName">the name for the currency</param>
 /// <param name="fRequireDayLandings">True to require day landings for day currency</param>
 public PassengerCurrency(string szName, bool fRequireDayLandings) : base(3, 90, false, szName)
 {
     RequireDayLandings = fRequireDayLandings;
     Query = new FlightQuery()
     {
         DateRange             = FlightQuery.DateRanges.Trailing90,
         HasLandings           = true,
         PropertiesConjunction = GroupConjunction.None
     };
     Query.PropertyTypes.Add(CustomPropertyType.GetCustomPropertyType((int)CustomPropertyType.KnownProperties.IDPropPilotMonitoring));
 }
Exemple #4
0
        private FlightQuery AddModelToQuery(FlightQuery fq, int idModel)
        {
            List <MakeModel> lst = new List <MakeModel>(fq.MakeList);

            if (!lst.Exists(m => m.MakeModelID == idModel))
            {
                lst.Add(MakeModel.GetModel(idModel));
            }
            fq.MakeList = lst.ToArray();
            return(fq);
        }
        /// <summary>
        /// Returns a KML respresentation of all of the flights represented by the specified query
        /// </summary>
        /// <param name="fq">The flight query</param>
        /// <param name="s">The stream to which to write</param>
        /// <param name="error">Any error</param>
        /// <param name="lstIDs">The list of specific flight IDs to request</param>
        /// <returns>KML string for the matching flights.</returns>
        public static void AllFlightsAsKML(FlightQuery fq, Stream s, out string error, IEnumerable <int> lstIDs = null)
        {
            if (fq == null)
            {
                throw new ArgumentNullException(nameof(fq));
            }
            if (String.IsNullOrEmpty(fq.UserName) && (lstIDs == null || !lstIDs.Any()))
            {
                throw new MyFlightbookException("Don't get all flights as KML for an empty user!!");
            }

            if (lstIDs != null)
            {
                fq.EnumeratedFlights = lstIDs;
            }

            // Get the master airport list
            AirportList alMaster = AllFlightsAndNavaids(fq);

            using (KMLWriter kw = new KMLWriter(s))
            {
                kw.BeginKML();

                error = LookAtAllFlights(
                    fq,
                    LogbookEntryCore.LoadTelemetryOption.LoadAll,
                    (le) =>
                {
                    if (le.Telemetry.HasPath)
                    {
                        using (FlightData fd = new FlightData())
                        {
                            try
                            {
                                fd.ParseFlightData(le.Telemetry.RawData, le.Telemetry.MetaData);
                                if (fd.HasLatLongInfo)
                                {
                                    kw.AddPath(fd.GetTrajectory(), String.Format(CultureInfo.CurrentCulture, "{0:d} - {1}", le.Date, le.Comment), fd.SpeedFactor);
                                    return;
                                }
                            }
                            catch (Exception ex) when(!(ex is OutOfMemoryException))
                            {
                            }                                                                   // eat any error and fall through below
                        }
                    }
                    // No path was found above.
                    AirportList al = alMaster.CloneSubset(le.Route);
                    kw.AddRoute(al.GetNormalizedAirports(), String.Format(CultureInfo.CurrentCulture, "{0:d} - {1}", le.Date, le.Route));
                },
                    lstIDs != null && lstIDs.Any());
                kw.EndKML();
            }
        }
        public NightCurrency(string szName) : base(RequiredLandings, TimeSpan, false, szName)
        {
            NightTakeoffCurrency = new FlightCurrency(RequiredTakeoffs, TimeSpan, false, szName);

            Query = new FlightQuery()
            {
                DateRange             = FlightQuery.DateRanges.Trailing90,
                HasNightLandings      = true,
                PropertiesConjunction = GroupConjunction.None
            };
            Query.PropertyTypes.Add(CustomPropertyType.GetCustomPropertyType((int)CustomPropertyType.KnownProperties.IDPropPilotMonitoring));
        }
Exemple #7
0
 public InstrumentCurrency() : base()
 {
     Query = new FlightQuery()
     {
         FlightCharacteristicsConjunction = GroupConjunction.Any,
         HasApproaches = true,
         HasHolds      = true,
         DateRange     = FlightQuery.DateRanges.Custom,
         DateMin       = DateTime.Now.Date.AddCalendarMonths(-6),
         DateMax       = DateTime.Now.Date.AddCalendarMonths(0)
     };
 }
Exemple #8
0
        protected void RefreshFormData()
        {
            FlightQuery fq = mfbSearchForm1.Restriction;

            MfbLogbook1.Restriction = new FlightQuery(fq);  // before we muck with the query below, copy it here.

            fq.Refresh();
            DBHelperCommandArgs args = new DBHelperCommandArgs()
            {
                Timeout = 120
            };

            args.AddFrom(fq.QueryParameters());

            UpdateDescription();

            IEnumerable <Form8710Row>    lst8710   = null;
            IEnumerable <ModelRollupRow> lstModels = null;

            // get the various reports.  This can be a bit slow, so do all of the queries in parallel asynchronously.
            try
            {
                Task.WaitAll(
                    Task.Run(() => { ClassTotals = Form8710ClassTotal.ClassTotalsForQuery(fq, args); }),
                    Task.Run(() => { lst8710 = Form8710Row.Form8710ForQuery(fq, args); }),
                    Task.Run(() => { lstModels = ModelRollupRow.ModelRollupForQuery(fq, args); }),
                    Task.Run(() => { RefreshTimePeriodRollup(); }),
                    Task.Run(() =>
                {
                    if (!Master.IsMobileSession())
                    {
                        MfbLogbook1.RefreshData();
                    }
                })
                    );
            }
            catch (MySqlException ex)
            {
                throw new MyFlightbookException(String.Format(CultureInfo.CurrentCulture, "Error getting 8710 data for user {0}: {1}", Page.User.Identity.Name, ex.Message), ex, Page.User.Identity.Name);
            }

            // Do the databinding itself AFTER the async queries, since databinding may not be thread safe.
            gvRollup.DataSource = lstModels;
            gvRollup.DataBind();
            if (gvRollup.Rows.Count > 0)
            {
                gvRollup.Rows[gvRollup.Rows.Count - 1].Font.Bold = true;
            }

            gv8710.DataSource = lst8710;
            gv8710.DataBind();
        }
        /// <summary>
        /// This function is delegated by the Client Query service.
        /// it will iterate all sellers and make the appropriate client requested
        /// query, returns search results to the client
        /// </summary>
        /// <param name="src">Source of flight</param>
        /// <param name="dst">Destination of flight</param>
        /// <param name="date">Date of flight</param>
        /// <returns>Flights from all sellers which match the input criterias</returns>
        public QueryResultFlights QueryFlights(string src, string dst, string date)
        {
            Console.WriteLine("FlightSearchServer: " + dst + " " + src + " " + date);

            try // Sanitize date
            {
                DateTime.ParseExact(date, "dd/MM/yyyy", CultureInfo.InvariantCulture);
            }
            catch (Exception)
            {
                throw new FlightSearchServerBadDate();
            }

            QueryResultFlights flights = new QueryResultFlights();

            foreach (var seller in sellers.Keys)
            {
                FlightQuery fq = new FlightQuery();
                fq.src  = src;
                fq.dst  = dst;
                fq.date = DateTime.Parse(date);
                using (new OperationContextScope((IContextChannel)sellers[seller]))
                {
                    try
                    {
                        Flights sellerFlights =
                            sellers[seller].GetFlights(fq); // DEAL WITH EXCEPTIONS HERE

                        foreach (var sellerFlight in sellerFlights)
                        {
                            QueryResultFlight f1 = (QueryResultFlight)sellerFlight;
                            f1.name = seller;
                            flights.Add(f1);
                        }
                    }
                    catch (FaultException e)
                    {
                        Console.WriteLine("Seller {0} failed with {1}, ignoring.", seller, e.Reason.ToString());
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine("Seller {0} {1} malfunction: \n{2}", seller, "search", e.Message.ToString());
                        ITicketSellingQueryService victim;
                        sellers.TryRemove(seller, out victim);
                    }
                }
            }

            flights.Sort();

            return(flights);
        }
Exemple #10
0
    protected void mfbQueryDescriptor1_QueryUpdated(object sender, FilterItemClickedEventArgs fic)
    {
        if (fic == null)
        {
            throw new ArgumentNullException(nameof(fic));
        }
        FlightQuery fq = Restriction.ClearRestriction(fic.FilterItem);

        ShowResults(sender, new FlightQueryEventArgs(fq));
        UpdateDescription();

        QuerySubmitted?.Invoke(sender, new FlightQueryEventArgs(fq));
    }
Exemple #11
0
 /// <summary>
 /// A currency object that requires 3 full-stop landings in the previous 90 days
 /// </summary>
 /// <param name="szName">the name for the currency</param>
 public TailwheelCurrency(string szName) : base(3, 90, false, szName)
 {
     Query = new FlightQuery()
     {
         DateRange           = FlightQuery.DateRanges.Trailing90,
         HasNightLandings    = true,
         HasFullStopLandings = true,
         FlightCharacteristicsConjunction = GroupConjunction.Any,
         IsTailwheel           = true,
         PropertiesConjunction = GroupConjunction.None
     };
     Query.PropertyTypes.Add(CustomPropertyType.GetCustomPropertyType((int)CustomPropertyType.KnownProperties.IDPropPilotMonitoring));
 }
Exemple #12
0
    private FlightQuery GetFlightQuery()
    {
        if (String.IsNullOrEmpty(Username))
        {
            Username = Page.User.Identity.Name;
        }

        m_fq = new CannedQuery(Username)
        {
            DateRange = FlightQuery.DateRanges.AllTime, QueryName = txtQueryName.Text
        };

        // General text
        m_fq.GeneralText = txtRestrict.Text;

        // Airports:
        if (txtAirports.Text.Length > 0)
        {
            m_fq.AirportList.Clear();
            MatchCollection mc = regAirports.Matches(txtAirports.Text);
            foreach (Match m in mc)
            {
                if (!String.IsNullOrEmpty(m.Value))
                {
                    m_fq.AirportList.Add(m.Value);
                }
            }
        }

        m_fq.Distance = (FlightQuery.FlightDistance)Convert.ToInt32(rblFlightDistance.SelectedValue, CultureInfo.InvariantCulture);

        // Remaining sections
        QueryDateFromForm();
        AircraftFromForm();
        ModelsFromForm();
        AircraftCharacteristicsFromForm();
        FlightCharacteristicsFromForm();
        CatClassFromForm();
        CustomPropsFromForm();

        // Typenames aren't exposed to the user; reset them here.
        m_fq.TypeNames.Clear();
        foreach (string sz in TypeNames)
        {
            m_fq.TypeNames.Add(sz);
        }

        m_fq.Refresh();

        return(m_fq);
    }
Exemple #13
0
    protected void UpdateQuery()
    {
        Restriction = mfbSearchForm.Restriction;
        UpdateForUser(hdnStudent.Value);
        AccordionCtrl.SelectedIndex = -1;
        apcAnalysis.LazyLoad        = true;
        mfbChartTotals.Visible      = false;
        int idx = mfbAccordionProxyExtender.IndexForProxyID(apcAnalysis.ID);

        if (idx == AccordionCtrl.SelectedIndex)
        {
            AccordionCtrl.SelectedIndex = -1;
        }
        mfbAccordionProxyExtender.SetJavascriptForControl(apcAnalysis, false, idx);
    }
Exemple #14
0
    private void InitializeRestriction()
    {
        string szFQParam = util.GetStringParam(Request, "fq");

        if (!String.IsNullOrEmpty(szFQParam))
        {
            mfbSearchForm1.Restriction = FlightQuery.FromBase64CompressedJSON(szFQParam);
            Master.HasFooter           = Master.HasHeader = false;
            if (!mfbSearchForm1.Restriction.IsDefault)
            {
                TabContainer1.ActiveTab = tpFilter;
            }
            lnkReturnToFlights.NavigateUrl = String.Format(CultureInfo.InvariantCulture, "~/Member/LogbookNew.aspx?fq={0}", szFQParam);
        }
    }
Exemple #15
0
    protected void UpdateForUser(string szUser)
    {
        FlightQuery r = Restriction;

        mfbTotalSummary.Username          = mfbCurrency1.UserName = mfbLogbook1.User = szUser;
        mfbTotalSummary.CustomRestriction = mfbLogbook1.Restriction = r;
        mfbCurrency1.RefreshCurrencyTable();
        bool fRestrictionIsDefault = r.IsDefault;

        mfbQueryDescriptor.DataSource = fRestrictionIsDefault ? null : r;
        mfbQueryDescriptor.DataBind();
        apcFilter.LabelControl.Font.Bold = !fRestrictionIsDefault;
        apcFilter.IsEnhanced             = !fRestrictionIsDefault;
        pnlFilter.Visible = !fRestrictionIsDefault;
        mfbLogbook1.RefreshData();
    }
Exemple #16
0
        private FlightQuery AddCatClassToQuery(FlightQuery fq, CategoryClass cc, string szTypeName)
        {
            List <CategoryClass> lst = new List <CategoryClass>(fq.CatClasses);

            if (!lst.Exists(c => c.IdCatClass == cc.IdCatClass))
            {
                lst.Add(cc);
            }
            fq.CatClasses = lst.ToArray();
            if (!String.IsNullOrEmpty(szTypeName))
            {
                fq.TypeNames = new string[] { szTypeName }
            }
            ;
            return(fq);
        }
        protected string PermaLink(PrintingOptions po, FlightQuery fq)
        {
            if (fq == null)
            {
                throw new ArgumentNullException(nameof(fq));
            }
            string szStudent = util.GetStringParam(Request, "u");

            return(PrintingOptions.PermaLink(fq, po, Request.Url.Host, Request.Url.Scheme, (nvc) =>
            {
                if (!String.IsNullOrEmpty(szStudent))
                {
                    nvc["u"] = szStudent;
                }
            }).ToString());
        }
Exemple #18
0
    protected void InitPassedRestriction()
    {
        string szFQParam = util.GetStringParam(Request, "fq");

        if (!String.IsNullOrEmpty(szFQParam))
        {
            try
            {
                Restriction = FlightQuery.FromBase64CompressedJSON(szFQParam);
                Restriction.Refresh();
            }
            catch (Exception ex) when(ex is ArgumentNullException || ex is FormatException || ex is Newtonsoft.Json.JsonSerializationException || ex is Newtonsoft.Json.JsonException)
            {
            }
        }
    }
Exemple #19
0
    protected void UpdateQuery()
    {
        Restriction = mfbSearchForm.Restriction;
        UpdateForUser(hdnStudent.Value);
        AccordionCtrl.SelectedIndex = -1;
        apcAnalysis.LazyLoad        = true;
        mfbChartTotals.Visible      = false;
        int idx = mfbAccordionProxyExtender.IndexForProxyID(apcAnalysis.ID);

        if (idx == AccordionCtrl.SelectedIndex)
        {
            AccordionCtrl.SelectedIndex = -1;
        }
        mfbAccordionProxyExtender.SetJavascriptForControl(apcAnalysis, false, idx);
        mfbChartTotals.HistogramManager = LogbookEntryDisplay.GetHistogramManager(mfbLogbook1.Data, hdnStudent.Value);
        mfbChartTotals.Refresh();
    }
        private static Dictionary <string, TotalsItem> TotalsForQuery(FlightQuery fq, bool fBind)
        {
            Dictionary <string, TotalsItem> d = new Dictionary <string, TotalsItem>();

            if (fBind)
            {
                UserTotals ut = new UserTotals(fq.UserName, fq, true);
                ut.DataBind();

                foreach (TotalsItem ti in ut.Totals)
                {
                    d[ti.Description] = ti;
                }
            }

            return(d);
        }
 private void InitPassedQuery(string szFQParam)
 {
     if (!String.IsNullOrEmpty(szFQParam))
     {
         try
         {
             Restriction = FlightQuery.FromBase64CompressedJSON(szFQParam);
         }
         catch (Exception ex) when(ex is ArgumentNullException || ex is FormatException || ex is JsonSerializationException || ex is JsonException)
         {
         }
     }
     else
     {
         Restriction = new FlightQuery(Page.User.Identity.Name);
     }
 }
        /// <summary>
        /// Estimates the total distance flown by the user for the subset of flights described by the query
        /// </summary>
        /// <param name="fq">The flight query</param>
        /// <param name="fAutofillDistanceFlown">True to autofill the distance flown property if not found.</param>
        /// <param name="error">Any error</param>
        /// <returns>Distance flown, in nm</returns>
        public static double DistanceFlownByUser(FlightQuery fq, bool fAutofillDistanceFlown, out string error)
        {
            if (fq == null)
            {
                throw new ArgumentNullException(nameof(fq));
            }
            if (String.IsNullOrEmpty(fq.UserName))
            {
                throw new MyFlightbookException("Don't estimate distance for an empty user!!");
            }

            double distance = 0.0;

            // Get the master airport list
            AirportList alMaster = AllFlightsAndNavaids(fq);

            error = LookAtAllFlights(
                fq,
                LogbookEntryCore.LoadTelemetryOption.MetadataOrDB,
                (le) =>
            {
                double distThisFlight = 0;

                // If the trajectory had a distance, use it; otherwise, use airport-to-airport.
                double dPath = le.Telemetry.Distance();
                if (dPath > 0)
                {
                    distThisFlight = dPath;
                }
                else if (!String.IsNullOrEmpty(le.Route))
                {
                    distThisFlight = alMaster.CloneSubset(le.Route).DistanceForRoute();
                }

                distance += distThisFlight;

                if (fAutofillDistanceFlown && distThisFlight > 0 && !le.CustomProperties.PropertyExistsWithID(CustomPropertyType.KnownProperties.IDPropDistanceFlown))
                {
                    le.CustomProperties.Add(CustomFlightProperty.PropertyWithValue(CustomPropertyType.KnownProperties.IDPropDistanceFlown, (decimal)distThisFlight));
                    le.FCommit();
                }
            });

            return(distance);
        }
Exemple #23
0
        protected void btnCheckAll_Click(object sender, EventArgs e)
        {
            UInt32 selectedOptions = SelectedOptions;

            if (selectedOptions == 0)
            {
                lblErr.Text = Resources.FlightLint.errNoOptionsSelected;
                return;
            }

            FlightQuery                    fq   = new FlightQuery(Page.User.Identity.Name);
            DBHelperCommandArgs            dbhq = LogbookEntryBase.QueryCommand(fq, fAsc: true);
            IEnumerable <LogbookEntryBase> rgle = LogbookEntryDisplay.GetFlightsForQuery(dbhq, Page.User.Identity.Name, "Date", SortDirection.Ascending, false, false);

            BindFlights(new FlightLint().CheckFlights(rgle, Page.User.Identity.Name, selectedOptions, mfbDateLastCheck.Date));

            Response.Cookies[szCookieLastCheck].Value   = DateTime.Now.YMDString();
            Response.Cookies[szCookieLastCheck].Expires = DateTime.Now.AddYears(5);
        }
Exemple #24
0
            public void AddItems(UserTotals ut)
            {
                FlightQuery fq = ut.Restriction;

                if (PIC == TotalTime)
                {
                    ut.AddToList(new TotalsItem(Name + " - " + Resources.Totals.SIC, SIC)
                    {
                        Query = QueryForModelFeatureTotal(fq, FeatureSubtotal.PIC)
                    });
                    ut.AddToList(new TotalsItem(Name + " - " + Resources.Totals.PICTotal, TotalTime)
                    {
                        Query = QueryForModelFeatureTotal(fq, FeatureSubtotal.Total)
                    });
                }
                else if (SIC == TotalTime)
                {
                    ut.AddToList(new TotalsItem(Name + " - " + Resources.Totals.SICTotal, TotalTime)
                    {
                        Query = QueryForModelFeatureTotal(fq, FeatureSubtotal.Total)
                    });
                    ut.AddToList(new TotalsItem(Name + " - " + Resources.Totals.PIC, PIC)
                    {
                        Query = QueryForModelFeatureTotal(fq, FeatureSubtotal.SIC)
                    });
                }
                else
                {
                    ut.AddToList(new TotalsItem(Name + " - " + Resources.Totals.SIC, SIC)
                    {
                        Query = QueryForModelFeatureTotal(fq, FeatureSubtotal.SIC)
                    });
                    ut.AddToList(new TotalsItem(Name + " - " + Resources.Totals.PIC, PIC)
                    {
                        Query = QueryForModelFeatureTotal(fq, FeatureSubtotal.PIC)
                    });
                    ut.AddToList(new TotalsItem(Name, TotalTime)
                    {
                        Query = QueryForModelFeatureTotal(fq, FeatureSubtotal.Total)
                    });
                }
            }
Exemple #25
0
            private FlightQuery QueryForModelFeatureTotal(FlightQuery fqBase, FeatureSubtotal fs)
            {
                FlightQuery fq = new FlightQuery(fqBase);

                switch (fs)
                {
                case FeatureSubtotal.PIC:
                    fq.HasPIC = true;
                    break;

                case FeatureSubtotal.SIC:
                    fq.HasSIC = true;
                    break;

                case FeatureSubtotal.Total:
                default:
                    break;
                }
                switch (ModelAttribute)
                {
                case FeatureTotalType.Complex:
                    fq.IsComplex = true;
                    break;

                case FeatureTotalType.HighPerf:
                    fq.IsHighPerformance = true;
                    break;

                case FeatureTotalType.Retract:
                    fq.IsRetract = true;
                    break;

                case FeatureTotalType.Tailwheel:
                    fq.IsTailwheel = true;
                    break;

                case FeatureTotalType.Turbine:
                    fq.IsTurbine = true;
                    break;
                }
                return(fq);
            }
    protected void Page_Load(object sender, EventArgs e)
    {
        Master.SelectedTab = tabID.tabTraining;
        Master.Layout      = MasterPage.LayoutMode.Accordion;

        if (!IsPostBack)
        {
            string            szStudent = util.GetStringParam(Request, "student");
            CFIStudentMap     sm        = new CFIStudentMap(Page.User.Identity.Name);
            InstructorStudent student   = sm.GetInstructorStudent(sm.Students, szStudent);
            if (student == null)
            {
                lblErr.Text = Resources.SignOff.ViewStudentNoSuchStudent;
            }
            else
            {
                if (!student.CanViewLogbook)
                {
                    lblErr.Text = Master.Title = Resources.SignOff.ViewStudentLogbookUnauthorized;
                }
                else
                {
                    // If we're here, we are authorized
                    lblHeader.Text   = String.Format(System.Globalization.CultureInfo.CurrentCulture, Resources.SignOff.ViewStudentLogbookHeader, student.UserFullName);
                    hdnStudent.Value = student.UserName;
                    Restriction      = new FlightQuery(student.UserName);

                    if (!String.IsNullOrEmpty(hdnStudent.Value))
                    {
                        UpdateForUser(hdnStudent.Value);
                    }
                }
            }

            pnlLogbook.Visible = (lblErr.Text.Length == 0);
        }

        if (pnlLogbook.Visible && mfbChartTotals.Visible)
        {
            mfbChartTotals.SourceData = mfbLogbook1.Data;   // do this every time, since charttotals doesn't persist its data.
        }
    }
        private void InitializeRestriction()
        {
            string szFQParam = util.GetStringParam(Request, "fq");

            if (!String.IsNullOrEmpty(szFQParam))
            {
                FlightQuery fq = FlightQuery.FromBase64CompressedJSON(szFQParam);

                if (fq.UserName.CompareCurrentCultureIgnoreCase(CurrentUser.UserName) != 0)
                {
                    return; // do nothing if this isn't for the current user
                }
                mfbSearchForm1.Restriction = fq;
                Master.HasFooter           = Master.HasHeader = false;
                if (!mfbSearchForm1.Restriction.IsDefault)
                {
                    TabContainer1.ActiveTab = tpFilter;
                }
                lnkReturnToFlights.NavigateUrl = String.Format(CultureInfo.InvariantCulture, "~/Member/LogbookNew.aspx?fq={0}", szFQParam);
            }
        }
        /// <summary>
        /// Examines all of the relevant flights for the specified query.
        /// </summary>
        /// <param name="dbh">Query that returns the relevant flights</param>
        /// <param name="action">Action that takes flight data, route, date, and comments.  DO NOT dispose of the FlightData - it's owned by THIS.</param>
        /// <returns>Any error string, empty or null for no error</returns>
        private static string LookAtAllFlights(FlightQuery fq, LogbookEntryCore.LoadTelemetryOption lto, Action <LogbookEntry> action, bool fForceLoad = false)
        {
            if (fq == null)
            {
                throw new ArgumentNullException(nameof(fq));
            }
            if (action == null)
            {
                throw new ArgumentNullException(nameof(action));
            }

            DBHelper dbh = new DBHelper(LogbookEntry.QueryCommand(fq, lto: lto));

            dbh.ReadRows(
                (comm) => { },
                (dr) =>
            {
                LogbookEntry le = new LogbookEntry(dr, fForceLoad ? (string)dr["username"] : fq.UserName, lto);
                action(le);
            });
            return(dbh.LastError);
        }
Exemple #29
0
    private FlightQuery GetFlightQuery()
    {
        if (String.IsNullOrEmpty(Username))
        {
            Username = Page.User.Identity.Name;
        }

        m_fq = new CannedQuery(Username)
        {
            DateRange = FlightQuery.DateRanges.AllTime, QueryName = txtQueryName.Text
        };

        // General text
        m_fq.GeneralText = txtRestrict.Text;

        // Airports:
        if (txtAirports.Text.Length > 0)
        {
            m_fq.AirportList = AirportList.NormalizeAirportList(txtAirports.Text);
        }

        m_fq.Distance = (FlightQuery.FlightDistance)Convert.ToInt32(rblFlightDistance.SelectedValue, CultureInfo.InvariantCulture);

        // Remaining sections
        QueryDateFromForm();
        AircraftFromForm();
        ModelsFromForm();
        AircraftCharacteristicsFromForm();
        FlightCharacteristicsFromForm();
        CatClassFromForm();
        CustomPropsFromForm();

        // Typenames aren't exposed to the user; reset them here.
        m_fq.TypeNames = (string[])ViewState[szKeyVSTypes] ?? new string[0];

        m_fq.Refresh();

        return(m_fq);
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        this.Master.SelectedTab = tabID.mptVisited;
        Title = Resources.Airports.visitedAirportTitle;

        if (!IsPostBack)
        {
            string szQuery = util.GetStringParam(Request, "fq");
            if (!String.IsNullOrEmpty(szQuery))
            {
                FlightQuery fq = FlightQuery.FromBase64CompressedJSON(szQuery);
                if (fq.UserName.CompareCurrentCultureIgnoreCase(User.Identity.Name) == 0)
                {
                    mfbSearchForm1.Restriction = fq;
                    mfbSearchForm1.Restriction.Refresh();
                    UpdateDescription();
                }
            }
        }

        RefreshData(!IsPostBack);
    }