using System.IO;
using System.Xml;
namespace WX.CRM.CRMServices.SMS.InterfaceModel
{
public class HuiZhiConfig
{
string _Assembly = "";
string _Url = "";
string _UserName = "";
string _Pwd = "";
string _Rstype = "xml";
int _Pfex = 0;
public HuiZhiConfig()
{
//加载配置
string filename = System.AppDomain.CurrentDomain.BaseDirectory + "XML\\SmsAccountConfig.xml";
try
{
if (File.Exists(filename))
{
//XElement root = XElement.Load(filename);
//var objects = from obj in root.Elements("HuiZhiConfig") select obj;
//object Define = objects.ToDictionary(
// k => k.Attribute("key").Value,
// v => v.Attribute("value").Value
//);
XmlDocument xDoc = new XmlDocument();
xDoc.Load(filename);
XmlNode xNode;
xNode = xDoc.SelectSingleNode(string.Format("//root//{0}", "HuiZhiConfig"));
if (xNode.Name == "HuiZhiConfig")
{
XmlNodeList node = xNode.ChildNodes;
foreach (XmlNode cn in node)
{
XmlElement temp = (XmlElement)cn;
switch (temp.GetAttribute("key"))
{
case "Assembly":
this._Assembly = temp.GetAttribute("value");
break;
case "Url":
this._Url = temp.GetAttribute("value");
break;
case "UserName":
this._UserName = temp.GetAttribute("value");
break;
case "Pwd":
this._Pwd = temp.GetAttribute("value");
break;
case "Rstype":
this._Rstype = temp.GetAttribute("value");
break;
case "Pfex":
int.TryParse(temp.GetAttribute("value"), out this._Pfex);
break;
}
}
}
}
}
catch
{
throw;
}
}
///
/// 程序集
///
public string Assembly
{
get { return _Assembly; }
set { _Assembly = value; }
}
///
/// 提交url
///
public string Url
{
get { return _Url; }
set { _Url = value; }
}
///
/// 用户名
///
public string UserName
{
get { return _UserName; }
set { _UserName = value; }
}
///
/// 密码
///
public string Pwd
{
get { return _Pwd; }
set { _Pwd = value; }
}
///
/// 返回类型,text或xml
///
public string Rstype
{
get { return string.Format("{0}", _Rstype).ToLower(); }
set { _Rstype = value; }
}
///
/// 短信发送时遇到违禁词时处理开关:0,1二个参数值(1自动处理禁发字符,此时短信长度会发一变化)
///
public int Pfex
{
get { return _Pfex; }
set { _Pfex = value; }
}
}
}