private IDictionary GetModifiedObjectsLogJson(InDbDatabase dbForOriginalValues)
        {
            ListDictionary listDictionary = new ListDictionary();

            foreach (ModifiedObjectInfo modifiedObjectInfo in this.Modified)
            {
                listDictionary.Add((object)modifiedObjectInfo.Id, (object)modifiedObjectInfo.ToLogJson(dbForOriginalValues));
            }
            return((IDictionary)listDictionary);
        }
예제 #2
0
        internal override void Load(InDbDatabase db, DataObjectList dstObjs)
        {
            int count = this.FIds.Count;

            if (count == 0)
            {
                return;
            }
            DataId[] dataIdArray = new DataId[count];
            this.FIds.Keys.CopyTo((Array)dataIdArray, 0);
            this.FIds.Clear();
            StringBuilder stringBuilder = new StringBuilder(this.SelectSql);

            stringBuilder.Append(" WHERE [").Append(this.InProperty.DataField).Append("] IN ('");
            int length = stringBuilder.Length;
            int index1 = 0;

            while (index1 < count)
            {
                stringBuilder.Length = length;
                for (int index2 = 0; index1 < count && index2 < 100; ++index2)
                {
                    if (index2 > 0)
                    {
                        stringBuilder.Append("','");
                    }
                    stringBuilder.Append(dataIdArray[index1].ToString());
                    ++index1;
                }
                stringBuilder.Append("')");
                InDbCommand command = db.CreateCommand(stringBuilder.ToString());
                IDataReader reader  = command.ExecuteReader();
                try
                {
                    this.Load(reader, dstObjs, (LoadContext)0);
                }
                finally
                {
                    reader.Dispose();
                    command.Dispose();
                }
            }
            if (!this.InProperty.IsId)
            {
                return;
            }
            for (int index2 = 0; index2 < count; ++index2)
            {
                DataId id = dataIdArray[index2];
                if (!this.LoadedObjects.ContainsKey((object)id))
                {
                    this.FStorage.EnsureCacheItem(id).SetSessionState(ObjectSessionState.Error);
                }
            }
        }
        private object GetDeletedObjectsLogJson(InDbDatabase dbForOriginalValues)
        {
            if (dbForOriginalValues == null)
            {
                return((object)this.Deleted);
            }
            ListDictionary listDictionary = new ListDictionary();

            foreach (string deletedId in this.Deleted)
            {
                listDictionary.Add((object)deletedId, (object)this.GetOriginalValues(deletedId, dbForOriginalValues));
            }
            return((object)listDictionary);
        }
        internal IDictionary ToLogJson(InDbDatabase dbForOriginalValues)
        {
            ListDictionary listDictionary = new ListDictionary();

            if (this.New != null && this.New.Length > 0)
            {
                listDictionary.Add((object)"New", (object)this.GetNewObjectsLogJson());
            }
            if (this.Modified != null && this.Modified.Length > 0)
            {
                listDictionary.Add((object)"Modified", (object)this.GetModifiedObjectsLogJson(dbForOriginalValues));
            }
            if (this.Deleted != null && this.Deleted.Length > 0)
            {
                listDictionary.Add((object)"Deleted", this.GetDeletedObjectsLogJson(dbForOriginalValues));
            }
            return((IDictionary)listDictionary);
        }
        private ListDictionary GetOriginalValues(
            string deletedId,
            InDbDatabase dbForOriginalValues)
        {
            ListDictionary properties = new ListDictionary();
            string         sql        = string.Format("SELECT * FROM [{0}] WHERE [{1}]=?", (object)this.Class.DataTable, (object)this.Class.IDProperty.DataField);

            using (InDbCommand command = dbForOriginalValues.CreateCommand(sql, DataType.String))
            {
                using (IDataReader originalValuesReader = command.ExecuteReader((object)deletedId))
                {
                    if (originalValuesReader.Read())
                    {
                        this.AddOriginalValues(properties, originalValuesReader);
                    }
                }
            }
            return(properties);
        }
예제 #6
0
        internal override void Load(InDbDatabase db, DataObjectList dstObjs)
        {
            StringBuilder sql     = new StringBuilder();
            bool          onePass = true;

            if (this.Condition.Length == 0)
            {
                sql.Append(this.SelectSql);
            }
            else
            {
                this.GenerateLoadSql(sql, ref onePass);
            }
            if (onePass || this.ObjectLoader.Count == 0)
            {
                using (InDbCommand command = db.CreateCommand(sql.ToString(), this.FParamTypes))
                {
                    using (IDataReader reader = command.ExecuteReader(this.FParamValues))
                    {
                        LoadContext loadContext = this.Condition == string.Empty ? LoadContext.FetchAllObjects : (LoadContext)0;
                        this.Load(reader, dstObjs, loadContext);
                    }
                }
            }
            else
            {
                List <DataId> dataIdList = new List <DataId>();
                using (InDbCommand command = db.CreateCommand(sql.ToString(), this.FParamTypes))
                {
                    using (IDataReader dataReader = command.ExecuteReader(this.FParamValues))
                    {
                        while (dataReader.Read())
                        {
                            dataIdList.Add(new DataId(dataReader.GetString(0)));
                        }
                    }
                }
                this.FStorage.Session.LoadData(this.ObjectLoader.BasePlan, dstObjs, dataIdList.ToArray(), (string)null);
            }
        }
예제 #7
0
 protected void Dispose(bool disposing)
 {
     if (disposing)
     {
         if (this.FCentralServerConnection != null)
         {
             this.FCentralServerConnection.Dispose();
         }
         if (this.FScriptLibraries != null)
         {
             this.FScriptLibraries.Dispose();
         }
         if (this.FStorages != null)
         {
             for (int index = 0; index < this.FStorages.Length; ++index)
             {
                 DataStorage fstorage = this.FStorages[index];
                 if (fstorage != null)
                 {
                     this.FStorages[index] = (DataStorage)null;
                     fstorage.Dispose();
                 }
             }
         }
         if (this.FDb != null)
         {
             this.FDb.Dispose();
         }
         if (this.Disposed != null)
         {
             this.Disposed((object)this, EventArgs.Empty);
         }
     }
     this.FCentralServerConnection = (CentralServerConnection)null;
     this.FDb = (InDbDatabase)null;
     this.FScriptLibraries = (ScriptLibraries)null;
 }
예제 #8
0
 internal InDbxDb(InDbDatabase db) => this.FDb = db;
예제 #9
0
 internal abstract void Load(InDbDatabase connection, DataObjectList dstObjs);