示例#1
0
        /// <summary>
        /// delete an entity if it exists
        /// </summary>
        /// <param name="entity"></param>
        public void Delete(ActionRequestLogEntry entity)
        {
            var deleteEntity = this.SelectOne(entity.PartitionKey, entity.RowKey);

            if (deleteEntity != null)
            {
                GetTableReference().Execute(TableOperation.Delete(deleteEntity));
            }
        }
示例#2
0
 /// <summary>
 /// insert an entity regardless
 /// </summary>
 /// <param name="entity"></param>
 public void Insert(ActionRequestLogEntry entity)
 {
     try
     {
         GetTableReference().Execute(TableOperation.Insert(entity));
     }
     catch (Exception ex)
     {
         LogErrorMessage(entity, ex);
     }
 }
示例#3
0
        /// <summary>
        /// update an entity if it exists, otherwise insert a new record
        /// </summary>
        /// <param name="entity"></param>
        public void Upsert(ActionRequestLogEntry entity)
        {
            var updateEntity = this.SelectOne(entity.PartitionKey, entity.RowKey);

            if (updateEntity == null)
            {
                this.Insert(entity);
            }
            else
            {
                this.Update(entity);
            }
        }
示例#4
0
        /// <summary>
        /// update an entity if it exists
        /// </summary>
        /// <param name="entity"></param>
        public void Update(ActionRequestLogEntry entity)
        {
            var updateEntity = this.SelectOne(entity.PartitionKey, entity.RowKey);

            if (updateEntity == null)
            {
                return;
            }

            // not allow to change the original creator id
            updateEntity.AccessDate       = entity.AccessDate;
            updateEntity.ActionParameters = entity.ActionParameters;
            updateEntity.IpAddress        = entity.IpAddress;
            GetTableReference().Execute(TableOperation.Replace(updateEntity));
        }
示例#5
0
        public void LogErrorMessage(ActionRequestLogEntry entity, Exception ex)
        {
            var msg = string.Format("message: {0}, source: {1}, stack trace: {2}, TargetSite: {3}", ex.Message, ex.Source, ex.StackTrace, ex.TargetSite);

            if (ex.Data != null && ex.Data.Keys != null)
            {
                foreach (var key in ex.Data.Keys)
                {
                    msg = string.Format("{0}, {1}|{2},", msg, key, ex.Data[key]);
                }
            }
            using (var context = OsbideContext.DefaultWebConnection)
            {
                context.LocalErrorLogs.Add(new LocalErrorLog
                {
                    SenderId = Convert.ToInt32(entity.RowKey.Split('_')[0]),
                    LogDate  = DateTime.Now,
                    Content  = msg
                });
                context.SaveChanges();
            }
        }