using System.Collections.Generic;
using System.Data;
using System.Reflection;
using System.Web.Script.Services;
using System.Web.Services;
using Tools;
using Webservice;
using WebService.Model;
namespace WebService
{
///
/// PaintWebservice 的摘要说明
///
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.ComponentModel.ToolboxItem(false)]
// 若要允许使用 ASP.NET AJAX 从脚本中调用此 Web 服务,请取消注释以下行。
// [System.Web.Script.Services.ScriptService]
public class PaintWebservice : System.Web.Services.WebService
{
[WebMethod]
public string HelloWorld()
{
return "Hello World";
}
///
/// 根据油漆条码查询油漆信息
///
///
///
///
[WebMethodAttribute]
[ScriptMethod(UseHttpGet = true, ResponseFormat = ResponseFormat.Json)]
public void GetInfoByPaintCode(string app_id, string PaintCode, string sign)
{
string errorReason = "";
JsonModel model = new JsonModel();
model.Result = "0";
model.ResultType = "Result";
model.ResultRowsCount = "0";
model.ErrReason = errorReason;
model.DataList = null;
#region 参数判断
if (string.IsNullOrWhiteSpace(app_id))
{
model.ErrReason = "缺少必要传入参数 app_id";
Context.Response.Write(JSONTools.ScriptSerialize>(model));
return;
}
if (string.IsNullOrWhiteSpace(PaintCode))
{
model.ErrReason = "缺少必要传入参数 PaintCode";
Context.Response.Write(JSONTools.ScriptSerialize>(model));
return;
}
if (string.IsNullOrWhiteSpace(sign))
{
model.ErrReason = "缺少必要传入参数 sign";
Context.Response.Write(JSONTools.ScriptSerialize>(model));
return;
}
bool access = Function.AppIDIsRight(app_id.Trim());
if (!access)
{
model.ErrReason = "APP接口调用标识不正确 远程服务器拒绝了此次连接请求";
Context.Response.Write(JSONTools.ScriptSerialize>(model));
return;
}
string[] param = { Function.app_secret.Trim(), PaintCode.Trim() };
bool paramIsRight = Function.signIsRight(param, sign);
if (!paramIsRight)
{
model.ErrReason = "sign参数传输错误 远程服务器拒绝了此次连接请求";
Context.Response.Write(JSONTools.ScriptSerialize>(model));
return;
}
#endregion
DataTable dtIsUsing = Function.GetPaintInfoIsUsing(PaintCode, out errorReason);
if (dtIsUsing.Rows.Count < 1)
{
model.ErrReason = "油漆条码已停用或有误";
Context.Response.Write(JSONTools.ScriptSerialize>(model));
return;
}
DataTable dt = Function.GetPaintInfo(PaintCode, out errorReason);
List listInfo = new List();
if (dt != null && dt.Rows.Count > 0)
{
model.Result = "1";
PaintInfoModel info = new PaintInfoModel();
info.PaintName = dt.Rows[0]["PaintName"].ToString();
info.PaintModel = dt.Rows[0]["PaintModel"].ToString();
info.UnitCode = dt.Rows[0]["UnitCode"].ToString();
info.CarModelCode = dt.Rows[0]["CarModelCode"].ToString();
listInfo.Add(info);
}
else
{
model.Result = "0";
}
model.ErrReason = errorReason;
model.ResultRowsCount = dt.Rows.Count.ToString();
model.DataList = listInfo;
LogHelper.WriteSysLogBase("【加漆防错-根据油漆条码返回油漆信息】入参:PaintCode:" + PaintCode + ",出参:" + JSONTools.ScriptSerialize>(model), MethodBase.GetCurrentMethod().Name);
Context.Response.Write(JSONTools.ScriptSerialize>(model));
}
///
/// 根据油漆条码查询油漆信息-wff,增加加漆时校验是否已从wms出库
///
///
///
///
///
[WebMethodAttribute]
[ScriptMethod(UseHttpGet = true, ResponseFormat = ResponseFormat.Json)]
public void GetInfoByPaintCode_new(string app_id, string PaintCode, string sign,string barCode)
{
string errorReason = "";
JsonModel model = new JsonModel();
model.Result = "0";
model.ResultType = "Result";
model.ResultRowsCount = "0";
model.ErrReason = errorReason;
model.DataList = null;
#region 参数判断
if (string.IsNullOrWhiteSpace(app_id))
{
model.ErrReason = "缺少必要传入参数 app_id";
Context.Response.Write(JSONTools.ScriptSerialize>(model));
return;
}
if (string.IsNullOrWhiteSpace(PaintCode))
{
model.ErrReason = "缺少必要传入参数 PaintCode";
Context.Response.Write(JSONTools.ScriptSerialize>(model));
return;
}
if (string.IsNullOrWhiteSpace(sign))
{
model.ErrReason = "缺少必要传入参数 sign";
Context.Response.Write(JSONTools.ScriptSerialize>(model));
return;
}
bool access = Function.AppIDIsRight(app_id.Trim());
if (!access)
{
model.ErrReason = "APP接口调用标识不正确 远程服务器拒绝了此次连接请求";
Context.Response.Write(JSONTools.ScriptSerialize>(model));
return;
}
string[] param = { Function.app_secret.Trim(), PaintCode.Trim() };
bool paramIsRight = Function.signIsRight(param, sign);
if (!paramIsRight)
{
model.ErrReason = "sign参数传输错误 远程服务器拒绝了此次连接请求";
Context.Response.Write(JSONTools.ScriptSerialize>(model));
return;
}
#endregion
#region 校验油漆是否已从wms出库
string[] code = barCode.Split(';');
bool flag = Function.IsOut(code[0]);
if (!flag)
{
model.ErrReason = "油漆条码未出库或有误";
Context.Response.Write(JSONTools.ScriptSerialize>(model));
return;
}
#endregion
DataTable dtIsUsing = Function.GetPaintInfoIsUsing(PaintCode, out errorReason);
if (dtIsUsing.Rows.Count < 1)
{
model.ErrReason = "油漆条码已停用或有误";
Context.Response.Write(JSONTools.ScriptSerialize>(model));
return;
}
DataTable dt = Function.GetPaintInfo(PaintCode, out errorReason);
List listInfo = new List();
if (dt != null && dt.Rows.Count > 0)
{
model.Result = "1";
PaintInfoModel info = new PaintInfoModel();
info.PaintName = dt.Rows[0]["PaintName"].ToString();
info.PaintModel = dt.Rows[0]["PaintModel"].ToString();
info.UnitCode = dt.Rows[0]["UnitCode"].ToString();
info.CarModelCode = dt.Rows[0]["CarModelCode"].ToString();
listInfo.Add(info);
}
else
{
model.Result = "0";
}
model.ErrReason = errorReason;
model.ResultRowsCount = dt.Rows.Count.ToString();
model.DataList = listInfo;
LogHelper.WriteSysLogBase("【加漆防错-根据油漆条码返回油漆信息】入参:PaintCode:" + PaintCode + ",出参:" + JSONTools.ScriptSerialize>(model), MethodBase.GetCurrentMethod().Name);
Context.Response.Write(JSONTools.ScriptSerialize>(model));
}
///
/// 油漆和油漆桶匹配
///
///
///
///
///
[WebMethod]
[ScriptMethod(UseHttpGet = true, ResponseFormat = ResponseFormat.Json)]
public void CheckPaint(string app_id, string PaintCode, string DrumCode, string sign)
{
string errorReason = "";
JsonModel model = new JsonModel();
model.Result = "0";
model.ResultType = "Result";
model.ResultRowsCount = "0";
model.ErrReason = errorReason;
model.DataList = null;
#region 参数判断
if (string.IsNullOrWhiteSpace(app_id))
{
model.ErrReason = "缺少必要传入参数 app_id";
Context.Response.Write(JSONTools.ScriptSerialize>(model));
return;
}
if (string.IsNullOrWhiteSpace(PaintCode))
{
model.ErrReason = "缺少必要传入参数 PaintCode";
Context.Response.Write(JSONTools.ScriptSerialize>(model));
return;
}
if (string.IsNullOrWhiteSpace(DrumCode))
{
model.ErrReason = "缺少必要传入参数 DrumCode";
Context.Response.Write(JSONTools.ScriptSerialize>(model));
return;
}
if (string.IsNullOrWhiteSpace(sign))
{
model.ErrReason = "缺少必要传入参数 sign";
Context.Response.Write(JSONTools.ScriptSerialize>(model));
return;
}
bool access = Function.AppIDIsRight(app_id.Trim());
if (!access)
{
model.ErrReason = "APP接口调用标识不正确 远程服务器拒绝了此次连接请求";
Context.Response.Write(JSONTools.ScriptSerialize>(model));
return;
}
string[] param = { Function.app_secret.Trim(), PaintCode.Trim(), DrumCode.Trim() };
bool paramIsRight = Function.signIsRight(param, sign);
if (!paramIsRight)
{
model.ErrReason = "sign参数传输错误 远程服务器拒绝了此次连接请求";
Context.Response.Write(JSONTools.ScriptSerialize>(model));
return;
}
#endregion
DataTable dt = Function.IsMatch(PaintCode, DrumCode, out errorReason);
if (dt != null && dt.Rows.Count > 0)
{
model.Result = "1";
}
else
{
model.Result = "0";
}
model.ErrReason = errorReason;
model.ResultRowsCount = dt.Rows.Count.ToString();
model.DataList = null;
LogHelper.WriteSysLogBase("【加漆防错-油漆和油漆桶匹配】入参:PaintCode:" + PaintCode + ",DrumCode:" + DrumCode + ",出参:" + JSONTools.ScriptSerialize>(model), MethodBase.GetCurrentMethod().Name);
Context.Response.Write(JSONTools.ScriptSerialize>(model));
}
}
}