コード例 #1
0
ファイル: Documents.cs プロジェクト: nampn/ODental
        ///<summary>Used along with GetChangedSinceDocumentNums</summary>
        public static List <Document> GetMultDocuments(List <long> documentNums, string AtoZpath)
        {
            if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
            {
                return(Meth.GetObject <List <Document> >(MethodBase.GetCurrentMethod(), documentNums, AtoZpath));
            }
            string    strDocumentNums = "";
            DataTable table;

            if (documentNums.Count > 0)
            {
                for (int i = 0; i < documentNums.Count; i++)
                {
                    if (i > 0)
                    {
                        strDocumentNums += "OR ";
                    }
                    strDocumentNums += "DocNum='" + documentNums[i].ToString() + "' ";
                }
                string command = "SELECT * FROM document WHERE " + strDocumentNums;
                table = Db.GetTable(command);
            }
            else
            {
                table = new DataTable();
            }
            Document[]      multDocuments = Crud.DocumentCrud.TableToList(table).ToArray();
            List <Document> documentList  = new List <Document>(multDocuments);

            foreach (Document d in documentList)
            {
                if (string.IsNullOrEmpty(d.RawBase64))
                {
                    Patient pat             = Patients.GetPat(d.PatNum);
                    string  filePathAndName = ImageStore.GetFilePath(Documents.GetByNum(d.DocNum), AtoZpath);
                    if (File.Exists(filePathAndName))
                    {
                        FileStream fs      = new FileStream(filePathAndName, FileMode.Open, FileAccess.Read);
                        byte[]     rawData = new byte[fs.Length];
                        fs.Read(rawData, 0, (int)fs.Length);
                        fs.Close();
                        d.RawBase64 = Convert.ToBase64String(rawData);
                    }
                }
            }
            return(documentList);
        }
コード例 #2
0
        ///<summary>Attempts to open the document using the default program. If not using AtoZfolder saves a local temp file and opens it.</summary>
        public static void OpenDoc(long docNum)
        {
            Document docCur = Documents.GetByNum(docNum);

            if (docCur.DocNum == 0)
            {
                return;
            }
            Patient patCur = Patients.GetPat(docCur.PatNum);

            if (patCur == null)
            {
                return;
            }
            string docPath;

            if (PrefC.AtoZfolderUsed == DataStorageType.LocalAtoZ)
            {
                docPath = ImageStore.GetFilePath(docCur, ImageStore.GetPatientFolder(patCur, ImageStore.GetPreferredAtoZpath()));
            }
            else if (PrefC.AtoZfolderUsed == DataStorageType.InDatabase)
            {
                //Some programs require a file on disk and cannot open in memory files. Save to temp file from DB.
                docPath = PrefC.GetRandomTempFile(ImageStore.GetExtension(docCur));
                File.WriteAllBytes(docPath, Convert.FromBase64String(docCur.RawBase64));
            }
            else              //Cloud storage
                              //Download file to temp directory
            {
                OpenDentalCloud.Core.TaskStateDownload state = CloudStorage.Download(ImageStore.GetPatientFolder(patCur, ImageStore.GetPreferredAtoZpath())
                                                                                     , docCur.FileName);
                docPath = PrefC.GetRandomTempFile(ImageStore.GetExtension(docCur));
                if (ODBuild.IsWeb())
                {
                    ThinfinityUtils.HandleFile(docPath);
                    return;
                }
                File.WriteAllBytes(docPath, state.FileContent);
            }
            Process.Start(docPath);
        }
コード例 #3
0
ファイル: Documents.cs プロジェクト: royedwards/DRDNet
        //Checks to see if the document exists in the correct location, or checks DB for stored content.
        public static bool DocExists(long docNum)
        {
            Document docCur = Documents.GetByNum(docNum);

            if (docCur.DocNum == 0)
            {
                return(false);
            }
            Patient patCur = Patients.GetPat(docCur.PatNum);

            if (patCur == null)
            {
                return(false);
            }
            if (PrefC.AtoZfolderUsed == DataStorageType.LocalAtoZ)
            {
                return(File.Exists(ImageStore.GetFilePath(docCur, ImageStore.GetPatientFolder(patCur, ImageStore.GetPreferredAtoZpath()))));
            }
            else if (CloudStorage.IsCloudStorage)
            {
                return(CloudStorage.FileExists(ODFileUtils.CombinePaths(ImageStore.GetPatientFolder(patCur, ImageStore.GetPreferredAtoZpath()), docCur.FileName, '/')));
            }
            return(!string.IsNullOrEmpty(docCur.RawBase64));
        }