using Bwp.MainSystem.BO;
|
|
using BWP.B3WeChat.BO;
|
|
using Forks.EnterpriseServices.DomainObjects2;
|
|
using Forks.EnterpriseServices.DomainObjects2.DQuery;
|
|
using Forks.EnterpriseServices.SqlDoms;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Web;
|
|
using TSingSoft.WebPluginFramework;
|
|
|
|
namespace BWP.B3WeChat
|
|
{
|
|
public class CustomerUserContext
|
|
{
|
|
|
|
string mCustomerCode;
|
|
public string CustomerCode
|
|
{
|
|
get
|
|
{
|
|
return mCustomerCode;
|
|
}
|
|
}
|
|
|
|
string mCustomerName;
|
|
public string CustomerName
|
|
{
|
|
get
|
|
{
|
|
return mCustomerName;
|
|
}
|
|
}
|
|
|
|
|
|
public string GetOpenID(string customerUsername)
|
|
{
|
|
var query = new DQueryDom(new JoinAlias(typeof(CustomerUser)));
|
|
query.Where.Conditions.Add(DQCondition.EQ("CustomerCode", CustomerCode));
|
|
query.Where.Conditions.Add(DQCondition.EQ("CustomerUsername", customerUsername));
|
|
query.Columns.Add(DQSelectColumn.Field("OpenID"));
|
|
query.Range = SelectRange.Top(1);
|
|
var result = query.EExecuteScalar<string>();
|
|
return result;
|
|
}
|
|
|
|
|
|
|
|
public static CustomerUserContext Current
|
|
{
|
|
get
|
|
{
|
|
var httpContext = HttpContext.Current;
|
|
var key = "CustomerUserContext";
|
|
if (httpContext != null && httpContext.Items.Contains(key))
|
|
{
|
|
return (CustomerUserContext)httpContext.Items[key];
|
|
}
|
|
else
|
|
{
|
|
var user = BLContext.User;
|
|
var query = new DQueryDom(new JoinAlias(typeof(DeviceAuthentication)));
|
|
query.Where.Conditions.Add(DQCondition.EQ("Ticket", user.UserTag.ToString("N")));
|
|
query.Columns.Add(DQSelectColumn.Field("DeviceNumber"));
|
|
query.Columns.Add(DQSelectColumn.Field("Name"));
|
|
query.Range = SelectRange.Top(1);
|
|
var tuple = query.EExecuteScalar<string,string>();
|
|
if (tuple == null)
|
|
{
|
|
return null;
|
|
}
|
|
var context = new CustomerUserContext();
|
|
context.mCustomerCode = tuple.Item1;
|
|
context.mCustomerName = tuple.Item2;
|
|
if (httpContext != null)
|
|
{
|
|
httpContext.Items[key] = context;
|
|
}
|
|
return context;
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|