Esempio n. 1
0
        public ResponsResult SaveIOS(IosVersion ios)
        {
            ResponsResult result = new ResponsResult();

            systemSettingService.SaveSettings(ios);
            return(result);
        }
        public ResponsResult GenSSign(string mobile, string code, int type)
        {
            var    apikey           = string.Empty;
            string WeChatApp_ApiKey = "23ACA89E-0169-44A1-8D08-64AD3EC4A551";
            string iOS_ApiKey       = "972F5D56-296B-4BD7-8CB6-49617A441A99";
            string Android_ApiKey   = "506DDE1D-4642-4859-9226-E26B098FC02B";

            if (type == 1)
            {
                apikey = WeChatApp_ApiKey;
            }
            else if (type == 2)
            {
                apikey = iOS_ApiKey;
            }
            else if (type == 3)
            {
                apikey = Android_ApiKey;
            }
            ResponsResult result = new ResponsResult
            {
                Data = Security.Sign(mobile, code, apikey)
            };

            return(result);
        }
Esempio n. 3
0
        /// <summary>
        /// 暂停指定任务计划
        /// </summary>
        /// <returns></returns>
        public async Task <ResponsResult> StopScheduleJobAsync(string jobGroup, string jobName)
        {
            ResponsResult result = new ResponsResult();

            try
            {
                scheduler = await GetSchedulerAsync();

                //使任务暂停
                await scheduler.PauseJob(new JobKey(jobName, jobGroup));

                var status = new StatusViewModel()
                {
                    Status = 0,
                    Msg    = "暂停任务计划成功",
                };
                result.Data = status.GetJson();
                return(result);
            }
            catch (Exception ex)
            {
                Log4Net.Error($"[JobCenter_StopScheduleJobAsync]_{ex}");
                var status = new StatusViewModel()
                {
                    Status = -1,
                    Msg    = "暂停任务计划失败",
                };
                result.Data = status.GetJson();
                return(result);
            }
        }
Esempio n. 4
0
        public ResponsResult GetSMSList(SmsSearchModel model)
        {
            ResponsResult result = new ResponsResult();
            var           query  = base.Query <SmsInfo>();

            if (!string.IsNullOrEmpty(model.IP))
            {
                query = query.Where(t => t.Ip.Contains(model.IP));
            }
            if (!string.IsNullOrEmpty(model.Mobile))
            {
                query = query.Where(t => t.Mobile.Contains(model.Mobile));
            }
            if (model.StartDate.HasValue)
            {
                query = query.Where(t => t.CreateTime >= model.StartDate);
            }
            if (model.EndDate.HasValue)
            {
                query = query.Where(t => t.CreateTime <= model.EndDate);
            }
            result.Data        = query.OrderByDescending(t => t.CreateTime).Pages(model.PageIndex, model.PageSize, out int count).ToList();
            result.RecordCount = count;
            return(result);
        }
Esempio n. 5
0
        public ResponsResult GetTaskList()
        {
            ResponsResult result = new ResponsResult();
            var           query  = base.Where <TaskSchedule>(t => !t.RunStatus.Equals(TaskJobStatus.JobHasDel)).Select(t => new
            {
                t.Id,
                t.JobGroup,
                t.JobName,
                t.RunStatus,
                t.StarRunTime,
                t.UpdateTime,
                t.CronExpress,
                t.EndRunTime,
                t.CreateTime
            }).ToList();
            List <TaskScheduleModel> _list = new List <TaskScheduleModel>();

            query.ForEach(t =>
            {
                _list.Add(new TaskScheduleModel()
                {
                    Id          = t.Id,
                    JobGroup    = t.JobGroup,
                    JobName     = t.JobName,
                    _RunStatus  = ((TaskJobStatus)t.RunStatus).GetString(),
                    StarRunTime = t.StarRunTime,
                    UpdateTime  = t.UpdateTime,
                    CronExpress = t.CronExpress,
                    EndRunTime  = t.EndRunTime,
                    CreateTime  = t.CreateTime
                });
            });
            result.Data = _list;
            return(result);
        }
Esempio n. 6
0
        /// <summary>
        /// 添加后台管理员
        /// </summary>
        /// <param name="model">AccountAdd</param>
        /// <returns></returns>
        public ResponsResult AddAccount(BackstageUserAdd model)
        {
            ResponsResult result  = new ResponsResult();
            BackstageUser account = this.First <BackstageUser>(t => t.LoginName == model.LoginName);

            if (account != null)
            {
                return(result.SetStatus(ErrorCode.NotFound, "登录名称已经存在!"));
            }
            else
            {
                account = new BackstageUser();
            }
            if (!MethordExtensions.IsIDCard(model.IdCard))
            {
                return(result.SetStatus(ErrorCode.InvalidData, "身份证非法!"));
            }
            model.Password = model.Password == "" ? "123456" : model.Password;
            string pwd = Security.MD5(model.Password);

            account.Id            = Guid.NewGuid().ToString("N");
            account.LoginName     = model.LoginName;
            account.FullName      = model.FullName;
            account.CreateTime    = DateTime.Now;
            account.AccountType   = (int)model.AccountType;
            account.RoleId        = (int)model.AccountType;
            account.Password      = pwd;
            account.Mobile        = model.Mobile;
            account.AccountStatus = (int)AccountStatus.Normal;
            account.SourceType    = (int)SourceType.Web;
            account.Gender        = model.Gender;
            account.IdCard        = model.IdCard;
            this.Add(account, true);
            return(result);
        }
Esempio n. 7
0
        public async Task <ResponsResult> DelTaskAsync(TaskScheduleModel model)
        {
            ResponsResult result = new ResponsResult();

            if (model == null)
            {
                return(result.SetError("Model 不能为空!"));
            }
            if (string.IsNullOrEmpty(model.JobName))
            {
                return(result.SetError("JobName 不能为空!"));
            }
            if (string.IsNullOrEmpty(model.JobGroup))
            {
                return(result.SetError("JobGroup 不能为空!"));
            }
            //search
            var taskInfo = base.Single <TaskSchedule>(t => t.Id.Equals(model.Id));
            var info     = await jobCenter.StopScheduleJobAsync(model.JobGroup, model.JobName);

            if (!info.Status.Equals(200))
            {
                return(result.SetError(info.Message));
            }
            //del
            base.Delete(taskInfo, true);
            return(result);
        }
Esempio n. 8
0
        /// <summary>
        /// 删除指定角色
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public ResponsResult DeleteRoles(RoleModel model)
        {
            ResponsResult result = new ResponsResult();
            //
            var backageUser = base.First <BackstageUser>(t => t.RoleId == model.Id);

            if (backageUser != null)
            {
                return(result.SetError("该角色下有管理人员,禁止删除该角色!"));
            }
            var role = base.Single <SystemRoles>(t => t.Id == model.Id);

            if (role != null)
            {
                var o1 = base.Where <SystemRolePermission>(t => t.RoleId == role.Id).ToList();
                o1.ForEach((Action <SystemRolePermission>)(t =>
                {
                    if (!model.Menus.Contains(t.ActionId))
                    {
                        base.Delete((object)t);
                    }
                }));
                base.Delete(role, true);
            }
            return(result);
        }
Esempio n. 9
0
        public ResponsResult GetAppAndroidVersion()
        {
            ResponsResult result = new ResponsResult();

            result.Data = SystemSettingService.AndroidVersion;
            return(result);
        }
        /// <summary>
        /// 检查返回的token
        /// </summary>
        /// <param name="token"></param>
        /// <returns></returns>
        protected ResponsResult CheckToken(string token)
        {
            ResponsResult rModel = new ResponsResult();

            try
            {
                string json = ServiceCollectionExtension.Decrypt(token);
                if (string.IsNullOrEmpty(json))
                {
                    return(rModel.SetStatus(ErrorCode.Relogin, "token不正确.请重新登录!"));
                }
                this.TokenModel = json.GetModel <TokenModel>();
                if (this.TokenModel == null)
                {
                    return(rModel.SetStatus(ErrorCode.InvalidToken, "非法请求."));
                }
                if (string.IsNullOrEmpty(this.TokenModel.Id))
                {
                    return(rModel.SetStatus(ErrorCode.InvalidToken, "无效token."));
                }
                //缓存+token对比时间做单点登录
                //检查token里的token是否在系统注册
                //Bicycle.Service.RegistActions
                //if (!Bicycle.Data.Entity.SystemToken.Tokens.Exists(t => this.Token.Token == t.Token))
                //{
                //    return rModel.SetError("不匹配,非法请求.", ResponseStatus.NotAcceptable);
                //}
            }
            catch (Exception ex)
            {
                return(rModel.SetStatus(ErrorCode.SystemError, $"请求失败.{ex.Message}"));
            }

            return(rModel);
        }
Esempio n. 11
0
        /// <summary>
        /// 用户退出
        /// </summary>
        /// <returns></returns>
        public ResponsResult LogoutUser()
        {
            ResponsResult result = new ResponsResult();

            CookieUtility.RemoveCookie(TbConstant.WEBSITE_AUTHENTICATION_SCHEME);
            return(result);
        }
Esempio n. 12
0
        public ResponsResult Post([FromBody] FileUploadModel model)
        {
            ResponsResult result = new ResponsResult();

            try
            {
                var ext = System.IO.Path.GetExtension(model.FileName);
                if (string.IsNullOrEmpty(ext))
                {
                    ext = ".jpg";
                }
                string _fileName  = $"{model.Type}_{DateTime.Now.ToString("yyyyMMddHHmmssfffffff")}{ext}";
                var    _virtual   = PathServerUtility.Combine(System.Enum.GetName(typeof(FileType), model.Type), model.Id.ToString(), _fileName);
                var    webApiPath = ConfigLocator.Instance[TbConstant.WebSiteKey] + "/api/UploadBase64File";
                var    sign       = Security.Sign(Domain.Config.TbConstant.UploadKey, _virtual);
                model.Picture = Convert.ToBase64String(ImageHandler.ShrinkImage(ImageHandler.Base64ToBytes(model.Picture)));
                string response;
                if (!string.IsNullOrEmpty(model.WaterMarks))
                {
                    response = HttpUtility.PostString(webApiPath, new { sign = sign, base64 = model.Picture, fileName = _virtual, watermarks = model.WaterMarks }.GetJson(), "application/json");
                }
                else
                {
                    response = HttpUtility.PostString(webApiPath, new { sign = sign, base64 = model.Picture, fileName = _virtual }.GetJson(), "application/json");
                }
                var uploadModel = (response.GetModel <ResponsResult>().Data as Newtonsoft.Json.Linq.JObject).ToObject <UploadModel>();
                result.Data = uploadModel;
                return(result);
            }
            catch (Exception ex)
            {
                Log4Net.Error($"[上传图片异常]_:{ex}");
                return(result.SetError("上传图片异常"));
            }
        }
Esempio n. 13
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="context"></param>
        /// <param name="actionId"></param>
        /// <returns></returns>
        public bool HasPermission(ActionExecutingContext context, string actionId)
        {
            var identity = (context.HttpContext.User.Identity as MvcIdentity);

            if (identity.IsAuthenticated)
            {
                var role = RolePermissions.SingleOrDefault(x => x.Id == identity.RoleId);
                if (role != null && role.Menus.Contains(actionId))
                {
                    return(true);
                }
                if (context.HttpContext.IsAjaxRequest())
                {
                    ResponsResult result = new ResponsResult();
                    result.SetStatus(ErrorCode.Forbidden);
                    context.Result = new ObjectResult(result);
                }
                else
                {
                    var view = new ViewResult();
                    view.ViewName  = "~/Views/Home/Welcome.cshtml";
                    context.Result = view;
                }
                return(false);
            }
            return(true);
        }
Esempio n. 14
0
        /// <summary>
        /// 添加信息
        /// </summary>
        /// <param name="accountId"></param>
        /// <param name="model"></param>
        /// <returns></returns>
        public ResponsResult AddMsgInfo(string accountId, AddRpwModel model)
        {
            ResponsResult result = new ResponsResult();

            if (string.IsNullOrEmpty(model.Content))
            {
                return(result.SetStatus(ErrorCode.RpwMsgEmpty));
            }
            if (model.Pics.Count <= 0)
            {
                return(result.SetStatus(ErrorCode.PicsEmpty));
            }
            MsgContent msgContent = new MsgContent()
            {
                AccountId   = accountId,
                AreaType    = (int)model.Type,
                ContextType = (int)MsgContextType.hot,
                Status      = (int)MsgStatus.NoReviewed,
                Content     = model.Content,
                Pics        = model.Pics.GetJson(),
                CreateTime  = DateTime.Now,
                Longtude    = model.Longtude,
                Latiude     = model.Latitude
            };

            base.Add(msgContent, true);
            return(result);
        }
Esempio n. 15
0
        public ResponsResult SaveAndroid(AndroidVersion android)
        {
            ResponsResult result = new ResponsResult();

            systemSettingService.SaveSettings(android);
            return(result);
        }
Esempio n. 16
0
        public ResponsResult SaveSetting(SystemSettingModel model)
        {
            ResponsResult result = new ResponsResult();

            systemSettingService.SaveSettings(model);
            return(result);
        }
        public async Task Invoke(HttpContext context)
        {
            try
            {
                await _next.Invoke(context);

                if (!SuccessCode.Contains(context.Response.StatusCode))
                {
                    int    statusCode2  = context.Response.StatusCode;
                    string reasonPhrase = ReasonPhrases.GetReasonPhrase(statusCode2);
                    string msg          = string.Format("Status Code: {0}, {1}; {2}{3}", new object[4]
                    {
                        statusCode2,
                        reasonPhrase,
                        context.Request.Path,
                        context.Request.QueryString
                    });
                    if (context.IsAjaxRequest())
                    {
                        context.Response.ContentType = "application/json;charset=utf-8";
                        ResponsResult response2 = new ResponsResult(statusCode2, msg, (Exception)null);
                        await context.Response.WriteAsync(response2.GetJson());
                    }
                }
            }
            catch (Exception exception)
            {
                int statusCode = SuccessCode.Contains(context.Response.StatusCode) ? 500 : context.Response.StatusCode;
                if (exception.TargetSite.DeclaringType != (Type)null)
                {
                    string name = exception.TargetSite.DeclaringType.Name;
                    if (name.Contains("ChallengeAsync"))
                    {
                        statusCode = 401;
                    }
                    else if (name.Contains("ForbidAsync"))
                    {
                        statusCode = 403;
                    }
                }
                Log4Net.Error($"[ErrorHandler中间件:]{exception}");
                Exception     ex      = exception;
                StringBuilder message = new StringBuilder();
                while (ex != null)
                {
                    message.AppendLine(ex.Message);
                    ex = ex.InnerException;
                }
                if (context.IsAjaxRequest() && !context.Response.HasStarted)
                {
                    context.Response.ContentType = "application/json;charset=utf-8";
                    ResponsResult response = new ResponsResult(statusCode, message.ToString(), (Exception)null);
                    await context.Response.WriteAsync(response.GetJson());
                }
            }
        }
Esempio n. 18
0
        /// <summary>
        /// 后端用户登录操作
        /// </summary>
        /// <param name="model">AccountViewModel实体</param>
        /// <returns></returns>
        public ResponsResult Login(BackstageUserAdd model)
        {
            ResponsResult result      = new ResponsResult();
            string        sessionCode = string.Empty;

            try
            {
                var code = CookieUtility.GetCookie(TbConstant.WEBSITE_VERIFICATION_CODE);
                if (code != null)
                {
                    sessionCode = ServiceCollectionExtension.Decrypt(code);
                }
            }
            catch (Exception ex)
            {
                Log4Net.Debug(ex);
            }
            if (model.ErrCount >= 3)
            {
                if (!model.VerCode.ToString().ToLower().Equals(sessionCode.ToLower()))
                {
                    return(result.SetStatus(ErrorCode.NotFound, "验证码输入不正确!"));
                }
            }

            BackstageUser account = this.First <BackstageUser>(t => t.LoginName == model.LoginName);

            if (account == null)
            {
                return(result.SetStatus(ErrorCode.NotFound, "账号不存在!"));
            }
            string pwd = Security.MD5(model.Password);

            if (!account.Password.Equals(pwd, StringComparison.OrdinalIgnoreCase))
            {
                return(result.SetStatus(ErrorCode.InvalidPassword));
            }
            switch (account.AccountStatus)
            {
            case (int)AccountStatus.Disabled:
                return(result.SetStatus(ErrorCode.AccountDisabled, "账号不可用!"));
            }

            account.LastLoginTime = DateTime.Now;
            account.LastLoginIp   = "";
            this.Update(account, true);
            MvcIdentity identity = new MvcIdentity(account.Id, account.LoginName, account.LoginName, account.Email, (int)account.AccountType, null, account.LastLoginTime);

            identity.Login(TbConstant.WEBSITE_AUTHENTICATION_SCHEME, x =>
            {
                x.Expires  = DateTime.Now.AddHours(25);//滑动过期时间
                x.HttpOnly = true;
            });

            return(result);
        }
Esempio n. 19
0
        public ResponsResult DelAdPic(AdManagerViewSearch model)
        {
            ResponsResult result = new ResponsResult();
            Advertising   adPic  = new Advertising();

            adPic.Id = model.Id;
            this.Delete(adPic, true);
            result.Message = "删除成功";
            return(result);
        }
Esempio n. 20
0
        public ResponsResult Register(string accountId, string mobile, string code)
        {
            ResponsResult result = new ResponsResult();

            if (string.IsNullOrEmpty(mobile))
            {
                return(result.SetStatus(ErrorCode.CannotEmpty, "请输入手机号!"));
            }
            if (!mobile.IsMobile())
            {
                return(result.SetStatus(ErrorCode.InvalidMobile, "手机号格式不正确!"));
            }
            if (string.IsNullOrEmpty(code))
            {
                return(result.SetStatus(ErrorCode.CannotEmpty, "请输入正确的手机验证码!"));
            }
            if (this.Exists <Account>(t => t.RealName == mobile))
            {
                return(result.SetStatus(ErrorCode.Existed, "该手机号已注册! 如果该手机号为你所有,请登录!"));
            }

            var now        = DateTime.Now.AddSeconds(-TbConstant.CanRequestAfterSecond);
            var mobileCode = base.Where <SmsInfo>(t => t.Mobile == mobile && (bool)!t.IsUsed && t.CreateTime > now)
                             .OrderByDescending(t => t.CreateTime).FirstOrDefault();

            if (mobileCode == null)
            {
                return(result.SetStatus(ErrorCode.Expired, "验证码已过期,请重新获取!"));
            }

            if (mobileCode.Code != code)
            {
                return(result.SetStatus(ErrorCode.InvalidData, "验证码不正确!"));
            }
            mobileCode.IsUsed = true;
            base.Update(mobileCode);
            var account = new Account
            {
                RealName      = mobile,
                AccountStatus = (int)AccountStatus.Normal,
                CreateTime    = DateTime.Now,
                PassWord      = "",
                LastLoginTime = DateTime.Now,
                ReferId       = accountId,
                HeaderPic     = TbConstant.DefaultHeadPicture,
                AccountType   = (int)SourceType.Web,
            };

            this.Add(account, true);
            var settings = SystemSettingService.SystemSetting;

            result.Data = settings.CouponForRegist + settings.InvitedPackage;

            return(result);
        }
Esempio n. 21
0
        public ResponsResult SaveHelp(InformationModel model)
        {
            ResponsResult result = new ResponsResult();

            if ((int)model.Type < 1)
            {
                return(result.SetError("请选择类型"));
            }
            if (model.Type != InformationType.UseGuide)
            {
                var info = this.First <Informations>(t => t.Type == (int)model.Type);
                if (info == null)
                {
                    info = new Informations {
                        Id = this.GenNewGuid(), CreateTime = DateTime.Now, Type = (int)model.Type, Title = model.Type.GetString()
                    };
                    this.Add(info);
                }
                else
                {
                    info.UpdateTime = DateTime.Now;
                    this.Update(info);
                }
                info.Description = model.Description;
                model.Id         = info.Id;
                this.Save();
            }
            else
            {
                if (string.IsNullOrEmpty(model.Title))
                {
                    return(result.SetError("请输入标题"));
                }
                var info = this.Single <Informations>(t => t.Id == model.Id);
                if (info == null)
                {
                    info = new Informations {
                        Id = this.GenNewGuid(), CreateTime = DateTime.Now, Type = (int)model.Type
                    };
                    this.Add(info);
                }
                else
                {
                    info.UpdateTime = DateTime.Now;
                    this.Update(info);
                }
                info.Title       = model.Title.Trim();
                info.Description = model.Description;
                model.Id         = info.Id;
                this.Save();
            }
            result.Data = model.Id;
            return(result);
        }
Esempio n. 22
0
        /// <summary>
        /// 获取角色所拥有的权限
        /// </summary>
        /// <returns></returns>
        public ResponsResult GetRoles()
        {
            ResponsResult result = new ResponsResult();
            var           list   = base.Query <SystemRoles>().ToList();

            list.ForEach(t =>
            {
                t.Menus = base.Where <SystemRolePermission>(x => x.RoleId == t.Id).Select(x => x.ActionId).ToList();
            });
            result.Data = list;
            return(result);
        }
Esempio n. 23
0
        public ResponsResult AdPicAdd_Updata(AdManagerViewSearch model)
        {
            ResponsResult result = new ResponsResult();
            Advertising   adPic;

            if (!string.IsNullOrEmpty(model.Id))
            {
                adPic = this.First <Advertising>(t => t.Id != model.Id && t.AdName == model.AdName && t.AdLocation == (int)model.AdLocation);
            }
            else
            {
                adPic = this.First <Advertising>(t => t.AdName == model.AdName && t.AdLocation == (int)model.AdLocation);
            }

            if (adPic != null)
            {
                return(result.SetStatus(ErrorCode.NotFound, "广告位已经存在!"));
            }
            else
            {
                if (string.IsNullOrEmpty(model.Id))
                {
                    adPic          = new Advertising();
                    adPic          = model.GetJson().GetModel <Advertising>();
                    adPic.AdDesc   = model.AdDesc;
                    adPic.IsEnable = true;//添加默认启用
                }
                else
                {
                    adPic            = this.First <Advertising>(t => t.Id == model.Id);
                    adPic.AdLocation = (int)model.AdLocation;
                    adPic.AdName     = model.AdName;
                    adPic.AdPic      = model.AdPic;
                    adPic.BeginTime  = model.BeginTime;
                    adPic.EndTime    = model.EndTime;
                    adPic.AdDesc     = model.AdDesc;
                    adPic.AdLink     = model.AdLink;
                    adPic.IsEnable   = model.IsEnable;
                }
            }

            if (!string.IsNullOrEmpty(model.Id))
            {
                this.Update(adPic, true);
            }
            else
            {
                adPic.Id = Guid.NewGuid().ToString("N");
                this.Add(adPic, true);
            }
            return(result);
        }
Esempio n. 24
0
        public ResponsResult ApiGetInformation(InformationType type)
        {
            ResponsResult result = new ResponsResult();

            if (type != InformationType.UseGuide)
            {
                result.Data = this.First <Informations>(t => t.Type == (int)type)?.Description ?? "";
            }
            else
            {
                result.Data = this.Where <Informations>(t => t.Type == (int)type).Select(t => new { t.Description, t.Id, t.Title, t.Type }).ToList();
            }
            return(result);
        }
Esempio n. 25
0
        /// <summary>
        /// 获取红包墙消息
        /// </summary>
        /// <param name="accountId"></param>
        /// <param name="longtude"></param>
        /// <param name="latitude"></param>
        /// <returns></returns>
        public ResponsResult GetRpwInfo(string accountId, decimal longtude, decimal latitude)
        {
            ResponsResult result = new ResponsResult();
            var           info   = base.Where <MsgContent>(t => t.AreaType == (int)AllOrLocal.All && t.ContextType == (int)MsgContextType.Rpw).Select(m => new MsgContentModel
            {
                TotalCounts  = m.TotalCounts,
                TotalPrice   = m.TotalPrice,
                RemainCounts = m.RemainCounts,
                Content      = m.Content,
                Pics         = m.Pics.GetModelList <string>("").GetPwFullPath(SystemSettingService.SystemSetting.ApiSite + "/"),
            }).ToList();

            result.Data = info;
            return(result);
        }
Esempio n. 26
0
        public ResponsResult IsEnableAdPic(AdManagerViewSearch model)
        {
            ResponsResult result = new ResponsResult();
            var           query  = base.Where <Advertising>(s => s.Id == model.Id).FirstOrDefault();

            if (query == null)
            {
                result.Message = "操作失败!";
                return(result);
            }
            query.IsEnable = model.IsEnable;//跟新赋值
            base.Update(query, true);
            result.Message = "操作成功!";
            return(result);
        }
Esempio n. 27
0
        /// <summary>
        /// 获取后台用户信息
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public ResponsResult GetBackstageUser(string id)
        {
            ResponsResult result        = new ResponsResult();
            BackstageUser backstageUser = this.First <BackstageUser>(t => t.Id == id);

            if (backstageUser == null)
            {
                backstageUser = new BackstageUser();
            }
            else
            {
                backstageUser.Password = "";
            }
            result.Data = backstageUser;
            return(result);
        }
Esempio n. 28
0
        /// <summary>
        /// 恢复指定的任务计划**恢复的是暂停后的任务计划,如果是程序奔溃后 或者是进程杀死后的恢复,此方法无效
        /// </summary>
        /// <returns></returns>
        public async Task <ResponsResult> RunScheduleJobAsync(TaskScheduleModel sm)
        {
            ResponsResult result = new ResponsResult();

            try
            {
                #region 开任务
                //scheduler = await GetSchedulerAsync();
                //DateTimeOffset starRunTime = DateBuilder.NextGivenSecondDate(sm.StarRunTime, 1);
                //DateTimeOffset endRunTime = DateBuilder.NextGivenSecondDate(sm.EndRunTime, 1);
                //IJobDetail job = JobBuilder.Create<HttpJob>()
                //  .WithIdentity(sm.JobName, sm.JobGroup)
                //  .Build();
                //ICronTrigger trigger = (ICronTrigger)TriggerBuilder.Create()
                //                             .StartAt(starRunTime)
                //                             .EndAt(endRunTime)
                //                             .WithIdentity(sm.JobName, sm.JobGroup)
                //                             .WithCronSchedule(sm.CronExpress)
                //                             .Build();
                //await scheduler.ScheduleJob(job, trigger);
                //await scheduler.Start();
                #endregion
                scheduler = await GetSchedulerAsync();

                //resumejob 恢复
                await scheduler.ResumeJob(new JobKey(sm.JobName, sm.JobGroup));

                var status = new StatusViewModel()
                {
                    Status = 0,
                    Msg    = "恢复任务计划成功",
                };
                result.Data = status.GetJson();
                return(result);
            }
            catch (Exception ex)
            {
                Log4Net.Error($"[JobCenter_RunScheduleJobAsync]_{ex}");
                var status = new StatusViewModel()
                {
                    Status = -1,
                    Msg    = "恢复任务计划失败",
                };
                result.Data = status.GetJson();
                return(result);
            }
        }
Esempio n. 29
0
        /// <summary>
        /// api获取手机验证码
        /// </summary>
        /// <param name="mobile"></param>
        /// <param name="sign"></param>
        /// <param name="apiKey"></param>
        /// <param name="accountId"></param>
        /// <returns></returns>
        public ResponsResult ApiGetVerifyCode(string mobile, string sign, string apiKey, string accountId = "")
        {
            ResponsResult result = new ResponsResult();

            if (string.IsNullOrEmpty(mobile))
            {
                return(result.SetStatus(ErrorCode.CannotEmpty, "请输入手机号!"));
            }
            if (!mobile.IsMobile())
            {
                return(result.SetStatus(ErrorCode.InvalidMobile, "手机号格式不正确!"));
            }
            if (string.IsNullOrEmpty(apiKey))
            {
                return(result.SetStatus(ErrorCode.CannotEmpty, "输入不正确!"));
            }
            if (!Security.ValidSign(sign, apiKey, mobile))
            {
                return(result.SetStatus(ErrorCode.InvalidSign));
            }
            var message = CheckRequest(ServiceCollectionExtension.ClientIP, mobile);

            if (!string.IsNullOrEmpty(message))
            {
                return(result.SetStatus(ErrorCode.BadRequest, message));
            }
            var codeList = Enumerable.Range(0, 9).OrderBy(t => Guid.NewGuid()).Skip(3).Take(6);
            var code     = string.Join("", codeList);

            result.Message = $"验证码已发送到你的手机,有效时长{TbConstant.CodeValidMinutes}分钟";

            /**/
            SmsInfo sms = new SmsInfo
            {
                Code       = code,
                Contents   = "获取验证码",
                Ip         = ServiceCollectionExtension.ClientIP,
                Mobile     = mobile,
                CreateTime = DateTime.Now,
                AccountId  = accountId
            };

            base.Add(sms, true);
            return(result);
        }
Esempio n. 30
0
        public ResponsResult GetValidCode(string mobile)
        {
            ResponsResult result = new ResponsResult();

            if (string.IsNullOrEmpty(mobile))
            {
                return(result.SetStatus(ErrorCode.CannotEmpty, "请输入手机号!"));
            }
            if (!mobile.IsMobile())
            {
                return(result.SetStatus(ErrorCode.InvalidMobile, "手机号格式不正确!"));
            }
            if (this.Exists <Account>(t => t.RealName == mobile))
            {
                return(result.SetStatus(ErrorCode.Existed, "该手机号已注册! 如果该手机号为你所有,请登录!"));
            }
            var message = CheckRequest(ServiceCollectionExtension.ClientIP, mobile);

            if (!string.IsNullOrEmpty(message))
            {
                return(result.SetStatus(ErrorCode.BadRequest, message));
            }
            var codeList = Enumerable.Range(0, 9).OrderBy(t => Guid.NewGuid()).Skip(3).Take(6);
            var code     = string.Join("", codeList);

            result.Message = $"验证码已发送到你的手机,有效时长{TbConstant.CodeValidMinutes}分钟";
            //MobileRequest request = new MobileRequest(mobile, $"{{code:'{code}',product:'{Constant.CompanyName}'}}");
            //var response = request.Excute();
            //if (!response.Success || response.ErrCode != 0)
            //{
            //    return result.SetError(response.Msg);
            //}
            SmsInfo sms = new SmsInfo
            {
                Code       = code,
                Contents   = "获取验证码",
                Ip         = ServiceCollectionExtension.ClientIP,
                Mobile     = mobile,
                CreateTime = DateTime.Now,
            };

            base.Add(sms, true);
            return(result);
        }