コード例 #1
0
        //Dont find folders with no white space at the end. No way to know if end of file path or not.
        public void ODFileUtils_FilePath_UNCPath_Without_Ending_Space()
        {
            string        testString     = @"This is a test to find the UNC path \\opendental.od\serverfiles\";
            List <string> returnedString = ODFileUtils.GetFilePathsFromText(testString);

            Assert.AreEqual(1, returnedString.Count);
        }
コード例 #2
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.
            }
コード例 #3
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);
        }
コード例 #4
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]);
     }
 }
コード例 #5
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);
     }
 }
コード例 #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
        ///<summary></summary>
        public static void SendData(Program ProgramCur, Patient pat)
        {
            string path = Programs.GetProgramPath(ProgramCur);

            if (pat == null)
            {
                MsgBox.Show("Adstra", "Please select a patient first.");
                return;
            }
            string str = "";

            str += Tidy(pat.LName) + ",";
            str += Tidy(pat.FName) + ",";
            if (ProgramProperties.GetPropVal(ProgramCur.ProgramNum, "Enter 0 to use PatientNum, or 1 to use ChartNum") == "0")
            {
                str += pat.PatNum.ToString() + ",,";
            }
            else
            {
                str += "," + Tidy(pat.ChartNumber) + ",";
            }
            //If birthdates are optional, only send them if they are valid.
            str += pat.Birthdate.ToString("yyyy/MM/dd");           //changed to match bridge format. Was MM/dd/yyy
            try {
                ODFileUtils.ProcessStart(path, str);
            }
            catch (Exception ex) {
                MessageBox.Show(ex.Message);
            }
        }
コード例 #8
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());
        }
コード例 #9
0
ファイル: RayMage.cs プロジェクト: ChemBrain/OpenDental
        public static void SendData(Program ProgramCur, Patient pat)
        {
            string path = Programs.GetProgramPath(ProgramCur);

            if (pat == null)
            {
                try {
                    ODFileUtils.ProcessStart(path);                    //shold start rayMage without bringing up a pt.
                }
                catch {
                    MessageBox.Show(path + " is not available.");
                }
            }
            else
            {
                string info = " /PATID \"";
                if (ProgramProperties.GetPropVal(ProgramCur.ProgramNum, "Enter 0 to use PatientNum, or 1 to use ChartNum") == "0")
                {
                    info += pat.PatNum.ToString();
                }
                else
                {
                    info += pat.ChartNumber;
                }
                info += "\" /NAME \"" + pat.FName.Replace(" ", "").Replace("\"", "") + "\" /SURNAME \"" + pat.LName.Replace(" ", "").Replace("\"", "") + "\"";
                try {
                    ODFileUtils.ProcessStart(path, ProgramCur.CommandLine + info);
                }
                catch {
                    MessageBox.Show(path + " is not available, or there is an error in the command line options.");
                }
            }
        }
コード例 #10
0
        ///<summary>Launches the program using a combination of command line characters and the patient.Cur data.</summary>

        /*Data like the following:
         * [PATIENT]
         * PatID=100011PC        <--- This is the key from the PMS that we will use to locate the Patient in Panda.
         * Title=Miss
         * FirstName=Janet
         * LastName=Wang
         * MiddleInitial=L
         * NickName=
         * Sex=F
         * BirthDate=12/28/1950
         * HomePhone=(360)897-5555
         * WorkPhone=(360)748-7777
         * WorkPhoneExt=
         * SSN=697-12-8888
         * ProviderName=David S North, DDS
         * [ACCOUNT]
         * AccountNO=100003
         * Title=
         * FirstName=Pamela
         * LastName=Courtney
         * MiddleInitial=J
         * Suffix=
         * HomePhone=(360)987-5555
         * WorkPhone=(360)748-7777
         * WorkPhoneExt=
         * Street=23665 Malmore Rd
         * City=Rochester
         * State=WA
         * Zip=98579
         * [REFERDR]
         * RefdrID=NELS12345          <--- This is the key from the PMS that we will use to locate the Referring Doctor in Panda.
         * RefdrLastName=Nelson
         * RefdrfirstName=Michael
         * RefdrMiddleInitial=
         * RefdrNickName=Mike
         * RefdrStreet=1234 Anywhere St.
         * RefdrStreet2=Suite 214
         * RefdrCity=Centralia
         * RefdrState=WA
         * RefdrZip=98531
         * RefdrWorkPhone=(360)256-3258
         * RefdrFax=
         *
         * Should appear in the following file: C:/Program Files/Panda Perio/PandaPerio.ini
         */
        public static void SendData(Program programCur, Patient pat)
        {
            string path = Programs.GetProgramPath(programCur);

            if (pat == null)
            {
                try {
                    ODFileUtils.ProcessStart(path);
                }
                catch {
                    MessageBox.Show(path + " is not available.");
                }
                return;
            }
            if (pat.Birthdate.Year < 1880)
            {
                MessageBox.Show("Patient must have a valid birthdate.");
                return;
            }
            string iniPath = GetIniFromRegistry();

            if (string.IsNullOrEmpty(iniPath))
            {
                MsgBox.Show("PandaPerioAdvanced", "The ini file is not available.");
                return;
            }
            try {
                ODFileUtils.WriteAllTextThenStart(iniPath, GetIniString(pat, programCur), path);
            }
            catch (Exception ex) {
                MessageBox.Show(ex.Message);
            }
        }
コード例 #11
0
ファイル: Cerec.cs プロジェクト: ChemBrain/OpenDental
        ///<summary>Launches the program using a combination of command line characters and the patient.Cur data.</summary>
        public static void SendData(Program ProgramCur, Patient pat)
        {
            string path = Programs.GetProgramPath(ProgramCur);

            //Example CerPI.exe -<patNum>;<fname>;<lname>;<birthday DD.MM.YYYY>; (Date format specified in the windows Regional Settings)
            if (pat == null)
            {
                try {
                    ODFileUtils.ProcessStart(path);                    //should start Cerec without bringing up a pt.
                }
                catch {
                    MessageBox.Show(path + " is not available.");
                }
                return;
            }
            string info = " -";

            if (ProgramProperties.GetPropVal(ProgramCur.ProgramNum, "Enter 0 to use PatientNum, or 1 to use ChartNum") == "0")
            {
                info += pat.PatNum.ToString() + ";";
            }
            else
            {
                info += pat.ChartNumber.ToString() + ";";
            }
            info += pat.FName + ";" + pat.LName + ";" + pat.Birthdate.ToShortDateString() + ";";
            try {
                ODFileUtils.ProcessStart(path, info);
            }
            catch {
                MessageBox.Show(path + " is not available, or there is an error in the command line options.");
            }
        }
コード例 #12
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;
 }
コード例 #13
0
ファイル: CleaRay.cs プロジェクト: ChemBrain/OpenDental
        ///<summary></summary>
        public static void SendData(Program ProgramCur, Patient pat)
        {
            string path = Programs.GetProgramPath(ProgramCur);

            if (pat == null)
            {
                try {
                    ODFileUtils.ProcessStart(path);
                }
                catch {
                    MessageBox.Show(path + " is not available.");
                }
                return;
            }
            string str = "";

            if (ProgramProperties.GetPropVal(ProgramCur.ProgramNum, "Enter 0 to use PatientNum, or 1 to use ChartNum") == "0")
            {
                str += "/ID:" + TidyAndEncapsulate(pat.PatNum.ToString()) + " ";
            }
            else
            {
                str += "/ID:" + TidyAndEncapsulate(pat.ChartNumber) + " ";
            }
            str += "/LN:" + TidyAndEncapsulate(pat.LName) + " ";
            str += "/N:" + TidyAndEncapsulate(pat.FName) + " ";
            try {
                ODFileUtils.ProcessStart(path, str);
            }
            catch (Exception ex) {
                MessageBox.Show(ex.Message);
            }
        }
コード例 #14
0
        public void ODFileUtils_FilePath_InternetURL()
        {
            string        testString     = @"This is a test to not find the url https://google.com ";
            List <string> returnedString = ODFileUtils.GetFilePathsFromText(testString);

            Assert.AreEqual(0, returnedString.Count);
        }
コード例 #15
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;
        }
コード例 #16
0
        ///<summary>Launches the program using a combination of command line characters and the patient.Cur data.</summary>
        public static void SendData(Program ProgramCur, Patient pat)
        {
            string path = Programs.GetProgramPath(ProgramCur);

            if (pat == null)
            {
                try {
                    ODFileUtils.ProcessStart(path);                    //should start i-Dixel without bringing up a pt.
                }
                catch {
                    MessageBox.Show(path + " is not available.");
                }
            }
            else
            {
                string args = " ";
                if (ProgramProperties.GetPropVal(ProgramCur.ProgramNum, "Enter 0 to use PatientNum, or 1 to use ChartNum") == "0")
                {
                    args += pat.PatNum + " ";
                }
                else
                {
                    args += pat.ChartNumber + " ";
                }
                args += pat.FName + " " + pat.LName + " " + (pat.Gender == PatientGender.Female ? "F" : "M");
                try {
                    ODFileUtils.ProcessStart(path, args);
                }
                catch {
                    MessageBox.Show(path + " is not available.");
                }
            }
        }
コード例 #17
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);
 }
コード例 #18
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"));
            }
        }
コード例 #19
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"));
            }
        }
コード例 #20
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(); }
            }
        }
コード例 #21
0
        private void butPrint_Click(object sender, EventArgs e)
        {
            string fileName = CodeBase.ODFileUtils.CombinePaths(PrefC.GetTempFolderPath(), "results.txt");

            ODFileUtils.WriteAllTextThenStart(fileName, textResults.Text, "");
            MsgBox.Show(this, "Please print from the text editor.");
        }
コード例 #22
0
        private void butPreview_Click(object sender, EventArgs e)
        {
            //A couple options here
            //Download the file and run the explorer windows process to show the temporary file
            if (!gridMain.Rows[gridMain.GetSelectedIndex()].Cells[0].Text.Contains("."))             //File path doesn't contain an extension and thus is a subfolder.
            {
                return;
            }
            FormProgress FormP = new FormProgress();

            FormP.DisplayText          = "Downloading...";
            FormP.NumberFormat         = "F";
            FormP.NumberMultiplication = 1;
            FormP.MaxVal = 100;          //Doesn't matter what this value is as long as it is greater than 0
            FormP.TickMS = 1000;
            OpenDentalCloud.Core.TaskStateDownload state = CloudStorage.DownloadAsync(textPath.Text
                                                                                      , Path.GetFileName(gridMain.Rows[gridMain.GetSelectedIndex()].Cells[0].Text)
                                                                                      , new OpenDentalCloud.ProgressHandler(FormP.OnProgress));
            if (FormP.ShowDialog() == DialogResult.Cancel)
            {
                state.DoCancel = true;
                return;
            }
            string tempFile = ODFileUtils.CreateRandomFile(Path.GetTempPath(), Path.GetExtension(gridMain.Rows[gridMain.GetSelectedIndex()].Cells[0].Text));

            File.WriteAllBytes(tempFile, state.FileContent);
            System.Diagnostics.Process.Start(tempFile);
        }
コード例 #23
0
 private void butRecord_Click(object sender, EventArgs e)
 {
     //The following article was used to figure out how to launch the appropriate executable:
     //http://blogs.microsoft.co.il/blogs/tamir/archive/2007/12/04/seek-and-hide-x64-or-where-my-sound-recoder.aspx
     try{
         //Try to launch the sound recorder program within the Windows operating system
         //for all versions of Windows prior to Windows Vista.
         ODFileUtils.ProcessStart("sndrec32.exe");
         //Process.Start("sndrec32.exe");
     }
     catch {
         //We are on a Windows Vista or later Operating System.
         //The path to the SoundRecorder.exe changes depending on if the Operating System
         //is 32 bit or 64 bit.
         try{
             //First try to launch the SoundRecorder.exe for 32 bit Operating Systems.
             ODFileUtils.ProcessStart("SoundRecorder.exe", "/file outputfile.wav");
             //Process.Start("SoundRecorder.exe","/file outputfile.wav");
         }
         catch {
             //This is a 64 bit Operating System. A special environment variable path must be used to indirectly access
             //the SoundRecoder.exe file. The resulting path inside of the soundRecoderVirtualPath variable will only
             //exist inside of this program and does not actually exist if one tries to browse to it.
             string soundRecorderVirtualPath = Environment.ExpandEnvironmentVariables(@"%systemroot%\Sysnative") + "\\SoundRecorder.exe";
             try {
                 ODFileUtils.ProcessStart(soundRecorderVirtualPath, "/file outputfile.wav");
                 //Process.Start(soundRecorderVirtualPath,"/file outputfile.wav");
             }
             catch {
                 //Windows 10 does not have this sound recorder program anymore.
                 MsgBox.Show(this, "Cannot find Windows Sound Recorder. Use the 'Record New' button to record a message sound.");
             }
         }
     }
 }
コード例 #24
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();
                }
            }
        }
コード例 #25
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;
     }
 }
コード例 #26
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.
        }
コード例 #27
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]);
            }
        }
コード例 #28
0
ファイル: Planmeca.cs プロジェクト: ChemBrain/OpenDental
        ///<summary>Launches the program using the patient.Cur data.</summary>
        public static void SendData(Program ProgramCur, Patient pat)
        {
            string path = Programs.GetProgramPath(ProgramCur);
            //DxStart.exe ”PatientID” ”FamilyName” ”FirstName” ”BirthDate”
            List <ProgramProperty> ForProgram = ProgramProperties.GetForProgram(ProgramCur.ProgramNum);

            if (pat == null)
            {
                MessageBox.Show("Please select a patient first");
                return;
            }
            string info = "";
            //Patient id can be any string format
            ProgramProperty PPCur      = ProgramProperties.GetCur(ForProgram, "Enter 0 to use PatientNum, or 1 to use ChartNum");
            string          bDayFormat = ProgramProperties.GetCur(ForProgram, "Birthdate format (usually dd/MM/yyyy or MM/dd/yyyy)").PropertyValue;

            if (PPCur.PropertyValue == "0")
            {
                info += "\"" + pat.PatNum.ToString() + "\" ";
            }
            else
            {
                info += "\"" + pat.ChartNumber.Replace("\"", "") + "\" ";
            }
            info += "\"" + pat.LName.Replace("\"", "") + "\" "
                    + "\"" + pat.FName.Replace("\"", "") + "\" "
                    + "\"" + pat.Birthdate.ToString(bDayFormat) + "\"";       //Format is dd/MM/yyyy by default. Planmeca also told a customer that the format should be MM/dd/yyyy (04/08/2016 cm).
            try {
                ODFileUtils.ProcessStart(path, info);
            }
            catch {
                MessageBox.Show(path + " is not available.");
            }
        }
コード例 #29
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);
        }
コード例 #30
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);
        }