using System; using System.Collections.Generic; using System.Linq; using System.Text; using Song.ServiceInterfaces; using WeiSha.Common; using Song.ViewData.Attri; using System.IO; namespace Song.ViewData.Methods { /// /// 平台信息 /// [HttpGet] public class Platform : IViewAPI { /// /// 授权信息 /// /// public WeiSha.Common.License Version() { WeiSha.Common.License lic = WeiSha.Common.License.Value; return lic; } /// /// 版权信息,来自根路径下的copyright.xml文件 /// /// public Copyright_Item[] Copyright() { List list = new List(); System.Xml.XmlDocument xml = new System.Xml.XmlDocument(); xml.Load(WeiSha.Common.Server.MapPath("~/Copyright.xml")); System.Xml.XmlNodeList nodes = xml.SelectNodes("Copyright/*"); foreach (System.Xml.XmlNode n in nodes) { string remark = n.Attributes["remark"] != null ? n.Attributes["remark"].Value : string.Empty; string type = n.Attributes["type"] != null ? n.Attributes["type"].Value : string.Empty; list.Add(new Copyright_Item() { Name = n.Name, Remark = Microsoft.JScript.GlobalObject.escape(remark), Type = type, Text = Microsoft.JScript.GlobalObject.escape(n.InnerText.Trim()) }); } return list.ToArray(); } /// /// 数据库是否链接正常 /// /// public bool DbConnection() { bool isCorrect = Business.Do().DatabaseLinkTest(); return isCorrect; } /// /// 数据库版本 /// /// public string DbVersion() { object version = Business.Do().ScalarSql("select @@version"); if (version == null) return string.Empty; string str = version.ToString(); str = str.Replace("\n", "").Replace("\t", "").Replace("\r", ""); return str; } /// /// 数据库字段与表是否完成 /// /// public string[] DbCheck() { bool isCorrect = Business.Do().DatabaseLinkTest(); if (!isCorrect) { throw new Exception("数据库链接不正常!"); } List error = Business.Do().DatabaseCompleteTest(); if (error == null) { return new string[] { }; } return error.ToArray(); } /// /// 机构公章信息 /// /// path:公章图片路径;positon:位置 public Dictionary Stamp() { Dictionary dic = new Dictionary(); Song.Entities.Organization org = Business.Do().OrganCurrent(); //公章 WeiSha.Common.CustomConfig config = CustomConfig.Load(org.Org_Config); //公章显示位置 string positon = config["StampPosition"].Value.String; if (string.IsNullOrEmpty(positon)) positon = "right-bottom"; dic.Add("positon", positon); //公章图像信息 string stamp = config["Stamp"].Value.String; string filepath = Upload.Get["Org"].Physics + stamp; dic.Add("path", !File.Exists(filepath) ? "" : Upload.Get["Org"].Virtual + stamp); return dic; } //其它基础信息 } #region /// /// 版权信息的项 /// public class Copyright_Item { public string Name { get; set; } public string Remark { get; set; } public string Type { get; set; } public string Text { get; set; } } #endregion }