Exemplo n.º 1
0
 public FileItem(string dir, CuteWebUI.AttachmentItem item)
 {
     _dir = dir;
     _guid = item.FileGuid;
     _name = item.FileName;
     _size = item.FileSize;
     _tempname = item.GetTempFilePath();
 }
 /// <summary>
 /// Save the picture in the database
 /// </summary>
 /// <param name="file">File uploaded by the user</param>
 /// <param name="userName">User name logged in the application</param>
 /// <param name="serviceOrderReportId">Service order identifier related</param>
 /// <param name="inspectionReportItemId">Id of inspections report item</param>
 public static void UploadPicture(CuteWebUI.MvcUploadFile file, Guid serviceOrderReportId, string userName, Guid? inspectionReportItemId = null)
 {
     //Add the file to DB along with metadata
     using (VestalisEntities context = new VestalisEntities())
     {
         //Create a new picture
         Picture picture = new Picture();
         picture.PictureId = Guid.NewGuid();
         picture.ServiceOrderId = serviceOrderReportId;
         if (inspectionReportItemId.HasValue)
             picture.InspectionReportItemId = inspectionReportItemId;
         //Copy document to entity
         using (Stream fileStream = file.OpenStream())
         {
             byte[] buffer = new byte[fileStream.Length];
             fileStream.Position = 0;
             fileStream.Read(buffer, 0, (int)fileStream.Length);
             picture.PictureFile = buffer;
             //Resize the thumbnail picture
             Image imageInput = Image.FromStream(fileStream);
             Image thumbnailImage = ResizeImage(imageInput, new Size(200, 200));
             ImageConverter converter = new ImageConverter();
             byte[] byteArrayThumb = (byte[])converter.ConvertTo(thumbnailImage, typeof(byte[]));
             //Set the thumbnail image to save in the database
             picture.PictureFileThumbnail = byteArrayThumb;
         }
         picture.CreationBy = userName;
         picture.CreationDate = DateTime.UtcNow;
         context.Pictures.AddObject(picture);
         //Save the new picture
         context.SaveChanges();
     }
 }
        /// <summary>
        /// Save the picture in the database
        /// </summary>
        /// <param name="file">File uploaded by the user</param>
        /// <param name="userName">User name logged in the application</param>
        /// <param name="serviceOrderReportId">Service order identifier related</param>
        public static void UploadDocument(CuteWebUI.MvcUploadFile file, Guid serviceOrderReportId, string userName)
        {
            //Add the file to DB along with metadata
            using (VestalisEntities context = new VestalisEntities())
            {
                //Create a new picture
                Picture picture = new Picture();
                picture.PictureId = Guid.NewGuid();
                picture.ServiceOrderId = serviceOrderReportId;
                //Copy the document to the entity
                using (Stream fileStream = file.OpenStream())
                {
                    byte[] buffer = new byte[fileStream.Length];
                    fileStream.Position = 0;
                    fileStream.Read(buffer, 0, (int)fileStream.Length);
                    picture.PictureFile = buffer;

                }
                picture.CreationBy = userName;
                picture.CreationDate = DateTime.UtcNow;
                context.Pictures.AddObject(picture);
                context.SaveChanges();
            }
        }
        /// <summary>
        /// Save a new or existing catalogue in the database
        /// </summary>
        /// <param name="file">File to be saved in the document</param>
        /// <param name="documentId">Document identifier</param>
        /// <param name="description">Document description</param>
        /// <param name="userName">Name of logged user</param>
        /// <param name="serviceOrderId">Service order idenfier</param>
        public static void SaveDocument(CuteWebUI.MvcUploadFile file, Guid? documentId, string description, string userName, Guid serviceOrderId)
        {
            Document documentNewEdit = null;
            using (VestalisEntities context = new VestalisEntities())
            {
                //if the entity don't have a catalogue id, the system will perform insert operation
                //otherwise, the system will perform edit operation
                if (documentId == Guid.Empty)
                {
                    documentNewEdit = new Document();
                    documentNewEdit.DocumentId = Guid.NewGuid();
                    documentNewEdit.ServiceOrderId = serviceOrderId;
                    //set auditory fields
                    documentNewEdit.CreationBy = userName;
                    documentNewEdit.CreationDate = DateTime.UtcNow;
                    documentNewEdit.DocumentDescription = description;
                    documentNewEdit.DocumentName = file.FileName;
                    //Copy the document to the entity
                    using (Stream fileStream = file.OpenStream())
                    {
                        byte[] buffer = new byte[fileStream.Length];
                        fileStream.Position = 0;
                        fileStream.Read(buffer, 0, (int)fileStream.Length);
                        documentNewEdit.DocumentFile = buffer;

                    }
                    context.Documents.AddObject(documentNewEdit);
                }
                else
                {
                    //get the current catalogue to edit
                    documentNewEdit = context.Documents
                    .FirstOrDefault(data => data.IsDeleted == false && data.DocumentId == documentId);

                    //set the description entered by the user
                    documentNewEdit.DocumentDescription = description;
                    //set auditory fields
                    documentNewEdit.ModificationBy = userName;
                    documentNewEdit.ModificationDate = DateTime.UtcNow;
                }

                //save changes
                context.SaveChanges();
            }
        }
Exemplo n.º 5
0
 protected void UploadAttachments1_UploadCompleted(object sender, CuteWebUI.UploaderEventArgs[] args)
 {
     DisplayImages();
 }
Exemplo n.º 6
0
    protected void Uploader_FileUploaded(object sender, CuteWebUI.UploaderEventArgs args)
    {
        

       // InsertMsg("File uploaded! " & args.FileName & ", " + args.FileSize.ToString() & " bytes.");
    }
Exemplo n.º 7
0
    protected void Uploader1_UploadCompleted(object sender, CuteWebUI.UploaderEventArgs[] args)
    {

    }