Esempio n. 1
0
        public AjaxResponseData AddNew(string text)
        {
            var response = new AjaxResponseData();

            if (IsValidUrl(text))
            {
                Uri    requestUrl  = HttpContext.Current.Request.Url;
                string requesthost = string.Format("{0}{1}{2}{3}",
                                                   requestUrl.Scheme,
                                                   Uri.SchemeDelimiter,
                                                   requestUrl.Authority,
                                                   "/");
                var entities = new UrlShortenerContext();
                var data     = new ShortenedUrl();
                data.OriginalUrl = text;
                entities.ShortUrls.Add(data);
                entities.SaveChanges();
                response.Success = true;
                response.Data    = requesthost + data.Id;
            }
            else
            {
                response.Success = false;
                response.Data    = "Please enter valid URL";
            }
            return(response);
        }
Esempio n. 2
0
        public JsonResult AddJob([FromBody] AddJobViewModel addJobViewModel)
        {
            AjaxResponseData ajaxResponseData = null;

            if (!ModelState.IsValid)
            {
                ajaxResponseData = ResponseDataFactory.CreateAjaxResponseData("-10001", "添加失败", $"输入参数错误:{ModelState.Values.Where(item => item.Errors.Count == 1).Aggregate(string.Empty, (current, item) => current + ($"{item.Errors[0].ErrorMessage} ;  "))}");
            }
            else
            {
                var jobId = _customerJobInfoRepository.AddCustomerJobInfo(addJobViewModel.JobName, addJobViewModel.JobGroupName, addJobViewModel.TriggerName, addJobViewModel.TriggerGroupName, addJobViewModel.CronJob == null ? null : addJobViewModel.CronJob.Cron, addJobViewModel.JobDescription, addJobViewModel.RequestUrl, addJobViewModel.SimpleJob == null ? null : addJobViewModel.SimpleJob.Cycle, addJobViewModel.SimpleJob == null ? null : addJobViewModel.SimpleJob.RepeatCount, addJobViewModel.TriggerType);

                ajaxResponseData = ResponseDataFactory.CreateAjaxResponseData("1", "添加成功", jobId);
            }
            return(Json(ajaxResponseData));
        }
 public static AjaxResponseData CreateAjaxResponseData(string statusCode, string message, object data)
 {
     if (_ajaxResponseData == null)
     {
         _ajaxResponseData = new AjaxResponseData()
         {
             StausCode = statusCode, Message = message, Data = data
         };
     }
     else
     {
         _ajaxResponseData.StausCode = statusCode;
         _ajaxResponseData.Message   = message;
         _ajaxResponseData.Data      = data;
     }
     return(_ajaxResponseData);
 }
Esempio n. 4
0
        /// <summary>
        /// 抽奖方法
        /// </summary>
        /// <returns></returns>
        public ActionResult LuckDrawAward()
        {
            JavaScriptSerializer jss    = new JavaScriptSerializer();
            AjaxResponseData     arData = new AjaxResponseData();
            M_login M_uid = (M_login)DataCache.GetCache(CacheRemove._loginCachePrefix + Utils.GetUserIDCookieslocahost().ToString());

            if (M_uid == null)
            {
                arData = new AjaxResponseData {
                    code = "1", data = "您还没有登录"
                };
                return(Content(jss.Serialize(arData)));
            }
            int    userID    = Utils.checkloginsession();//获取登录用户编号
            string returnStr = TActivity_Luck.LuckDrawAward(userID, startTime, endTime, amount);

            string[] spl = returnStr.Split(';');
            arData = new AjaxResponseData {
                code = spl[0], data = spl[1]
            };
            return(Content(jss.Serialize(arData)));
        }
Esempio n. 5
0
        private async Task <AjaxResponseData> OperateJobAsync(int jobId, Func <CustomerJobInfo, bool> operateJobFunc)
        {
            AjaxResponseData ajaxResponseData = null;
            var jobDetail = await _customerJobInfoRepository.LoadCustomerJobInfoAsync(i => i.Id == jobId);

            if (jobDetail == null)
            {
                ajaxResponseData = ResponseDataFactory.CreateAjaxResponseData("0", "无此任务", jobDetail);
            }
            else
            {
                var isSuccess = operateJobFunc(jobDetail);
                if (isSuccess)
                {
                    ajaxResponseData = ResponseDataFactory.CreateAjaxResponseData("1", "操作成功", jobDetail);
                }
                else
                {
                    ajaxResponseData = ResponseDataFactory.CreateAjaxResponseData("-10001", "操作失败", jobDetail);
                }
            }
            return(ajaxResponseData);
        }
Esempio n. 6
0
        /// <summary>
        /// 操作任务
        /// </summary>
        /// <param name="jobId">任务编号</param>
        /// <param name="operateJobFunc">具体操作任务的委托</param>
        /// <returns></returns>
        private AjaxResponseData _operateJob(int jobId, Func <customer_quartzjobinfo, bool> operateJobFunc)
        {
            AjaxResponseData ajaxResponseData = null;
            var jobDetail = _customerJobInfoRepository.LoadCustomerInfo(x => x.Id == jobId);

            if (jobDetail == null)
            {
                ajaxResponseData = ResponseDataFactory.CreateAjaxResponseData("0", "无此任务", jobDetail);
            }
            else
            {
                var isSuccess = operateJobFunc(jobDetail);
                if (isSuccess)
                {
                    ajaxResponseData = ResponseDataFactory.CreateAjaxResponseData("1", "操作成功", jobDetail);
                }
                else
                {
                    ajaxResponseData = ResponseDataFactory.CreateAjaxResponseData("-10001", "操作失败", jobDetail);
                }
            }
            return(ajaxResponseData);
        }
Esempio n. 7
0
        /// <summary>
        /// 操作任务
        /// </summary>
        /// <param name="jobId">任务编号</param>
        /// <param name="operateJobFunc">具体操作任务的委托</param>
        /// <returns></returns>
        public AjaxResponseData _operateJob(int jobId, Func <custom_job_infoes, bool> operateJobFunc)
        {
            AjaxResponseData ajaxResponseData = null;
            var jobDetail = _customerJobInfoRepository.LoadCustomerInfo(jobId);

            if (jobDetail == null)
            {
                ajaxResponseData = ResponseDataFactory.CreateAjaxResponseData("0", "无此任务", jobDetail);
            }
            else
            {
                _setSpecificTrigger(jobDetail.TriggerType);
                var isSuccess = operateJobFunc(jobDetail);
                if (isSuccess)
                {
                    ajaxResponseData = ResponseDataFactory.CreateAjaxResponseData("1", "操作成功", jobDetail);
                }
                else
                {
                    ajaxResponseData = ResponseDataFactory.CreateAjaxResponseData("-10001", "操作失败", jobDetail);
                }
            }
            return(ajaxResponseData);
        }
Esempio n. 8
0
        /// <summary>
        /// 抽奖方法
        /// </summary>
        /// <returns></returns>
        public ActionResult LuckDrawAward()
        {
            string app    = DNTRequest.GetString("app");
            int    userID = 0;

            if (app.ToLower() == "clt")
            {
                string uid = DNTRequest.GetString("userid");
                userID = int.Parse(string.IsNullOrWhiteSpace(uid) ? "0" : uid);
            }
            else
            {
                userID = Settings.Instance.CurrentUserId;//获取登录用户编号
            }
            JavaScriptSerializer jss    = new JavaScriptSerializer();
            AjaxResponseData     arData = new AjaxResponseData();
            string returnStr            = TActivity_Luck.LuckDrawAward(userID, startTime, endTime, amount);

            string[] spl = returnStr.Split(';');
            arData = new AjaxResponseData {
                code = spl[0], data = spl[1]
            };
            return(Content(jss.Serialize(arData)));
        }
Esempio n. 9
0
        /// <summary>
        /// 抽奖方法
        /// </summary>
        /// <returns></returns>
        public ActionResult LuckDrawAward()
        {
            JavaScriptSerializer jss    = new JavaScriptSerializer();
            AjaxResponseData     arData = new AjaxResponseData();

            try
            {
                string msg   = "";
                int    state = CheckActivityTime(ref msg);
                if (state != 0)
                {
                    arData = new AjaxResponseData {
                        code = "4", data = msg
                    };
                    return(Content(jss.Serialize(arData)));
                }

                int userID = Settings.Instance.CurrentUserId;

                //M_login M_uid = (M_login)DataCache.GetCache(Utils.GetUserIDCookieslocahost().ToString());
                //if (M_uid == null)
                if (userID < 1)
                {
                    arData = new AjaxResponseData {
                        code = "1", data = "请登录后重试"
                    };
                    return(Content(jss.Serialize(arData)));
                }
                //if (M_uid.codeno != Utils.getSessioncode())
                //{
                //    arData = new AjaxResponseData { code = "1", data = "请登录后重试" };
                //    return Content(jss.Serialize(arData));
                //}
                //获取登录用户编号
                //int userID = M_uid.userid;
                //可抽奖次数
                int            CanUseTimes = 1;
                B_member_table bllMember   = new B_member_table();
                //获取会员信息
                PartialMemberModel member = bllMember.GetPartialModel(userID);
                //验证用户是否为今天新注册的用户
                if (member.registration_time >= DateTime.Now.Date && member.registration_time < DateTime.Now.AddDays(1).Date&& member.isrealname == 1)
                {
                    CanUseTimes += 1;
                }
                B_LuckDraw bllLuckDraw = new B_LuckDraw();
                //获取用户的抽奖记录数量(当天的)
                int recordsCount = bllLuckDraw.GetRecordsCount(userID, DateTime.Now.Date, DateTime.Now.AddDays(1).Date);
                CanUseTimes -= recordsCount;

                if (CanUseTimes <= 0)
                {
                    arData = new AjaxResponseData {
                        code = "2", data = "抽奖机会已用完,请明天再来"
                    };
                    return(Content(jss.Serialize(arData)));
                }
                #region 规则及数据
                // 现金50元   50  0.17 %(60次抽满后,每天限中2次,概率填充入50元代金券)
                //1 -17
                //50元代金券  2450    23.33 %
                //18-2350
                //20元代金卷  2100    20.00 %
                //2351-4350
                //10元代金卷  2100    20.00 %
                //4351-6350
                //1 % 加息券   1750    16.67 %
                //6351-8017
                //2 % 加息券   1400    13.33 %
                //8018-9350
                //谢谢参与    682.5   6.50 %
                //9351-10000

                //47    9月注册送500元奖励
                //48    9月注册送200元奖励
                //49    9月注册送50元奖励
                //50    9月注册送20元奖励
                //51    [9月注册送10元奖励]
                //52    [9月注册送8元奖励]

                //1   3 % 加息券
                //2   1 % 加息券
                //3   2 % 加息券
                //4   加息券
                #endregion
                //现金50元已抽中的个数
                int cash50Count = bllLuckDraw.GetCash50RecordsCount(-2, DateTime.Now.Date, DateTime.Now.AddDays(1).Date);
                //B_Activity_schedule bllASchedule = new B_Activity_schedule();
                ActFacade act = new ActFacade();
                //B_Activity bllActivity = new B_Activity();
                //admin.users.AddBonusForUser adfu = new admin.users.AddBonusForUser();
                //奖品编号
                int awardID = 0;
                //奖品标题
                string title = "";
                //奖品类型
                int awardType = -1;
                //轮盘区块编号
                int    awardBlockID = 0;
                Random random       = new Random();
                //随机数
                int randomRate = random.Next(1, 10001);
                //randomRate = 9350;
                //switch (randomRate)
                //{
                if (randomRate <= 8)
                {
                    //每天限中2次,概率填充入50元代金券
                    if (cash50Count < 2)
                    {
                        awardID      = ConfigHelper.GetConfigInt("AwardCash50");
                        awardType    = 0;
                        title        = "现金50元";
                        awardBlockID = 3;
                    }
                    else
                    {
                        awardID      = ConfigHelper.GetConfigInt("AwardBonus50");
                        awardType    = 1;
                        awardBlockID = 7;
                    }
                }
                //现金50元
                else if (randomRate <= 17)
                {
                    //每天限中2次,概率填充入50元代金券
                    if (cash50Count < 2)
                    {
                        awardID      = ConfigHelper.GetConfigInt("AwardCash50");
                        awardType    = 0;
                        title        = "现金50元";
                        awardBlockID = 5;
                    }
                    else
                    {
                        awardID      = ConfigHelper.GetConfigInt("AwardBonus50");
                        awardType    = 1;
                        awardBlockID = 7;
                    }
                }
                //50元代金券
                else if (randomRate <= 2350)
                {
                    awardID = ConfigHelper.GetConfigInt("AwardBonus50"); awardType = 1; awardBlockID = 7;
                }
                //20元代金卷
                else if (randomRate <= 4350)
                {
                    awardID = ConfigHelper.GetConfigInt("AwardBonus20"); awardType = 1; awardBlockID = 4;
                }
                //10元代金卷
                else if (randomRate <= 6350)
                {
                    awardID = ConfigHelper.GetConfigInt("AwardBonus10"); awardType = 1; awardBlockID = 6;
                }
                //1 % 加息券
                else if (randomRate <= 8017)
                {
                    awardID = ConfigHelper.GetConfigInt("AwardRate1"); awardType = 2; awardBlockID = 0;
                }
                //2 % 加息券
                else if (randomRate <= 9350)
                {
                    awardID = ConfigHelper.GetConfigInt("AwardRate2"); awardType = 2; awardBlockID = 2;
                }
                //谢谢参与
                else if (randomRate <= 10000)
                {
                    awardID = ConfigHelper.GetConfigInt("AwardThankYou"); awardType = 3; title = "谢谢参与"; awardBlockID = 1;
                }
                //谢谢参与
                if (awardType == -1)
                {
                    awardID = ConfigHelper.GetConfigInt("AwardThankYou"); awardType = 3; title = "谢谢参与"; awardBlockID = 1;
                }
                //}
                //发放代金券
                if (awardType == 1 || awardType == 2)
                {
                    var sourceData = act.GetActivityModel(awardID); //bllASchedule.GetModel(awardID);
                    title = sourceData.ActName;                     //sourceData.activity_schedule_name.Replace("活动", "抽奖");
                    if (bllLuckDraw.AddNewRecord(new M_LuckDrawRecord {
                        Ldre_AwardID = awardID, Ldre_AwardName = sourceData.ActName, Ldre_AwardType = awardType, Ldre_CreatTime = DateTime.Now, Ldre_UserID = userID
                    }))
                    {
                        DrawBonus(sourceData, userID);
                        arData = new AjaxResponseData {
                            code = "0", data = awardBlockID.ToString()
                        };
                        return(Content(jss.Serialize(arData)));
                    }
                    else
                    {
                        arData = new AjaxResponseData {
                            code = "3", data = "碰到点小问题,刷新一下试试^v^"
                        };
                        return(Content(jss.Serialize(arData)));
                    }
                }
                ////发放加息券
                //if (awardType == 2)
                //{
                //    var sourceData = bllActivity.GetModel(awardID);
                //    title = "9月抽奖" + sourceData.ActivityName;
                //    if (bllLuckDraw.AddNewRecord(new M_LuckDrawRecord { Ldre_AwardID = awardID, Ldre_AwardName = sourceData.ActivityName, Ldre_AwardType = awardType, Ldre_CreatTime = DateTime.Now, Ldre_UserID = userID }))
                //    {
                //        thisObj.SubmitRate(awardID, 1, userID, DateTime.Now, sourceData.EndDate, title);
                //        arData = new AjaxResponseData { code = "0", data = awardBlockID.ToString() };
                //        return jss.Serialize(arData);
                //    }
                //}
                //增加现金和“谢谢参与”的抽奖记录
                if (bllLuckDraw.AddNewRecord(new M_LuckDrawRecord {
                    Ldre_AwardID = awardID, Ldre_AwardName = title, Ldre_AwardType = awardType, Ldre_CreatTime = DateTime.Now, Ldre_UserID = userID
                }))
                {
                    arData = new AjaxResponseData {
                        code = "0", data = awardBlockID.ToString()
                    };
                    return(Content(jss.Serialize(arData)));
                }
                //没有增加任何抽奖记录时的异常状态
                arData = new AjaxResponseData {
                    code = "3", data = "碰到点小问题,刷新一下试试"
                };
                return(Content(jss.Serialize(arData)));
            }
            catch (Exception ex)
            {
                LogInfo.WriteLog("9月抽奖活动异常日志:" + "msg:" + ex.Message + "   StackTrace" + ex.StackTrace);

                //没有增加任何抽奖记录时的异常状态
                arData = new AjaxResponseData {
                    code = "3", data = ex.Message
                };
                return(Content(jss.Serialize(arData)));
            }
        }
Esempio n. 10
0
        /// <summary>
        /// 抽奖方法
        /// </summary>
        /// <returns></returns>
        public ActionResult Grab()
        {
            JavaScriptSerializer jss    = new JavaScriptSerializer();
            AjaxResponseData     arData = new AjaxResponseData();

            try
            {
                string msg   = "";
                int    state = CheckActivityTime(ref msg);
                if (state != 0)
                {
                    arData = new AjaxResponseData {
                        code = "4", data = msg
                    };
                    return(Content(jss.Serialize(arData)));
                }

                int userID = Settings.Instance.CurrentUserId;

                //M_login M_uid = (M_login)DataCache.GetCache(Utils.GetUserIDCookieslocahost().ToString());
                //if (M_uid == null)
                if (userID < 1)
                {
                    arData = new AjaxResponseData {
                        code = "1", data = "请登录后重试"
                    };
                    return(Content(jss.Serialize(arData)));
                }
                //if (M_uid.codeno != Utils.getSessioncode())
                //{
                //    arData = new AjaxResponseData { code = "1", data = "请登录后重试" };
                //    return Content(jss.Serialize(arData));
                //}
                //获取登录用户编号
                //int userID = M_uid.userid;
                //可抽奖次数
                bool hadUsed     = false;
                int  CanUseTimes = GetCanUseTimes(ref hadUsed);
                //B_member_table bllMember = new B_member_table();
                ////获取会员信息
                //PartialMemberModel member = bllMember.GetPartialModel(userID);
                ////验证用户是否为今天新注册的用户
                //if (member.registration_time >= DateTime.Now.Date && member.registration_time < DateTime.Now.AddDays(1).Date && member.isrealname == 1)
                //{
                //    CanUseTimes += 1;
                //}
                //B_LuckDraw bllLuckDraw = new B_LuckDraw();
                ////获取用户的抽奖记录数量(当天的)
                //int recordsCount = bllLuckDraw.GetRecordsCount(userID, DateTime.Now.Date, DateTime.Now.AddDays(1).Date);
                //CanUseTimes -= recordsCount;

                if (CanUseTimes <= 0)
                {
                    arData = new AjaxResponseData {
                        code = "2", data = hadUsed.ToString()
                    };
                    return(Content(jss.Serialize(arData)));
                }
                #region 规则及数据

                //金额 数量  概率
                //1-17
                //10元  60    0.17 %
                //18-1684
                //8元  1750  16.67 %
                //1685-3667
                //7元  2082  19.83 %
                //3668-5667
                //6元  2100  20 %
                //5668-7667
                //5元  2100  20 %
                //7667-10000
                //3元  2450  23.33 %
                #endregion
                //现金50元已抽中的个数
                //int cash50Count = bllLuckDraw.GetCash50RecordsCount(-2, DateTime.Now.Date, DateTime.Now.AddDays(1).Date);
                //B_Activity_schedule bllASchedule = new B_Activity_schedule();
                ActFacade act = new ActFacade();
                //B_Activity bllActivity = new B_Activity();
                //admin.users.AddBonusForUser adfu = new admin.users.AddBonusForUser();
                //奖品编号
                int awardID = ConfigHelper.GetConfigInt("GrabCash");
                //奖品标题
                string title = "";
                //奖金金额
                int awardAmt = 0;
                //轮盘区块编号
                //int awardBlockID = 0;
                Random random = new Random();
                //随机数
                int randomRate = random.Next(1, 10001);
                //randomRate = 9350;

                //10元
                if (randomRate <= 17)
                {
                    title = "现金10元";
                    //awardBlockID = 5;
                    awardAmt = 10;
                }
                //8元
                else if (randomRate <= 1684)
                {
                    title = "现金8元";
                    //awardBlockID = 7;
                    awardAmt = 8;
                }
                //7元
                else if (randomRate <= 3667)
                {
                    title = "现金7元";
                    //awardBlockID = 4;
                    awardAmt = 7;
                }
                //6元
                else if (randomRate <= 5667)
                {
                    title = "现金6元";
                    //awardBlockID = 6;
                    awardAmt = 6;
                }
                //5元
                else if (randomRate <= 7667)
                {
                    title = "现金5元";
                    //awardBlockID = 0;
                    awardAmt = 5;
                }
                //3元
                else if (randomRate <= 10000)
                {
                    title = "现金3元";
                    //awardBlockID = 2;
                    awardAmt = 3;
                }
                if (SendCash(awardID, userID, awardAmt))
                {
                    arData = new AjaxResponseData {
                        code = "0", data = awardAmt.ToString()
                    };
                    return(Content(jss.Serialize(arData)));
                }
                //插入记录失败时的异常状态
                arData = new AjaxResponseData {
                    code = "3", data = "碰到点小问题,刷新一下试试"
                };
                return(Content(jss.Serialize(arData)));
            }
            catch (Exception ex)
            {
                LogInfo.WriteLog("9月抽奖活动异常日志:" + "msg:" + ex.Message + "   StackTrace" + ex.StackTrace);

                //没有增加任何抽奖记录时的异常状态
                arData = new AjaxResponseData {
                    code = "3", data = ex.Message
                };
                return(Content(jss.Serialize(arData)));
            }
        }