static void Main(string[] args) { string watchFolder = ConfigurationManager.AppSettings["WacthFolder"]; string zipFolder = ConfigurationManager.AppSettings["ZipFolder"]; string password = ConfigurationManager.AppSettings["ZipEncryptionPassword"]; var fileList = IOHelper.GetExcellFileList(watchFolder); foreach (var obj in fileList) { if (IOHelper.IsCompressible(obj)) { FileZipHelper.FileZipWithPassword(obj, password); } } var zipFileList = IOHelper.GetZipFileList(watchFolder); foreach (var obj in zipFileList) { var newPath = zipFolder + IOHelper.GetFileName(obj); IOHelper.Move(obj, newPath); } MailTemplate mailTemplate = new MailTemplate(); try { string data = File.ReadAllText(ConfigurationManager.AppSettings["EmailFile"]); mailTemplate = JsonConvert.DeserializeObject <MailTemplate>(data); if (!string.IsNullOrEmpty(mailTemplate.Link)) { foreach (var email in mailTemplate.Emails) { MailHelper.Send(email, "Deneme", mailTemplate.Link); } } } catch { } }
/// <summary> /// 批量下载知识 /// </summary> /// <param name="id"></param> /// <returns></returns> public JsonResult DownloadResources(string ids) { try { var list = _resourceManager.GetListByIds(ids.GetArray()); if (list.Count > 0) { List <int> id = new List <int>(); //List<string> filePath = new List<string>(); List <KeyValuePair <string, string> > filePath = new List <KeyValuePair <string, string> >(); foreach (var item in list) { if (item.CanDownload == 1) { string tmp = Server.MapPath(item.RealName); if (System.IO.File.Exists(tmp)) { id.Add(item.ResourceId); //filePath.Add(tmp); filePath.Add(new KeyValuePair <string, string>(tmp, item.ResourceName + "." + item.ExtendName)); } } } if (id.Count == 0) { return(Json(new { result = 0, content = RetechWing.LanguageResources.KnowledgeLanguage.DownloadFailedjunbu }, JsonRequestBehavior.AllowGet)); } _resourceManager.DownloadResource(id.ToArray(), CurrentUser.UserId); _resourceManager.AddResourceCount(id.ToArray(), 4); var filename = Guid.NewGuid().ToString(); if (!Directory.Exists(Server.MapPath("/UploadFiles/tmp/"))) { Directory.CreateDirectory(Server.MapPath("/UploadFiles/tmp/")); //LogHelper.WriteLog("KnowledgeCenterController.cs 528行 创建目录:" + uploadpath); } //string zipFile = FileZipHelper.PackFiles(Server.MapPath("/UploadFiles/tmp/" + filename + ".zip"), filePath.ToArray()); FileZipHelper.PackFiles(Server.MapPath("/UploadFiles/tmp/" + filename + ".zip"), filePath); #region 积分 RetechWing.BusinessCommon.Integration.IntegrationManager.Instence.FireIntegrationEvent(RetechWing.BusinessCommon.Integration.IntegrationEvents.DownloadKnowledge, CurrentUser.UserId, CurrentTenant.TenantId); #endregion return(Json(new { result = 1, zipFile = filename }, JsonRequestBehavior.AllowGet)); } } catch { } return(Json(new { result = 0, content = RetechWing.LanguageResources.KnowledgeLanguage.DownloadFailedbeishanchu }, JsonRequestBehavior.AllowGet)); }
/// <summary> /// 获取一个考试的详情【考前须知、试卷信息】 /// </summary> /// <param name="euId"></param> /// <returns></returns> public JsonResult GetExamDetailByEuId(int euId, int dw = 0) { try { int leavePageTimes = 0; tbExamSendStudent eu = _examTestManager.GetExamUser(euId); if (eu.RemainingTime == 0 && dw == 0) { return(Json(new { result = 0, msg = "您的考试时间已用完,不可进入!" }, JsonRequestBehavior.AllowGet)); } int examTestTimes = 0; tbExamination exam = _examinationManager.GetExamination(eu.RelationID); examTestTimes = exam.TestTimes; if (exam.LeavePageTimes < eu.LeavePageTimes && dw == 0) { return(Json(new { result = 0, msg = "您离开页面的总次数已用完,不可进入!" }, JsonRequestBehavior.AllowGet)); } if (eu.TestTimes >= exam.TestTimes && dw == 0) { return(Json(new { result = 0, msg = "进入次数已达到上限,不可进入!" }, JsonRequestBehavior.AllowGet)); } if (exam.ExamEndTime.ToLocalTime() <= DateTime.Now && dw == 0) { return(Json(new { result = 0, msg = "本场考试已经结束,不可进入!" }, JsonRequestBehavior.AllowGet)); } var exambase = _examTestManager.GetExamBaseInforShow(euId, leavePageTimes); var exampaper = _examTestManager.GetExampaperBaseInforShow(euId); List <KeyValuePair <string, string> > filePath = new List <KeyValuePair <string, string> >(); foreach (var item in exampaper.QuestionList) { if (item.QType == 6) { foreach (var p in item.FileUpload) { p.fileName = "http://" + Request.Url.Authority + p._fileName; filePath.Add(new KeyValuePair <string, string>(p._fileName, p._fileName)); } } } string txtContent = Newtonsoft.Json.JsonConvert.SerializeObject(new { exambase = new { exambase.ExamRuleList, exambase.ExamEndTime, exambase.ExamStartTime, exambase.ExamLength, exambase.ExamTitle, exambase.UserRemainingTime }, exampaper = new { QuestionList = exampaper.QuestionList.Select(p => new { FileUpload = p.FileUpload.Select(f => new { fileName = f._fileName, fileType = f._fileType }), p.QAnswerType, p.QType, QuestionAnswer = p.QuestionAnswer.Select(q => new { q.AnswerContent, q.AnswerType, q.Order, q.oldOrder }), p.QuestionContent, p.QuestionID, p.QuestionOrder, p.FillBlankCount, p.UserAnswer, p.Score }) }, testTimes = examTestTimes - eu.TestTimes }); string jsonfilename = Guid.NewGuid().ToString(); string jsonfilefilepath = Server.MapPath(Url.Addr("~/UploadFiles/ExamQuestionResource/") + jsonfilename + ".json"); System.IO.File.WriteAllText(jsonfilefilepath, txtContent); filePath.Add(new KeyValuePair <string, string>(jsonfilefilepath, "data.json")); string zipFilePath = ""; long filesize = 0; if (filePath.Count > 0) { string filename = Guid.NewGuid().ToString(); if (!Directory.Exists(Server.MapPath("~/UploadFiles/tmp/"))) { Directory.CreateDirectory(Server.MapPath("~/UploadFiles/tmp/")); } FileZipHelper.PackFiles(Server.MapPath("~/UploadFiles/tmp/" + filename + ".zip"), filePath); zipFilePath = "http://" + Request.Url.Authority + Url.Addr("~/UploadFiles/tmp/") + filename + ".zip"; filesize = new System.IO.FileInfo(Server.MapPath("~/UploadFiles/tmp/" + filename + ".zip")).Length; } return(Json(new { result = 1, msg = "获取成功!", zipFilePath = zipFilePath, FileSize = filesize }, JsonRequestBehavior.AllowGet)); } catch { return(Json(new { result = 0, msg = "获取失败!" }, JsonRequestBehavior.AllowGet)); } }