示例#1
0
        /// <summary>
        /// 公共注册
        /// </summary>
        /// <param name="mo">个人用户信息</param>
        /// <returns></returns>
        private SharedResultVM RegisterUser(Domain.UserInfo mo)
        {
            var vm = new SharedResultVM();

            var isok = true;

            //邮箱注册
            if (!string.IsNullOrWhiteSpace(mo.UserMail))
            {
                isok = !db.UserInfo.Any(x => x.UserName == mo.UserName || x.UserMail == mo.UserMail);

                vm.Set(SharedEnum.RTag.exist);
                vm.Msg = "该邮箱已经注册";
            }
            else
            {
                isok = !db.UserInfo.Any(x => x.UserName == mo.UserName);

                vm.Set(SharedEnum.RTag.exist);
                vm.Msg = "该账号已经注册";
            }

            if (isok)
            {
                db.UserInfo.Add(mo);
                int num = db.SaveChanges();
                vm.Set(num > 0);
            }

            return(vm);
        }
示例#2
0
        public SharedResultVM DelCatalog(string code, string id)
        {
            var vm = new SharedResultVM();

            var uinfo = Apps.LoginService.Get(HttpContext);

            var ds = db.DocSet.Find(code);

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

            var listdsd    = db.DocSetDetail.Where(x => x.DsCode == code && string.IsNullOrEmpty(x.DsdContentMd)).ToList();
            var removelist = Core.TreeTo.FindToTree(listdsd, "DsdPid", "DsdId", new List <string> {
                id
            });

            removelist.Add(listdsd.FirstOrDefault(x => x.DsdId == id));
            db.DocSetDetail.RemoveRange(removelist);

            int num = db.SaveChanges();

            vm.Set(num > 0);

            return(vm);
        }
示例#3
0
        public SharedResultVM AboutServerStatus()
        {
            var vm = new SharedResultVM();

            try
            {
                var ckss = "Global_SystemStatus";
                if (CacheTo.Get(ckss) is not SystemStatusTo ss)
                {
                    ss = new SystemStatusTo();
                    CacheTo.Set(ckss, ss, 10, false);
                }

                vm.Log.Add(ss);
                vm.Data = ss.ToView();
                vm.Set(SharedEnum.RTag.success);
            }
            catch (Exception ex)
            {
                vm.Set(ex);
                ConsoleTo.Log(ex);
            }

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

            if (db.SysUser.Where(x => x.SrId == id).Any())
            {
                vm.Set(SharedEnum.RTag.exist);
            }
            else
            {
                var mo = db.SysRole.Find(id);
                db.SysRole.Remove(mo);

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

                vm.Set(num > 0);
            }

            return(vm);
        }
示例#5
0
文件: MailService.cs 项目: netnr/blog
        /// <summary>
        /// 发送邮件
        /// </summary>
        /// <param name="ToMail">送达邮件地址</param>
        /// <param name="Title">标题</param>
        /// <param name="Content">内容</param>
        /// <returns></returns>
        public static SharedResultVM Send(string ToMail, string Title, string Content)
        {
            var vm = new SharedResultVM();

            try
            {
                var message = new MimeMessage();
                message.From.Add(MailboxAddress.Parse(GlobalTo.GetValue("MailKit:FromAddress")));
                message.To.Add(MailboxAddress.Parse(ToMail));
                message.Subject = Title;
                message.Body    = new BodyBuilder()
                {
                    HtmlBody = Content
                }.ToMessageBody();

                using var client = new SmtpClient
                      {
                          ServerCertificateValidationCallback = (s, c, h, e) => true
                      };
                client.Connect(GlobalTo.GetValue("MailKit:Host"), GlobalTo.GetValue <int>("MailKit:Port"), true);
                client.Authenticate(GlobalTo.GetValue("MailKit:Auth:UserName"), GlobalTo.GetValue("MailKit:Auth:Password"));
                client.Send(message);
                client.Disconnect(true);

                vm.Set(SharedEnum.RTag.success);
            }
            catch (Exception ex)
            {
                vm.Set(ex);
            }

            return(vm);
        }
示例#6
0
        public SharedResultVM ReplyAdd([FromForm] Domain.UserReply mo, [FromForm] string id)
        {
            var vm = new SharedResultVM();

            try
            {
                if (string.IsNullOrWhiteSpace(id))
                {
                    vm.Set(SharedEnum.RTag.invalid);
                }
                else if (string.IsNullOrWhiteSpace(mo.UrContent))
                {
                    vm.Set(SharedEnum.RTag.invalid);
                    vm.Msg = "回复内容不能为空";
                }
                else
                {
                    vm = Apps.LoginService.CompleteInfoValid(HttpContext);
                    if (vm.Code == 200)
                    {
                        var uinfo = Apps.LoginService.Get(HttpContext);

                        var guffmo = db.GuffRecord.Find(id);
                        if (guffmo == null)
                        {
                            vm.Set(SharedEnum.RTag.invalid);
                        }
                        else
                        {
                            mo.Uid          = uinfo.UserId;
                            mo.UrTargetType = Application.EnumService.ConnectionType.GuffRecord.ToString();
                            mo.UrTargetId   = id;
                            mo.UrCreateTime = DateTime.Now;
                            mo.UrStatus     = 1;
                            mo.UrTargetPid  = 0;

                            mo.UrAnonymousLink = ParsingTo.JsSafeJoin(mo.UrAnonymousLink);

                            db.UserReply.Add(mo);

                            guffmo.GrReplyNum += 1;
                            db.GuffRecord.Update(guffmo);

                            int num = db.SaveChanges();
                            vm.Set(num > 0);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                vm.Set(ex);
                Apps.FilterConfigs.WriteLog(HttpContext, ex);
            }

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

            //明细反序列化为对象
            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);
        }
示例#8
0
        public SharedResultVM CopySysRoleAuth(SysRole mo, string copyid)
        {
            var vm = new SharedResultVM();

            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);
        }
示例#9
0
        public SharedResultVM DelSysMenu(string id)
        {
            var vm = new SharedResultVM();

            var ids = new List <string> {
                id
            };

            do
            {
                var listMo = db.SysMenu.Where(x => ids.Contains(x.SmId)).ToList();
                if (listMo.Count > 0)
                {
                    db.SysMenu.RemoveRange(listMo);

                    var childMo = db.SysMenu.Where(x => ids.Contains(x.SmPid)).ToList();
                    ids = childMo.Select(x => x.SmId).ToList();
                }
                else
                {
                    ids.Clear();
                }
            } while (ids.Count > 0);

            int num = db.SaveChanges();

            vm.Set(num > 0);

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

            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);
        }
示例#11
0
        /// <summary>
        /// 保存一条回复(管理)
        /// </summary>
        /// <param name="mo"></param>
        /// <returns></returns>
        public SharedResultVM ReplyAdminSave(Domain.UserReply mo)
        {
            var vm = new SharedResultVM();

            var uinfo = Apps.LoginService.Get(HttpContext);

            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);
        }
示例#12
0
        /// <summary>
        /// 保存一篇文章(管理)
        /// </summary>
        /// <param name="mo"></param>
        /// <returns></returns>
        public SharedResultVM WriteAdminSave(Domain.UserWriting mo)
        {
            var vm = new SharedResultVM();

            var uinfo = Apps.LoginService.Get(HttpContext);

            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);
        }
示例#13
0
        public SharedResultVM SaveSysButton(SysButton mo, string savetype)
        {
            var vm = new SharedResultVM();

            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);
        }
示例#14
0
        public SharedResultVM SaveConfigForm(string rows, string tablename)
        {
            var vm = new SharedResultVM();

            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.FirstOrDefault(x => x.ColField == field);

                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);
        }
示例#15
0
        public SharedResultVM SaveConfigTable(string rows, string tablename)
        {
            var vm = new SharedResultVM();

            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.FirstOrDefault(x => x.Id == id);

                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);
        }
示例#16
0
        public SharedResultVM ListUserConn(int a)
        {
            var vm = new SharedResultVM();

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

            var uinfo = Apps.LoginService.Get(HttpContext);

            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         = 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);
        }
示例#17
0
        /// <summary>
        /// 信息完整
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        public static SharedResultVM CompleteInfoValid(HttpContext context)
        {
            var vm = new SharedResultVM();

            if (!context.User.Identity.IsAuthenticated)
            {
                vm.Log.Add("先登录");
            }
            else
            {
                if (GlobalTo.GetValue <bool>("Common:CompleteInfo"))
                {
                    var uinfo = Get(context);

                    if (string.IsNullOrWhiteSpace(uinfo.Nickname))
                    {
                        vm.Log.Add("填写昵称");
                    }

                    using var db = Data.ContextBaseFactory.CreateDbContext();
                    var umo = db.UserInfo.Find(uinfo.UserId);

                    if (umo.UserId != GlobalTo.GetValue <int>("Common:AdminId"))
                    {
                        if (umo.UserMailValid != 1)
                        {
                            vm.Log.Add("验证邮箱");
                        }

                        if (string.IsNullOrWhiteSpace(umo.UserPhone) || umo.UserPhone.Trim().Length != 11)
                        {
                            vm.Log.Add("填写手机号码");
                        }

                        if (string.IsNullOrWhiteSpace(umo.OpenId1) &&
                            string.IsNullOrWhiteSpace(umo.OpenId2) &&
                            string.IsNullOrWhiteSpace(umo.OpenId3) &&
                            string.IsNullOrWhiteSpace(umo.OpenId4) &&
                            string.IsNullOrWhiteSpace(umo.OpenId5) &&
                            string.IsNullOrWhiteSpace(umo.OpenId6))
                        {
                            vm.Log.Add("绑定一项授权关联");
                        }

                        if (umo.UserCreateTime.Value.AddDays(15) > DateTime.Now)
                        {
                            vm.Log.Add("新注册用户需 15 天以后才能操作");
                        }
                    }
                }
            }

            vm.Set(vm.Log.Count == 0);
            vm.Msg = string.Join("、", vm.Log);

            return(vm);
        }
示例#18
0
        public async Task <SharedResultVM> WebHook()
        {
            var vm = new SharedResultVM();

            try
            {
                if (Request.Method == "POST")
                {
                    using var ms = new MemoryStream();
                    await Request.Body.CopyToAsync(ms);

                    string postStr = Encoding.UTF8.GetString(ms.ToArray());
                    Console.WriteLine(postStr);

                    //TO DO
                    var jo          = postStr.ToJObject();
                    var respName    = jo["repository"]["name"].ToString();
                    var projectPath = $"/package/site/{respName}";
                    if (Directory.Exists(projectPath) && Directory.Exists(Path.Combine(projectPath, ".git")))
                    {
                        var arg = $"git -C \"{projectPath}\" pull --all";
                        Console.WriteLine(arg);
                        var cr = CmdTo.Execute(arg);
                        var rt = cr.CrOutput + cr.CrError;
                        Console.WriteLine(rt);
                        vm.Log.AddRange(rt.Split('\n'));
                    }
                    else
                    {
                        var errorMsg = $"{projectPath} Not Exists(.git)";
                        Console.WriteLine(errorMsg);
                        vm.Log.Add(errorMsg);
                    }

                    vm.Set(SharedEnum.RTag.success);
                }
            }
            catch (Exception ex)
            {
                vm.Set(ex);
            }

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

            try
            {
                using var db = ContextBaseFactory.CreateDbContext();

                //处理Guff查询记录数
                var ctype  = EnumService.ConnectionType.GuffRecord.ToString();
                var listOr = db.OperationRecord.Where(x => x.OrType == ctype && x.OrMark == "default").ToList();
                if (listOr.Count > 0)
                {
                    var listAllId = string.Join(",", listOr.Select(x => x.OrSource).ToList()).Split(',').ToList();
                    var listid    = listAllId.Distinct();

                    var listmo = db.GuffRecord.Where(x => listid.Contains(x.GrId)).ToList();
                    foreach (var item in listmo)
                    {
                        item.GrReadNum += listAllId.GroupBy(x => x).FirstOrDefault(x => x.Key == item.GrId).Count();
                    }
                    db.GuffRecord.UpdateRange(listmo);

                    db.OperationRecord.RemoveRange(listOr);

                    int num = db.SaveChanges();

                    vm.Set(num > 0);
                    vm.Data = "处理操作记录,受影响行数:" + num;
                }
                else
                {
                    vm.Set(SharedEnum.RTag.lack);
                }
            }
            catch (Exception ex)
            {
                vm.Set(ex);
            }

            return(vm);
        }
示例#20
0
        public SharedResultVM SaveSysUser(SysUser mo, string savetype, string OldUserPwd)
        {
            var vm = new SharedResultVM();

            if (savetype == "add")
            {
                if (db.SysUser.Where(x => x.SuName == mo.SuName).Any())
                {
                    vm.Set(SharedEnum.RTag.exist);
                }
                else
                {
                    mo.SuId         = Guid.NewGuid().ToString();
                    mo.SuCreateTime = DateTime.Now;
                    mo.SuPwd        = Core.CalcTo.MD5(mo.SuPwd);
                    db.SysUser.Add(mo);
                }
            }
            else
            {
                if (db.SysUser.Where(x => x.SuName == mo.SuName && x.SuId != mo.SuId).Any())
                {
                    vm.Set(SharedEnum.RTag.exist);
                }
                else
                {
                    if (mo.SuPwd != OldUserPwd)
                    {
                        mo.SuPwd = Core.CalcTo.MD5(mo.SuPwd);
                    }
                    db.SysUser.Update(mo);
                }
            }

            int num = db.SaveChanges();

            vm.Set(num > 0);

            return(vm);
        }
示例#21
0
        public SharedResultVM SaveDocSet(Domain.DocSet mo)
        {
            var vm = new SharedResultVM();

            var uinfo = Apps.LoginService.Get(HttpContext);

            if (string.IsNullOrWhiteSpace(mo.DsCode))
            {
                mo.DsCode       = Core.UniqueTo.LongId().ToString();
                mo.Uid          = uinfo.UserId;
                mo.DsStatus     = 1;
                mo.DsCreateTime = DateTime.Now;

                db.DocSet.Add(mo);

                var num = db.SaveChanges();
                vm.Set(num > 0);
            }
            else
            {
                var currmo = db.DocSet.Find(mo.DsCode);
                if (currmo.Uid != uinfo.UserId)
                {
                    vm.Set(SharedEnum.RTag.unauthorized);
                }
                else
                {
                    currmo.DsName   = mo.DsName;
                    currmo.DsRemark = mo.DsRemark;
                    currmo.DsOpen   = mo.DsOpen;
                    currmo.Spare1   = mo.Spare1;

                    db.DocSet.Update(currmo);

                    var num = db.SaveChanges();
                    vm.Set(num > 0);
                }
            }
            return(vm);
        }
示例#22
0
        public SharedResultVM DelNote(int id)
        {
            var vm = new SharedResultVM();

            var uinfo = Apps.LoginService.Get(HttpContext);

            var mo = db.Notepad.Find(id);

            if (mo.Uid == uinfo.UserId)
            {
                db.Notepad.Remove(mo);
                int num = db.SaveChanges();

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

            return(vm);
        }
示例#23
0
        /// <summary>
        /// 根据控制器构建静态页面
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <returns></returns>
        public SharedResultVM Html <T>() where T : Controller
        {
            var vm = new SharedResultVM();

            try
            {
                //访问前缀
                var urlPrefix = $"{Context.Request.Scheme}://{Context.Request.Host}/home/";
                //保存目录
                var savePath = GlobalTo.WebRootPath + "/";

                //反射action
                var type    = typeof(T);
                var methods = type.GetMethods().Where(x => x.DeclaringType == type).ToList();

                vm.Log.Add($"Build Count:{methods.Count}");

                var cbs = new ConcurrentBag <string>();
                //并行请求
                Parallel.ForEach(methods, mh =>
                {
                    Console.WriteLine(mh.Name);

                    cbs.Add(mh.Name);
                    string html = HttpTo.Get(urlPrefix + mh.Name);
                    FileTo.WriteText(html, savePath + mh.Name.ToLower() + ".html", false);
                });
                vm.Log.AddRange(cbs);
                Console.WriteLine("\nDone!\n");

                vm.Set(SharedEnum.RTag.success);
            }
            catch (Exception ex)
            {
                vm.Set(ex);
            }

            return(vm);
        }
示例#24
0
        public SharedResultVM MenuTree()
        {
            var vm = new SharedResultVM();

            try
            {
                var code = RouteData.Values["id"]?.ToString();

                var list = db.DocSetDetail.Where(x => x.DsCode == code).OrderBy(x => x.DsdOrder).Select(x => new
                {
                    x.DsdId,
                    x.DsdPid,
                    x.DsdTitle,
                    x.DsdOrder,
                    IsCatalog = string.IsNullOrEmpty(x.DsdContentMd)
                }).ToList();

                var listtree = Core.TreeTo.ListToTree(list, "DsdPid", "DsdId", new List <string> {
                    Guid.Empty.ToString()
                });
                if (string.IsNullOrWhiteSpace(listtree))
                {
                    vm.Set(SharedEnum.RTag.lack);
                }
                else
                {
                    vm.Data = listtree.ToJArray();
                    vm.Set(SharedEnum.RTag.success);
                }
            }
            catch (Exception ex)
            {
                vm.Set(ex);
                Apps.FilterConfigs.WriteLog(HttpContext, ex);
            }

            return(vm);
        }
示例#25
0
        public SharedResultVM DelSysTableConfig(string id)
        {
            var vm = new SharedResultVM();

            var mo = db.SysTableConfig.Find(id);

            db.SysTableConfig.Remove(mo);

            int num = db.SaveChanges();

            vm.Set(num > 0);

            return(vm);
        }
示例#26
0
        public IActionResult DelMessage()
        {
            var vm = new SharedResultVM();

            var id = RouteData.Values["id"]?.ToString();

            if (!string.IsNullOrWhiteSpace(id))
            {
                var uinfo = Apps.LoginService.Get(HttpContext);

                var um = db.UserMessage.Find(id);
                if (um == null)
                {
                    vm.Set(SharedEnum.RTag.lack);
                }
                else if (um?.Uid != uinfo.UserId)
                {
                    vm.Set(SharedEnum.RTag.unauthorized);
                }
                else
                {
                    db.UserMessage.Remove(um);
                    int num = db.SaveChanges();

                    vm.Set(num > 0);
                }
            }

            if (vm.Code == 200)
            {
                return(Redirect("/user/message"));
            }
            else
            {
                return(Content(vm.ToJson()));
            }
        }
示例#27
0
        public SharedResultVM QueryNoteOne(int id)
        {
            var vm = new SharedResultVM();

            var uinfo = Apps.LoginService.Get(HttpContext);

            var mo = db.Notepad.Find(id);

            if (mo == null)
            {
                vm.Set(SharedEnum.RTag.invalid);
            }
            else if (mo.Uid == uinfo.UserId)
            {
                vm.Set(SharedEnum.RTag.success);
                vm.Data = mo;
            }
            else
            {
                vm.Set(SharedEnum.RTag.unauthorized);
            }

            return(vm);
        }
示例#28
0
    /// <summary>
    /// 入口
    /// </summary>
    /// <param name="tdb"></param>
    /// <param name="conn"></param>
    /// <param name="databaseName"></param>
    /// <param name="dkCall"></param>
    /// <returns></returns>
    static SharedResultVM Entry(SharedEnum.TypeDB tdb, string conn, string databaseName, Func <DataKit, object> dkCall)
    {
        var vm = new SharedResultVM();

        try
        {
            var dk = DataKit.Init(tdb, conn, databaseName);
            if (dk != null)
            {
                vm.Data = dkCall(dk);
                vm.Set(SharedEnum.RTag.success);
            }
            else
            {
                vm.Set(SharedEnum.RTag.error);
            }
        }
        catch (Exception ex)
        {
            vm.Set(ex);
        }

        return(vm);
    }
示例#29
0
        public SharedResultVM DelSysDictionary(string id)
        {
            var vm = new SharedResultVM();

            var mo = db.SysDictionary.Find(id);

            mo.SdStatus = -1;
            db.SysDictionary.Update(mo);

            int num = db.SaveChanges();

            vm.Set(num > 0);

            return(vm);
        }
示例#30
0
        public SharedResultVM UpdateUserSay(Domain.UserInfo mo)
        {
            var vm = new SharedResultVM();

            var uinfo = Apps.LoginService.Get(HttpContext);

            var currmo = db.UserInfo.Find(uinfo.UserId);

            currmo.UserSay = mo.UserSay;
            db.UserInfo.Update(currmo);

            int num = db.SaveChanges();

            vm.Set(num > 0);

            return(vm);
        }