public HttpResponseMessage GerAttributeGroupInfo(MallModel model)
        {
            string Result = string.Empty;

            try
            {
                //请求中包含的固定参数
                model.SOURCE      = ParametersFilter.FilterSqlHtml(model.SOURCE, 24);
                model.CREDENTIALS = ParametersFilter.FilterSqlHtml(model.CREDENTIALS, 24);
                model.ADDRESS     = HttpHelper.IPAddress();
                model.TERMINAL    = ParametersFilter.FilterSqlHtml(model.TERMINAL, 1);
                model.INDEX       = ParametersFilter.FilterSqlHtml(model.INDEX, 24);
                model.METHOD      = ParametersFilter.FilterSqlHtml(model.METHOD, 24);

                model.DATA = ParametersFilter.StripSQLInjection(model.DATA);

                //返回结果
                Result = ApiHelper.HttpRequest(username, password, Url, model);

                ///写日志
                string RequestAction = "api/" + username + "/" + HttpContext.Current.Request.RequestContext.RouteData.Values["action"].ToString() + ":";
                LogHelper.LogResopnse(RequestAction + Result);
            }
            catch (Exception ex)
            {
                LogHelper.LogError(ex.ToString());
            }

            HttpResponseMessage Respend = new HttpResponseMessage {
                Content = new StringContent(Result, Encoding.GetEncoding("UTF-8"), "application/json")
            };

            return(Respend);
        }
        public HttpResponseMessage ScanVerification(CabinetModel model)
        {
            string Result = string.Empty;

            try
            {
                //请求中包含的固定参数
                model.SOURCE      = ParametersFilter.FilterSqlHtml(model.SOURCE, 24);
                model.CREDENTIALS = ParametersFilter.FilterSqlHtml(model.CREDENTIALS, 24);
                model.ADDRESS     = HttpHelper.IPAddress();
                model.TERMINAL    = ParametersFilter.FilterSqlHtml(model.TERMINAL, 1);
                model.INDEX       = ParametersFilter.FilterSqlHtml(model.INDEX, 24);
                model.METHOD      = ParametersFilter.FilterSqlHtml(model.METHOD, 24);

                //去除用户参数中包含的特殊字符
                model.QRCODE = ParametersFilter.StripSQLInjection(model.QRCODE);

                //返回结果
                Result = ApiHelper.HttpRequest(username, password, Url, model);
            }
            catch (Exception ex)
            {
                LogHelper.LogError(ex.ToString());
            }

            HttpResponseMessage Respend = new HttpResponseMessage {
                Content = new StringContent(Result, Encoding.GetEncoding("UTF-8"), "application/json")
            };

            return(Respend);
        }
Exemple #3
0
        public HttpResponseMessage CommodityAdd(ProductCodeInfoModel model)
        {
            string Result = string.Empty;

            try
            {
                //请求中包含的固定参数
                model.SOURCE      = ParametersFilter.FilterSqlHtml(model.SOURCE, 24);
                model.CREDENTIALS = ParametersFilter.FilterSqlHtml(model.CREDENTIALS, 24);
                model.ADDRESS     = HttpHelper.IPAddress();
                model.TERMINAL    = ParametersFilter.FilterSqlHtml(model.TERMINAL, 1);
                model.INDEX       = ParametersFilter.FilterSqlHtml(model.INDEX, 24);
                model.METHOD      = ParametersFilter.FilterSqlHtml(model.METHOD, 24);

                //去除用户参数中包含的特殊字符
                model.DATA        = ParametersFilter.StripSQLInjection(model.DATA);
                model.UserAccount = ParametersFilter.FilterSqlHtml(model.UserAccount, 64);

                #region base64上传
                //string ImgString = model.FilePath.Split(new char[] { ',' })[1];

                ////图片Model
                //ImgModel imgModel = new ImgModel();
                //imgModel.ImgIp = ApiHelper.ImgURL();
                //imgModel.ImgDisk = SingleXmlInfo.GetInstance().GetWebApiConfig("imgDisk");
                //imgModel.ImgRoot = SingleXmlInfo.GetInstance().GetWebApiConfig("imgRoot");
                //imgModel.ImgAttribute = "commodity";
                //imgModel.UserAccount = model.UserAccount;
                //imgModel.ImgName = ReDateTime.GetTimeStamp();
                //imgModel.ImgString = ImgString;

                //model.FilePath = ApiHelper.HttpRequest(ApiHelper.GetImgUploadURL("imgUploadIp", "imgUpload"), imgModel);
                //model.FilePath = model.FilePath.Replace("\"", "");
                #endregion

                ///商品轮播图地址
                model.FilePath = ApiHelper.ImgURL() + model.UserAccount + "/Commodity/";

                ///商品详情图地址
                model.CommodityProfile = ApiHelper.ImgURL() + model.UserAccount + "/Commodity/";

                //返回结果
                Result = ApiHelper.HttpRequest(username, password, Url, model);

                ///写日志
                string RequestAction = "api/" + username + "/" + HttpContext.Current.Request.RequestContext.RouteData.Values["action"].ToString() + ":";
                LogHelper.LogResopnse(RequestAction + Result);
            }
            catch (Exception ex)
            {
                LogHelper.LogError(ex.ToString());
            }

            HttpResponseMessage Respend = new HttpResponseMessage {
                Content = new StringContent(Result, Encoding.GetEncoding("UTF-8"), "application/json")
            };

            return(Respend);
        }
        public HttpResponseMessage Settlement(ShoppingCartModel model)
        {
            string Result = string.Empty;

            try
            {
                //请求中包含的固定参数
                model.SOURCE      = ParametersFilter.FilterSqlHtml(model.SOURCE, 24);
                model.CREDENTIALS = ParametersFilter.FilterSqlHtml(model.CREDENTIALS, 24);
                model.ADDRESS     = HttpHelper.IPAddress();
                model.TERMINAL    = ParametersFilter.FilterSqlHtml(model.TERMINAL, 1);
                model.INDEX       = ParametersFilter.FilterSqlHtml(model.INDEX, 24);
                model.METHOD      = ParametersFilter.FilterSqlHtml(model.METHOD, 24);

                //去除提交的数据中的不安全字符
                model.UserAccount     = ParametersFilter.FilterSqlHtml(model.UserAccount, 24);
                model.CommodityNumber = ParametersFilter.StripSQLInjection(model.CommodityNumber);
                model.AddresseeName   = ParametersFilter.StripSQLInjection(model.AddresseeName);
                model.Telephone       = ParametersFilter.StripSQLInjection(model.Telephone);
                model.Province        = ParametersFilter.StripSQLInjection(model.Province);
                model.RegionCity      = ParametersFilter.StripSQLInjection(model.RegionCity);
                model.CountyDistrict  = ParametersFilter.StripSQLInjection(model.CountyDistrict);
                model.DetailedAddress = ParametersFilter.StripSQLInjection(model.DetailedAddress);

                //if (model.TERMINAL=="2")
                //{
                //    model.CommodityName = System.Web.HttpUtility.UrlEncode(model.CommodityName);
                //    model.AddresseeName = System.Web.HttpUtility.UrlEncode(model.AddresseeName);
                //    model.TelephoneProvince = System.Web.HttpUtility.UrlEncode(model.TelephoneProvince);
                //    model.RegionCity = System.Web.HttpUtility.UrlEncode(model.RegionCity);
                //    model.CountyDistrict = ParametersFilter.StripSQLInjection(model.CountyDistrict);
                //    model.DetailedAddress = ParametersFilter.StripSQLInjection(model.DetailedAddress);
                //}

                Result = ApiHelper.HttpRequest(username, password, Url, model);

                ///写日志
                string RequestAction = "api/" + username + "/" + HttpContext.Current.Request.RequestContext.RouteData.Values["action"].ToString() + ":";
                LogHelper.LogResopnse(RequestAction + Result);
            }
            catch (Exception ex)
            {
                LogHelper.LogError(ex.ToString());
            }
            HttpResponseMessage Respond = new HttpResponseMessage {
                Content = new StringContent(Result, Encoding.GetEncoding("UTF-8"), "application/json")
            };

            return(Respond);
        }
Exemple #5
0
        public HttpResponseMessage ForgetPayPasswd(UserInfoModel model)
        {
            string Result = string.Empty;

            //bool ReturnCode = AuthHelper.AuthUserStatus(model);

            try
            {
                //if (ReturnCode)
                //{
                //请求中包含的固定参数
                model.SOURCE      = ParametersFilter.FilterSqlHtml(model.SOURCE, 24);
                model.CREDENTIALS = ParametersFilter.FilterSqlHtml(model.CREDENTIALS, 24);
                model.ADDRESS     = HttpHelper.IPAddress();
                model.TERMINAL    = ParametersFilter.FilterSqlHtml(model.TERMINAL, 1);
                model.INDEX       = ParametersFilter.FilterSqlHtml(model.INDEX, 24);
                model.METHOD      = ParametersFilter.FilterSqlHtml(model.METHOD, 24);
                model.DATA        = ParametersFilter.StripSQLInjection(model.DATA);
                if (model.TERMINAL == "2")
                {
                    model.DATA = System.Web.HttpUtility.UrlEncode(model.DATA);
                }


                //返回结果
                Result = ApiHelper.HttpRequest(username, password, Url, model);

                ///写日志
                string RequestAction = "api/" + username + "/" + HttpContext.Current.Request.RequestContext.RouteData.Values["action"].ToString() + ":";
                LogHelper.LogResopnse(RequestAction + Result);
                //}
                //else
                //{
                //    Result = "{\"RETURNCODE\":\"403\"}";
                //}
            }
            catch (Exception ex)
            {
                LogHelper.LogError(ex.ToString());
            }

            HttpResponseMessage Respend = new HttpResponseMessage {
                Content = new StringContent(Result, Encoding.GetEncoding("UTF-8"), "application/json")
            };

            return(Respend);
        }
        public HttpResponseMessage CounterRollBack(ShoppingCartModel model)
        {
            string Result = string.Empty;

            try
            {
                //请求中包含的固定参数
                model.SOURCE      = ParametersFilter.FilterSqlHtml(model.SOURCE, 24);
                model.CREDENTIALS = ParametersFilter.FilterSqlHtml(model.CREDENTIALS, 24);
                model.ADDRESS     = HttpHelper.IPAddress();
                model.TERMINAL    = ParametersFilter.FilterSqlHtml(model.TERMINAL, 1);
                model.INDEX       = ParametersFilter.FilterSqlHtml(model.INDEX, 24);
                model.METHOD      = ParametersFilter.FilterSqlHtml(model.METHOD, 24);

                //去除用户参数中包含的特殊字符
                model.UserAccount    = ParametersFilter.FilterSqlHtml(model.UserAccount, 24);
                model.UserName       = ParametersFilter.FilterSqlHtml(model.UserName, 24);
                model.UserMobile     = ParametersFilter.FilterSqlHtml(model.UserMobile, 11);
                model.BUserAccount   = ParametersFilter.FilterSqlHtml(model.BUserAccount, 32);
                model.ShelvesAccount = ParametersFilter.FilterSqlHtml(model.ShelvesAccount, 32);
                model.ShelvesType    = ParametersFilter.FilterSqlHtml(model.ShelvesType, 1);
                model.CommodityCode  = ParametersFilter.StripSQLInjection(model.CommodityCode);
                model.DATA           = ParametersFilter.StripSQLInjection(model.DATA);
                if (model.TERMINAL == "2")
                {
                    model.DATA = System.Web.HttpUtility.UrlEncode(model.DATA);
                }

                //返回结果
                Result = ApiHelper.HttpRequest(username, password, Url, model);

                ///写日志
                string RequestAction = "api/" + username + "/" + HttpContext.Current.Request.RequestContext.RouteData.Values["action"].ToString() + ":";
                LogHelper.LogResopnse(RequestAction + Result);
            }
            catch (Exception ex)
            {
                LogHelper.LogError(ex.ToString());
            }

            HttpResponseMessage Respend = new HttpResponseMessage {
                Content = new StringContent(Result, Encoding.GetEncoding("UTF-8"), "application/json")
            };

            return(Respend);
        }
        public HttpResponseMessage UpdateServiceProduct(PlatformServiceModel model)
        {
            string Result = string.Empty;

            try
            {
                //请求中包含的固定参数
                model.SOURCE      = ParametersFilter.FilterSqlHtml(model.SOURCE, 24);
                model.CREDENTIALS = ParametersFilter.FilterSqlHtml(model.CREDENTIALS, 24);
                model.ADDRESS     = HttpHelper.IPAddress();
                model.TERMINAL    = ParametersFilter.FilterSqlHtml(model.TERMINAL, 1);
                model.INDEX       = ParametersFilter.FilterSqlHtml(model.INDEX, 24);
                model.METHOD      = ParametersFilter.FilterSqlHtml(model.METHOD, 24);

                //去除参数中的特殊字符
                //model.ServiceProduct = ParametersFilter.FilterSqlHtml(model.ServiceProduct, 50);
                //model.EnServiceProduct = ParametersFilter.FilterSqlHtml(model.EnServiceProduct, 50);
                //model.ChargePrice = ParametersFilter.FilterSqlHtml(model.ChargePrice, 10);
                //model.ChargeUnit = ParametersFilter.FilterSqlHtml(model.ChargeUnit, 10);
                //model.ContainOption = ParametersFilter.FilterSqlHtml(model.ContainOption, 10);
                //model.ServiceIntroduce = ParametersFilter.FilterSqlHtml(model.ServiceIntroduce, 500);
                //model.EditTime = System.DateTime.Now.ToString();
                model.DATA = ParametersFilter.StripSQLInjection(model.DATA);

                //http请求
                Result = ApiHelper.HttpRequest(username, password, Url, model);

                ///写日志
                string RequestAction = "api/" + username + "/" + HttpContext.Current.Request.RequestContext.RouteData.Values["action"].ToString() + ":";
                LogHelper.LogResopnse(RequestAction + Result);
            }
            catch (Exception ex)
            {
                LogHelper.LogError(ex.ToString());
            }

            //返回请求结果
            HttpResponseMessage Respend = new HttpResponseMessage {
                Content = new StringContent(Result, Encoding.GetEncoding("UTF-8"), "application/json")
            };

            return(Respend);
        }
        public HttpResponseMessage MobileUpdatePasswd(RedisModel.BaseModel model)
        {
            string Result = string.Empty;

            try
            {
                //请求中包含的固定参数
                model.SOURCE      = ParametersFilter.FilterSqlHtml(model.SOURCE, 24);
                model.CREDENTIALS = ParametersFilter.FilterSqlHtml(model.CREDENTIALS, 24);
                model.ADDRESS     = HttpHelper.IPAddress();
                model.TERMINAL    = ParametersFilter.FilterSqlHtml(model.TERMINAL, 1);
                model.INDEX       = ParametersFilter.FilterSqlHtml(model.INDEX, 24);
                model.METHOD      = ParametersFilter.FilterSqlHtml(model.METHOD, 24);

                //去除提交的数据中的不安全字符
                model.DATA = ParametersFilter.StripSQLInjection(model.DATA);


                Result = ApiHelper.HttpRequest(username, password, Url, model);

                ///写日志
                string RequestAction = "api/" + username + "/" + HttpContext.Current.Request.RequestContext.RouteData.Values["action"].ToString() + ":";
                LogHelper.LogResopnse(RequestAction + Result);

                JObject json = (JObject)JsonConvert.DeserializeObject(Result);

                if (json["DATA"][0].ToString() == "1")
                {
                    string AuthCode = ApiHelper.HttpRequest(ApiHelper.GetAuthCodeURL("smsCodeIp", "sms", "GetAuthCode"), model);
                }
            }
            catch (Exception ex)
            {
                LogHelper.LogError(ex.ToString());
            }
            HttpResponseMessage Respond = new HttpResponseMessage {
                Content = new StringContent(Result, Encoding.GetEncoding("UTF-8"), "application/json")
            };

            return(Respond);
        }
        public HttpResponseMessage SolveReportList(PlatformReportModel model)
        {
            string Result = string.Empty;

            try
            {
                //请求中包含的固定参数
                model.SOURCE      = ParametersFilter.FilterSqlHtml(model.SOURCE, 24);
                model.CREDENTIALS = ParametersFilter.FilterSqlHtml(model.CREDENTIALS, 24);
                model.ADDRESS     = HttpHelper.IPAddress();
                model.TERMINAL    = ParametersFilter.FilterSqlHtml(model.TERMINAL, 1);
                model.INDEX       = ParametersFilter.FilterSqlHtml(model.INDEX, 24);
                model.METHOD      = ParametersFilter.FilterSqlHtml(model.METHOD, 24);
                model.DATA        = ParametersFilter.StripSQLInjection(model.DATA);

                //去除参数中的特殊字符
                //model.CommodityCode = ParametersFilter.FilterSqlHtml(model.CommodityCode, 50);
                //model.ReportState = ParametersFilter.FilterSqlHtml(model.ReportState, 1);
                //model.CheckIdea = ParametersFilter.FilterSqlHtml(model.CheckIdea, 500);

                //http请求
                Result = ApiHelper.HttpRequest(username, password, Url, model);

                ///写日志
                string RequestAction = "api/" + username + "/" + HttpContext.Current.Request.RequestContext.RouteData.Values["action"].ToString() + ":";
                LogHelper.LogResopnse(RequestAction + Result);
            }
            catch (Exception ex)
            {
                LogHelper.LogError(ex.ToString());
            }

            //返回请求结果
            HttpResponseMessage Respend = new HttpResponseMessage {
                Content = new StringContent(Result, Encoding.GetEncoding("UTF-8"), "application/json")
            };

            return(Respend);
        }
        public HttpResponseMessage SalesRecordTable(FaultToleranceModel model)
        {
            string Result = string.Empty;

            try
            {
                //请求中包含的固定参数
                model.SOURCE      = ParametersFilter.FilterSqlHtml(model.SOURCE, 24);
                model.CREDENTIALS = ParametersFilter.FilterSqlHtml(model.CREDENTIALS, 24);
                model.ADDRESS     = HttpHelper.IPAddress();
                model.TERMINAL    = ParametersFilter.FilterSqlHtml(model.TERMINAL, 1);
                model.INDEX       = ParametersFilter.FilterSqlHtml(model.INDEX, 24);
                model.METHOD      = ParametersFilter.FilterSqlHtml(model.METHOD, 24);

                //去除用户参数中包含的特殊字符
                //model.UserAccount = ParametersFilter.FilterSqlHtml(model.UserAccount, 50);
                //model.CommodityCode = ParametersFilter.FilterSqlHtml(model.CommodityCode, 128);
                model.DATA = ParametersFilter.StripSQLInjection(model.DATA);
                //model.PageNum = ParametersFilter.FilterSqlHtml(model.PageNum, 10);

                //返回结果
                Result = ApiHelper.HttpRequest(username, password, Url, model);

                ///写日志
                string RequestAction = "api/" + username + "/" + HttpContext.Current.Request.RequestContext.RouteData.Values["action"].ToString() + ":";
                LogHelper.LogResopnse(RequestAction + Result);
            }
            catch (Exception ex)
            {
                LogHelper.LogError(ex.ToString());
            }

            HttpResponseMessage Respend = new HttpResponseMessage {
                Content = new StringContent(Result, Encoding.GetEncoding("UTF-8"), "application/json")
            };

            return(Respend);
        }
        public HttpResponseMessage UpdateDealSum(ShoppingCartModel model)
        {
            string Result = string.Empty;

            try
            {
                //请求中包含的固定参数
                model.SOURCE      = ParametersFilter.FilterSqlHtml(model.SOURCE, 24);
                model.CREDENTIALS = ParametersFilter.FilterSqlHtml(model.CREDENTIALS, 24);
                model.ADDRESS     = HttpHelper.IPAddress();
                model.TERMINAL    = ParametersFilter.FilterSqlHtml(model.TERMINAL, 1);
                model.INDEX       = ParametersFilter.FilterSqlHtml(model.INDEX, 24);
                model.METHOD      = ParametersFilter.FilterSqlHtml(model.METHOD, 24);

                //去除提交的数据中的不安全字符
                model.UserAccount   = ParametersFilter.FilterSqlHtml(model.UserAccount, 24);
                model.CommodityName = ParametersFilter.StripSQLInjection(model.CommodityName);
                model.DealSum       = ParametersFilter.StripSQLInjection(model.DealSum);
                model.DealMoney     = ParametersFilter.StripSQLInjection(model.DealMoney);

                Result = ApiHelper.HttpRequest(username, password, Url, model);

                ///写日志
                string RequestAction = "api/" + username + "/" + HttpContext.Current.Request.RequestContext.RouteData.Values["action"].ToString() + ":";
                LogHelper.LogResopnse(RequestAction + Result);
            }
            catch (Exception ex)
            {
                LogHelper.LogError(ex.ToString());
            }
            HttpResponseMessage Respond = new HttpResponseMessage {
                Content = new StringContent(Result, Encoding.GetEncoding("UTF-8"), "application/json")
            };

            return(Respond);
        }
        public HttpResponseMessage UserRegister(UserInfoModel model)
        {
            string Result = string.Empty;

            try
            {
                //请求中包含的固定参数
                model.SOURCE      = ParametersFilter.FilterSqlHtml(model.SOURCE, 24);
                model.CREDENTIALS = ParametersFilter.FilterSqlHtml(model.CREDENTIALS, 24);
                model.ADDRESS     = HttpHelper.IPAddress();
                model.TERMINAL    = ParametersFilter.FilterSqlHtml(model.TERMINAL, 1);
                model.INDEX       = ParametersFilter.FilterSqlHtml(model.INDEX, 24);
                model.METHOD      = ParametersFilter.FilterSqlHtml(model.METHOD, 24);

                //去除用户参数中包含的特殊字符
                model.DATA        = ParametersFilter.StripSQLInjection(model.DATA);
                model.UserAccount = ParametersFilter.FilterSqlHtml(model.UserAccount, 64);

                model.DATA = System.Web.HttpUtility.UrlDecode(model.DATA);
                string datatojson = ApiHelper.DATAToJson(model.DATA);
                model.Verification = JObject.Parse(datatojson)["Verification"].ToString();
                model.UserMobile   = JObject.Parse(datatojson)["UserMobile"].ToString();
                model.DATA         = System.Web.HttpUtility.UrlEncode(model.DATA);

                //获取Redis中的验证码
                string  GetRedisAuthCode = ApiHelper.HttpRequest(ApiHelper.GetAuthCodeURL("smsCodeIp", "sms", "VerifyAuthCode"), model);
                JObject json             = (JObject)JsonConvert.DeserializeObject(GetRedisAuthCode);
                //if (json["result"].ToString() == "1")
                //{
                #region Base64
                //string ImgString = model.UserAvatar.Split(new char[] { ',' })[1];

                ////图片Model
                //ImgModel imgModel = new ImgModel();

                //imgModel.ImgIp = ApiHelper.ImgURL();
                //imgModel.ImgDisk = SingleXmlInfo.GetInstance().GetWebApiConfig("imgDisk");
                //imgModel.ImgRoot = SingleXmlInfo.GetInstance().GetWebApiConfig("imgRoot");
                //imgModel.ImgAttribute = "user";
                //imgModel.UserAccount = model.UserAccount;
                //imgModel.ImgName = "useravatar";
                //imgModel.ImgString = ImgString;

                //model.UserAvatar = ApiHelper.HttpRequest(ApiHelper.GetImgUploadURL("imgUploadIp", "imgUpload"), imgModel);
                //model.UserAvatar = model.UserAvatar.Replace("\"", "");
                #endregion

                ImgModel imgModel = new ImgModel();

                imgModel.ImgIp        = ApiHelper.ImgURL();
                imgModel.ImgDisk      = SingleXmlInfo.GetInstance().GetWebApiConfig("imgDisk");
                imgModel.ImgRoot      = SingleXmlInfo.GetInstance().GetWebApiConfig("imgRoot");
                imgModel.ImgAttribute = "user";
                imgModel.UserAccount  = model.UserAccount;

                ///临时文件夹地址
                imgModel.SourceFileName = model.UserAvatar;

                ///保存图片名字
                imgModel.ImgName = "useravatar";

                model.UserAvatar = ApiHelper.HttpRequest(ApiHelper.MoveImg("imgUploadIp", "imgUpload"), imgModel);

                //返回结果
                Result = ApiHelper.HttpRequest(username, password, Url, model);
                //}
                //else if(json["result"].ToString()=="0")
                //{
                //    ///验证码错误
                //    Result = "{\"DATA\":[5]}";
                //}
                //else
                //{
                //    ///验证码超时
                //    Result = "{\"DATA\":[6]}";
                //}

                ///写日志
                string RequestAction = "api/" + username + "/" + HttpContext.Current.Request.RequestContext.RouteData.Values["action"].ToString() + ":";
                LogHelper.LogResopnse(RequestAction + Result);
            }
            catch (Exception ex)
            {
                LogHelper.LogError(ex.ToString());
            }

            HttpResponseMessage Respend = new HttpResponseMessage {
                Content = new StringContent(Result, Encoding.GetEncoding("UTF-8"), "application/json")
            };

            return(Respend);
        }
Exemple #13
0
        public HttpResponseMessage CommodityUpdate(ProductCodeInfoModel model)
        {
            string Result = string.Empty;

            try
            {
                //请求中包含的固定参数
                model.SOURCE      = ParametersFilter.FilterSqlHtml(model.SOURCE, 24);
                model.CREDENTIALS = ParametersFilter.FilterSqlHtml(model.CREDENTIALS, 24);
                model.ADDRESS     = HttpHelper.IPAddress();
                model.TERMINAL    = ParametersFilter.FilterSqlHtml(model.TERMINAL, 1);
                model.INDEX       = ParametersFilter.FilterSqlHtml(model.INDEX, 24);
                model.METHOD      = ParametersFilter.FilterSqlHtml(model.METHOD, 24);
                model.UserAccount = ParametersFilter.FilterSqlHtml(model.UserAccount, 64);

                //去除用户参数中包含的特殊字符
                model.DATA = ParametersFilter.StripSQLInjection(model.DATA);

                #region MyRegion
                //model.DATA = System.Web.HttpUtility.UrlDecode(model.DATA);
                //string ImgString = string.Empty;
                //if (model.FilePath.Substring(model.FilePath.Length - 3, 3) != "jpg")
                //{
                //    ImgString = model.FilePath.Split(new char[] { ',' })[1];
                //}
                //else
                //{
                //    ImgString = model.FilePath;
                //}

                //string datatojson = ApiHelper.DATAToJson(model.DATA);

                //string CommodityCode = JObject.Parse(datatojson)["CommodityCode"].ToString();

                ////图片Model
                //ImgModel imgModel = new ImgModel();
                //imgModel.ImgIp = ApiHelper.ImgURL();
                //imgModel.ImgDisk = SingleXmlInfo.GetInstance().GetWebApiConfig("imgDisk");
                //imgModel.ImgRoot = SingleXmlInfo.GetInstance().GetWebApiConfig("imgRoot");
                //imgModel.ImgAttribute = "commodity";
                //imgModel.UserAccount = model.UserAccount;
                //imgModel.ImgName = CommodityCode;
                //imgModel.ImgString = ImgString;

                //model.FilePath = ApiHelper.HttpRequest(ApiHelper.GetImgUploadURL("imgUploadIp", "imgUpload"), imgModel);
                //model.FilePath = model.FilePath.Replace("\"", "");

                ////URL编码
                //model.DATA = System.Web.HttpUtility.UrlEncode(model.DATA);
                #endregion

                //返回结果
                Result = ApiHelper.HttpRequest(username, password, Url, model);

                ///写日志
                string RequestAction = "api/" + username + "/" + HttpContext.Current.Request.RequestContext.RouteData.Values["action"].ToString() + ":";
                LogHelper.LogResopnse(RequestAction + Result);
            }
            catch (Exception ex)
            {
                LogHelper.LogError(ex.ToString());
            }

            HttpResponseMessage Respend = new HttpResponseMessage {
                Content = new StringContent(Result, Encoding.GetEncoding("UTF-8"), "application/json")
            };

            return(Respend);
        }
Exemple #14
0
        public HttpResponseMessage UpdateCommodityFilePath(ProductCodeInfoModel model)
        {
            string Result = string.Empty;

            try
            {
                //请求中包含的固定参数
                model.SOURCE      = ParametersFilter.FilterSqlHtml(model.SOURCE, 24);
                model.CREDENTIALS = ParametersFilter.FilterSqlHtml(model.CREDENTIALS, 24);
                model.ADDRESS     = HttpHelper.IPAddress();
                model.TERMINAL    = ParametersFilter.FilterSqlHtml(model.TERMINAL, 1);
                model.INDEX       = ParametersFilter.FilterSqlHtml(model.INDEX, 24);
                model.METHOD      = ParametersFilter.FilterSqlHtml(model.METHOD, 24);

                model.UserAccount     = ParametersFilter.FilterSqlHtml(model.UserAccount, 64);
                model.Status          = ParametersFilter.FilterSqlHtml(model.Status, 1);
                model.CommodityNumber = ParametersFilter.StripSQLInjection(model.CommodityNumber);
                model.ImgStatus       = ParametersFilter.FilterSqlHtml(model.ImgStatus, 1);

                ///原图片地址
                string ImgPath = model.FilePath;

                if (model.Status == "0")
                {
                    model.FilePath = model.FilePath.Substring(model.FilePath.LastIndexOf("."), model.FilePath.Length - model.FilePath.LastIndexOf("."));
                }

                //返回结果
                Result = ApiHelper.HttpRequest(username, password, Url, model);

                //解析返回结果
                JObject jsons = (JObject)JsonConvert.DeserializeObject(Result);

                ///添加商品
                if (model.Status == "0")
                {
                    ImgModel imgModel = new ImgModel();
                    imgModel.ImgDisk        = SingleXmlInfo.GetInstance().GetWebApiConfig("imgDisk");
                    imgModel.ImgRoot        = SingleXmlInfo.GetInstance().GetWebApiConfig("imgRoot");
                    imgModel.UserAccount    = model.UserAccount;
                    imgModel.ImgAttribute   = "commodity";
                    imgModel.SourceFileName = ImgPath;
                    imgModel.ImgName        = jsons["FilePath"].ToString();

                    string Return = ApiHelper.HttpRequest(ApiHelper.MoveCommodityImg("imgUploadIp", "imgUpload"), imgModel);

                    if (Return != "1")
                    {
                        jsons["DATA"][0] = 0;
                    }
                    else
                    {
                        jsons["DATA"][0] = 1;
                    }
                    Result = JsonConvert.SerializeObject(jsons);
                }
                else if (model.Status == "1")
                {
                    if (jsons["DATA"][0].ToString() == "1")
                    {
                        ImgModel imgModel = new ImgModel();
                        imgModel.ImgDisk        = SingleXmlInfo.GetInstance().GetWebApiConfig("imgDisk");
                        imgModel.ImgRoot        = SingleXmlInfo.GetInstance().GetWebApiConfig("imgRoot");
                        imgModel.UserAccount    = model.UserAccount;
                        imgModel.ImgAttribute   = "commodity";
                        imgModel.SourceFileName = ImgPath;
                        string DeleteImg = ApiHelper.HttpRequest(ApiHelper.DeleteCommodityImg("imgUploadIp", "imgUpload"), imgModel);
                        if (DeleteImg != "1")
                        {
                            jsons["DATA"][0] = 0;
                        }

                        Result = JsonConvert.SerializeObject(jsons);
                    }
                }

                ///写日志
                string RequestAction = "api/" + username + "/" + HttpContext.Current.Request.RequestContext.RouteData.Values["action"].ToString() + ":";
                LogHelper.LogResopnse(RequestAction + Result);
            }
            catch (Exception ex)
            {
                LogHelper.LogError(ex.ToString());
            }

            HttpResponseMessage Respend = new HttpResponseMessage {
                Content = new StringContent(Result, Encoding.GetEncoding("UTF-8"), "application/json")
            };

            return(Respend);
        }
        public HttpResponseMessage UserLogin(UserInfoModel model)
        {
            string Result = string.Empty;

            try
            {
                //请求中包含的固定参数
                model.SOURCE      = ParametersFilter.FilterSqlHtml(model.SOURCE, 24);
                model.CREDENTIALS = ParametersFilter.FilterSqlHtml(model.CREDENTIALS, 24);
                model.ADDRESS     = HttpHelper.IPAddress();
                model.TERMINAL    = ParametersFilter.FilterSqlHtml(model.TERMINAL, 1);
                model.INDEX       = ParametersFilter.FilterSqlHtml(model.INDEX, 24);
                model.METHOD      = ParametersFilter.FilterSqlHtml(model.METHOD, 24);

                //去除用户参数中包含的特殊字符
                model.UserAccount = ParametersFilter.FilterSqlHtml(model.UserAccount, 30);
                model.UserPasswd  = ParametersFilter.FilterSqlHtml(model.UserPasswd, 30);
                model.UserMobile  = ParametersFilter.StripSQLInjection(model.UserMobile);
                //model.UserEmail = ParametersFilter.StripSQLInjection(model.UserEmail);

                if (model.TERMINAL == "2")
                {
                    if (model.UserAccount != null)
                    {
                        model.UserMobile = "";
                    }
                    else
                    {
                        model.UserAccount = "";
                    }
                }

                //返回结果
                Result = ApiHelper.HttpRequest(username, password, Url, model);

                ///写日志
                string RequestAction = "api/" + username + "/" + HttpContext.Current.Request.RequestContext.RouteData.Values["action"].ToString() + ":";
                LogHelper.LogResopnse(RequestAction + Result);

                //解析返回结果
                JObject jsons = (JObject)JsonConvert.DeserializeObject(Result);
                if (jsons["DATA"][0]["result"].ToString() == "登录成功!")
                {
                    model.UserMobile = jsons["DATA"][0]["UserMobile"].ToString();

                    //返回凭证
                    jsons["CREDENTIALS"] = AuthHelper.AuthUserSet(model);
                    Result = JsonConvert.SerializeObject(jsons);
                }
            }
            catch (Exception ex)
            {
                LogHelper.LogError(ex.ToString());
            }

            HttpResponseMessage Respend = new HttpResponseMessage {
                Content = new StringContent(Result, Encoding.GetEncoding("UTF-8"), "application/json")
            };

            return(Respend);
        }
        public HttpResponseMessage AdvertisingUpdate(AdvertiseMentModel model)
        {
            string Result = string.Empty;

            try
            {
                //请求中包含的固定参数
                model.SOURCE      = ParametersFilter.FilterSqlHtml(model.SOURCE, 24);
                model.CREDENTIALS = ParametersFilter.FilterSqlHtml(model.CREDENTIALS, 24);
                model.ADDRESS     = HttpHelper.IPAddress();
                model.TERMINAL    = ParametersFilter.FilterSqlHtml(model.TERMINAL, 1);
                model.INDEX       = ParametersFilter.FilterSqlHtml(model.INDEX, 24);
                model.METHOD      = ParametersFilter.FilterSqlHtml(model.METHOD, 24);

                //去除用户参数中包含的特殊字符
                model.DATA        = ParametersFilter.StripSQLInjection(model.DATA);
                model.UserAccount = ParametersFilter.FilterSqlHtml(model.UserAccount, 64);
                string ImgString = string.Empty;

                #region Base64
                //if (model.FilePosition.Substring(model.FilePath.Length - 3, 3) != "jpg")
                //{
                //    ImgString = model.FilePosition.Split(new char[] { ',' })[1];
                //}
                //else
                //{
                //    ImgString = model.FilePosition;
                //}

                //图片Model
                //ImgModel imgModel = new ImgModel();

                //imgModel.ImgIp = ApiHelper.ImgURL();
                //imgModel.ImgDisk = SingleXmlInfo.GetInstance().GetWebApiConfig("imgDisk");
                //imgModel.ImgRoot = SingleXmlInfo.GetInstance().GetWebApiConfig("imgRoot");
                //imgModel.ImgAttribute = "advertisement";
                //imgModel.UserAccount = model.UserAccount;
                //imgModel.ImgName = ReDateTime.GetTimeStamp();
                //imgModel.ImgString = ImgString;

                //model.FilePosition = ApiHelper.HttpRequest(ApiHelper.GetImgUploadURL("imgUploadIp", "imgUpload"), imgModel);
                //model.FilePosition = model.FilePosition.Replace("\"", "");
                #endregion

                #region fileStream
                ImgModel imgModel = new ImgModel();

                imgModel.ImgIp        = ApiHelper.ImgURL();
                imgModel.ImgDisk      = SingleXmlInfo.GetInstance().GetWebApiConfig("imgDisk");
                imgModel.ImgRoot      = SingleXmlInfo.GetInstance().GetWebApiConfig("imgRoot");
                imgModel.ImgAttribute = "advertisement";
                imgModel.UserAccount  = model.UserAccount;

                ///临时文件夹地址
                imgModel.SourceFileName = model.FilePosition;

                ///保存图片名字
                imgModel.ImgName = ReDateTime.GetTimeStamp();

                model.FilePosition = ApiHelper.HttpRequest(ApiHelper.MoveImg("imgUploadIp", "imgUpload"), imgModel);
                #endregion

                //返回结果
                Result = ApiHelper.HttpRequest(username, password, Url, model);

                ///写日志
                string RequestAction = "api/" + username + "/" + HttpContext.Current.Request.RequestContext.RouteData.Values["action"].ToString() + ":";
                LogHelper.LogResopnse(RequestAction + Result);
            }
            catch (Exception ex)
            {
                LogHelper.LogError(ex.ToString());
            }

            HttpResponseMessage Respend = new HttpResponseMessage {
                Content = new StringContent(Result, Encoding.GetEncoding("UTF-8"), "application/json")
            };

            return(Respend);
        }
        public HttpResponseMessage SubmitReportInfo(ProductInfoModel model)
        {
            string Result = string.Empty;

            //bool ReturnCode = AuthHelper.AuthUserStatus(model);

            try
            {
                //if (ReturnCode)
                //{
                //请求中包含的固定参数
                model.SOURCE      = ParametersFilter.FilterSqlHtml(model.SOURCE, 24);
                model.CREDENTIALS = ParametersFilter.FilterSqlHtml(model.CREDENTIALS, 24);
                model.ADDRESS     = HttpHelper.IPAddress();
                model.TERMINAL    = ParametersFilter.FilterSqlHtml(model.TERMINAL, 1);
                model.INDEX       = ParametersFilter.FilterSqlHtml(model.INDEX, 24);
                model.METHOD      = ParametersFilter.FilterSqlHtml(model.METHOD, 24);
                model.DATA        = ParametersFilter.StripSQLInjection(model.DATA);

                if (!string.IsNullOrEmpty(model.Screenshot))
                {
                    model.DATA = System.Web.HttpUtility.UrlDecode(model.DATA);
                    string datatojson = ApiHelper.DATAToJson(model.DATA);


                    string CommodityCode = JObject.Parse(datatojson)["CommodityCode"].ToString();
                    string ReportUser    = JObject.Parse(datatojson)["ReportUser"].ToString();

                    //string UserAccount =

                    ProductInfoModel InfoModel = new ProductInfoModel();
                    InfoModel.SOURCE        = model.SOURCE;
                    InfoModel.CREDENTIALS   = model.CREDENTIALS;
                    InfoModel.ADDRESS       = model.ADDRESS;
                    InfoModel.TERMINAL      = model.TERMINAL;
                    InfoModel.INDEX         = model.INDEX;
                    InfoModel.METHOD        = "GetCommodityUserAccount";
                    InfoModel.CommodityCode = CommodityCode;

                    string ReturnUserAccount = ApiHelper.HttpRequest(username, password, Url, InfoModel);
                    //解析返回结果
                    JObject jsons       = (JObject)JsonConvert.DeserializeObject(ReturnUserAccount);
                    string  UserAccount = jsons["UserAccount"].ToString();

                    #region 图片地址
                    //图片Model
                    ImgModel imgModel = new ImgModel();

                    imgModel.ImgIp        = ApiHelper.ImgURL();
                    imgModel.ImgDisk      = SingleXmlInfo.GetInstance().GetWebApiConfig("imgDisk");
                    imgModel.ImgRoot      = SingleXmlInfo.GetInstance().GetWebApiConfig("imgRoot");
                    imgModel.UserAccount  = UserAccount;
                    imgModel.ImgAttribute = "report";
                    imgModel.ImgName      = ReportUser + ReDateTime.GetTimeStamp();
                    imgModel.ImgString    = model.Screenshot;

                    //保存图片
                    model.Screenshot = ApiHelper.HttpRequest(ApiHelper.GetImgUploadURL("imgUploadIp", "imgUpload"), imgModel);
                    model.Screenshot = model.Screenshot.Replace("\"", "");
                    #endregion
                }

                model.DATA = System.Web.HttpUtility.UrlEncode(model.DATA);


                //返回结果
                Result = ApiHelper.HttpRequest(username, password, Url, model);

                ///写日志
                string RequestAction = "api/" + username + "/" + HttpContext.Current.Request.RequestContext.RouteData.Values["action"].ToString() + ":";
                LogHelper.LogResopnse(RequestAction + Result);
                //}
                //else
                //{
                //    Result = "{\"RETURNCODE\":\"403\"}";
                //}
            }
            catch (Exception ex)
            {
                LogHelper.LogRequest(ex.ToString());
                LogHelper.LogError(ex.ToString());
                LogHelper.LogResopnse(ex.ToString());
            }

            HttpResponseMessage Respend = new HttpResponseMessage {
                Content = new StringContent(Result, Encoding.GetEncoding("UTF-8"), "application/json")
            };

            return(Respend);
        }