111 lines
3.4 KiB
C#
111 lines
3.4 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Xml;
|
|
using WebServer.ServiceReference1;
|
|
|
|
namespace WebServer
|
|
{
|
|
public class WebHelp
|
|
{
|
|
public static blwwsSoapClient bs = null;
|
|
static object locks = new object();
|
|
public static void Init()
|
|
{
|
|
if (bs == null)
|
|
{
|
|
lock (locks)
|
|
{
|
|
if (bs == null)
|
|
{
|
|
bs = new blwwsSoapClient();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// 退房
|
|
/// </summary>
|
|
/// <param name="checkOut"></param>
|
|
/// <returns></returns>
|
|
public static bool CheckOut(CheckOutInfo checkOut)
|
|
{
|
|
Init();
|
|
string errstr = string.Empty;
|
|
bs.CheckOut(checkOut.key, checkOut.code, checkOut.roomNumber, checkOut.checkOutDate,ref errstr);
|
|
return string.IsNullOrEmpty(errstr);
|
|
}
|
|
/// <summary>
|
|
/// 开房信息
|
|
/// </summary>
|
|
/// <param name="info">发送的实体</param>
|
|
public static bool Send(SendInfo info, params UserInfo[] user)
|
|
{
|
|
Init();
|
|
string errmsg = string.Empty;
|
|
long chekinid = 0;
|
|
bs.CheckIn2(
|
|
info.key,
|
|
info.code,
|
|
info.roomNumber,
|
|
info.checkInDate,
|
|
GetXml(user),
|
|
ref errmsg,
|
|
ref chekinid,
|
|
info.phoneNumber,
|
|
info.idNumber
|
|
);
|
|
var sad = GetXml(user);
|
|
if (errmsg == string.Empty)
|
|
{
|
|
foreach (var item in user)
|
|
{
|
|
if( bs.UploadPhoto(
|
|
info.key,
|
|
info.code,
|
|
chekinid,
|
|
item.idtype,
|
|
item.idcard,
|
|
item.customer,
|
|
item.sex == "男" ? 1 : item.sex == "女" ? 0 : 2,
|
|
DateTime.Now.AddYears(-20).ToString("yyy-MM-dd"),
|
|
item.photoUrl,
|
|
null,
|
|
ref errmsg
|
|
))
|
|
{
|
|
break;
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
return string.IsNullOrEmpty(errmsg);
|
|
}
|
|
static string GetXml(params UserInfo[] user)
|
|
{
|
|
string xmlstr = @"<?xml version='1.0' encoding='utf - 8' ?><interface></interface>";
|
|
XmlDocument xml = new XmlDocument();
|
|
xml.LoadXml(xmlstr);
|
|
var interfaceElement = xml.DocumentElement;
|
|
foreach (UserInfo item in user)
|
|
{
|
|
XmlElement node = xml.CreateElement("item");
|
|
Type t = user[0].GetType();
|
|
foreach (var i in t.GetProperties())
|
|
{
|
|
var val = i.GetValue(item);
|
|
if (i.Name!= "photoUrl" && val != null && !string.IsNullOrEmpty( val.ToString()))
|
|
{
|
|
node.SetAttribute(i.Name, val.ToString());
|
|
}
|
|
}
|
|
interfaceElement.AppendChild(node);
|
|
}
|
|
return xml.OuterXml;
|
|
}
|
|
}
|
|
}
|