Esempio n. 1
0
 public Attachment SaveAttachment(Attachment attachment)
 {
     using (var cnn = DataDb.DbConnection())
     {
         if (attachment.AttachmentId == null || attachment.AttachmentId <= 0)
         {
             attachment.AttachmentId = cnn.Query<int>(attachment.GetSqliteInsertSql(InsertIgnore), attachment).FirstOrDefault();
             return attachment;
         }
         else
         {
             cnn.Execute(attachment.GetUpdateSql(KeyFiled, UpdateIgnore), attachment);
             return attachment;
         }
     }
 }
Esempio n. 2
0
        public Attachment SaveAttachment(Attachment attachment)
        {
            var existAttachment = GetAttachmentById(attachment.AttachmentId ?? 0);
            if (existAttachment != null)
            {
                attachment.Version = existAttachment.Version + 1;
                attachment.AttachmentId = existAttachment.AttachmentId;
                attachment.FileName = existAttachment.FileName;
            }
            else
            {
                attachment.Version = 0;
            }

            return AttachmentData.SaveAttachment(attachment);
        }
Esempio n. 3
0
 public Attachment SaveAttachment(int contentLength, string contentType, string fileName)
 {
     var existAttachment = GetAttachmentByName(fileName);
     if (existAttachment != null)
     {
         existAttachment.Version++;
         existAttachment.Size = contentLength;
         existAttachment.ContentType = contentType;
         existAttachment.Type = GetExtention(fileName);
         return AttachmentData.SaveAttachment(existAttachment);
     }
     else
     {
         Attachment attachment = new Attachment();
         attachment.OriginName = fileName;
         attachment.Type = GetExtention(fileName);
         attachment.FileName = GenerateFileName();
         attachment.ContentType = contentType;
         attachment.Size = contentLength;
         attachment.Version = 0;
         if (!string.IsNullOrEmpty(attachment.Type))
         {
             attachment.Alt = fileName.Substring(0, fileName.LastIndexOf('.'));
         }
         attachment.Path = IsImage(attachment.Type) ? ImagePath : OtherTypePath;
         return AttachmentData.SaveAttachment(attachment);
     }
 }
Esempio n. 4
0
 public Attachment SaveAttachment(Attachment attachment)
 {
     return AttachmentManager.SaveAttachment(attachment);
 }