示例#1
0
		public Cursor (ISQLiteStatement statement)
		{
			this.statement = statement;
			currentRow = -1;

			hasRows = statement.Step () == SQLiteResult.ROW;
			statement.Reset ();
		}
示例#2
0
        private static SimpleGeoData CreateSimpleGeo(ISQLiteStatement stmt)
        {
            var basicGeo = new BasicGeoposition();
            basicGeo.Latitude = (double)stmt[2];
            basicGeo.Longitude = (double)stmt[3];
            basicGeo.Altitude = (double)stmt[4];

            var ret = new SimpleGeoData();
            ret.Position = basicGeo;
            ret.DateCreated = DateTimeOffset.Parse((string)stmt[1]);
            return ret;
        }
示例#3
0
        public static object ReadCol(ISQLiteStatement stmt, int index, Type clrType)
        {
            var result = stmt[index];
            if (result == null)
                return null;

            if (clrType == typeof(String))
                return result as string;
            if (clrType == typeof(Int32))
                return Convert.ToInt32(result, CultureInfo.InvariantCulture);
            if (clrType == typeof(Boolean))
                return (Int64)result == 1;
            if (clrType == typeof(Double))
                return Convert.ToDouble(result, CultureInfo.InvariantCulture);
            if (clrType == typeof(Single))
                return Convert.ToSingle(result, CultureInfo.InvariantCulture);
            if (clrType == typeof(DateTime))
                return DateTime.Parse((string)result, CultureInfo.InvariantCulture);
            if (clrType == typeof(DateTimeOffset))
                return DateTime.Parse((string)result, CultureInfo.InvariantCulture);
            if (clrType == typeof(TimeSpan))
                return TimeSpan.FromTicks((Int64)result);
            if (clrType.GetTypeInfo().IsEnum)
                return Convert.ToInt32(result, CultureInfo.InvariantCulture);
            if (clrType == typeof(Int64))
                return (Int64)result;
            if (clrType == typeof(UInt32))
                return Convert.ToUInt32(result, CultureInfo.InvariantCulture);
            if (clrType == typeof(Decimal))
                return Convert.ToDecimal(result, CultureInfo.InvariantCulture);
            if (clrType == typeof(Byte))
                return Convert.ToByte(result, CultureInfo.InvariantCulture);
            if (clrType == typeof(UInt16))
                return Convert.ToUInt16(result, CultureInfo.InvariantCulture);
            if (clrType == typeof(Int16))
                return Convert.ToInt16(result, CultureInfo.InvariantCulture);
            if (clrType == typeof(sbyte))
                return Convert.ToSByte(result, CultureInfo.InvariantCulture);
            if (clrType == typeof(byte[]))
                return (byte[])result;
            if (clrType == typeof(Guid))
                return new Guid((String)result);

            throw new NotSupportedException("Don't know how to read " + clrType);
        }
        public bool Execute(ISQLiteStatement statement)
        {
            if (_isFinished)
            {
                throw new Exception("Cannot execute statement on finished transaction. Start a new transaction.");
            }

            if (_mustRollback)
            {
                throw new Exception("Cannot execute statement on failed transaction. Rollback this transaction and start a new transaction.");
            }

            var result = statement.Step();
            if (!result.IsSuccess())
            {
                System.Diagnostics.Debug.WriteLine("Failed to execute statement.");
                _mustRollback = true;
                return false;
            }

            return true;
        }
示例#5
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="statement"></param>
 /// <param name="item"></param>
 protected abstract void FillInsertStatement(ISQLiteStatement statement, TItemType item);
示例#6
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="statement"></param>
 /// <returns></returns>
 protected abstract TItemType CreateItem(ISQLiteStatement statement);
        private JObject ReadRow(TableDefinition table, ISQLiteStatement statement)
        {
            var row = new JObject();
            for (int i = 0; i < statement.ColumnCount; i++)
            {
                string name = statement.ColumnName(i);
                object value = statement[i];

                ColumnDefinition column;
                if (table.TryGetValue(name, out column))
                {
                    JToken jVal = SqlHelpers.DeserializeValue(value, column.StoreType, column.JsonType);
                    row[name] = jVal;
                }
                else
                {
                    row[name] = value == null ? null : JToken.FromObject(value);
                }
            }
            return row;
        }
示例#8
0
        public static object ReadCol(ISQLiteStatement stmt, int index, Type clrType)
        {
            var result = stmt[index];

            if (result == null)
            {
                return(null);
            }

            if (clrType == typeof(String))
            {
                return(result as string);
            }
            if (clrType == typeof(Int32))
            {
                return(Convert.ToInt32(result, CultureInfo.InvariantCulture));
            }
            if (clrType == typeof(Boolean))
            {
                return((Int64)result == 1);
            }
            if (clrType == typeof(Double))
            {
                return(Convert.ToDouble(result, CultureInfo.InvariantCulture));
            }
            if (clrType == typeof(Single))
            {
                return(Convert.ToSingle(result, CultureInfo.InvariantCulture));
            }
            if (clrType == typeof(DateTime))
            {
                return(DateTime.Parse((string)result, CultureInfo.InvariantCulture));
            }
            if (clrType == typeof(DateTimeOffset))
            {
                return(DateTime.Parse((string)result, CultureInfo.InvariantCulture));
            }
            if (clrType == typeof(TimeSpan))
            {
                return(TimeSpan.FromTicks((Int64)result));
            }
            if (clrType.GetTypeInfo().IsEnum)
            {
                return(Convert.ToInt32(result, CultureInfo.InvariantCulture));
            }
            if (clrType == typeof(Int64))
            {
                return((Int64)result);
            }
            if (clrType == typeof(UInt32))
            {
                return(Convert.ToUInt32(result, CultureInfo.InvariantCulture));
            }
            if (clrType == typeof(Decimal))
            {
                return(Convert.ToDecimal(result, CultureInfo.InvariantCulture));
            }
            if (clrType == typeof(Byte))
            {
                return(Convert.ToByte(result, CultureInfo.InvariantCulture));
            }
            if (clrType == typeof(UInt16))
            {
                return(Convert.ToUInt16(result, CultureInfo.InvariantCulture));
            }
            if (clrType == typeof(Int16))
            {
                return(Convert.ToInt16(result, CultureInfo.InvariantCulture));
            }
            if (clrType == typeof(sbyte))
            {
                return(Convert.ToSByte(result, CultureInfo.InvariantCulture));
            }
            if (clrType == typeof(byte[]))
            {
                return((byte[])result);
            }
            if (clrType == typeof(Guid))
            {
                return(new Guid((String)result));
            }

            throw new NotSupportedException("Don't know how to read " + clrType);
        }
示例#9
0
 private static void Mapping(ISQLiteStatement statement, Category e)
 {
     e.id   = (long)statement["id"];
     e.name = (string)statement["name"];
 }
 protected abstract TItem CreateInstance(ISQLiteStatement query);
示例#11
0
 protected override void FillDeleteItemStatement(ISQLiteStatement statement, Int64 key)
 {
     statement.Bind("@" + PrimaryKeyName, key);
 }
 protected override void BindSelectItemQuery(ISQLiteStatement query, string itemId)
 {
     query.Bind(1, itemId);
 }
 private static Record SqliteStmtToRecord(ISQLiteStatement stmt)
 {
     return new Record(stmt.GetText(RecordColumns.KEY),
                        stmt.GetText(RecordColumns.VALUE),
                        stmt.GetInteger(RecordColumns.SYNC_COUNT),
                        new DateTime(long.Parse(stmt.GetText(RecordColumns.LAST_MODIFIED_TIMESTAMP))),
                        stmt.DataType(RecordColumns.LAST_MODIFIED_BY) == SQLiteType.NULL ? string.Empty : stmt.GetText(RecordColumns.LAST_MODIFIED_BY),
                        new DateTime(long.Parse(stmt.GetText(RecordColumns.DEVICE_LAST_MODIFIED_TIMESTAMP))),
                        stmt.GetInteger(RecordColumns.MODIFIED) == 1);
 }
 private static DatasetMetadata SqliteStmtToDatasetMetadata(ISQLiteStatement stmt)
 {
     return new DatasetMetadata(
         stmt.DataType(RecordColumns.DATASET_NAME) == SQLiteType.NULL ?string.Empty:stmt.GetText(DatasetColumns.DATASET_NAME),
         new DateTime(long.Parse(stmt.GetText(DatasetColumns.CREATION_TIMESTAMP))),
         new DateTime(long.Parse(stmt.GetText(DatasetColumns.LAST_MODIFIED_TIMESTAMP))),
         stmt.DataType(DatasetColumns.LAST_MODIFIED_BY) == SQLiteType.NULL ? string.Empty : stmt.GetText(DatasetColumns.LAST_MODIFIED_BY),
         stmt.GetInteger(DatasetColumns.STORAGE_SIZE_BYTES),
         stmt.GetInteger(DatasetColumns.RECORD_COUNT)
     );
 }
示例#15
0
 /// <summary>
 /// Wypełnienie zapytania odającefo nowy produkt do bazy
 /// </summary>
 /// <param name="statement"></param>
 /// <param name="item"></param>
 protected override void FillInsertStatement(ISQLiteStatement statement, Device item)
 {
     statement.Bind("@name", item.Name);
     statement.Bind("@manufacturer", item.Manufacturer);
     statement.Bind("@others", item.Others);
 }
示例#16
0
 private Planeta getPlanetaWithStatement(ISQLiteStatement statement)
 {
     Planeta planeta = new Planeta();
     planeta.Id = (long)statement[0];
     planeta.Nombre = (string)statement[1];
     planeta.Gravity = (float)statement[2];
     return planeta;
 }
        /// <summary>
        ///     Helper to retrieve data.
        /// </summary>
        /// <param name="statement"></param>
        /// <param name="position"></param>
        /// <returns></returns>
        private object GetObject(ISQLiteStatement statement, int position)
        {
            try
            {
                return statement.GetText(position);
            }
            catch (Exception) { }

            try
            {
                return statement.GetInteger(position);
            }
            catch (Exception) { }

            try
            {
                return statement.GetFloat(position);
            }
            catch (Exception) { }

            return null;
        }
示例#18
0
 private static void Mapping(ISQLiteStatement statement, Account e)
 {
     e.id      = (long)statement["id"];
     e.name    = (string)statement["name"];
     e.balance = (double)statement["balance"];
 }
        /// <summary>
        ///     Re-index all soup elements for passed indexPaths
        /// </summary>
        /// <param name="soupName"></param>
        /// <param name="indexPaths"></param>
        /// <param name="handleTx"></param>
        public void ReIndexSoup(string soupName, string[] indexPaths, bool handleTx)
        {
            lock (smartlock)
            {
                DBHelper db            = DBHelper.GetInstance(DatabasePath);
                string   soupTableName = db.GetSoupTableName(soupName);
                if (String.IsNullOrWhiteSpace(soupTableName))
                {
                    throw new SmartStoreException("Soup: " + soupName + " does not exist");
                }
                Dictionary <string, IndexSpec> mapAllSpecs = IndexSpec.MapForIndexSpecs(GetSoupIndexSpecs(soupName));
                IndexSpec[] indexSpecs =
                    (from indexPath in indexPaths where mapAllSpecs.ContainsKey(indexPath) select mapAllSpecs[indexPath])
                    .ToArray();
                if (indexSpecs.Length == 0)
                {
                    return; // nothing to do
                }
                if (handleTx)
                {
                    db.BeginTransaction();
                }

                using (
                    ISQLiteStatement stmt = db.Query(soupTableName, new[] { IdCol, SoupCol }, String.Empty, String.Empty,
                                                     String.Empty))
                {
                    if (stmt.DataCount > 0)
                    {
                        try
                        {
                            do
                            {
                                string soupEntryId = stmt.GetText(0);
                                string soupRaw     = stmt.GetText(1);

                                try
                                {
                                    JObject soupElt       = JObject.Parse(soupRaw);
                                    var     contentValues = new Dictionary <string, object>();
                                    foreach (IndexSpec indexSpec in indexSpecs)
                                    {
                                        ProjectIndexedPaths(soupElt, contentValues, indexSpec);
                                    }
                                    db.Update(soupTableName, contentValues, IdPredicate, soupEntryId + String.Empty);
                                }
                                catch (JsonException e)
                                {
                                    Debug.WriteLine("SmartStore.ReIndexSoup: Could not parse soup element " +
                                                    soupEntryId +
                                                    "\n" + e.Message);
                                }
                            } while (stmt.Step() == SQLiteResult.ROW);
                        }
                        finally
                        {
                            if (handleTx)
                            {
                                db.CommitTransaction();
                            }
                        }
                    }
                }
            }
        }
示例#20
0
 protected override void BindSelectByPathQuery(ISQLiteStatement query, string path, long folderId)
 {
     throw new NotImplementedException();
 }
 public static T GetValue <T>(this ISQLiteStatement statement, int index)
 {
     return(GetValue <T>(statement[index]));
 }
示例#22
0
 protected override void BindSelectItemQuery(ISQLiteStatement query, string itemId)
 {
     throw new NotImplementedException();
 }
示例#23
0
 protected override void FillInsertStatement(ISQLiteStatement statement, TodoList item)
 {
     // NOTE that named parameters have a leading "@",":" or "$".
     statement.Bind("@id", item.Id);
     statement.Bind("@title", item.Title);
 }
示例#24
0
 /// <summary>
 /// Adds the parameter to the query
 /// </summary>
 /// <param name="query"></param>
 protected abstract void BindSelectAllQuery(ISQLiteStatement query);
示例#25
0
 protected override void BindSelectItemQuery(ISQLiteStatement query, long key)
 {
     query.Bind(1, key);
 }
示例#26
0
 protected override void FillSelectAllStatement(ISQLiteStatement statement)
 {
     // Nothing to do
 }
 public SQLiteResult Execute(string sql, out ISQLiteStatement statement)
 {
     statement = _sqlConnection.Prepare(sql);
     if (statement != null)
     {
         return statement.Step();
     }
     return SQLiteResult.ERROR;
 }
示例#28
0
        internal static void BindParameter(ISQLiteStatement stmt, int index, object value)
        {
            if (value == null)
            {
                stmt.Bind(index, null);
            }
            else if (value is Int32)
            {
                stmt.Bind(index, (int)value);
            }
            else if (value is String)
            {
                stmt.Bind(index, (string)value);
            }
            else if (value is Byte || value is UInt16 || value is SByte || value is Int16)
            {
                stmt.Bind(index, Convert.ToInt32(value, CultureInfo.InvariantCulture));
            }
            else if (value is Boolean)
            {
                stmt.Bind(index, (bool)value ? 1 : 0);
            }
            else if (value is UInt32 || value is Int64)
            {
                stmt.Bind(index, Convert.ToInt64(value, CultureInfo.InvariantCulture));
            }
            else if (value is Single || value is Double || value is Decimal)
            {
                stmt.Bind(index, Convert.ToDouble(value, CultureInfo.InvariantCulture));
            }
            else if (value is DateTimeOffset)
            {
                stmt.Bind(index, ((DateTimeOffset)value).ToString("yyyy-MM-dd HH:mm:ss"));
            }
            else if (value is TimeSpan)
            {
                stmt.Bind(index, ((TimeSpan)value).Ticks);
            }
            else if (value is DateTime)
            {
                stmt.Bind(index, ((DateTime)value).ToString("yyyy-MM-dd HH:mm:ss"));
#if !NETFX_CORE
            }
            else if (value.GetType().IsEnum)
            {
#else
            }
            else if (value.GetType().GetTypeInfo().IsEnum)
            {
#endif
                stmt.Bind(index, Convert.ToInt32(value, CultureInfo.InvariantCulture));
            }
            else if (value is byte[])
            {
                var vByte = (byte[])value;
                //var iBuffer = vByte.AsBuffer();

                stmt.Bind(index, vByte);
            }
            else if (value is Guid)
            {
                stmt.Bind(index, ((Guid)value).ToString());
            }
            else
            {
                throw new NotSupportedException("Cannot store type: " + value.GetType());
            }
        }
示例#29
0
        internal static void BindParameter(ISQLiteStatement stmt, int index, object value)
        {
            if (value == null)
            {
                stmt.Bind(index, null);
            }
            else if (value is Int32)
            {
                stmt.Bind(index, (int)value);
            }
            else if (value is String)
            {
                stmt.Bind(index, (string)value);
            }
            else if (value is Byte || value is UInt16 || value is SByte || value is Int16)
            {
                stmt.Bind(index, Convert.ToInt32(value, CultureInfo.InvariantCulture));
            }
            else if (value is Boolean)
            {
                stmt.Bind(index, (bool)value ? 1 : 0);
            }
            else if (value is UInt32 || value is Int64)
            {
                stmt.Bind(index, Convert.ToInt64(value, CultureInfo.InvariantCulture));
            }
            else if (value is Single || value is Double || value is Decimal)
            {
                stmt.Bind(index, Convert.ToDouble(value, CultureInfo.InvariantCulture));
            }
            else if (value is DateTimeOffset)
            {
                stmt.Bind(index, ((DateTimeOffset)value).ToString("yyyy-MM-dd HH:mm:ss"));
            }
            else if (value is TimeSpan)
            {
                stmt.Bind(index, ((TimeSpan)value).Ticks);
            }
            else if (value is DateTime)
            {
                stmt.Bind(index, ((DateTime)value).ToString("yyyy-MM-dd HH:mm:ss"));
#if !NETFX_CORE
            }
            else if (value.GetType().IsEnum)
            {
#else
            }
            else if (value.GetType().GetTypeInfo().IsEnum)
            {
#endif
                stmt.Bind(index, Convert.ToInt32(value, CultureInfo.InvariantCulture));
            }
            else if (value is byte[])
            {
                var vByte = (byte[])value;
                //var iBuffer = vByte.AsBuffer();

                stmt.Bind(index, vByte);
            }
            else if (value is Guid)
            {
                stmt.Bind(index, ((Guid)value).ToString());
            }
            else
            {
                throw new NotSupportedException("Cannot store type: " + value.GetType());
            }
        }
示例#30
0
        public KartaPostaci GetKarta(int id)
        {
            KartaPostaci KP = new KartaPostaci();

            String sqlQuery = @"SELECT * FROM " + TABLE_KARTY_POSTACI + " WHERE id=" + id;

            SQLiteConnection dbConnect = new SQLiteConnection("Karty.db");

            ISQLiteStatement cursor = dbConnect.Prepare(sqlQuery);

            while (cursor.Step() == SQLiteResult.ROW)
            {
                string test = ". " + (cursor[columns[0]]).ToString();

                KP.setId(Int32.Parse(cursor[columns[0]].ToString()));
                // Log.i("testy","Ilosc "+cursor.getCount());
                // Log.i("testy", cursor.getString(1)+"");
                // Show(getHowManyInBase().ToString());

                KP.setImie(cursor[columns[1]] as string);
                KP.setWiek(cursor[columns[2]] as string);
                KP.setGracz(cursor[columns[3]] as string);
                KP.setKoncept(cursor[columns[4]] as string);
                KP.setCnota(cursor[columns[5]] as string);
                KP.setSkaza(cursor[columns[6]] as string);
                KP.setKronika(cursor[columns[7]] as string);
                KP.setFrakcja(cursor[columns[8]] as string);
                KP.setNazwaGrupy(cursor[columns[9]] as string);

                KP.setInteligencja(Int32.Parse(cursor[columns[10]].ToString()));
                KP.setCzujnosc(Int32.Parse(cursor[columns[11]].ToString()));
                KP.setDeterminacja(Int32.Parse(cursor[columns[12]].ToString()));
                KP.setSila(Int32.Parse(cursor[columns[13]].ToString()));
                KP.setZrecznosc(Int32.Parse(cursor[columns[14]].ToString()));
                KP.setWytrzymalosc(Int32.Parse(cursor[columns[15]].ToString()));
                KP.setPreswazja(Int32.Parse(cursor[columns[16]].ToString()));
                KP.setManipulacja(Int32.Parse(cursor[columns[17]].ToString()));
                KP.setOpanowanie(Int32.Parse(cursor[columns[18]].ToString()));

                KP.setDedukcja(Int32.Parse(cursor[columns[19]].ToString()));
                KP.setInformatyka(Int32.Parse(cursor[columns[20]].ToString()));
                KP.setMedycyna(Int32.Parse(cursor[columns[21]].ToString()));
                KP.setNauka(Int32.Parse(cursor[columns[22]].ToString()));
                KP.setOkultyzm(Int32.Parse(cursor[columns[23]].ToString()));
                KP.setPolityka(Int32.Parse(cursor[columns[24]].ToString()));
                KP.setRzemioslo(Int32.Parse(cursor[columns[25]].ToString()));
                KP.setWyksztalcenie(Int32.Parse(cursor[columns[26]].ToString()));

                KP.setBijatyka(Int32.Parse(cursor[columns[27]].ToString()));
                KP.setBronBiala(Int32.Parse(cursor[columns[28]].ToString()));
                KP.setBronPalna(Int32.Parse(cursor[columns[29]].ToString()));
                KP.setProwadzenie(Int32.Parse(cursor[columns[30]].ToString()));
                KP.setPrzetrwanie(Int32.Parse(cursor[columns[31]].ToString()));
                KP.setSkradanie(Int32.Parse(cursor[columns[32]].ToString()));
                KP.setWysportowanie(Int32.Parse(cursor[columns[33]].ToString()));
                KP.setZlodziejstwo(Int32.Parse(cursor[columns[34]].ToString()));

                KP.setEkspresja(Int32.Parse(cursor[columns[35]].ToString()));
                KP.setEmpatia(Int32.Parse(cursor[columns[36]].ToString()));
                KP.setObycie(Int32.Parse(cursor[columns[37]].ToString()));
                KP.setOszustwo(Int32.Parse(cursor[columns[38]].ToString()));
                KP.setPreswazja(Int32.Parse(cursor[columns[39]].ToString()));
                KP.setPolswiate(Int32.Parse(cursor[columns[40]].ToString()));
                KP.setZatraszanie(Int32.Parse(cursor[columns[41]].ToString()));
                KP.setZwierzeta(Int32.Parse(cursor[columns[42]].ToString()));

                KP.setAt1Nazwa(cursor[columns[43]] as string);
                KP.setAt2Nazwa(cursor[columns[44]] as string);
                KP.setAt3Nazwa(cursor[columns[45]] as string);
                KP.setAt4Nazwa(cursor[columns[46]] as string);
                KP.setAt5Nazwa(cursor[columns[47]] as string);
                KP.setAt6Nazwa(cursor[columns[48]] as string);
                KP.setAt7Nazwa(cursor[columns[49]] as string);
                KP.setAt8Nazwa(cursor[columns[50]] as string);
                KP.setAt9Nazwa(cursor[columns[51]] as string);

                KP.setAt1Wartosc(Int32.Parse(cursor[columns[52]].ToString()));
                KP.setAt2Wartosc(Int32.Parse(cursor[columns[53]].ToString()));
                KP.setAt3Wartosc(Int32.Parse(cursor[columns[54]].ToString()));
                KP.setAt4Wartosc(Int32.Parse(cursor[columns[55]].ToString()));
                KP.setAt5Wartosc(Int32.Parse(cursor[columns[56]].ToString()));
                KP.setAt6Wartosc(Int32.Parse(cursor[columns[57]].ToString()));
                KP.setAt7Wartosc(Int32.Parse(cursor[columns[58]].ToString()));
                KP.setAt8Wartosc(Int32.Parse(cursor[columns[59]].ToString()));
                KP.setAt9Wartosc(Int32.Parse(cursor[columns[60]].ToString()));


                KP.setWada1Nazwa(cursor[columns[61]] as string);
                KP.setWada2Nazwa(cursor[columns[62]] as string);
                KP.setWada3Nazwa(cursor[columns[63]] as string);
                KP.setWada4Nazwa(cursor[columns[64]] as string);
                KP.setWada1Wartosc(Int32.Parse(cursor[columns[65]].ToString()));
                KP.setWada2Wartosc(Int32.Parse(cursor[columns[66]].ToString()));
                KP.setWada3Wartosc(Int32.Parse(cursor[columns[67]].ToString()));
                KP.setWada4Wartosc(Int32.Parse(cursor[columns[68]].ToString()));

                KP.setRozmiar(cursor[columns[69]] as string);
                KP.setSzybkosc(cursor[columns[70]] as string);
                KP.setInicjatywa(cursor[columns[71]] as string);
                KP.setObrona(cursor[columns[72]] as string);
                KP.setPancerz(cursor[columns[73]] as string);
                KP.setZdrowieMax(Int32.Parse(cursor[columns[74]].ToString()));
                KP.setSilaWoliMax(Int32.Parse(cursor[columns[75]].ToString()));
                KP.setZdrowie(Int32.Parse(cursor[columns[76]].ToString()));
                KP.setSilaWoli(Int32.Parse(cursor[columns[77]].ToString()));
                KP.setDoswiadczenie(Int32.Parse(cursor[columns[78]].ToString()));
                KP.setMoralnosc(Int32.Parse(cursor[columns[79]].ToString()));
                KP.setBron1Nazwa(cursor[columns[80]] as string);
                KP.setBron2Nazwa(cursor[columns[81]] as string);
                KP.setBron3Nazwa(cursor[columns[82]] as string);
                KP.setBron1Mod(Int32.Parse(cursor[columns[83]].ToString()));
                KP.setBron2Mod(Int32.Parse(cursor[columns[84]].ToString()));
                KP.setBron3Mod(Int32.Parse(cursor[columns[85]].ToString()));
                KP.setWyp1Nazwa(cursor[columns[86]] as string);
                KP.setWyp2Nazwa(cursor[columns[87]] as string);
                KP.setWyp3Nazwa(cursor[columns[88]] as string);
                KP.setWyp1Mod(Int32.Parse(cursor[columns[89]].ToString()));
                KP.setWyp2Mod(Int32.Parse(cursor[columns[90]].ToString()));


                KP.setWyp3Mod(Int32.Parse(cursor[columns[91]].ToString()));
            }

            return(KP);
        }
示例#31
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="statement"></param>
 protected abstract void FillSelectAllStatement(ISQLiteStatement statement);
 public static void ResetAndClearBindings(this ISQLiteStatement statement)
 {
     statement.Reset();
     statement.ClearBindings();
 }
示例#33
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="statement"></param>
 /// <param name="key"></param>
 protected abstract void FillDeleteItemStatement(ISQLiteStatement statement, TKeyType key);
示例#34
0
 protected override void FillSelectItemStatement(ISQLiteStatement statement, string key)
 {
     statement.Bind(1, key);
 }
示例#35
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="statement"></param>
 /// <param name="key"></param>
 /// <param name="item"></param>
 protected abstract void FillUpdateStatement(ISQLiteStatement statement, TKeyType key, TItemType item);
示例#36
0
 protected override void FillUpdateStatement(ISQLiteStatement statement, string key, TodoItem item)
 {
     FillInsertStatement(statement, item);
     statement.Bind(8, key);
 }
 /// <summary>
 ///     Return JSONArray for one row of data from the statement
 /// </summary>
 /// <param name="statement"></param>
 /// <returns></returns>
 private JArray GetDataFromRow(ISQLiteStatement statement)
 {
     var row = new JArray();
     int columnCount = statement.ColumnCount;
     for (int i = 0; i < columnCount; i++)
     {
         if (statement.ColumnName(i).EndsWith(SoupCol))
         {
             string raw = statement.GetText(i);
             row.Add(JObject.Parse(raw));
         }
         else
         {
             object raw = GetObject(statement, i);
             if (raw != null)
             {
                 long value;
                 if (long.TryParse(raw.ToString(), out value))
                 {
                     row.Add(new JValue(value));
                 }
                 else
                 {
                     double dvalue;
                     if (double.TryParse(raw.ToString(), out dvalue))
                     {
                         row.Add(new JValue(dvalue));
                     }
                     else
                     {
                         row.Add(raw.ToString());
                     }
                 }
             }
         }
     }
     return row;
 }
示例#38
0
 protected override void FillUpdateStatement(ISQLiteStatement statement, long key, Project item)
 {
     FillInsertStatement(statement, item);
     statement.Bind(5, key);
 }
        protected override void OnNavigatedTo(NavigationEventArgs ne)
        {
            id = ne.Parameter.ToString();

            string CategoryName = @"SELECT * FROM categories WHERE id=" + id;

            var title = objConn.Prepare(CategoryName);
            title.Step();
            CBTitle.Text = title[1] + " - Quiz {}";

            string QuestionPhrase = @"SELECT * FROM questions WHERE categoryid=" + id;
            question = objConn.Prepare(QuestionPhrase);

            while (question.Step() == SQLiteResult.ROW)
            {
                questiontotal++;
            }

            question.Reset();

            ChangeQuestion();
        }
示例#40
0
 protected override void FillDeleteItemStatement(ISQLiteStatement statement, long key)
 {
     statement.Bind(1, key);
 }
示例#41
0
        protected override void FillUpdateItemStatement(ISQLiteStatement statement, Int64 key, ItemRow itemRow)
        {
            statement.Bind("@" + PrimaryKeyName, itemRow.Field <Int64>(PrimaryKeyName));

            FillInsertItemStatement(statement, itemRow);
        }
        private static void BindData(ISQLiteStatement statement, params object[] parameters)
        {
            if (parameters != null)
            {
                for (int i = 1; i <= parameters.Length; i++)
                {
                    object o = parameters[i - 1];

                    var dt = o as DateTime?;
                    if (dt.HasValue)
                    {
                        string ticks = dt.Value.Ticks.ToString();
                        statement.Bind(i, ticks);
                    }
                    else
                    {
                        statement.Bind(i, o);
                    }
                }
            }
        }
 public static T GetValue <T>(this ISQLiteStatement statement, string key)
 {
     return(GetValue <T>(statement[key]));
 }
示例#44
0
 protected override void BindSelectAllQuery(ISQLiteStatement query)
 {
     //nothing to do
 }
        /// <summary>
        /// Hilfsmethode, die aus einem durch eine Query zurückgelieferten Statement ein Objekt des Typs Kanal extrahiert.
        /// Je nach Typ des Kanals werden zusätzliche Informationen aus Subklassen-Tabellen abgefragt und ein Objekt
        /// der Subklasse extrahiert.
        /// </summary>
        /// <param name="conn">Eine aktive Connection zur Datenbank, um Informationen aus Subklassen-Tabellen abfragen zu können.</param>
        /// <param name="stmt">Das Statement, aus dem die Informationen extrahiert werden sollen.</param>
        /// <returns>Ein Objekt vom Typ Channel.</returns>
        private Channel retrieveChannelObjectFromStatement(SQLiteConnection conn, ISQLiteStatement stmt)
        {
            // Channel Objekt.
            Channel channel = null;

            try
            {
                // Initialisierung der Variablen.
                int id;
                string name, description, term, location, dates, contact, website, startDate, endDate, lecturer,
                    assistant, cost, organizer, participants;
                bool deleted;
                ChannelType type;
                Faculty faculty;
                NotificationSetting announcementNotificationSetting;
                DateTimeOffset creationDate, modificationDate;

                // Frage Kanal-Werte ab.
                id = Convert.ToInt32(stmt["Id"]);
                name = (string)stmt["Name"];
                description = (string)stmt["Description"];
                type = (ChannelType)Enum.ToObject(typeof(ChannelType), stmt["Type"]);
                creationDate = DatabaseManager.DateTimeFromSQLite(stmt["CreationDate"].ToString());
                modificationDate = DatabaseManager.DateTimeFromSQLite(stmt["ModificationDate"].ToString());
                term = (string)stmt["Term"];
                location = (string)stmt["Location"];
                dates = (string)stmt["Dates"];
                contact = (string)stmt["Contact"];
                website = (string)stmt["Website"];
                deleted = ((long)stmt["Deleted"] == 1) ? true : false;
                announcementNotificationSetting = (NotificationSetting)Enum.ToObject(typeof(NotificationSetting), stmt["NotificationSettings_NotifierId"]);

                // Falls notwendig, hole Daten aus Tabelle der Subklasse.
                switch (type)
                {
                    case ChannelType.LECTURE:
                        using (var getLectureStmt = conn.Prepare("SELECT * FROM Lecture WHERE Channel_Id=?;"))
                        {
                            getLectureStmt.Bind(1, id);

                            // Hole Ergebnis der Query.
                            if (getLectureStmt.Step() == SQLiteResult.ROW)
                            {
                                faculty = (Faculty)Enum.ToObject(typeof(Faculty), getLectureStmt["Faculty"]);
                                startDate = (string)getLectureStmt["StartDate"];
                                endDate = (string)getLectureStmt["EndDate"];
                                lecturer = (string)getLectureStmt["Lecturer"];
                                assistant = (string)getLectureStmt["Assistant"];

                                // Erstelle Lecture Objekt und füge es der Liste hinzu.
                                Lecture lecture = new Lecture(id, name, description, type, creationDate, modificationDate, term, location,
                                    dates, contact, website, deleted, faculty, startDate, endDate, lecturer, assistant);
                                channel = lecture;
                            }
                        }
                        break;
                    case ChannelType.EVENT:
                        using (var getEventStmt = conn.Prepare("SELECT * FROM Event WHERE Channel_Id=?;"))
                        {
                            getEventStmt.Bind(1, id);

                            // Hole Ergebnis der Query.
                            if (getEventStmt.Step() == SQLiteResult.ROW)
                            {
                                cost = (string)getEventStmt["Cost"];
                                organizer = (string)getEventStmt["Organizer"];

                                // Erstelle Event Objekt und füge es der Liste hinzu.
                                Event eventObj = new Event(id, name, description, type, creationDate, modificationDate, term, location,
                                    dates, contact, website, deleted, cost, organizer);
                                channel = eventObj;
                            }
                        }
                        break;
                    case ChannelType.SPORTS:
                        using (var getSportsStmt = conn.Prepare("SELECT * FROM Sports WHERE Channel_Id=?;"))
                        {
                            getSportsStmt.Bind(1, id);

                            // Hole Ergebnis der Query.
                            if (getSportsStmt.Step() == SQLiteResult.ROW)
                            {
                                cost = (string)getSportsStmt["Cost"];
                                participants = (string)getSportsStmt["NumberOfParticipants"];

                                // Erstelle Sports Objekt und füge es der Liste hinzu.
                                Sports sportsObj = new Sports(id, name, description, type, creationDate, modificationDate, term, location,
                                    dates, contact, website, deleted, cost, participants);
                                channel = sportsObj;
                            }
                        }
                        break;
                    default:
                        // Keine Subklasse, also erzeuge Kanal Objekt.
                        channel = new Channel(id, name, description, type, creationDate, modificationDate, term, location,
                            dates, contact, website, deleted);
                        break;
                }

                // Füge announcementNotificationSetting Einstellung noch dem Objekt hinzu.
                channel.AnnouncementNotificationSetting = announcementNotificationSetting;
            }
            catch(SQLiteException sqlEx){
                Debug.WriteLine("SQLiteException has occurred in retrieveChannelObjectFromStatement. The message is: {0}.", sqlEx.Message);
                throw new DatabaseException("Retrieve channel has failed.");
            }
            catch(Exception ex)
            {
                Debug.WriteLine("Exception has occurred in retrieveChannelObjectFromStatement. The message is: {0}, " +
                    "and the stack trace: {1}.", ex.Message, ex.StackTrace);
                throw new DatabaseException("Retrieve channel has failed.");
            }
            
            return channel;
        }
示例#46
0
        private Factura getFacturaWithStatement(ISQLiteStatement statement)
        {
            Factura factura = new Factura();
            factura.Id = (long)statement[0];
            factura.Nombre = (string)statement[1];

            factura.Vence = FormatDateTime(statement[2]);

            factura.Alarma = FormatDateTime(statement[3]);

            factura.Valor = (long)statement[4];
            factura.Estado = (string)statement[5];
            return factura;
        }