private void button2_Click(object sender, EventArgs e) { string formPath = Config.GetValue("FormPath") + "\\Learun.Application.Web\\"; //来源文件目录 string toPath = Config.GetValue("ToPathWeb"); //目标文件目录 textBox1.Clear(); textBox1.AppendText("开始复制文件\r\n"); string[] filePaths = DirFileHelper.GetFileNames(formPath, "*", true); int num = 0; foreach (string filePath in filePaths) { if (filePath.IndexOf("\\bin\\") == -1 && filePath.IndexOf("\\obj\\") == -1 && filePath.IndexOf("Learun.Application.Web.csproj") == -1) { textBox1.AppendText(num + ":" + filePath + "\r\n"); string path = toPath + filePath.Replace(formPath, ""); if (filePath.IndexOf("\\LR_Content\\") != -1) { string content = File.ReadAllText(filePath, Encoding.UTF8); FileInfo fi = new FileInfo(path); if (fi.Extension == ".js") { if (!string.IsNullOrEmpty(content)) { content = javaScriptCompressor.Compress(content); } DirFileHelper.CreateFileContent(path, content); } else if (fi.Extension == ".css") { if (!string.IsNullOrEmpty(content)) { content = cssCompressor.Compress(content); } DirFileHelper.CreateFileContent(path, content); } else { if (!Directory.Exists(fi.DirectoryName)) { Directory.CreateDirectory(fi.DirectoryName); } System.IO.File.Copy(filePath, path, true); } } else { FileInfo fi = new FileInfo(path); if (!Directory.Exists(fi.DirectoryName)) { Directory.CreateDirectory(fi.DirectoryName); } System.IO.File.Copy(filePath, path, true); } num++; } } textBox1.AppendText("结束复制文件\r\n"); }
/// <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 ActionResult ExecuteImportScheme(string templateId, string fileId, int chunks, string ext) { UserInfo userInfo = LoginUserInfo.Get(); string path = annexesFileIBLL.SaveAnnexes(fileId, fileId + "." + ext, chunks, userInfo); if (!string.IsNullOrEmpty(path)) { // 读取导入文件 string data = DirFileHelper.ReadText(path); // 删除临时文件 DirFileHelper.DeleteFile2(path); if (!string.IsNullOrEmpty(data)) { NWFSchemeModel nWFSchemeModel = data.ToObject <NWFSchemeModel>(); // 验证流程编码是否重复 NWFSchemeInfoEntity schemeInfoEntityTmp = nWFSchemeIBLL.GetInfoEntityByCode(nWFSchemeModel.info.F_Code); if (schemeInfoEntityTmp != null) { nWFSchemeModel.info.F_Code = Guid.NewGuid().ToString(); } nWFSchemeIBLL.SaveEntity("", nWFSchemeModel.info, nWFSchemeModel.scheme, nWFSchemeModel.authList); } return(Success("导入成功")); } else { return(Fail("导入模板失败!")); } }
/// <summary> /// 获取图片 /// </summary> /// <param name="keyValue">主键</param> public void GetImg(string keyValue) { string img = ""; if (!string.IsNullOrEmpty(keyValue)) { string fileHeadImg = Config.GetValue("fileHealthImg"); //Config.GetValue("fileAppDTImg"); string fileImg = string.Format("{0}/{1}{2}", fileHeadImg, keyValue, ".jpg"); if (DirFileHelper.IsExistFile(fileImg)) { img = fileImg; FileDownHelper.DownLoadnew(img); return; } } else { img = "/Content/images/add.jpg"; } if (string.IsNullOrEmpty(img)) { img = "/Content/images/add.jpg"; } FileDownHelper.DownLoad(img); }
/// <summary>取得图片文件的宽高</summary> /// <param name="srcFile"></param> /// <param name="ww">取得图片的宽度</param> /// <param name="hh">取得图片的高度</param> /// <returns></returns> public static bool Get_Pic_WW_HH(string srcFile, out int ww, out int hh) { string sExt = DirFileHelper.GetFileExtension(srcFile).ToLower(); if (sExt == "gif" || sExt == "jpg" || sExt == "jpeg" || sExt == "bmp" || sExt == "png") { if (srcFile.IndexOf(":") < 0) { srcFile = DirFileHelper.GetMapPath(srcFile); } if (DirFileHelper.IsExistFile(srcFile)) { try { System.Drawing.Image testImage = System.Drawing.Image.FromFile(srcFile); ww = testImage.Width; hh = testImage.Height; testImage.Dispose(); return(true); } catch (Exception ex) { throw ex; } } } ww = 0; hh = 0; return(false); }
public static bool BuildDirectoryMd5(string dirPath, out string dirMD5) { dirMD5 = string.Empty; if (string.IsNullOrEmpty(dirPath)) { return(false); } string[] fileList = null; if (!DirFileHelper.GetFileNames(dirPath, "*", true, out fileList)) { return(false); } StringBuilder builder = new StringBuilder(); if (fileList == null) { return(false); } for (int i = 0; i < fileList.Length; i++) { string str = string.Empty; if (BuildFileMd5(fileList[i], out str)) { builder.Append(str); } } byte[] data = CreateMD5(Encoding.Default.GetBytes(builder.ToString())); dirMD5 = FormatMD5(data); return(true); }
/// <summary> /// 生成控制器 /// </summary> /// <param name="table">表名</param> /// <returns></returns> public string GetCodeBuilderController(string table) { StringBuilder sbController = new StringBuilder(); sbController.Append("using AnJie.ERP.Business;\r\n"); sbController.Append("using AnJie.ERP.Entity;\r\n"); sbController.Append("using AnJie.ERP.Utilities;\r\n"); sbController.Append("using System;\r\n"); sbController.Append("using System.Collections;\r\n"); sbController.Append("using System.Collections.Generic;\r\n"); sbController.Append("using System.Data;\r\n"); sbController.Append("using System.Linq;\r\n"); sbController.Append("using System.Web;\r\n"); sbController.Append("using System.Web.Mvc;\r\n\r\n"); sbController.Append("namespace AnJie.ERP.WebApp.Areas." + AreasName + ".Controllers\r\n"); sbController.Append("{\r\n"); sbController.Append(" /// <summary>\r\n"); sbController.Append(" /// " + ClassName + "控制器\r\n"); sbController.Append(" /// </summary>\r\n"); sbController.Append(" public class " + ControllerName + " : PublicController<" + EntityName + ">\r\n"); sbController.Append(" {\r\n"); sbController.Append(" }\r\n"); sbController.Append("}"); WriteCodeBuilder(table + "\\" + ControllerName + ".cs", sbController.ToString()); string strFilePath = "~/CodeMatic/" + table; string strZipPath = "~/CodeMatic/" + table + ".zip"; GZipHelper.ZipFile(strFilePath, strZipPath); DirFileHelper.DeleteDirectory("~/CodeMatic/" + table); return(sbController.ToString()); }
/// <summary> /// 删除实体数据 /// <param name="keyValue">主键</param> /// <summary> /// <returns></returns> public void DeleteEntity(string keyValue) { try { DTImgEntity entity = GetEntity(keyValue); if (entity != null) { if (!string.IsNullOrEmpty(entity.F_FileName)) { string fileHeadImg = Config.GetValue("fileAppDTImg"); string fileImg = string.Format("{0}/{1}{2}", fileHeadImg, entity.F_Id, entity.F_FileName); if (DirFileHelper.IsExistFile(fileImg)) { System.IO.File.Delete(fileImg); } } } dTImgService.DeleteEntity(keyValue); } catch (Exception ex) { if (ex is ExceptionEx) { throw; } else { throw ExceptionEx.ThrowBusinessException(ex); } } }
/// <summary> /// 获取图片 /// </summary> /// <param name="keyValue">主键</param> public void GetImg(string keyValue) { DTImgEntity entity = GetEntity(keyValue); string img = ""; if (entity != null) { if (!string.IsNullOrEmpty(entity.F_FileName)) { string fileHeadImg = Config.GetValue("fileAppDTImg"); string fileImg = string.Format("{0}/{1}{2}", fileHeadImg, entity.F_Id, entity.F_FileName); if (DirFileHelper.IsExistFile(fileImg)) { img = fileImg; FileDownHelper.DownLoadnew(img); return; } } } else { img = "/Content/images/add.jpg"; } if (string.IsNullOrEmpty(img)) { img = "/Content/images/add.jpg"; } FileDownHelper.DownLoad(img); }
/// <summary> /// 同步bin文件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void button1_Click(object sender, EventArgs e) { string formPath = Config.GetValue("FormPath") + "\\Learun.Framework.Module\\"; //来源文件目录 string toPath = Config.GetValue("ToPath"); //目标文件目录 string[] filePaths = DirFileHelper.GetFileNames(formPath, "*", true); textBox1.Clear(); textBox1.AppendText("开始复制文件\r\n"); int num = 0; foreach (string filePath in filePaths) { if (filePath.IndexOf("\\bin\\Release") != -1) { textBox1.AppendText(num + ":" + filePath + "\r\n"); string path = toPath + filePath.Replace(formPath, ""); FileInfo fi = new FileInfo(path); if (!Directory.Exists(fi.DirectoryName)) { Directory.CreateDirectory(fi.DirectoryName); } System.IO.File.Copy(filePath, path, true); num++; } } textBox1.AppendText("结束复制文件\r\n"); }
static JWTHelper() { string path = DirFileHelper.MapPath("SecretKey\\token.privateKey.key"); string key = DirFileHelper.ReadAllText(path); TokenPrivateKey = key; }
/// <summary> /// 获取用户头像 /// </summary> /// <param name="userId">用户ID</param> public void GetImg(string userId) { UserEntity entity = GetEntityByUserId(userId); string img = ""; string fileHeadImg = Config.GetValue("fileHeadImg"); if (entity != null) { if (!string.IsNullOrEmpty(entity.F_HeadIcon)) { string fileImg = string.Format("{0}/{1}{2}", fileHeadImg, entity.F_UserId, entity.F_HeadIcon); if (DirFileHelper.IsExistFile(fileImg)) { img = fileImg; } } } else { img = string.Format("{0}/{1}", fileHeadImg, "on-boy.jpg"); } if (string.IsNullOrEmpty(img)) { if (entity.F_Gender == 0) { img = string.Format("{0}/{1}", fileHeadImg, "on-girl.jpg"); } else { img = string.Format("{0}/{1}", fileHeadImg, "on-boy.jpg"); } } FileDownHelper.DownLoadnew(img); }
/// <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(""); }
public ActionResult TestModuleExcelExport() { DirFileHelper.ClearDirectory("/Areas/ZhangCeModule/UploadFile"); TestMoudleBll tmBll = new TestMoudleBll(); // 1.获取数据集合 List <TestMoudle> list = tmBll.GetTestMoudleAllInfo(CookieHelper.GetCookie("NK")); // 2.设置单元格抬头 // key:实体对象属性名称,可通过反射获取值 // value:Excel列的名称 Dictionary <string, string> cellheader = new Dictionary <string, string> { { "GradeCode", "年级" }, { "ClassCode", "班级编号" }, { "ClassName", "班级名称" }, { "ItemName", "项目名称" }, { "TestTeacher", "测试老师" }, { "TestTime", "测试时间" }, { "TestAddress", "测试地点" }, { "TestMaterial", "测试器材" }, { "TestType", "测试方式(手工/仪器)" }, }; // 3.进行Excel转换操作,并返回转换的文件下载链接 string urlPath = DeriveExcel.ListToExcel2003(cellheader, list, "测试信息模版"); var path = Server.MapPath("~/" + urlPath); var name = Path.GetFileName(path); return(File(path, "application/vnd.ms-excel", name)); }
public ActionResult HeBeiStudentTestTableExport() { DirFileHelper.ClearDirectory("/Areas/ZhangCeModule/UploadFile"); DStudent_TestScoreBll tcBll = new DStudent_TestScoreBll(); List <HeBeiStudents> heBeiSList = tcBll.GetHeBeiStudentInfoExport(CookieHelper.GetCookie("NK")); StringBuilder HeBeiHtmlTable = new StringBuilder(); HeBeiHtmlTable.Append("<table>"); HeBeiHtmlTable.Append("<tr><th >序号</th><th>新生来源地(以省内11个设区市为单位)</th><th>性别</th><th>人数</th><th>优秀率</th><th>良好率</th><th>及格率</th><th>总达标率</th></tr>"); string mes = ""; foreach (HeBeiStudents heBeiS in heBeiSList) { mes = mes + string.Format("<tr><th>{0}</th><th>{1}</th><th>{2}</th><th>{3}</th><th>{4}</th><th>{5}</th><th>{6}</th><th>{7}</th></tr>", heBeiS.ID, heBeiS.StudentAddress, heBeiS.StudentSex, heBeiS.StudentCount, heBeiS.Outstanding, heBeiS.Goodrate, heBeiS.PassRate, heBeiS.TotalRate); } HeBeiHtmlTable.Append(mes); HeBeiHtmlTable.Append("</table>"); // 进行Excel转换操作,并返回转换的文件下载链接 string urlPath = DeriveExcel.ExportHtmlTableToExcel(HeBeiHtmlTable.ToString(), "河北新生表"); var path = Server.MapPath("~/" + urlPath); var name = Path.GetFileName(path); return(File(path, "application/vnd.ms-excel", name)); }
public IHttpActionResult SaveProof(ProofObj obj) { User u = SessionManage.CurrentUser; obj.FinshDate = obj.FinshDate.AddHours(8); if (obj.ProofOrderId == "" || obj.ProofStyleId == "") { return(BadRequest("申请单号和样品单号不能为空!")); } if (u != null) { string webPath = Config.GetSampleConfig().ProofFilePath; ProofOrderAdapter poa = new ProofOrderAdapter(u); obj.FileListItems.ForEach(p => { string path1 = p.Url; string path2 = webPath + @"gy\" + p.FullName; DirFileHelper.MoveFile(path1, path2); p.Url = path2; }); poa.CreateProofOrder(obj); poa.SaveProofOrder(); } return(Ok()); }
private void FtpDownload(M_MyJob myJob) { //文件路径 string filePath = Path.GetDirectoryName(myJob.FilePath).Replace("\\", "//"); //文件名 string fileName = Path.GetFileName(myJob.FilePath); //复制文件到系统路径 string copyPath = string.Format(@"{0}\SowerTestClient\Paper\Download\{1}_{2}", Application.StartupPath, PublicClass.StudentCode, fileName); //下载文件保存路径 string savePath = string.Format("{0}\\{1}", Globals.DownLoadDir, fileName); FtpWeb ftpWeb = CommonUtil.GetFtpWeb(); if (ftpWeb != null) { ftpWeb.Download(Globals.DownLoadDir, fileName, filePath, tsbBar, tsbMessage, "作业下载进度:"); } //复制作业到系统目录 File.Copy(savePath, copyPath, true); //删除下载文件 File.Delete(savePath); //设置已下载状态 dgvResult.SelectedRows[0].Cells["JobDownLoadState"].Value = "已下载"; tsbMessage.Text = "作业下载进度:"; tsbBar.Value = 0; //下载账套文件 if (ftpWeb != null && myJob.RequireEnvFile.ToLower() == "true" && myJob.IsUpload.ToLower() == "true" && cbIsDownAccount.Checked == true) { filePath = Path.GetDirectoryName(myJob.EnvFilePath).Replace("\\", "//"); fileName = myJob.EnvFileName; copyPath = string.Format(@"{0}\SowerTestClient\Paper\Account\{1}", Application.StartupPath, fileName); savePath = string.Format("{0}\\{1}", Globals.DownLoadDir, fileName); ftpWeb.Download(Globals.DownLoadDir, fileName, filePath, tsbBar, tsbMessage, "帐套下载进度:"); //复制作业到系统目录 DirFileHelper.Copy(savePath, copyPath); //删除临时下载文件 DirFileHelper.DeleteFile(savePath); tsbMessage.Text = "帐套下载进度:"; tsbBar.Value = 0; dgvResult.SelectedRows[0].Cells["AccountDownLoadState"].Value = "已下载"; } //下载视频文件 if (ftpWeb != null && myJob.IsUploadVideoFile == true && string.IsNullOrEmpty(myJob.VideoFilePath) == false && cbIsDownVideo.Checked == true) { filePath = Path.GetDirectoryName(myJob.VideoFilePath).Replace("\\", "//"); fileName = myJob.VideoFileName; copyPath = string.Format(@"{0}\SowerTestClient\Video\{1}_{2}\", Application.StartupPath, PublicClass.StudentCode, DirFileHelper.GetFileNameNoExtension(myJob.VideoFilePath)); savePath = string.Format("{0}\\{1}", Globals.DownLoadDir, fileName); ftpWeb.Download(Globals.DownLoadDir, fileName, filePath, tsbBar, tsbMessage, "视频下载进度:"); //复制作业到系统目录 ZipFileTools.UnZipSZL(savePath, copyPath); //删除临时下载文件 DirFileHelper.DeleteFile(savePath); tsbMessage.Text = "视频下载进度:"; tsbBar.Value = 0; dgvResult.SelectedRows[0].Cells["VideoDownLoadState"].Value = "已下载"; } }
/// <summary>读取数据</summary> public override void LoadData() { int id = ConvertHelper.Cint0(hidId.Text); if (id != 0) { //获取指定ID的广告位置内容 var model = AdvertisingPositionBll.GetInstence().GetModelForCache(x => x.Id == id); if (model == null) { return; } //地址名称 txtName.Text = model.Name; //给下拉列表赋值 ddlParentId.SelectedValue = model.ParentId + ""; //编辑时不能修改父节点 ddlParentId.Enabled = false; //设置父ID txtParent.Text = model.ParentId + ""; //设置排序 txtSort.Text = model.Sort + ""; //KEY txtKey.Text = model.Keyword; //给页面图片赋值 if (model.MapImg != null && model.MapImg.Length > 5) { imgMap.ImageUrl = DirFileHelper.GetFilePathPostfix(model.MapImg, "s"); } else { //不存在图片,则隐藏图片控件和图片删除按钮 imgMap.Visible = false; ButtonDelMapImg.Visible = false; } //给页面图片赋值 if (model.PicImg != null && model.PicImg.Length > 5) { imgPic.ImageUrl = DirFileHelper.GetFilePathPostfix(model.PicImg, "s"); } else { //不存在图片,则隐藏图片控件和图片删除按钮 imgPic.Visible = false; ButtonDelPicImg.Visible = false; } //是否显示(状态) rblIsDisplay.SelectedValue = model.IsDisplay + ""; } else { //新建广告位置时,隐藏图片控件和图片删除按钮 imgMap.Visible = false; imgPic.Visible = false; ButtonDelMapImg.Visible = false; ButtonDelPicImg.Visible = false; } }
public static void LoadConfig() { ConfigPath = DirFileHelper.MapPath(ConfigPath); string context = DirFileHelper.ReadAllText(ConfigPath); RedisServers = context.JsonToList <RedisServerModel>(); }
public App() { var dir = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Jobs"); var dir2 = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Output"); DirFileHelper.CreateDir(dir); DirFileHelper.CreateDir(dir2); }
public void Execute(IJobExecutionContext context) { // string path = System.Environment.CurrentDirectory; // MapPath("/App_Data/selfsetting.xml"); HttpContext http = HttpContext.Current; string path = System.IO.Path.Combine(HttpRuntime.AppDomainAppPath, "App_Data/selfsetting.xml"); XmlDocument xmldoc = new XmlDocument(); // string path = System.AppDomain.CurrentDomain.BaseDirectory.ToString()+ "App_Data/selfsetting.xml"; xmldoc.Load(path); string time = xmldoc.SelectSingleNode("root").SelectSingleNode("daorutime").Attributes[0].Value; string daorupath = xmldoc.SelectSingleNode("root").SelectSingleNode("daorudir").Attributes[0].Value; string daorunowdate = xmldoc.SelectSingleNode("root").SelectSingleNode("daorunowdate").Attributes[0].Value; var files = DirFileHelper.GetFileNames(daorupath); if (files.Length > 0) { DataSet ds = ExportFile.ExcelSqlConnection(files[0], "Info"); //调用自定义方法 DataRow[] dr = ds.Tables[0].Select(); int successcount = 0; int failcount = 0; M_HitchInfoBll M_HitchInfoBll = new M_HitchInfoBll(); for (int i = 0; i < dr.Length; i++) { try { M_HitchInfo model = new M_HitchInfo(); model.AreaName = dr[0][0].ToString(); model.FactorySation = dr[i][1].ToString(); model.Signal = dr[i][2].ToString(); model.HappenTimes = int.Parse(dr[i][3].ToString()); model.SignalType = dr[i][4].ToString(); model.HappenTimes1 = int.Parse(dr[i][5].ToString()); model.MessageType = dr[i][6].ToString(); model.CreateUserId = 1; model.CreateUserName = "******"; model.CreateTime = DateTime.Now.AddDays(int.Parse(daorunowdate)); if (M_HitchInfoBll.M_HitchInfoAdd(model) > 0) { successcount++; } else { failcount++; } } catch (Exception) { failcount++; } } for (int i = 0; i < files.Length; i++) { File.Delete(files[i]); } } }
/// <summary> /// 获取映射数据 /// </summary> /// <returns></returns> public Dictionary <string, UserModel> GetModelMap() { try { Dictionary <string, UserModel> dic = cache.Read <Dictionary <string, UserModel> >(cacheKey + "dic", CacheId.user); if (dic == null) { dic = new Dictionary <string, UserModel>(); var list = userService.GetAllList(); foreach (var item in list) { UserModel model = new UserModel() { companyId = item.F_CompanyId, departmentId = item.F_DepartmentId, name = item.F_RealName, }; string img = ""; if (!string.IsNullOrEmpty(item.F_HeadIcon)) { string fileHeadImg = Config.GetValue("fileHeadImg"); string fileImg = string.Format("{0}/{1}{2}", fileHeadImg, item.F_UserId, item.F_HeadIcon); if (DirFileHelper.IsExistFile(fileImg)) { img = item.F_HeadIcon; } } if (string.IsNullOrEmpty(img)) { if (item.F_Gender == 0) { img = "0"; } else { img = "1"; } } model.img = img; dic.Add(item.F_UserId, model); cache.Write(cacheKey + "dic", dic, CacheId.user); } } return(dic); } catch (Exception ex) { if (ex is ExceptionEx) { throw; } else { throw ExceptionEx.ThrowBusinessException(ex); } } }
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> /// <param name="keyValue">主键</param> public void RemoveForm(string keyValue) { //删除老照片 TelphoneCertificationEntity oldEntity = this.BaseRepository().FindEntity(keyValue); DirFileHelper.DeleteFile(oldEntity.photo_z); DirFileHelper.DeleteFile(oldEntity.photo_b); DirFileHelper.DeleteFile(oldEntity.photo_s); this.BaseRepository().Delete(keyValue); }
/// <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); }
public ActionResult RemoveForm(string keyValue) { var Entity = weChatAppBLL.GetEntity(keyValue); if (Entity != null) { weChatAppBLL.RemoveForm(keyValue); DirFileHelper.DeleteFile(Entity.AppLogo); } return(Success("删除成功。")); }
private async void SaveJobs() { var jobInfoList = this.JobInfos.ToList(); await Task.Run(() => { lock (_locker) { var jsonJobs = JsonConvert.SerializeObject(jobInfoList); DirFileHelper.WriteText(jobsFile, jsonJobs); } }); }
public App() { var dir = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Jobs"); var dir2 = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Output"); var dirLog = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Logs"); App.Current.Startup += Current_Startup; App.Current.Exit += Current_Exit; DirFileHelper.CreateDir(dir); DirFileHelper.CreateDir(dir2); DirFileHelper.CreateDir(dirLog); }
public static void SaveObjectLocal <T>(T source) where T : class { var basePath = CommonHelper.ExePath; var dirPath = Path.Combine(basePath, "LocalData"); DirFileHelper.CreateDir(dirPath); var serializedstr = JsonConvert.SerializeObject(source); var fileName = string.Format("local_{0}.json", typeof(T).ToString()); var filePath = Path.Combine(dirPath, fileName); DirFileHelper.CreateFile(filePath, serializedstr); }