コード例 #1
0
        public FileStreamResult DownAnaysleFile(int id)
        {
            var info = DBContext.UploadInfo.FirstOrDefault(x => x.Id == id);

            if (info == null)
            {
                return(new FileStreamResult(null, "error"));
            }
            string absoluFilePath = GetPath(info.SaveName);

            UnionLib.AnaysleService service = new UnionLib.AnaysleService();
            string file = service.Create(absoluFilePath, GetAssistParams(id));

            var fileStream = new FileStream(file, FileMode.Open);

            return(File(fileStream, "application/octet-stream", Server.UrlEncode(file)));
        }
コード例 #2
0
        public JsonResult SendTo(int id)
        {
            Common.ResultInfo rInfo = new Common.ResultInfo();

            try
            {
                var currentInfo = DBContext.UploadInfo.FirstOrDefault(x => x.Id == id);

                if (currentInfo != null)
                {
                    string absoluFilePath = GetPath(currentInfo.SaveName);

                    UnionLib.AnaysleService service = new UnionLib.AnaysleService();
                    string file = service.Create(absoluFilePath, GetAssistParams(id));

                    var msg      = "";
                    var sendMail = new MailLib.MailHelper("smtp.163.com", 25, "*****@*****.**", "qwerty123", System.Configuration.ConfigurationManager.AppSettings["toUsers"].Split(','), "how are you", "body is xxxx", false);
                    sendMail.IsSendAttachments = true;
                    sendMail.Attachments       = new string[] { file };
                    var s = sendMail.Send(out msg);
                    if (s == MailLib.MailHelper.SendStatus.Success)
                    {
                        rInfo.IsSuccess = true;
                    }
                    else
                    {
                        rInfo.Message = msg;
                    }
                }
                else
                {
                    rInfo.Message = string.Format("没有 {0}", id);
                }
            }
            catch (Exception ex)
            {
                rInfo.Message = ex.Message;
            }

            return(Json(rInfo, JsonRequestBehavior.AllowGet));
        }