Exemplo n.º 1
0
    protected void DateRangeChanged(object sender, EventArgs e)
    {
        FlightQuery fq = new FlightQuery(User.Identity.Name);

        fq.DateRange            = MfbSimpleTotals1.DateRange;
        MfbLogbook1.Restriction = fq;
        MfbLogbook1.RefreshData();
    }
Exemplo n.º 2
0
 protected void Refresh()
 {
     MfbLogbook1.Restriction = mfbSearchForm1.Restriction;
     MfbLogbook1.RefreshData();
     mfbChartTotals1.Refresh(MfbLogbook1.Data);
     mfbQueryDescriptor.DataSource = mfbSearchForm1.Restriction;
     mfbQueryDescriptor.DataBind();
     mvTrends.SetActiveView(vwChart);
 }
Exemplo n.º 3
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();
        }
Exemplo n.º 4
0
    protected void SearchResults(string szRestrict)
    {
        if (szRestrict == null)
        {
            throw new ArgumentNullException("szRestrict");
        }
        if (szRestrict.Length > 0)
        {
            mfbSearchAndTotals1.SimpleQuery = szRestrict;
        }
        MfbLogbook1.Restriction = mfbSearchAndTotals1.Restriction;

        MfbLogbook1.RefreshData();
    }
Exemplo n.º 5
0
 protected void UpdateTotalsAndLogbook()
 {
     MfbLogbook1.User        = User.Identity.Name;
     MfbLogbook1.Restriction = mfbSearchAndTotals1.Restriction;
     MfbLogbook1.RefreshData();
 }
Exemplo n.º 6
0
 protected void FilterResults(object sender, EventArgs e)
 {
     MfbLogbook1.Restriction = mfbSearchAndTotals1.Restriction;
     MfbLogbook1.RefreshData();
 }
Exemplo n.º 7
0
    protected void RefreshFormData()
    {
        FlightQuery fq = mfbSearchForm1.Restriction;

        fq.Refresh();

        string szRestrict         = fq.RestrictClause;
        string szQueryTemplate    = ConfigurationManager.AppSettings["8710ForUserQuery"].ToString();
        string szHaving           = String.IsNullOrEmpty(fq.HavingClause) ? string.Empty : "HAVING " + fq.HavingClause;
        string szQueryClassTotals = String.Format(CultureInfo.InvariantCulture, szQueryTemplate, szRestrict, szHaving, "f.InstanceTypeID, f.CatClassID");
        string szQueryMain        = String.Format(CultureInfo.InvariantCulture, szQueryTemplate, szRestrict, szHaving, "f.category");

        DBHelperCommandArgs args = new DBHelperCommandArgs(szQueryClassTotals);

        if (fq != null)
        {
            args.AddWithValue("localecode", System.Globalization.CultureInfo.CurrentCulture.Name.Replace("-", "_"));
            args.AddWithValue("shortDate", DBHelper.CSharpDateFormatToMySQLDateFormat());
            foreach (MySqlParameter p in fq.QueryParameters())
            {
                args.Parameters.Add(p);
            }
        }

        // get the class totals
        try
        {
            ClassTotals = new Dictionary <string, List <TotalsItem> >();
            DBHelper dbh = new DBHelper(args);
            dbh.ReadRows((c) => { }, (d) =>
            {
                string szCategory = (string)d["Category"];
                string szClass    = (string)d["Class"];
                string szCatClass = (string)d["CatClass"];
                if (!String.IsNullOrEmpty(szCategory) && !String.IsNullOrEmpty(szClass) && !String.IsNullOrEmpty(szCatClass))
                {
                    if (!ClassTotals.ContainsKey(szCategory))
                    {
                        ClassTotals[szCategory] = new List <TotalsItem>();
                    }
                    ClassTotals[szCategory].Add(new TotalsItem(szCatClass, Convert.ToDecimal(d["TotalTime"], CultureInfo.InvariantCulture)));
                }
            });
        }
        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);
        }

        using (MySqlCommand comm = new MySqlCommand())
        {
            DBHelper.InitCommandObject(comm, args);
            using (comm.Connection)
            {
                MySqlDataReader dr = null;
                try
                {
                    comm.CommandText = szQueryMain;
                    comm.Connection.Open();
                    using (dr = comm.ExecuteReader())
                    {
                        gv8710.DataSource = dr;
                        gv8710.DataBind();
                        UpdateDescription();
                        if (!this.Master.IsMobileSession())
                        {
                            MfbLogbook1.Restriction = fq;
                            MfbLogbook1.RefreshData();
                        }
                    }
                }
                catch (Exception 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);
                }
                finally
                {
                    if (comm.Connection != null && comm.Connection.State != ConnectionState.Closed)
                    {
                        comm.Connection.Close();
                    }
                }
            }
        }
    }
    protected void RefreshFormData()
    {
        FlightQuery fq = mfbSearchForm1.Restriction;

        fq.Refresh();

        string szRestrict         = fq.RestrictClause;
        string szQueryTemplate    = ConfigurationManager.AppSettings["8710ForUserQuery"];
        string szHaving           = String.IsNullOrEmpty(fq.HavingClause) ? string.Empty : "HAVING " + fq.HavingClause;
        string szQueryClassTotals = String.Format(CultureInfo.InvariantCulture, szQueryTemplate, szRestrict, szHaving, "f.InstanceTypeID, f.CatClassID");
        string szQueryMain        = String.Format(CultureInfo.InvariantCulture, szQueryTemplate, szRestrict, szHaving, "f.category");

        string szQueryRollup = String.Format(CultureInfo.InvariantCulture, ConfigurationManager.AppSettings["RollupGridQuery"], szRestrict, szHaving);


        DBHelperCommandArgs args = new DBHelperCommandArgs(szQueryClassTotals);

        if (fq != null)
        {
            foreach (MySqlParameter p in fq.QueryParameters())
            {
                args.Parameters.Add(p);
            }
        }

        // get the class totals
        try
        {
            ClassTotals = new Dictionary <string, List <ClassTotal> >();
            DBHelper dbh = new DBHelper(args);
            dbh.ReadRows((c) => { }, (d) =>
            {
                string szCategory = (string)d["Category"];
                string szClass    = (string)d["Class"];
                string szCatClass = (string)d["CatClass"];
                if (!String.IsNullOrEmpty(szCategory) && !String.IsNullOrEmpty(szClass) && !String.IsNullOrEmpty(szCatClass))
                {
                    if (!ClassTotals.ContainsKey(szCategory))
                    {
                        ClassTotals[szCategory] = new List <ClassTotal>();
                    }
                    List <ClassTotal> lst = ClassTotals[szCategory];
                    ClassTotal ct         = new ClassTotal()
                    {
                        ClassName = szCatClass,
                        Total     = Convert.ToDecimal(d["TotalTime"], CultureInfo.InvariantCulture),
                        PIC       = Convert.ToDecimal(d["PIC"], CultureInfo.InvariantCulture),
                        SIC       = Convert.ToDecimal(d["SIC"], CultureInfo.InvariantCulture)
                    };
                    lst.Add(ct);
                }
            });
        }
        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);
        }

        using (MySqlCommand comm = new MySqlCommand())
        {
            DBHelper.InitCommandObject(comm, args);
            using (comm.Connection)
            {
                MySqlDataReader dr = null;
                try
                {
                    comm.CommandText = szQueryMain;
                    comm.Connection.Open();
                    using (dr = comm.ExecuteReader())
                    {
                        gv8710.DataSource = dr;
                        gv8710.DataBind();
                    }

                    comm.CommandText = szQueryRollup;
                    using (dr = comm.ExecuteReader())
                    {
                        gvRollup.DataSource = dr;
                        gvRollup.DataBind();
                        if (gvRollup.Rows.Count > 0)
                        {
                            gvRollup.Rows[gvRollup.Rows.Count - 1].Font.Bold = true;
                        }
                    }
                }
                catch (Exception 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);
                }
                finally
                {
                    if (comm.Connection != null && comm.Connection.State != ConnectionState.Closed)
                    {
                        comm.Connection.Close();
                    }
                }
            }
        }

        UpdateDescription();
        if (!this.Master.IsMobileSession())
        {
            MfbLogbook1.Restriction = fq;
            MfbLogbook1.RefreshData();
        }
    }