Esempio n. 1
0
 private bool CDCLogging(TEntity entity, HttpRequestInfo reqInfo, short type, short isDeleted)
 {
     try
     {
         var key       = EntityHelper.GetEntityKey <TEntity>(context, entity);
         var oldEntity = dbSet.Find(key.EntityKeyValues.FirstOrDefault().Value);
         var data      = new RouteValueDictionary(oldEntity);
         var xml       = new XElement(
             "items",
             data.Where(x => x.Value != null).Select(x => new XElement("item", new XAttribute("id", x.Key), new XAttribute("value", x.Value)))
             ).ToString();
         CDC cdc = new CDC();
         cdc.OperationIdUserRef = reqInfo.UserID;
         cdc.OperationDate      = DateTime.Now;
         cdc.OperationIP        = reqInfo.IpAddress;
         cdc.OperationIsDeleted = isDeleted;
         cdc.OperationType      = type;
         cdc.TableName          = key.EntitySetName;
         cdc.Source             = xml;
         long keyLong = -1;
         Guid keyGuid;
         long.TryParse(key.EntityKeyValues.FirstOrDefault().Value.ToString(), out keyLong);
         Guid.TryParse(key.EntityKeyValues.FirstOrDefault().Value.ToString(), out keyGuid);
         if (keyLong != -1)
         {
             cdc.TableId = keyLong;
         }
         cdc.TableIdGuid         = keyGuid;
         cdc.TablePrimaryKeyName = key.EntityKeyValues.FirstOrDefault().Key;
         var cdcContext    = new DerinEntities();
         var cdcRec        = new GenericRepository <CDC>(cdcContext);
         var cdcUnitOfWork = new UnitOfWork.Derin.UnitOfWork(cdcContext);
         cdcRec.Insert(cdc);
         cdcUnitOfWork.Save();
         cdcUnitOfWork.Dispose();
         return(true);
     }
     catch (System.Exception ex)
     {
         return(false);
     }
 }
Esempio n. 2
0
 public UnitOfWork(DerinEntities context)
 {
     _context = context;
 }