Example #1
0
 async private void UploadFile(DTO_ClaimDocument documentUploadRequest)
 {
     //intended to use after display and local save of changes to upload finalized document to server for keeping
     await s1.AddClaimDocument(documentUploadRequest);
 }
Example #2
0
        async private void UploadImage(string filepathtoupload = null)
        {
            var fileDialog = new System.Windows.Forms.OpenFileDialog();
            var result     = System.Windows.Forms.DialogResult.OK;

            if (filepathtoupload == null)
            {
                result = fileDialog.ShowDialog();
            }
            else
            {
            }
            switch (result)
            {
            case System.Windows.Forms.DialogResult.OK:
                if (filepathtoupload == null)
                {
                    FullFilePath = fileDialog.FileName;
                }
                else
                {
                    FullFilePath = filepathtoupload;
                }
                var file = FullFilePath;
                TextFile.Text    = file;
                TextFile.ToolTip = file;
                var onlyFileName = System.IO.Path.GetFileNameWithoutExtension(file);
                if (AvailableDocuments.SelectedItem.ToString() == string.Empty || AvailableDocuments.SelectedItem.ToString() == null)
                {
                    onlyFileName = AvailableDocuments.SelectedItem.ToString();
                }
                onlyFileName = onlyFileName.Replace(" ", "_");
                byte[]            imageBytes            = System.IO.File.ReadAllBytes(file);
                string            ext                   = System.IO.Path.GetExtension(file);
                DTO_ClaimDocument documentUploadRequest = new DTO_ClaimDocument
                {
                    FileBytes    = Convert.ToBase64String(imageBytes),
                    FileName     = onlyFileName,
                    FileExt      = ext,
                    ClaimID      = int.Parse(ClaimList.Text),
                    DocTypeID    = AvailableDocuments.SelectedIndex,
                    DocumentDate = DateTime.Today
                };
                await s1.AddClaimDocument(documentUploadRequest);

                //SAVING FILES TO DISK
                //string filename = fileDialog.FileName = @"newfile" + ext;
                //using (SaveFileDialog saveFileDialog1 = new SaveFileDialog())
                //{
                //    saveFileDialog1.FileName = filename;
                //    if (System.Windows.Forms.DialogResult.OK != saveFileDialog1.ShowDialog())
                //        return;
                //    System.IO.File.WriteAllBytes(saveFileDialog1.FileName,Convert.FromBase64String(s1.ClaimDocument.FileBytes));
                //}
                break;

            case System.Windows.Forms.DialogResult.Cancel:
            default:
                TextFile.Text    = null;
                TextFile.ToolTip = null;
                break;
            }
        }