Ejemplo n.º 1
0
            public static MethodData Read(BinaryReader reader)
            {
                var hasDebugData = reader.ReadVariableInt() != 0;
                var dataSize     = reader.ReadVariableInt();
                var dataEnd      = reader.BaseStream.Position + dataSize;

                var      seqPoints = new List <SeqPoint> ();
                SeqPoint prev      = null;

                while (reader.BaseStream.Position < dataEnd)
                {
                    var seqPoint = SeqPoint.Read(reader, prev, hasDebugData);
                    seqPoints.Add(seqPoint);
                    prev = seqPoint;
                }

                if (reader.BaseStream.Position != dataEnd)
                {
                    throw new Exception("Read more seq point than expected.");
                }

                return(new MethodData()
                {
                    seqPoints = seqPoints
                });
            }
Ejemplo n.º 2
0
            public static SeqPoint Read(BinaryReader reader, SeqPoint prev, bool hasDebug)
            {
                var ilOffset     = reader.ReadVariableZigZagInt();
                var nativeOffset = reader.ReadVariableZigZagInt();

                // Respect delta encoding
                if (prev != null)
                {
                    ilOffset     += prev.ILOffset;
                    nativeOffset += prev.NativeOffset;
                }

                //Read everything to ensure the buffer position is at the end of the seq point data.
                if (hasDebug)
                {
                    reader.ReadVariableInt();                      // flags

                    var next_length = reader.ReadVariableInt();
                    for (var i = 0; i < next_length; ++i)
                    {
                        reader.ReadVariableInt();
                    }
                }

                return(new SeqPoint(ilOffset, nativeOffset));
            }
Ejemplo n.º 3
0
 private unsafe Point GetScrollPos()
 {
     SeqPoint res = new SeqPoint();
     IntPtr ptr = new IntPtr(&res);
     Message m = Message.Create(this.Handle, EM_GETSCROLLPOS, IntPtr.Zero, ptr);
     this.WndProc(ref m);
     return new Point(res.x,res.y);
 }
Ejemplo n.º 4
0
 private unsafe void SetScrollPos( Point p )
 {
     SeqPoint res = new SeqPoint();
     res.x = p.X;
     res.y = p.Y;
     IntPtr ptr = new IntPtr(&res);
     Message m = Message.Create(this.Handle, EM_SETSCROLLPOS, IntPtr.Zero, ptr);
     this.WndProc(ref m);
 }
Ejemplo n.º 5
0
            public bool TryGetILOffset(int nativeOffset, out int ilOffset)
            {
                ilOffset = 0;
                SeqPoint prev = null;

                foreach (var seqPoint in seqPoints)
                {
                    if (seqPoint.NativeOffset > nativeOffset)
                    {
                        break;
                    }
                    prev = seqPoint;
                }

                if (prev == null)
                {
                    return(false);
                }

                ilOffset = prev.ILOffset;
                return(true);
            }
Ejemplo n.º 6
0
			public static SeqPoint Read (BinaryReader reader, SeqPoint prev, bool hasDebug)
			{
				var ilOffset = reader.ReadVariableZigZagInt ();
				var nativeOffset = reader.ReadVariableZigZagInt ();

				// Respect delta encoding
				if (prev != null) {
					ilOffset += prev.ILOffset;
					nativeOffset += prev.NativeOffset;
				}

				//Read everything to ensure the buffer position is at the end of the seq point data.
				if (hasDebug) {
					reader.ReadVariableInt (); // flags

					var next_length = reader.ReadVariableInt ();
					for (var i = 0; i < next_length; ++i)
						reader.ReadVariableInt ();
				}

				return new SeqPoint (ilOffset, nativeOffset);
			}
Ejemplo n.º 7
0
        /// <summary>
        /// Run the program through the main sequence.
        /// Note that each case simply increments the seq SeqPoint.
        /// It is debateable whether this is the more readable way to write this.
        /// I think it is.
        /// </summary>
        /// <param name="form">The form on which these controls are displayed</param>
        /// <param name="seq">Next step on the main sequence</param>
        private static void Run(Form1 form, SeqPoint seq)
        {
            bool are_table_files_present = BeforeEnteringMainSequence(form); // Initialize before entering the main sequence.

            if (are_table_files_present || seq <= SeqPoint.extractFromZip)
            {
                var update_form     = new UpdatedBillsForm();
                var unreported_form = new UnreportedBillsForm();
                while (seq != SeqPoint.complete)      // While the main sequence is not complete
                {
                    switch (seq)                      // Perform the current step in the sequence
                    {
                    case SeqPoint.importFromLegSite:
                        new LegSiteController().Run(form); // Download the latest leginfo zip file, which is a zipped file.
                        seq++;
                        break;

                    case SeqPoint.extractFromZip:
                        new ZipController().Run(form); // Extract the contents of the downloaded zip file.
                        if (!are_table_files_present)  // If could not fill database from unzipped table files
                        {
                            if (!BeforeEnteringMainSequence(form))
                            {
                                throw new ApplicationException($"SequenceController.Run: Table files missing, cannot initialize database.");
                            }
                        }
                        seq++;
                        break;

                    case SeqPoint.importToDB:
                        new ImportController().Run(form);// Update the database with the latest data on the bill's text, status, committee location, etc.
                        seq++;
                        break;

                    case SeqPoint.regenBillReports:
                        new Regenerate().Run(form);   // Regenerate the individual bill reports.  In particular, update the bill's history
                        seq++;
                        break;

                    case SeqPoint.updateBillReports:
                        new UpdateExistingReports().Run(form, update_form);// User updates existing bill reports
                        seq++;
                        break;

                    case SeqPoint.createBillReports:
                        new CreateNewReports().Run(form, unreported_form);// User creates reports for newly found bills of interest
                        seq++;
                        break;

                    case SeqPoint.weeklyReport:
                        new WeeklyReport().Run(form); // Generate the weekly report
                        seq++;
                        break;

                    default:
                        throw new ApplicationException($"SequenceControl.Run: Invalid sequence point {seq} encountered.");
                    }
                }
            }
            else
            {
                string msg = "At least one of BILL_HISTORY_TBL.dat, BILL_VERSION_TBL.dat, LOCATION_CODE_TBL.dat are not present.";
                LogAndShow(msg);
                throw new ApplicationException($"SequenceControl.Run: {msg}");
            }
        }