Example #1
0
        public Response Info(JmPayParameter.Models.Initialization mode)
        {
            Response json = new Response();
            string   ip   = ((System.Web.HttpContextWrapper)Request.Properties["MS_HttpContext"]).Request.UserHostAddress;

            try
            {
                #region 获取传入的参数
                Dictionary <string, string> dict = new Dictionary <string, string>();
                string pamentjson = "";
                if (Request.Method == HttpMethod.Get)
                {
                    dict = Request.GetQueryNameValuePairs().ToDictionary(x => x.Key, x => x.Value, StringComparer.CurrentCultureIgnoreCase);
                    if (dict.Count > 0)
                    {
                        pamentjson = JMP.TOOL.JsonHelper.DictJsonstr(dict);
                        mode       = JMP.TOOL.JsonHelper.Deserialize <Initialization>(pamentjson);
                    }
                }
                else if (Request.Method == HttpMethod.Post)
                {
                    pamentjson = JMP.TOOL.JsonHelper.Serialize(mode);
                }
                #endregion
                if (mode != null)
                {
                    //获取配置文件设置的缓存时间
                    int           CacheTime     = Int32.Parse(ConfigurationManager.AppSettings["CacheTime"].ToString());
                    InfoInterface infoInterface = new InfoInterface();
                    var           message       = infoInterface.InfoPass(mode, pamentjson, CacheTime, ip);
                    json.ErrorCode = message.ErrorCode;
                    json.Message   = message.Message;
                }
                else
                {
                    json = json.InfoToResponse(InfoErrorCode.Code9999);
                }
            }
            catch (Exception e)
            {
                string bcxx = "报错提示" + e.Message + "报错对象:" + e.Source + "报错方法:" + e.TargetSite + "报错信息:" + e.ToString() + "报错位置:" + e.StackTrace;//报错信息
                PayApiGlobalErrorLogger.Log("报错信息:" + bcxx, summary: "初始化接口主通道Info报错");
                json = json.InfoToResponse(InfoErrorCode.Code9998);
            }
            return(json);
        }
Example #2
0
        ///<summary>Gets and refreshes all available configuration information this <see cref="UsbDevice"/>.</summary>
        ///<returns>A <see cref="InfoConfigs"/> list containing all device config information.</returns>
        public InfoConfigs RefreshConfigs()
        {
            mConfigs = new InfoConfigs();

            StringBuilder sbTemp = new StringBuilder(255);

            for (int iConfig = 0; iConfig < mDev.mDeviceDescriptor.bNumConfigurations; iConfig++)
            {
                LibUsb_ConfigDescriptor usb_config = mDev.GetConfig(iConfig);
                InfoConfig config = new InfoConfig(this);
                mConfigs.Add(config);

                config.bLength             = usb_config.bLength;
                config.bDescriptorType     = usb_config.bDescriptorType;
                config.wTotalLength        = usb_config.wTotalLength;
                config.bNumInterfaces      = usb_config.bNumInterfaces;
                config.bConfigurationValue = usb_config.bConfigurationValue;
                config.iConfiguration      = usb_config.iConfiguration;
                config.bmAttributes        = usb_config.bmAttributes;
                config.bMaxPower           = usb_config.MaxPower;

                if (usb_config.extralen > 0 && usb_config.extra != IntPtr.Zero)
                {
                    config.aExtra = new byte[usb_config.extralen];
                    Marshal.Copy(usb_config.extra, config.aExtra, 0, usb_config.extralen);
                }

                config.mUSBInfoInterfaces = new InfoInterfaces();
                for (int iInterface = 0; iInterface < usb_config.bNumInterfaces; iInterface++)
                {
                    LibUsb_InterfaceDescriptor usb_int = usb_config.GetInterface(iInterface);

                    for (int iAlt = 0; iAlt < usb_int.mNumAltSetting; iAlt++)
                    {
                        LibUsb_AltInterfaceDescriptor usb_id = usb_int.GetAltInterface(iAlt);
                        InfoInterface UsbInt = new InfoInterface(this);
                        config.mUSBInfoInterfaces.Add(UsbInt);

                        UsbInt.bLength            = usb_id.bLength;
                        UsbInt.bDescriptorType    = usb_id.bDescriptorType;
                        UsbInt.bInterfaceNumber   = usb_id.bInterfaceNumber;
                        UsbInt.bAlternateSetting  = usb_id.bAlternateSetting;
                        UsbInt.bNumEndpoints      = usb_id.bNumEndpoints;
                        UsbInt.bInterfaceClass    = usb_id.bInterfaceClass;
                        UsbInt.bInterfaceSubClass = usb_id.bInterfaceSubClass;
                        UsbInt.bInterfaceProtocol = usb_id.bInterfaceProtocol;
                        UsbInt.iInterface         = usb_id.iInterface;

                        UsbInt.usbInfoEndpoints = new InfoEndpoints();
                        for (int iEndpoint = 0; iEndpoint < usb_id.bNumEndpoints; iEndpoint++)
                        {
                            InfoEndpoint endPoint = new InfoEndpoint(this);
                            UsbInt.usbInfoEndpoints.Add(endPoint);
                            LibUsb_EndpointDescriptor usb_endpoint = usb_id.GetEndpoint(iEndpoint);

                            endPoint.bLength          = usb_endpoint.bLength;
                            endPoint.bDescriptorType  = usb_endpoint.bDescriptorType;
                            endPoint.bEndpointAddress = usb_endpoint.bEndpointAddress;
                            endPoint.bmAttributes     = usb_endpoint.bmAttributes;
                            endPoint.wMaxPacketSize   = usb_endpoint.wMaxPacketSize;
                            endPoint.bInterval        = usb_endpoint.bInterval;
                            endPoint.bRefresh         = usb_endpoint.bRefresh;
                            endPoint.bSynchAddress    = usb_endpoint.bSynchAddress;
                        } //Endpoints
                    }     //Alt Interfaces
                }         //Interfaces
            }             //Configs
            return(mConfigs);
        }