using System; using System.Data; using System.IO; using System.Web; using System.Xml; using CallCenter.Utility; namespace CallCenterApi.Common { public class SysConfigHelper { public class DemoKeys { /// /// ApiID /// public string ID; /// /// api域名 /// public string Domain; /// /// Api名称 /// public string Name; /// /// ApiKey /// public string Keys; public DemoKeys(string Key) { var configPath = GetFilePath("~/Content/Config/DemoKeys.config"); var myxml = new XmlHelper(); var stream = new StringReader(myxml.InnerXml(configPath)); var reader = new XmlTextReader(stream); var ds = new DataSet(); ds.ReadXml(reader); var dt = ds.Tables.Count > 0 ? ds.Tables[0] : null; if (dt != null) { for (var i = 0; i < dt.Rows.Count; i++) { if (Key.ToLower() == dt.Rows[i]["ID"].ToString().ToLower() || Key.ToLower() == dt.Rows[i]["Domain"].ToString().ToLower()) { ID = dt.Rows[i]["ID"].ToString(); Domain = dt.Rows[i]["Domain"].ToString(); Name = dt.Rows[i]["Name"].ToString(); Keys = dt.Rows[i]["Keys"].ToString(); break; } } } } } public class SysConfigPara { /// /// Api地址请求超时秒数 /// public int ApiTimeOut; /// /// 广播连接用户 /// public string InterfaceUsername; /// /// 广播连接密码 /// public string InterfacePassword; /// /// 广播连接Key /// public string LoginSecretKey; /// /// 广播连接地址 /// public string BoardcastUrl; public SysConfigPara() { string configPath = GetFilePath("~/Content/Config/ConfigPara.config"); var myxml = new XmlHelper(); myxml.LoadXml(configPath); ApiTimeOut = Convert.ToInt32(myxml.GetValue("ApiTimeOut")); InterfaceUsername = myxml.GetValue("InterfaceUsername"); InterfacePassword = myxml.GetValue("InterfacePassword"); LoginSecretKey = myxml.GetValue("LoginSecretKey"); BoardcastUrl = myxml.GetValue("BoardcastUrl"); } } private static string GetFilePath(string fileName) { return HttpContext.Current.Server.MapPath(fileName); } } }