/* 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"]));
 }
Exemple #2
0
        protected override Exemplar InitEntryByReader(System.Data.SQLite.SQLiteDataReader reader)
        {
            Exemplar exemplar = new Exemplar();

            ulong id = System.Convert.ToUInt64(reader.GetInt32(reader.GetOrdinal("id")));

            string   loanPeriodAsString = reader.GetString(reader.GetOrdinal("loanPeriod"));
            DateTime loanPeriod         = new DateTime();

            if (loanPeriodAsString != null || loanPeriodAsString != "")
            {
                loanPeriod = DateTime.Parse(loanPeriodAsString);
            }

            string     stateString = reader.GetString(reader.GetOrdinal("state"));
            BookStates state       = (BookStates)Enum.Parse(typeof(BookStates), stateString, true);

            string signatur   = reader.GetString(reader.GetOrdinal("signatur"));
            ulong  customerId = System.Convert.ToUInt64(reader.GetInt32(reader.GetOrdinal("customerID")));
            ulong  bookId     = System.Convert.ToUInt64(reader.GetInt32(reader.GetOrdinal("bookID")));

            exemplar.ExemplarId = id;
            exemplar.LoanPeriod = loanPeriod;
            exemplar.State      = state;
            exemplar.Signatur   = signatur;
            exemplar.BookId     = bookId;

            return(exemplar);
        }
Exemple #3
0
    internal DbChannel(SignalSource source, SQLiteDataReader r, IDictionary<string, int> field, 
      DataRoot dataRoot, IDictionary<string,bool> encryptionInfo)
    {
      this.SignalSource = source;
      this.RecordIndex = r.GetInt32(field["channel_handle"]);

      this.Bits = r.GetInt32(field["list_bits"]);
      bool isTv = (Bits & BITS_Tv) != 0;
      bool isRadio = (Bits & BITS_Radio) != 0;
      bool isAnalog = (source & SignalSource.Analog) != 0;
      if (isAnalog && !isTv)
      {
        this.IsDeleted = true;
        return;
      }

      if (isTv) this.SignalSource |= SignalSource.Tv;
      if (isRadio) this.SignalSource |= SignalSource.Radio;
      this.Lock = (Bits & BITS_Locked) != 0;
      this.OldProgramNr = r.GetInt32(field["channel_number"]);
      this.Favorites = this.ParseFavorites(Bits);
      
      if (isAnalog)
        this.ReadAnalogData(r, field);
      else
        this.ReadDvbData(r, field, dataRoot, encryptionInfo);
    }
        public Report()
        {
            InitializeComponent();

            // Connect to database file
            sql_con = new SQLiteConnection("Data Source=" + applicationPath + "\\ExpenseTracker.db;Version=3;New=False;Compress=True;");
            sql_cmd = new SQLiteCommand();
            sql_con.Open();
            sql_cmd.Connection = sql_con;
            sql_cmd.CommandText = "SELECT * FROM Month";
            sql_reader = sql_cmd.ExecuteReader();
            while (sql_reader.Read())
            {
                dataGridView.Rows.Add(
                    sql_reader.GetInt32(0),
                    CustomDate.GetThaiMonth(sql_reader.GetInt32(1)),
                    sql_reader.GetDecimal(2).ToString("#,#0.00#"),
                    sql_reader.GetDecimal(3).ToString("#,#0.00#"),
                    sql_reader.GetDecimal(4).ToString("#,#0.00#")
                );
            }
            sql_reader.Close();

            dataGridView.ClearSelection();
        }
 /* Returns a Activity using a SQLiteDataReader and a dictionary mapping the attributes to a index.
  */
 private Activity ActivityExtractor(SQLiteDataReader reader, Dictionary<string, int> attributeIndexDict)
 {
     return new Activity(reader.GetInt32(attributeIndexDict["activityId"]),
             reader.GetInt32(attributeIndexDict["seqNum"]), reader.GetString(attributeIndexDict["workoutName"]),
             reader.GetInt32(attributeIndexDict["numSets"]), reader.GetInt32(attributeIndexDict["workoutVersion"]),
             reader.GetString(attributeIndexDict["exerciseName"]), reader.GetInt32(attributeIndexDict["exerciseVersion"]));
 }
Exemple #6
0
 protected void ReadDvbData(SQLiteDataReader r, IDictionary<string, int> field, DataRoot dataRoot, 
   IDictionary<string, bool> encryptionInfo)
 {
   string longName, shortName;
   this.GetChannelNames(r.GetString(field["channel_label"]), out longName, out shortName);
   this.Name = longName;
   this.ShortName = shortName;
   this.RecordOrder = r.GetInt32(field["channel_order"]);
   this.FreqInMhz = (decimal)r.GetInt32(field["frequency"]) / 1000;
   int serviceType = r.GetInt32(field["dvb_service_type"]);
   this.ServiceType = serviceType;
   this.OriginalNetworkId = r.GetInt32(field["onid"]);
   this.TransportStreamId = r.GetInt32(field["tsid"]);
   this.ServiceId = r.GetInt32(field["sid"]);
   int bits = r.GetInt32(field["list_bits"]);
   this.Favorites = this.ParseFavorites(bits);
   if ((this.SignalSource & SignalSource.Sat) != 0)
   {
     int satId = r.GetInt32(field["sat_id"]);
     var sat = dataRoot.Satellites.TryGet(satId);
     if (sat != null)
     {
       this.Satellite = sat.Name;
       this.SatPosition = sat.OrbitalPosition;
       int tpId = satId * 1000000 + (int)this.FreqInMhz;
       var tp = dataRoot.Transponder.TryGet(tpId);
       if (tp != null)
       {
         this.SymbolRate = tp.SymbolRate;
       }
     }
   }
   this.Encrypted = encryptionInfo.TryGet(this.Uid);      
 }
Exemple #7
0
 private int findNOCert()
 {
     try
     {
         using (System.Data.SQLite.SQLiteConnection conn = new System.Data.SQLite.SQLiteConnection("data source=gestionalePalestra.db"))
         {
             using (System.Data.SQLite.SQLiteCommand cmd = new System.Data.SQLite.SQLiteCommand(conn))
             {
                 conn.Open();
                 string command = "SELECT count(*) FROM Certificato WHERE Presente='NO';";
                 cmd.CommandText = command;
                 using (System.Data.SQLite.SQLiteDataReader reader = cmd.ExecuteReader())
                 {
                     if (reader.Read())
                     {
                         return(reader.GetInt32(0)); //ritorna la prima colonna, quella avente il count
                     }
                 }
                 conn.Close();
             }
         }
         return(0);
     }
     catch
     {
         return(-1);
     }
 }
Exemple #8
0
 private int findNextToPay()
 {
     try
     {
         using (System.Data.SQLite.SQLiteConnection conn = new System.Data.SQLite.SQLiteConnection("data source=gestionalePalestra.db"))
         {
             using (System.Data.SQLite.SQLiteCommand cmd = new System.Data.SQLite.SQLiteCommand(conn))
             {
                 conn.Open();
                 string command = "SELECT count(*) FROM Rata WHERE DATE(DataPagam) <= DATE('now','+'||14||' days') and DATE(DataPagam) >= DATE('now') and (PagamentoAvv='NO')";
                 cmd.CommandText = command;
                 using (System.Data.SQLite.SQLiteDataReader reader = cmd.ExecuteReader())
                 {
                     if (reader.Read())
                     {
                         return(reader.GetInt32(0)); //ritorna la prima colonna, quella avente il count
                     }
                 }
                 conn.Close();
             }
         }
         return(0);
     }
     catch
     {
         return(-1);
     }
 }
        public string printToConsole(SQLiteDataReader readerDB, int index)
        {
            if (readerDB.IsDBNull(index))
            {
                //return "NULL";
                return "";
            }
            else
            {
                String dataObject = readerDB.GetFieldType(index).ToString();
                switch (dataObject)
                {
                    case "System.Int32":
                        return readerDB.GetInt32(index).ToString();
                    case "System.DateTime":
                        DateTime date = readerDB.GetDateTime(index);
                        return Convert.ToString(date);
                    case "System.String":
                        return readerDB.GetString(index);
                    default:
                        return "Unknown";
                }
            }

        }
 public ICollection <IFinancialProduct> UpdateTheListView(ICollection <IFinancialProduct> listProducts)
 {
     try
     {
         connection.Open();
         cmd = new System.Data.SQLite.SQLiteCommand(connection);
         //cmd.Prepare();
         //connection.CreateTable<Stock>();
         //connection.CreateTable<Fund>();
         cmd.CommandText = "SELECT * FROM Stock";
         try
         {
             allRead = cmd.ExecuteReader();
             while (allRead.Read())
             {
                 listProducts.Add(new Stock(allRead.GetInt32(0), allRead.GetString(1), allRead.GetString(2), allRead.GetString(3)));
                 //listProducts.Add(new Stock((int)allRead["Id"], (string)allRead["categoria"], (string)allRead["name"], (string)allRead["code"])); //Isso não converte.
             }
         }
         catch (Exception e)
         {
             MessageBox.Show("Erro ao montar a lista de ações: " + e.Message);
             return(null);
         }
         cmd = new System.Data.SQLite.SQLiteCommand(connection);
         //cmd.Prepare();
         //connection.CreateTable<Stock>();
         //connection.CreateTable<Fund>();
         cmd.CommandText = "SELECT * FROM Fund";
         try
         {
             allRead = cmd.ExecuteReader();
             while (allRead.Read())
             {
                 listProducts.Add(new Fund(allRead.GetInt32(0), allRead.GetString(1), allRead.GetString(2), allRead.GetString(3), allRead.GetString(4)));
                 //listProducts.Add(new Fund(
                 //(int)allRead["Id"],
                 //(string)allRead["categoria"],
                 //(string)allRead["name"],
                 //(string)allRead["code"])); //Isso não converte.
             }
         }
         catch (Exception e)
         {
             MessageBox.Show("Erro ao montar a lista de Fundos: " + e.Message);
             return(null);
         }
     }
     catch (Exception e)
     {
         MessageBox.Show("Erro ao acessar Banco de Dados: " + e);
         return(null);
     }
     finally
     {
         connection.Close();
     }
     return(listProducts);
 }
        internal FateRecord(SQLiteDataReader rpReader)
        {
            ID = rpReader.GetInt64("time");

            var rMasterInfo = KanColleGame.Current.MasterInfo;
            var rMasterID = rpReader.GetInt32("master_id");
            IsEquipment = rpReader.GetBoolean("is_equipment");
            if (!IsEquipment)
                Ship = rMasterInfo.Ships[rMasterID];
            else
                Equipment = rMasterInfo.Equipment[rMasterID];

            Level = rpReader.GetInt32("level");
            Proficiency = rpReader.GetInt32("proficiency");

            Fate = (Fate)rpReader.GetInt32("fate");
        }
        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");
        }
        internal SortieConsumptionRecord(SQLiteDataReader rpReader) : base(rpReader)
        {
            ID = rpReader.GetInt64("id");

            var rMapMaxHP = rpReader.GetInt32Optional("map_max_hp");
            if (rMapMaxHP.HasValue)
            {
                var rMapHP = rpReader.GetInt32Optional("map_hp");
                if (rMapHP.HasValue)
                    MapHP = new ClampedValue(rMapMaxHP.Value, rMapHP.Value);
            }

            Fuel = rpReader.GetInt32("fuel");
            Bullet = rpReader.GetInt32("bullet");
            Steel = rpReader.GetInt32("steel");
            Bauxite = rpReader.GetInt32("bauxite");
            Bucket = rpReader.GetInt32("bucket");

            RankingPoint = rpReader.GetDoubleOptional("ranking_point");
        }
 private TranslationMemory ReadTranslationMemory(SQLiteDataReader reader)
 {
     TranslationMemory tm = new TranslationMemory();
     tm.tmid = reader.GetInt32(0); // tmid used for update
     tm.japanese = GetSegmentFromXml(reader.GetString(4)); // source_segment
     tm.chinese = GetSegmentFromXml(reader.GetString(6)); // target_segment
     tm.tags += reader.GetString(8) + Environment.NewLine; // user
     tm.tags += reader.GetString(9) + Environment.NewLine; // date
     tm.tmname = Path.GetFileName(this.sourcePath);
     return tm;
 }
        public ResourceRecord(SQLiteDataReader rpReader)
        {
            ID = rpReader.GetInt64("time");

            Fuel = rpReader.GetInt32("fuel");
            Bullet = rpReader.GetInt32("bullet");
            Steel = rpReader.GetInt32("steel");
            Bauxite = rpReader.GetInt32("bauxite");
            InstantConstruction = rpReader.GetInt32("instant_construction");
            Bucket = rpReader.GetInt32("bucket");
            DevelopmentMaterial = rpReader.GetInt32("development_material");
            ImprovementMaterial = rpReader.GetInt32("improvement_material");
        }
        public SortieRecordBase(SQLiteDataReader rpReader)
        {
            var rMapID = rpReader.GetInt32("map");
            Map = MapService.Instance.GetMasterInfo(rMapID);

            var rEventMapDifficulty = rpReader.GetInt32Optional("difficulty");
            if (rEventMapDifficulty.HasValue)
            {
                IsEventMap = true;
                EventMapDifficulty = (EventMapDifficulty)rEventMapDifficulty.Value;
            }
        }
Exemple #17
0
 private void ParseFavorites(SQLiteDataReader r, IDictionary<string, int> field)
 {
   for (int i = 0; i < 4; i++)
   {
     int favIndex = r.GetInt32(field["profile" + (i + 1) + "index"]);
     if (favIndex > 0)
     {
       this.Favorites |= (Favorites) (1 << i);
       this.FavIndex[i] = favIndex;
     }
   }
 }
Exemple #18
0
    protected void ReadDvbData(SQLiteDataReader r, IDictionary<string, int> field, DataRoot dataRoot, byte[] delivery)
    {
      int stype = r.GetInt32(field["stype"]);
      this.SignalSource |= LookupData.Instance.IsRadioOrTv(stype);
      this.ServiceType = stype;

      int freq = r.GetInt32(field["freq"]);
      if ((this.SignalSource & SignalSource.Sat) != 0)
      {
// ReSharper disable PossibleLossOfFraction
        this.FreqInMhz = freq/10;
// ReSharper restore PossibleLossOfFraction
        int satId = r.GetInt32(field["physical_ch"]) >> 12;
        var sat = dataRoot.Satellites.TryGet(satId);
        if (sat != null)
        {
          this.Satellite = sat.Name;
          this.SatPosition = sat.OrbitalPosition;
        }
        if (delivery.Length >= 7)
        {
          this.SymbolRate = (delivery[5] >> 4)*10000 + (delivery[5] & 0x0F)*1000 +
                            (delivery[6] >> 4)*100 + (delivery[6] & 0x0F)*10;
        }
      }
      else
      {
        freq /= 1000;
        this.FreqInMhz = freq;
        this.ChannelOrTransponder = (this.SignalSource & SignalSource.Antenna) != 0 ? 
          LookupData.Instance.GetDvbtTransponder(freq).ToString() : 
          LookupData.Instance.GetDvbcTransponder(freq).ToString();
        this.Satellite = (this.SignalSource & SignalSource.Antenna) != 0 ? "DVB-T" : "DVB-C";
      }

      this.OriginalNetworkId = r.GetInt32(field["onid"]);
      this.TransportStreamId = r.GetInt32(field["tsid"]);
      this.ServiceId = r.GetInt32(field["sid"]);
    }
Exemple #19
0
    internal DbChannel(SQLiteDataReader r, IDictionary<string, int> field, DataRoot dataRoot, Dictionary<long, string> providers, Satellite sat, Transponder tp)
    {
      var chType = r.GetInt32(field["chType"]);
      this.SignalSource = DbSerializer.ChTypeToSignalSource(chType);

      this.RecordIndex = r.GetInt64(field["SRV.srvId"]);
      this.OldProgramNr = r.GetInt32(field["major"]);
      this.FreqInMhz = (decimal)r.GetInt32(field["freq"]) / 1000;
      this.ChannelOrTransponder = 
        (this.SignalSource & SignalSource.DvbT) == SignalSource.DvbT ? LookupData.Instance.GetDvbtTransponder(this.FreqInMhz).ToString() :
        (this.SignalSource & SignalSource.DvbC) == SignalSource.DvbC ? LookupData.Instance.GetDvbcTransponder(this.FreqInMhz).ToString() :
        (this.SignalSource & SignalSource.Sat) == SignalSource.DvbS ? LookupData.Instance.GetAstraTransponder((int)this.FreqInMhz).ToString() :
        "";
      this.Name = DbSerializer.ReadUtf16(r, 6);
      this.Hidden = r.GetBoolean(field["hidden"]);
      this.Encrypted = r.GetBoolean(field["scrambled"]);
      this.Lock = r.GetBoolean(field["lockMode"]);
      this.Skip = !r.GetBoolean(field["numSel"]);

      if (sat != null)
      {
        this.Satellite = sat.Name;
        this.SatPosition = sat.OrbitalPosition;
      }
      if (tp != null)
      {
        this.Transponder = tp;
        this.SymbolRate = tp.SymbolRate;
      }

      if ((this.SignalSource & SignalSource.Digital) != 0)
        this.ReadDvbData(r, field, dataRoot, providers);
      else
        this.ReadAnalogData(r, field);

      base.IsDeleted = this.OldProgramNr == -1;
    }
        internal ConstructionRecord(SQLiteDataReader rpReader)
        {
            ID = rpReader.GetInt64("time");

            Ship = KanColleGame.Current.MasterInfo.Ships[rpReader.GetInt32("ship")];

            FuelConsumption = rpReader.GetInt32("fuel");
            BulletConsumption = rpReader.GetInt32("bullet");
            SteelConsumption = rpReader.GetInt32("steel");
            BauxiteConsumption = rpReader.GetInt32("bauxite");
            DevelopmentMaterialConsumption = rpReader.GetInt32("dev_material");

            SecretaryShip = KanColleGame.Current.MasterInfo.Ships[rpReader.GetInt32("flagship")];
            HeadquarterLevel = rpReader.GetInt32("hq_level");

            EmptyDockCount = rpReader.GetInt32Optional("empty_dock");
        }
Exemple #21
0
 protected void ReadDvbData(SQLiteDataReader r, IDictionary<string, int> field, DataRoot dataRoot, Dictionary<long, string> providers)
 {
   this.ShortName = DbSerializer.ReadUtf16(r, 16);
   this.RecordOrder = r.GetInt32(field["major"]);
   int serviceType = r.GetInt32(field["srvType"]);
   this.ServiceType = serviceType;
   this.SignalSource |= LookupData.Instance.IsRadioOrTv(serviceType);
   this.OriginalNetworkId = r.GetInt32(field["onid"]);
   this.TransportStreamId = r.GetInt32(field["tsid"]);
   this.ServiceId = r.GetInt32(field["progNum"]);
   this.VideoPid = r.GetInt32(field["vidPid"]);
   if (!r.IsDBNull(field["provId"]))
     this.Provider = providers.TryGet(r.GetInt64(field["provId"]));
   this.AddDebug(r.GetInt32(field["lcn"]).ToString());
 }
        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();
        }
Exemple #23
0
    internal DbChannel(SQLiteDataReader r, IDictionary<string, int> field, DataRoot dataRoot, Encoding encoding)
    {
      this.RecordIndex = r.GetInt32(field["rowid"]);
      this.RecordOrder = r.GetInt32(field["major_channel"]);
      this.OldProgramNr = r.GetInt32(field["major_channel"]);
      int ntype = r.GetInt32(field["ntype"]);
      if (ntype == 1)
      {
        this.SignalSource |= SignalSource.DvbS;
        if (r.GetInt32(field["ya_svcid"]) >= 0)
          this.SignalSource |= SignalSource.Freesat;
      }
      else if (ntype == 2)
        this.SignalSource |= SignalSource.DvbT;
      else if (ntype == 3)
        this.SignalSource |= SignalSource.DvbC;
      else if (ntype == 10)
        this.SignalSource |= SignalSource.AnalogT | SignalSource.Tv;
      else if (ntype == 14)
        this.SignalSource |= SignalSource.AnalogC | SignalSource.Tv;
      else if (ntype == 15)
        this.SignalSource |= SignalSource.SatIP;

      byte[] buffer = new byte[1000];
      var len = r.GetBytes(field["delivery"], 0, buffer, 0, 1000);
      this.AddDebug(buffer, 0, (int) len);

      this.Skip = r.GetInt32(field["skip"]) != 0;
      this.Encrypted = r.GetInt32(field["free_CA_mode"]) != 0;
      this.Lock = r.GetInt32(field["child_lock"]) != 0;
      this.ParseFavorites(r, field);
      this.ReadNamesWithEncodingDetection(r, field, encoding);

      if (ntype == 10 || ntype == 14)
        this.ReadAnalogData(r, field);
      else
        this.ReadDvbData(r, field, dataRoot, buffer);
    }
        internal DevelopmentRecord(SQLiteDataReader rpReader)
        {
            ID = rpReader.GetInt64("time");

            var rEquipmentID = rpReader.GetInt32Optional("equipment");
            if (rEquipmentID.HasValue)
                Equipment = KanColleGame.Current.MasterInfo.Equipment[rEquipmentID.Value];

            FuelConsumption = rpReader.GetInt32("fuel");
            BulletConsumption = rpReader.GetInt32("bullet");
            SteelConsumption = rpReader.GetInt32("steel");
            BauxiteConsumption = rpReader.GetInt32("bauxite");

            SecretaryShip = KanColleGame.Current.MasterInfo.Ships[rpReader.GetInt32("flagship")];
            HeadquarterLevel = rpReader.GetInt32("hq_level");
        }
Exemple #25
0
        /// <summary>
        /// 读取权限列表
        /// </summary>
        /// <returns>权限列表的name与权限</returns>
        public List <Tuple <string, int> > ReadAuthorityTable()
        {
            try
            {
                using (var conn = new System.Data.SQLite.SQLiteConnection())
                {
                    var connstr = new SQLiteConnectionStringBuilder();
                    connstr.DataSource = datasource;
                    //connstr.Password = "******";//设置密码,SQLite ADO.NET实现了数据库密码保护
                    conn.ConnectionString = connstr.ToString();
                    conn.Open();
                    using (SQLiteCommand cmd = new SQLiteCommand())
                    {
                        var collect = new List <Tuple <string, int> >();

                        cmd.Connection = conn;

                        string sql = "SELECT * from control_authority";
                        cmd.CommandText = sql;
                        System.Data.SQLite.SQLiteDataReader reader = cmd.ExecuteReader();
                        while (reader.Read())
                        {
                            collect.Add(new Tuple <string, int>(reader.GetString(0), reader.GetInt32(1)));
                        }



                        conn.Close();
                        return(collect);
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        private static HuntingPlace createHunt(SQLiteDataReader reader)
        {
            SQLiteCommand command;

            if (!reader.Read()) {
                return null;
            }

            HuntingPlace huntingPlace = new HuntingPlace();
            huntingPlace.permanent = true;
            huntingPlace.id = reader.GetInt32(0);
            huntingPlace.name = reader["name"].ToString();
            huntingPlace.level = reader.IsDBNull(2) ? DATABASE_NULL : reader.GetInt32(2);
            huntingPlace.exp_quality = reader.IsDBNull(3) ? DATABASE_NULL : reader.GetInt32(3);
            huntingPlace.loot_quality = reader.IsDBNull(4) ? DATABASE_NULL : reader.GetInt32(4);
            string imageName = reader.GetString(5).ToLower();
            Creature cr = getCreature(imageName);
            if (cr != null) {
                huntingPlace.image = cr.GetImage();
            } else {
                NPC npc = getNPC(imageName);
                if (npc != null) {
                    huntingPlace.image = npc.GetImage();
                } else {
                    throw new Exception("Unrecognized npc or creature image.");
                }
            }
            huntingPlace.city = reader["city"].ToString();

            // Hunting place coordinates
            command = new SQLiteCommand(String.Format("SELECT x, y, z FROM HuntingPlaceCoordinates WHERE huntingplaceid={0}", huntingPlace.id), mainForm.conn);
            reader = command.ExecuteReader();
            while (reader.Read()) {
                Coordinate c = new Coordinate();
                c.x = reader.IsDBNull(0) ? DATABASE_NULL : reader.GetInt32(0);
                c.y = reader.IsDBNull(1) ? DATABASE_NULL : reader.GetInt32(1);
                c.z = reader.IsDBNull(2) ? DATABASE_NULL : reader.GetInt32(2);
                huntingPlace.coordinates.Add(c);
            }
            // Hunting place directions
            command = new SQLiteCommand(String.Format("SELECT beginx, beginy, beginz,endx, endy, endz, ordering, description, settings FROM HuntDirections WHERE huntingplaceid={0} ORDER BY ordering", huntingPlace.id), mainForm.conn);
            reader = command.ExecuteReader();
            while (reader.Read()) {
                Directions d = new Directions();
                d.huntingplaceid = huntingPlace.id;
                d.begin = new Coordinate(reader.GetInt32(0), reader.GetInt32(1), reader.GetInt32(2));
                d.end = new Coordinate(reader.GetInt32(3), reader.GetInt32(4), reader.GetInt32(5));
                d.ordering = reader.GetInt32(6);
                d.description = reader["description"].ToString();
                d.settings = reader.GetString(8);
                huntingPlace.directions.Add(d);
            }

            // Hunting place creatures
            command = new SQLiteCommand(String.Format("SELECT creatureid FROM HuntingPlaceCreatures WHERE huntingplaceid={0}", huntingPlace.id), mainForm.conn);
            reader = command.ExecuteReader();
            while (reader.Read()) {
                int creatureid = reader.GetInt32(0);
                huntingPlace.creatures.Add(creatureid);
            }
            // Hunting place requirements
            command = new SQLiteCommand(String.Format("SELECT questid, requirementtext FROM HuntRequirements WHERE huntingplaceid={0}", huntingPlace.id), mainForm.conn);
            reader = command.ExecuteReader();
            while (reader.Read()) {
                Requirements r = new Requirements();
                r.huntingplaceid = huntingPlace.id;
                int questid = reader.IsDBNull(0) ? DATABASE_NULL : reader.GetInt32(0);
                r.quest = questIdMap[questid];
                r.notes = reader["requirementtext"].ToString();
                huntingPlace.requirements.Add(r);
            }
            return huntingPlace;
        }
 /* Returns an Exercise using a SQLiteDataReader and a dictionary mapping the attributes to a index.
  */
 private Date DateExtractor(SQLiteDataReader reader, Dictionary<string, int> attributeIndexDict)
 {
     return new Date(reader.GetInt32(attributeIndexDict["day"]),
             reader.GetInt32(attributeIndexDict["month"]), reader.GetInt32(attributeIndexDict["year"]),
             reader.GetString(attributeIndexDict["workoutName"]), reader.GetInt32(attributeIndexDict["workoutVersion"]),
             reader.GetString(attributeIndexDict["comments"]));
 }
 /* Returns an Exercise using a SQLiteDataReader and a dictionary mapping the attributes to a index.
  */
 private Exercise ExerciseExtractor(SQLiteDataReader reader, Dictionary<string, int> attributeIndexDict)
 {
     return new Exercise(reader.GetString(attributeIndexDict["exerciseName"]),
             reader.GetString(attributeIndexDict["format"]), reader.GetInt32(attributeIndexDict["exerciseVersion"]),
             reader.GetInt32(attributeIndexDict["deleted"]));
 }
        private static NPC createNPC(SQLiteDataReader reader)
        {
            SQLiteCommand command;

            if (!reader.Read()) {
                return null;
            }

            NPC npc = new NPC();
            npc.permanent = true;
            npc.id = reader.GetInt32(0);
            npc.name = reader["name"].ToString();
            npc.city = reader["city"].ToString();
            if (!reader.IsDBNull(3) && !reader.IsDBNull(4) && !reader.IsDBNull(5)) {
                npc.pos.x = reader.GetInt32(3);
                npc.pos.y = reader.GetInt32(4);
                npc.pos.z = reader.GetInt32(5);
            }
            npc.image = Image.FromStream(reader.GetStream(6));
            npc.job = reader.IsDBNull(7) ? "" : reader.GetString(7);
            if (npc.image.RawFormat.Guid == ImageFormat.Gif.Guid) {
                int frames = npc.image.GetFrameCount(FrameDimension.Time);
                if (frames == 1) {
                    Bitmap new_bitmap = new Bitmap(npc.image);
                    new_bitmap.MakeTransparent();
                    npc.image.Dispose();
                    npc.image = new_bitmap;
                }
            }

            // special case for rashid: change location based on day of the week
            if (npc != null && npc.name == "Rashid") {
                command = new SQLiteCommand(String.Format("SELECT city, x, y, z FROM RashidPositions WHERE day='{0}'", DateTime.Now.DayOfWeek.ToString()), mainForm.conn);
                reader = command.ExecuteReader();
                if (reader.Read()) {
                    npc.city = reader["city"].ToString();
                    npc.pos.x = reader.GetInt32(1);
                    npc.pos.y = reader.GetInt32(2);
                    npc.pos.z = reader.GetInt32(3);
                }
            }
            command = new SQLiteCommand(String.Format("SELECT itemid, value FROM SellItems WHERE vendorid={0}", npc.id), mainForm.conn);
            reader = command.ExecuteReader();
            while (reader.Read()) {
                ItemSold sellItem = new ItemSold();
                sellItem.itemid = reader.GetInt32(0);
                sellItem.npcid = npc.id;
                sellItem.price = reader.GetInt32(1);
                npc.sellItems.Add(sellItem);
            }
            command = new SQLiteCommand(String.Format("SELECT itemid, value FROM BuyItems WHERE vendorid={0}", npc.id), mainForm.conn);
            reader = command.ExecuteReader();
            while (reader.Read()) {
                ItemSold buyItem = new ItemSold();
                buyItem.itemid = reader.GetInt32(0);
                buyItem.npcid = npc.id;
                buyItem.price = reader.GetInt32(1);
                npc.buyItems.Add(buyItem);
            }
            command = new SQLiteCommand(String.Format("SELECT spellid,knight,druid,paladin,sorcerer FROM SpellNPCs WHERE npcid={0}", npc.id), mainForm.conn);
            reader = command.ExecuteReader();
            while (reader.Read()) {
                SpellTaught t = new SpellTaught();
                t.npcid = npc.id;
                t.spellid = reader.GetInt32(0);
                t.knight = reader.GetBoolean(1);
                t.druid = reader.GetBoolean(2);
                t.paladin = reader.GetBoolean(3);
                t.sorcerer = reader.GetBoolean(4);
                npc.spellsTaught.Add(t);
            }

            command = new SQLiteCommand(String.Format("SELECT DISTINCT questid FROM QuestNPCs WHERE npcid={0}", npc.id), mainForm.conn);
            reader = command.ExecuteReader();
            while (reader.Read()) {
                Quest q = getQuest(reader.GetInt32(0));
                npc.involvedQuests.Add(q);
            }

            command = new SQLiteCommand(String.Format("SELECT destination,cost,notes FROM NPCDestinations WHERE npcid={0}", npc.id), mainForm.conn);
            reader = command.ExecuteReader();
            while (reader.Read()) {
                Transport t = new Transport();
                t.destination = reader.GetString(0);
                t.cost = reader.GetInt32(1);
                t.notes = reader.GetString(2);
                npc.transportOffered.Add(t);
            }
            return npc;
        }
 /* Returns a Workout using a SQLiteDataReader and a dictionary mapping the attributes to a index.
  */
 private Workout WorkoutExtractor(SQLiteDataReader reader, Dictionary<string, int> attributeIndexDict)
 {
     return new Workout(reader.GetString(attributeIndexDict["workoutName"]),
             reader.GetInt32(attributeIndexDict["workoutVersion"]));
 }
 private Int32 SafeInt32(SQLiteDataReader reader, int idx)
 {
     try
       {
     if (reader.IsDBNull(idx))
       return 0;
     else
       return reader.GetInt32(idx);
       }
       catch (Exception)
       {
     return 0;
       }
 }
        private static Mount createMount(SQLiteDataReader reader)
        {
            if (!reader.Read()) {
                return null;
            }

            Mount mount = new Mount();
            mount.permanent = true;
            mount.id = reader.GetInt32(0);
            mount.title = reader.GetString(1);
            mount.name = reader.GetString(2);

            int tameitem = reader.IsDBNull(3) ? DATABASE_NULL : reader.GetInt32(3);
            if (tameitem > 0) mount.tameitemid = tameitem;
            else mount.tameitemid = -1;
            int tamecreature = reader.IsDBNull(4) ? DATABASE_NULL : reader.GetInt32(4);
            if (tamecreature > 0) mount.tamecreatureid = tamecreature;
            else mount.tamecreatureid = -1;
            mount.speed = reader.GetInt32(5);
            mount.tibiastore = reader.GetBoolean(6);
            mount.image = Image.FromStream(reader.GetStream(7));

            return mount;
        }
Exemple #33
0
 private void ReadAnalogData(SQLiteDataReader r, IDictionary<string, int> field)
 {
   this.FreqInMhz = r.IsDBNull(field["freq"]) ? 0 : (decimal)r.GetInt32(field["freq"]) / 1000;
   this.ChannelOrTransponder = Tools.GetAnalogChannelNumber((int)this.FreqInMhz);
 }
        private static Item createItem(SQLiteDataReader reader)
        {
            SQLiteCommand command;

            if (!reader.Read()) {
                return null;
            }

            Item item = new Item();
            item.permanent = true;
            item.id = reader.GetInt32(0);
            item.displayname = reader.GetString(1);
            item.actual_value = reader.IsDBNull(2) ? DATABASE_NULL : reader.GetInt64(2);
            item.vendor_value = reader.IsDBNull(3) ? DATABASE_NULL : reader.GetInt64(3);
            item.stackable = reader.GetBoolean(4);
            item.capacity = reader.IsDBNull(5) ? DATABASE_NULL : reader.GetFloat(5);
            item.category = reader.IsDBNull(6) ? "Unknown" : reader.GetString(6);
            item.discard = reader.GetBoolean(7);
            item.convert_to_gold = reader.GetBoolean(8);
            item.look_text = reader.IsDBNull(9) ? String.Format("You see a {0}.", item.displayname) : reader.GetString(9);
            item.title = reader.GetString(10);
            item.currency = reader.IsDBNull(11) ? DATABASE_NULL : reader.GetInt32(11);
            item.image = Image.FromStream(reader.GetStream(12));
            if (item.image.RawFormat.Guid == ImageFormat.Gif.Guid) {
                int frames = item.image.GetFrameCount(FrameDimension.Time);
                if (frames == 1) {
                    Bitmap new_bitmap = new Bitmap(item.image);
                    new_bitmap.MakeTransparent();
                    item.image.Dispose();
                    item.image = new_bitmap;
                }
            }

            command = new SQLiteCommand(String.Format("SELECT vendorid, value FROM SellItems WHERE itemid={0}", item.id), mainForm.conn);
            reader = command.ExecuteReader();
            while (reader.Read()) {
                ItemSold sellItem = new ItemSold();
                sellItem.itemid = item.id;
                sellItem.npcid = reader.GetInt32(0);
                sellItem.price = reader.GetInt32(1);
                item.sellItems.Add(sellItem);
            }
            command = new SQLiteCommand(String.Format("SELECT vendorid, value FROM BuyItems WHERE itemid={0}", item.id), mainForm.conn);
            reader = command.ExecuteReader();
            while (reader.Read()) {
                ItemSold buyItem = new ItemSold();
                buyItem.itemid = item.id;
                buyItem.npcid = reader.GetInt32(0);
                buyItem.price = reader.GetInt32(1);
                item.buyItems.Add(buyItem);
            }
            command = new SQLiteCommand(String.Format("SELECT creatureid, percentage, min, max FROM CreatureDrops WHERE itemid={0}", item.id), mainForm.conn);
            reader = command.ExecuteReader();
            while (reader.Read()) {
                ItemDrop itemDrop = new ItemDrop();
                itemDrop.itemid = item.id;
                itemDrop.creatureid = reader.GetInt32(0);
                itemDrop.percentage = reader.IsDBNull(1) ? DATABASE_NULL : reader.GetFloat(1);
                if (itemDrop.percentage > 100) {
                    itemDrop.min = 1;
                    itemDrop.max = (int)(itemDrop.percentage / 100.0 * 2.0);
                    itemDrop.percentage = 100;
                } else {
                    itemDrop.min = Math.Max(reader.GetInt32(2), 1);
                    itemDrop.max = Math.Max(reader.GetInt32(3), itemDrop.min);
                }

                item.itemdrops.Add(itemDrop);
            }
            command = new SQLiteCommand(String.Format("SELECT questid FROM QuestRewards WHERE itemid={0}", item.id), mainForm.conn);
            reader = command.ExecuteReader();
            while (reader.Read()) {
                item.rewardedBy.Add(getQuest(reader.GetInt32(0)));
            }
            command = new SQLiteCommand(String.Format("SELECT property, value FROM ItemProperties WHERE itemid={0}", item.id), mainForm.conn);
            reader = command.ExecuteReader();
            while (reader.Read()) {
                string property = reader.GetString(0);
                switch(property) {
                    case "Voc":
                        item.vocation = reader.GetString(1);
                        break;
                    case "Level":
                        item.level = reader.GetInt32(1);
                        break;
                    case "Def":
                        item.defensestr = reader["value"].ToString();
                        if (!int.TryParse(item.defensestr, out item.defense)) {
                            item.defense = int.Parse(item.defensestr.Split(' ')[0]);
                        }
                        break;
                    case "Attrib":
                        item.attrib = reader.GetString(1);
                        break;
                    case "Atk":
                        item.attack = reader.GetInt32(1);
                        break;
                    case "Atk+":
                        item.atkmod = reader.GetInt32(1);
                        break;
                    case "Hit+":
                        string str = reader["value"].ToString();
                        int.TryParse(str, out item.hitmod);
                        break;
                    case "Arm":
                        item.armor = reader.GetInt32(1);
                        break;
                    case "Range":
                        item.range = reader.GetInt32(1);
                        break;
                    case "Type":
                        item.type = reader.GetString(1);
                        break;
                }
            }

            return item;
        }
Exemple #35
0
 private void ReadAnalogData(SQLiteDataReader r, IDictionary<string, int> field)
 {
   this.Name = r.GetString(field["channel_label"]);
   this.FreqInMhz = (decimal)r.GetInt32(field["frequency"]) / 1000000;
 }