コード例 #1
0
        ///<summary>Takes any files found in the reports folder for the clearinghouse, and imports them into the database.  Deletes the original files.  No longer any such thing as archive.</summary>
        private void ImportReportFiles()
        {
            if (!Directory.Exists(Clearinghouses.Listt[comboClearhouse.SelectedIndex].ResponsePath))
            {
                //MsgBox.Show(this,"Clearinghouse does not have a valid Report Path set.");
                return;
            }
            if (Clearinghouses.Listt[comboClearhouse.SelectedIndex].CommBridge == EclaimsCommBridge.CDAnet)
            {
                //the report path is shared with many other important files.  Do not process anything.  Comm is synchronous only.
                return;
            }
            string[] files      = Directory.GetFiles(Clearinghouses.Listt[comboClearhouse.SelectedIndex].ResponsePath);
            string   archiveDir = ODFileUtils.CombinePaths(Clearinghouses.Listt[comboClearhouse.SelectedIndex].ResponsePath, "Archive");

            if (!Directory.Exists(archiveDir))
            {
                Directory.CreateDirectory(archiveDir);
            }
            for (int i = 0; i < files.Length; i++)
            {
                Etranss.ProcessIncomingReport(
                    File.GetCreationTime(files[i]),
                    Clearinghouses.Listt[comboClearhouse.SelectedIndex].ClearinghouseNum,
                    File.ReadAllText(files[i]));
                try{
                    File.Copy(files[i], ODFileUtils.CombinePaths(archiveDir, Path.GetFileName(files[i])));
                }
                catch {}
                File.Delete(files[i]);
            }
        }
コード例 #2
0
        private List <string> GetTableNames()
        {
            //"C:\development\OPEN DENTAL SUBVERSION\head\OpenDentBusiness\TableTypes\";
            string inputFile = ODFileUtils.CombinePaths(new string[] { "..", "..", "..", "OpenDentBusiness", "TableTypes" });

            return(Directory.GetFiles(inputFile, "*.cs").Select(Path.GetFileNameWithoutExtension).ToList());
        }
コード例 #3
0
ファイル: FormChooseDatabase.cs プロジェクト: nampn/ODental
 ///<summary>Gets a list of all computer names on the network (this is not easy)</summary>
 private string[] GetComputerNames()
 {
     if (Environment.OSVersion.Platform == PlatformID.Unix)
     {
         return(new string[0]);
     }
     try{
         File.Delete(ODFileUtils.CombinePaths(Application.StartupPath, "tempCompNames.txt"));
         ArrayList retList = new ArrayList();
         //string myAdd=Dns.GetHostByName(Dns.GetHostName()).AddressList[0].ToString();//obsolete
         string           myAdd = Dns.GetHostEntry(Dns.GetHostName()).AddressList[0].ToString();
         ProcessStartInfo psi   = new ProcessStartInfo();
         psi.FileName  = @"C:\WINDOWS\system32\cmd.exe";             //Path for the cmd prompt
         psi.Arguments = "/c net view > tempCompNames.txt";          //Arguments for the command prompt
         //"/c" tells it to run the following command which is "net view > tempCompNames.txt"
         //"net view" lists all the computers on the network
         //" > tempCompNames.txt" tells dos to put the results in a file called tempCompNames.txt
         psi.WindowStyle = ProcessWindowStyle.Hidden;              //Hide the window
         Process.Start(psi);
         StreamReader sr       = null;
         string       filename = ODFileUtils.CombinePaths(Application.StartupPath, "tempCompNames.txt");
         Thread.Sleep(200);                //sleep for 1/5 second
         if (!File.Exists(filename))
         {
             return(new string[0]);
         }
         try {
             sr = new StreamReader(filename);
         }
         catch {
         }
         while (!sr.ReadLine().StartsWith("--"))
         {
             //The line just before the data looks like: --------------------------
         }
         string line = "";
         retList.Add("localhost");
         while (true)
         {
             line = sr.ReadLine();
             if (line.StartsWith("The"))                   //cycle until we reach,"The command completed successfully."
             {
                 break;
             }
             line = line.Split(char.Parse(" "))[0];                  // Split the line after the first space
             // Normally, in the file it lists it like this
             // \\MyComputer                 My Computer's Description
             // Take off the slashes, "\\MyComputer" to "MyComputer"
             retList.Add(line.Substring(2, line.Length - 2));
         }
         sr.Close();
         File.Delete(ODFileUtils.CombinePaths(Application.StartupPath, "tempCompNames.txt"));
         string[] retArray = new string[retList.Count];
         retList.CopyTo(retArray);
         return(retArray);
     }
     catch {           //it will always fail if not WinXP
         return(new string[0]);
     }
 }
コード例 #4
0
 private void butStart_Click(object sender, EventArgs e)
 {
     if (butStart.Text == Lan.g(this, "Record"))
     {
         timerRecord.Start();
         _recordStart = DateTime.Now;
         mciSendString("open new Type waveaudio Alias recsound", "", 0, 0);
         mciSendString("record recsound", "", 0, 0);
         butStart.Text   = Lan.g(this, "Stop");
         butStart.Image  = imageListMain.Images[1];
         butPlay.Enabled = false;
         butSave.Enabled = false;
     }
     else              //butStart.Text=="Stop"
     {
         timerRecord.Stop();
         _tempPath = ODFileUtils.CombinePaths(PrefC.GetTempFolderPath(), "recsound" + ".wav");
         mciSendString("save recsound " + _tempPath, "", 0, 0);
         mciSendString("close recsound ", "", 0, 0);
         butStart.Text   = Lan.g(this, "Record");
         butStart.Image  = imageListMain.Images[0];
         butPlay.Enabled = true;
         butSave.Enabled = true;
     }
 }
コード例 #5
0
        private void butOK_Click(object sender, System.EventArgs e)
        {
            if (!Directory.Exists(textLocation.Text))
            {
                MsgBox.Show(this, "Location does not exist.");
                return;
            }
            if (Directory.Exists(ODFileUtils.CombinePaths(textLocation.Text, textName.Text)))
            {
                MsgBox.Show(this, "Folder already exists.");
                return;
            }
            try {
                FileSystemAccessRule fsar = new FileSystemAccessRule("everyone", FileSystemRights.FullControl, AccessControlType.Allow);
                DirectorySecurity    ds   = new DirectorySecurity();
                ds.AddAccessRule(fsar);
                string requestDir     = textLocation.Text;
                string rootFolderName = textName.Text;
                string rootDir        = ODFileUtils.CombinePaths(requestDir, rootFolderName);
                //Enable file sharing for the A to Z folder.
                if (Environment.OSVersion.Platform == PlatformID.Unix)
                {
                    //Process.Start("net","usershare add OpenDentImages \""+rootDir+"\"");//for future use.
                }
                else                  //Windows
                {
                    Process.Start("NET", "SHARE OpenDentImages=\"" + rootDir + "\"");
                }
                //All folder names to be created should be put in this list, so that each folder is created exactly
                //the same way.
                string[] aToZFolderNames = new string[] {
                    "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N",
                    "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z",
                    "EmailAttachments", "Forms", "Reports", "Sounds",
                };
                //Create A to Z folders in root folder.
                for (int i = 0; i < aToZFolderNames.Length; i++)
                {
                    string pathToCreate = ODFileUtils.CombinePaths(rootDir, aToZFolderNames[i]);
                    if (!Directory.Exists(pathToCreate))
                    {
                        // Mono does support Directory.CreateDirectory(string, DirectorySecurity)
#if !LINUX
                        Directory.CreateDirectory(pathToCreate, ds);
#else
                        Directory.CreateDirectory(pathToCreate);
#endif
                    }
                }
                //Save new image path into the DocPath and
                //set "use A to Z folders" check-box to checked.
                Prefs.UpdateString("DocPath", rootDir);
                Prefs.UpdateString("AtoZfolderNotRequired", "0");
                Prefs.Refresh();
            }
            catch (Exception ex) {
                Logger.openlog.LogMB("Failed to create A to Z folders: " + ex.ToString(), Logger.Severity.ERROR);
            }
            DialogResult = DialogResult.OK;
        }
コード例 #6
0
ファイル: FormSheetFieldImage.cs プロジェクト: nampn/ODental
 private void FillImage()
 {
     textFullPath.Text = ODFileUtils.CombinePaths(SheetUtil.GetImagePath(), comboFieldName.Text);
     if (File.Exists(textFullPath.Text))
     {
         try {
             pictureBox.Image = Image.FromFile(textFullPath.Text);
         }
         catch {
             pictureBox.Image = null;
             textWidth2.Text  = "";
             textHeight2.Text = "";
             MessageBox.Show("Invalid image type.");
             return;
         }
         textWidth2.Text  = pictureBox.Image.Width.ToString();
         textHeight2.Text = pictureBox.Image.Height.ToString();
     }
     else if (comboFieldName.Text == "Patient Info.gif")
     {
         pictureBox.Image  = Properties.Resources.Patient_Info;
         textWidth2.Text   = pictureBox.Image.Width.ToString();
         textHeight2.Text  = pictureBox.Image.Height.ToString();
         textFullPath.Text = "Patient Info.gif (internal)";
     }
     else
     {
         pictureBox.Image = null;
         textWidth2.Text  = "";
         textHeight2.Text = "";
     }
 }
コード例 #7
0
ファイル: ImageStore.cs プロジェクト: nampn/ODental
        public static byte[] GetBytes(Document doc, string patFolder)
        {
            /*if(ImageStoreIsDatabase) {not supported
             *      byte[] buffer;
             *      using(IDbConnection connection = DataSettings.GetConnection())
             *      using(IDbCommand command = connection.CreateCommand()) {
             *              command.CommandText =	@"SELECT Data FROM files WHERE DocNum = ?DocNum";
             *              IDataParameter docNumParameter = command.CreateParameter();
             *              docNumParameter.ParameterName = "?DocNum";
             *              docNumParameter.Value = doc.DocNum;
             *              command.Parameters.Add(docNumParameter);
             *              connection.Open();
             *              buffer = (byte[])command.ExecuteScalar();
             *              connection.Close();
             *      }
             *      return buffer;
             * }
             * else {*/
            string path = ODFileUtils.CombinePaths(patFolder, doc.FileName);

            if (!File.Exists(path))
            {
                return(new byte[] { });
            }
            byte[] buffer;
            using (FileStream fs = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read)) {
                int fileLength = (int)fs.Length;
                buffer = new byte[fileLength];
                fs.Read(buffer, 0, fileLength);
            }
            return(buffer);
        }
コード例 #8
0
        private void butImport_Click(object sender, EventArgs e)
        {
            OpenFileDialog dlg = new OpenFileDialog();

            dlg.Multiselect = false;
            if (dlg.ShowDialog() != DialogResult.OK)
            {
                return;
            }
            if (!File.Exists(dlg.FileName))
            {
                MsgBox.Show(this, "File does not exist.");
                return;
            }
            string newName = ODFileUtils.CombinePaths(SheetUtil.GetImagePath(), Path.GetFileName(dlg.FileName));

            if (File.Exists(newName))
            {
                MsgBox.Show(this, "A file of that name already exists in SheetImages.  Please rename the file before importing.");
                return;
            }
            File.Copy(dlg.FileName, newName);
            FillCombo();
            for (int i = 0; i < comboFieldName.Items.Count; i++)
            {
                if (comboFieldName.Items[i].ToString() == Path.GetFileName(newName))
                {
                    comboFieldName.SelectedIndex = i;
                    comboFieldName.Text          = Path.GetFileName(newName);
                    FillImage();
                    ShrinkToFit();
                }
            }
        }
コード例 #9
0
ファイル: FormEhrSetup.cs プロジェクト: kjb7749/testImport
        private static string downloadFileHelper(string codeSystemURL, string codeSystemName)
        {
            string zipFileDestination = PrefC.GetRandomTempFile(".tmp");          //@"c:\users\ryan\desktop\"+codeSystemName+".tmp";

            File.Delete(zipFileDestination);
            WebRequest  wr      = WebRequest.Create(codeSystemURL);
            WebResponse webResp = null;

            try {
                webResp = wr.GetResponse();
            }
            catch (Exception ex) {
                ex.DoNothing();
                return(null);
            }
            DownloadFileWorker(codeSystemURL, zipFileDestination);
            Thread.Sleep(100);            //allow file to be released for use by the unzipper.
            //Unzip the compressed file-----------------------------------------------------------------------------------------------------
            MemoryStream ms = new MemoryStream();

            using (ZipFile unzipped = ZipFile.Read(zipFileDestination)) {
                ZipEntry ze = unzipped[0];
                ze.Extract(PrefC.GetTempFolderPath(), ExtractExistingFileAction.OverwriteSilently);
                return(ODFileUtils.CombinePaths(PrefC.GetTempFolderPath(), unzipped[0].FileName));
            }
        }
コード例 #10
0
ファイル: ImageStore.cs プロジェクト: nampn/ODental
 public static Bitmap OpenImage(Document doc, string patFolder)
 {
     if (PrefC.UsingAtoZfolder)
     {
         string srcFileName = ODFileUtils.CombinePaths(patFolder, doc.FileName);
         if (HasImageExtension(srcFileName))
         {
             //if(File.Exists(srcFileName) && HasImageExtension(srcFileName)) {
             if (File.Exists(srcFileName))
             {
                 return(new Bitmap(srcFileName));
             }
             else
             {
                 //throw new Exception();
                 return(null);
             }
         }
         else
         {
             return(null);
         }
     }
     else
     {
         if (HasImageExtension(doc.FileName))
         {
             return(PIn.Bitmap(doc.RawBase64));
         }
         else
         {
             return(null);
         }
     }
 }
コード例 #11
0
        public Document ImportForm(string form, int docCategory)
        {
            string fileName = ODFileUtils.CombinePaths(new string[] { FileStoreSettings.GetPreferredImagePath,
                                                                      "Forms", form });

            if (!File.Exists(fileName))
            {
                throw new Exception(Lan.g("ContrDocs", "Could not find file: ") + fileName);
            }
            Document doc = new Document();

            doc.FileName    = Path.GetExtension(fileName);
            doc.DateCreated = DateTime.Today;
            doc.DocCategory = docCategory;
            doc.PatNum      = Patient.PatNum;
            doc.ImgType     = ImageType.Document;
            Documents.Insert(doc, Patient);            //this assigns a filename and saves to db
            try {
                SaveDocument(doc, fileName);
            }
            catch {
                Documents.Delete(doc);
                throw;
            }
            return(doc);
        }
コード例 #12
0
ファイル: FormUpdateSetup.cs プロジェクト: nampn/ODental
        private void butValidate_Click(object sender, EventArgs e)
        {
            if (!PrefC.UsingAtoZfolder)
            {
                MsgBox.Show(this, "Not using AtoZ folders, so UpdateFiles folder does not exist.");
                return;
            }
            string  folderUpdate   = ODFileUtils.CombinePaths(ImageStore.GetPreferredAtoZpath(), "UpdateFiles");
            Version currentVersion = new Version(Application.ProductVersion);

            //identify the ideal situation where everything is already in place and no copy is needed.
            if (Directory.Exists(folderUpdate))
            {
                string filePath = ODFileUtils.CombinePaths(folderUpdate, "Manifest.txt");
                if (File.Exists(filePath))
                {
                    string fileText = File.ReadAllText(filePath);
                    if (fileText == currentVersion.ToString(3))
                    {
                        if (!MsgBox.Show(this, MsgBoxButtons.YesNo, "According to the information in UpdateFiles\\Manifest.txt, the UpdateFiles folder is current.  Recopy anyway?"))
                        {
                            return;
                        }
                    }
                }
            }
            Cursor = Cursors.WaitCursor;
            if (!PrefL.CopyFromHereToUpdateFiles(currentVersion))
            {
                Cursor = Cursors.Default;
                return;
            }
            Cursor = Cursors.Default;
            MsgBox.Show(this, "Recopied.");
        }
コード例 #13
0
        ///<summary>This is the function that the worker thread uses to restore the A-Z folder.</summary>
        private void InstanceMethodRestore()
        {
            curVal = 0;
            string atozFull = textBackupRestoreAtoZToPath.Text;          // C:\OpenDentalData\

            //remove the trailing \
            atozFull = atozFull.Substring(0, atozFull.Length - 1);                                      // C:\OpenDentalData
            string atozDir = atozFull.Substring(atozFull.LastIndexOf(Path.DirectorySeparatorChar) + 1); // OpenDentalData

            Invoke(new PassProgressDelegate(PassProgressToDialog), new object [] { 0,
                                                                                   Lan.g(this, "Database restored.\r\nCalculating size of files in A to Z folder."),
                                                                                   100, "" }); //max of 100 keeps dlg from closing
            long atozSize = GetFileSizes(ODFileUtils.CombinePaths(new string[] { textBackupRestoreFromPath.Text, atozDir, "" }),
                                         ODFileUtils.CombinePaths(atozFull, "")) / 1024;       // C:\OpenDentalData\

            if (!Directory.Exists(atozFull))                                                   // C:\OpenDentalData\
            {
                Directory.CreateDirectory(atozFull);                                           // C:\OpenDentalData\
            }
            curVal = 0;
            CopyDirectoryIncremental(ODFileUtils.CombinePaths(new string[] { textBackupRestoreFromPath.Text, atozDir, "" }),
                                     ODFileUtils.CombinePaths(atozFull, ""),// C:\OpenDentalData\
                                     atozSize);
            //force dlg to close even if no files copied or calculation was slightly off.
            Invoke(new PassProgressDelegate(PassProgressToDialog), new object[] { 0, "", 0, "" });
        }
コード例 #14
0
ファイル: ImageStore.cs プロジェクト: steev90/opendental
 ///<summary>For each of the documents in the list, deletes row from db and image from AtoZ folder if needed.  Throws exception if the file cannot be deleted.  Surround in try/catch.</summary>
 public static void DeleteDocuments(IList <Document> documents, string patFolder)
 {
     for (int i = 0; i < documents.Count; i++)
     {
         if (documents[i] == null)
         {
             continue;
         }
         if (PrefC.AtoZfolderUsed)
         {
             try {
                 string filePath = ODFileUtils.CombinePaths(patFolder, documents[i].FileName);
                 if (File.Exists(filePath))
                 {
                     File.Delete(filePath);
                 }
             }
             catch {
                 throw new Exception(Lans.g("ContrImages", "Could not delete file, it may be in use."));
             }
         }
         //Row from db.  This deletes the "image file" also if it's stored in db.
         Documents.Delete(documents[i]);
     }
 }
コード例 #15
0
ファイル: ImageStore.cs プロジェクト: nampn/ODental
        /// <summary>Obviously no support for db storage</summary>
        public static Document ImportForm(string form, long docCategory, Patient pat)
        {
            string patFolder      = GetPatientFolder(pat, GetPreferredAtoZpath());
            string pathSourceFile = ODFileUtils.CombinePaths(GetPreferredAtoZpath(), "Forms", form);

            if (!File.Exists(pathSourceFile))
            {
                throw new Exception(Lans.g("ContrDocs", "Could not find file: ") + pathSourceFile);
            }
            Document doc = new Document();

            doc.FileName    = Path.GetExtension(pathSourceFile);
            doc.DateCreated = DateTime.Today;
            doc.DocCategory = docCategory;
            doc.PatNum      = pat.PatNum;
            doc.ImgType     = ImageType.Document;
            Documents.Insert(doc, pat);           //this assigns a filename and saves to db
            doc = Documents.GetByNum(doc.DocNum);
            try {
                SaveDocument(doc, pathSourceFile, patFolder);
            }
            catch {
                Documents.Delete(doc);
                throw;
            }
            return(doc);
        }
コード例 #16
0
        private void butExportGrid_Click(object sender, EventArgs e)
        {
            StringBuilder sb = new StringBuilder();

            sb.AppendLine(string.Join(",", gridMain.ListGridColumns.OfType <GridColumn>().Select(x => x.Heading)));
            gridMain.ListGridRows.OfType <GridRow>().ToList()
            .ForEach(row => sb.AppendLine(string.Join(",", row.Cells.Select(cell => cell.Text.Replace(',', '-').Replace('\t', ',')))));
            if (ODBuild.IsWeb())
            {
                string exportFilename = "BenefitsRpt_" + _dtNow.ToString("yyyyMMdd") + "_" + DateTime.Now.ToString("hhmm") + ".csv";
                string dataString     = sb.ToString();
                ThinfinityUtils.ExportForDownload(exportFilename, dataString);
                return;
            }
            FolderBrowserDialog fbd = new FolderBrowserDialog();

            if (fbd.ShowDialog() != DialogResult.OK || string.IsNullOrEmpty(fbd.SelectedPath))
            {
                MsgBox.Show(this, "Invalid directory.");
                return;
            }
            string filename = ODFileUtils.CombinePaths(fbd.SelectedPath, "BenefitsRpt_" + _dtNow.ToString("yyyyMMdd") + "_" + DateTime.Now.ToString("hhmm") + ".csv");

            System.IO.File.WriteAllText(filename, sb.ToString());
            if (MsgBox.Show(this, MsgBoxButtons.YesNo, "Would you like to open the file now?"))
            {
                try {
                    System.Diagnostics.Process.Start(filename);
                }
                catch (Exception ex) { ex.DoNothing(); }
            }
        }
コード例 #17
0
ファイル: ImageStore.cs プロジェクト: nampn/ODental
 ///<summary>For each of the documents in the list, deletes row from db and image from AtoZ folder if needed.</summary>
 public static void DeleteDocuments(IList <Document> documents, string patFolder)
 {
     for (int i = 0; i < documents.Count; i++)
     {
         if (documents[i] == null)
         {
             continue;
         }
         if (PrefC.UsingAtoZfolder)
         {
             try{
                 string filePath = ODFileUtils.CombinePaths(patFolder, documents[i].FileName);
                 if (File.Exists(filePath))
                 {
                     File.Delete(filePath);
                 }
             }
             catch {
                 //if(verbose) {
                 //	Debug.WriteLine(Lans.g("ContrDocs", "Could not delete file. It may be in use elsewhere, or may have already been deleted."));
                 //}
             }
         }
         //Row from db.  This deletes the "image file" also if it's stored in db.
         Documents.Delete(documents[i]);
     }
 }
コード例 #18
0
        ///<summary>Moves all files in the temporary directory to the destination directory.
        ///Returns false if there was a problem moving the files from the temporary directory to the destination directory.</summary>
        private bool MoveFilesToDestDir(FileInfo[] arraySourceFiles)
        {
            string sourceManifest = "";

            for (int i = 0; i < arraySourceFiles.Length; i++)
            {
                if (arraySourceFiles[i].Name == "Manifest.txt")
                {
                    sourceManifest = ODFileUtils.CombinePaths(TempPathSource, arraySourceFiles[i].Name);
                    continue;
                }
                SetLabelText("Verifying: " + arraySourceFiles[i].Name);
                string source = ODFileUtils.CombinePaths(TempPathSource, arraySourceFiles[i].Name);
                string dest   = ODFileUtils.CombinePaths(_destDirectory, arraySourceFiles[i].Name);
                try {
                    File.Copy(source, dest, true);
                }
                catch {
                    //SetLabelText("Copying files from temp to destination failed.");
                    return(false);
                }
            }
            //Save the Manifest.txt file for last so that any subsequent attempts launching Open Dental will try to launch the FileUpdateCopier again.
            if (sourceManifest != "")
            {
                try {
                    File.Copy(sourceManifest, Path.Combine(_destDirectory, "Manifest.txt"), true);
                }
                catch {
                    //SetLabelText("Copying Manifest.txt from temp to destination failed.");
                    return(false);
                }
            }
            return(true);           //Files copied successfully.
        }
コード例 #19
0
ファイル: ImageStore.cs プロジェクト: nampn/ODental
        ///<summary></summary>
        public static void DeleteThumbnailImage(Document doc, string patFolder)
        {
            /*if(ImageStoreIsDatabase) {
             *      using(IDbConnection connection = DataSettings.GetConnection())
             *      using(IDbCommand command = connection.CreateCommand()) {
             *              command.CommandText =
             *              @"UPDATE files SET Thumbnail = NULL WHERE DocNum = ?DocNum";
             *
             *              IDataParameter docNumParameter = command.CreateParameter();
             *              docNumParameter.ParameterName = "?DocNum";
             *              docNumParameter.Value = doc.DocNum;
             *              command.Parameters.Add(docNumParameter);
             *
             *              connection.Open();
             *              command.ExecuteNonQuery();
             *              connection.Close();
             *      }
             * }
             * else {*/
            //string patFolder=GetPatientFolder(pat);
            string thumbnailFile = ODFileUtils.CombinePaths(patFolder, "Thumbnails", doc.FileName);

            if (File.Exists(thumbnailFile))
            {
                try {
                    File.Delete(thumbnailFile);
                }
                catch {
                    //Two users *might* edit the same image at the same time, so the image might already be deleted.
                }
            }
        }
コード例 #20
0
 private bool MoveFileToArchiveFolder()
 {
     try {
         string dir        = Path.GetDirectoryName(_x834.FilePath);
         string dirArchive = ODFileUtils.CombinePaths(dir, "Archive");
         if (!Directory.Exists(dirArchive))
         {
             Directory.CreateDirectory(dirArchive);
         }
         string destPathBasic     = ODFileUtils.CombinePaths(dirArchive, Path.GetFileName(_x834.FilePath));
         string destPathExt       = Path.GetExtension(destPathBasic);
         string destPathBasicRoot = destPathBasic.Substring(0, destPathBasic.Length - destPathExt.Length);
         string destPath          = destPathBasic;
         int    attemptCount      = 1;
         while (File.Exists(destPath))
         {
             attemptCount++;
             destPath = destPathBasicRoot + "_" + attemptCount + destPathExt;
         }
         File.Move(_x834.FilePath, destPath);
     }
     catch (Exception ex) {
         MessageBox.Show(Lan.g(this, "Failed to move file") + " '" + _x834.FilePath + "' "
                         + Lan.g(this, "to archive, probably due to a permission issue.") + "  " + ex.Message);
         return(false);
     }
     return(true);
 }
コード例 #21
0
        ///<summary>The problem with this is that if multiple copies of OD are open at the same time, it might get data from only the most recently opened database.  This won't work for some users, so we will normally dynamically alter the connection string.</summary>
        public static string GetODConnStr()
        {
            //return "Server=localhost;Database=development54;User ID=root;Password=;CharSet=utf8";
            XmlDocument document = new XmlDocument();
            string      path     = ODFileUtils.CombinePaths(Application.StartupPath, "FreeDentalConfig.xml");

            if (!File.Exists(path))
            {
                return("");
            }
            string computerName = "";
            string database     = "";
            string user         = "";
            string password     = "";

            try {
                document.Load(path);
                XmlNodeReader reader         = new XmlNodeReader(document);
                string        currentElement = "";
                while (reader.Read())
                {
                    if (reader.NodeType == XmlNodeType.Element)
                    {
                        currentElement = reader.Name;
                    }
                    else if (reader.NodeType == XmlNodeType.Text)
                    {
                        switch (currentElement)
                        {
                        case "ComputerName":
                            computerName = reader.Value;
                            break;

                        case "Database":
                            database = reader.Value;
                            break;

                        case "User":
                            user = reader.Value;
                            break;

                        case "Password":
                            password = reader.Value;
                            break;
                        }
                    }
                }
                reader.Close();
            }
            catch {
                return("");
            }
            //example:
            //Server=localhost;Database=opendental;User ID=root;Password=;CharSet=utf8
            return("Server=" + computerName
                   + ";Database=" + database
                   + ";User ID=" + user
                   + ";Password="******";CharSet=utf8");
        }
コード例 #22
0
ファイル: x837Controller.cs プロジェクト: royedwards/DRDNet
        ///<summary>Gets the filename for this batch. Used when saving or when rolling back.</summary>
        private static string GetFileName(Clearinghouse clearinghouseClin, int batchNum, bool isAutomatic)         //called from this.SendBatch. Clinic-level clearinghouse passed in.
        {
            string saveFolder = clearinghouseClin.ExportPath;

            if (!Directory.Exists(saveFolder))
            {
                if (!isAutomatic)
                {
                    MessageBox.Show(saveFolder + " not found.");
                }
                return("");
            }
            if (clearinghouseClin.CommBridge == EclaimsCommBridge.RECS)
            {
                if (File.Exists(ODFileUtils.CombinePaths(saveFolder, "ecs.txt")))
                {
                    if (!isAutomatic)
                    {
                        MessageBox.Show(Lans.g("FormClaimsSend", "You must send your existing claims from the RECS program before you can create another batch."));
                    }
                    return("");                   //prevents overwriting an existing ecs.txt.
                }
                return(ODFileUtils.CombinePaths(saveFolder, "ecs.txt"));
            }
            else
            {
                return(ODFileUtils.CombinePaths(saveFolder, "claims" + batchNum.ToString() + ".txt"));
            }
        }
コード例 #23
0
        ///<summary>Returns patient's AtoZ path if local AtoZ is used.  Returns Cloud AtoZ path if Dropbox is used.  Returns temp path if in database.</summary>
        public static string GetAttachPath()
        {
            //No need to check RemotingRole; no call to db.
            string attachPath;

            if (PrefC.AtoZfolderUsed == DataStorageType.LocalAtoZ)
            {
                attachPath = ODFileUtils.CombinePaths(ImageStore.GetPreferredAtoZpath(), "EmailAttachments");
                if (!Directory.Exists(attachPath))
                {
                    Directory.CreateDirectory(attachPath);
                }
            }
            else if (CloudStorage.IsCloudStorage)
            {
                attachPath = ODFileUtils.CombinePaths(ImageStore.GetPreferredAtoZpath(), "EmailAttachments", '/');            //Gets Cloud path with EmailAttachments folder.
            }
            else
            {
                //For users who have the A to Z folders disabled, there is no defined image path, so we
                //have to use a temp path.  This means that the attachments might be available immediately afterward,
                //but probably not later.
                attachPath = ODFileUtils.CombinePaths(Path.GetTempPath(), "opendental");             //Have to use Path.GetTempPath() here instead of PrefL.GetTempPathFolder() because we can't access PrefL.
            }
            return(attachPath);
        }
コード例 #24
0
 private void butExport_Click(object sender, EventArgs e)
 {
     #region Web Build
     if (ODBuild.IsWeb())
     {
         string fileName = ElementCur.SigText + ".wav";
         string tempPath = ODFileUtils.CombinePaths(Path.GetTempPath(), fileName);
         try {
             PIn.Sound(ElementCur.Sound, tempPath);
         }
         catch (ApplicationException ex) {
             MessageBox.Show(ex.Message);
             return;
         }
         ThinfinityUtils.ExportForDownload(tempPath);
         return;
     }
     #endregion Web Build
     saveFileDialog1.FileName   = "";
     saveFileDialog1.DefaultExt = "wav";
     if (saveFileDialog1.ShowDialog() != DialogResult.OK)
     {
         return;
     }
     try {
         PIn.Sound(ElementCur.Sound, saveFileDialog1.FileName);
     }
     catch (ApplicationException ex) {
         MessageBox.Show(ex.Message);
     }
 }
コード例 #25
0
 ///<summary></summary>
 public void FormDocInfo_Load(object sender, System.EventArgs e)
 {
     //if (Docs.Cur.FileName.Equals(null))
     listCategory.Items.Clear();
     for (int i = 0; i < DefB.Short[(int)DefCat.ImageCats].Length; i++)
     {
         string folderName = DefB.Short[(int)DefCat.ImageCats][i].ItemName;
         listCategory.Items.Add(folderName);
         if (i == 0 || DefB.Short[(int)DefCat.ImageCats][i].DefNum == DocCur.DocCategory || folderName == initialSelection)
         {
             listCategory.SelectedIndex = i;
         }
     }
     listType.Items.Clear();
     listType.Items.AddRange(Enum.GetNames(typeof(ImageType)));
     listType.SelectedIndex = (int)DocCur.ImgType;
     textToothNumbers.Text  = Tooth.FormatRangeForDisplay(DocCur.ToothNumbers);
     textDate.Text          = DocCur.DateCreated.ToString("d");
     textDescript.Text      = DocCur.Description;
     //When the A to Z folders are disabled, the image module is disabled and this
     //code will never get called. Thus, by the time this point in the code is reached,
     //there will be a valid image path.
     textFileName.Text = ODFileUtils.CombinePaths(new string[] { FormPath.GetPreferredImagePath(),
                                                                 PatCur.ImageFolder.Substring(0, 1).ToUpper(),
                                                                 PatCur.ImageFolder,
                                                                 DocCur.FileName });
     if (File.Exists(textFileName.Text))
     {
         FileInfo fileInfo = new FileInfo(textFileName.Text);
         textSize.Text = fileInfo.Length.ToString("n0");
     }
     textToothNumbers.Text = Tooth.FormatRangeForDisplay(DocCur.ToothNumbers);
     //textNote.Text=DocCur.Note;
 }
コード例 #26
0
ファイル: Sftp.cs プロジェクト: royedwards/DRDNet
            protected override async Task PerformIO()
            {
                bool hadToConnect = _client.ConnectIfNeeded();

                _client.CreateDirectoriesIfNeeded(Folder);
                string fullFilePath = ODFileUtils.CombinePaths(Folder, FileName, '/');

                using (MemoryStream uploadStream = new MemoryStream(FileContent)) {
                    SftpUploadAsyncResult res = (SftpUploadAsyncResult)_client.BeginUploadFile(uploadStream, fullFilePath);
                    while (!res.AsyncWaitHandle.WaitOne(100))
                    {
                        if (DoCancel)
                        {
                            res.IsUploadCanceled = true;
                        }
                        OnProgress((double)res.UploadedBytes / (double)1024 / (double)1024, "?currentVal MB of ?maxVal MB uploaded", (double)FileContent.Length / (double)1024 / (double)1024, "");
                    }
                    _client.EndUploadFile(res);
                    if (res.IsUploadCanceled)
                    {
                        TaskStateDelete state = new Delete()
                        {
                            _client = this._client,
                            Path    = fullFilePath
                        };
                        state.Execute(false);
                    }
                }
                _client.DisconnectIfNeeded(hadToConnect);
                await Task.Run(() => { });                //Gets rid of a compiler warning and does nothing.
            }
コード例 #27
0
        ///<summary>Gets the filename for this batch. Used when saving or when rolling back.</summary>
        private static string GetFileName(Clearinghouse clearinghouseClin, int batchNum, bool isAutomatic)         //called from this.SendBatch. Clinic-level clearinghouse passed in.
        {
            string saveFolder = clearinghouseClin.ExportPath;

            if (!ODBuild.IsWeb() && !Directory.Exists(saveFolder))
            {
                if (!isAutomatic)
                {
                    MessageBox.Show(saveFolder + " not found.");
                }
                return("");
            }
            if (clearinghouseClin.CommBridge == EclaimsCommBridge.RECS)
            {
                if (!ODBuild.IsWeb() && File.Exists(ODFileUtils.CombinePaths(saveFolder, "ecs.txt")))
                {
                    if (!isAutomatic)
                    {
                        MessageBox.Show(RECSFileExistsMsg);
                    }
                    return("");                   //prevents overwriting an existing ecs.txt.
                }
                return(ODFileUtils.CombinePaths(saveFolder, "ecs.txt"));
            }
            else
            {
                return(ODFileUtils.CombinePaths(saveFolder, "claims" + batchNum.ToString() + ".txt"));
            }
        }
コード例 #28
0
ファイル: TrophyEnhanced.cs プロジェクト: kjb7749/testImport
        ///<summary>Guaranteed to always return a valid foldername unless major error or user chooses to exit.  This also saves the TrophyFolder value to this patient in the db and creates the new folder.</summary>
        private static string AutomaticallyGetTrophyFolderNumbered(Patient pat, string trophyPath)
        {
            //if this a patient with existing images in a trophy folder, find that folder
            //Different Trophy might? be organized differently.
            //But our logic will only cover the one situation that we are aware of.
            //In numbered mode, the folder numbering scheme is [trophyImageDir]\XX\PatNum.  The two digits XX are obtained by retrieving the 5th and 6th (indexes 4 and 5) digits of the patient's PatNum, left padded with 0's to ensure the PatNum is at least 6 digits long.  Examples: PatNum=103, left pad to 000103, substring to 03, patient's folder location is [trophyDirectory]\03\103.  PatNum=1003457, no need to left pad, substring to 45, pat folder is [trophyDirectory]\45\1003457.
            string retVal   = ODFileUtils.CombinePaths(pat.PatNum.ToString().PadLeft(6, '0').Substring(4, 2), pat.PatNum.ToString());     //this is our default return value
            string fullPath = ODFileUtils.CombinePaths(trophyPath, retVal);

            if (!Directory.Exists(fullPath))
            {
                try {
                    Directory.CreateDirectory(fullPath);
                }
                catch {
                    throw new Exception("Error.  Could not create folder: " + fullPath);
                }
            }
            //folder either existed before we got here, or we successfully created it
            Patient PatOld = pat.Copy();

            pat.TrophyFolder = retVal;
            Patients.Update(pat, PatOld);
            return(retVal);
        }
コード例 #29
0
        public FormUpdateInProgress(string updateComputerName)
        {
            InitializeComponent();
            Lan.F(this);
            _updateComputerName = updateComputerName;
            _listAdminCompNames = new List <string>();
            string      xmlPath  = ODFileUtils.CombinePaths(Application.StartupPath, "FreeDentalConfig.xml");
            XmlDocument document = new XmlDocument();

            try {
                document.Load(xmlPath);
                XPathNavigator    Navigator = document.CreateNavigator();
                XPathNavigator    nav;
                XPathNodeIterator navIterator;
                nav         = Navigator.SelectSingleNode("//AdminCompNames");
                navIterator = nav.SelectChildren(XPathNodeType.All);
                for (int i = 0; i < navIterator.Count; i++)
                {
                    navIterator.MoveNext();
                    _listAdminCompNames.Add(navIterator.Current.Value);                    //Add this computer name to the list.
                }
            }
            catch (Exception) {
                //suppress. this just means that the FreeDentalConfig xml file doesn't have any Admin Computers listed.
            }
            _listAdminCompNames.Add(_updateComputerName);
        }
コード例 #30
0
        private void buttonExport_Click(object sender, EventArgs e)
        {
            string fileName = Lan.g(this, "Treatment Finder");
            string filePath = ODFileUtils.CombinePaths(Path.GetTempPath(), fileName);

            if (ODBuild.IsWeb())
            {
                //file download dialog will come up later, after file is created.
                filePath += ".txt";              //Provide the filepath an extension so that Thinfinity can offer as a download.
            }
            else
            {
                SaveFileDialog saveFileDialog2 = new SaveFileDialog();
                saveFileDialog2.AddExtension = true;
                saveFileDialog2.Title        = Lan.g(this, "Treatment Finder");
                saveFileDialog2.FileName     = Lan.g(this, "Treatment Finder");
                if (!Directory.Exists(PrefC.GetString(PrefName.ExportPath)))
                {
                    try {
                        Directory.CreateDirectory(PrefC.GetString(PrefName.ExportPath));
                        saveFileDialog2.InitialDirectory = PrefC.GetString(PrefName.ExportPath);
                    }
                    catch {
                        //initialDirectory will be blank
                    }
                }
                else
                {
                    saveFileDialog2.InitialDirectory = PrefC.GetString(PrefName.ExportPath);
                }
                saveFileDialog2.Filter      = "Text files(*.txt)|*.txt|Excel Files(*.xls)|*.xls|All files(*.*)|*.*";
                saveFileDialog2.FilterIndex = 0;
                if (saveFileDialog2.ShowDialog() != DialogResult.OK)
                {
                    return;
                }
                filePath = saveFileDialog2.FileName;
            }
            try{
                using (StreamWriter sw = new StreamWriter(filePath, false))
                {
                    sw.WriteLine(string.Join("\t", gridMain.ListGridColumns.Select(x => x.Heading)));
                    gridMain.ListGridRows.ForEach(x => sw.WriteLine(
                                                      string.Join("\t", x.Cells.Select(y => string.Concat(y.Text.Where(z => !z.In('\r', '\n', '\t', '\"')))))));
                }
            }
            catch {
                MessageBox.Show(Lan.g(this, "File in use by another program.  Close and try again."));
                return;
            }
            if (ODBuild.IsWeb())
            {
                ThinfinityUtils.ExportForDownload(filePath);
            }
            else
            {
                MessageBox.Show(Lan.g(this, "File created successfully"));
            }
        }