Ejemplo n.º 1
0
        public static void ReportError(int epid)
        {
            ErrorReporting report = null;

            using (SQLiteCommand command = new SQLiteCommand("select errordetails from downloads where epid=@epid and errordetails is not null", FetchDbConn()))
            {
                command.Parameters.Add(new SQLiteParameter("@epid", epid));

                using (SQLiteMonDataReader reader = new SQLiteMonDataReader(command.ExecuteReader()))
                {
                    if (reader.Read())
                    {
                        int errordetailsOrdinal = reader.GetOrdinal("errordetails");

                        // Get the length of the content by passing null to getbytes
                        int contentLength = (int)reader.GetBytes(errordetailsOrdinal, 0, null, 0, 0);

                        byte[] content = new byte[contentLength];
                        reader.GetBytes(errordetailsOrdinal, 0, content, 0, contentLength);

                        using (MemoryStream stream = new MemoryStream(content))
                        {
                            BinaryFormatter formatter = new BinaryFormatter();
                            report = (ErrorReporting)formatter.Deserialize(stream);
                        }
                    }
                }
            }

            if (report == null)
            {
                MessageBox.Show("Please retry this download before reporting the error again.", Application.ProductName);
                return;
            }

            if (report.SendReport())
            {
                using (SQLiteCommand command = new SQLiteCommand("update downloads set errordetails=null where epid=@epid", FetchDbConn()))
                {
                    command.Parameters.Add(new SQLiteParameter("@epid", epid));
                    command.ExecuteNonQuery();
                }
            }
        }
Ejemplo n.º 2
0
        public static void ReportError(int epid)
        {
            ErrorReporting report = null;

            using (SQLiteCommand command = new SQLiteCommand("select errordetails from downloads where epid=@epid and errordetails is not null", FetchDbConn()))
            {
                command.Parameters.Add(new SQLiteParameter("@epid", epid));

                using (SQLiteMonDataReader reader = new SQLiteMonDataReader(command.ExecuteReader()))
                {
                    if (reader.Read())
                    {
                        int errordetailsOrdinal = reader.GetOrdinal("errordetails");

                        // Get the length of the content by passing null to getbytes
                        int contentLength = (int)reader.GetBytes(errordetailsOrdinal, 0, null, 0, 0);

                        byte[] content = new byte[contentLength];
                        reader.GetBytes(errordetailsOrdinal, 0, content, 0, contentLength);

                        using (MemoryStream stream = new MemoryStream(content))
                        {
                            BinaryFormatter formatter = new BinaryFormatter();
                            report = (ErrorReporting)formatter.Deserialize(stream);
                        }
                    }
                }
            }

            if (report == null)
            {
                MessageBox.Show("Please retry this download before reporting the error again.", Application.ProductName);
                return;
            }

            if (report.SendReport())
            {
                using (SQLiteCommand command = new SQLiteCommand("update downloads set errordetails=null where epid=@epid", FetchDbConn()))
                {
                    command.Parameters.Add(new SQLiteParameter("@epid", epid));
                    command.ExecuteNonQuery();
                }
            }
        }