101 lines
3.1 KiB
C#
101 lines
3.1 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.IO;
|
|
using System.Xml;
|
|
|
|
namespace WX.CRM.CRMServices.SMS.InterfaceModel
|
|
{
|
|
public class LianTongConfig
|
|
{
|
|
string _account = "";
|
|
string _pwd = "";
|
|
string _url = "";
|
|
string _spCodeStr = "";
|
|
Dictionary<string, string> spCodeArr = new Dictionary<string, string>();
|
|
public LianTongConfig()
|
|
{
|
|
//加载配置
|
|
string filename = System.AppDomain.CurrentDomain.BaseDirectory + "XML\\SmsAccountConfig.xml";
|
|
try
|
|
{
|
|
if (File.Exists(filename))
|
|
{
|
|
XmlDocument xDoc = new XmlDocument();
|
|
xDoc.Load(filename);
|
|
XmlNode xNode;
|
|
xNode = xDoc.SelectSingleNode(string.Format("//root//{0}", "LianTong"));
|
|
if (xNode.Name == "LianTong")
|
|
{
|
|
XmlNodeList node = xNode.ChildNodes;
|
|
foreach (XmlNode cn in node)
|
|
{
|
|
XmlElement temp = (XmlElement)cn;
|
|
switch (temp.GetAttribute("key"))
|
|
{
|
|
case "account":
|
|
this._account = temp.GetAttribute("value");
|
|
break;
|
|
case "pwd":
|
|
this._pwd = temp.GetAttribute("value");
|
|
break;
|
|
case "url":
|
|
this._url = temp.GetAttribute("value");
|
|
break;
|
|
case "spcode":
|
|
this._spCodeStr = temp.GetAttribute("value");
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
catch
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
|
|
public string account
|
|
{
|
|
get { return _account; }
|
|
set { _account = value; }
|
|
}
|
|
|
|
public string pwd
|
|
{
|
|
get { return _pwd; }
|
|
set { _pwd = value; }
|
|
}
|
|
|
|
public string url
|
|
{
|
|
get { return _url; }
|
|
set { _url = value; }
|
|
}
|
|
/// <summary>
|
|
/// 联通是传的
|
|
/// </summary>
|
|
/// <param name="username"></param>
|
|
/// <returns></returns>
|
|
public string GetUserName(string SpCode)
|
|
{
|
|
try
|
|
{
|
|
string[] groupsp = _spCodeStr.Split('|');
|
|
foreach (string g in groupsp)
|
|
{
|
|
string[] sp = g.Split(',');
|
|
//以服务号获取用户密码
|
|
spCodeArr.Add(sp[1], sp[0]);
|
|
}
|
|
return spCodeArr[SpCode];
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw new Exception("【联通—通信接口企业号配置错误】:" + ex.Message + ex.StackTrace);
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|