示例#1
0
        /// <summary>
        /// 验证应用和签名是否合法
        /// </summary>
        /// <param name="mode">请求参数实体</param>
        /// <param name="json">请求参数json</param>
        /// <param name="CacheTime">有效查询时间</param>
        /// <returns></returns>
        private QueryRespon Selectparameter(QueryModels mode, string json, int CacheTime)
        {
            QueryRespon qu        = new QueryRespon();
            SelectAPP   selectAPP = new SelectAPP();
            jmp_app     app       = selectAPP.SelectAppId(mode.appid, CacheTime);

            if (app != null)
            {
                //验证签名的方式 参数AIIZ首字母顺序排列md532大写加密
                Dictionary <string, string> dic = JMP.TOOL.JsonHelper.Deserialize <Dictionary <string, string> >(json);
                dic = dic.Where(x => x.Key != "sign").ToDictionary(x => x.Key, x => x.Value);
                string signstr = JMP.TOOL.UrlStr.AzGetStr(dic) + "&key=" + app.a_key;
                string md5str  = JMP.TOOL.MD5.md5strGet(signstr, true).ToUpper();
                if (mode.sign != md5str)
                {
                    return(qu = qu.QueryResp(QueryErrorCode.Code9993));
                }
                else
                {
                    qu = qu.QueryResp(QueryErrorCode.Code100);
                }
            }
            else
            {
                qu = qu.QueryResp(QueryErrorCode.Code9994);
            }
            return(qu);
        }
示例#2
0
        /// <summary>
        /// 根据应用id查询应用
        /// </summary>
        /// <param name="appid">应用id</param>
        /// <param name="CacheTime">缓存时间从配置文件中读取的</param>
        /// <returns></returns>
        public jmp_app SelectAppId(int appid, int CacheTime)
        {
            jmp_app app = new jmp_app();

            JMP.BLL.jmp_app bll      = new JMP.BLL.jmp_app();
            string          Cachekey = "Cachekey" + appid;

            if (JMP.TOOL.CacheHelper.IsCache(Cachekey))                  //判读是否存在缓存
            {
                app = JMP.TOOL.CacheHelper.GetCaChe <jmp_app>(Cachekey); //获取缓存
                if (app == null)
                {
                    app = bll.SelectAppIdStat(appid);
                    if (app != null)
                    {
                        JMP.TOOL.CacheHelper.CacheObjectLocak <jmp_app>(app, Cachekey, CacheTime);//存入缓存
                    }
                }
            }
            else
            {
                app = bll.SelectAppIdStat(appid);
                if (app != null)
                {
                    JMP.TOOL.CacheHelper.CacheObjectLocak <jmp_app>(app, Cachekey, CacheTime);//存入缓存
                }
            }
            return(app);
        }
示例#3
0
文件: PreOrder.cs 项目: dmhai/dxpay
        /// <summary>
        /// 预下单接口通道
        /// </summary>
        /// <param name="json">json字符串</param>
        /// <param name="mode">参数实体类型</param>
        /// <param name="CacheTime">缓存时间</param>
        /// <param name="UserIp">ip地址</param>
        /// <returns></returns>
        public InnerResponse OrderInterface(string json, RequestParameter mode, int CacheTime, string UserIp)
        {
            InnerResponse Inn = new InnerResponse();

            if (!string.IsNullOrEmpty(json))
            {
                pr.ip = UserIp;
                //订单缓存时间
                int bizcodeTime = Int32.Parse(ConfigurationManager.AppSettings["bizcodeTime"]);
                Inn = ValidationParameter(mode, json, bizcodeTime);
                if (Inn.Success)
                {
                    SelectAPP selectAPP = new SelectAPP();
                    jmp_app   app       = selectAPP.SelectAppId(mode.appid, CacheTime);
                    if (app != null)
                    {
                        Apprate apprate = new Apprate();
                        if (mode.paytype > 0 && !apprate.SelectApprate(mode.appid, mode.paytype, CacheTime))
                        {
                            return(Inn = Inn.ToResponse(ErrorCode.Code8987));
                        }
                        pr.appkey = app.a_key;
                        Inn       = ValidationApp(mode, json, app);
                        if (Inn.Success == true)
                        {
                            Inn = DownOrder(mode, json);
                            if (Inn.Success == true)
                            {
                                //设置缓存
                                SetUpCache(mode.bizcode, mode.appid, bizcodeTime);
                                Inn = judge(mode.paytype, app.a_platform_id, app.a_rid, CacheTime, app.a_id);
                            }
                        }
                    }
                    else
                    {
                        Inn = Inn.ToResponse(ErrorCode.Code9998);
                    }
                }
            }
            return(Inn);
        }
示例#4
0
文件: PreOrder.cs 项目: dmhai/dxpay
        /// <summary>
        /// 验证数据是否合法(需要使用查询数据)
        /// </summary>
        /// <param name="mode">请求参数实体</param>
        /// <param name="json">参数json字符串</param>
        /// <param name="app">应用实体</param>
        /// <returns></returns>
        private InnerResponse ValidationApp(RequestParameter mode, string json, jmp_app app)
        {
            InnerResponse Inn = new InnerResponse();

            try
            {
                if (app == null)
                {
                    return(Inn = Inn.ToResponse(ErrorCode.Code9998));
                }
                //验证签名的方式  price + bizcode+timestamp+appkey
                string Verificationsign = mode.price + mode.bizcode + mode.timestamp + app.a_key;
                string sign             = JMP.TOOL.MD5.md5strGet(Verificationsign, true).ToUpper();
                if (mode.sign != sign)
                {
                    PayApiDetailErrorLogger.DownstreamErrorLog("报错信息9989:支付接口签名验证失败,获取到的参数:" + json + ",组装的签名字符串:" + Verificationsign + ",我们生产的签名:" + sign, summary: "接口错误信息", appId: app.a_id, errorType: EnumForLogForApi.ErrorType.Other);

                    return(Inn = Inn.ToResponse(ErrorCode.Code9989));
                }
                //判断终端唯一标示码。ios和安卓模式为必传
                if (app.a_platform_id < 3 && app.a_platform_id > 0)
                {
                    if (string.IsNullOrEmpty(mode.termkey) || mode.termkey.Length > 64)
                    {
                        return(Inn = Inn.ToResponse(ErrorCode.Code9996));
                    }
                }
                else
                {
                    mode.termkey = "";
                }
                if (string.IsNullOrEmpty(mode.address))
                {
                    mode.address = app.a_notifyurl;
                }
                else
                {
                    if (mode.address.Length > 200)
                    {
                        return(Inn = Inn.ToResponse(ErrorCode.Code9995));
                    }
                }

                if (app.a_platform_id == 3)
                {
                    if (string.IsNullOrEmpty(mode.showaddress))
                    {
                        mode.showaddress = app.a_showurl;
                    }
                    else
                    {
                        if (mode.showaddress.Length > 200)
                        {
                            return(Inn = Inn.ToResponse(ErrorCode.Code9994));
                        }
                    }
                }

                if (mode.paytype < 0 || mode.paytype > 8)
                {
                    return(Inn = Inn.ToResponse(ErrorCode.Code9990));
                }
                else
                {
                    if (mode.paytype > 0 && !app.a_paymode_id.Contains(mode.paytype.ToString()))
                    {
                        return(Inn = Inn.ToResponse(ErrorCode.Code105));
                    }
                    else
                    {
                        pr.ThispayType = app.a_paymode_id;
                    }
                }
                Inn = Inn.ToResponse(ErrorCode.Code100);
            }
            catch (Exception e)
            {
                PayApiGlobalErrorLogger.Log("报错信息103:支付接口验证参数错误,获取到的参数:" + json + ",报错信息:" + e.ToString(), summary: "接口错误信息");
                Inn = Inn.ToResponse(ErrorCode.Code103);
            }
            return(Inn);
        }
示例#5
0
 public static AppViewModel ToViewModel(this jmp_app entity)
 {
     return(entity.MapTo <jmp_app, AppViewModel>());
 }
示例#6
0
        // GET: Index
        public ActionResult Index()
        {
            //常规的做法
            // IDBHelper DBHelpers = new DBHelper();//先初始化再执行构造方法
            //DBHelpers.Query();

            IDBHelper idbhelper = SimleFactory.CreateFactory();//调用封装的反射方法

            idbhelper.Query();
            {
                string   name         = ConfigurationManager.AppSettings["name"]; //从配置文件动态获取
                string[] nameArray    = name.Split(',');
                Assembly assembly     = Assembly.Load(nameArray[1]);              //反射的入口 动态的加载dll
                Type     dbHelperType = assembly.GetType(nameArray[0]);           //基于类的完整名称 找出类型
                object   oDBHelper    = Activator.CreateInstance(dbHelperType);   //根据类型,创建对象 编译器能识别的静态类型是object
                //下面一句话可以替代上面三句话
                // object obj = Activator.CreateInstance(nameArray[1], nameArray[0]).Unwrap();

                foreach (MethodInfo method in dbHelperType.GetMethods()) //用 MethodInfo可以找出此类型的所有方法 GetMethods
                {
                    Console.WriteLine("名称:{0}", method.Name);
                }
                MethodInfo query = dbHelperType.GetMethod("Query", new Type[] { });                                                         //根据名字,找到此方法(无参)
                query.Invoke(oDBHelper, null);                                                                                              //调用此方法
                MethodInfo queryint = dbHelperType.GetMethod("Query", new Type[] { typeof(int) });                                          //int重载的需要传入对应的参数类型,系统会调用对应的方法
                queryint.Invoke(oDBHelper, new object[] { 11 });
                MethodInfo querystring = dbHelperType.GetMethod("Query", new Type[] { typeof(string) });                                    //string
                querystring.Invoke(oDBHelper, new object[] { "name" });
                MethodInfo querystring1 = dbHelperType.GetMethod("Query", new Type[] { typeof(int), typeof(string) });                      //string
                querystring1.Invoke(oDBHelper, new object[] { 11, "name" });
                MethodInfo query1 = dbHelperType.GetMethod("Query2", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); //可访问私有方法
                query1.Invoke(oDBHelper, new object[] { });
                IDBHelper dbHelperReflection = (IDBHelper)oDBHelper;                                                                        //类型转换  is  然后as 强制转换 通过接口获取方法
                dbHelperReflection.Query();                                                                                                 //完成方法的调用

                Type   typeSingle    = assembly.GetType("DB.MySql.Singleton");
                Object oObjectSingle = Activator.CreateInstance(typeSingle, true);//破坏单例 多次执行

                //常规的做法
                People people = new People();
                people.Id   = 11;
                people.Name = "笨小孩";
                Console.WriteLine("Id:{0},Name{0}", people.Id, people.Name);
                // Assembly assemblyp = Assembly.Load("DB.Model");//反射入口
                //object objectP = assembly.GetType("DB.Model.People");//找到类型
                Type   type    = typeof(People);                 //找到类型可替代上面的两句代码
                object oObject = Activator.CreateInstance(type); //创建对象
                foreach (var prop in type.GetProperties())       //找出此类型的所有属性
                {
                    if (prop.Name.Equals("Id"))
                    {
                        prop.SetValue(oObject, 12);//赋值
                    }
                    if (prop.Name.Equals("Name"))
                    {
                        prop.SetValue(oObject, "test");
                    }
                    Console.WriteLine("Id:{0},Name{1}", prop.Name, prop.GetValue(oObject));//prop.Name属性名  GetValue(oObject)获取值
                }

                Type      DBHelper = typeof(DBHelper);
                object    obj      = Activator.CreateInstance(DBHelper);
                IDBHelper dbH      = (IDBHelper)obj;
                jmp_app   app      = dbH.FindBy <jmp_app>(1);

                DBHelper DBHelpers = new DBHelper();
                jmp_app  app0      = DBHelpers.FindBy <jmp_app>(1);
            }


            return(View());
        }