/// <summary> /// 获取某一个表的主键字段 /// </summary> /// <param name="tableCode">查询指定表</param> /// <returns></returns> public string GetPrimaryKey(string tableCode) { StringBuilder strSql = new StringBuilder(); if (!string.IsNullOrEmpty(tableCode)) { XmlDocument myXmlDocument = new XmlDocument(); myXmlDocument.Load(DirFileHelper.MapPath("~/CodeMatic/AnJie.ERP.Framework.pdm")); // 获取表格 string selectPath = "/Model/*[local-name()='RootObject' and namespace-uri()='object'][1]/*[local-name()='Children' and namespace-uri()='collection'][1]/*[local-name()='Model' and namespace-uri()='object'][1]/*[local-name()='Tables' and namespace-uri()='collection'][1]"; XmlNodeList myXmlNodeList = myXmlDocument.SelectSingleNode(selectPath).ChildNodes; foreach (XmlNode myXmlNode in myXmlNodeList) { if (myXmlNode.ChildNodes[2].InnerText.Equals(tableCode)) { XmlNodeList myXmlNodeList_field = myXmlNode.ChildNodes[11].ChildNodes; foreach (XmlNode myXmlNode_field in myXmlNodeList_field) { return(myXmlNode_field.ChildNodes[2].InnerText); } } } } return(""); }
static JWTHelper() { string path = DirFileHelper.MapPath("SecretKey\\token.privateKey.key"); string key = DirFileHelper.ReadAllText(path); TokenPrivateKey = key; }
/// <summary> /// 上传头像 /// </summary> /// <returns></returns> public ActionResult UploadFile() { HttpFileCollection files = System.Web.HttpContext.Current.Request.Files; //没有文件上传,直接返回 if (files[0].ContentLength == 0 || string.IsNullOrEmpty(files[0].FileName)) { return(HttpNotFound()); } string fileEextension = Path.GetExtension(files[0].FileName); string userId = OperatorProvider.Provider.Current().UserId; string virtualPath = string.Format("/upload/images/head/{0}{1}", userId, fileEextension); string fullFileName = DirFileHelper.MapPath(virtualPath); //创建文件夹,保存文件 string path = Path.GetDirectoryName(fullFileName); if (!string.IsNullOrEmpty(path)) { Directory.CreateDirectory(path); files[0].SaveAs(fullFileName); } UserEntity userEntity = new UserEntity { Id = OperatorProvider.Provider.Current().UserId, HeadIcon = virtualPath, EnabledMark = true, DeleteMark = false }; bool isSucc = userBLL.AddUser(userEntity.Id, userEntity, out userId); return(Success(isSucc ? "上传成功。" : "上传失败")); }
public static void LoadConfig() { ConfigPath = DirFileHelper.MapPath(ConfigPath); string context = DirFileHelper.ReadAllText(ConfigPath); RedisServers = context.JsonToList <RedisServerModel>(); }
static CustomActionFilterAttribute() { string path = DirFileHelper.MapPath("SecretKey\\api.privateKey.key"); PrivateKey = DirFileHelper.ReadAllText(path); path = DirFileHelper.MapPath("SecretKey\\api.publicKey.key"); PublicKey = DirFileHelper.ReadAllText(path); }
/// <summary> /// 获取某一个表的所有字段 /// </summary> /// <param name="tableCode">查询指定表</param> /// <returns></returns> public DataTable GetColumns(string tableCode) { StringBuilder strSql = new StringBuilder(); if (!string.IsNullOrEmpty(tableCode)) { DataTable dt = new DataTable(); DataColumn dc1 = new DataColumn("column_Name", Type.GetType("System.String")); DataColumn dc2 = new DataColumn("comments", Type.GetType("System.String")); DataColumn dc3 = new DataColumn("char_col_decl_length", Type.GetType("System.String")); DataColumn dc4 = new DataColumn("data_type", Type.GetType("System.String")); dt.Columns.Add(dc1); dt.Columns.Add(dc2); dt.Columns.Add(dc3); dt.Columns.Add(dc4); XmlDocument myXmlDocument = new XmlDocument(); myXmlDocument.Load(DirFileHelper.MapPath("~/CodeMatic/AnJie.ERP.Framework.pdm")); // 获取表格 string selectPath = "/Model/*[local-name()='RootObject' and namespace-uri()='object'][1]/*[local-name()='Children' and namespace-uri()='collection'][1]/*[local-name()='Model' and namespace-uri()='object'][1]/*[local-name()='Tables' and namespace-uri()='collection'][1]"; XmlNodeList myXmlNodeList = myXmlDocument.SelectSingleNode(selectPath).ChildNodes; foreach (XmlNode myXmlNode in myXmlNodeList) { if (myXmlNode.ChildNodes[2].InnerText.Equals(tableCode)) { XmlNodeList myXmlNodeList_field = myXmlNode.ChildNodes[10].ChildNodes; foreach (XmlNode myXmlNode_field in myXmlNodeList_field) { int count = myXmlNode_field.ChildNodes.Count; DataRow dr = dt.NewRow(); dr["column_Name"] = myXmlNode_field.ChildNodes[2].InnerText; dr["comments"] = myXmlNode_field.ChildNodes[1].InnerText; dr["data_type"] = myXmlNode_field.ChildNodes[9].InnerText; if (count > 9) { try { dr["char_col_decl_length"] = myXmlNode_field.ChildNodes[10].InnerText; } catch (Exception) { } finally { } } dt.Rows.Add(dr); } break; } } return(dt); } return(null); }
/// <summary> /// 加载所有数据表 /// </summary> /// <returns></returns> public XmlNodeList GetTableName() { XmlDocument myXmlDocument = new XmlDocument(); myXmlDocument.Load(DirFileHelper.MapPath("~/Areas/CodeMaticModule/DataModel/LeaRun.Framework.pdm")); // 获取表格 string selectPath = "/Model/*[local-name()='RootObject' and namespace-uri()='object'][1]/*[local-name()='Children' and namespace-uri()='collection'][1]/*[local-name()='Model' and namespace-uri()='object'][1]/*[local-name()='Tables' and namespace-uri()='collection'][1]"; XmlNodeList myXmlNodeList = myXmlDocument.SelectSingleNode(selectPath).ChildNodes; return(myXmlNodeList); }