Example #1
0
        /// <summary>
        ///  Create basic tables of PersistentObjects
        /// </summary>
        private static Type[] CreateBasicTable()
        {
            Type[] basicTypes = new Type[] {
                //typeof(dictDatabaseDpo),
                //typeof(dictDataTableDpo),
                //typeof(dictDataColumnDpo),
                //typeof(dictEnumTypeDpo),
                //typeof(logDataSetDpo),
                //typeof(logDataTableDpo),
                //typeof(logDataColumnDpo),
                //typeof(RecordLockDpo),
                //typeof(DataProviderDpo),
                //typeof(logDpoClassDpo)
            };

            foreach (Type type in basicTypes)
            {
                DPObject dpo = (DPObject)Activator.CreateInstance(type);
                dpo.CreateTable();
            }

            foreach (Type type in basicTypes)
            {
                DPObject dpo = (DPObject)Activator.CreateInstance(type);
                //dpo.RegisterEntireTable();
            }

            return(basicTypes);
        }
Example #2
0
        public Logger(Transaction transaction, DPObject dpo)
        {
            this.log_transaction = transaction;
            this.tableName       = dpo.TableName;
            this.tableId         = dpo.TableId;
            this.rowID           = dpo.RowId;

            this.logee = LogManager.Instance.RowLogee(dpo);

            dpoType = dpo.GetType();
        }
Example #3
0
        public void RowChanged(object sender, RowChangedEventArgs e)
        {
            if (e.state == ObjectState.Added || e.state == ObjectState.Deleted || e.state == ObjectState.Modified)
            {
                if (!log_transaction)
                {
                    throw new MessageException("TransactionID is not assgined yet.");
                }

                if (this.rowID == 0)
                {
                    if (e.saved)      //log after save with identity value created
                    {
                        if (dpoType != null)
                        {
                            DPObject dpo = (DPObject)Activator.CreateInstance(dpoType, new object[] { e.adapter.Row });
                            this.rowID = dpo.RowId;
                        }
                        else if (this.rowIdColumnName != null)
                        {
                            this.rowID = (int)e.adapter.Row[this.rowIdColumnName];
                        }
                        else
                        {
                            throw new MessageException("DPO Type is not defined");
                        }
                    }
                    else
                    {
                        return;
                    }
                }

                modified = e.state == ObjectState.Modified;

                if (e.state == ObjectState.Modified || e.state == ObjectState.Added || e.state == ObjectState.Deleted)
                {
                    log_row_id = this.logee.LogRow(log_transaction, this.tableName, this.tableId, this.rowID, e.state, e.adapter.Row1, e.adapter.Row);

                    logged = log_row_id > 0;
                }
            }
        }
Example #4
0
        private static MessageBuilder CreateTable(Type dpoType)
        {
            MessageBuilder messages = new MessageBuilder();

            DPObject dpo = (DPObject)Activator.CreateInstance(dpoType);

            int tableId = dpo.TableName.Id;

            if (dpo.CreateTable())
            {
                messages.Add(Message.Information(string.Format("Table {0} created.", dpo.TableName)));

                //if (tableId == -1)  //register new table to dictionary
                //tableId = dpo.RegisterEntireTable();
            }
            else
            {
                messages.Add(Message.Information(string.Format("Table {0} exists, cannot be created.", dpo.TableName)));
            }

            return(messages);
        }
Example #5
0
 public ClassName(DPObject dpo)
     : this(dpo.GetType())
 {
 }
Example #6
0
 public IRowLogee RowLogee(DPObject dpo)
 {
     return(RowLogee(dpo.TableName));
 }