Ejemplo n.º 1
0
        public ActionResult NewUpload(HttpPostedFileBase fileData, string guid, string number)
        {
            try
            {
                var files = Request.Files;
                if (files != null && files.Count > 0)
                {
                    Stream fileStream     = Request.Files[0].InputStream;
                    byte[] fileDataStream = new byte[Request.Files[0].ContentLength];
                    fileStream.Read(fileDataStream, 0, Request.Files[0].ContentLength);
                    T_Attachment entity = new T_Attachment();
                    entity.A_GUID     = Guid.NewGuid().ToString();
                    entity.FileName   = Request.Files[0].FileName;
                    entity.FileType   = Request.Files[0].ContentType;
                    entity.FR_GUID    = guid;
                    entity.FlieData   = fileDataStream;
                    entity.Number     = number;
                    entity.FileRemark = "";

                    bool rResult = new AttachmentSvc().AddAttachment(entity);
                    return(Content(rResult.ToString()));
                }
                else
                {
                    return(Content("false"));
                }
            }
            catch (Exception ex)
            {
                return(Content("false"));
            }
        }
        /// <summary>
        /// 一一删除记录的每个附件
        /// </summary>
        /// <param name="id">A_GUID纪录标识</param>
        /// <returns></returns>
        public string DelEveryAttachment(string id)
        {
            bool   result = new AttachmentSvc().DelEveryAttachment(id);
            string msg    = string.Empty;

            if (result)
            {
                msg = General.Resource.Common.Success;
            }
            else
            {
                msg = General.Resource.Common.Failed;
            }
            return(string.Format("{{\"Result\":{0},\"Msg\":\"{1}\"}}"
                                 , result.ToString().ToLower(), msg));
        }
        /// <summary>
        /// 更新附件备注
        /// </summary>
        /// <param name="attachenmt"></param>
        /// <returns></returns>
        public string UpdAttachment(T_Attachment attachenmt)
        {
            string msg    = string.Empty;
            bool   result = new AttachmentSvc().UpdAttachment(attachenmt.A_GUID, attachenmt.FileName, attachenmt.FileRemark);

            if (result)
            {
                msg = General.Resource.Common.Success;
            }
            else
            {
                msg = General.Resource.Common.Failed;
            }
            return(string.Format("{{\"Result\":{0},\"Msg\":\"{1}\"}}"
                                 , result.ToString().ToLower(), msg));
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 修改附件名称
        /// </summary>
        /// <param name=""></param>
        /// <returns></returns>
        /// <remarks>hdy   2017/03/09   create</remarks>
        public string UpdHaveFileUpload(T_Attachment form)
        {
            bool   result = false;
            string msg    = string.Empty;

            result = new AttachmentSvc().UpdHaveFileUpload(form);
            if (result)
            {
                msg = General.Resource.Common.Success;
            }
            else
            {
                msg = General.Resource.Common.Failed;
            }
            return(string.Format("{{\"Result\":{0},\"Msg\":\"{1}\"}}"
                                 , result.ToString().ToLower(), msg));
        }
Ejemplo n.º 5
0
        /// <summary>
        /// 上传图片
        /// </summary>
        /// <param name="fileData">上传文件</param>
        /// <param name="guid"></param>
        /// <param name="folder"></param>
        /// <returns></returns>
        //[AcceptVerbs(HttpVerbs.Post)]
        public ActionResult Upload(HttpPostedFileBase fileData, string guid, string folder)
        {
            DelAttachment(guid);
            if (fileData != null)
            {
                try
                {
                    ControllerContext.HttpContext.Request.ContentEncoding  = Encoding.GetEncoding("UTF-8");
                    ControllerContext.HttpContext.Response.ContentEncoding = Encoding.GetEncoding("UTF-8");
                    ControllerContext.HttpContext.Response.Charset         = "UTF-8";

                    //写入数据流
                    Stream fileStream     = fileData.InputStream;
                    byte[] fileDataStream = new byte[fileData.ContentLength];
                    fileStream.Read(fileDataStream, 0, fileData.ContentLength);
                    //写入数据
                    T_Attachment entity = new T_Attachment();
                    entity.A_GUID     = Guid.NewGuid().ToString();
                    entity.FileName   = fileData.FileName;
                    entity.FileType   = fileData.ContentType;
                    entity.FR_GUID    = guid;
                    entity.FlieData   = fileDataStream;
                    entity.FileRemark = "";


                    bool rResult = new AttachmentSvc().AddAttachment(entity);
                    return(Content(rResult.ToString()));
                }
                catch (Exception ex)
                {
                    return(Content("false"));
                }
            }
            else
            {
                return(Content("false"));
            }
        }