protected void btnAdminFixSignature_Click(object sender, EventArgs e)
    {
        LogbookEntry le = new LogbookEntry();

        le.FLoadFromDB(FlightID, FlightUser, LogbookEntry.LoadTelemetryOption.None, true);
        le.AdminSignatureSanityFix(false);
        Response.Redirect(Request.Url.OriginalString);
    }
Esempio n. 2
0
        protected void UpdateInvalidSigs()
        {
            List <int> lstSigned = new List <int>();

            // Pick up where we left off.
            int offset = Convert.ToInt32(hdnSigOffset.Value, CultureInfo.InvariantCulture);

            const int chunkSize = 250;

            DBHelper dbh = new DBHelper("SELECT idFlight FROM Flights WHERE signatureState<>0 LIMIT ?lim, ?chunk");

            dbh.CommandArgs.Timeout = 300;  // up to 300 seconds.
            dbh.ReadRows((comm) => { comm.Parameters.AddWithValue("lim", offset); comm.Parameters.AddWithValue("chunk", chunkSize); },
                         (dr) => { lstSigned.Add(Convert.ToInt32(dr["idFlight"], CultureInfo.InvariantCulture)); });

            lstSigned.ForEach((idFlight) =>
            {
                LogbookEntry le = new LogbookEntry();
                le.FLoadFromDB(idFlight, string.Empty, LogbookEntry.LoadTelemetryOption.None, true);
                if (le.AdminSignatureSanityCheckState != LogbookEntry.SignatureSanityCheckState.OK)
                {
                    // see if we can auto-fix these.  Auto-fixed = decrypted hash matches case insenstive and trimmed.
                    if (le.DecryptedCurrentHash.Trim().CompareCurrentCultureIgnoreCase(le.DecryptedFlightHash.Trim()) == 0)
                    {
                        lstAutoFix.Add(le);
                        le.AdminSignatureSanityFix(true);
                    }
                    else
                    {
                        lstToFix.Add(le);
                    }
                }
            });

            offset += lstSigned.Count;

            lblSigResults.Text = String.Format(CultureInfo.CurrentCulture, "Found {0} signed flights, {1} appear to have problems, {2} were autofixed (capitalization or leading/trailing whitespace)", offset, lstToFix.Count, lstAutoFix.Count);

            if (lstSigned.Any())
            {
                // we have more to go, so show the progress view that auto-clicks for the next chunk.
                mvCheckSigs.SetActiveView(vwSigProgress);
                hdnSigOffset.Value = offset.ToString(CultureInfo.InvariantCulture);
            }
            else
            {
                mvCheckSigs.SetActiveView(vwInvalidSigs);                                  // stop pressing
                hdnSigOffset.Value             = 0.ToString(CultureInfo.InvariantCulture); // and reset the offset so you can press it again.
                gvInvalidSignatures.DataSource = lstToFix;
                gvInvalidSignatures.DataBind();
                gvAutoFixed.DataSource = lstAutoFix;
                gvAutoFixed.DataBind();
            }
        }
Esempio n. 3
0
    protected void gvInvalidSignatures_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        int idFlight = e.CommandArgument.ToString().SafeParseInt(LogbookEntry.idFlightNone);

        if (idFlight != LogbookEntry.idFlightNone)
        {
            LogbookEntry le = new LogbookEntry();
            le.FLoadFromDB(idFlight, string.Empty, LogbookEntry.LoadTelemetryOption.None, true);
            if (le.AdminSignatureSanityFix(e.CommandName.CompareTo("ForceValidity") == 0))
            {
                List <LogbookEntry> lst = (List <LogbookEntry>)ViewState["InvalidSigs"];
                lst.RemoveAll(l => l.FlightID == idFlight);
                gvInvalidSignatures.DataSource = ViewState["InvalidSigs"] = lst;
                gvInvalidSignatures.DataBind();
            }
        }
    }
Esempio n. 4
0
        protected void gvInvalidSignatures_RowCommand(object sender, CommandEventArgs e)
        {
            if (e == null)
            {
                throw new ArgumentNullException(nameof(e));
            }
            int idFlight = e.CommandArgument.ToString().SafeParseInt(LogbookEntry.idFlightNone);

            if (idFlight != LogbookEntry.idFlightNone)
            {
                LogbookEntry le = new LogbookEntry();
                le.FLoadFromDB(idFlight, string.Empty, LogbookEntry.LoadTelemetryOption.None, true);
                if (le.AdminSignatureSanityFix(e.CommandName.CompareOrdinalIgnoreCase("ForceValidity") == 0))
                {
                    List <LogbookEntry> lst = lstToFix;
                    lst.RemoveAll(l => l.FlightID == idFlight);
                    gvInvalidSignatures.DataSource = lstToFix = lst;
                    gvInvalidSignatures.DataBind();
                }
            }
        }
Esempio n. 5
0
        protected void UpdateInvalidSigs()
        {
            List <LogbookEntry> lst        = new List <LogbookEntry>();
            List <LogbookEntry> lstAutoFix = new List <LogbookEntry>();

            List <int> lstIDs = new List <int>();
            DBHelper   dbh    = new DBHelper("SELECT idFlight FROM Flights WHERE signatureState<>0 ORDER BY Username ASC, Date DESC");

            dbh.CommandArgs.Timeout = 300;  // up to 300 seconds.
            dbh.ReadRows((comm) => { }, (dr) => { lstIDs.Add(Convert.ToInt32(dr["idFlight"], CultureInfo.InvariantCulture)); });

            int cTotalSigned = lstIDs.Count;

            lstIDs.ForEach((idFlight) =>
            {
                LogbookEntry le = new LogbookEntry();
                le.FLoadFromDB(idFlight, string.Empty, LogbookEntry.LoadTelemetryOption.None, true);
                if (le.AdminSignatureSanityCheckState != LogbookEntry.SignatureSanityCheckState.OK)
                {
                    // see if we can auto-fix these.  Auto-fixed = decrypted hash matches case insenstive and trimmed.
                    if (le.DecryptedCurrentHash.Trim().CompareCurrentCultureIgnoreCase(le.DecryptedFlightHash.Trim()) == 0)
                    {
                        lstAutoFix.Add(le);
                        le.AdminSignatureSanityFix(true);
                    }
                    else
                    {
                        lst.Add(le);
                    }
                }
            });

            gvInvalidSignatures.DataSource = ViewState["InvalidSigs"] = lst;
            gvInvalidSignatures.DataBind();

            lblSigResults.Text = String.Format(CultureInfo.CurrentCulture, "Found {0} signed flights, {1} appear to have problems, {2} were autofixed (capitalization or leading/trailing whitespace)", cTotalSigned, lst.Count, lstAutoFix.Count);
        }