示例#1
0
        public ActionResultVM SaveConfigTable(string rows, string tablename)
        {
            var vm = new ActionResultVM();

            JArray ja = JArray.Parse(rows);

            var listRow = db.SysTableConfig.Where(x => x.TableName == tablename).ToList();

            int order = 0;

            foreach (JToken jt in ja)
            {
                string id = jt["Id"].ToString();

                var mo = listRow.Where(x => x.Id == id).FirstOrDefault();

                mo.ColTitle  = jt["ColTitle"].ToStringOrEmpty();
                mo.ColAlign  = string.IsNullOrWhiteSpace(jt["ColAlign"].ToStringOrEmpty()) ? 1 : Convert.ToInt32(jt["ColAlign"].ToStringOrEmpty());
                mo.ColWidth  = string.IsNullOrWhiteSpace(jt["ColWidth"].ToStringOrEmpty()) ? 0 : Convert.ToInt32(jt["ColWidth"].ToStringOrEmpty());
                mo.ColHide   = string.IsNullOrWhiteSpace(jt["ColHide"].ToStringOrEmpty()) ? 0 : Convert.ToInt32(jt["ColHide"].ToStringOrEmpty());
                mo.ColFrozen = string.IsNullOrWhiteSpace(jt["ColFrozen"].ToStringOrEmpty()) ? 0 : Convert.ToInt32(jt["ColFrozen"].ToStringOrEmpty());
                mo.ColExport = string.IsNullOrWhiteSpace(jt["ColExport"].ToStringOrEmpty()) ? 0 : Convert.ToInt32(jt["ColExport"].ToStringOrEmpty());
                mo.ColOrder  = order++;
            }

            db.SysTableConfig.UpdateRange(listRow);
            int num = db.SaveChanges();

            vm.Set(num > 0);

            return(vm);
        }
示例#2
0
        public ActionResultVM SaveConfigForm(string rows, string tablename)
        {
            var vm = new ActionResultVM();

            JArray ja = JArray.Parse(rows);

            var listRow = db.SysTableConfig.Where(x => x.TableName == tablename).ToList();

            int order = 0;

            foreach (JToken jt in ja)
            {
                string field = jt["field"].ToStringOrEmpty();
                var    mo    = listRow.Where(x => x.ColField == field).FirstOrDefault();

                mo.ColTitle  = jt["title"].ToStringOrEmpty();
                mo.FormSpan  = string.IsNullOrWhiteSpace(jt["span"].ToStringOrEmpty()) ? 1 : Convert.ToInt32(jt["span"].ToStringOrEmpty());
                mo.FormArea  = string.IsNullOrWhiteSpace(jt["area"].ToStringOrEmpty()) ? 0 : Convert.ToInt32(jt["area"].ToStringOrEmpty());
                mo.FormOrder = order++;
            }

            db.SysTableConfig.UpdateRange(listRow);
            int num = db.SaveChanges();

            vm.Set(num > 0);

            return(vm);
        }
示例#3
0
        public ActionResultVM SaveSysMenu(SysMenu mo, string savetype)
        {
            var vm = new ActionResultVM();

            if (string.IsNullOrWhiteSpace(mo.SmPid))
            {
                mo.SmPid = Guid.Empty.ToString();
            }
            using (var db = new ContextBase())
            {
                if (savetype == "add")
                {
                    mo.SmId = Guid.NewGuid().ToString();
                    db.SysMenu.Add(mo);
                }
                else
                {
                    db.SysMenu.Update(mo);
                }
                int num = db.SaveChanges();

                vm.Set(num > 0);
            }

            //清理缓存
            Core.CacheTo.Remove(Func.Common.GlobalCacheKey.SysMenu);

            return(vm);
        }
示例#4
0
        public ActionResultVM GetOnlineAllUser()
        {
            var vm = new ActionResultVM();

            try
            {
                vm.Data = ccs.OnlineUser2;
                vm.Set(ARTag.success);
            }
            catch (Exception ex)
            {
                vm.Set(ex);
            }

            return(vm);
        }
示例#5
0
        public ActionResultVM CopySysRoleAuth(SysRole mo, string copyid)
        {
            var vm = new ActionResultVM();

            var list   = db.SysRole.Where(x => x.SrId == mo.SrId || x.SrId == copyid).ToList();
            var copymo = list.Find(x => x.SrId == copyid);

            foreach (var item in list)
            {
                item.SrMenus   = copymo.SrMenus;
                item.SrButtons = copymo.SrButtons;
            }
            db.SysRole.UpdateRange(list);

            int num = db.SaveChanges();

            if (num > 0)
            {
                //清理缓存
                Core.CacheTo.Remove(Application.CommonService.GlobalCacheKey.SysRole);
            }

            vm.Set(num > 0);

            return(vm);
        }
示例#6
0
        public ActionResultVM AddTag(string tagName)
        {
            var vm = new ActionResultVM();

            if (string.IsNullOrWhiteSpace(tagName))
            {
                vm.msg  = "标签名不可为空值";
                vm.code = -1;
                return(vm);
            }
            else
            {
                var uinfo = new Func.UserAuthAid(HttpContext).Get();

                var  now    = DateTime.Now;
                Tags newtag = new Tags()
                {
                    createTime = now,
                    updateTime = now,
                    TagName    = tagName,
                    TagOwner   = uinfo.UserId,
                    TagStatus  = 1
                };

                _context.Tags.Add(newtag);

                int num = _context.SaveChanges();
                vm.Set(num > 0);
                vm.data = newtag.TagName;
            }

            return(vm);
        }
示例#7
0
        public ActionResultVM SaveSysRole(SysRole mo, string savetype)
        {
            var vm = new ActionResultVM();

            if (savetype == "add")
            {
                mo.SrId         = Guid.Empty.ToString();
                mo.SrCreateTime = DateTime.Now;
                db.SysRole.Add(mo);
            }
            else
            {
                db.SysRole.Update(mo);
            }

            int num = db.SaveChanges();

            if (num > 0)
            {
                //清理缓存
                Core.CacheTo.Remove(Application.CommonService.GlobalCacheKey.SysRole);
            }

            vm.Set(num > 0);

            return(vm);
        }
示例#8
0
        public ActionResultVM GetToken(string AppId, string AppKey)
        {
            var vm = new ActionResultVM();

            try
            {
                if (string.IsNullOrWhiteSpace(AppId) || string.IsNullOrWhiteSpace(AppKey))
                {
                    vm.Set(ARTag.lack);
                    vm.msg = "参数缺失";
                }
                else
                {
                    if (!(Core.CacheTo.Get(AppKey) is ActionResultVM cvm))
                    {
                        vm = SQLiteBase.GetToken(AppId, AppKey);

                        if (vm.code == 200)
                        {
                            //Token缓存
                            Core.CacheTo.Set(AppKey, vm, GlobalTo.GetValue <int>("Safe:TokenCache"), false);
                        }
                    }
                    else
                    {
                        vm = cvm;
                    }
                }
示例#9
0
        /// <summary>
        /// 保存为JSON文件
        /// </summary>
        /// <param name="CoverJson">写入JSON文件,默认 false</param>
        /// <returns></returns>
        public ActionResultVM SaveAsJson(bool CoverJson = false)
        {
            var vm = new ActionResultVM();

            var dicKey = new Dictionary <string, object>
            {
                { "SysButton", Tsb.ToList() },
                { "SysDictionary", Tsd.ToList() },
                { "SysMenu", Tsm.ToList() },
                { "SysRole", Tsr.ToList() },
                { "SysTableConfig", Tstc.ToList() },
                { "SysUser", Tsu.ToList() },

                { "TempExample", Tte.ToList() },
                { "TempInvoiceDetail", Ttid.ToList() },
                { "TempInvoiceMain", Ttim.ToList() }
            };

            vm.Data = dicKey;

            if (CoverJson)
            {
                Core.FileTo.WriteText(vm.ToJson(), fullJsonData, false);
            }

            vm.Set(ARTag.success);

            return(vm);
        }
示例#10
0
        public ActionResultVM ExecTask(string id)
        {
            var vm = new ActionResultVM();

            if (string.IsNullOrWhiteSpace(id))
            {
                id = RouteData.Values["id"]?.ToString();
            }

            switch (id?.ToLower())
            {
            default:
                vm.Set(ARTag.invalid);
                break;

            //备份数据库
            case "backup":
                vm = Func.TaskAid.BackupDataBase();
                break;

            //替换链接
            case "replacelink":
                vm = Func.TaskAid.ReplaceLink();
                break;

            //Gist同步
            case "gistsync":
                vm = Func.TaskAid.GistSync();
                break;
            }

            return(vm);
        }
示例#11
0
        public ActionResultVM ResetDataBaseForJson()
        {
            var vm = new ActionResultVM();

            try
            {
                //非内部调用 && 是爬虫
                if (HttpContext != null && new UserAgentTo(new ClientTo(HttpContext).UserAgent).IsBot)
                {
                    vm.Set(ARTag.refuse);
                    vm.Msg = "are you human?";
                }
                else
                {
                    //用户
                    vm = new Application.DataMirrorService().AddForJson();
                }
            }
            catch (Exception ex)
            {
                vm.Set(ex);
            }

            return(vm);
        }
示例#12
0
        /// <summary>
        /// 保存单据
        /// </summary>
        /// <param name="moMain"></param>
        /// <param name="rows"></param>
        /// <returns></returns>
        public ActionResultVM SaveInvoiceForm(TempInvoiceMain moMain, string rows)
        {
            var vm = new ActionResultVM();

            //明细反序列化为对象
            var listDetail = rows.ToEntitys <TempInvoiceDetail>();

            //新增,补齐主表信息
            var isadd = string.IsNullOrWhiteSpace(moMain.TimId);

            if (isadd)
            {
                moMain.TimId         = Guid.NewGuid().ToString();
                moMain.TimCreateTime = DateTime.Now;

                moMain.TimOwnerId   = Guid.Empty.ToString();
                moMain.TimOwnerName = "系统登录人员";
            }


            if (isadd)
            {
                db.TempInvoiceMain.Add(moMain);
            }
            else
            {
                db.TempInvoiceMain.Update(moMain);

                //更新时,删除原有明细
                var currDetail = db.TempInvoiceDetail.Where(x => x.TimId == moMain.TimId).ToList();
                if (currDetail.Count > 0)
                {
                    db.TempInvoiceDetail.RemoveRange(currDetail);
                }
            }

            //添加明细
            if (listDetail.Count > 0)
            {
                //初始值
                foreach (var item in listDetail)
                {
                    item.TidId = Guid.NewGuid().ToString();
                    item.TimId = moMain.TimId;
                }

                db.TempInvoiceDetail.AddRange(listDetail);
            }

            int num = db.SaveChanges();

            vm.Set(num > 0);

            if (isadd)
            {
                vm.Data = moMain.TimId;
            }

            return(vm);
        }
示例#13
0
        /// <summary>
        /// 保存一条回复(管理)
        /// </summary>
        /// <param name="mo"></param>
        /// <returns></returns>
        public ActionResultVM ReplyAdminSave(UserReply mo)
        {
            var vm = new ActionResultVM();

            var uinfo = new UserAuthAid(HttpContext).Get();

            using (var db = new ContextBase())
            {
                var oldmo = db.UserReply.FirstOrDefault(x => x.UrId == mo.UrId);

                if (oldmo != null)
                {
                    oldmo.UrAnonymousName = mo.UrAnonymousName;
                    oldmo.UrAnonymousMail = mo.UrAnonymousMail;
                    oldmo.UrAnonymousLink = mo.UrAnonymousLink;

                    oldmo.UrStatus = mo.UrStatus;

                    db.UserReply.Update(oldmo);

                    int num = db.SaveChanges();

                    vm.Set(num > 0);
                }
            }

            return(vm);
        }
示例#14
0
        /// <summary>
        /// 保存一篇文章(管理)
        /// </summary>
        /// <param name="mo"></param>
        /// <returns></returns>
        public ActionResultVM WriteAdminSave(UserWriting mo)
        {
            var vm = new ActionResultVM();

            var uinfo = new UserAuthAid(HttpContext).Get();

            using (var db = new ContextBase())
            {
                var oldmo = db.UserWriting.FirstOrDefault(x => x.UwId == mo.UwId);

                if (oldmo != null)
                {
                    oldmo.UwStatus   = mo.UwStatus;
                    oldmo.UwReplyNum = mo.UwReplyNum;
                    oldmo.UwReadNum  = mo.UwReadNum;
                    oldmo.UwLaud     = mo.UwLaud;
                    oldmo.UwMark     = mo.UwMark;
                    oldmo.UwOpen     = mo.UwOpen;

                    db.UserWriting.Update(oldmo);

                    int num = db.SaveChanges();

                    vm.Set(num > 0);
                }
            }

            return(vm);
        }
示例#15
0
        public ActionResultVM ListUserConn(int a)
        {
            var vm = new ActionResultVM();

            int wid = Convert.ToInt32(RouteData.Values["id"]?.ToString());

            var uinfo = new Application.UserAuthService(HttpContext).Get();

            using (var db = new ContextBase())
            {
                var uw = db.UserWriting.Find(wid);

                var uc = db.UserConnection.FirstOrDefault(x => x.Uid == uinfo.UserId && x.UconnTargetId == wid.ToString() && x.UconnAction == a);
                if (uc == null)
                {
                    uc = new UserConnection()
                    {
                        UconnId         = Core.UniqueTo.LongId().ToString(),
                        UconnAction     = a,
                        UconnCreateTime = DateTime.Now,
                        UconnTargetId   = wid.ToString(),
                        UconnTargetType = Application.EnumService.ConnectionType.UserWriting.ToString(),
                        Uid             = uinfo.UserId
                    };
                    db.UserConnection.Add(uc);
                    if (a == 1)
                    {
                        uw.UwLaud += 1;
                    }
                    if (a == 2)
                    {
                        uw.UwMark += 1;
                    }
                    db.UserWriting.Update(uw);

                    vm.Data = "1";
                }
                else
                {
                    db.UserConnection.Remove(uc);
                    if (a == 1)
                    {
                        uw.UwLaud -= 1;
                    }
                    if (a == 2)
                    {
                        uw.UwMark -= 1;
                    }
                    db.UserWriting.Update(uw);

                    vm.Data = "0";
                }

                int num = db.SaveChanges();

                vm.Set(num > 0);
            }

            return(vm);
        }
示例#16
0
        /// <summary>
        /// 批量新增
        /// </summary>
        /// <returns></returns>
        private ActionResultVM BulkInsert()
        {
            var vm = new ActionResultVM();

            var list = new List <SysLog>();

            for (int i = 0; i < 50_000; i++)
            {
                var mo = new SysLog()
                {
                    LogId          = Guid.NewGuid().ToString(),
                    LogAction      = "/",
                    LogBrowserName = "Chrome",
                    LogArea        = "重庆",
                    LogContent     = "测试信息",
                    LogCreateTime  = vm.StartTime,
                    LogGroup       = 1,
                    LogIp          = "0.0.0.0",
                    LogSystemName  = "Win10",
                    LogUrl         = Request.Path,
                    SuName         = "netnr",
                    SuNickname     = "netnr",
                    LogRemark      = "无"
                };
                list.Add(mo);
            }

            db.SysLog.BulkInsert(list);

            db.BulkSaveChanges();

            vm.Set(ARTag.success);

            return(vm);
        }
示例#17
0
        public ActionResultVM LsitReplySave(UserReply mo, UserMessage um)
        {
            var vm = new ActionResultVM();

            var now = DateTime.Now;

            if (HttpContext.User.Identity.IsAuthenticated)
            {
                mo.Uid = new Func.UserAuthAid(HttpContext).Get().UserId;
            }
            else
            {
                mo.Uid = 0;
            }

            //回复消息
            um.UmId         = Core.UniqueTo.LongId().ToString();
            um.UmTriggerUid = mo.Uid;
            um.UmType       = Func.EnumAid.MessageType.UserWriting.ToString();
            um.UmTargetId   = mo.UrTargetId;
            um.UmAction     = 2;
            um.UmStatus     = 1;
            um.UmContent    = mo.UrContent;
            um.UmCreateTime = now;


            using (var db = new ContextBase())
            {
                //回复内容
                mo.UrCreateTime = now;
                mo.UrStatus     = 1;
                mo.UrTargetPid  = 0;
                mo.UrTargetType = Func.EnumAid.ReplyType.UserWriting.ToString();

                db.UserReply.Add(mo);

                //回填文章最新回复记录
                var mow = db.UserWriting.FirstOrDefault(x => x.UwId.ToString() == mo.UrTargetId);
                if (mow != null)
                {
                    mow.UwReplyNum += 1;
                    mow.UwLastUid   = mo.Uid;

                    um.UmTargetIndex = mow.UwReplyNum;

                    db.UserWriting.Update(mow);
                }

                if (um.Uid != um.UmTriggerUid)
                {
                    db.UserMessage.Add(um);
                }

                int num = db.SaveChanges();

                vm.Set(num > 0);
            }

            return(vm);
        }
示例#18
0
        public ActionResultVM SaveSysButton(SysButton mo, string savetype)
        {
            var vm = new ActionResultVM();

            if (string.IsNullOrWhiteSpace(mo.SbPid))
            {
                mo.SbPid = Guid.Empty.ToString();
            }
            if (mo.SbBtnHide == null)
            {
                mo.SbBtnHide = -1;
            }

            if (savetype == "add")
            {
                mo.SbId = Guid.NewGuid().ToString();
                db.SysButton.Add(mo);
            }
            else
            {
                db.SysButton.Update(mo);
            }

            int num = db.SaveChanges();

            vm.Set(num > 0);

            //清理缓存
            Core.CacheTo.Remove(Application.CommonService.GlobalCacheKey.SysButton);

            return(vm);
        }
示例#19
0
        public ActionResultVM QueryServerInfo()
        {
            var vm = new ActionResultVM();

            try
            {
                vm.data = new Fast.OSInfoTo();
                vm.Set(ARTag.success);
            }
            catch (Exception ex)
            {
                vm.Set(ex);
                Core.ConsoleTo.Log(ex);
            }

            return(vm);
        }
示例#20
0
        public ActionResultVM SaveCatalog(DocSetDetail mo)
        {
            var vm = new ActionResultVM();

            var uinfo = new Application.UserAuthService(HttpContext).Get();

            using var db = new ContextBase();
            var ds = db.DocSet.Find(mo.DsCode);

            if (ds?.Uid != uinfo.UserId)
            {
                vm.Set(ARTag.unauthorized);
                return(vm);
            }

            mo.DsdOrder ??= 99;
            mo.DsdUpdateTime = DateTime.Now;
            if (string.IsNullOrWhiteSpace(mo.DsdPid))
            {
                mo.DsdPid = Guid.Empty.ToString();
            }

            if (string.IsNullOrWhiteSpace(mo.DsdId))
            {
                mo.DsdId         = Guid.NewGuid().ToString();
                mo.DsdCreateTime = mo.DsdUpdateTime;
                mo.Uid           = uinfo.UserId;


                db.DocSetDetail.Add(mo);
            }
            else
            {
                var currmo = db.DocSetDetail.Where(x => x.DsdId == mo.DsdId).FirstOrDefault();
                currmo.DsdTitle = mo.DsdTitle;
                currmo.DsdOrder = mo.DsdOrder;
                currmo.DsdPid   = mo.DsdPid;

                db.DocSetDetail.Update(currmo);
            }
            int num = db.SaveChanges();

            vm.Set(num > 0);

            return(vm);
        }
示例#21
0
        /// <summary>
        /// 创建FixToken
        /// </summary>
        /// <param name="AppId">分配的应用ID</param>
        /// <param name="AppKey">分配的应用密钥</param>
        /// <param name="Name">名称</param>
        /// <param name="AuthMethod">授权接口</param>
        /// <returns></returns>
        public static ActionResultVM CreateFixToken(string AppId, string AppKey, string Name, string AuthMethod)
        {
            var vm = new ActionResultVM();

            try
            {
                using var db = new SQLiteConnection(SQLiteConn);
                var sk = db.Table <SysApp>().FirstOrDefault(x => x.AppId == AppId && x.AppKey == AppKey);
                if (sk != null)
                {
                    var listmo = new List <FixTokenJson>();
                    if (!string.IsNullOrWhiteSpace(sk.FixToken))
                    {
                        listmo = sk.FixToken.ToEntitys <FixTokenJson>();
                    }

                    var fixToken = NewToken(true);
                    listmo.Add(new FixTokenJson()
                    {
                        Name       = Name,
                        Token      = fixToken,
                        AuthMethod = AuthMethod,
                        CreateTime = DateTime.Now
                    });
                    sk.FixToken = listmo.ToJson();

                    int num = db.Update(sk);
                    vm.Data = new
                    {
                        Token = fixToken,
                        AuthMethod
                    };
                    vm.Set(num > 0);
                }
                else
                {
                    vm.Set(ARTag.unauthorized);
                }
            }
            catch (Exception ex)
            {
                vm.Set(ex);
            }

            return(vm);
        }
示例#22
0
        public ActionResultVM ResetDataBaseForJson()
        {
            var vm = new ActionResultVM();

            try
            {
                int num = new Func.DataMirrorAid().AddForJson();
                vm.Set(num > 0);
                vm.data = num;
            }
            catch (Exception ex)
            {
                vm.Set(ex);
            }

            return(vm);
        }
示例#23
0
        public ActionResultVM CreateApp(string owner, string password = "******")
        {
            var vm = new ActionResultVM();

            try
            {
                if (GlobalTo.GetValue <bool>("Safe:IsDev"))
                {
                    if (string.IsNullOrWhiteSpace(password) || password != GlobalTo.GetValue("Safe:CreateAppPassword"))
                    {
                        vm.Set(ARTag.unauthorized);
                        vm.Msg = "密码错误";
                    }
                    else if (string.IsNullOrWhiteSpace(owner))
                    {
                        vm.Set(ARTag.refuse);
                        vm.Msg = "owner 不能为空";
                    }
                    else if (new Regex(@"\W").Match(owner).Success)
                    {
                        vm.Msg = "owner 仅为字母、数字";
                    }
                    else
                    {
                        vm = FileServerService.CreateApp(owner);
                        if (vm.Code == -1 && vm.Msg.Contains("UNIQUE"))
                        {
                            vm.Set(ARTag.exist);
                            vm.Msg = "owner 用户已经存在";
                        }
                    }
                }
                else
                {
                    vm.Set(ARTag.refuse);
                }
            }
            catch (Exception ex)
            {
                vm.Set(ex);
                Core.ConsoleTo.Log(ex);
            }

            return(vm);
        }
示例#24
0
        public ActionResultVM SaveNote(Domain.Notepad mo)
        {
            var vm = new ActionResultVM();

            var uinfo = new Func.UserAuthAid(HttpContext).Get();

            using (var db = new ContextBase())
            {
                var now = DateTime.Now;
                if (mo.NoteId == 0)
                {
                    mo.NoteCreateTime = now;
                    mo.NoteUpdateTime = now;
                    mo.Uid            = uinfo.UserId;

                    db.Notepad.Add(mo);

                    int num = db.SaveChanges();
                    vm.Set(num > 0);
                    vm.data = mo.NoteId;
                }
                else
                {
                    var currmo = db.Notepad.Find(mo.NoteId);
                    if (currmo.Uid == uinfo.UserId)
                    {
                        currmo.NoteTitle      = mo.NoteTitle;
                        currmo.NoteContent    = mo.NoteContent;
                        currmo.NoteUpdateTime = now;

                        db.Notepad.Update(currmo);

                        int num = db.SaveChanges();

                        vm.Set(num > 0);
                    }
                    else
                    {
                        vm.Set(ARTag.unauthorized);
                    }
                }
            }

            return(vm);
        }
示例#25
0
        /// <summary>
        /// 新增
        /// </summary>
        /// <param name="list"></param>
        public static ActionResultVM InsertFile(List <FileRecord> list)
        {
            var vm = new ActionResultVM();

            try
            {
                using var db = new SQLiteConnection(SQLiteConn);
                int num = db.InsertAll(list);

                vm.Set(num > 0);
            }
            catch (Exception ex)
            {
                vm.Set(ex);
            }

            return(vm);
        }
示例#26
0
        /// <summary>
        /// 更新
        /// </summary>
        /// <param name="model">实体</param>
        public static ActionResultVM UpdateFile(FileRecord model)
        {
            var vm = new ActionResultVM();

            try
            {
                using var db = new SQLiteConnection(SQLiteConn);

                int num = db.Update(model);
                vm.Set(num > 0);
            }
            catch (Exception ex)
            {
                vm.Set(ex);
            }

            return(vm);
        }
示例#27
0
        public ActionResultVM RepairTableConfig(string names)
        {
            var vm = new ActionResultVM();

            var listName = names.Split(',');

            if (string.IsNullOrWhiteSpace(names) || listName.Length == 0)
            {
                vm.code = 1;
                vm.msg  = "表名不能为空";
            }
            else
            {
                using var db = new ContextBase();
                var dbname      = db.Database.GetDbConnection().Database;
                var sqltemplate = QueryScripts(ContextBase.TDB.ToString(), "config");

                var listTc = db.SysTableConfig.ToList();

                foreach (var name in listName)
                {
                    var sql = sqltemplate.Replace("@DataBaseName", dbname).Replace("@TableName", name);

                    if (!string.IsNullOrWhiteSpace(sql))
                    {
                        var dt = new DataTable();

                        using (var dbsql = new ContextBase())
                        {
                            using var conn = dbsql.Database.GetDbConnection();
                            conn.Open();
                            var cmd = conn.CreateCommand();
                            cmd.CommandText = sql;
                            dt.Load(cmd.ExecuteReader());
                        }

                        foreach (DataRow dr in dt.Rows)
                        {
                            var tcmo = listTc.Where(x => x.TableName == dr["TableName"].ToString() && x.ColField == dr["ColField"].ToString()).FirstOrDefault();
                            tcmo.FormMaxlength = Convert.ToInt32(dr["FormMaxlength"]);
                            if (string.IsNullOrWhiteSpace(tcmo.ColRelation))
                            {
                                tcmo.ColRelation = "Equal,Contains";
                            }
                        }
                    }
                }

                db.SysTableConfig.UpdateRange(listTc);
                db.SaveChanges();

                vm.Set(ARTag.success);
            }

            return(vm);
        }
示例#28
0
        /// <summary>
        /// 获取App列表
        /// </summary>
        /// <param name="pageNumber">页码,默认1</param>
        /// <param name="pageSize">页量,默认20</param>
        /// <returns></returns>
        public static ActionResultVM GetAppList(int pageNumber = 1, int pageSize = 20)
        {
            var vm = new ActionResultVM();

            try
            {
                using var db = new SQLiteConnection(SQLiteConn);
                var sk = db.Table <SysKey>().OrderByDescending(x => x.SkCreateTime).Skip((pageNumber - 1) * pageSize).Take(pageSize).ToList();

                vm.Data = sk;
                vm.Set(ARTag.success);
            }
            catch (Exception ex)
            {
                vm.Set(ex);
            }

            return(vm);
        }
示例#29
0
        public ActionResultVM ResetAll(string password = "******")
        {
            var vm = new ActionResultVM();

            try
            {
                if (GlobalTo.GetValue <bool>("Safe:IsDev"))
                {
                    if (!string.IsNullOrWhiteSpace(password) && password == GlobalTo.GetValue("Safe:CreateAppPassword"))
                    {
                        //清空数据库
                        using var db = new SQLite.SQLiteConnection(FileServerService.SQLiteConn);
                        db.DeleteAll <SysKey>();
                        db.DeleteAll <FileRecord>();

                        //删除上传文件
                        var rootdir = GlobalTo.WebRootPath + GlobalTo.GetValue("StaticResource:RootDir");
                        if (Directory.Exists(rootdir))
                        {
                            Directory.Delete(rootdir, true);
                        }

                        vm.Set(ARTag.success);
                    }
                    else
                    {
                        vm.Set(ARTag.unauthorized);
                        vm.Msg = "密码错误";
                    }
                }
                else
                {
                    vm.Set(ARTag.refuse);
                }
            }
            catch (Exception ex)
            {
                vm.Set(ex);
                Core.ConsoleTo.Log(ex);
            }

            return(vm);
        }
示例#30
0
        public ActionResultVM DelSysRole(string id)
        {
            var vm = new ActionResultVM();

            if (db.SysUser.Where(x => x.SrId == id).Count() > 0)
            {
                vm.Set(ARTag.exist);
            }
            else
            {
                var mo = db.SysRole.Find(id);
                db.SysRole.Remove(mo);
                int num = db.SaveChanges();

                vm.Set(num > 0);
            }

            return(vm);
        }