/* Returns a Set using a SQLiteDataReader and a dictionary mapping the attributes to a index.
  */
 private Set SetExtractor(SQLiteDataReader reader, Dictionary<string, int> attributeIndexDict)
 {
     return new Set(reader.GetInt32(attributeIndexDict["day"]), reader.GetInt32(attributeIndexDict["month"]), 
             reader.GetInt32(attributeIndexDict["year"]), reader.GetInt32(attributeIndexDict["setSeqNum"]),
             reader.GetInt32(attributeIndexDict["activityId"]), reader.GetDouble(attributeIndexDict["weight"]),
             reader.GetInt32(attributeIndexDict["secs"]), reader.GetInt32(attributeIndexDict["reps"]));
 }
Example #2
0
        public void CreateChart(ZedGraphControl zgc)
        {
            GraphPane myPane = zgc.GraphPane;

            PointPairList lstIncome = new PointPairList();
            PointPairList lstExpense = new PointPairList();

            // Set the title and axis labels
            myPane.Title.FontSpec.Family = "Browallia New";
            myPane.Title.FontSpec.Size = 24;
            myPane.Title.Text = "สรุป";
            myPane.XAxis.Title.FontSpec.Family = "Browallia New";
            myPane.XAxis.Title.FontSpec.Size = 16;
            myPane.XAxis.Title.Text = "เดือน";
            myPane.XAxis.Type = AxisType.Text;
            myPane.YAxis.Title.FontSpec.Family = "Browallia New";
            myPane.YAxis.Title.FontSpec.Size = 24;
            myPane.YAxis.Title.Text = "จำนวนเงิน";

            // Load data for this month
            sql_cmd.CommandText = "SELECT Month, TotalIncome, TotalExpense FROM Month WHERE Year = '" + CustomDate.GetThaiYear(DateTime.Today.Year) + "'";
            sql_reader = sql_cmd.ExecuteReader();
            while (sql_reader.Read())
            {
                monthsLabel.Add(CustomDate.GetThaiMonth(sql_reader.GetInt32(0)));
                lstIncome.Add(0, sql_reader.GetDouble(1));
                lstExpense.Add(0, sql_reader.GetDouble(2));
            }
            sql_reader.Close();

            myPane.XAxis.Scale.FontSpec.Family = "Browallia New";
            myPane.XAxis.Scale.FontSpec.Size = 16;
            myPane.XAxis.Scale.TextLabels = monthsLabel.ToArray();

            BarItem myCurve = myPane.AddBar("รายรับ", lstIncome, Color.Blue);
            BarItem myCurve2 = myPane.AddBar("รายจ่าย", lstExpense, Color.Red);

            myPane.Chart.Fill = new Fill(Color.White, Color.FromArgb(255, 255, 166), 45.0F);

            myPane.YAxis.Scale.Max += myPane.YAxis.Scale.MajorStep;

            //BarItem.CreateBarLabels(myPane, false, "#,#0.00#", "Tahoma", 10, Color.Black, true, false, false);

            zgc.AxisChange();
        }
        public SortieStatisticData(SQLiteDataReader rpReader) : base(rpReader)
        {
            Count = rpReader.GetInt32("count");

            FuelConsumption = rpReader.GetInt32("fuel_consumption");
            BulletConsumption = rpReader.GetInt32("bullet_consumption");
            SteelConsumption = rpReader.GetInt32("steel_consumption");
            BauxiteConsumption = rpReader.GetInt32("bauxite_consumption");
            BucketConsumption = rpReader.GetInt32("bucket_consumption");

            RankingPoint = rpReader.GetDouble("ranking_point");

            SRankCount = rpReader.GetInt32("s_rank_count");
            ARankCount = rpReader.GetInt32("a_rank_count");
            BRankCount = rpReader.GetInt32("b_rank_count");
            FailureRankCount = rpReader.GetInt32("failure_rank_count");
        }
Example #4
0
 public static void ReadValue(SQLiteDataReader reader, int index, TypeStorage type, ICdlValueWriter writer)
 {
     switch (type)
     {
         case TypeStorage.Boolean:
             writer.SetBoolean(reader.GetInt32(index) != 0);
             break;
         case TypeStorage.Byte:
             writer.SetByte((byte) reader.GetInt32(index));
             break;
         case TypeStorage.Int16:
             writer.SetInt16((short) reader.GetInt32(index));
             break;
         case TypeStorage.Int32:
             writer.SetInt32((int) reader.GetInt32(index));
             break;
         case TypeStorage.Int64:
             writer.SetInt64((long) reader.GetInt64(index));
             break;
         case TypeStorage.SByte:
             writer.SetSByte((sbyte) reader.GetInt32(index));
             break;
         case TypeStorage.UInt16:
             writer.SetUInt16((ushort) reader.GetInt32(index));
             break;
         case TypeStorage.UInt32:
             writer.SetUInt32((uint) reader.GetInt32(index));
             break;
         case TypeStorage.UInt64:
             writer.SetUInt64((ulong) reader.GetInt64(index));
             break;
         case TypeStorage.DateTime:
             writer.SetDateTime(DateTime.Parse(reader.GetString(index), CultureInfo.InvariantCulture));
             //writer.SetDateTime(DateTime.ParseExact(reader.GetString(index), "s", CultureInfo.InvariantCulture));
             break;
         case TypeStorage.DateTimeEx:
             writer.SetDateTimeEx(DateTimeEx.ParseNormalized(reader.GetString(index)));
             break;
         case TypeStorage.DateEx:
             writer.SetDateEx(DateEx.ParseNormalized(reader.GetString(index)));
             break;
         case TypeStorage.TimeEx:
             writer.SetTimeEx(TimeEx.ParseNormalized(reader.GetString(index)));
             break;
         case TypeStorage.Decimal:
             {
                 var dtype = reader.GetFieldType(index);
                 decimal value;
                 if (dtype == typeof (string))
                 {
                     value = Decimal.Parse(reader.GetString(index), CultureInfo.InvariantCulture);
                 }
                 else
                 {
                     value = (decimal) reader.GetDouble(index);
                 }
                 writer.SetDecimal(value);
             }
             break;
         case TypeStorage.Float:
             writer.SetFloat((float) reader.GetDouble(index));
             break;
         case TypeStorage.Double:
             writer.SetDouble((double) reader.GetDouble(index));
             break;
         case TypeStorage.String:
             writer.SetString(reader.GetString(index));
             break;
         case TypeStorage.Guid:
             writer.SetGuid(new Guid(reader.GetString(index)));
             break;
         case TypeStorage.ByteArray:
             writer.SetByteArray((byte[]) reader.GetValue(index));
             break;
         case TypeStorage.Null:
             writer.SetNull();
             break;
         default:
             throw new Exception("DBSH-00167 Unsupported field type:" + type.ToString());
     }
 }
        private StoredBlock ReadBlock(SQLiteDataReader reader)
        {
            int col = 0;

            StoredBlockBuilder blockBuilder = new StoredBlockBuilder();

            byte[] headerBytes = ReadBytes(reader, col++);
            blockBuilder.Header = BlockHeader.Read(new BitcoinStreamReader(new MemoryStream(headerBytes)));
            blockBuilder.Hash = ReadBytes(reader, col++);
            blockBuilder.Height = reader.GetInt32(col++);
            blockBuilder.TotalWork = reader.GetDouble(col++);
            blockBuilder.HasContent = reader.GetBoolean(col++);
            blockBuilder.IsInBestHeaderChain = reader.GetBoolean(col++);
            blockBuilder.IsInBestBlockChain = reader.GetBoolean(col++);

            StoredBlock block = blockBuilder.Build();

            return block;
        }
        //Argument to this function should be changed
        //into the SQLResults object returned from
        //runQuery above (and used in fQR above)
        /// <summary>
        /// A public method allowing the Track Model and external modules to format 
        /// database queries into coherent RouteInfo objects
        /// </summary>
        /// <param name="rr">A SQLiteDataReader object provided by the runQuery method in the DBManager</param>
        /// <returns>A valid RouteInfo object, or null in the case of a database error.</returns>
        public RouteInfo formatRouteQueryResults(SQLiteDataReader rr)
        {
            if (rr == null)
                return null;
            //Temp list used to store blocks, since we dont know
            //ahead of time how many to expect
            var blockList = new List<Block>();
            int nBlocks = 0;

            //We need to get our list of blocks, and the number of blocks
            int bIDFinal = -1, locXFinal = -1, locYFinal = -1;
            double sEFinal = -1.0, gradeFinal = -0.0, bSizeFinal = -1.0;
            int dest1Final = -1, dest2Final = -1, prevFinal = -1;
            int trackCirIDFinal = -1;
            int speedLimitFinal =-1;
            while (rr.Read())
            {
                //Get all fields for a given block
                bIDFinal = rr.GetInt32(rr.GetOrdinal("blockID"));
                string line = rr.GetString(rr.GetOrdinal("line"));
                string infra = rr.GetString(rr.GetOrdinal("infra"));
                string dir = rr.GetString(rr.GetOrdinal("dir"));
                string state = rr.GetString(rr.GetOrdinal("state"));
                sEFinal = rr.GetDouble(rr.GetOrdinal("starting_elev"));
                gradeFinal = rr.GetDouble(rr.GetOrdinal("grade"));
                bSizeFinal = rr.GetDouble(rr.GetOrdinal("bSize"));
                trackCirIDFinal = rr.GetInt32(rr.GetOrdinal("trackCirID"));
                speedLimitFinal = rr.GetInt32(rr.GetOrdinal("speedLimit"));
                locXFinal = rr.GetInt32(rr.GetOrdinal("locX"));
                locYFinal = rr.GetInt32(rr.GetOrdinal("locY"));

                prevFinal = rr.GetInt32(rr.GetOrdinal("prev"));
                dest1Final = rr.GetInt32(rr.GetOrdinal("dest1"));
                dest2Final = rr.GetInt32(rr.GetOrdinal("dest2"));

                //////////////////////////////////////////////////////////////////////
                //Parse fields that must be provided as a different type
                string[] infraFinal = infra.Split(';');
                var dirFinal = (DirEnum) Enum.Parse(typeof (DirEnum), dir, true);
                var stateFinal = (StateEnum) Enum.Parse(typeof (StateEnum), state, true);

                var locFinal = new int[2];
                locFinal[0] = locXFinal;
                locFinal[1] = locYFinal;

                blockList.Add(new Block(bIDFinal, stateFinal, prevFinal, sEFinal, gradeFinal, locFinal, bSizeFinal,
                                        dirFinal, infraFinal, dest1Final, dest2Final, trackCirIDFinal, line,speedLimitFinal));
                nBlocks++;
            }

            //If we didnt find any blocks, give up.
            if (nBlocks == 0)
            {
                //if (_dbCon.State != ConnectionState.Closed)
                  //  _dbCon.Close();
                return null;
            }

            Block[] blocks = blockList.ToArray();
            string rName = blocks[0].Line;
            int rID;
            if (rName.Equals("Red", StringComparison.OrdinalIgnoreCase))
                rID = 0;
            else
                rID = 1;

            //All routes start and end at the yard
            int sID = 0;
            int eID = 0;

            var tempRoute = new RouteInfo(rID, rName, nBlocks, blocks, sID, eID);
            //if (_dbCon.State != ConnectionState.Closed)
              //  _dbCon.Close();
            return tempRoute;
        }
        //Argument to this function shouldbe changed
        //into the SQLResults object returned from
        //runQuery() above
        /// <summary>
        /// A public method allowing the track model and other modules to format 
        /// database query results into coherent Block objects
        /// </summary>
        /// <param name="bR">The SQLiteDataReader containing the results of the query</param>
        /// <returns>A valid Block object, or null in the case of an error</returns>
        public Block formatBlockQueryResults(SQLiteDataReader bR)
        {
            Block tempBlock = null;
            int i = 0;
            if (!bR.IsClosed)
            {
                while (bR.Read())
                {
                    //Get all fields for a given block
                    string line = null, infra = null, dir = null;
                    string state = null;

                    int bIDFinal = -1, locXFinal = -1, locYFinal = -1;
                    double sEFinal = -1.0, gradeFinal = -1.0, bSizeFinal = -1.0;
                    int prevFinal = -1, dest1Final = -1, dest2Final = -1;
                    int trackCirIDFinal = -1;
                    int speedLimitFinal = -1;
                    try
                    {
                        bIDFinal = bR.GetInt32(bR.GetOrdinal("blockID"));
                        line = bR.GetString(bR.GetOrdinal("line"));
                        infra = bR.GetString(bR.GetOrdinal("infra"));
                        dir = bR.GetString(bR.GetOrdinal("dir"));
                        state = bR.GetString(bR.GetOrdinal("state"));
                        if (bIDFinal != 0)
                        {
                            sEFinal = bR.GetDouble(bR.GetOrdinal("starting_elev"));
                            gradeFinal = bR.GetDouble(bR.GetOrdinal("grade"));
                            locXFinal = bR.GetInt32(bR.GetOrdinal("locX"));
                            locYFinal = bR.GetInt32(bR.GetOrdinal("locY"));
                            bSizeFinal = bR.GetDouble(bR.GetOrdinal("bSize"));
                            prevFinal = bR.GetInt32(bR.GetOrdinal("prev"));
                            dest1Final = bR.GetInt32(bR.GetOrdinal("dest1"));
                            dest2Final = bR.GetInt32(bR.GetOrdinal("dest2"));
                            trackCirIDFinal = bR.GetInt32(bR.GetOrdinal("trackCirID"));
                            speedLimitFinal = bR.GetInt32(bR.GetOrdinal("speedLimit"));
                        }
                    }
                    catch (Exception e)
                    {
                        //Console.WriteLine("Exception was raised");
                    }
                    //////////////////////////////////////////////////////////////////////
                    //Parse fields that must be provided as a different type
                    string[] infraFinal = infra.Split(';');
                    var dirFinal = (DirEnum) Enum.Parse(typeof (DirEnum), dir, true);
                    var stateFinal = (StateEnum) Enum.Parse(typeof (StateEnum), state, true);

                    var locFinal = new int[2];
                    locFinal[0] = locXFinal;
                    locFinal[1] = locYFinal;

                    tempBlock = new Block(bIDFinal, stateFinal, prevFinal, sEFinal, gradeFinal, locFinal, bSizeFinal,
                                          dirFinal, infraFinal, dest1Final, dest2Final, trackCirIDFinal, line,speedLimitFinal);
                    i++; //Inc counter
                }
            }
            else
            {
                //Console.WriteLine("Reader was closed, this was a mistake.");
            }

            if (i != 1)
                return null;
            else
                return tempBlock;
        }
 AnswerValue GetValues(SQLiteDataReader reader)
 {
     var a = new Answer { Id = reader.GetInt32(1), ProjectRoundId = reader.GetInt32(6), ProjectRoundUnitId = reader.GetInt32(7) };
     var v = new AnswerValue { Id = reader.GetInt32(0), Answer = a, QuestionId = reader.GetInt32(2), OptionId = reader.GetInt32(3), AnswerDecimal = reader.GetDouble(4) };
     return v;
 }
 public static void Read(this Beatmap beatmap, SQLiteDataReader reader)
 {
     int i = 1;
     beatmap.TitleRoman = reader.GetString(i); i++;
     beatmap.ArtistRoman = reader.GetString(i); i++;
     beatmap.TitleUnicode = reader.GetString(i); i++;
     beatmap.ArtistUnicode = reader.GetString(i); i++;
     beatmap.Creator = reader.GetString(i); i++;
     beatmap.DiffName = reader.GetString(i); i++;
     beatmap.Mp3Name = reader.GetString(i); i++;
     beatmap.Md5 = reader.GetString(i); i++;
     beatmap.OsuFileName = reader.GetString(i); i++;
     beatmap.MaxBpm = reader.GetDouble(i); i++;
     beatmap.MinBpm = reader.GetDouble(i); i++;
     beatmap.Tags = reader.GetString(i); i++;
     beatmap.State = reader.GetByte(i); i++;
     beatmap.Circles = (short)reader.GetInt32(i); i++;
     beatmap.Sliders = (short)reader.GetInt32(i); i++;
     beatmap.Spinners = (short)reader.GetInt32(i); i++;
     beatmap.EditDate = reader.GetDateTime(i); i++;
     beatmap.ApproachRate = (float)reader.GetDouble(i); i++;
     beatmap.CircleSize = (float)reader.GetDouble(i); i++;
     beatmap.HpDrainRate = (float)reader.GetDouble(i); i++;
     beatmap.OverallDifficulty = (float)reader.GetDouble(i); i++;
     beatmap.SliderVelocity = reader.GetDouble(i); i++;
     beatmap.DrainingTime = reader.GetInt32(i); i++;
     beatmap.TotalTime = reader.GetInt32(i); i++;
     beatmap.PreviewTime = reader.GetInt32(i); i++;
     beatmap.MapId = reader.GetInt32(i); i++;
     beatmap.MapSetId = reader.GetInt32(i); i++;
     beatmap.ThreadId = reader.GetInt32(i); i++;
     beatmap.MapRating = reader.GetInt32(i); i++;
     beatmap.Offset = (short)reader.GetInt32(i); i++;
     beatmap.StackLeniency = (float)reader.GetDouble(i); i++;
     beatmap.Mode = reader.GetByte(i); i++;
     beatmap.Source = reader.GetString(i); i++;
     beatmap.AudioOffset = (short)reader.GetInt32(i); i++;
     beatmap.LetterBox = reader.GetString(i); i++;
     beatmap.Played = reader.GetBoolean(i); i++;
     beatmap.LastPlayed = reader.GetDateTime(i); i++;
     beatmap.IsOsz2 = reader.GetBoolean(i); i++;
     beatmap.Dir = reader.GetString(i); i++;
     beatmap.LastSync = reader.GetDateTime(i); i++;
     beatmap.DisableHitsounds = reader.GetBoolean(i); i++;
     beatmap.DisableSkin = reader.GetBoolean(i); i++;
     beatmap.DisableSb = reader.GetBoolean(i); i++;
     beatmap.BgDim = reader.GetInt16(i); i++;
     beatmap.Somestuff = reader.GetInt16(i); i++;
     beatmap.VideoDir = reader.GetString(i);
 }