示例#1
0
        internal async Task DeleteObjectByOIDAsync(int oid, SqoTypeInfo tinf)
        {
            ObjectSerializer serializer = SerializerFactory.GetSerializer(this.path, GetFileByType(tinf), useElevatedTrust);

            await this.MarkObjectAsDeleteAsync(serializer, oid, tinf).ConfigureAwait(false);
        }
示例#2
0
        internal async Task <int> SaveObjectAsync(object oi, SqoTypeInfo ti)
        {
            ObjectInfo objInfo = MetaExtractor.GetObjectInfo(oi, ti, metaCache);

            return(await this.SaveObjectAsync(oi, ti, objInfo).ConfigureAwait(false));
        }
示例#3
0
        internal void DeleteObjectByOID(int oid, SqoTypeInfo tinf)
        {
            ObjectSerializer serializer = SerializerFactory.GetSerializer(this.path, GetFileByType(tinf), useElevatedTrust);

            this.MarkObjectAsDelete(serializer, oid, tinf);
        }
示例#4
0
        internal int SaveObject(object oi, SqoTypeInfo ti)
        {
            ObjectInfo objInfo = MetaExtractor.GetObjectInfo(oi, ti, metaCache);

            return(this.SaveObject(oi, ti, objInfo));
        }
示例#5
0
        internal async Task <int> DeleteObjectByAsync(string[] fieldNames, object obj, SqoTypeInfo ti, Transaction transaction)
        {
            ObjectInfo objInfo = MetaExtractor.GetObjectInfo(obj, ti, metaCache);
            int        i       = 0;
            ICriteria  wPrev   = null;

            foreach (string fieldName in fieldNames)
            {
                FieldSqoInfo fi = MetaHelper.FindField(ti.Fields, fieldName);
                if (fi == null)
                {
                    throw new SiaqodbException("Field:" + fieldName + " was not found as member of Type:" + ti.TypeName);
                }

                Where w = new Where(fieldName, OperationType.Equal, objInfo.AtInfo[fi]);
                w.StorageEngine     = this;
                w.ParentSqoTypeInfo = ti;
                w.ParentType.Add(w.ParentSqoTypeInfo.Type);
                if (i > 0)
                {
                    And and = new And();
                    and.Add(w, wPrev);

                    wPrev = and;
                }
                else
                {
                    wPrev = w;
                }
                i++;
            }

            List <int> oids = await wPrev.GetOIDsAsync().ConfigureAwait(false);


            if (oids.Count > 1)
            {
                throw new SiaqodbException("In database exists more than one object with value of fields specified");
            }
            else if (oids.Count == 1)
            {
                objInfo.Oid = oids[0];
                //obj.OID = oids[0];
                metaCache.SetOIDToObject(obj, oids[0], ti);

                ObjectSerializer serializer = SerializerFactory.GetSerializer(this.path, GetFileByType(ti), useElevatedTrust);

                if (transaction == null)
                {
                    await CheckForConcurencyAsync(obj, objInfo, ti, serializer, true).ConfigureAwait(false);

                    await this.MarkObjectAsDeleteAsync(serializer, objInfo.Oid, ti).ConfigureAwait(false);

                    await this.indexManager.UpdateIndexesAfterDeleteAsync(objInfo, ti).ConfigureAwait(false);
                }
                else
                {
                    await this.DeleteObjectAsync(obj, ti, transaction, objInfo).ConfigureAwait(false);
                }

                return(oids[0]);
            }
            else
            {
                return(-1);
            }
        }
示例#6
0
        internal bool UpdateObjectBy(string[] fieldNames, object obj, SqoTypeInfo ti, Transaction transact)
        {
            ObjectInfo objInfo = MetaExtractor.GetObjectInfo(obj, ti, metaCache);
            int        i       = 0;
            ICriteria  wPrev   = null;

            foreach (string fieldName in fieldNames)
            {
                FieldSqoInfo fi = MetaHelper.FindField(ti.Fields, fieldName);
                if (fi == null)
                {
                    throw new SiaqodbException("Field:" + fieldName + " was not found as member of Type:" + ti.TypeName);
                }

                Where w = new Where(fieldName, OperationType.Equal, objInfo.AtInfo[fi]);
                w.StorageEngine     = this;
                w.ParentSqoTypeInfo = ti;
                w.ParentType.Add(w.ParentSqoTypeInfo.Type);

                if (i > 0)
                {
                    And and = new And();
                    and.Add(w, wPrev);

                    wPrev = and;
                }
                else
                {
                    wPrev = w;
                }
                i++;
            }

            List <int> oids = wPrev.GetOIDs();

            if (oids.Count > 1)
            {
                throw new SiaqodbException("In database exists more than one object with value of fields specified");
            }
            else if (oids.Count == 1)
            {
                objInfo.Oid = oids[0];
                #region old code that was duplicated like on SaveObject

                /*//obj.OID = oids[0];
                 * MetaHelper.SetOIDToObject(obj, oids[0], ti.Type);
                 *
                 * lock (_syncRoot)
                 * {
                 *  ObjectSerializer serializer = SerializerFactory.GetSerializer(this.path, GetFileByType(ti), useElevatedTrust);
                 *
                 *  CheckForConcurency(obj, objInfo, ti, serializer,false);
                 *
                 *  CheckConstraints(objInfo, ti);
                 *
                 *  Dictionary<string, object> oldValuesOfIndexedFields = this.PrepareUpdateIndexes(objInfo, ti, serializer);
                 *
                 *  serializer.SerializeObject(objInfo);
                 *
                 *  this.UpdateIndexes(objInfo, ti, oldValuesOfIndexedFields);
                 * }*/
                #endregion

                if (transact == null)
                {
                    this.SaveObject(obj, ti, objInfo);
                }
                else
                {
                    this.SaveObject(obj, ti, objInfo, transact);
                }
                return(true);
            }
            else
            {
                return(false);
            }
        }
示例#7
0
        internal async Task <bool> UpdateObjectByAsync(string[] fieldNames, object obj, SqoTypeInfo ti, Transaction transact)
        {
            ObjectInfo objInfo = MetaExtractor.GetObjectInfo(obj, ti, metaCache);
            int        i       = 0;
            ICriteria  wPrev   = null;

            foreach (string fieldName in fieldNames)
            {
                FieldSqoInfo fi = MetaHelper.FindField(ti.Fields, fieldName);
                if (fi == null)
                {
                    throw new SiaqodbException("Field:" + fieldName + " was not found as member of Type:" + ti.TypeName);
                }

                Where w = new Where(fieldName, OperationType.Equal, objInfo.AtInfo[fi]);
                w.StorageEngine     = this;
                w.ParentSqoTypeInfo = ti;
                w.ParentType.Add(w.ParentSqoTypeInfo.Type);

                if (i > 0)
                {
                    And and = new And();
                    and.Add(w, wPrev);

                    wPrev = and;
                }
                else
                {
                    wPrev = w;
                }
                i++;
            }

            List <int> oids = await wPrev.GetOIDsAsync().ConfigureAwait(false);

            if (oids.Count > 1)
            {
                throw new SiaqodbException("In database exists more than one object with value of fields specified");
            }
            else if (oids.Count == 1)
            {
                objInfo.Oid = oids[0];

                if (transact == null)
                {
                    await this.SaveObjectAsync(obj, ti, objInfo).ConfigureAwait(false);
                }
                else
                {
                    await this.SaveObjectAsync(obj, ti, objInfo, transact).ConfigureAwait(false);
                }
                return(true);
            }
            else
            {
                return(false);
            }
        }
示例#8
0
        internal void AdjustArrayFieldsAfterShrink(SqoTypeInfo ti, FieldSqoInfo fi, int objectOID, int newOID)
        {
            ObjectSerializer serializer = SerializerFactory.GetSerializer(this.path, GetFileByType(ti), useElevatedTrust);

            serializer.SaveArrayOIDFieldContent(ti, fi, objectOID, newOID);
        }
示例#9
0
        internal int InsertObjectByMeta(SqoTypeInfo tinf)
        {
            ObjectSerializer serializer = SerializerFactory.GetSerializer(this.path, GetFileByType(tinf), useElevatedTrust);

            return(serializer.InsertEmptyObject(tinf));
        }
示例#10
0
        internal int SaveObjectBytes(byte[] objBytes, SqoTypeInfo ti)
        {
            ObjectSerializer serializer = SerializerFactory.GetSerializer(this.path, GetFileByType(ti), useElevatedTrust);

            return(serializer.SerializeObjectWithNewOID(objBytes, ti));
        }
示例#11
0
        internal async Task <int> SaveObjectBytesAsync(byte[] objBytes, SqoTypeInfo ti)
        {
            ObjectSerializer serializer = SerializerFactory.GetSerializer(this.path, GetFileByType(ti), useElevatedTrust);

            return(await serializer.SerializeObjectWithNewOIDAsync(objBytes, ti).ConfigureAwait(false));
        }
示例#12
0
        internal void SetFileLength(long newLength, SqoTypeInfo ti)
        {
            ObjectSerializer serializer = SerializerFactory.GetSerializer(this.path, GetFileByType(ti), useElevatedTrust);

            serializer.SetLength(newLength);
        }
示例#13
0
        internal static long GetSeekPosition(SqoTypeInfo ti, int oid)
        {
            long position = (long)ti.Header.headerSize + (long)((long)(oid - 1) * (long)ti.Header.lengthOfRecord);

            return(position);
        }
示例#14
0
 internal QueryTranslator(StorageEngine engine, SqoTypeInfo ti)
 {
     this.engine = engine;
     this.ti     = ti;
 }
示例#15
0
 public void AddTypeInfo(SqoTypeInfo ti)
 {
     dict[ti] = new ConditionalWeakTable();
 }
示例#16
0
 public ComplexTypeTransformer(ObjectSerializer serializer, SqoTypeInfo ti, FieldSqoInfo fi)
 {
     this.serializer = serializer;
     this.fi         = fi;
     this.ti         = ti;
 }