You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
204 lines
7.7 KiB
204 lines
7.7 KiB
2 months ago
|
using System;
|
||
|
using System.Collections.Generic;
|
||
|
using System.Data;
|
||
|
using System.Linq;
|
||
|
using System.Reflection;
|
||
|
using System.Web;
|
||
|
using System.Web.Script.Services;
|
||
|
using System.Web.Services;
|
||
|
using Tools;
|
||
|
using Webservice;
|
||
|
using WebService.Model;
|
||
|
|
||
|
namespace WebService
|
||
|
{
|
||
|
/// <summary>
|
||
|
/// 滑撬扫描接口
|
||
|
/// </summary>
|
||
|
[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 SkidWebservice : System.Web.Services.WebService
|
||
|
{
|
||
|
|
||
|
[WebMethod]
|
||
|
public string HelloWorld()
|
||
|
{
|
||
|
return "Hello World";
|
||
|
}
|
||
|
|
||
|
/// <summary>
|
||
|
/// 获取颜色
|
||
|
/// </summary>
|
||
|
/// <param name="app_id"></param>
|
||
|
[WebMethod]
|
||
|
[ScriptMethod(UseHttpGet = true, ResponseFormat = ResponseFormat.Json)]
|
||
|
public void GetAllColor(string app_id)
|
||
|
{
|
||
|
string errorReason = "";
|
||
|
|
||
|
JsonModel<ColorInfoModel> model = new JsonModel<ColorInfoModel>();
|
||
|
model.Result = "0";
|
||
|
model.ResultType = "List";
|
||
|
model.ResultRowsCount = "0";
|
||
|
model.ErrReason = errorReason;
|
||
|
model.DataList = null;
|
||
|
|
||
|
#region 参数判断
|
||
|
if (string.IsNullOrWhiteSpace(app_id))
|
||
|
{
|
||
|
model.ErrReason = "缺少必要传入参数 app_id";
|
||
|
Context.Response.Write(JSONTools.ScriptSerialize<JsonModel<ColorInfoModel>>(model));
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
bool access = Function.AppIDIsRight(app_id.Trim());
|
||
|
if (!access)
|
||
|
{
|
||
|
model.ErrReason = "APP接口调用标识不正确 远程服务器拒绝了此次连接请求";
|
||
|
Context.Response.Write(JSONTools.ScriptSerialize<JsonModel<ColorInfoModel>>(model));
|
||
|
return;
|
||
|
}
|
||
|
#endregion
|
||
|
|
||
|
DataTable dt = FunctionAddColor.GetAllColor();
|
||
|
List<ColorInfoModel> list = new List<ColorInfoModel>();
|
||
|
|
||
|
if (dt != null && dt.Rows.Count > 0)
|
||
|
{
|
||
|
|
||
|
for (int i = 0; i < dt.Rows.Count; i++)
|
||
|
{
|
||
|
ColorInfoModel mod = new ColorInfoModel();
|
||
|
mod.ColorInfo = dt.Rows[i][0].ToString();
|
||
|
|
||
|
list.Add(mod);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
model.Result = "1";
|
||
|
model.ResultType = "List";
|
||
|
model.ResultRowsCount = dt.Rows.Count.ToString();
|
||
|
model.ErrReason = errorReason;
|
||
|
model.DataList = list;
|
||
|
|
||
|
LogHelper.WriteSysLogBase("滑撬扫描【获取颜色信息】,出参:" + list.ToString(), MethodBase.GetCurrentMethod().Name);
|
||
|
|
||
|
Context.Response.Write(JSONTools.ScriptSerialize<JsonModel<ColorInfoModel>>(model));
|
||
|
}
|
||
|
|
||
|
/// <summary>
|
||
|
/// 保存滑撬信息
|
||
|
/// </summary>
|
||
|
/// <param name="app_id"></param>
|
||
|
/// <param name="SkidNo"></param>
|
||
|
/// <param name="BarcodeLeft"></param>
|
||
|
/// <param name="BarcodeRight"></param>
|
||
|
/// <param name="Layer"></param>
|
||
|
/// <param name="ColorInfo"></param>
|
||
|
/// <param name="sign"></param>
|
||
|
[WebMethod]
|
||
|
[ScriptMethod(UseHttpGet = true, ResponseFormat = ResponseFormat.Json)]
|
||
|
public void SaveSkidInfo(string app_id, string SkidNo, string BarcodeLeft, string BarcodeRight, string Layer, string ColorInfo, string sign)
|
||
|
{
|
||
|
string errorReason = "";
|
||
|
|
||
|
JsonModel<NoModel> model = new JsonModel<NoModel>();
|
||
|
model.Result = "0";
|
||
|
model.ResultType = "List";
|
||
|
model.ResultRowsCount = "0";
|
||
|
model.ErrReason = errorReason;
|
||
|
model.DataList = null;
|
||
|
|
||
|
#region 参数判断
|
||
|
|
||
|
if (string.IsNullOrWhiteSpace(app_id))
|
||
|
{
|
||
|
model.ErrReason = "缺少必要传入参数 app_id";
|
||
|
Context.Response.Write(JSONTools.ScriptSerialize<JsonModel<NoModel>>(model));
|
||
|
return;
|
||
|
}
|
||
|
if (string.IsNullOrWhiteSpace(SkidNo))
|
||
|
{
|
||
|
model.ErrReason = "缺少必要传入参数 SkidNo";
|
||
|
Context.Response.Write(JSONTools.ScriptSerialize<JsonModel<NoModel>>(model));
|
||
|
return;
|
||
|
}
|
||
|
if (string.IsNullOrWhiteSpace(BarcodeLeft))
|
||
|
{
|
||
|
model.ErrReason = "缺少必要传入参数 BarcodeLeft";
|
||
|
Context.Response.Write(JSONTools.ScriptSerialize<JsonModel<NoModel>>(model));
|
||
|
return;
|
||
|
}
|
||
|
if (string.IsNullOrWhiteSpace(BarcodeRight))
|
||
|
{
|
||
|
model.ErrReason = "缺少必要传入参数 BarcodeRight";
|
||
|
Context.Response.Write(JSONTools.ScriptSerialize<JsonModel<NoModel>>(model));
|
||
|
return;
|
||
|
}
|
||
|
if (string.IsNullOrWhiteSpace(Layer))
|
||
|
{
|
||
|
model.ErrReason = "缺少必要传入参数 Layer";
|
||
|
Context.Response.Write(JSONTools.ScriptSerialize<JsonModel<NoModel>>(model));
|
||
|
return;
|
||
|
}
|
||
|
if (string.IsNullOrWhiteSpace(ColorInfo))
|
||
|
{
|
||
|
model.ErrReason = "缺少必要传入参数 ColorInfo";
|
||
|
Context.Response.Write(JSONTools.ScriptSerialize<JsonModel<NoModel>>(model));
|
||
|
return;
|
||
|
}
|
||
|
if (string.IsNullOrWhiteSpace(sign))
|
||
|
{
|
||
|
model.ErrReason = "缺少必要传入参数 sign";
|
||
|
Context.Response.Write(JSONTools.ScriptSerialize<JsonModel<NoModel>>(model));
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
bool access = Function.AppIDIsRight(app_id.Trim());
|
||
|
if (!access)
|
||
|
{
|
||
|
model.ErrReason = "APP接口调用标识不正确 远程服务器拒绝了此次连接请求";
|
||
|
Context.Response.Write(JSONTools.ScriptSerialize<JsonModel<NoModel>>(model));
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
string[] param = { Function.app_secret.Trim(), SkidNo.Trim(), BarcodeLeft.Trim(), BarcodeRight.Trim(), Layer.Trim(), ColorInfo.Trim() };
|
||
|
bool paramIsRight = Function.signIsRight(param, sign);
|
||
|
if (!paramIsRight)
|
||
|
{
|
||
|
model.ErrReason = "sign参数传输错误 远程服务器拒绝了此次连接请求";
|
||
|
Context.Response.Write(JSONTools.ScriptSerialize<JsonModel<NoModel>>(model));
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
#endregion
|
||
|
|
||
|
int res = FunctionAddColor.InsertSkidInfo(SkidNo, BarcodeLeft, BarcodeRight, Layer, ColorInfo, out errorReason);
|
||
|
|
||
|
if (res >= 1)
|
||
|
{
|
||
|
model.Result = "1";
|
||
|
model.ResultType = "Result";
|
||
|
model.ResultRowsCount = "0";
|
||
|
model.ErrReason = errorReason;
|
||
|
model.DataList = null;
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
model.Result = "0";
|
||
|
model.ResultType = "Result";
|
||
|
model.ResultRowsCount = "0";
|
||
|
model.ErrReason = errorReason;
|
||
|
model.DataList = null;
|
||
|
}
|
||
|
|
||
|
LogHelper.WriteSysLogBase("滑撬扫描【保存滑橇信息】,入参:SkidNo=" + SkidNo + ",BarcodeLeft=" + BarcodeLeft + ",BarcodeRight=" + BarcodeRight + ",Layer=" + Layer + ",ColorInfo=" + ColorInfo + ",出参:" + JSONTools.ScriptSerialize<JsonModel<NoModel>>(model), MethodBase.GetCurrentMethod().Name);
|
||
|
|
||
|
Context.Response.Write(JSONTools.ScriptSerialize<JsonModel<NoModel>>(model));
|
||
|
}
|
||
|
}
|
||
|
}
|