public static OutAPIResult ReCoverData(GameServer server, string RoomCode) { OutAPIResult r = new OutAPIResult(); try { if (server.GameDataDic.ContainsKey(RoomCode)) { return(r); } else { EOneGame game = new EOneGame(RoomCode); GameDataHandle handle = new GameDataHandle(game); server.GameDataDic.Add(RoomCode, handle); } } catch (Exception ex) { r.ErrorMsg = ex.Message; } return(r); }
public OutAPIResult GameUserLogin_WX(GameModel.EUserInfo wxUser) { NLogHelper.GameInfo("Login_WX In"); if (Request.Method.Method.ToLower() == "options") { return(null); } OutAPIResult result = new OutAPIResult(); try { using (GameContent db = new GameContent()) { var user = db.DBUserInfo.Where(a => a.openId == wxUser.openId).FirstOrDefault(); if (user == null) { result = GameUserRegister_WX(wxUser); } else { user.LastLogin = DateTime.Now; user.LoginCount++; db.SaveChanges(); } } } catch (Exception ex) { result.ErrorMsg = ex.Message; } return(result); }
public static OutAPIResult GenerateEmptyGame(GameServer server, string RoomCode) { OutAPIResult r = new OutAPIResult(); EOneGame game = new EOneGame(RoomCode); GameDataHandle handle = new GameDataHandle(game); try { handle.InitNewGameData(); if (server.GameDataDic.ContainsKey(RoomCode)) { r.ErrorMsg = "房间已存在!"; } else { server.GameDataDic.Add(RoomCode, handle); } } catch (Exception ex) { r.ErrorMsg = ex.Message; } return(r); }
public OutAPIResult GetMessage(string Phone) { OutAPIResult result = new OutAPIResult(); try { if (IsVerifiedPhone(Phone)) { result.ErrorMsg = ("手机已经注册,请直接登陆"); result.IntMsg = 100; return(result); } int LastInterval = GetLastMessageInterval(Phone); if (LastInterval == -1) { ESMSVerification sms = SendSMSToUser(Phone); if (sms == null || sms.SMSVerifyStatus == SMSVerifyStatus.SentFailure) { result.ErrorMsg = ("短信发送未成功,若尝试几次任然不成功,请联系客服!"); } } else { result.ErrorMsg = string.Format("请不要重复操作,先查看已发送的验证码,{0}秒后再尝试", LastInterval); } } catch (Exception ex) { result.ErrorMsg = ex.Message; } return(result); }
// public bool /// <summary> /// 通过转账验证账户 /// </summary> /// <returns></returns> public OutAPIResult TestAccountByTransfer(string AliPayAccount, EAliPayApplication app) { OutAPIResult result = new OutAPIResult(); string tId; try { AlipayFundTransToaccountTransferResponse res = DoTransferAmount(TransferTarget.User, app, AliPayAccount, "0.1", PayTargetMode.AliPayAccount, out tId, null, "账户校验"); if (res.Code != "10000") { result.IsSuccess = false; result.ErrorMsg = res.Msg + "--" + res.SubMsg; } return(result); } catch (Exception ex) { result.IsSuccess = false; result.ErrorMsg = ex.Message; } return(result); }
public OutAPIResult ConfirmVerification(string Phone, string VerifyCode) { OutAPIResult result = new OutAPIResult(); try { if (string.IsNullOrEmpty(VerifyCode)) { result.ErrorMsg = "验证码不能为空!"; return(result); } using (PPContent db = new PPContent()) { ESMSVerification sms = db.DBSMSVerification.Where(a => a.MobilePhone == Phone && a.SMSVerifyStatus == SMSVerifyStatus.Sent && a.SMSEvent == SMSEvent.OO_Register ) .OrderByDescending(s => s.ID) .FirstOrDefault(); if (sms == null) { result.ErrorMsg = "验证码还没有成功获取!"; return(result); } else { if (sms.VerifyCode != VerifyCode) { result.ErrorMsg = "验证码不正确!请仔细查看收到的短信信息"; } //校验成功 else { int SMSMaxIntervalSec = Convert.ToInt32(ConfigurationManager.AppSettings["SMSMaxIntervalSec"]); if (sms.SendDateTime.GetSecInterval() > SMSMaxIntervalSec) { result.ErrorMsg = "验证码已失效,请重新获取!"; result.IntMsg = -100; return(result); } else { sms.SMSVerifyStatus = SMSVerifyStatus.Success; db.SaveChanges(); } } } } } catch (Exception ex) { result.ErrorMsg = ex.Message; } return(result); }
public OutAPIResult SetGameInfo(EGameInfo gi) { OutAPIResult r = new OutAPIResult(); try { r = GameDataHandle.SetGameInfo(gi); } catch (Exception ex) { r.ErrorMsg = ex.Message; } return(r); }
public OutAPIResult UserStandUp_Redis(string UserOpenId) { OutAPIResult result = new OutAPIResult(); RoomUserRedis redis = new RoomUserRedis(); try { result = redis.UserSitUp(UserOpenId); } catch (Exception ex) { result.ErrorMsg = ex.Message; } return(result); }
public OutAPIResult UserSitDown_Redis(string UserOpenId, int SeatNo, decimal coins) { OutAPIResult result = new OutAPIResult(); RoomUserRedis redis = new RoomUserRedis(); try { result = redis.UserSitDown(UserOpenId, SeatNo, coins); } catch (Exception ex) { result.ErrorMsg = ex.Message; } return(result); }
/// <summary> /// 删除用户的任务 /// </summary> /// <param name="taskId"></param> /// <returns></returns> public OutAPIResult DeleteUserTask(long UserId, long TaskId) { OutAPIResult result = new OutAPIResult(); try { } catch (Exception ex) { result.IsSuccess = false; result.ErrorMsg = ex.Message; ErrorToDb(ex.Message); } return(result); }
public OutAPIResult SetGameInfo(EGameInfo gi) { OutAPIResult r = new OutAPIResult(); try { GameRedis.SetGameBasic(gi); _OneGame.GameInfo = gi; } catch (Exception ex) { r.ErrorMsg = ex.Message; } return(r); }
/// <summary> /// 获取用户邀请信息 /// </summary> /// <returns></returns> public OutAPIResult InviteInfo() { OutAPIResult result = new OutAPIResult(); try { using (OOContent db = new OOContent()) { } } catch (Exception ex) { ErrorToDb(ex.Message); } return(result); }
public static OutAPIResult UploadImg(string saveFullPath) { OutAPIResult result = new OutAPIResult(); try { HttpPostedFile file0 = HttpContext.Current.Request.Files[0]; file0.SaveAs(saveFullPath); return(result); } catch (Exception ex) { result.ErrorMsg = ex.Message; } return(result); }
public OutAPIResult ModifyPwd() { string phone = HttpContext.Current.Request["Phone"]; string newPwd = HttpContext.Current.Request["newPwd"]; string oldPwd = HttpContext.Current.Request["oldPwd"]; OutAPIResult result = new OutAPIResult(); try { if (string.IsNullOrEmpty(phone)) { result.ErrorMsg = "手机号不能为空!"; return(result); } if (string.IsNullOrEmpty(newPwd)) { result.ErrorMsg = "新密码不能为空!"; return(result); } using (OOContent db = new OOContent()) { EUserInfo ui = db.DBUserInfo.Where(a => a.Phone == phone).FirstOrDefault(); if (ui == null) { result.ErrorMsg = "手机对应的用户没有找到"; return(result); } if (ui.Pwd != oldPwd) { result.ErrorMsg = "旧密码不匹配"; return(result); } else { ui.Pwd = newPwd; db.SaveChanges(); } } } catch (Exception ex) { result.ErrorMsg = ex.Message; } return(result); }
public OutAPIResult FindAvailableRoom(int weight) { OutAPIResult r = new OutAPIResult(); try { r = RoomRedis.FindOrCreateRoom(_UserOpenId, weight); if (r.IsSuccess) { // this._RoomCode = r.SuccessMsg; } } catch (Exception ex) { r.ErrorMsg = ex.Message; } return(r); }
public OutAPIResult ExitRoom_Redis(string userOpenId) { OutAPIResult result = new OutAPIResult(); RoomUserRedis roomUserRedis = new RoomUserRedis(); try { lock (_ExitRoom) { result = roomUserRedis.UserExitRoom(userOpenId); } } catch (Exception ex) { result.ErrorMsg = ex.Message; } return(result); }
public OutAPIResult UserSitDown(int SeatNo, decimal coins) { OutAPIResult result = new OutAPIResult(); try { if (coins <= 0) { result.ErrorMsg = "金币不足,无法入座"; return(result); } result = RoomUserRedis.UserSitDown(_UserOpenId, SeatNo, coins); } catch (Exception ex) { result.ErrorMsg = ex.Message; } return(result); }
/// <summary> /// 刷单邀请码 /// </summary> /// <param name="qr"></param> /// <param name="context"></param> /// <returns></returns> #region ShuaDan public static OutAPIResult CreateShuaDan_InviteQR(HttpContext context) { OutAPIResult r = new OutAPIResult(); try { string url = "http://wx.iqianba.cn/api/wx/CreateShuDanInviteQR"; string data = string.Format("?sId={0}", 100); url += data; string res = HttpHelper.RequestUrlSendMsg(url, HttpHelper.HttpMethod.Post, data, "application/x-www-form-urlencoded"); SSOQR obj = JsonConvert.DeserializeObject <SSOQR>(res); //qr.TargetUrl = obj.TargetUrl; System.Drawing.Image bkImg = ImgHelper.GetImgFromUrl(obj.TargetUrl); string filePath = "/Content/QR/ShuaDan.jpg"; //// qr.OrigFilePath = filePath; string fullPath = context.Server.MapPath(filePath); // bkImg.Save(fullPath); Bitmap logo = new Bitmap(context.Server.MapPath(@"/Content/QR/TX_Logo_100.png")); Bitmap finImg = ImgHelper.ImageWatermark(new Bitmap(bkImg), logo); // filePath = "/Content/QR/ShuaDan.jpg"; // qr.FilePath = filePath; // fullPath = context.Server.MapPath(filePath); finImg.Save(fullPath); finImg.Dispose(); bkImg.Dispose(); // return qr; } catch (Exception ex) { r.ErrorMsg = ex.Message; throw ex; } return(r); }
public OutAPIResult SetNickName() { OutAPIResult result = new OutAPIResult(); string NickName = HttpContext.Current.Request["NickName"]; string phone = HttpContext.Current.Request["Phone"]; NLogHelper.InfoTxt(string.Format("Set Nick Name:{0}.Phone:{1}", NickName, phone)); try { if (string.IsNullOrEmpty(phone)) { result.ErrorMsg = "【B】手机号没有获取"; return(result); } if (string.IsNullOrEmpty(NickName)) { result.ErrorMsg = "【B】昵称没有获取"; return(result); } using (OOContent db = new OOContent()) { var pList = new List <SqlParameter>(); pList.Add(new SqlParameter("@NickName", NickName)); pList.Add(new SqlParameter("@Phone", phone)); var sql = @"update UserInfo set NickName = @NickName where Phone = @Phone "; result.IntMsg = db.Database.ExecuteSqlCommand(sql, pList.ToArray()); if (result.IntMsg <= 0) { result.ErrorMsg = "没有找到对应的用户更新"; } } } catch (Exception ex) { result.ErrorMsg = ex.Message; } return(result); }
public OutAPIResult UserEntryRoom(string roomCode) { OutAPIResult r = new OutAPIResult(); try { //登记用户 r = RoomUserRedis.UserLogin(_UserOpenId, roomCode); if (r.IsSuccess) { //用户进入房间 r = RoomUserRedis.UserEntryRoom(_UserOpenId, roomCode); _RoomCode = roomCode; } } catch (Exception ex) { r.ErrorMsg = ex.Message; } return(r); }
public OutAPIResult GameUserRegister_WX(GameModel.EUserInfo user) { OutAPIResult result = new OutAPIResult(); try { using (GameContent db = new GameContent()) { user.RegisterDate = DateTime.Now; user.LastLogin = DateTime.Now; user.LoginCount = 1; db.DBUserInfo.Add(user); db.SaveChanges(); } } catch (Exception ex) { result.ErrorMsg = ex.Message; } return(result); }
public OutAPIResult InsertBanner() { OutAPIResult result = new OutAPIResult(); try { using (OOContent db = new OOContent()) { EBanner obj = new EBanner(); obj.BannerImg = "/Content/Images/AppBanner/Banner1.png"; obj.Title = "最新公告"; obj.CreatedTime = DateTime.Now; obj.Position = 1; db.DBBanner.Add(obj); db.SaveChanges(); } } catch (Exception ex) { result.IsSuccess = false; result.ErrorMsg = ex.Message; } return(result); }
public OutAPIResult UpdateHeaderImage() { OutAPIResult result = new OutAPIResult(); Stream stream; int maxSize = 10; string phone = HttpContext.Current.Request["UserPhone"]; try { if (string.IsNullOrEmpty(phone)) { result.ErrorMsg = "【B】手机号没有获取"; return(result); } HttpPostedFile file0 = HttpContext.Current.Request.Files[0]; int size = file0.ContentLength / 1024; //文件大小KB if (size > maxSize * 1024) { result.ErrorMsg = string.Format("文件过大,不能超过{0}M", maxSize); return(result); } byte[] fileByte = new byte[2]; //contentLength,这里我们只读取文件长度的前两位用于判断就好了,这样速度比较快,剩下的也用不到。 stream = file0.InputStream; stream.Read(fileByte, 0, 2); //contentLength,还是取前两位 string fileFlag = ""; if (fileByte != null || fileByte.Length <= 0)//图片数据是否为空 { fileFlag = fileByte[0].ToString() + fileByte[1].ToString(); } //extDir.Add("255216", "jpg"); if (fileFlag != "255216") { result.ErrorMsg = "图片格式不正确"; return(result); } string fileName = "user_" + phone + ".jpg"; string saveFullPath = SysConfig.ImageSaveDir + "\\" + fileName; NLogHelper.InfoTxt("Save Paht:" + saveFullPath); OutAPIResult updateResult = ImgHelper.UploadImg(saveFullPath); if (updateResult.IsSuccess) { using (OOContent db = new OOContent()) { var dbImgUrl = SysConfig.ImageSaveDBRoot + fileName; var pList = new List <SqlParameter>(); pList.Add(new SqlParameter("@imgUrl", dbImgUrl)); pList.Add(new SqlParameter("@Phone", phone)); var sql = @"update UserInfo set HeaderImgUrl = @imgUrl where Phone = @Phone "; db.Database.ExecuteSqlCommand(sql, pList.ToArray()); } } else { result.ErrorMsg = result.ErrorMsg; } } catch (Exception ex) { result.ErrorMsg = ex.Message; } return(result); }
public NResult <EUserInfo> Register(InUserReg userReg) { NResult <EUserInfo> result = new NResult <EUserInfo>(); EUserInfo ui = null; EUserQRInvite pQR = null; SMSController smsController = new SMSController(); try { if (string.IsNullOrEmpty(userReg.Phone)) { result.ErrorMsg = "手机号不能未空"; return(result); } if (string.IsNullOrEmpty(userReg.Pwd)) { result.ErrorMsg = "密码不能为空"; return(result); } if (string.IsNullOrEmpty(userReg.VerifyCode)) { result.ErrorMsg = "验证码不能为空"; return(result); } OutAPIResult smsResult = smsController.ConfirmVerification(userReg.Phone, userReg.VerifyCode); if (!smsResult.IsSuccess) { result.ErrorMsg = smsResult.ErrorMsg; return(result); } using (OOContent db = new OOContent()) { using (TransactionScope ts = new TransactionScope()) { //创建用户基本信息 ui = db.DBUserInfo.Where(a => a.Phone == userReg.Phone).FirstOrDefault(); if (ui != null) { result.ErrorMsg = "手机号已存在"; return(result); } ui = new EUserInfo(); //如果昵称或登陆名为空,则用手机号补充 if (string.IsNullOrEmpty(userReg.LoginName)) { ui.LoginName = userReg.Phone; } if (string.IsNullOrEmpty(userReg.NickName)) { ui.NickName = userReg.Phone; } ui.Phone = userReg.Phone; ui.Pwd = userReg.Pwd; ui.UserRole = IQBCore.OO.BaseEnum.UserRole.User; ui.RecordStatus = IQBCore.OO.BaseEnum.RecordStatus.Normal; ui.RegisterDateTime = DateTime.Now; ui.RegisterChannel = RegisterChannel.OOAPP; db.DBUserInfo.Add(ui); //检查邀请码 if (!string.IsNullOrEmpty(userReg.InviteCode)) { pQR = db.DBUserQRInvite.Where(a => a.InviteCode == userReg.InviteCode).FirstOrDefault(); if (pQR == null) { result.ErrorMsg = "邀请码没有找到对应的用户"; return(result); } } db.SaveChanges(); //创建用户邀请码 EUserQRInvite qr = new EUserQRInvite { InviteCode = StringHelper.GenerateUserInviteCode(ui.Phone), QRPath = "", QRUrl = "", UserId = ui.Id }; db.DBUserQRInvite.Add(qr); //用户关系 EUserRelation ur = new EUserRelation(); ur.UserId = ui.Id; ur.UserName = ui.NickName; if (pQR != null) { ur.PId = pQR.UserId; } db.DBUserRelation.Add(ur); //用户账户 EUserBalance ub = new EUserBalance(); ub.UserId = ui.Id; ub.Balance = 0; ub.CurrencyCode = CoreStatic.Instance.Sys.CurCurrencyCode; db.DBUserBalance.Add(ub); //用户回报 EUserReward reward = new EUserReward(); reward.UserId = ui.Id; reward.ADRewardRate = CoreStatic.Instance.Sys.ADRewardRate; reward.OrderRewardRate = CoreStatic.Instance.Sys.L1RewardRate; reward.IntroRate = CoreStatic.Instance.Sys.IntroRate; db.DBUserReward.Add(reward); //绑定用户设备和用户手机号 UpdateDevice(userReg.DeviceIdentify, userReg.Phone, db); db.SaveChanges(); ts.Complete(); } result.resultObj = ui; } } catch (Exception ex) { result.ErrorMsg = ex.Message; ErrorToDb(ex.Message); } return(result); }