using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Net;
using System.Net.Mail;
using System.Text;
using System.Text.RegularExpressions;
using System.Web;
using System.Web.Services;
using NetLibrary;
using NetLibrary.Log;
using NetLibrary.OnlineTrade;
using TradeData;
using TradeModel;
using System.IO;
namespace TradeManageNew
{
///
/// UserServiceNew2 的摘要说明
///
[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 UserServiceNew2 : System.Web.Services.WebService
{
#region 登陆
[WebMethod(EnableSession = true)]
public bool Login(string UserName, string PassWord)
{
//HttpContext.Current.Request.UserHostAddress
//HttpContext.Current.Request.ServerVariables.GetValues("REMOTE_ADDR")[0]
string LoginIp = HttpContext.Current.Request.ServerVariables.GetValues("REMOTE_ADDR")[0];
var list = BaseService.Login(UserName, PassWord, LoginIp);
if (list == null)
{
// string Content="登陆用户名:"+UserName+"密码:"+PassWord+"登陆时间:"+DateTime.Now.ToString()+"登陆ip:"+ LoginIp+"";
// PagesNew.SaveLog(0,"登陆日志",Content,0);
return false;
}
UserModel model = new UserModel();
if (list.CompanyId > 0) model.CompanyID = list.CompanyId.Value;
model.Name = list.Name;
model.UserID = list.UserId.Value;
model.UserType = list.UserType;
model.UserName = UserName;
model.PassWord = PassWord;
model.CompanyName = list.CompanyName;
if (list.DeptId != null)
model.DeptId = list.DeptId.Value;
else
model.DeptId = 0;
model.Duty = list.Duty;
Session["CompanyId"] = model.CompanyID;
Session["DeptId"] = model.DeptId;
Session["Name"] = model.Name;
Session["UserId"] = model.UserID;
Session["UserName"] = model.UserName;
Session["UserType"] = model.UserType;
Session["CompanyName"] = model.CompanyName;
Session["Duty"] = model.Duty;
Session["Login_UserModel"] = model;
//string Content1="登陆用户名:"+UserName+"姓名:"+model.Name+"登陆时间:"+DateTime.Now.ToString()+"登陆ip:"+ LoginIp+"";
//PagesNew.SaveLog(model.UserID,"登陆日志",Content1,0);
//JC_ExpressService.InitExpress(model.CompanyID);
return true;
}
#endregion
#region 登陆
[WebMethod(EnableSession = true)]
public bool LoginNew(string UserName, string PassWord, string ul, string LoginIp)
{
//HttpContext.Current.Request.UserHostAddress
//HttpContext.Current.Request.ServerVariables.GetValues("REMOTE_ADDR")[0]
//string LoginIp = HttpContext.Current.Request.ServerVariables.GetValues("REMOTE_ADDR")[0];
int IsNb = 0;
if (ul.Contains("192.168."))
IsNb = 1;
var list = BaseService.LoginNew(UserName, PassWord, LoginIp, IsNb);
if (list == null)
{
string Content = "登陆用户名:" + UserName + "密码:" + PassWord + "登陆时间:" + DateTime.Now.ToString() + "登陆ip:" + LoginIp + "";
PagesNew.SaveLog(0, "登陆日志", Content, 0);
return false;
}
UserModel model = new UserModel();
if (list.CompanyId > 0) model.CompanyID = list.CompanyId.Value;
model.Name = list.Name;
model.UserID = list.UserId.Value;
model.UserType = list.UserType;
model.UserName = UserName;
model.PassWord = PassWord;
model.CompanyName = list.CompanyName;
if (list.DeptId != null)
model.DeptId = list.DeptId.Value;
else
model.DeptId = 0;
model.Duty = list.Duty;
Session["CompanyId"] = model.CompanyID;
Session["DeptId"] = model.DeptId;
Session["Name"] = model.Name;
Session["UserId"] = model.UserID;
Session["UserName"] = model.UserName;
Session["UserType"] = model.UserType;
Session["CompanyName"] = model.CompanyName;
Session["Duty"] = model.Duty;
Session["Login_UserModel"] = model;
//string Content1="登陆用户名:"+UserName+"姓名:"+model.Name+"登陆时间:"+DateTime.Now.ToString()+"登陆ip:"+ LoginIp+"";
//PagesNew.SaveLog(model.UserID,"登陆日志",Content1,0);
//JC_ExpressService.InitExpress(model.CompanyID);
return true;
}
#endregion
#region 登陆
[WebMethod(EnableSession = true)]
public bool LoginNew2(string UserName, string PassWord)
{
var list = BaseService.LoginNew2(UserName, PassWord);
if (list == null)
{
string Content = "登陆用户名:" + UserName + "密码:" + PassWord + "登陆时间:" + DateTime.Now.ToString() + "登陆ip:";
PagesNew.SaveLog(0, "登陆日志", Content, 0);
return false;
}
UserModel model = new UserModel();
if (list.CompanyId > 0) model.CompanyID = list.CompanyId.Value;
model.Name = list.Name;
model.UserID = list.UserId.Value;
model.UserType = list.UserType;
model.UserName = UserName;
model.PassWord = PassWord;
model.CompanyName = list.CompanyName;
if (list.DeptId != null)
model.DeptId = list.DeptId.Value;
else
model.DeptId = 0;
model.Duty = list.Duty;
Session["PT"] = "hwc";
Session["CompanyId"] = model.CompanyID;
Session["DeptId"] = model.DeptId;
Session["Name"] = model.Name;
Session["UserId"] = model.UserID;
Session["UserName"] = model.UserName;
Session["UserType"] = model.UserType;
Session["CompanyName"] = model.CompanyName;
Session["Duty"] = model.Duty;
Session["Login_UserModel"] = model;
//string Content1="登陆用户名:"+UserName+"姓名:"+model.Name+"登陆时间:"+DateTime.Now.ToString()+"登陆ip:"+ LoginIp+"";
//PagesNew.SaveLog(model.UserID,"登陆日志",Content1,0);
//JC_ExpressService.InitExpress(model.CompanyID);
return true;
}
#endregion
#region 登陆
[WebMethod(EnableSession = true)]
public bool Login2(int UserId)
{
var list = BaseService.Login2(UserId);
if (list == null)
{
// string Content="登陆用户名:"+UserName+"密码:"+PassWord+"登陆时间:"+DateTime.Now.ToString()+"登陆ip:"+ LoginIp+"";
// PagesNew.SaveLog(0,"登陆日志",Content,0);
return false;
}
UserModel model = new UserModel();
if (list.CompanyId > 0) model.CompanyID = list.CompanyId.Value;
model.Name = list.Name;
model.UserID = list.UserId.Value;
model.UserType = list.UserType;
model.UserName = "";
model.PassWord = "";
if (list.DeptId != null)
model.DeptId = list.DeptId.Value;
else
model.DeptId = 0;
model.CompanyName = list.CompanyName;
Session["CompanyId"] = model.CompanyID;
Session["Name"] = model.Name;
Session["DeptId"] = model.DeptId;
Session["UserId"] = model.UserID;
Session["UserName"] = model.UserName;
Session["UserType"] = model.UserType;
Session["CompanyName"] = model.CompanyName;
Session["Login_UserModel"] = model;
//string Content1="登陆用户名:"+UserName+"姓名:"+model.Name+"登陆时间:"+DateTime.Now.ToString()+"登陆ip:"+ LoginIp+"";
//PagesNew.SaveLog(model.UserID,"登陆日志",Content1,0);
//JC_ExpressService.InitExpress(model.CompanyID);
return true;
}
#endregion
#region 密码获取
[WebMethod(EnableSession = true)]
public string GetUserPwd(string Email)
{
BaseService obj = new BaseService();
var md = obj.GetUserPwd(Email);
if (md == null)
{
return "邮箱不正确,如果忘记邮箱地址请与软件服务商联系";
}
string Content = "您好,您在蜜糖erp的登陆用户名为:" + md.UserName + "密码:" + md.Password + ";请您尽快登陆平台修改密码,并妥善保管,谢谢!";
string mess = SendMail("蜜糖erp账号获取", Content, Email);
string Content1 = "获取邮箱:" + Email + "获取时间:" + DateTime.Now.ToString() + "内容:" + Content + mess;
PagesNew.SaveLog(0, "获取密码", Content1, 0);
//JC_ExpressService.InitExpress(model.CompanyID);
return mess;
}
#endregion
public string GetIp()
{
try
{
string ip = "";
string hostInfo = Dns.GetHostName();
//IP地址
System.Net.IPAddress[] addressList = Dns.GetHostEntry(Dns.GetHostName()).AddressList;
for (int i = 0; i < addressList.Length; i++)
{
ip += addressList[i].ToString() + ";";
}
return ip;
}
catch (Exception e)
{
return "";
}
}
[WebMethod(EnableSession = true)]
public string GetIp2()
{
try
{
IPAddress ipAddr = Dns.Resolve(Dns.GetHostName()).AddressList[0];//获得当前IP地址
string ip = ipAddr.ToString();
return ip;
}
catch (Exception e)
{
return "";
}
}
[WebMethod(EnableSession = true)]
public string GetIP3()
{
string tempip = "";
try
{
WebRequest wr = WebRequest.Create("https://www.ipip.net/ip.html");
Stream s = wr.GetResponse().GetResponseStream();
StreamReader sr = new StreamReader(s, Encoding.UTF8);
string all = sr.ReadToEnd(); //读取网站的数据
int start = all.IndexOf("ipip?ipstr=") + 11;
int end = start + 15;
tempip = all.Substring(start, end - start);
sr.Close();
s.Close();
}
catch
{
}
return tempip;
}
[WebMethod(EnableSession = true)]
public string GetIP4()
{
string tempIP = string.Empty;
if (System.Net.Dns.GetHostEntry(System.Net.Dns.GetHostName()).AddressList.Length > 1)
tempIP = System.Net.Dns.GetHostEntry(System.Net.Dns.GetHostName()).AddressList[1].ToString();
return tempIP;
}
#region 退出
[WebMethod(EnableSession = true)]
public void LoginOut()
{
UserModel user = PagesNew.Login2(this.Session);
BaseService.ExitLogin(user.UserID);
Session.Remove("CompanyId");
Session.Remove("Name");
Session.Remove("UserId");
Session.Remove("UserName");
Session.Remove("UserType");
Session.Remove("Login_UserModel");
}
#endregion
#region 读取菜单
[WebMethod(EnableSession = true)]
public List GetListMenu()
{
PagesNew.Login(this.Session);
int UserID = Convert.ToInt32(Session["UserId"]);
int CompanyId = Convert.ToInt32(Session["CompanyId"]);
return BaseService.GetListMenu(UserID, CompanyId);
}
#endregion
#region 读取菜单
[WebMethod(EnableSession = true)]
public List GetListMenu2()
{
PagesNew.Login(this.Session);
int UserID = Convert.ToInt32(Session["UserId"]);
int CompanyId = Convert.ToInt32(Session["CompanyId"]);
return BaseService.GetListMenu2(UserID, CompanyId);
}
#endregion
#region 修改密码
[WebMethod(EnableSession = true)]
public int UpdatePassWord(string UserName, string OldPassword, string NewPassWord)
{
PagesNew.Login(this.Session);
int UserID = Convert.ToInt32(Session["UserId"]);
return BaseService.UpdatePassWord(UserName, UserID, OldPassword, NewPassWord);
}
#endregion
#region 修改密码
[WebMethod(EnableSession = true)]
public int AddUser(string UserName, string Password, int CompanyId)
{
PagesNew.Login(this.Session);
return BaseService.AddUser(UserName, Password, CompanyId);
}
#endregion
#region 验证是否设置过店铺
[WebMethod(EnableSession = true)]
public int IsShopAdd()
{
PagesNew.Login(this.Session);
int CompanyId = Convert.ToInt32(Session["CompanyId"]);
BaseService obj = new BaseService();
return obj.IsShopAdd(CompanyId);
}
#endregion
#region 读取基础类型
[WebMethod(EnableSession = true)]
public List GetListBaseCode(int CompanyID, string KeyName)
{
PagesNew.Login(this.Session);
if (CompanyID == 0) CompanyID = Convert.ToInt32(Session["CompanyId"]);
return BaseService.GetListBaseCode(CompanyID, KeyName);
}
#endregion
#region 读取平台
[WebMethod(EnableSession = true)]
public List GetPlatBaseCode2(int CompanyID, string KeyName)
{
PagesNew.Login(this.Session);
return BaseService.GetPlatBaseCode(CompanyID, KeyName);
}
#endregion
#region 读取平台
[WebMethod(EnableSession = true)]
public List GetPlatBaseCode(int CompanyID, string KeyName)
{
PagesNew.Login(this.Session);
if (CompanyID == 0) CompanyID = Convert.ToInt32(Session["CompanyId"]);
return BaseService.GetPlatBaseCode(CompanyID, KeyName);
}
#endregion
//#region 读取全部或单个机构
// [WebMethod(EnableSession = true)]
//public List GetListCompany()
//{
// PagesNew.Login(this.Session);
// int CompanyID = Convert.ToInt32(Session["CompanyId"]);
// return BaseService.GetListCompany(CompanyID);
//}
//#endregion
// #region 读取全部或单个机构
// [WebMethod(EnableSession = true)]
// public List GetListCompany3()
// {
// PagesNew.Login(this.Session);
// int CompanyID = Convert.ToInt32(Session["CompanyId"]);
// return BaseService.GetListCompany3(CompanyID);
// }
// #endregion
// #region 读取全部或单个机构
// [WebMethod(EnableSession = true)]
// public List GetListCompany2()
// {
// PagesNew.Login(this.Session);
// int CompanyID = Convert.ToInt32(Session["CompanyId"]);
// return BaseService.GetListCompany2(CompanyID);
// }
// #endregion
#region 读取所有部门
[WebMethod(EnableSession = true)]
public List GetListDept(int CompanyID)
{
PagesNew.Login(this.Session);
if (CompanyID == 0) CompanyID = Convert.ToInt32(Session["CompanyId"]);
return BaseService.GetListDept(CompanyID);
}
#endregion
#region 读取工作
[WebMethod(EnableSession = true)]
public List GetListWork(int DeptId)
{
PagesNew.Login(this.Session);
int CompanyId = Convert.ToInt32(Session["CompanyId"]);
var obj = new BaseService();
var list = obj.GetUserWork(CompanyId, DeptId);
if (list != null)
{
foreach (var md in list)
{
if (md.NowState == "请假")
{
var lmd = JC_UserInfoService.GetUserLeave(md.UserId.Value);
if (lmd != null)
{
md.LeaveTime = lmd.SDate.Value.ToString("MM月dd日HH:mm") + "-" + lmd.EDate.Value.ToString("MM月dd日HH:mm");
}
}
}
}
return list;
}
#endregion
#region 读取所有部门
[WebMethod(EnableSession = true)]
public List GetMyListDept()
{
PagesNew.Login(this.Session);
int CompanyID = Convert.ToInt32(Session["CompanyId"]);
int UserId = Convert.ToInt32(Session["UserId"]);
return BaseService.GetMyListDept(CompanyID, UserId);
}
#endregion
#region 读取所属部门人员
[WebMethod(EnableSession = true)]
public List GetListUser(int CompanyID, int DeptID)
{
PagesNew.Login(this.Session);
return BaseService.GetListUser(CompanyID, DeptID);
}
#endregion
#region 读取所属部门人员
[WebMethod(EnableSession = true)]
public List GetListUserForTM(int CompanyID, int DeptID)
{
PagesNew.Login(this.Session);
return BaseService.GetListUserForTM(CompanyID, DeptID);
}
#endregion
#region 读取所属部门人员
[WebMethod(EnableSession = true)]
public List GetListUserInfo(int CompanyID, int DeptID, string Name, string Persons)
{
PagesNew.Login(this.Session);
if (CompanyID == 0)
CompanyID = Convert.ToInt32(Session["CompanyId"]);
return BaseService.GetListUserInfo(CompanyID, DeptID, Name, Persons);
}
#endregion
#region 读取消息提示
[WebMethod(Description = "读取消息提示", EnableSession = true)]
public List GetListWindowMess()
{
PagesNew.Login(this.Session);
int UserId = Convert.ToInt32(Session["UserId"]);
//string UserType = Convert.ToString(Session["UserType"]);
BaseService obj = new BaseService();
DataSet ds = obj.UserOpenMess("P", UserId);
if (ds == null)
return null;
var list = ds.Tables[0].ToList();
//foreach (DataRow item in ds.Tables[0].Rows)
//{
// string content = item["Content"].ToString();
// content = content + item["OpenDate"].ToString();
// list.Add(new { content = content });
//}
return list;
}
#endregion
#region 读取消息提示
[WebMethod(EnableSession = true)]
public List GetListWindowMess4()
{
PagesNew.Login(this.Session);
int UserId = Convert.ToInt32(Session["UserId"]);
//string UserType = Convert.ToString(Session["UserType"]);
var list = DataNew.GetListOpenMess(UserId);
return list;
}
#endregion
public string[] MessEn = { "Collection", "The transport of the shipment item has started in the country of the sender/Item posted at post office", "Opening", "Departure from outward office of exchange", "Opening", "Arrival at the International Office of destination", "Sorting,Ready to be sent to {City}", " {City},Processing" };
public string[] MessRu = { "Collection", "The transport of the shipment item has started in the country of the sender/Item posted at post office", "Opening", "Departure from outward office of exchange", "Opening", "Arrival at the International Office of destination", "Sorting,Ready to be sent to {City}", " {City},Processing" };
public string[] MessSp = { "Collection", "The transport of the shipment item has started in the country of the sender/Item posted at post office", "Opening", "Departure from outward office of exchange", "Opening", "Arrival at the International Office of destination", "Sorting,Ready to be sent to {City}", " {City},Processing" };
public string[] MessPp = { "Collection", "The transport of the shipment item has started in the country of the sender/Item posted at post office", "Opening", "Departure from outward office of exchange", "Opening", "Arrival at the International Office of destination", "Sorting,Ready to be sent to {City}", " {City},Processing" };
public List GetWLMess(int Lan, DateTime SDate, int days, int spdays, string City, int LastNum, int SecondNum)
{
List list = new List();
if (days == 30)
{
WL_TrackStep md = new WL_TrackStep();
md.SDay = 3;
md.EDay = 4;
md.Step = 1;
md.DayLen = 1;
list.Add(md);
md = new WL_TrackStep();
md.SDay = 4;
md.EDay = 4;
md.Step = 2;
md.DayLen = 0;
list.Add(md);
md = new WL_TrackStep();
md.SDay = 5;
md.EDay = 6;
md.Step = 3;
md.DayLen = 2;
list.Add(md);
md = new WL_TrackStep();
md.SDay = 7;
md.EDay = 11;
md.Step = 4;
md.DayLen = 4;
list.Add(md);
md = new WL_TrackStep();
md.SDay = 12;
md.EDay = 20;
md.Step = 5;
md.DayLen = 3;
list.Add(md);
md = new WL_TrackStep();
md.SDay = 21;
md.EDay = 25;
md.Step = 6;
md.DayLen = 2;
list.Add(md);
md = new WL_TrackStep();
md.SDay = 26;
md.EDay = 29;
md.Step = 7;
md.DayLen = 2;
list.Add(md);
md = new WL_TrackStep();
md.SDay = 30;
md.EDay = 35;
md.Step = 8;
md.DayLen = 4;
list.Add(md);
}
else
if (days == 45)
{
WL_TrackStep md = new WL_TrackStep();
md.SDay = 3;
md.EDay = 4;
md.Step = 1;
md.DayLen = 1;
list.Add(md);
md = new WL_TrackStep();
md.SDay = 4;
md.EDay = 4;
md.Step = 2;
md.DayLen = 0;
list.Add(md);
md = new WL_TrackStep();
md.SDay = 5;
md.EDay = 7;
md.Step = 3;
md.DayLen = 2;
list.Add(md);
md = new WL_TrackStep();
md.SDay = 8;
md.EDay = 11;
md.Step = 4;
md.DayLen = 3;
list.Add(md);
md = new WL_TrackStep();
md.SDay = 12;
md.EDay = 28;
md.Step = 5;
md.DayLen = 4;
list.Add(md);
md = new WL_TrackStep();
md.SDay = 29;
md.EDay = 34;
md.Step = 6;
md.DayLen = 2;
list.Add(md);
md = new WL_TrackStep();
md.SDay = 35;
md.EDay = 42;
md.Step = 7;
md.DayLen = 3;
list.Add(md);
md = new WL_TrackStep();
md.SDay = 43;
md.EDay = 47;
md.Step = 8;
md.DayLen = 3;
list.Add(md);
}
else
if (days == 60)
{
WL_TrackStep md = new WL_TrackStep();
md.SDay = 3;
md.EDay = 4;
md.Step = 1;
md.DayLen = 1;
list.Add(md);
md = new WL_TrackStep();
md.SDay = 4;
md.EDay = 4;
md.Step = 2;
md.DayLen = 0;
list.Add(md);
md = new WL_TrackStep();
md.SDay = 5;
md.EDay = 8;
md.Step = 3;
md.DayLen = 2;
list.Add(md);
md = new WL_TrackStep();
md.SDay = 9;
md.EDay = 12;
md.Step = 4;
md.DayLen = 3;
list.Add(md);
md = new WL_TrackStep();
md.SDay = 13;
md.EDay = 37;
md.Step = 5;
md.DayLen = 4;
list.Add(md);
md = new WL_TrackStep();
md.SDay = 38;
md.EDay = 47;
md.Step = 6;
md.DayLen = 3;
list.Add(md);
md = new WL_TrackStep();
md.SDay = 48;
md.EDay = 55;
md.Step = 7;
md.DayLen = 3;
list.Add(md);
md = new WL_TrackStep();
md.SDay = 56;
md.EDay = 60;
md.Step = 8;
md.DayLen = 4;
list.Add(md);
}
//Random rd = new Random();
List clist = new List();
for (int i = 0; i < list.Count; i++)
{
if (list[i].SDay > spdays)
continue;
var cmd = new WL_TrackContent();
if (Lan == 1)
{
cmd.Content = MessEn[i].Replace("{City}", City);
}
else
if (Lan == 2)
{
cmd.Content = MessRu[i].Replace("{City}", City);
}
else if (Lan == 3)
{
cmd.Content = MessSp[i].Replace("{City}", City);
}
else if (Lan == 4)
{
cmd.Content = MessPp[i].Replace("{City}", City);
}
int h = SecondNum % 9 + i;
if (i >= 4)
h = SecondNum % 5 + i;
if (h < 6)
h = 7;
if (i == 1)
h = h + 3;
DateTime NowDate = SDate.AddDays(list[i].SDay);
if (list[i].DayLen > 0)
NowDate = NowDate.AddDays(LastNum % list[i].DayLen);
if (NowDate >= DateTime.Today)
NowDate = DateTime.Now.AddDays(-1);
int m = SecondNum % 9 + i * 5;
cmd.InDate = NowDate.ToString("yyyy-MM-dd") + " " + h.ToString("00") + ":" + m.ToString("00");
clist.Add(cmd);
}
return clist;
}
#region 读取物流信息
[WebMethod(Description = "读取物流信息", EnableSession = true)]
public List GetTrackModel(string Code)
{
if (Code.Trim() == "" && Code.Trim().Length < 4)
return null;
// ServiceReference1.WL_TrackList md = new ServiceReference1.WL_TrackList();
// ServiceReference1.OutServiceSoapClient sc = new ServiceReference1.OutServiceSoapClient();
BaseService obj = new BaseService();
var md = obj.GetTrackListModel(Code.Trim());
if (md == null)
return null;
int LastNum = 1;
int SecondNum = 2;
if (IsNumber(Code.Substring(Code.Length - 1)) == true)
{
LastNum = Convert.ToInt32(Code.Substring(Code.Length - 1));
}
else if (IsNumber(Code.Substring(Code.Length - 3, 1)) == true)
{
LastNum = Convert.ToInt32(Code.Substring(Code.Length - 3, 1));
}
if (IsNumber(Code.Substring(Code.Length - 2, 1)) == true)
{
SecondNum = Convert.ToInt32(Code.Substring(Code.Length - 2, 1));
}
else if (IsNumber(Code.Substring(Code.Length - 4, 1)) == true)
{
SecondNum = Convert.ToInt32(Code.Substring(Code.Length - 4, 1));
}
List list = new List();
DateTime InDate = DateTime.Now;
if (md.InDate != null)
InDate = md.InDate.Value;
TimeSpan ts = DateTime.Now - InDate;
int spdays = ts.Days; //两天相差的天数
if (spdays < 2)
{
return null;
}
int Days = 30;
if (md.Days != null)
Days = md.Days.Value;
int Lan = 1;
if (md.Lan != null)
Lan = md.Lan.Value;
var list1 = GetWLMess(Lan, InDate, Days, spdays, md.City, LastNum, SecondNum);
if (list1 != null)
{
for (int i = list1.Count - 1; i >= 0; i--)
{
list1[i].Country = md.Country;
list.Add(list1[i]);
}
}
return list;
}
#endregion
public static bool IsNumber(string strNumber)
{
Regex regex = new Regex("[^0-9]");
return !regex.IsMatch(strNumber);
}
#region 注册
[WebMethod(EnableSession = true)]
public int Register(JC_FriendCode model)
{
BaseService obj = new BaseService();
if (obj.IsFriendCode(model.FriendCode) == 0)
return 0;
if (obj.IsUserName(model.UserName) > 0)
return 1;
JC_Company CompanyMd = new JC_Company();
CompanyMd.CompanyName = model.CompanyName;
CompanyMd.WeightRate = 20;
CompanyMd.State = 1;
CompanyMd.SimpleName = (model.CompanyName.Length >= 10) ? model.CompanyName.Substring(0, 9) : model.CompanyName;
CompanyMd.Email = model.Email;
CompanyMd.Phone = model.Phone;
CompanyMd.CompanyID = 0;
int CompanyId = JC_CompanyService.Save(CompanyMd);
obj.SaveStartData(CompanyId);
int UserId = obj.RegisterAddUser(model.UserName, model.PassWord, CompanyId);
obj.UpdateFriendCode(model.FriendCode, UserId);
return 2;
}
#endregion
#region 发送邮件
public string SendMail(string Title, string Content, string Email)
{
try
{
MailMessage mailObj = new MailMessage();
mailObj.From = new MailAddress("jwfish_007@163.com"); //发送人邮箱地址
mailObj.To.Add(Email); //收件人邮箱地址
mailObj.Subject = Title; //主题
mailObj.BodyEncoding = System.Text.Encoding.UTF8;//编码
mailObj.Body = Content; //正文
SmtpClient smtp = new SmtpClient();
smtp.Host = "smtp.163.com"; //smtp服务器名称
smtp.UseDefaultCredentials = true;
smtp.Credentials = new NetworkCredential("jwfish_007@163.com", "cmj62710315"); //发送人的登录名和密码
smtp.Send(mailObj);
return "已发送至邮箱,请注意查收";
}
catch (Exception ex)
{
return ex.Message;
}
}
#endregion
#region 导入数据
[WebMethod(EnableSession = true)]
public void TestDataImport(int OldCompanyId)
{
PagesNew.Login(this.Session);
BaseService obj = new BaseService();
int CompanyId = Convert.ToInt32(Session["CompanyId"]);
obj.TestDataImport(OldCompanyId, CompanyId);
}
#endregion
#region 验证管理员
[WebMethod(EnableSession = true)]
public int IsManage(string UserName, string Password)
{
PagesNew.Login(this.Session);
BaseService obj = new BaseService();
int CompanyId = Convert.ToInt32(Session["CompanyId"]);
return obj.IsManage(UserName, Password, CompanyId);
}
#endregion
#region 清空数据数据
[WebMethod(EnableSession = true)]
public void DeleteDataImport(int IsShop, int IsSort, int IsGoods, int IsChase, int IsOrder)
{
PagesNew.Login(this.Session);
BaseService obj = new BaseService();
int CompanyId = Convert.ToInt32(Session["CompanyId"]);
obj.DeleteTestData(CompanyId, IsShop, IsSort, IsGoods, IsChase, IsOrder);
}
#endregion
#region 导入平邮跟踪码
[WebMethod(EnableSession = true)]
public string ImportTrack(string FileName)
{
if (string.IsNullOrEmpty(FileName) == true) return "要导入的文件路径不能为空";
string ServerFileName = AppDomain.CurrentDomain.BaseDirectory + FileName;
if (System.IO.File.Exists(ServerFileName) == false) return "要导入的文件路径不存在";
try
{
MicrosoftExcel excel = new MicrosoftExcel();
DataTable tb = excel.ImportExcel(ServerFileName);
string error = "";
if (tb.Columns.Contains("国家") == false) { error = error + "导入模板的 国家 列不存在"; }
if (tb.Columns.Contains("跟踪码") == false) { error = error + "导入模板的 跟踪码 列不存在"; }
if (tb.Columns.Contains("发货时间") == false) { error = error + "导入模板的 发货时间 列不存在"; }
if (tb.Columns.Contains("城市") == false) { error = error + "导入模板的 城市 列不存在"; }
if (string.IsNullOrEmpty(error) == false) return error + ";请导入格式不正确";
BaseService obj = new BaseService();
int Num = 0;
for (int i = 0; i < tb.Rows.Count; i++)
{
WL_TrackList md = new WL_TrackList();
md.Country = tb.Rows[i]["国家"].ToString().Trim();
md.TrackCode = tb.Rows[i]["跟踪码"].ToString().Trim();
if (md.TrackCode == "")
{
error += "第" + (i + 2).ToString() + "行数据跟踪码没填";
continue;
}
if (tb.Rows[i]["发货时间"].ToString().Trim() == "")
{
error += "第" + (i + 2).ToString() + "行数据发货时间没填";
continue;
}
try
{
md.InDate = DateTime.Parse(tb.Rows[i]["发货时间"].ToString().Trim());
//md.InDate =Convert.ToDateTime(tb.Rows[i]["发货时间"].ToString().Trim());
}
catch
{
error += "第" + (i + 2).ToString() + "行数据发货时间格式错误,请填写日期格式";
continue;
}
md.City = tb.Rows[i]["城市"].ToString().Trim();
md.TrackId = 0;
obj.SaveTrackList(md);
Num++;
}
if (error == "")
{
error = "数据成功共【" + Num.ToString() + "条】;";
}
else
{
error = "数据导入成功【" + Num.ToString() + "条】;" + error;
}
return error;
}
catch (Exception e)
{
return "文件导入失败!请确定模板格式是否正确,或者重新下载模板,填写数据,重新导入!!!" + e.Message;
}
return "导入成功";
}
#endregion
#region 保存Code
[WebMethod(EnableSession = true)]
public JC_Shop SaveCode(string Appkey, string DeveKey, string Code)
{
PagesNew.Login(this.Session);
AlibabaApi obj = new AlibabaApi();
obj.Appkey = Appkey.Trim();
obj.DeveKey = DeveKey.Trim();
obj.Code = Code.Trim();
string ErrorMessage = "";
obj.GetAllToken(out ErrorMessage);
if (string.IsNullOrEmpty(ErrorMessage) == false) return null;
JC_Shop model = new JC_Shop();
model.RefreshToken = obj.RefreshToken;
model.AccessToken = obj.AccessToken;
model.RefreshTokenSaveTime = obj.RefreshTokenSaveTime;
model.AccessTokenUpdateTime = obj.AccessTokenUpdateTime;
return model;
}
#endregion
#region 员工离职
[WebMethod(EnableSession = true)]
public void UpdateUserOut(string UserIds)
{
PagesNew.Login(this.Session);
if (UserIds != "")
JC_UserInfoService.UpdateDelete(UserIds.Trim(','));
}
#endregion
#region 读取菜单
[WebMethod(EnableSession = true)]
public List GetListMenuErp()
{
PagesNew.Login(this.Session);
Session["YLeave"] = 0;
string UserCode = Convert.ToString(Session["UserId"]);
int UserID = Convert.ToInt32(Session["UserId"]);
int CompanyId = Convert.ToInt32(Session["CompanyId"]);
var slist = BaseService.GetListMenu(UserID, CompanyId);
List list = new List();
if (slist != null)
{
foreach (var md in slist)
{
JC_Menu smd = new JC_Menu();
smd.parent_menu_no = md.ParentModuleNo;
smd.menu_no = md.ModuleNo;
smd.menu_url = md.ModuleUrl;
smd.target = md.Target;
smd.menu_name = md.ModuleName;
smd.sort_no = md.SortNo;
list.Add(smd);
}
}
List mlist = new List();
if (list != null)
{
var pmd = list.FindAll(n => n.parent_menu_no == null);
if (pmd != null)
{
foreach (var md in pmd)
{
md.layer = 1;
mlist.Add(md);
var ppmd = list.FindAll(n => n.parent_menu_no == md.menu_no);
if (ppmd != null)
{
if (ppmd.Count > 0)
md.has_child = 1;
foreach (var mmd in ppmd)
{
mmd.layer = 2;
mlist.Add(mmd);
var ppmd2 = list.FindAll(n => n.parent_menu_no == mmd.menu_no);
if (ppmd2 != null)
{
if (ppmd2.Count > 0)
mmd.has_child = 1;
foreach (var mmd2 in ppmd2)
{
mmd2.layer = 3;
mlist.Add(mmd2);
var ppmd3 = list.FindAll(n => n.parent_menu_no == mmd2.menu_no);
if (ppmd3 != null)
{
if (ppmd3.Count > 0)
mmd2.has_child = 1;
foreach (var mmd3 in ppmd3)
{
mmd3.layer = 4;
mlist.Add(mmd3);
}
}
}
}
}
}
}
}
}
if (mlist != null)
{
var umd = mlist.FindAll(n => n.menu_url != null && n.menu_url != "");
if (umd != null)
{
foreach (var md in umd)
{
md.use_state = 2;
var pmd = mlist.Find(n => n.menu_no == md.parent_menu_no);
if (pmd != null)
{
pmd.use_state = 2;
var pmd2 = mlist.Find(n => n.menu_no == pmd.parent_menu_no);
if (pmd2 != null)
{
pmd2.use_state = 2;
var pmd3 = mlist.Find(n => n.menu_no == pmd2.parent_menu_no);
if (pmd3 != null)
pmd3.use_state = 2;
}
}
}
}
}
if (mlist != null)
{
List mmlist = mlist.FindAll(n => n.use_state == 2);
return mmlist;
}
return mlist;
}
#endregion
#region 读取菜单ebook
[WebMethod(EnableSession = true)]
public List GetListMenuErpBook()
{
PagesNew.Login(this.Session);
Session["YLeave"] = 0;
string UserCode = Convert.ToString(Session["UserId"]);
int UserID = Convert.ToInt32(Session["UserId"]);
int CompanyId = Convert.ToInt32(Session["CompanyId"]);
var slist = DataNew.GetListMenuBook(UserID, CompanyId);
List list = new List();
if (slist != null)
{
foreach (var md in slist)
{
JC_Menu smd = new JC_Menu();
smd.parent_menu_no = md.ParentModuleNo;
smd.menu_no = md.ModuleNo;
smd.menu_url = md.ModuleUrl;
smd.target = md.Target;
smd.menu_name = md.ModuleName;
smd.sort_no = md.SortNo;
list.Add(smd);
}
}
List mlist = new List();
if (list != null)
{
var pmd = list.FindAll(n => n.parent_menu_no == null);
if (pmd != null)
{
foreach (var md in pmd)
{
md.layer = 1;
mlist.Add(md);
var ppmd = list.FindAll(n => n.parent_menu_no == md.menu_no);
if (ppmd != null)
{
if (ppmd.Count > 0)
md.has_child = 1;
foreach (var mmd in ppmd)
{
mmd.layer = 2;
mlist.Add(mmd);
var ppmd2 = list.FindAll(n => n.parent_menu_no == mmd.menu_no);
if (ppmd2 != null)
{
if (ppmd2.Count > 0)
mmd.has_child = 1;
foreach (var mmd2 in ppmd2)
{
mmd2.layer = 3;
mlist.Add(mmd2);
var ppmd3 = list.FindAll(n => n.parent_menu_no == mmd2.menu_no);
if (ppmd3 != null)
{
if (ppmd3.Count > 0)
mmd2.has_child = 1;
foreach (var mmd3 in ppmd3)
{
mmd3.layer = 4;
mlist.Add(mmd3);
}
}
}
}
}
}
}
}
}
if (mlist != null)
{
var umd = mlist.FindAll(n => n.menu_url != null && n.menu_url != "");
if (umd != null)
{
foreach (var md in umd)
{
md.use_state = 2;
var pmd = mlist.Find(n => n.menu_no == md.parent_menu_no);
if (pmd != null)
{
pmd.use_state = 2;
var pmd2 = mlist.Find(n => n.menu_no == pmd.parent_menu_no);
if (pmd2 != null)
{
pmd2.use_state = 2;
var pmd3 = mlist.Find(n => n.menu_no == pmd2.parent_menu_no);
if (pmd3 != null)
pmd3.use_state = 2;
}
}
}
}
}
if (mlist != null)
{
List mmlist = mlist.FindAll(n => n.use_state == 2);
return mmlist;
}
return mlist;
}
#endregion
}
}