예제 #1
0
        internal static APIModel CopyFrom(LightDataModel.tbl_api_orderItem _orderInfo)
        {
            var m = new APIModel();

            m.apiExdata    = _orderInfo.api_exdata;
            m.cid          = _orderInfo.cid;
            m.clientIp     = _orderInfo.clientip;
            m.cpVerifyCode = _orderInfo.cp_verifyCode;
            m.extraParams  = _orderInfo.extra_param;
            m.extrData     = _orderInfo.ExtrData;
            m.iccid        = _orderInfo.iccid;
            m.id           = _orderInfo.id;
            m.imei         = _orderInfo.imei;
            m.imsi         = _orderInfo.imsi;
            m.ip           = _orderInfo.ip;
            //m.isHidden = _orderInfo.is_hidden;
            m.lac                 = _orderInfo.lac;
            m.mobile              = _orderInfo.mobile;
            m.msg                 = _orderInfo.msg;
            m.netType             = _orderInfo.nettype;
            m.packageName         = _orderInfo.packagename;
            m.port                = _orderInfo.port;
            m.sdkVersion          = _orderInfo.sdkversion;
            m.spExField           = _orderInfo.sp_exField;
            m.spLinkId            = _orderInfo.sp_linkid;
            m.status              = _orderInfo.status;
            m.tbl_sp_trone_api_id = _orderInfo.api_id;
            m.tbl_trone_order_id  = _orderInfo.trone_order_id;
            m.troneId             = _orderInfo.trone_id;
            m.userAgent           = _orderInfo.user_agent;
            return(m);
        }
예제 #2
0
        /// <summary>
        /// 处理用户请求
        /// </summary>
        /// <returns></returns>
        public bool ProcesUserRequest()
        {
            if (!CheckLimit())
            {
                return(false);
            }

            var url = string.Format("http://localhost:9191/api/kk{0}.ashx", orderInfo.api_id);
            var api = new Model.APIModel();

            orderInfo.SaveToDatabase(dBase);
            api.port                = orderInfo.port;
            api.msg                 = orderInfo.msg;
            api.spLinkId            = orderInfo.sp_linkid;
            api.mobile              = orderInfo.mobile;
            api.id                  = orderInfo.id;
            api.tbl_sp_trone_api_id = orderInfo.api_id;
            api.tbl_trone_order_id  = orderInfo.trone_order_id;
            api.apiExdata           = orderInfo.api_exdata;
            api.spExField           = orderInfo.sp_exField;
            api.troneId             = orderInfo.trone_id;
            api.tbl_trone_order_id  = orderInfo.trone_order_id;


            string json = null;

            using (var stm = new MemoryStream())
            {
                var dc = new DataContractJsonSerializer(api.GetType());
                dc.WriteObject(stm, api);
                json = ASCIIEncoding.UTF8.GetString(stm.ToArray());
            }
            try
            {
                var html = n8wan.Public.Library.DownloadHTML(url, json, 2000, null);
                api = Shotgun.Library.Static.JsonParser <Model.ApiResultModel>(html).Request;
                orderInfo.status = api.status;
                Shotgun.Library.SimpleLogRecord.WriteLog("telcom_mo", html);
                return(SetSuccess());
            }
            catch (System.Net.WebException ex)
            {
                if (ex.Status == System.Net.WebExceptionStatus.Timeout)
                {
                    orderInfo.status = 1023;
                }
                else
                {
                    orderInfo.status = 1010;
                }
                return(SetErrorMesage(string.Format("api接出口出错:url:{0},code:{1}", url, ex.Status)));
            }
            finally
            {
                //Shotgun.Library.SimpleLogRecord.WriteLog("telcom_mo", string.Format("updated api.status={0},orderInfo.status={1}", api.status, orderInfo.status));
                orderInfo.SaveToDatabase(dBase);
            }
        }
예제 #3
0
        public object Clone()
        {
            var t      = this.GetType();
            var fields = t.GetFields();
            var ret    = new APIModel();

            foreach (var f in fields)
            {
                var val = f.GetValue(this);
                f.SetValue(ret, val);
            }
            return(ret);
        }