Ejemplo n.º 1
0
        private IDbConnection CreateSqlConnection(CoreEntity entity)
        {
            IDbConnection cn;

            if (entity._notRecommendedConnection != null)
            {
                // This is assumed to be open
                cn = entity._notRecommendedConnection;
            }
            else
            {
                cn = entity.CreateIDbConnection();

                if (entity._raw != "")
                {
                    cn.ConnectionString = entity._raw;
                }
                else
                {
                    cn.ConnectionString = ConfigurationManager.ConnectionStrings[entity._config].ConnectionString;
                }

                cn.Open();
            }

            return(cn);
        }
Ejemplo n.º 2
0
        public override int SaveChanges()
        {
            var      ModifiedEntities = ChangeTracker.Entries().Where(m => m.State == EntityState.Modified || m.State == EntityState.Added).ToList();
            DateTime datetime         = DateTime.Now;
            string   ip = HttpContext.Current.Request.UserHostAddress;

            foreach (var item in ModifiedEntities)
            {
                CoreEntity entity = item.Entity as CoreEntity;
                if (item != null)
                {
                    switch (item.State)
                    {
                    case EntityState.Added:
                        entity.CreatedIP   = ip;
                        entity.CreatedDate = datetime;
                        break;

                    case EntityState.Modified:
                        entity.ModifiedIP   = ip;
                        entity.ModifiedDate = datetime;
                        break;
                    }
                }
            }
            return(base.SaveChanges());
        }
Ejemplo n.º 3
0
        public int SaveChanges(Guid UserID)
        {
            var modifiedEntries = ChangeTracker.Entries().Where(x => x.State == EntityState.Modified || x.State == EntityState.Added).ToList();

            string   Identity     = WindowsIdentity.GetCurrent().Name;
            string   ComputerName = Environment.MachineName;
            DateTime dateTime     = DateTime.Now;
            string   ip           = RemoteIp.GetIpAddress();

            foreach (var item in modifiedEntries)
            {
                CoreEntity entity = item.Entity as CoreEntity;
                if (item != null)
                {
                    if (item.State == EntityState.Added)
                    {
                        entity.CreatedADUserName   = Identity;
                        entity.CreatedComputerName = ComputerName;
                        entity.CreatedDate         = dateTime;
                        entity.CreatedBy           = UserID;
                        entity.CreatedIp           = ip;
                    }
                    else if (item.State == EntityState.Modified)
                    {
                        entity.ModifiedADUserName   = Identity;
                        entity.ModifiedBy           = UserID;
                        entity.ModifiedComputerName = ComputerName;
                        entity.ModifiedDate         = dateTime;
                        entity.ModifiedIp           = ip;
                    }
                }
            }
            return(base.SaveChanges());
        }
Ejemplo n.º 4
0
        public override Task <int> SaveChangesAsync(bool acceptAllChangesOnSuccess, CancellationToken cancellationToken = default)
        {
            var modifiedEntries = ChangeTracker.Entries().Where(x => x.State == EntityState.Added || x.State == EntityState.Modified);

            string   identity     = WindowsIdentity.GetCurrent().Name;
            string   computerName = Environment.MachineName;
            DateTime dateTime     = DateTime.Now;

            foreach (var item in modifiedEntries)
            {
                CoreEntity entity = item.Entity as CoreEntity;

                if (item.State == EntityState.Added)
                {
                    entity.CreatedUserName     = identity;
                    entity.CreatedComputerName = computerName;
                    entity.CreatedDate         = dateTime;
                }
                else if (item.State == EntityState.Modified)
                {
                    entity.ModifiedUserName     = identity;
                    entity.ModifiedComputerName = computerName;
                    entity.ModifiedDate         = dateTime;
                }
            }
            return(base.SaveChangesAsync(acceptAllChangesOnSuccess, cancellationToken));
        }
Ejemplo n.º 5
0
        public override int SaveChanges()
        {
            //ChangeTracker nesnesi : veritabanına giden her verinin takibini yapar. Veri o an yeni mi ekleniyor yoksa mevcut veri mi güncelleniyor bunu takip eder.

            var modifiedEntries = ChangeTracker.Entries().Where(x => x.State == EntityState.Added || x.State == EntityState.Modified).ToList(); // Where kullandığımız için birden fazla sonuç gelebilir .

            foreach (var item in modifiedEntries)
            {
                CoreEntity nesne = (CoreEntity)item.Entity;
                if (item != null)
                {
                    if (item.State == EntityState.Added)
                    {
                        nesne.CreatedDate         = DateTime.Now;
                        nesne.CreatedComputerName = Environment.MachineName;
                        //nesne.CreatedUserName = Environment.UserName;
                        nesne.CreatedUserName = WindowsIdentity.GetCurrent().Name;
                        nesne.Durumu          = Core.Entity.Enum.Status.Active;
                    }
                    else if (item.State == EntityState.Modified)
                    {
                        nesne.ModifiedDate         = DateTime.Now;
                        nesne.ModifiedComputerName = Environment.MachineName;
                        //nesne.CreatedUserName = Environment.UserName;
                        nesne.ModifiedUserName = WindowsIdentity.GetCurrent().Name;
                        if (nesne.Durumu == Core.Entity.Enum.Status.Active)
                        {
                            nesne.Durumu = Core.Entity.Enum.Status.Active;
                        }
                    }
                }
            }

            return(base.SaveChanges());
        }
 public void OnActiveAction(CoreEntity entity, Action value)
 {
     if (entity.hasActiveAction && entity.hasCurrentRoom)
     {
         this.OnCurrentRoom(entity, entity.currentRoom.roomId);
     }
 }
Ejemplo n.º 7
0
        public static ChildEntity SaveForTest(this ChildEntity entity, CoreEntity parent = null,
                                              string name = null, int?integer = null, decimal?deci = null)
        {
            var created = entity.GenerateForTest();

            return(SaveEntity <ChildEntity, int>(created));
        }
Ejemplo n.º 8
0
        public override int SaveChanges()
        {
            var      modifiedEntries = ChangeTracker.Entries().Where(x => x.State == EntityState.Modified || x.State == EntityState.Added).ToList();
            string   identity        = WindowsIdentity.GetCurrent().Name;
            string   computerName    = Environment.MachineName;
            DateTime dateTime        = DateTime.Now;
            string   user            = "******";
            string   ip = CoreEntity.GetHostName();

            foreach (var item in modifiedEntries)
            {
                CoreEntity coreEntity = item.Entity as CoreEntity;
                if (item != null)
                {
                    if (item.State == EntityState.Added)
                    {
                        coreEntity.CreatedAdUserName   = identity;
                        coreEntity.CreatedComputerName = computerName;
                        coreEntity.CreatedDate         = dateTime;
                        coreEntity.CreatedIP           = ip;
                        coreEntity.CreatedBy           = user;
                    }
                    else if (item.State == EntityState.Modified)
                    {
                        coreEntity.ModifiedAdComputerName = identity;
                        coreEntity.ModifiedComputerName   = computerName;
                        coreEntity.ModifiedDate           = dateTime;
                        coreEntity.ModifiedIP             = ip;
                        coreEntity.ModifiedBy             = user;
                    }
                }
            }
            return(base.SaveChanges());
        }
Ejemplo n.º 9
0
        public override int SaveChanges()// DBContext’in save işleminin yapıldığı yer burasıdır. Önce değişen tablolar bulunur ve değiştiği alanların önceki ve sonraki halleri kaydedilir.
        {
            var modifiedEntries = ChangeTracker.Entries().Where(x => x.State == EntityState.Added || x.State == EntityState.Modified);
            //“ChangeTracker.Entries()” :Tüm entry’ler alınır.
            //“.Where(p => p.State == EntityState.Modified).ToList()” : Update olanlar bir listeye atılır.

            string   identity     = WindowsIdentity.GetCurrent().Name; //Geçerli Windows kullanıcısını temsil eden bir WindowsIdentity nesnesini döndürür.
            string   computerName = Environment.MachineName;           //Bu yerel bilgisayarın NetBIOS adını alır.
            DateTime dateTime     = DateTime.Now;
            string   GetIp        = RemoteIP.IpAddress;

            foreach (var item in modifiedEntries)
            {
                CoreEntity entity = item.Entity as CoreEntity;

                if (item.State == EntityState.Added)
                {
                    entity.CreatedUserName     = identity;
                    entity.CreatedComputerName = computerName;
                    entity.CreatedDate         = dateTime;
                    entity.CreatedIP           = GetIp;
                }
                else if (item.State == EntityState.Modified)
                {
                    entity.ModifiedUserName     = identity;
                    entity.ModifiedComputerName = computerName;
                    entity.ModifiedDate         = dateTime;
                    entity.ModifiedIP           = GetIp;
                }
            }

            return(base.SaveChanges());
        }
Ejemplo n.º 10
0
        public override int SaveChanges()
        {
            var modifiedEntries = ChangeTracker.Entries().Where(e => e.State == EntityState.Added || e.State == EntityState.Modified);

            string   identity     = WindowsIdentity.GetCurrent().Name;
            string   computerName = Environment.MachineName;
            DateTime date         = DateTime.Now;
            string   ip           = Core.Service.RemoteIP.IpAddress;

            foreach (var item in modifiedEntries)
            {
                CoreEntity entity = item.Entity as CoreEntity;
                if (entity != null)
                {
                    if (item.State == EntityState.Added)
                    {
                        entity.Status              = Core.Entity.Enum.Status.Active;
                        entity.CreatedADUserName   = identity;
                        entity.CreatedComputerName = computerName;
                        entity.CreatedIP           = ip;
                        entity.CreatedDate         = date;
                    }
                    else if (item.State == EntityState.Modified)
                    {
                        entity.ModifiedADUserName   = identity;
                        entity.ModifiedComputerName = computerName;
                        entity.ModifiedIP           = ip;
                        entity.ModifiedDate         = date;
                    }
                }
            }

            return(base.SaveChanges());
        }
Ejemplo n.º 11
0
    public void InitializeView(Contexts contexts, IEntity entity)
    {
        _entity = (CoreEntity)entity;
        _entity.AddCoreDestroyedListener(this);

        gameObject.Link(entity);
    }
Ejemplo n.º 12
0
        public override int SaveChanges()
        {
            var gelenEntities = ChangeTracker.Entries()
                                .Where(x => x.State == EntityState.Modified || x.State == EntityState.Added).ToList();

            string   computerName = Environment.MachineName;
            string   ipAddress    = "127.0.0.1";
            DateTime date         = DateTime.Now;

            foreach (var item in gelenEntities)
            {
                CoreEntity entity = item.Entity as CoreEntity;
                if (item != null)
                {
                    switch (item.State)
                    {
                    case EntityState.Added:
                        entity.CreatedComputerName = computerName;
                        entity.CreatedIP           = ipAddress;
                        entity.CreatedDate         = date;
                        break;

                    case EntityState.Modified:
                        entity.ModifiedComputerName = computerName;
                        entity.CreatedIP            = ipAddress;
                        entity.CreatedDate          = date;
                        break;
                    }
                }
            }

            return(base.SaveChanges());
        }
Ejemplo n.º 13
0
        public override int SaveChanges()
        {
            var modifiedEntries = ChangeTracker.Entries().Where(x => x.State == EntityState.Added || x.State == EntityState.Modified);

            string   identity     = WindowsIdentity.GetCurrent().Name;
            string   computerName = Environment.MachineName;
            DateTime dateTime     = DateTime.Now;
            string   GetIp        = RemoteIP.IpAddress;

            foreach (var item in modifiedEntries)
            {
                CoreEntity entity = item.Entity as CoreEntity;

                if (item.State == EntityState.Added)
                {
                    entity.CreatedUserName     = identity;
                    entity.CreatedComputerName = computerName;
                    entity.CreatedDate         = dateTime;
                    entity.CreatedIP           = GetIp;
                }
                else if (item.State == EntityState.Modified)
                {
                    entity.ModifiedUserName     = identity;
                    entity.ModifiedComputerName = computerName;
                    entity.ModifiedDate         = dateTime;
                    entity.ModifiedIP           = GetIp;
                }
            }
            return(base.SaveChanges());
        }
Ejemplo n.º 14
0
        public override int SaveChanges()
        {
            var modifiedEntities = ChangeTracker.Entries().Where(x => x.State == EntityState.Modified || x.State == EntityState.Added).ToList();

            string   ip          = HttpContext.Current.Request.UserHostAddress;
            DateTime dt          = DateTime.Now;
            string   machineName = WindowsIdentity.GetCurrent().Name;

            foreach (var item in modifiedEntities)
            {
                CoreEntity entity = item.Entity as CoreEntity;

                if (item != null)
                {
                    switch (item.State)
                    {
                    case EntityState.Added:
                        entity.CreatedDate         = dt;
                        entity.CreatedIP           = ip;
                        entity.CreatedComputerName = machineName;
                        break;

                    case EntityState.Modified:
                        entity.ModifiedIP           = ip;
                        entity.ModifiedDate         = dt;
                        entity.ModifiedComputerName = machineName;
                        break;
                    }
                }
            }
            return(base.SaveChanges());
        }
        public override int SaveChanges()
        {
            //Have changes or added entities are catched with ChangceTracker and assing to modifiedEntities variable
            var      modifiedEntities = ChangeTracker.Entries().Where(x => x.State == EntityState.Modified || x.State == EntityState.Added).ToList();
            string   computerName     = Environment.MachineName;
            string   ipAddress        = "127.0.0.1";
            DateTime date             = DateTime.Now;

            foreach (var item in modifiedEntities)
            {
                CoreEntity entity = item.Entity as CoreEntity;

                if (item != null)
                {
                    if (item.State == EntityState.Modified)
                    {
                        entity.UpdatedComputerName = computerName;
                        entity.UpdatedIP           = ipAddress;
                        entity.CreatedDate         = date;
                    }
                    else if (item.State == EntityState.Added)
                    {
                        entity.UpdatedComputerName = computerName;
                        entity.UpdatedIP           = ipAddress;
                        entity.CreatedDate         = date;
                    }
                }
            }

            return(base.SaveChanges());
        }
Ejemplo n.º 16
0
 public void OnDirtLevel(CoreEntity entity, float value)
 {
     foreach (var dirtSprite in dirtSprites)
     {
         var color = dirtSprite.color;
         dirtSprite.color = new Color(color.r, color.g, color.b, Mathf.Max(0, Mathf.Min(1, value / 10)));
     }
 }
Ejemplo n.º 17
0
        /// <summary>
        /// Called internally by CoreEntity
        /// </summary>
        /// <param name="entity"></param>
        internal void AddBusinessEntity(CoreEntity entity)
        {
            if (this.objectsInTransaction == null)
            {
                this.objectsInTransaction = new ArrayList();
            }

            this.objectsInTransaction.Add(entity);
        }
Ejemplo n.º 18
0
    public virtual void Link(CoreEntity entity)
    {
        gameObject.Link(entity);

        entity.AddCoreDestroyedListener(this);
        if (entity.isDestroyed)
        {
            this.OnDestroyed(entity);
        }
    }
Ejemplo n.º 19
0
    public override void Link(CoreEntity entity)
    {
        base.Link(entity);

        entity.AddDirtLevelListener(this);
        if (entity.hasDirtLevel)
        {
            this.OnDirtLevel(entity, entity.dirtLevel.value);
        }
    }
    public void OnCurrentRoom(CoreEntity entity, int roomId)
    {
        switch (roomId)
        {
        case 0:     // Living room
            if (entity.hasActiveAction && entity.activeAction.value == Action.HAVE_A_PARTY)
            {
                transform.position = new Vector2(5.02f, 2.67f);
            }
            else if (entity.hasActiveAction && entity.activeAction.value == Action.WATCH_TV)
            {
                transform.position = new Vector2(6.82f, 0.31f);
            }
            else
            {
                transform.position = new Vector2(6.82f, 2f);
            }
            break;

        case 1:     // Kitchen
            if (entity.hasActiveAction && entity.activeAction.value == Action.DO_THE_DISHES)
            {
                transform.position = new Vector2(1.92f, 3.87f);
            }
            else if (entity.hasActiveAction && entity.activeAction.value == Action.EAT)
            {
                transform.position = new Vector2(3.8f, 0.5f);
            }
            else
            {
                transform.position = new Vector2(3f, 3f);
            }
            break;

        case 2:     // Bathroom
            if (entity.hasActiveAction && entity.activeAction.value == Action.GO_TO_TOILET)
            {
                transform.position = new Vector2(0.2f, -4.2f);
            }
            else if (entity.hasActiveAction && entity.activeAction.value == Action.SHOWER)
            {
                transform.position = new Vector2(0.2f, -3f);
            }
            else
            {
                transform.position = new Vector2(-1.5f, -3f);
            }

            break;

        default:
            transform.position = new Vector2(0f, 0f);
            break;
        }
    }
Ejemplo n.º 21
0
        public static CoreEntity GenerateForTest(this CoreEntity entity)
        {
            RandomizeTestBase <CoreEntity, int>(entity);

            if (entity.ParentEntity == null)
            {
                entity.ParentEntity = new ParentEntity().SaveForTest();
            }

            return(entity);
        }
Ejemplo n.º 22
0
        public static ChildEntity GenerateForTest(this ChildEntity entity, CoreEntity parent = null,
                                                  string name = null, int?integer = null, decimal?deci = null)
        {
            RandomizeTestBase <ChildEntity, int>(entity);

            if (entity.CoreEntity == null)
            {
                entity.CoreEntity = new CoreEntity().SaveForTest();
            }

            return(entity);
        }
    protected override void Execute(List <ViewEntity> entities)
    {
        foreach (var e in entities)
        {
            CoreEntity coreEntity = context.GetEntityWithId(e.coreEntityReference.entityId);
            if (coreEntity == null)
            {
                continue;
            }

            e.view.value.Link(coreEntity);
        }
    }
Ejemplo n.º 24
0
    public void RegisterListeners(IEntity entity)
    {
        _entity = (CoreEntity)entity;
        _entity.AddCorePositionListener(this);

        if (!_entity.hasPosition)
        {
            Debug.Log("Entity " + _entity.id.value + " doesn't have position component");
        }
        else
        {
            OnPosition(_entity, _entity.position.value);
        }
    }
Ejemplo n.º 25
0
        public override int SaveChanges()
        {
            //Otomatik loglama amaçlı kullanılan bazı özelliklerin doldurulması için, savechanges metodunu override ediyoruz.

            //Yeni eklenen veya güncellenen tüm entry yani kayıtları yakalıyoruz.

            var modifiedEntries = ChangeTracker.Entries().Where(e => e.State == EntityState.Added || e.State == EntityState.Modified);

            //Hem eklemede hem de güncellemede kullanılacak olan ortak değerleri bir kere de yakalıyoruz.
            string   identity     = WindowsIdentity.GetCurrent().Name;
            string   computerName = Environment.MachineName;
            DateTime date         = DateTime.Now;
            //IP Yakalama Utility içerisine atılacak
            string ip = string.Empty;


            //Yeni eklenen ve güncellenen tüm kayıtlarda geziyoruz.
            foreach (var item in modifiedEntries)
            {
                //hangi entity sınıfından geleceğini bilmiyoruz. Ortak tip olan coreEntity olarak yakalıyoruz.
                CoreEntity entity = item.Entity as CoreEntity;

                if (item != null)
                {
                    if (item.State == EntityState.Added)
                    {
                        entity.Status              = Core.Core.Entity.Enums.Status.Active;
                        entity.CreatedADUserName   = identity;
                        entity.CreatedComputerName = computerName;
                        entity.CreatedDate         = date;
                        entity.CreatedIP           = ip;
                    }
                    else if (item.State == EntityState.Modified)
                    {
                        if (entity.Status != Core.Core.Entity.Enums.Status.Deleted)
                        {
                            entity.Status = Core.Core.Entity.Enums.Status.Updated;
                        }
                        entity.ModifiedADUserName   = identity;
                        entity.ModifiedComputerName = computerName;
                        entity.ModifiedDate         = date;
                        entity.ModifiedIP           = ip;
                    }
                }
            }


            return(base.SaveChanges());
        }
Ejemplo n.º 26
0
 /// <summary>
 /// Each call to Enlist must be followed eventually by a call to DeEnlist.
 /// </summary>
 /// <param name="cmd"></param>
 /// <param name="entity"></param>
 /// <example>
 /// C#
 /// <code>
 /// txMgr.Enlist(cmd, this);
 /// cmd.ExecuteNonQuery();
 /// txMgr.DeEnlist(cmd, this);
 /// </code>
 /// VB.NET
 /// <code>>
 /// txMgr.Enlist(cmd, Me)
 /// cmd.ExecuteNonQuery()
 /// txMgr.DeEnlist(cmd, Me)
 /// </code>
 /// </example>
 public void DeEnlist(IDbCommand cmd, CoreEntity entity)
 {
     if (entity._notRecommendedConnection != null)
     {
         // NotRecommendedConnection never play in dOOdad transactions
         cmd.Connection = null;
     }
     else
     {
         if (txCount == 0)
         {
             cmd.Connection.Dispose();
         }
     }
 }
Ejemplo n.º 27
0
        public override int SaveChanges()
        {
            var modifiedEntries = ChangeTracker.Entries().Where(e => e.State == EntityState.Added);

            DateTime date = DateTime.UtcNow;

            foreach (var item in modifiedEntries)
            {
                CoreEntity entity = item.Entity as CoreEntity;
                entity.AddedDate = date;
            }


            return(base.SaveChanges());
        }
Ejemplo n.º 28
0
        public override int SaveChanges()
        {
            //Otomatik loglama amaçlı kullanılan bazı özelliklerin doldurulması için, savechannges öetodunu override ediyoruz.

            //İlk olarak yeni eklenen veya yeni güncellenen tüm kayıtları yakalamalıyız.

            //ChangeTracker nesnesi savechanges metodu çağırıldığında bizim yaptığımız tüm kayıtlardaki değişimleri takip eden nesnedir.

            //Alttaki kodda eklenmeyi bekleyen veya güncellenmeyi bekleyen tüm kayıtları yani entry'leri yakalıyoruz.
            var modifiedEntries = ChangeTracker.Entries().Where(e => e.State == EntityState.Added || e.State == EntityState.Modified);


            string   identity     = WindowsIdentity.GetCurrent().Name;
            string   computerName = Environment.MachineName;
            DateTime date         = DateTime.Now;
            //Utility projesinden çekilir.
            string ip = RemoteIP.IpAddress;

            //string ip = default(string);

            foreach (var item in modifiedEntries)
            {
                CoreEntity entity = item.Entity as CoreEntity;
                if (entity != null)
                {
                    if (item.State == EntityState.Added)
                    {
                        entity.Status              = Core.Entity.Enum.Status.Active;
                        entity.CreatedADUserName   = identity;
                        entity.CreatedComputerName = computerName;
                        entity.CreatedIP           = ip;
                        entity.CreatedDate         = date;
                    }
                    else if (item.State == EntityState.Modified)
                    {
                        entity.ModifiedADUserName   = identity;
                        entity.ModifiedComputerName = computerName;
                        entity.ModifiedIP           = ip;
                        entity.ModifiedDate         = date;
                    }
                }
            }



            return(base.SaveChanges());
        }
Ejemplo n.º 29
0
        /// <summary>
        /// Enlist by the dOOdads architecture when a IDbCommand (SqlCommand is an IDbCommand). The command may or may not be enrolled
        /// in a transaction depending on whether or not BeginTransaction has been called. Each call to Enlist must be followed by a
        /// call to <see cref="DeEnlist"/>.
        /// </summary>
        /// <param name="cmd">Your SqlCommand, OleDbCommand, etc ...</param>
        /// <param name="entity">Your business entity, in C# use 'this', VB.NET use 'Me'.</param>
        /// <example>
        /// C#
        /// <code>
        /// txMgr.Enlist(cmd, this);
        /// cmd.ExecuteNonQuery();
        /// txMgr.DeEnlist(cmd, this);
        /// </code>
        /// VB.NET
        /// <code>
        /// txMgr.Enlist(cmd, Me)
        /// cmd.ExecuteNonQuery()
        /// txMgr.DeEnlist(cmd, Me)
        /// </code>
        /// </example>
        public void Enlist(IDbCommand cmd, CoreEntity entity)
        {
            if (txCount == 0 || entity._notRecommendedConnection != null)
            {
                // NotRecommendedConnections never play in dOOdad transactions
                cmd.Connection = CreateSqlConnection(entity);
            }
            else
            {
                string connStr = entity._config;
                if (entity._raw != "")
                {
                    connStr = entity._raw;
                }

                Transaction tx = this.transactions[connStr] as Transaction;

                if (tx == null)
                {
                    IDbConnection sqlConn = CreateSqlConnection(entity);

                    tx = new Transaction();
                    tx.sqlConnection = sqlConn;

                    if (_isolationLevel != IsolationLevel.Unspecified)
                    {
                        tx.sqlTx = sqlConn.BeginTransaction(_isolationLevel);
                    }
                    else
                    {
                        tx.sqlTx = sqlConn.BeginTransaction();
                    }
                    this.transactions[connStr] = tx;
                }

                cmd.Connection  = tx.sqlConnection;
                cmd.Transaction = tx.sqlTx;
            }
        }
Ejemplo n.º 30
0
        public override int SaveChanges()
        {
            var modifiedEntries = ChangeTracker.Entries().Where(x => x.State == EntityState.Modified || x.State == EntityState.Added).ToList();

            string   Identity     = WindowsIdentity.GetCurrent().Name;
            string   ComputerName = Environment.MachineName;
            DateTime dateTime     = DateTime.Now;
            int      User         = 1;
            string   ip           = "123";

            foreach (var item in modifiedEntries)
            {
                CoreEntity entity = item.Entity as CoreEntity;

                if (item != null)
                {
                    if (item.State == EntityState.Added)
                    {
                        entity.CreatedUsername     = Identity;
                        entity.CreatedComputerName = ComputerName;
                        entity.CreatedDate         = dateTime;
                        entity.CreatedBy           = User;
                        entity.CreatedIp           = ip;

                        entity.Durumu = Core.Entity.Enum.Status.Active;
                    }
                    else if (item.State == EntityState.Modified)
                    {
                        entity.ModifiedUsername     = Identity;
                        entity.ModifiedComputerName = ComputerName;
                        entity.ModifiedIp           = ip;
                        entity.ModifiedBy           = User;
                        entity.ModifiedDate         = dateTime;
                    }
                }
            }

            return(base.SaveChanges());
        }