public AttachmentFile GetAttachment(int attachmentId)
        {
            AttachmentFile attachmentFile = new AttachmentFile();
            var            sqlQuery       = string.Format("SELECT * FROM {0} WHERE Id=@Id;", DatabaseHelper.AttachmentTable);

            using (var sqlConnection = new SqlConnection(DatabaseHelper.BIRequestConnectionString))
                using (var sqlCommand = new SqlCommand(sqlQuery, sqlConnection))
                {
                    sqlCommand.Parameters.AddWithValue("@Id", attachmentId);
                    sqlConnection.Open();
                    var dataReader = sqlCommand.ExecuteReader();
                    if (!dataReader.HasRows)
                    {
                        return(attachmentFile);
                    }
                    if (dataReader.Read())
                    {
                        attachmentFile.Id            = DataTransformer.ParseNullableLong(dataReader["Id"] as long?);
                        attachmentFile.RequestId     = dataReader["RequestId"] as long?;
                        attachmentFile.FileName      = dataReader["FileName"] as string;
                        attachmentFile.ContentType   = dataReader["ContentType"] as string;
                        attachmentFile.ContentLength = dataReader["ContentLength"] as long?;
                        attachmentFile.FileContent   = dataReader["FileContent"] as byte[];
                    }
                    sqlConnection.Close();
                }
            return(attachmentFile);
        }
        // Liz E - the attachment does not seem to be working properly. a link is provided int eh feedback for the attachment but the data is not there.
        //   I am seeking assistance throught he HockeyApp discussions. In the meantime, disabling this and attaching the info as part of the message if it is a text file.
        private List <IFeedbackAttachment> GetFileAttachmentList()
        {
            List <IFeedbackAttachment> attachmentList = new List <IFeedbackAttachment>();

            try
            {
                // HockeyApp allows multiple attachments. If we change Attachment file to allow a list, then this will need to be modified.
                if (!string.IsNullOrEmpty(AttachmentFile) && File.Exists(AttachmentFile))
                {
                    byte[] dataBytes   = File.ReadAllBytes(AttachmentFile);
                    string contentType = "";
                    if (AttachmentFile.EndsWith("txt") || AttachmentFile.EndsWith("log"))
                    {
                        contentType = "text/plain; charset=utf-8";
                    }
                    // if we decide to allow images for screen shot, for example
//                    else if (IsImage(AttachmentFile))
//                    {
//                        contentType = <whatever we need for image attachment>;
//                    }
                    // create IFeedbackAttachment in a list
                    IFeedbackAttachment feedbackAttachment = new HockeyApp.Model.FeedbackAttachment(AttachmentFile, dataBytes, contentType);
                    attachmentList.Add(feedbackAttachment);
                }

                return(attachmentList);
            }
            catch (Exception ex)
            {
                // we were note able to access the file data, return empty attachment list
                return(attachmentList);
            }
        }
Exemple #3
0
        private void delete_Tapped(object sender, EventArgs e)
        {
            try
            {
                var args = (TappedEventArgs)e;

                AttachmentFile t2 = args.Parameter as AttachmentFile;

                var itemToRemove = attach.Single(r => r.file_name == t2.file_name);

                attach.Remove(itemToRemove);

                attachviewlist.ItemsSource   = null;
                attachviewlist.ItemsSource   = attach;
                attachviewlist.HeightRequest = 50 * attach.Count;

                if (attach.Count == 0)
                {
                    attachviewlist.IsVisible = false;
                }
            }
            catch (Exception ex)
            {
            }
        }
        public async Task <IActionResult> delete([FromBody] AttachmentFile attachment)
        {
            var credentials = new BasicAWSCredentials(enviroment.awsAccessKeyId,
                                                      enviroment.awsSecretAccessKey);
            var config = new AmazonS3Config
            {
                RegionEndpoint = Amazon.RegionEndpoint.EUWest2
            };

            using var client = new AmazonS3Client(credentials, config);

            try
            {
                var deleteObjectRequest = new DeleteObjectRequest
                {
                    BucketName = enviroment.bucketName,
                    Key        = attachment.TaskScheduleId + "/" + attachment.FileName
                };

                Console.WriteLine("Deleting an object");
                await client.DeleteObjectAsync(deleteObjectRequest);

                //remove from the database
                _repo.Delete(attachment.Id);
            }
            catch (AmazonS3Exception e)
            {
                Console.WriteLine("Error encountered on server. Message:'{0}' when deleting an object", e.Message);
            }
            catch (Exception e)
            {
                Console.WriteLine("Unknown encountered on server. Message:'{0}' when deleting an object", e.Message);
            }
            return(Ok());
        }
        private void ShowFileSavedInPreviewController(AttachmentFile fileAtt)
        {
            QLPreviewController quickLookController = new QLPreviewController();

            quickLookController.DataSource = new PreviewControllerDataSource(fileAtt.FileName);
            NavigationController.PushViewController(quickLookController, true);
        }
Exemple #6
0
        private void AddAttachments(ApplicationDbContext db, int bookItemID, AttachmentFile file, FileType type)
        {
            string directoryPath = Path.Combine(HttpContext.Current.Server.MapPath("~/Upload"), bookItemID.ToString());

            if (!Directory.Exists(directoryPath))
            {
                Directory.CreateDirectory(directoryPath);
            }

            var fileName = file.File.FileName.Remove(file.File.FileName.LastIndexOf('.')) + "_" + bookItemID +
                           Path.GetExtension(file.File.FileName);

            var filePath = Path.Combine(directoryPath, fileName);

            Attachment at = new Attachment()
            {
                FileType    = type,
                FileName    = fileName,
                BookItemID  = bookItemID,
                Source      = filePath,
                Descryption = file.Descryption
            };

            file.File.SaveAs(filePath);
            db.Attachments.Add(at);
            db.SaveChanges();
        }
Exemple #7
0
        private void RemoveFilesFromServer()
        {
            //Show Progress
            ShowProgressDialog(true);

            Task.Run(async() =>
            {
                try
                {
                    AttachmentFile fileDelete = filesToDeleteInServer[countAttachmentsDeleted];

                    AttachmentFile response = await AysaClient.Instance.DeleteFile(fileDelete.Id);

                    RunOnUiThread(() =>
                    {
                        countAttachmentsDeleted++;

                        if (filesToDeleteInServer.Count() > countAttachmentsDeleted)
                        {
                            RemoveFilesFromServer();
                        }
                        else
                        {
                            // Finish to delete files, continue with the secuence
                            if (attachedFiles.Count > 0)
                            {
                                UploadFilesToServer();
                            }
                            else
                            {
                                UploadEventToServer();
                            }
                        }
                    });
                }
                catch (HttpUnauthorized)
                {
                    RunOnUiThread(() =>
                    {
                        ShowErrorAlert("No tiene permisos para eliminar archivos");
                    });
                }
                catch (Exception ex)
                {
                    RunOnUiThread(() =>
                    {
                        ShowErrorAlert(ex.Message);
                    });
                }
                finally
                {
                    RunOnUiThread(() =>
                    {
                        // Remove progress
                        ShowProgressDialog(false);
                    });
                }
            });
        }
 private void UpdateAttachment(AttachmentFile attachment)
 {
     File = attachment;
     buttonOpenAttachment.Enabled = buttonExportAttachment.Enabled = buttonRemoveAttachment.Enabled = attachment != null;
     this.SuspendLayout();
     UpdatePreview(AutoDetectPreviewType(File));
     this.ResumeLayout();
 }
Exemple #9
0
 // Default contructor that set entity to field
 public AttachmentFileModel(AttachmentFile attachmentfile)
 {
     this._attachment_file = attachmentfile;
     this._id        = attachmentfile.Id;
     this._name      = attachmentfile.Name;
     this._path_file = attachmentfile.PathFile;
     this._originalAttachmentFile = attachmentfile.DeepClone();
 }
        private void SaveFileInLocalFolder(NSData data, AttachmentFile documentFile)
        {
            var documents = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
            var filename  = Path.Combine(documents, documentFile.FileName);

            data.Save(filename, false);

            ShowFileSavedInPreviewController(documentFile);
        }
        private void addAttachment(AttachmentFile file)
        {
            var pdfDictionary = new PdfDictionary();

            pdfDictionary.Put(PdfName.MODDATE, new PdfDate(DateTime.Now));
            var fs = PdfFileSpecification.FileEmbedded(_writer, string.Empty, file.FileName, file.Content, true, null, pdfDictionary);

            _writer.AddFileAttachment(fs);
        }
Exemple #12
0
        public JsonResult UploadReport(long id)
        {
            long specialistId = -1;

            if (!long.TryParse(Session["SpecialistId"].ToString(), out specialistId))
            {
                return(Json(new { result = -1, msg = "Can't get specialist's profile" }, JsonRequestBehavior.AllowGet));
            }

            var can = db.Candidates.FirstOrDefault(s => s.CandidateId == id && s.SpecialistId == specialistId);

            if (can != null)
            {
                try
                {
                    //upload file and save link to candidate by id
                    HttpPostedFileBase file = Request.Files[0]; //Uploaded file
                    // Create directory to save this file
                    string filePath = Util.Helper.getRandomAlphaNumeric(10);
                    while (Directory.Exists(Server.MapPath("~/Reports/") + filePath))
                    {
                        filePath = Util.Helper.getRandomAlphaNumeric(10);
                    }
                    Directory.CreateDirectory(Server.MapPath("~/Reports/") + filePath);
                    filePath += "/" + file.FileName;;
                    //To save file, use SaveAs method
                    file.SaveAs(Server.MapPath("~/Reports/") + filePath);
                    AttachmentFile attachment = new AttachmentFile()
                    {
                        Link = Server.MapPath("~/Reports/") + filePath, CandidateId = id, FileName = file.FileName
                    };
                    db.AttachmentFiles.Add(attachment);
                    db.SaveChanges();
                    var logAction = new ActivityLog()
                    {
                        ActionTime    = DateTime.Now,
                        ActionType    = "Upload Candidate's report",
                        ActionContent = "Upload " + can.FirstName + " " + can.MiddleName + " " + can.LastName + "'s report",
                        CandidateId   = can.CandidateId,
                        SpecialistId  = specialistId,
                    };
                    db.ActivityLogs.Add(logAction);
                    db.SaveChanges();

                    return(Json(new { result = 1, msg = "Uploaded " + Request.Files.Count + " files" }, JsonRequestBehavior.AllowGet));
                }
                catch (Exception e)
                {
                    return(Json(new { rs = -1, msg = e.Message }, JsonRequestBehavior.AllowGet));
                }
            }

            return(Json(new { result = -1, msg = "Can't get candidate's information" }, JsonRequestBehavior.AllowGet));
        }
        override public void Execute()
        {
            // Signer with 1 attachment requirement
            signer = SignerBuilder.NewSignerWithEmail(email1)
                     .WithFirstName("John")
                     .WithLastName("Smith")
                     .WithCustomId(SIGNER_ID)
                     .WithAttachmentRequirement(AttachmentRequirementBuilder.NewAttachmentRequirementWithName(NAME)
                                                .WithDescription(DESCRIPTION)
                                                .IsRequiredAttachment()
                                                .Build()).Build();

            DocumentPackage superDuperPackage = PackageBuilder.NewPackageNamed(PackageName)
                                                .DescribedAs("This is a package created using the eSignLive SDK")
                                                .WithSigner(signer)
                                                .WithDocument(DocumentBuilder.NewDocumentNamed("test document")
                                                              .FromStream(fileStream1, DocumentType.PDF)
                                                              .WithSignature(SignatureBuilder.SignatureFor(email1)
                                                                             .Build())
                                                              .Build())
                                                .Build();

            packageId = OssClient.CreateAndSendPackage(superDuperPackage);

            retrievedPackage = OssClient.GetPackage(packageId);
            signerAtt        = retrievedPackage.GetSigner(email1).GetAttachmentRequirement(NAME);

            byte [] attachmentForSignerFileContent = new StreamDocumentSource(attachmentInputStream).Content();
            signerAttachmentFileSize = attachmentForSignerFileContent.Length;
            OssClient.UploadAttachment(packageId, signerAtt.Id, ATTACHMENT_FILE_NAME,
                                       attachmentForSignerFileContent, SIGNER_ID);

            retrievedPackage = OssClient.GetPackage(packageId);
            signerAtt        = retrievedPackage.GetSigner(email1).GetAttachmentRequirement(NAME);

            filesAfterUpload = signerAtt.Files;

            AttachmentFile attachmentFile = filesAfterUpload[0];

            // Download signer attachment
            DownloadedFile downloadedAttachment = ossClient.AttachmentRequirementService.DownloadAttachmentFile(packageId, signerAtt.Id, attachmentFile.Id);

            System.IO.File.WriteAllBytes(downloadedAttachment.Filename, downloadedAttachment.Contents);

            OssClient.DeleteAttachmentFile(packageId, signerAtt.Id, attachmentFile.Id, SIGNER_ID);

            retrievedPackage = OssClient.GetPackage(packageId);
            signerAtt        = retrievedPackage.GetSigner(email1).GetAttachmentRequirement(NAME);

            filesAfterDelete = signerAtt.Files;

            downloadedAttachmentFile = new FileInfo(downloadedAttachment.Filename);
        }
 private PreviewType AutoDetectPreviewType(AttachmentFile attachment)
 {
     if (attachment == null)
     {
         return(PreviewType.None);
     }
     if (attachment.Mime == "image/bmp" || attachment.Mime == "image/gif" || attachment.Mime == "image/jpeg" || attachment.Mime == "image/png")
     {
         return(PreviewType.Image);
     }
     return(PreviewType.File);
 }
Exemple #15
0
        private static Attachment UploadAttachment(RestClient client, string token, AttachmentFile file, int id)
        {
            var restRequest = new RestRequest("UploadFile.ashx" + token, Method.POST);

            restRequest.AddHeader("Content-Type", "multipart/form-data");
            restRequest.AddFile("attachment", file.Content.ToArray(), file.FileName, file.ContentType);
            restRequest.AddParameter("generalId", id);
            var response = client.Execute <Attachment>(restRequest);

            Console.WriteLine(response.StatusCode);
            Console.WriteLine(response.Content);
            return(response.Data);
        }
Exemple #16
0
        public void RemoveAttachmentSelected(AttachmentFile documentFile)
        {
            UIAlertController alert = UIAlertController.Create("Aviso", "¿Está seguro que desea quitar el Archivo?", UIAlertControllerStyle.Alert);

            alert.AddAction(UIAlertAction.Create("Cancelar", UIAlertActionStyle.Cancel, null));

            alert.AddAction(UIAlertAction.Create("Si", UIAlertActionStyle.Default, action => {
                // Delete file
                DeleteFile(documentFile);
            }));

            PresentViewController(alert, animated: true, completionHandler: null);
        }
Exemple #17
0
        private void ReadData(Cardfile file, SeekableBinaryReader reader)
        {
            uint cardCount = reader.ReadUInt32();
            uint cardIndex = reader.ReadUInt32();

            reader.Skip(20);

            if (cardIndex > cardCount)
            {
                throw new ArgumentException("Not a valid .CRDX file!");
            }
            else if (cardIndex == cardCount)
            {
                file.FrontIndex = -1;
            }

            for (int i = 0; i < cardCount; ++i)
            {
                long textOffset = reader.ReadInt64();
                long fileOffset = reader.ReadInt64();
                reader.Skip(12);
                uint indexLength = reader.ReadUInt32();

                string index       = encoding.GetString(reader.ReadBytes((int)indexLength));
                long   oldPosition = reader.Position;
                Card   newCard     = new Card(index);

                reader.Seek(textOffset, SeekOrigin.Begin);
                ulong  textLength = reader.ReadUInt64();
                byte[] buffer     = reader.ReadBytes((int)textLength);
                newCard.Contents = encoding.GetString(buffer);

                if (fileOffset >= 0)
                {
                    reader.Seek(fileOffset, SeekOrigin.Begin);
                    uint           nameLength       = reader.ReadUInt32();
                    byte[]         nameData         = reader.ReadBytes((int)nameLength);
                    uint           mimeLength       = reader.ReadUInt32();
                    byte[]         mimeData         = reader.ReadBytes((int)mimeLength);
                    ulong          attachmentLength = reader.ReadUInt64();
                    byte[]         attachmentData   = reader.ReadBytes((int)textLength);
                    AttachmentFile attachment       = new AttachmentFile(encoding.GetString(nameData), encoding.GetString(mimeData), attachmentData);
                    newCard.Attachment = attachment;
                }

                file.AddCard(newCard);
                reader.Seek(oldPosition, SeekOrigin.Begin);
            }
            file.FrontIndex = (int)cardIndex;
        }
        private void BuildFileAttachment(UIImagePickerMediaPickedEventArgs media)
        {
            string name = "";

            // Build attachment and show in view

            NSUrl referenceURL = media.Info[new NSString("UIImagePickerControllerReferenceURL")] as NSUrl;

            if (referenceURL != null)
            {
                ALAssetsLibrary assetsLibrary = new ALAssetsLibrary();
                assetsLibrary.AssetForUrl(referenceURL, delegate(ALAsset asset) {
                    ALAssetRepresentation representation = asset.DefaultRepresentation;

                    if (representation != null)
                    {
                        name = representation.Filename;
                    }

                    string nameFile = name.Length > 0 ? name : "Archivo Adjunto " + (AttachmentFilesInMemory.Count + 1).ToString();

                    AttachmentFile attachmentFile = new AttachmentFile();
                    attachmentFile.FileName       = nameFile;
                    attachmentFile.Private        = privateFile;

                    // Get image and convert to BytesArray
                    UIImage originalImage = media.Info[UIImagePickerController.OriginalImage] as UIImage;

                    if (originalImage != null)
                    {
                        string extension = referenceURL.PathExtension;

                        using (NSData imageData = originalImage.AsJPEG(0.5f))
                        {
                            Byte[] fileByteArray = new Byte[imageData.Length];
                            Marshal.Copy(imageData.Bytes, fileByteArray, 0, Convert.ToInt32(imageData.Length));
                            attachmentFile.BytesArray = fileByteArray;
                        }
                    }


                    AttachmentFilesInMemory.Add(attachmentFile);

                    // Show file selected in view
                    LoadAttachmentsOfEvent();
                }, delegate(NSError error) {
                    return;
                });
            }
        }
Exemple #19
0
 private void DeleteFile(AttachmentFile documentFile)
 {
     // Delete file from server if it's necessary
     // If the file has id that means that it was upload to the server, so it's needed to remove
     if (documentFile.Id != null)
     {
         // Call WS to remove file in server
         RemoveFileFromServer(documentFile);
     }
     else
     {
         // It's not necessary remove file in the server, so only remove in view
         RemoveFileFromView(documentFile);
     }
 }
        public void Update(AttachmentFile attachmentFile)
        {
            // get id that matches fileName and taskscheduleId
            var AttachmentFilesDb = _context.AttachmentFiles
                                    .Where(f => f.FileName == attachmentFile.FileName)
                                    .Where(f => f.TaskScheduleId == attachmentFile.TaskScheduleId)
                                    .Select(t => t.Id)
                                    .ToList();

            //use the id to find it in the database then update the values
            var AttachmentFileDb = _context.AttachmentFiles.SingleOrDefault(s => s.Id == AttachmentFilesDb[0]);

            AttachmentFileDb.UserId = attachmentFile.UserId;

            _context.SaveChanges();
        }
        public void LoadAttachmentFileInView(AttachmentFile file, bool readOnly)
        {
            this.File = file;

            NameFileLabel.Text = file.FileName;

            if (file.Private)
            {
                IconImageView.Image = UIImage.FromBundle("lock");
            }

            if (readOnly)
            {
                ConfigViewForReadOnly();
            }
        }
        protected override void OnActivityResult(int requestCode, Result resultCode, Intent data)
        {
            if ((requestCode == PickImageId) && (resultCode == Result.Ok) && (data != null))
            {
                Android.Net.Uri uri      = data.Data;
                string          filename = GetFileName(uri);
                AttachmentFile  file     = new AttachmentFile(filename);

                Byte[] fileByteArray = ConvertUriToByteArray(uri, filename);
                file.BytesArray = fileByteArray;

                attachedFiles.Add(file);

                addAttachedFile(filename);
            }
        }
Exemple #23
0
        private void DeleteFile(AttachmentFile documentFile, int filePosition)
        {
            // Delete file from server if it's necessary
            // If the file has id that means that it was upload to the server, so it's needed to remove
            if (documentFile.Id != null)
            {
                filesToDeleteInServer.Add(documentFile);

                // Call WS to remove file in server
                //RemoveFileFromServer(documentFile, filePosition);
            }

            // Remove file in view
            attachedFiles.RemoveAt(filePosition);

            filesContainer.RemoveViewAt(filePosition);
        }
Exemple #24
0
 internal bool TryExportAttachment()
 {
     if (State.File.FrontCard.Attachment != null)
     {
         AttachmentFile attachment = State.File.FrontCard.Attachment;
         string         ext        = Path.GetExtension(attachment.Name);
         if (ext != "")
         {
             exportAttachmentDialog.Filter = string.Format(
                 Language.Get("ExportAttachmentFilter", "{1} (*.{0})|*.{0}|All files (*.*)|*"),
                 ext,
                 Win32Util.GetFileDescription(ext) ?? string.Format(Language.Get("UnknownExtension", "{0} File"), ext));
         }
         else
         {
             exportAttachmentDialog.Filter = Language.Get("ExportAttachmentFilterNoExt", "All files (*.*)|*");
         }
         exportAttachmentDialog.FileName = attachment.Name;
         DialogResult result = exportAttachmentDialog.ShowDialog();
         if (result == DialogResult.OK)
         {
             string filePath = exportAttachmentDialog.FileName;
             try
             {
                 UseWaitCursor = true;
                 File.WriteAllBytes(filePath, attachment.Data);
             }
             catch (IOException)
             {
                 MessageBox.Show(
                     this,
                     Language.Get("CannotExportAttachment", "An error occurred while exporting the attachment. Make sure the file is not read-only and that you have sufficient disk space."),
                     this.ProgramName,
                     MessageBoxButtons.OK,
                     MessageBoxIcon.Hand);
             }
             finally
             {
                 UseWaitCursor = false;
             }
             return(true);
         }
         return(false);
     }
     return(false);
 }
        /// <summary>
        /// This method saves note.
        /// </summary>
        /// <returns></returns>
        public async System.Threading.Tasks.Task SaveNote()
        {
            progressRing.IsActive = true;

            // Instantiate note
            Annotation annotation = new Annotation();

            // Set regarding
            annotation.ObjectId = new EntityReference(EntityMetadataEx.EntityMetadata.LogicalName, Id);
            annotation.Subject  = txtTitle.Text;
            annotation.NoteText = txtNoteText.Text;

            // If there is an attachment file, then handle it.
            if (AttachmentFile != null)
            {
                annotation.FileName = AttachmentFile.Name;

                IRandomAccessStreamWithContentType fileStream = await AttachmentFile.OpenReadAsync();

                byte[] fileBytes = null;
                fileBytes = new byte[fileStream.Size];
                using (DataReader reader = new DataReader(fileStream))
                {
                    await reader.LoadAsync((uint)fileStream.Size);

                    reader.ReadBytes(fileBytes);
                }
                annotation.DocumentBody = Convert.ToBase64String(fileBytes);
            }
            if (!String.IsNullOrEmpty(txtId.Text))
            {
                annotation.Id = Guid.Parse(txtId.Text);
            }

            // Create a note
            await CRMHelper.UpsertRecord(annotation);

            // Reverse the control visibility
            lvList.Visibility = Visibility.Visible;
            spNote.Visibility = Visibility.Collapsed;

            // Reload data
            await LoadData();

            progressRing.IsActive = false;
        }
Exemple #26
0
        override public void Execute()
        {
            // Signer1 with 1 attachment requirement
            signer1 = SignerBuilder.NewSignerWithEmail(email1)
                      .WithFirstName("John")
                      .WithLastName("Smith")
                      .WithCustomId(SIGNER1_ID)
                      .WithAttachmentRequirement(AttachmentRequirementBuilder.NewAttachmentRequirementWithName(NAME1)
                                                 .WithDescription(DESCRIPTION1)
                                                 .IsRequiredAttachment()
                                                 .Build()).Build();

            DocumentPackage superDuperPackage = PackageBuilder.NewPackageNamed(PackageName)
                                                .DescribedAs("This is a package created using the eSignLive SDK")
                                                .WithSigner(signer1)
                                                .WithDocument(DocumentBuilder.NewDocumentNamed("test document")
                                                              .FromStream(fileStream1, DocumentType.PDF)
                                                              .WithSignature(SignatureBuilder.SignatureFor(email1)
                                                                             .Build())
                                                              .Build())
                                                .Build();

            packageId = OssClient.CreateAndSendPackage(superDuperPackage);

            retrievedPackage = OssClient.GetPackage(packageId);
            signer1Att1      = retrievedPackage.GetSigner(email1).GetAttachmentRequirement(NAME1);

            byte [] attachment1ForSigner1FileContent = new StreamDocumentSource(attachmentInputStream1).Content();
            OssClient.UploadAttachment(packageId, signer1Att1.Id, ATTACHMENT_FILE_NAME1,
                                       attachment1ForSigner1FileContent, SIGNER1_ID);

            retrievedPackage = OssClient.GetPackage(packageId);
            signer1Att1      = retrievedPackage.GetSigner(email1).GetAttachmentRequirement(NAME1);

            filesAfterUpload = signer1Att1.Files;

            AttachmentFile attachmentFile = filesAfterUpload[0];

            OssClient.DeleteAttachmentFile(packageId, signer1Att1.Id, attachmentFile.Id, SIGNER1_ID);

            retrievedPackage = OssClient.GetPackage(packageId);
            signer1Att1      = retrievedPackage.GetSigner(email1).GetAttachmentRequirement(NAME1);

            filesAfterDelete = signer1Att1.Files;
        }
        private void DownloadFileToShowIt(AttachmentFile documentFile)
        {
            // Display an Activity Indicator in the status bar
            UIApplication.SharedApplication.NetworkActivityIndicatorVisible = true;

            Task.Run(async() =>
            {
                try
                {
                    // Download file from server
                    byte[] bytesArray = await AysaClient.Instance.GetFile(documentFile.Id);
                    //var text = System.Text.Encoding.Default.GetString(bytesArray);
                    //text = text.Replace("\"", "");
                    //bytesArray = Convert.FromBase64String(text);


                    InvokeOnMainThread(() =>
                    {
                        NSData data = NSData.FromArray(bytesArray);

                        SaveFileInLocalFolder(data, documentFile);
                    });
                }
                catch (HttpUnauthorized)
                {
                    InvokeOnMainThread(() =>
                    {
                        ShowSessionExpiredError();
                    });
                }
                catch (Exception ex)
                {
                    InvokeOnMainThread(() =>
                    {
                        ShowErrorAlert(ex.Message);
                    });
                }
                finally
                {
                    // Dismiss an Activity Indicator in the status bar
                    UIApplication.SharedApplication.NetworkActivityIndicatorVisible = false;
                }
            });
        }
Exemple #28
0
            public async Task <CommandResponse> Handle(Command message, CancellationToken cancellationToken)
            {
                var result = new CommandResponse();

                using (var scope = _scopeFactory.Create())
                {
                    var context = scope.DbContexts.Get <MainContext>();

                    var att = new AttachmentFile();
                    Mapper.Map(message, att);
                    att.Id       = Guid.NewGuid();
                    att.ParentId = message.ParentId;
                    context.Set <AttachmentFile>().Add(att);

                    scope.SaveChanges();
                }

                return(await Task.FromResult(result));
            }
Exemple #29
0
 private bool TryParseOleAttachment(OleObject obj, ref AttachmentFile attachment)
 {
     if (obj.ClassString == "SoundRec")
     {
         attachment = new AttachmentFile("SOUND.WAV", "audio/wav", obj.StaticData);
         return(true);
     }
     if (obj.ClassString == "PBrush")
     {
         attachment = new AttachmentFile("IMAGE.BMP", "image/bmp", obj.StaticData);
         return(true);
     }
     if (obj.ClassString == "Package")
     {
         attachment = new AttachmentFile("PACKAGE.OLE", "application/octet-stream", obj.StaticData);
         return(true);
     }
     return(false);
 }
Exemple #30
0
        private void DownloadFileToShowIt(AttachmentFile documentFile)
        {
            ShowProgress(true);

            Task.Run(async() =>
            {
                try
                {
                    byte[] bytesArray = await AysaClient.Instance.GetFile(documentFile.Id);

                    //var text = System.Text.Encoding.Default.GetString(bytesArray);
                    //text = text.Replace("\"", "");
                    //bytesArray = Convert.FromBase64String(text);

                    RunOnUiThread(() =>
                    {
                        SaveDocumentInTemporaryFolder(documentFile.FileName, bytesArray);
                    });
                }
                catch (HttpUnauthorized)
                {
                    RunOnUiThread(() =>
                    {
                        ShowSessionExpiredError();
                    });
                }
                catch (Exception ex)
                {
                    RunOnUiThread(() =>
                    {
                        ShowErrorAlert(ex.Message);
                    });
                }
                finally
                {
                    RunOnUiThread(() =>
                    {
                        ShowProgress(false);
                    });
                }
            });
        }