|
|
|
@ -1,101 +0,0 @@ |
|
|
|
using Bwp.MainSystem.BO; |
|
|
|
using BWP.B3WeChat.BO; |
|
|
|
using BWP.B3WeChat.Utils; |
|
|
|
using Forks.EnterpriseServices.DomainObjects2; |
|
|
|
using Forks.EnterpriseServices.DomainObjects2.DQuery; |
|
|
|
using Forks.EnterpriseServices.JsonRpc; |
|
|
|
using Forks.EnterpriseServices.SqlDoms; |
|
|
|
using Forks.Utils; |
|
|
|
using System; |
|
|
|
using System.Collections.Generic; |
|
|
|
using System.IO; |
|
|
|
using System.Linq; |
|
|
|
using System.Text; |
|
|
|
using TSingSoft.WebPluginFramework; |
|
|
|
|
|
|
|
namespace BWP.B3WeChat.Rpcs |
|
|
|
{ |
|
|
|
[Rpc] |
|
|
|
public static class ClientRpc |
|
|
|
{ |
|
|
|
static string GetDeviceNumber() |
|
|
|
{ |
|
|
|
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.Range = SelectRange.Top(1); |
|
|
|
var deviceNumber = query.EExecuteScalar<string>(); |
|
|
|
return deviceNumber; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
[Rpc] |
|
|
|
public static void Send(String message, string username) |
|
|
|
{ |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
[Rpc] |
|
|
|
public static String GetQRCodeUrl(string username) |
|
|
|
{ |
|
|
|
string url = string.Empty; |
|
|
|
string customer = GetDeviceNumber(); |
|
|
|
if (string.IsNullOrEmpty(customer)) |
|
|
|
return url; |
|
|
|
string ticket = InOutMessageUtil.GenerateEQCode(30, GetSceneId(customer, username)); |
|
|
|
string name=DateTime.Now.Ticks.ToString() + ".jpg"; |
|
|
|
string path = GetQRCodeDir() + name; |
|
|
|
InOutMessageUtil.GetQRPic(ticket, path); |
|
|
|
return url; |
|
|
|
} |
|
|
|
|
|
|
|
static string ExistQRCode(string customer, string username) |
|
|
|
{ |
|
|
|
var query = new DQueryDom(new JoinAlias(typeof(QRCodeScene))); |
|
|
|
query.Columns.Add(DQSelectColumn.Field("Path")); |
|
|
|
query.Where.Conditions.Add(DQCondition.EQ("Customer", customer)); |
|
|
|
query.Where.Conditions.Add(DQCondition.EQ("UserId", username)); |
|
|
|
query.Where.Conditions.Add(DQCondition.GreaterThan(DQExpression.Field("OutTime"), DQExpression.Value(DateTime.Now))); |
|
|
|
query.Range = SelectRange.Top(1); |
|
|
|
var path = query.EExecuteScalar<string>(); |
|
|
|
return path; |
|
|
|
} |
|
|
|
|
|
|
|
static int GetSceneId(string customer, string username) |
|
|
|
{ |
|
|
|
var query = new DQueryDom(new JoinAlias(typeof(QRCodeScene))); |
|
|
|
query.Columns.Add(DQSelectColumn.Field("ID")); |
|
|
|
query.Where.Conditions.Add(DQCondition.EQ("Customer", customer)); |
|
|
|
query.Where.Conditions.Add(DQCondition.EQ("UserId", username)); |
|
|
|
query.Range = SelectRange.Top(1); |
|
|
|
var sceneId = query.EExecuteScalar<int?>(); |
|
|
|
if (!sceneId.HasValue) |
|
|
|
{ |
|
|
|
using (var session = Dmo.NewSession()) |
|
|
|
{ |
|
|
|
QRCodeScene newSence = new QRCodeScene() |
|
|
|
{ |
|
|
|
Customer = customer, |
|
|
|
UserId = username, |
|
|
|
}; |
|
|
|
session.Insert(newSence); |
|
|
|
session.Commit(); |
|
|
|
sceneId = newSence.ID; |
|
|
|
} |
|
|
|
} |
|
|
|
return sceneId.Value; |
|
|
|
} |
|
|
|
|
|
|
|
static string GetQRCodeDir() |
|
|
|
{ |
|
|
|
string dir = System.Environment.CurrentDirectory + "/QRCodePic/"; |
|
|
|
if (!Directory.Exists(dir)) |
|
|
|
{ |
|
|
|
Directory.CreateDirectory(dir); |
|
|
|
} |
|
|
|
return dir; |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |