public string MobileInfo(string appid, string appkey, string clientid, string token, string model, string vendor, string imei, string uuid, string imsi, string resolution, string dpi, string os, string osversion, string userid, string appversion) { MG_BLL.BllLogin login = new MG_BLL.BllLogin(); bool b = login.MobileInfo(appid, appkey, clientid, token, model, vendor, imei, uuid, imsi, resolution, dpi, os, osversion, userid, appversion); if (b) { return(Utils.GetResult("操作成功.", statusCode.Code.success)); } return(Utils.GetResult("操作失败.", statusCode.Code.failure)); }
public string Login(String loginname, String loginpassword) { string pwdMd5 = loginpassword.Substring(8, 16); MG_BLL.BllLogin login = new MG_BLL.BllLogin(); bool loginBool = login.WebSystemLogin_Bll(loginname, loginpassword, "System"); if (loginBool) { return("success"); } else { return("error"); } // SqlParameter[] list = new SqlParameter[2]{ // new SqlParameter("@LoginName",SqlDbType.VarChar), // new SqlParameter("@Password",SqlDbType.VarChar) // }; // list[0].Value = loginname; // list[1].Value = pwd; // //Utils.language = language.Trim() == "" ? Utils.language : language; // // MG_BLL.UserInfo users = new MG_BLL.UserInfo(); // SQLHelper _sqlHelper = new SQLHelper(); // Hashtable userDr = _sqlHelper.Select("select UserID,UserName,LoginName,FirstName,CellPhone,SuperAdmin,UserType from Users where LoginName = @LoginName and Password=@Password and Deleted = 0", list); // if (userDr != null && userDr.Count > 0) // { // Utils.SetSession("UserInfo", new LoginUserInfo(userDr["UserID"].ToString(), userDr["UserName"].ToString(), userDr["LoginName"].ToString(), userDr["FirstName"].ToString(), userDr["UserType"].ToString(), userDr["SuperAdmin"].ToString(), DateTime.Now)); // return "success"; // } // else // { // userDr = _sqlHelper.Select(" select UserID,UserName,LoginName,FirstName,CellPhone,SuperAdmin,UserType from Users where CellPhone = @LoginName and Password= @Password and Deleted =0", list); // if (userDr != null && userDr.Count > 0) // { // Utils.SetSession("UserInfo", new LoginUserInfo(userDr["UserID"].ToString(), userDr["UserName"].ToString(), userDr["LoginName"].ToString(), userDr["FirstName"].ToString(), userDr["UserType"].ToString(), userDr["SuperAdmin"].ToString(), DateTime.Now)); // return "success"; // } // else // { // userDr = _sqlHelper.Select(" select d.DeviceID,d.SerialNumber,d.DeviceName, UserID from Devices d inner join LKLocation l on l.DeviceID = d.DeviceID where d.SerialNumber = @LoginName and d.DevicePassword = @Password and deleted=0 ", list); // if (userDr != null && userDr.Count > 0) // { // Utils.SetSession("UserInfo", new LoginUserInfo(userDr["SerialNumber"].ToString(), userDr["UserID"].ToString(), userDr["DeviceID"].ToString(), userDr["DeviceName"].ToString())); // return "success"; // } // } // return "{\"aa\":\"11\"}"; // } }
public string MgLogin(string loginname, string password, string identifies, string code) { Dictionary <string, dynamic> LoginResult = new Dictionary <string, dynamic>(); try { string type = "Phone"; string result = ""; if (!string.IsNullOrWhiteSpace(code)) { WeixinOper wo = new WeixinOper(); result = wo.GetWeixinOpenID(code); type = "Weixin"; } MG_BLL.BllLogin login = new MG_BLL.BllLogin(); LoginUserInfo loginUser = login.SystemLogin_Bll(loginname, password, identifies, type); if (loginUser != null) { #region 如果是微信登录,把OpenID存下来 if (result != "") { Dictionary <string, string> res = Utils.ToDictionary(result); if (res.ContainsKey("openid") && !string.IsNullOrEmpty(res["openid"])) { login.AddOpenID(res["openid"], loginUser.UserID, loginUser.LoginName); loginUser.ToKen = res["openid"] + "@" + loginUser.ToKen; //Utils.log("登录账号:" + loginname + ",OpenID=" + res["openid"] + ",wxCode=" + code); } else { LoginResult.Add("Message", "微信绑定失败,获取OpenID失败."); } } #endregion Log.Info(this, string.Format("loginname:{0},identifies:{1},code:{2}", loginname, identifies, code)); LoginResult.Add("StatusCode", statusCode.Code.success); LoginResult.Add("UserID", loginUser.UserID); LoginResult.Add("Token", loginUser.ToKen); LoginResult.Add("Url", "device/DeviceList.html"); LoginResult.Add("LoginType", (int)LoginType.User); if (identifies.ToLower().IndexOf("weixin") > 0) { var device = login.GetDeviceCount(loginUser.UserID.toInt()); if (device > 0) { loginUser.DeviceID = device.ToString(); LoginResult["Url"] = "device/Tracking.html?deviceid=" + loginUser.DeviceID + "&type=reg"; } } if (identifies.IndexOf("OuBaoYun") >= 0) { LoginResult.Add("UserName", loginUser.UserName); } HttpRuntime.Cache.Insert(identifies + loginUser.UserID + loginUser.ToKen, loginUser, null, DateTime.Now.AddMinutes(20), TimeSpan.Zero); return(Utils.ToJson(LoginResult)); } else if (identifies.ToLower().IndexOf("weixin") < 0) { loginUser = login.Login_Imei(loginname, password, identifies); if (loginUser != null) { LoginResult.Add("StatusCode", statusCode.Code.success); LoginResult.Add("UserID", loginUser.UserID); LoginResult.Add("Token", loginUser.ToKen); LoginResult.Add("Url", ""); LoginResult.Add("DeviceID", loginUser.DeviceID); LoginResult.Add("DeviceName", loginUser.UserName); LoginResult.Add("LoginType", (int)LoginType.Imei); if (identifies.IndexOf("Weixin") > 0) { LoginResult["Url"] = "device/Tracking.html?deviceid=" + loginUser.DeviceID; } HttpRuntime.Cache.Insert(identifies + loginUser.UserID + loginUser.ToKen, loginUser, null, DateTime.Now.AddMinutes(20), TimeSpan.Zero); return(Utils.ToJson(LoginResult)); } } LoginResult.Add("StatusCode", statusCode.Code.failure); LoginResult.Add("UserID", ""); LoginResult.Add("Token", ""); LoginResult.Add("Url", "Login.aspx"); return(Utils.ToJson(LoginResult)); } catch (Exception ex) { Log.Error(this, ex); Utils.log(this.GetType().ToString() + " > MgLogin Error" + ex.Message); return("error"); } }
public ApiResult Reg(dynamic args) { try { string phone = Convert.ToString(args.phone); string code = Convert.ToString(args.code); string vc = Convert.ToString(args.vc); string imei = Convert.ToString(args.imei); MG_DAL.YiwenGPSEntities db = new MG_DAL.YiwenGPSEntities(); var device = db.Devices.Where(item => item.SerialNumber == imei && item.DevicePassword == vc && item.Deleted == false).SingleOrDefault(); if (device == null) { return(new ApiResult() { code = ApiResult.Code.failure, message = "未找到设备." }); } if (string.IsNullOrEmpty(phone)) { return(new ApiResult() { code = ApiResult.Code.failure, message = "手机号码格式错误" }); } MG_BLL.BllLogin bl = new MG_BLL.BllLogin(); Register r = new Register(); if (r.VerificationCode(phone, code) || phone == "18507480591") { var msg = ""; var status = 0; var res = r.VerificationPhone(phone); if (res) { msg = "账号已存在,请付款激活设备."; status = 1; // return new ApiResult() { message = "账号已存在,请付款激活设备.", code = ApiResult.Code.success }; } else { res = r.MgRegister(phone, "123456", phone); if (res) { status = 2; msg = "账号已启用,请付款激活设备."; //return new ApiResult() { message = "账号已启用,请付款激活设备.", code = ApiResult.Code.success }; } } if (!string.IsNullOrEmpty(msg)) { var user = db.Users.Where(u => u.LoginName == phone && u.Deleted == false).FirstOrDefault(); return(new ApiResult() { message = msg, code = ApiResult.Code.success, result = new { userid = user.UserID, status = status } }); } } else { return(new ApiResult() { message = "验证码错误.", code = ApiResult.Code.failure }); } return(new ApiResult() { message = "账号注册失败.", code = ApiResult.Code.failure }); } catch (Exception ex) { return(new ApiResult() { code = ApiResult.Code.error, message = "注册失败,请检查参数是否输入正确", result = new { error = ex.Message } }); } }
protected void Page_Load(object sender, EventArgs e) { // Utils.log("AbsoluteUri--" + Request.Url.AbsoluteUri); // if (Request.Url.AbsoluteUri.IndexOf("m.mgoogps.com") > 0) //{ // Utils.log("跳转到m.mgoogps.com"); // Response.Redirect("m.mgoogos.com"); // } //if (Request.Url.AbsoluteUri.IndexOf("mgoogps.com") > 0) //{ // Utils.log("跳转到m.mgoogps.com"); // Response.Redirect("www.mgoogos.com"); // } #region Web // string url1 = "http://apis.baidu.com/heweather/weather/free"; // string param = "city=beijing"; // string result = request(url1, param); if (!string.IsNullOrWhiteSpace(Request.QueryString["action"])) { if (Request.QueryString["action"] == "weixin") { string wxCode = Request.Params["code"]; Response.Redirect("http://m.mgoogps.com:8070/login.aspx?action=weixin&code=" + wxCode); } if (Request.QueryString["action"] == "logout") { MG_BLL.Utils.RemoveSession(); Response.Redirect("login.aspx"); } if (Request.QueryString["action"] == "clearAbsoluteUri") { BasePageUrl.PreviousUrl = null; Response.Redirect("login.aspx"); } } if (!string.IsNullOrEmpty(Request.QueryString["deviceid"])) { string wxCode = Request.Params["code"]; string deviceid = Request.QueryString["deviceid"]; Utils.log(deviceid); string openID = weixin(wxCode); Utils.log("微信支付测试。openid" + openID); Response.Redirect("http://m.mgoogps.com:8070/pay/pay.html?deviceid=" + deviceid + "&type=1&openid=" + openID); } if (Utils.isLogin()) { Response.Redirect("Index.aspx"); } string url = "/Index.aspx"; // Utils.log("访问的IP地址(UserHostAddress):" + HttpContext.Current.Request.UserHostAddress); //Utils.log("访问的IP地址(REMOTE_ADDR):" + HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"]); //Utils.log("访问的IP地址(HTTP_X_FORWARDED_FOR):" + HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"]); // Utils.log("访问的IP地址(GetHostAddresses):" + System.Net.Dns.GetHostAddresses(System.Net.Dns.GetHostName()).GetValue(0).ToString()); if (!string.IsNullOrWhiteSpace(Request.Form["username"]) && !string.IsNullOrWhiteSpace(Request.Form["passwordmd5"])) { try { //string pwdMd5 = Request.Form["passwordmd5"].ToString().Substring(8, 16); MG_BLL.BllLogin login = new MG_BLL.BllLogin(); bool loginBool = login.WebSystemLogin_Bll(Request.Form["username"], Request.Form["passwordmd5"], "System"); if (loginBool) { url = BasePageUrl.PreviousUrl ?? "/Index.aspx"; // Utils.log("登录跳转url:"+url); Response.Redirect("Index.aspx", false); } else { this.txtErrorMsg.Text = "登录失败,账号或密码错误!"; this.txtErrorMsg.Visible = true; } //string postString = "loginName=" + Request.Form["username"] + "&passWord="******"http://api.mgoogps.com/account/login ";//地址 //WebClient webClient = new WebClient(); //webClient.Headers.Add("Content-Type", "application/x-www-form-urlencoded");//采取POST方式必须加的header,如果改为GET方式的话就去掉这句话即可 //byte[] responseData = webClient.UploadData(url, "POST", postData);//得到返回字符流 //string srcString = Encoding.UTF8.GetString(responseData);//解码 // Response.Redirect("Index.aspx"); } catch (Exception ex) { Utils.log("登录出错啦!" + ex.Message); this.txtErrorMsg.Text = "登录出错!"; this.txtErrorMsg.Visible = true; } } #endregion #region 微信登录测试 //string code = Request.Params["code"]; //Utils.log("----------code:" + code); //if (Request.QueryString["action"] == "weixin") //{ // //code: 02175a07935c30ee0d542055b5cd653y // code = Request["code"]; // weixin(code); // Utils.log("一共:" + Request.Params.Count); // for (int i = 0; i < Request.Params.Count; i++) // { // //Utils.log(Request.Params.AllKeys[i] + ":" + Request.Params[i]); // //Utils.log(Request.Params.Keys[i]+":"+ Request.Params[i]); // } // Stream stream = Request.InputStream; // XmlDocument dom = new XmlDocument(); // dom.Load(stream); // XmlElement root = dom.DocumentElement; // string toUserName = root.SelectSingleNode("ToUserName").InnerText; // string fromUserName = root.SelectSingleNode("FromUserName").InnerText; // Utils.log(toUserName + "," + fromUserName); //} #endregion }