protected override object Evaluate(CommonRequest request)
        {
            var data = JsonConvert.DeserializeObject <Businesslike>(request.data);

            if (data == null)
            {
                return new CommonOutputT <string>
                       {
                           success = false,
                           message = "删除成功"
                       }
            }
            ;
            using (var ctx = new XiangXiEntities())
            {
                var one = ctx.Businesslike.Find(data.id);

                if (one == null)
                {
                    return(new CommonOutputT <string>
                    {
                        success = false,
                        message = "未找到需要删除的数据"
                    });
                }
                ctx.Businesslike.Remove(one);
                ctx.SaveChanges();
                return(new CommonOutputT <string>
                {
                    success = true,
                    message = "删除成功"
                });
            }
        }
    }
Exemple #2
0
 protected override object Evaluate(CommonRequest request)
 {
     using (var ctx = new XiangXiEntities())
     {
         var rows   = ctx.V_Table_Comments.ToList();
         var tables = new HashSet <string>(rows.Select(p => p.table_name));
         return(tables.ToDictionary(p => p, p => rows.Where(r => r.table_name == p).ToList()));
     }
 }
Exemple #3
0
 protected override object Evaluate(CommonRequest request)
 {
     using (var ctx = new XiangXiEntities())
     {
         UserInformation user   = Sessions["UserInformation"] as UserInformation;
         string          name   = user.UILoginName;
         string          pwd    = user.UICode;
         var             rows   = ctx.V_Table_Comments.ToList();
         var             tables = new HashSet <string>(rows.Select(p => p.table_name));
         return(tables.ToDictionary(p => p, p => rows.Where(r => r.table_name == p).ToList()));
     }
 }
        protected override object Evaluate(CommonRequest request)
        {
            if (Sessions.Count == 0)
            {
                return(new
                {
                    success = false,
                    message = "请登录"
                });
            }
            var user = Sessions[nameof(UserInformation)] as UserInformation;

            if (user == null)
            {
                return(new
                {
                    success = false,
                    message = "请登录"
                });
            }
            using (var ctx = new XiangXiEntities())
            {
                var s      = request.data;
                var entity = JsonConvert.DeserializeObject <Businesslike>(s);
                // 行级排他锁开始
                var transactionId = Guid.NewGuid().ToString();
                var isnew         = entity.id == null;
                if (!isnew)
                {
                    var one = ctx.Businesslike.FirstOrDefault(p => p.id == entity.id);
                    if (one == null)
                    {
                        return new
                               {
                                   success = false,
                                   message = "编辑错误,未找到ID"
                               }
                    }
                    ;
                    if (one.VersionNo != entity.VersionNo)
                    {
                        return new
                               {
                                   success = false,
                                   message = "发生数据写冲突"
                               }
                    }
                    ;
                    one.VersionNo++;
                    one.TransactionID = transactionId;
                    ctx.Businesslike.AddOrUpdate(one);
                    ctx.SaveChanges();
                    entity.VersionNo = one.VersionNo;
                }

                entity.id       = entity.id ?? Guid.NewGuid().ToString();
                entity.CreateBy = entity.CreateBy ?? user?.UILoginName ?? "未登录用户";
                entity.UpdateBy = user?.UILoginName ?? "未登录用户";
                var now = DateTime.Now;
                entity.CreateOn      = entity.CreateOn ?? now;
                entity.TransactionID = transactionId;
                entity.UpdateOn      = now;
                entity.IsDeleted     = 0;
                ctx.Businesslike.AddOrUpdate(entity);
                ctx.SaveChanges();
                // 行级排他锁结束
                return(new
                {
                    success = true,
                    message = "操作成功"
                });
            }
        }
    }