partial void DeleteAttachment(Attachment instance);
 partial void InsertAttachment(Attachment instance);
 partial void UpdateAttachment(Attachment instance);
        /// <summary>
        /// 上传文件
        /// </summary>
        /// <param name="files">文件列表</param>
        /// <param name="masterNR">附主号</param>
        /// <returns>上传信息</returns>
        public Message FileUpLoad(FileUP[] files,string masterNR)
        {
            try
            {
                if (files != null && files.Length > 0)
                {
                    using (IUnitOfWork unitwork = MSSqlHelper.DataContext())
                    {
                        string p = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, Settings.Default.FileAttachmentPath);
                        if (!Directory.Exists(p))
                        {
                            Directory.CreateDirectory(p);
                        }
                        List<Attachment> reportAttaches = new List<Attachment>();
                        string type = string.Empty;
                        const int bufferLength = 4096;

                        foreach (FileUP file in files)
                        {
                            // type = file.Name.Substring(file.Name.LastIndexOf('.'), file.Name.Length - file.Name.LastIndexOf('.'));
                            string servername = GuidUtil.GenerateGUID().ToString() + file.FileType;

                            string filePath = Path.Combine(p, servername);

                            using (FileStream fs = new FileStream(filePath, FileMode.Create, FileAccess.Write, FileShare.Read))
                            {
                                using (Stream stream = new MemoryStream(file.Data))
                                {
                                    byte[] buffer = new byte[bufferLength];
                                    int readcount = 0;
                                    do
                                    {
                                        readcount = stream.Read(buffer, 0, bufferLength);
                                        if (readcount > 0)
                                        {
                                            fs.Write(buffer, 0, readcount);
                                        }
                                    } while (readcount > 0);
                                }
                            }

                            Attachment attachment = new Attachment()
                            {
                                MasterNR = masterNR,
                                Name = file.Name,
                                Path = servername,
                                Date = DateTime.Now
                            };
                            reportAttaches.Add(attachment);
                        }

                        IAttachmentRepository attachRep = new AttachmentRepository(unitwork);
                        attachRep.Add(reportAttaches);
                        unitwork.Submit();

                        return new Message() { MsgType = MsgType.OK, Content = "文件上传成功!" };
                    }
                }
                return new Message() { MsgType = MsgType.Warn, Content = "文件为空!" };
            }
            catch(Exception ex)
            {
                LogUtil.log.Error(ex.ToString());
                return new Message() { MsgType = MsgType.Error, Content = "请核实所填数据的准确性" };
            }
        }