public Int32 Index(string user, string domain, string sign) { //XTrace.WriteLine("user:{0} domain:{1} sign:{2}", user, domain, sign); //查询对应域名服务器是否存在 tgm_server.SetDbConnName(DBConnect.GetName(null)); var server = tgm_server.GetGameServer(domain); if (server == null) { return(2); //return Json(new BaseEntity() //{ // result = 2, // message = "服务器不存在,请确认游戏服域名正确并已被添加到后台", //}, JsonRequestBehavior.AllowGet); } //票据检查 md5(user_ domain _平台密钥) var encrypt = server.Platform.encrypt; var ck = string.Format("{0}_{1}_{2}", user, domain, encrypt); var md5 = UConvert.MD5(ck); var chksum = md5; if (sign != md5) { return(3); // return Json(new BaseEntity() // { // result = 3, //#if DEBUG // message = "md5错误,请确认密钥正确,充值票据算法跟文档描述一致,参与票据计算的参数于传递给接口的参数一致" + chksum, //#endif //#if !DEBUG // message = " md5错误,请确认密钥正确,充值票据算法跟文档描述一致,参与票据计算的参数于传递给接口的参数一致", //#endif // }, JsonRequestBehavior.AllowGet); } //账号检查 tg_user.SetDbConnName(DBConnect.GetName(server)); var player = tg_user.GetEntityByCode(user); if (player == null) { return(4); //return Json(new BaseEntity() //{ // result = 4, // message = "玩家账号未创建角色", //}, JsonRequestBehavior.AllowGet); } return(1); //return Json(new BaseEntity() //{ // result = 1, // message = "成功,玩家账号存在", //}, JsonRequestBehavior.AllowGet); }
protected override int GetBodyLengthFromHeader(byte[] header, int offset, int length) { var bl = new byte[4]; Array.Copy(header, offset + 4, bl, 0, 4); var len = UConvert.ByteToInt(bl); return(len); }
/// <summary> /// Construtor com serialização /// </summary> /// <param name="arquivoXML">arquivo a ser lido</param> /// <param name="dadosEmpresa">dados da empresa</param> public BloquearSAT(string arquivoXML, Empresa dadosEmpresa) { FileStream fs = new FileStream(arquivoXML, FileMode.Open, FileAccess.ReadWrite); XmlDocument doc = new XmlDocument(); doc.Load(fs); fs.Close(); fs.Dispose(); DadosEmpresa = dadosEmpresa; ArquivoXML = arquivoXML; Marca = UConvert.ToEnum <EnunsSAT.Fabricante>(DadosEmpresa.MarcaSAT); CodigoAtivacao = DadosEmpresa.CodigoAtivacaoSAT; }
/// <summary> /// Construtor com serialização /// </summary> /// <param name="arquivoXML">arquivo a ser lido</param> /// <param name="dadosEmpresa">dados da empresa</param> public ConsultarSAT(string arquivoXML, Empresa dadosEmpresa) { FileStream fs = new FileStream(arquivoXML, FileMode.Open, FileAccess.ReadWrite); XmlDocument doc = new XmlDocument(); doc.Load(fs); fs.Close(); fs.Dispose(); DadosEmpresa = dadosEmpresa; ArquivoXML = arquivoXML; ConsultarEnvio = DeserializarObjeto <Servicos.Envio.ConsultarSAT>(); Marca = UConvert.ToEnum <EnunsSAT.Fabricante>(DadosEmpresa.MarcaSAT); CodigoAtivacao = DadosEmpresa.CodigoAtivacaoSAT; }
/// <summary> /// Construtor com serialização /// </summary> /// <param name="arquivoXML">arquivo a ser lido</param> /// <param name="dadosEmpresa">dados da empresa</param> public ConsultarNumeroSessao(string arquivoXML, Empresa dadosEmpresa) { FileStream fs = new FileStream(arquivoXML, FileMode.Open, FileAccess.ReadWrite); XmlDocument doc = new XmlDocument(); doc.Load(fs); fs.Close(); fs.Dispose(); DadosEmpresa = dadosEmpresa; ArquivoXML = arquivoXML; ConsultarNumeroSessaoEnvio = doc.InnerXml; NumeroSessao = Convert.ToInt32(GetValueXML(doc, "ConsultarNumeroSessao", "NumeroSessao")); Marca = UConvert.ToEnum <EnunsSAT.Fabricante>(DadosEmpresa.MarcaSAT); CodigoAtivacao = DadosEmpresa.CodigoAtivacaoSAT; }
/// <summary> /// Construtor com serialização /// </summary> /// <param name="arquivoXML">arquivo a ser lido</param> /// <param name="dadosEmpresa">dados da empresa</param> public AssociarAssinatura(string arquivoXML, Empresa dadosEmpresa) { FileStream fs = new FileStream(arquivoXML, FileMode.Open, FileAccess.ReadWrite); Document.Load(fs); fs.Close(); fs.Dispose(); CNPJValue = GetValueXML(Document, "AssociarAssinatura", "CNPJvalue"); AssinaturaCNPJs = GetValueXML(Document, "AssociarAssinatura", "assinaturaCNPJs"); DadosEmpresa = dadosEmpresa; ArquivoXML = arquivoXML; Marca = UConvert.ToEnum <EnunsSAT.Fabricante>(DadosEmpresa.MarcaSAT); CodigoAtivacao = DadosEmpresa.CodigoAtivacaoSAT; }
/// <summary> /// Construtor com serialização /// </summary> /// <param name="arquivoXML">arquivo a ser lido</param> /// <param name="dadosEmpresa">dados da empresa</param> public AtivarSAT(string arquivoXML, Empresa dadosEmpresa) { FileStream fs = new FileStream(arquivoXML, FileMode.Open, FileAccess.ReadWrite); Document.Load(fs); fs.Close(); fs.Dispose(); SubComando = Convert.ToInt32(GetValueXML(Document, "AtivarSAT", "SubComando")); CNPJ = GetValueXML(Document, "AtivarSAT", "CNPJ"); CodigoUF = Convert.ToInt32(GetValueXML(Document, "AtivarSAT", "CodigoUF")); DadosEmpresa = dadosEmpresa; ArquivoXML = arquivoXML; Marca = UConvert.ToEnum <EnunsSAT.Fabricante>(DadosEmpresa.MarcaSAT); CodigoAtivacao = DadosEmpresa.CodigoAtivacaoSAT; }
/// <summary> /// Construtor com serialização /// </summary> /// <param name="arquivoXML">arquivo a ser lido</param> /// <param name="dadosEmpresa">dados da empresa</param> public CancelarUltimaVenda(string arquivoXML, Empresa dadosEmpresa) { FileStream fs = new FileStream(arquivoXML, FileMode.Open, FileAccess.ReadWrite); XmlDocument doc = new XmlDocument(); doc.Load(fs); fs.Close(); fs.Dispose(); XmlNodeList elemList = doc.GetElementsByTagName("infCFe"); ChaveAcessoVenda = elemList[0].Attributes["chCanc"].Value; DadosEmpresa = dadosEmpresa; ArquivoXML = arquivoXML; Marca = UConvert.ToEnum <EnunsSAT.Fabricante>(DadosEmpresa.MarcaSAT); CodigoAtivacao = DadosEmpresa.CodigoAtivacaoSAT; CancelarUltimaVendaEnvio = doc.InnerXml; }
public ActionResult Recharge(FormCollection collection) { if (!IsLogin) { return(Redirect("/Home/Login")); } //token|sid|user_code|player_id|player_name|order_id|channel|type|amount|key var pay_token = collection["pay_token"]; var pay_sid = collection["pay_sid"]; var pay_user_code = collection["pay_user_code"]; //var pay_player_id = collection["pay_player_id"]; //var pay_player_name = collection["pay_player_name"]; var pay_order_id = collection["pay_order_id"]; var pay_channel = collection["pay_channel"]; var pay_type = collection["pay_type"]; var pay_amount = collection["pay_amount"]; var param = string.Format("{0}|{1}|{2}|{3}|{4}|{5}|{6}", pay_token, pay_sid, pay_user_code, pay_order_id, pay_channel, pay_type, pay_amount); var chk = string.Format("{0}|{1}", param, "15B5EACDB05E66D"); //加密字符 var chksum = UConvert.MD5(chk); //POST api/Common?param={param}&checksum={checksum} var api = new ApiReceive() { URL = string.Format("{0}", ConfigHelper.GetApiUrl()), Resource = string.Format("api/Common?param={0}&checksum={1}", param, chksum), }; var result = api.PostJsonToParameter(); api.Dispose(); var be = CommonHelper.Deserialize <BaseEntity>(result); ViewBag.Error = be.result; ViewBag.Message = be.message; return(View(user)); }
public ActionResult Index(FormCollection collection) { var user = collection["user"]; var domain = collection["domain"]; var encrypt = collection["encrypt"]; var ck = string.Format("{0}_{1}_{2}", user, domain, encrypt); var md5 = UConvert.MD5(ck); var chksum = md5; var url1 = string.Format("login?adult=1&time={0}&user={1}&sign={2}", domain, user, chksum); var url2 = string.Format("check?domain={0}&user={1}&sign={2}", domain, user, chksum); return(View(new ToolsEnitiy { user = user, domain = domain, encrypt = encrypt, chksum = chksum, url1 = url1, url2 = url2, })); }
public Int32 Index(String user, Int32 money, String order, string domain, String sign) { //查询对应域名服务器是否存在 tgm_server.SetDbConnName(DBConnect.GetName(null)); var server = tgm_server.GetGameServer(domain); if (server == null) { return(2); //return Json(new BaseEntity() //{ // result = 2, // message = "充值的服务器不存在,请确认游戏服域名正确并已被添加到后台", //}, JsonRequestBehavior.AllowGet); } //票据检查 md5(user_money_order_domain_平台密钥) var encrypt = server.Platform.encrypt; var ck = string.Format("{0}_{1}_{2}_{3}_{4}", user, money, order, domain, encrypt); var md5 = UConvert.MD5(ck); var chksum = md5; if (sign != md5) { return(5); // return Json(new BaseEntity() // { // result = 5, //#if DEBUG // message = "md5错误,请确认密钥正确,充值票据算法跟文档描述一致,参与票据计算的参数于传递给接口的参数一致" + chksum, //#endif //#if !DEBUG // message = "md5错误,请确认密钥正确,充值票据算法跟文档描述一致,参与票据计算的参数于传递给接口的参数一致", //#endif // }, JsonRequestBehavior.AllowGet); } //订单号验证 tgm_record_pay.SetDbConnName(DBConnect.GetName(null)); var _pay = tgm_record_pay.FindCount(string.Format("order_id='{0}'", order), null, null, 0, 0); if (_pay > 0) { return(9); } //账号检查 tg_user.SetDbConnName(DBConnect.GetName(server)); var player = tg_user.GetEntityByCode(user); if (player == null) { return(7); //return Json(new BaseEntity() //{ // result = 7, // message = "不存在此账号,请确认用户名和登录接口传递的是一致的", //}, JsonRequestBehavior.AllowGet); } //令牌|游戏服编号|玩家账号|订单号|渠道|充值类型|充值数值|平台加密字符串 var param = string.Format("{0}|{1}|{2}|{3}|{4}|{5}|{6}", server.Platform.token, server.id, user, order, 1, (int)PayType.RMB, money); var chk = string.Format("{0}|{1}", param, encrypt); //加密字符 var api_chksum = UConvert.MD5(chk); //POST api/Common?param={param}&checksum={checksum} var api = new ApiReceive() { URL = string.Format("{0}", ConfigHelper.GetApiUrl()), Resource = string.Format("api/Common?param={0}&checksum={1}", param, api_chksum), }; var result = api.PostJsonToParameter(); api.Dispose(); var be = CommonHelper.Deserialize <BaseEntity>(result); if (be.result == (int)ApiType.OK) { return(1); //return Json(new BaseEntity() //{ // result = 1, // message = "充值成功", //}, JsonRequestBehavior.AllowGet); } else { return(be.result); //return Json(be, JsonRequestBehavior.AllowGet); } }
/// <summary>充值接口</summary> /// <param name="param">充值参数字符串 /// token|sid|user_code|order_id|channel|type|amount /// 令牌|游戏服编号|玩家账号|订单号|渠道|充值类型|充值数值 /// </param> /// <param name="checksum">param的MD5校验和 /// MD5字符串token|sid|user_code|order_id|channel|type|amount|key /// 令牌|游戏服编号|玩家账号|订单号|渠道|充值类型|充值数值|平台加密字符串 /// </param> /// <returns>充值后状态结果值</returns> public BaseEntity PostPayment(String param, String checksum) { //key : 解析param用 //param:充值封装字符串 格式: token|sid|user_code|order_id|channel|type|amount //checksum: MD5字符串token|sid|user_code|order_id|channel|type|amount|key //var t = string.Format("{0}|{1}|{2}|{3}|{4}|{5}|{6}|{7}", "0c372ec3-1b00-4286-84a8-9216e7ab59e3", 1, "", 1, "", 1, 1, 100); //var _t0 = string.Format("{0}|{1}", t, "123456"); //解析 var s = param.Split(new[] { '|' }, StringSplitOptions.RemoveEmptyEntries); if (s.Length == 7) { var _token = s[0]; var _sid = Convert.ToInt32(s[1]); var _user_code = s[2]; var _order_id = s[3]; var _channel = s[4]; var _type = Convert.ToInt32(s[5]); var _amount = Convert.ToInt32(s[6]); if (!IsToken(_token)) { return new BaseEntity { result = (int)ApiType.FAIL, message = "令牌错误" } } ; //验证会话 var ck = string.Format("{0}|{1}", param, Token.encrypt); var md5 = UConvert.MD5(ck); if (checksum == md5)//参数校验 { //获取游戏服信息 tgm_server.SetDbConnName(tgm_connection); var server = tgm_server.FindByid(_sid); if (server == null) { return new BaseEntity { result = (int)ApiType.FAIL, message = "游戏服务器不存在" } } ; SN = server.name; tg_user.SetDbConnName(db_connection); var user = tg_user.GetEntityByCode(_user_code); if (user == null) { return new BaseEntity { result = (int)ApiType.FAIL, message = "玩家账号不存在" } } ; var ip = server.ip; var port = server.port_server; //var conn = server.connect_string; //解析后调用游戏接口判断是否成功 var gold = UConvert.ToGold(_amount, _type); var api = new CommandApi(ip, port, ApiCommand.充值); var state = api.Recharge(user.id, gold); api.Dispose(); if (state == (int)ApiType.OK) { tgm_record_pay.SetDbConnName(tgm_connection); var entity = new tgm_record_pay() { sid = _sid, user_code = _user_code, player_id = user.id, player_name = user.player_name, order_id = _order_id, channel = _channel, pay_type = _type, amount = gold, pay_state = state, createtime = DateTime.Now.Ticks, money = _amount, }; //无论成功,存入后台数据库这条数据记录 entity.Save(); //同步数据 tgm_record_pay.Proc_sp_pay_syn(entity.id); return(new BaseEntity { result = (int)ApiType.OK, message = "充值成功" }); } return(new BaseEntity { result = state, message = "充值未达到玩家账号" }); } else { return(new BaseEntity { result = (int)ApiType.FAIL, message = "参数校验错误,传递参数被修改" }); } } return(new BaseEntity { result = (int)ApiType.FAIL, message = "传递参数解析错误" }); }
public ActionResult Index(String user, String sign, Int64 time = 0, Int32 adult = 1) { var info = new BaseEntity(); if (Request.Url == null) { info.result = 404; info.message = "请求路径错误"; return(View(info)); } //参数验证 if (String.IsNullOrEmpty(user) || String.IsNullOrEmpty(sign) ) { info.result = 1; info.message = string.Format("请求格式错误:?adult=1&time=0&user=***&sign=***"); return(View(info)); } //时间戳验证 TimeSpan delta = TimeSpan.FromMilliseconds(time * 1000); System.DateTime startTime = TimeZone.CurrentTimeZone.ToLocalTime(new System.DateTime(1970, 1, 1)); DateTime curTime = startTime.Add(delta); DateTime dt = curTime; DateTime nowTime = DateTime.Now; var sub = nowTime.Subtract(dt).TotalSeconds; //有效时间10分钟 600秒 if (sub < 0 || sub > 600) { info.result = 1; info.message = string.Format("登陆超时"); return(View(info)); } // var domain = String.Format("{0}{1}", Request.Url.Host, Request.Url.Port == 80 ? "" : ":" + Request.Url.Port); tgm_server.SetDbConnName(DBConnect.GetName(null)); var server = tgm_server.GetGameServer(domain); if (server == null) { info.result = 1; info.message = string.Format("服务器不存在,请确认游戏服域名正确并已被添加到后台,请求格式参数:?adult=1&time=0&user=***&sign=***"); return(View(info)); } if (server.server_state == 0 || server.server_state == 1) { info.result = 501; info.message = string.Format("服务器当前状态:{0}", server.server_state == 0 ? "未启服" : "停服"); return(View(info)); } //票据检查 md5(user_time_平台密钥) var encrypt = server.Platform.encrypt; var ck = string.Format("{0}_{1}_{2}", user, time, encrypt); var md5 = UConvert.MD5(ck); var chksum = md5; if (sign != md5) { info.result = 2; #if DEBUG info.message = "md5错误,请确认密钥正确,充值票据算法跟文档描述一致,参与票据计算的参数于传递给接口的参数一致 " + chksum; #endif #if !DEBUG info.message = "md5错误,请确认密钥正确,充值票据算法跟文档描述一致,参与票据计算的参数于传递给接口的参数一致"; #endif return(View(info)); } //用户名加密 md5(user_game密钥) var game_key = ConfigHelper.GetAppSettings("gamekey"); var game_user = UConvert.CryptoString(CryptoHelper.Encrypt(user, game_key)); var data = String.Format("userName={0}&isAdult={1}&serverIp={2}&port={3}&portPolicy={4}" , game_user, adult, server.ip, server.port_server, server.port_policy); //var data = "userName=arlen0101&isAdult=1&connectServer=1&server=1&serverIp=192.168.1.254&port=10086&portPolicy=10087"; //ViewBag.js = string.Format("\"{0}\"", data); //ViewBag.languageType = string.Format("{0}", ConfigHelper.GetAppSettings("languageType")); //ViewBag.resourceRootPath = string.Format("\"{0}\"", ConfigHelper.GetAppSettings("resourceRootPath")); //var _domain = String.Format("{0}{1}", Request.Url.Host, Request.Url.Port == 80 ? "" : ":" + Request.Url.Port); //ViewBag.rechargetUrl = string.Format("\"{0}?domain={1}\"", ConfigHelper.GetAppSettings("rechargetUrl"), _domain); //ViewBag.homeUrl = string.Format("\"{0}\"", ConfigHelper.GetAppSettings("homeUrl")); var _data = String.Format("\"{0}\"", data); var _state = server.server_state; //TempData["data"] = //TempData["state"] = server.server_state; Session.Clear(); Session.Add("login", new LoginEntity { data = _data, state = _state }); Session.Timeout = 60; return(RedirectToAction("Index", "Home")); }