コード例 #1
0
        private void SaveToImageFolder(string fileSourcePath, LetterMerge letterCur)
        {
            if (letterCur.ImageFolder == 0)           //This shouldn't happen
            {
                return;
            }
            string rawBase64 = "";

            if (PrefC.AtoZfolderUsed == DataStorageType.InDatabase)
            {
                rawBase64 = Convert.ToBase64String(File.ReadAllBytes(fileSourcePath));
            }
            Document docSave = new Document();

            docSave.DocNum = Documents.Insert(docSave);
            string fileName     = Lans.g(this, "LetterMerge") + "_" + letterCur.Description + docSave.DocNum;
            string fileDestPath = FileAtoZ.CombinePaths(ImageStore.GetPatientFolder(PatCur, ImageStore.GetPreferredAtoZpath()), fileName + ".doc");

            docSave.ImgType     = ImageType.Document;
            docSave.DateCreated = DateTime.Now;
            docSave.PatNum      = PatCur.PatNum;
            docSave.DocCategory = letterCur.ImageFolder;
            docSave.Description = fileName;          //no extension.
            docSave.RawBase64   = rawBase64;         //blank if using AtoZfolder
            docSave.FileName    = fileName + ".doc"; //file extension used for both DB images and AtoZ images
            FileAtoZ.Copy(fileSourcePath, fileDestPath, FileAtoZSourceDestination.LocalToAtoZ);
            Documents.Update(docSave);
        }
コード例 #2
0
ファイル: FormLetterMerges.cs プロジェクト: royedwards/DRDNet
        private Document SaveToImageFolder(string fileSourcePath, LetterMerge letterCur)
        {
            if (letterCur.ImageFolder == 0)           //This shouldn't happen
            {
                return(new Document());
            }
            string rawBase64 = "";

            if (PrefC.AtoZfolderUsed == DataStorageType.InDatabase)
            {
                rawBase64 = Convert.ToBase64String(File.ReadAllBytes(fileSourcePath));
            }
            Document docSave = new Document();

            docSave.DocNum      = Documents.Insert(docSave);
            docSave.ImgType     = ImageType.Document;
            docSave.DateCreated = DateTime.Now;
            docSave.PatNum      = PatCur.PatNum;
            docSave.DocCategory = letterCur.ImageFolder;
            docSave.Description = letterCur.Description + docSave.DocNum; //no extension.
            docSave.RawBase64   = rawBase64;                              //blank if using AtoZfolder
            docSave.FileName    = ODFileUtils.CleanFileName(letterCur.Description) + GetFileExtensionForWordDoc(fileSourcePath);
            string fileDestPath = ImageStore.GetFilePath(docSave, ImageStore.GetPatientFolder(PatCur, ImageStore.GetPreferredAtoZpath()));

            FileAtoZ.Copy(fileSourcePath, fileDestPath, FileAtoZSourceDestination.LocalToAtoZ);
            Documents.Update(docSave);
            return(docSave);
        }
コード例 #3
0
		public void FillAttachments() {
			_listEmailAttachDisplayed=new List<EmailAttach>();
			if(!_isComposing) {
				SetSig(null);
			}
			gridAttachments.BeginUpdate();
			gridAttachments.ListGridRows.Clear();
			gridAttachments.ListGridColumns.Clear();
			gridAttachments.ListGridColumns.Add(new OpenDental.UI.GridColumn("",0));//No name column, since there is only one column.
			for(int i=0;i<_emailMessage.Attachments.Count;i++) {
				if(_emailMessage.Attachments[i].DisplayedFileName.ToLower()=="smime.p7s") {
					if(!_isComposing) {
						string smimeP7sFilePath=FileAtoZ.CombinePaths(EmailAttaches.GetAttachPath(),_emailMessage.Attachments[i].ActualFileName);
						string localFile=PrefC.GetRandomTempFile(".p7s");
						FileAtoZ.Copy(smimeP7sFilePath,localFile,FileAtoZSourceDestination.AtoZToLocal,doOverwrite:true);
						SetSig(EmailMessages.GetEmailSignatureFromSmimeP7sFile(localFile));
					}
					//Do not display email signatures in the attachment list, because "smime.p7s" has no meaning to a user
					//Also, Windows will install the smime.p7s into an useless place in the Windows certificate store.
					continue;
				}
				OpenDental.UI.GridRow row=new UI.GridRow();
				row.Cells.Add(_emailMessage.Attachments[i].DisplayedFileName);
				gridAttachments.ListGridRows.Add(row);
				_listEmailAttachDisplayed.Add(_emailMessage.Attachments[i]);
			}
			gridAttachments.EndUpdate();
			if(gridAttachments.ListGridRows.Count>0) {
				gridAttachments.SetSelected(0,true);
			}
		}
コード例 #4
0
        private void butSavePDFToImages_Click(object sender, EventArgs e)
        {
            if (gridMain.ListGridRows.Count == 0)
            {
                MsgBox.Show(this, "Grid is empty.");
                return;
            }
            //Get image category to save to. First image "Statement(S)" category.
            List <Def> listImageCatDefs = Defs.GetDefsForCategory(DefCat.ImageCats, true).Where(x => x.ItemValue.Contains("S")).ToList();

            if (listImageCatDefs.IsNullOrEmpty())
            {
                MsgBox.Show(this, "No image category set for Statements.");
                return;
            }
            string tempFile = PrefC.GetRandomTempFile(".pdf");

            CreatePDF(tempFile);
            Patient patCur    = _fam.GetPatient(PatNum);
            string  rawBase64 = "";

            if (PrefC.AtoZfolderUsed == DataStorageType.InDatabase)
            {
                rawBase64 = Convert.ToBase64String(File.ReadAllBytes(tempFile));
            }
            Document docSave = new Document();

            docSave.DocNum      = Documents.Insert(docSave);
            docSave.ImgType     = ImageType.Document;
            docSave.DateCreated = DateTime.Now;
            docSave.PatNum      = PatNum;
            docSave.DocCategory = listImageCatDefs.FirstOrDefault().DefNum;
            docSave.Description = $"ServiceDateView" + docSave.DocNum + $"{docSave.DateCreated.Year}_{docSave.DateCreated.Month}_{docSave.DateCreated.Day}";
            docSave.RawBase64   = rawBase64;        //blank if using AtoZfolder
            string fileName = ODFileUtils.CleanFileName(docSave.Description);
            string filePath = ImageStore.GetPatientFolder(patCur, ImageStore.GetPreferredAtoZpath());

            while (FileAtoZ.Exists(FileAtoZ.CombinePaths(filePath, fileName + ".pdf")))
            {
                fileName += "x";
            }
            FileAtoZ.Copy(tempFile, ODFileUtils.CombinePaths(filePath, fileName + ".pdf"), FileAtoZSourceDestination.LocalToAtoZ);
            docSave.FileName = fileName + ".pdf";        //file extension used for both DB images and AtoZ images
            Documents.Update(docSave);
            try {
                File.Delete(tempFile);                 //cleanup the temp file.
            }
            catch (Exception ex) {
                ex.DoNothing();
            }
            MsgBox.Show(this, "PDF saved successfully.");
        }
コード例 #5
0
        private void butImport_Click(object sender, EventArgs e)
        {
            OpenFileDialog dlg = new OpenFileDialog();

            dlg.Multiselect      = true;
            dlg.InitialDirectory = "";
            if (dlg.ShowDialog() != DialogResult.OK)
            {
                return;
            }
            foreach (string fileName in dlg.FileNames)
            {
                FileAtoZ.Copy(fileName, FileAtoZ.CombinePaths(textPath.Text, Path.GetFileName(fileName)), FileAtoZSourceDestination.LocalToAtoZ);
            }
            FillGrid();
        }
コード例 #6
0
        private void butImport_Click(object sender, EventArgs e)
        {
            OpenFileDialog openFD = new OpenFileDialog();

            openFD.Multiselect = true;
            if (openFD.ShowDialog() != DialogResult.OK)
            {
                return;
            }
            Invalidate();
            foreach (string fileName in openFD.FileNames)
            {
                //check file types?
                string destinationPath = FileAtoZ.CombinePaths(_imageFolder, Path.GetFileName(fileName));
                if (FileAtoZ.Exists(destinationPath))
                {
                    switch (MessageBox.Show(Lan.g(this, "Overwrite Existing File") + ": " + destinationPath, "", MessageBoxButtons.YesNoCancel))
                    {
                    case DialogResult.No:                            //rename, do not overwrite
                        InputBox ip = new InputBox(Lan.g(this, "New file name."));
                        ip.textResult.Text = Path.GetFileName(fileName);
                        ip.ShowDialog();
                        if (ip.DialogResult != DialogResult.OK)
                        {
                            continue;                                    //cancel, next file.
                        }
                        bool cancel = false;
                        while (!cancel && FileAtoZ.Exists(FileAtoZ.CombinePaths(_imageFolder, ip.textResult.Text)))
                        {
                            MsgBox.Show(this, "File name already exists.");
                            if (ip.ShowDialog() != DialogResult.OK)
                            {
                                cancel = true;
                            }
                        }
                        if (cancel)
                        {
                            continue;                                    //cancel rename, and go to next file.
                        }
                        destinationPath = FileAtoZ.CombinePaths(_imageFolder, ip.textResult.Text);
                        break;                                //proceed to save file.

                    case DialogResult.Yes:                    //overwrite
                        try {
                            FileAtoZ.Delete(destinationPath);
                        }
                        catch (Exception ex) {
                            MessageBox.Show(Lan.g(this, "Cannot copy file") + ":" + fileName + "\r\n" + ex.Message);
                            continue;
                        }
                        break;                          //file deleted, proceed to save.

                    default:                            //cancel
                        continue;                       //skip this file.
                    }
                }
                FileAtoZ.Copy(fileName, destinationPath, FileAtoZSourceDestination.LocalToAtoZ);
            }
            FillGrid();
            if (openFD.FileNames.Length == 1)           //if importing exactly one image, select it upon returning.
            {
                textSearch.Text = Path.GetFileName(openFD.FileNames[0]);
            }
        }
コード例 #7
0
ファイル: EmailAttachL.cs プロジェクト: kjb7749/testImport
        ///<summary>Allow the user to pick the files to be attached. The 'pat' argument can be null. If the user cancels at any step, the return value
        ///will be an empty list.</summary>
        public static List <EmailAttach> PickAttachments(Patient pat)
        {
            List <EmailAttach> listAttaches = new List <EmailAttach>();
            OpenFileDialog     dlg          = new OpenFileDialog();

            dlg.Multiselect = true;
            bool          isLocalFileSelected = false;
            List <string> listFileNames;

            if (pat != null && PrefC.AtoZfolderUsed != DataStorageType.InDatabase)
            {
                string patFolder = ImageStore.GetPatientFolder(pat, ImageStore.GetPreferredAtoZpath());
                if (CloudStorage.IsCloudStorage)
                {
                    FormFilePicker FormFP = new FormFilePicker(patFolder);
                    if (FormFP.ShowDialog() != DialogResult.OK)
                    {
                        return(listAttaches);
                    }
                    isLocalFileSelected = FormFP.WasLocalFileSelected;
                    listFileNames       = FormFP.SelectedFiles;
                }
                else
                {
                    dlg.InitialDirectory = patFolder;
                    if (dlg.ShowDialog() != DialogResult.OK)
                    {
                        return(listAttaches);
                    }
                    isLocalFileSelected = true;
                    listFileNames       = dlg.FileNames.ToList();
                }
            }
            else              //No patient selected or images in database
                              //Use the OS default directory for this type of file viewer.
            {
                dlg.InitialDirectory = "";
                if (dlg.ShowDialog() != DialogResult.OK)
                {
                    return(listAttaches);
                }
                isLocalFileSelected = true;
                listFileNames       = dlg.FileNames.ToList();
            }
            try {
                for (int i = 0; i < listFileNames.Count; i++)
                {
                    if (CloudStorage.IsCloudStorage)
                    {
                        FileAtoZSourceDestination sourceDestination;
                        if (isLocalFileSelected)
                        {
                            sourceDestination = FileAtoZSourceDestination.LocalToAtoZ;
                        }
                        else
                        {
                            sourceDestination = FileAtoZSourceDestination.AtoZToAtoZ;
                        }
                        //Create EmailAttach using EmailAttaches.CreateAttach logic, shortened for our specific purpose.
                        EmailAttach emailAttach = new EmailAttach();
                        emailAttach.DisplayedFileName = Path.GetFileName(listFileNames[i]);
                        string attachDir = EmailAttaches.GetAttachPath();
                        string subDir    = "Out";
                        emailAttach.ActualFileName = ODFileUtils.CombinePaths(subDir,
                                                                              DateTime.Now.ToString("yyyyMMdd") + "_" + DateTime.Now.TimeOfDay.Ticks.ToString()
                                                                              + "_" + MiscUtils.CreateRandomAlphaNumericString(4) + "_" + emailAttach.DisplayedFileName).Replace("\\", "/");
                        FileAtoZ.Copy(listFileNames[i], FileAtoZ.CombinePaths(attachDir, emailAttach.ActualFileName), sourceDestination);
                        listAttaches.Add(emailAttach);
                    }
                    else                      //Not cloud
                    {
                        listAttaches.Add(EmailAttaches.CreateAttach(Path.GetFileName(listFileNames[i]), File.ReadAllBytes(listFileNames[i])));
                    }
                }
            }
            catch (Exception ex) {
                MessageBox.Show(ex.Message);
            }
            return(listAttaches);
        }