コード例 #1
0
ファイル: FormDocInfo.cs プロジェクト: ChemBrain/OpenDental
 private void butOpen_Click(object sender, EventArgs e)
 {
     if (PrefC.AtoZfolderUsed == DataStorageType.LocalAtoZ)
     {
         System.Diagnostics.Process.Start("Explorer", Path.GetDirectoryName(textFileName.Text));
     }
     else if (CloudStorage.IsCloudStorage)             //First download, then open
     {
         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;
         string patFolder;
         if (!TryGetPatientFolder(out patFolder, false))
         {
             return;
         }
         OpenDentalCloud.Core.TaskStateDownload state = CloudStorage.DownloadAsync(patFolder
                                                                                   , DocCur.FileName
                                                                                   , new OpenDentalCloud.ProgressHandler(FormP.OnProgress));
         FormP.ShowDialog();
         if (FormP.DialogResult == DialogResult.Cancel)
         {
             state.DoCancel = true;
             return;
         }
         //Create temp file here or create the file with the actual name?  Changes made when opening the file won't be saved, so I think temp file is best.
         string tempFile = PrefC.GetRandomTempFile(Path.GetExtension(DocCur.FileName));
         File.WriteAllBytes(tempFile, state.FileContent);
         if (ODBuild.IsWeb())
         {
             ThinfinityUtils.HandleFile(tempFile);
         }
         else
         {
             System.Diagnostics.Process.Start(tempFile);
         }
     }
 }
コード例 #2
0
ファイル: FileAtoZ.cs プロジェクト: kjb7749/testImport
 ///<summary>Copies or downloads the file and opens it. acutalFileName should be a full path, displayedFileName should be a file name only.
 ///</summary>
 public static void OpenFile(string actualFilePath, string displayedFileName = "")
 {
     try {
         string tempFile;
         if (displayedFileName == "")
         {
             tempFile = ODFileUtils.CombinePaths(PrefC.GetTempFolderPath(), Path.GetFileName(actualFilePath));
         }
         else
         {
             tempFile = ODFileUtils.CombinePaths(PrefC.GetTempFolderPath(), displayedFileName);
         }
         if (CloudStorage.IsCloudStorage)
         {
             FormProgress FormP = CreateFormProgress("Downloading...");
             OpenDentalCloud.Core.TaskStateDownload state = CloudStorage.DownloadAsync(Path.GetDirectoryName(actualFilePath),
                                                                                       Path.GetFileName(actualFilePath), new OpenDentalCloud.ProgressHandler(FormP.OnProgress));
             FormP.ShowDialog();
             if (FormP.DialogResult == DialogResult.Cancel)
             {
                 state.DoCancel = true;
                 return;
             }
             File.WriteAllBytes(tempFile, state.FileContent);
         }
         else                   //Not Cloud
                                //We have to create a copy of the file because the name is different.
                                //There is also a high probability that the attachment no longer exists if
                                //images are stored in the database, since the file will have originally been
                                //placed in the temporary directory.
         {
             File.Copy(actualFilePath, tempFile, true);
         }
         Process.Start(tempFile);
     }
     catch (Exception ex) {
         MessageBox.Show(ex.Message);
     }
 }
コード例 #3
0
ファイル: FileAtoZ.cs プロジェクト: kjb7749/testImport
        ///<summary>Runs the file. Downloads it from the cloud if necessary.</summary>
        public static void StartProcess(string fileName)
        {
            string filePathToOpen;

            if (CloudStorage.IsCloudStorage)
            {
                FormProgress FormP = CreateFormProgress("Downloading...");
                OpenDentalCloud.Core.TaskStateDownload state = CloudStorage.DownloadAsync(Path.GetDirectoryName(fileName), Path.GetFileName(fileName),
                                                                                          new OpenDentalCloud.ProgressHandler(FormP.OnProgress));
                FormP.ShowDialog();
                if (FormP.DialogResult == DialogResult.Cancel)
                {
                    state.DoCancel = true;
                    return;
                }
                filePathToOpen = PrefC.GetRandomTempFile(Path.GetExtension(fileName));
                File.WriteAllBytes(filePathToOpen, state.FileContent);
            }
            else
            {
                filePathToOpen = fileName;
            }
            Process.Start(filePathToOpen);
        }
コード例 #4
0
        private void butDownload_Click(object sender, System.EventArgs e)
        {
            File.Delete(PrefB.GetString("DocPath") + "Setup.exe");          //fixes a minor bug
            string remoteUri = textWebsitePath.Text + textRegMain.Text + "/";

            //WebClient myWebClient=new WebClient();
            myStringWebResource = remoteUri + "Setup.exe";
            WriteToFile         = PrefB.GetString("DocPath") + "Setup.exe";
            WebRequest  wr       = WebRequest.Create(myStringWebResource);
            WebResponse webResp  = wr.GetResponse();
            int         fileSize = (int)webResp.ContentLength / 1024;
            //start the thread that will perform the download
            Thread workerThread = new Thread(new ThreadStart(InstanceMethod));

            workerThread.Start();
            //display the progress dialog to the user:
            FormP        = new FormProgress();
            FormP.MaxVal = (double)fileSize / 1024;
            FormP.NumberMultiplication = 100;
            FormP.DisplayText          = "?currentVal MB of ?maxVal MB copied";
            FormP.NumberFormat         = "F";
            FormP.ShowDialog();
            if (FormP.DialogResult == DialogResult.Cancel)
            {
                workerThread.Abort();
                return;
            }
            MsgBox.Show(this, "Download succeeded.  Setup program will now begin.  When done, restart the program on this computer, then on the other computers.");
            try{
                Process.Start(PrefB.GetString("DocPath") + "Setup.exe");
                Application.Exit();
            }
            catch {
                MsgBox.Show(this, "Could not launch setup");
            }
        }
コード例 #5
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;
            }
            if (!ImageHelper.HasImageExtension(dlg.FileName))
            {
                MsgBox.Show(this, "Only allowed to import an image.");
                return;
            }
            string newName = dlg.FileName;

            if (PrefC.AtoZfolderUsed == DataStorageType.LocalAtoZ)
            {
                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);
            }
            else if (CloudStorage.IsCloudStorage)
            {
                if (CloudStorage.FileExists(ODFileUtils.CombinePaths(SheetUtil.GetImagePath(), Path.GetFileName(dlg.FileName))))
                {
                    MsgBox.Show(this, "A file of that name already exists in SheetImages.  Please rename the file before importing.");
                    return;
                }
                FormProgress FormP = new FormProgress();
                FormP.DisplayText          = Lan.g(CloudStorage.LanThis, "Uploading...");
                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.TaskStateUpload state = CloudStorage.UploadAsync(SheetUtil.GetImagePath(), Path.GetFileName(dlg.FileName)
                                                                                      , File.ReadAllBytes(dlg.FileName)
                                                                                      , new OpenDentalCloud.ProgressHandler(FormP.OnProgress));
                if (FormP.ShowDialog() == DialogResult.Cancel)
                {
                    state.DoCancel = true;
                    return;
                }
                newName = Path.GetFileName(dlg.FileName);
                //It would be nice to save the image somewhere so that we don't have to download it again.
            }
            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();
                }
            }
        }
コード例 #6
0
 private void FillImage()
 {
     if (comboFieldName.Text == "")
     {
         return;
     }
     if (CloudStorage.IsCloudStorage)
     {
         textFullPath.Text = CloudStorage.PathTidy(ODFileUtils.CombinePaths(SheetUtil.GetImagePath(), comboFieldName.Text));
     }
     else
     {
         textFullPath.Text = ODFileUtils.CombinePaths(SheetUtil.GetImagePath(), comboFieldName.Text);
     }
     if (PrefC.AtoZfolderUsed == DataStorageType.LocalAtoZ && File.Exists(textFullPath.Text))
     {
         GC.Collect();
         try {
             pictureBox.Image = Image.FromFile(textFullPath.Text);
         }
         catch {
             pictureBox.Image = null;
             MsgBox.Show(this, "Invalid image type.");
         }
     }
     else if (comboFieldName.Text == "Patient Info.gif")           //Interal image
     {
         pictureBox.Image  = OpenDentBusiness.Properties.Resources.Patient_Info;
         textFullPath.Text = "Patient Info.gif (internal)";
     }
     else if (CloudStorage.IsCloudStorage)
     {
         if (comboFieldName.Text == SheetFieldDefCur.FieldName && SheetFieldDefCur.ImageField != null)
         {
             pictureBox.Image = SheetFieldDefCur.ImageField;
         }
         else
         {
             FormProgress FormP = new FormProgress();
             FormP.DisplayText          = Lan.g(CloudStorage.LanThis, "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(SheetUtil.GetImagePath(), comboFieldName.Text,
                                                                                       new OpenDentalCloud.ProgressHandler(FormP.OnProgress));
             if (FormP.ShowDialog() == DialogResult.Cancel)
             {
                 state.DoCancel = true;
                 return;
             }
             if (state == null || state.FileContent == null)
             {
                 pictureBox.Image = null;
             }
             else
             {
                 using (MemoryStream stream = new MemoryStream(state.FileContent)) {
                     pictureBox.Image = new Bitmap(Image.FromStream(stream));
                 }
             }
         }
     }
     else
     {
         pictureBox.Image = null;
     }
     if (pictureBox.Image == null)
     {
         textWidth2.Text  = "";
         textHeight2.Text = "";
     }
     else
     {
         textWidth2.Text  = pictureBox.Image.Width.ToString();
         textHeight2.Text = pictureBox.Image.Height.ToString();
     }
 }
コード例 #7
0
        private void butBackup_Click(object sender, System.EventArgs e)
        {
            if (!IsBackupTabValid())
            {
                return;
            }
            //Ensure that the backup from and backup to paths are different. This is to prevent the live database
            //from becoming corrupt.
            if (this.textBackupFromPath.Text.Trim().ToLower() == this.textBackupToPath.Text.Trim().ToLower())
            {
                MsgBox.Show(this, "The backup from path and backup to path must be different.");
                return;
            }
            //test saving defaults
            if (textBackupFromPath.Text != PrefC.GetString(PrefName.BackupFromPath) ||
                textBackupToPath.Text != PrefC.GetString(PrefName.BackupToPath) ||
                textBackupRestoreFromPath.Text != PrefC.GetString(PrefName.BackupRestoreFromPath) ||
                textBackupRestoreToPath.Text != PrefC.GetString(PrefName.BackupRestoreToPath) ||
                textBackupRestoreAtoZToPath.Text != PrefC.GetString(PrefName.BackupRestoreAtoZToPath))
            {
                if (MsgBox.Show(this, MsgBoxButtons.YesNo, "Set as default?") && SaveTabPrefs())
                {
                    DataValid.SetInvalid(InvalidType.Prefs);
                }
            }
            string dbName = MiscData.GetCurrentDatabase();

            if (InnoDb.HasInnoDbTables(dbName))
            {
                //Database has innodb tables. Backup tool does not work on dbs with InnoDb tables.
                MsgBox.Show(this, "InnoDb tables detected. Backup tool cannot run with InnoDb tables.");
                return;
            }
            if (!Directory.Exists(ODFileUtils.CombinePaths(textBackupFromPath.Text, dbName)))           // C:\mysql\data\opendental
            {
                MsgBox.Show(this, "Backup FROM path is invalid.");
                return;
            }
            if (!Directory.Exists(textBackupToPath.Text))            // D:\
            {
                MsgBox.Show(this, "Backup TO path is invalid.");
                return;
            }
            _errorMessage = "";
            FormP         = new FormProgress();
            FormP.MaxVal  = 100;             //We will be setting maxVal from worker thread.  (double)fileSize/1024;
            FormP.NumberMultiplication = 100;
            FormP.DisplayText          = ""; //We will set the text from the worker thread.
            FormP.NumberFormat         = "N1";
            //start the thread that will perform the database copy
            Thread workerThread = new Thread(new ThreadStart(InstanceMethodBackup));

            workerThread.Start();
            //display the progress dialog to the user:
            FormP.ShowDialog();
            if (FormP.DialogResult == DialogResult.Cancel)
            {
                workerThread.Abort();
                return;
            }
            if (_errorMessage == "")
            {
                SecurityLogs.MakeLogEntry(Permissions.Backup, 0, Lan.g(this, "Database backup created at ") + textBackupToPath.Text);
                MessageBox.Show(Lan.g(this, "Backup complete."));
            }
            else              //Backup failed for some reason.
            {
                MessageBox.Show(_errorMessage);
            }
            Close();
        }
コード例 #8
0
ファイル: FormUpdate.cs プロジェクト: nampn/ODental
 /// <summary>destinationPath includes filename (Setup.exe).  destinationPath2 will create a second copy at the specified path/filename, or it will be skipped if null or empty.</summary>
 public static void DownloadInstallPatchFromURI(string downloadUri,string destinationPath,bool runSetupAfterDownload,bool showShutdownWindow,string destinationPath2)
 {
     string[] dblist=PrefC.GetString(PrefName.UpdateMultipleDatabases).Split(new string[] {","},StringSplitOptions.RemoveEmptyEntries);
     if(showShutdownWindow) {
         //Even if updating multiple databases, extra shutdown signals are not needed.
         FormShutdown FormSD=new FormShutdown();
         FormSD.IsUpdate=true;
         FormSD.ShowDialog();
         if(FormSD.DialogResult==DialogResult.OK) {
             //turn off signal reception for 5 seconds so this workstation will not shut down.
             FormOpenDental.signalLastRefreshed=MiscData.GetNowDateTime().AddSeconds(5);
             Signalod sig=new Signalod();
             sig.ITypes=((int)InvalidType.ShutDownNow).ToString();
             sig.SigType=SignalType.Invalid;
             Signalods.Insert(sig);
             Computers.ClearAllHeartBeats(Environment.MachineName);//always assume success
             //SecurityLogs.MakeLogEntry(Permissions.Setup,0,"Shutdown all workstations.");//can't do this because sometimes no user.
         }
         //continue on even if user clicked cancel
         //no other workstation will be able to start up until this value is reset.
         Prefs.UpdateString(PrefName.UpdateInProgressOnComputerName,Environment.MachineName);
     }
     MiscData.LockWorkstationsForDbs(dblist);//lock workstations for other db's.
     File.Delete(destinationPath);
     WebRequest wr=WebRequest.Create(downloadUri);
     WebResponse webResp=null;
     try{
         webResp=wr.GetResponse();
     }
     catch(Exception ex){
         CodeBase.MsgBoxCopyPaste msgbox=new MsgBoxCopyPaste(ex.Message+"\r\nUri: "+downloadUri);
         msgbox.ShowDialog();
         MiscData.UnlockWorkstationsForDbs(dblist);//unlock workstations since nothing was actually done.
         return;
     }
     int fileSize=(int)webResp.ContentLength/1024;
     FormProgress FormP=new FormProgress();
     //start the thread that will perform the download
     System.Threading.ThreadStart downloadDelegate= delegate { DownloadInstallPatchWorker(downloadUri,destinationPath,ref FormP); };
     Thread workerThread=new System.Threading.Thread(downloadDelegate);
     workerThread.Start();
     //display the progress dialog to the user:
     FormP.MaxVal=(double)fileSize/1024;
     FormP.NumberMultiplication=100;
     FormP.DisplayText="?currentVal MB of ?maxVal MB copied";
     FormP.NumberFormat="F";
     FormP.ShowDialog();
     if(FormP.DialogResult==DialogResult.Cancel) {
         workerThread.Abort();
         MiscData.UnlockWorkstationsForDbs(dblist);//unlock workstations since nothing was actually done.
         return;
     }
     //copy to second destination directory
     if(destinationPath2!=null && destinationPath2!=""){
         if(File.Exists(destinationPath2)){
             File.Delete(destinationPath2);
         }
         File.Copy(destinationPath,destinationPath2);
     }
     //copy the Setup.exe to the AtoZ folders for the other db's.
     List<string> atozNameList=MiscData.GetAtoZforDb(dblist);
     for(int i=0;i<atozNameList.Count;i++) {
         if(destinationPath==Path.Combine(atozNameList[i],"Setup.exe")) {//if they are sharing an AtoZ folder.
             continue;
         }
         if(Directory.Exists(atozNameList[i])) {
             File.Copy(destinationPath,//copy the Setup.exe that was just downloaded to this AtoZ folder
                 Path.Combine(atozNameList[i],"Setup.exe"),//to the other atozFolder
                 true);//overwrite
         }
     }
     if(!runSetupAfterDownload) {
         return;
     }
     string msg=Lan.g("FormUpdate","Download succeeded.  Setup program will now begin.  When done, restart the program on this computer, then on the other computers.");
     if(dblist.Length > 0){
         msg="Download succeeded.  Setup file probably copied to other AtoZ folders as well.  Setup program will now begin.  When done, restart the program for each database on this computer, then on the other computers.";
     }
     if(MessageBox.Show(msg,"",MessageBoxButtons.OKCancel) !=DialogResult.OK){
         //Clicking cancel gives the user a chance to avoid running the setup program,
         Prefs.UpdateString(PrefName.UpdateInProgressOnComputerName,"");//unlock workstations, since nothing was actually done.
         return;
     }
     try{
         Process.Start(destinationPath);
         Application.Exit();
     }
     catch{
         Prefs.UpdateString(PrefName.UpdateInProgressOnComputerName,"");//unlock workstations, since nothing was actually done.
         MsgBox.Show(FormP,"Could not launch setup");
     }
 }
コード例 #9
0
        ///<summary>Moves all MedLab objects and any embedded PDFs tied to the MedLabResults to the PatCur.
        ///If the MedLab objects were not originally attached to a patient, any embedded PDFs will be in the image folder in a directory called
        ///"MedLabEmbeddedFiles" and will be moved to PatCur's image folder.
        ///If PatCur is null or the MedLabs are already attached to PatCur, does nothing.</summary>
        private void MoveLabsAndImagesHelper()
        {
            //if they have selected the same patient, nothing to do
            if (PatCur == null || PatCur.PatNum == _medLabCur.PatNum)
            {
                return;
            }
            //if the MedLab object(s) were attached to a patient and they are being moved to another patient, move the associated documents
            Patient patOld = Patients.GetPat(_medLabCur.PatNum);

            MedLabs.UpdateAllPatNums(ListMedLabs.Select(x => x.MedLabNum).ToList(), PatCur.PatNum);
            string atozFrom = "";
            string atozTo   = "";

            if (PrefC.AtoZfolderUsed == DataStorageType.LocalAtoZ)
            {
                string atozPath = ImageStore.GetPreferredAtoZpath();
                //if patOld is null, the file was placed into the image folder in a directory named MedLabEmbeddedFiles, not a patient's image folder
                if (patOld == null)
                {
                    atozFrom = ODFileUtils.CombinePaths(atozPath, "MedLabEmbeddedFiles");
                }
                else
                {
                    atozFrom = ImageStore.GetPatientFolder(patOld, atozPath);
                }
                atozTo = ImageStore.GetPatientFolder(PatCur, atozPath);
            }
            else if (CloudStorage.IsCloudStorage)
            {
                atozFrom = ODFileUtils.CombinePaths(ImageStore.GetPreferredAtoZpath(), "MedLabEmbeddedFiles", '/');
                atozTo   = ImageStore.GetPatientFolder(PatCur, "");
            }
            //get list of all DocNums of files referenced by MedLabResults which were embedded in the MedLab HL7 message as base64 text
            //in order to move the file (if not storing images in db) and assign (or reassign) the FileName
            List <long> listDocNums = ListMedLabs
                                      .SelectMany(x => x.ListMedLabResults
                                                  .Select(y => y.DocNum)
                                                  .Where(y => y > 0))
                                      .Distinct().ToList();
            List <Document> listDocs         = Documents.GetByNums(listDocNums);
            int             fileMoveFailures = 0;

            for (int i = 0; i < listDocs.Count; i++)
            {
                Document doc          = listDocs[i];
                string   destFileName = Documents.GetUniqueFileNameForPatient(PatCur, doc.DocNum, Path.GetExtension(doc.FileName));
                if (PrefC.AtoZfolderUsed == DataStorageType.LocalAtoZ)
                {
                    string fromFilePath = ODFileUtils.CombinePaths(atozFrom, doc.FileName);
                    if (!File.Exists(fromFilePath))
                    {
                        //the DocNum in the MedLabResults table is pointing to a file that either doesn't exist or is not accessible, can't move/copy it
                        fileMoveFailures++;
                        continue;
                    }
                    string destFilePath = ODFileUtils.CombinePaths(atozTo, destFileName);
                    if (File.Exists(destFilePath))                     //should never happen, since we already got a unique file name, but just in case
                    //The file being copied has the same name as a file that exists in the destination folder, use a unique file name and update document table
                    {
                        destFileName = patOld.PatNum.ToString() + "_" + doc.FileName;                  //try to prepend patient's PatNum to the original file name
                        destFilePath = ODFileUtils.CombinePaths(atozTo, destFileName);
                        while (File.Exists(destFilePath))
                        {
                            //if still not unique, try appending date/time to seconds precision until the file name is unique
                            destFileName = patOld.PatNum.ToString() + "_" + Path.GetFileNameWithoutExtension(doc.FileName)
                                           + "_" + DateTime.Now.ToString("yyyyMMddhhmmss") + Path.GetExtension(doc.FileName);
                            destFilePath = ODFileUtils.CombinePaths(atozTo, destFileName);
                        }
                    }
                    try {
                        File.Copy(fromFilePath, destFilePath);
                    }
                    catch (Exception ex) {
                        ex.DoNothing();
                        fileMoveFailures++;
                        continue;
                    }
                    //try to delete the original file
                    try {
                        File.Delete(fromFilePath);
                    }
                    catch (Exception ex) {
                        ex.DoNothing();
                        //If we cannot delete the file, could be a permission issue or someone has the file open currently
                        //Just skip deleting the file, which means there could be an image in the old pat's folder that may need to be deleted manually
                        fileMoveFailures++;
                    }
                }
                else if (CloudStorage.IsCloudStorage)
                {
                    //move files around in the cloud
                    FormProgress FormP = new FormProgress(false);
                    FormP.DisplayText          = "Uploading...";
                    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.TaskStateMove state = CloudStorage.MoveAsync(atozFrom
                                                                                      , atozTo
                                                                                      , new OpenDentalCloud.ProgressHandler(FormP.OnProgress));
                    FormP.ShowDialog();                    //Don't allow users to cancel from here due to the limitations of the current feature for figuring out which files were moved successfully.
                }
                //if we get here the file was copied successfully or not storing images in the database, so update the document row
                //Safe to update the document FileName and PatNum to PatCur and new file name
                doc.PatNum   = PatCur.PatNum;
                doc.FileName = destFileName;
                Documents.Update(doc);
            }
            ListMedLabs.ForEach(x => x.PatNum = PatCur.PatNum); //update local list, done after moving files
            _medLabCur = ListMedLabs[0];
            if (fileMoveFailures > 0)                           //will never be > 0 if storing images in the db
            {
                MessageBox.Show(Lan.g(this, "Some files attached to the MedLab objects could not be moved.") + "\r\n"
                                + Lan.g(this, "This could be due to a missing file, a file being open, or a permission issue on the file which is preventing the move.") + "\r\n"
                                + Lan.g(this, "The file(s) will have to be moved manually from the Image module.") + "\r\n"
                                + Lan.g(this, "Number of files not moved") + ": " + fileMoveFailures.ToString());
            }
        }
コード例 #10
0
        private void butMerge_Click(object sender, EventArgs e)
        {
            if (_patTo.PatNum == _patFrom.PatNum)
            {
                MsgBox.Show(this, "Cannot merge a patient account into itself. Please select a different patient to merge from.");
                return;
            }
            string msgText = "";

            if (_patFrom.FName.Trim().ToLower() != _patTo.FName.Trim().ToLower() ||
                _patFrom.LName.Trim().ToLower() != _patTo.LName.Trim().ToLower() ||
                _patFrom.Birthdate != _patTo.Birthdate)
            {            //mismatch
                msgText = Lan.g(this, "The two patients do not have the same first name, last name, and birthdate.");
                if (Programs.UsingEcwTightOrFullMode())
                {
                    msgText += "\r\n" + Lan.g(this, "The patients must first be merged from within eCW, then immediately merged in the same order in Open Dental.  "
                                              + "If the patients are not merged in this manner, some information may not properly bridge between eCW and Open Dental.");
                }
                msgText += "\r\n\r\n"
                           + Lan.g(this, "Into patient name") + ": " + Patients.GetNameFLnoPref(_patTo.LName, _patTo.FName, "") + ", "     //using Patients.GetNameFLnoPref to omit MiddleI
                           + Lan.g(this, "Into patient birthdate") + ": " + _patTo.Birthdate.ToShortDateString() + "\r\n"
                           + Lan.g(this, "From patient name") + ": " + Patients.GetNameFLnoPref(_patFrom.LName, _patFrom.FName, "") + ", " //using Patients.GetNameFLnoPref to omit MiddleI
                           + Lan.g(this, "From patient birthdate") + ": " + _patFrom.Birthdate.ToShortDateString() + "\r\n\r\n"
                           + Lan.g(this, "Merge the patient on the bottom into the patient shown on the top?");
                if (MessageBox.Show(msgText, "", MessageBoxButtons.YesNo) != DialogResult.Yes)
                {
                    return;                    //The user chose not to merge
                }
            }
            else              //name and bd match
            {
                if (!MsgBox.Show(this, MsgBoxButtons.YesNo, "Merge the patient at the bottom into the patient shown at the top?"))
                {
                    return;                    //The user chose not to merge.
                }
            }
            if (_patFrom.PatNum == _patFrom.Guarantor)
            {
                Family fam = Patients.GetFamily(_patFrom.PatNum);
                if (fam.ListPats.Length > 1)
                {
                    msgText = Lan.g(this, "The patient you have chosen to merge from is a guarantor.  Merging this patient into another account will cause all "
                                    + "family members of the patient being merged from to be moved into the same family as the patient account being merged into.") + "\r\n"
                              + Lan.g(this, "Do you wish to continue with the merge?");
                    if (MessageBox.Show(msgText, "", MessageBoxButtons.YesNo) != DialogResult.Yes)
                    {
                        return;                        //The user chose not to merge.
                    }
                }
            }
            Cursor = Cursors.WaitCursor;
            List <Task> listPatientTasks  = Tasks.RefreshPatientTickets(_patFrom.PatNum);        //Get this before the merge, because the merge updates Task.KeyNum.
            bool        isSuccessfulMerge = false;

            try {
                isSuccessfulMerge = Patients.MergeTwoPatients(_patTo.PatNum, _patFrom.PatNum);
            }
            catch (Exception ex) {
                SecurityLogs.MakeLogEntry(Permissions.PatientMerge, _patTo.PatNum,
                                          "Error occurred while merging Patient: " + _patFrom.GetNameFL() + "\r\nPatNum From: " + _patFrom.PatNum + "\r\nPatNum To: " + _patTo.PatNum);
                Cursor = Cursors.Default;
                FriendlyException.Show(Lan.g(this, "Unable to fully merge patients.  Contact support."), ex);
            }
            if (isSuccessfulMerge)
            {
                //The patient has been successfully merged.
                #region Refresh Patient's Tasks
                List <Signalod> listSignals = new List <Signalod>();
                foreach (Task task in listPatientTasks)
                {
                    Signalod signal = new Signalod();
                    signal.IType       = InvalidType.Task;
                    signal.FKeyType    = KeyType.Task;
                    signal.FKey        = task.TaskNum;
                    signal.DateViewing = DateTime.MinValue;                  //Mimics Signalods.SetInvalid()
                    listSignals.Add(signal);
                }
                Signalods.SetInvalid(InvalidType.TaskPatient, KeyType.Undefined, _patTo.PatNum); //Ensure anyone viewing Patient tab of new pat gets refreshed.
                Signalods.Insert(listSignals.ToArray());                                         //Refreshes existing tasks in all other tabs.
                //Causes Task area and open Task Edit windows to refresh immediately.  No popups, alright to pass empty lists for listRefreshedTaskNotes and
                //listBlockedTaskLists.
                FormOpenDental.S_HandleRefreshedTasks(listSignals, listPatientTasks.Select(x => x.TaskNum).ToList(), listPatientTasks, new List <TaskNote>()
                                                      , new List <UserOdPref>());
                #endregion
                //Now copy the physical images from the old patient to the new if they are using an AtoZ image share.
                //This has to happen in the UI because the middle tier server might not have access to the image share.
                //If the users are storing images within the database, those images have already been taken care of in the merge method above.
                int fileCopyFailures = 0;
                if (PrefC.AtoZfolderUsed == DataStorageType.LocalAtoZ)
                {
                    #region Copy AtoZ Documents
                    //Move the patient documents within the 'patFrom' A to Z folder to the 'patTo' A to Z folder.
                    //We have to be careful here of documents with the same name. We have to rename such documents
                    //so that no documents are overwritten/lost.
                    string   atoZpath  = ImageStore.GetPreferredAtoZpath();
                    string   atozFrom  = ImageStore.GetPatientFolder(_patFrom, atoZpath);
                    string   atozTo    = ImageStore.GetPatientFolder(_patTo, atoZpath);
                    string[] fromFiles = Directory.GetFiles(atozFrom);
                    if (atozFrom == atozTo)
                    {
                        //Very rarely, two patients have the same image folder.  PatFrom and PatTo both have Documents that point to the same file.  Since we
                        //are about to copy the image file for PatFrom to PatTo's directory and delete the file from PatFrom's directory, we would break the
                        //file reference for PatTo's Document.  In this case, skip deleting the original file, since PatTo's Document still references it.
                        Documents.MergePatientDocuments(_patFrom.PatNum, _patTo.PatNum);
                    }
                    else
                    {
                        foreach (string fileCur in fromFiles)
                        {
                            string fileName     = Path.GetFileName(fileCur);
                            string destFileName = fileName;
                            string destFilePath = ODFileUtils.CombinePaths(atozTo, fileName);
                            if (File.Exists(destFilePath))
                            {
                                //The file being copied has the same name as a possibly different file within the destination a to z folder.
                                //We need to copy the file under a unique file name and then make sure to update the document table to reflect
                                //the change.
                                destFileName = _patFrom.PatNum.ToString() + "_" + fileName;
                                destFilePath = ODFileUtils.CombinePaths(atozTo, destFileName);
                                while (File.Exists(destFilePath))
                                {
                                    destFileName = _patFrom.PatNum.ToString() + "_" + fileName + "_" + DateTime.Now.ToString("yyyyMMddhhmmss");
                                    destFilePath = ODFileUtils.CombinePaths(atozTo, destFileName);
                                }
                            }
                            try {
                                File.Copy(fileCur, destFilePath);                                //Will throw exception if file already exists.
                            }
                            catch (Exception ex) {
                                ex.DoNothing();
                                fileCopyFailures++;
                                continue;                                //copy failed, increment counter and move onto the next file
                            }
                            //If the copy did not fail, try to delete the old file.
                            //We can now safely update the document FileName and PatNum to the "to" patient.
                            Documents.MergePatientDocument(_patFrom.PatNum, _patTo.PatNum, fileName, destFileName);
                            try {
                                File.Delete(fileCur);
                            }
                            catch (Exception ex) {
                                ex.DoNothing();
                                //If we were unable to delete the file then it is probably because someone has the document open currently.
                                //Just skip deleting the file. This means that occasionally there will be an extra file in their backup
                                //which is just clutter but at least the merge is guaranteed this way.
                            }
                        }
                    }
                    #endregion Copy AtoZ Documents
                }                //end if AtoZFolderUsed
                else if (CloudStorage.IsCloudStorage)
                {
                    string atozFrom = ImageStore.GetPatientFolder(_patFrom, "");
                    string atozTo   = ImageStore.GetPatientFolder(_patTo, "");
                    if (atozFrom == atozTo)
                    {
                        //Very rarely, two patients have the same image folder.  PatFrom and PatTo both have Documents that point to the same file.  Since we
                        //are about to copy the image file for PatFrom to PatTo's directory and delete the file from PatFrom's directory, we would break the
                        //file reference for PatTo's Document.  In this case, skip deleting the original file, since PatTo's Document still references it.
                        Documents.MergePatientDocuments(_patFrom.PatNum, _patTo.PatNum);
                    }
                    else
                    {
                        FormProgress FormP = new FormProgress();
                        FormP.DisplayText          = "Moving Documents...";
                        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.TaskStateMove state = CloudStorage.MoveAsync(atozFrom
                                                                                          , atozTo
                                                                                          , new OpenDentalCloud.ProgressHandler(FormP.OnProgress));
                        if (FormP.ShowDialog() == DialogResult.Cancel)
                        {
                            state.DoCancel   = true;
                            fileCopyFailures = state.CountTotal - state.CountSuccess;
                        }
                        else
                        {
                            fileCopyFailures = state.CountFailed;
                        }
                    }
                }
                Cursor = Cursors.Default;
                if (fileCopyFailures > 0)
                {
                    MessageBox.Show(Lan.g(this, "Some files belonging to the from patient were not copied.") + "\r\n"
                                    + Lan.g(this, "Number of files not copied") + ": " + fileCopyFailures);
                }
                //Make log entry here not in parent form because we can merge multiple patients at a time.
                SecurityLogs.MakeLogEntry(Permissions.PatientMerge, _patTo.PatNum,
                                          "Patient: " + _patFrom.GetNameFL() + "\r\nPatNum From: " + _patFrom.PatNum + "\r\nPatNum To: " + _patTo.PatNum);
                textPatientIDFrom.Text    = "";
                textPatientNameFrom.Text  = "";
                textPatFromBirthdate.Text = "";
                //This will cause CheckUIState() to disabled the merge button until the user selects a new _patFrom.
                _patFrom = null;
                CheckUIState();
                MsgBox.Show(this, "Patients merged successfully.");
            }            //end MergeTwoPatients
            Cursor = Cursors.Default;
        }
コード例 #11
0
		private void butRestore_Click(object sender, System.EventArgs e) {			
			if(textBackupRestoreFromPath.Text!="" && !textBackupRestoreFromPath.Text.EndsWith(""+Path.DirectorySeparatorChar)){
				MessageBox.Show(Lan.g(this,"Paths must end with ")+Path.DirectorySeparatorChar+".");
				return;
			}
			if(textBackupRestoreToPath.Text!="" && !textBackupRestoreToPath.Text.EndsWith(""+Path.DirectorySeparatorChar)){
				MessageBox.Show(Lan.g(this,"Paths must end with ")+Path.DirectorySeparatorChar+".");
				return;
			}
			if(ShouldUseAtoZFolder()) {
				if(textBackupRestoreAtoZToPath.Text!="" && !textBackupRestoreAtoZToPath.Text.EndsWith(""+Path.DirectorySeparatorChar)){
					MessageBox.Show(Lan.g(this,"Paths must end with ")+Path.DirectorySeparatorChar+".");
					return;
				}
			}
			if(Environment.OSVersion.Platform!=PlatformID.Unix){
				//dmg This check will not work on Linux, because mapped drives exist as regular (mounted) paths. Perhaps there
				//is another way to check for this on Linux.
				if(textBackupRestoreToPath.Text!="" && textBackupRestoreToPath.Text.StartsWith(""+Path.DirectorySeparatorChar)){
					MsgBox.Show(this,"The restore database TO folder must be on this computer.");
					return;
				}
			}
			//pointless to save defaults
			string dbName=MiscData.GetCurrentDatabase();
			if(!Directory.Exists(ODFileUtils.CombinePaths(textBackupRestoreFromPath.Text,dbName))){// D:\opendental
				MessageBox.Show(Lan.g(this,"Restore FROM path is invalid.  Unable to find folder named ")+dbName);
				return;
			}
			if(!Directory.Exists(ODFileUtils.CombinePaths(textBackupRestoreToPath.Text,dbName))) {// C:\mysql\data\opendental
				MessageBox.Show(Lan.g(this,"Restore TO path is invalid.  Unable to find folder named ")+dbName);
				return;
			}
			if(ShouldUseAtoZFolder()) {
				if(!Directory.Exists(textBackupRestoreAtoZToPath.Text)) {// C:\OpenDentalData\
					MsgBox.Show(this,"Restore A-Z images TO path is invalid.");
					return;
				}
				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
				if(!Directory.Exists(ODFileUtils.CombinePaths(textBackupRestoreFromPath.Text,atozDir))){// D:\OpenDentalData
					MsgBox.Show(this,"Restore A-Z images FROM path is invalid.");
					return;
				}
			}
			string fromPath=ODFileUtils.CombinePaths(new string[] {textBackupRestoreFromPath.Text,dbName,""});// D:\opendental\
			DirectoryInfo dirInfo=new DirectoryInfo(fromPath);//does not check to see if dir exists
			if(MessageBox.Show(Lan.g(this,"Restore from backup created on")+"\r\n"
				+dirInfo.LastWriteTime.ToString("dddd")+"  "+dirInfo.LastWriteTime.ToString()
				,"",MessageBoxButtons.OKCancel,MessageBoxIcon.Question)==DialogResult.Cancel) {
				return;
			}
			Cursor=Cursors.WaitCursor;
			//stop the service--------------------------------------------------------------------------------------
			ServiceController sc=new ServiceController("MySQL");
			try{
				sc.Stop();
				sc.WaitForStatus(ServiceControllerStatus.Stopped,new TimeSpan(0,0,10));
			}
			catch{
				MsgBox.Show(this,"Unable to stop MySQL service.");
				return;
			}
			//rename the current database---------------------------------------------------------------------------
			//Get a name for the new directory
			string newDb=dbName+"backup_"+DateTime.Today.ToString("MM_dd_yyyy");
			if(Directory.Exists(ODFileUtils.CombinePaths(textBackupRestoreToPath.Text,newDb))){//if the new database name already exists
				//find a unique one
				int uniqueID=1;
				string originalNewDb=newDb;
				do{
					newDb=originalNewDb+"_"+uniqueID.ToString();
					uniqueID++;
				}
				while(Directory.Exists(ODFileUtils.CombinePaths(textBackupRestoreToPath.Text,newDb)));
			}
			//move the current db (rename)
			Directory.Move(ODFileUtils.CombinePaths(textBackupRestoreToPath.Text,dbName),// C:\mysql\data\opendental
				ODFileUtils.CombinePaths(textBackupRestoreToPath.Text,newDb));// C:\mysql\data\opendentalbackup_03_25_2006
			//Restore----------------------------------------------------------------------------------------------
			string toPath=textBackupRestoreToPath.Text;// C:\mysql\data\
			Directory.CreateDirectory(ODFileUtils.CombinePaths(toPath,dirInfo.Name));
			FileInfo[] files=dirInfo.GetFiles();
			curVal=0;//curVal gets increased
			for(int i=0;i<files.Length;i++){
				File.Copy(files[i].FullName,ODFileUtils.CombinePaths(new string[] {toPath,dirInfo.Name,files[i].Name}));
			}
			//start the service--------------------------------------------------------------------------------------
			try{
				sc.Start();
				sc.WaitForStatus(ServiceControllerStatus.Running,new TimeSpan(0,0,10));
			}
			catch{
				//do nothing
			}
			Cursor=Cursors.Default;
			//restore A-Z folder, and give user a chance to cancel it.
			if(ShouldUseAtoZFolder()) {
				FormP=new FormProgress();
				FormP.MaxVal=100;//We will be setting maxVal from worker thread.  (double)fileSize/1024;
				FormP.NumberMultiplication=100;
				FormP.DisplayText="";//We will set the text from the worker thread.
				FormP.NumberFormat="N1";
				//start the thread that will perform the database copy
				Thread workerThread=new Thread(new ThreadStart(InstanceMethodRestore));
				workerThread.Start();
				//display the progress dialog to the user:
				FormP.ShowDialog();
				if(FormP.DialogResult==DialogResult.Cancel){
					workerThread.Abort();
					return;
				}
			}
			MsgBox.Show(this,"Done");
			PrefL.CheckProgramVersion();//this might force program to close if version mismatch could not be resolved.
			Close();
		}
コード例 #12
0
		private void butBackup_Click(object sender, System.EventArgs e) {
			//test for trailing slashes
			if(textBackupFromPath.Text!="" && !textBackupFromPath.Text.EndsWith(""+Path.DirectorySeparatorChar)){
				MsgBox.Show(this,"Paths must end with "+Path.DirectorySeparatorChar+".");
				return;
			}
			if(textBackupToPath.Text!="" && !textBackupToPath.Text.EndsWith(""+Path.DirectorySeparatorChar)){
				MsgBox.Show(this,"Paths must end with "+Path.DirectorySeparatorChar+".");
				return;
			}
			if(textBackupRestoreFromPath.Text!="" && !textBackupRestoreFromPath.Text.EndsWith(""+Path.DirectorySeparatorChar)) {
				MsgBox.Show(this,"Paths must end with "+Path.DirectorySeparatorChar+".");
				return;
			}
			if(textBackupRestoreToPath.Text!="" && !textBackupRestoreToPath.Text.EndsWith(""+Path.DirectorySeparatorChar)) {
				MsgBox.Show(this,"Paths must end with "+Path.DirectorySeparatorChar+".");
				return;
			}
			if(textBackupRestoreAtoZToPath.Text!="" && !textBackupRestoreAtoZToPath.Text.EndsWith(""+Path.DirectorySeparatorChar)) {
				MsgBox.Show(this,"Paths must end with "+Path.DirectorySeparatorChar+".");
				return;
			}
			//Ensure that the backup from and backup to paths are different. This is to prevent the live database
			//from becoming corrupt.
			if(this.textBackupFromPath.Text.Trim().ToLower()==this.textBackupToPath.Text.Trim().ToLower()) {
				MsgBox.Show(this,"The backup from path and backup to path must be different.");
				return;
			}
			//test saving defaults
			if(textBackupFromPath.Text!=PrefC.GetString(PrefName.BackupFromPath)
				|| textBackupToPath.Text!=PrefC.GetString(PrefName.BackupToPath)
				|| textBackupRestoreFromPath.Text!=PrefC.GetString(PrefName.BackupRestoreFromPath)
				|| textBackupRestoreToPath.Text!=PrefC.GetString(PrefName.BackupRestoreToPath)
				|| textBackupRestoreAtoZToPath.Text!=PrefC.GetString(PrefName.BackupRestoreAtoZToPath))
			{
				if(MsgBox.Show(this,true,"Set as default?")){
					Prefs.UpdateString(PrefName.BackupFromPath,textBackupFromPath.Text);
					Prefs.UpdateString(PrefName.BackupToPath,textBackupToPath.Text);
					Prefs.UpdateString(PrefName.BackupRestoreFromPath,textBackupRestoreFromPath.Text);
					Prefs.UpdateString(PrefName.BackupRestoreToPath,textBackupRestoreToPath.Text);
					Prefs.UpdateString(PrefName.BackupRestoreAtoZToPath,textBackupRestoreAtoZToPath.Text);
					DataValid.SetInvalid(InvalidType.Prefs);
				}
			}
			string dbName=MiscData.GetCurrentDatabase();
			if(!Directory.Exists(ODFileUtils.CombinePaths(textBackupFromPath.Text,dbName))){// C:\mysql\data\opendental
				MsgBox.Show(this,"Backup FROM path is invalid.");
				return;
			}
			if(!Directory.Exists(textBackupToPath.Text)){// D:\
				MsgBox.Show(this,"Backup TO path is invalid.");
				return;
			}
			FormP=new FormProgress();
			FormP.MaxVal=100;//We will be setting maxVal from worker thread.  (double)fileSize/1024;
			FormP.NumberMultiplication=100;
			FormP.DisplayText="";//We will set the text from the worker thread.
			FormP.NumberFormat="N1";
			//start the thread that will perform the database copy
			Thread workerThread=new Thread(new ThreadStart(InstanceMethodBackup));
			workerThread.Start();
			//display the progress dialog to the user:
			FormP.ShowDialog();
			if(FormP.DialogResult==DialogResult.Cancel){
				workerThread.Abort();
				return;
			}
			SecurityLogs.MakeLogEntry(Permissions.Copy,0,"Database backup created at "+PrefC.GetString(PrefName.BackupToPath));
			MessageBox.Show(Lan.g(this,"Backup complete."));
			Close();
		}
コード例 #13
0
        private void butDownloadClaimform_Click(object sender, EventArgs e)
        {
            Cursor = Cursors.WaitCursor;
            //Application.DoEvents();
            string      remoteUri = textWebsitePath.Text + textRegClaimform.Text + "/";
            WebRequest  wr;
            WebResponse webResp;

            //int fileSize;
            //copy image file-------------------------------------------------------------------------------
            if (BackgroundImg != "")
            {
                myStringWebResource = remoteUri + BackgroundImg;
                WriteToFile         = PrefB.GetString("DocPath") + BackgroundImg;
                if (File.Exists(WriteToFile))
                {
                    File.Delete(WriteToFile);
                }
                wr = WebRequest.Create(myStringWebResource);
                int fileSize;
                try{
                    webResp  = wr.GetResponse();
                    fileSize = (int)webResp.ContentLength / 1024;
                }
                catch (Exception ex) {
                    Cursor = Cursors.Default;
                    MessageBox.Show("Error downloading " + BackgroundImg + ". " + ex.Message);
                    return;
                    //fileSize=0;
                }
                if (fileSize > 0)
                {
                    //start the thread that will perform the download
                    Thread workerThread = new Thread(new ThreadStart(InstanceMethod));
                    workerThread.Start();
                    //display the progress dialog to the user:
                    FormP        = new FormProgress();
                    FormP.MaxVal = (double)fileSize / 1024;
                    FormP.NumberMultiplication = 100;
                    FormP.DisplayText          = "?currentVal MB of ?maxVal MB copied";
                    FormP.NumberFormat         = "F";
                    FormP.ShowDialog();
                    if (FormP.DialogResult == DialogResult.Cancel)
                    {
                        workerThread.Abort();
                        Cursor = Cursors.Default;
                        return;
                    }
                    MsgBox.Show(this, "Image file downloaded successfully.");
                }
            }
            Cursor = Cursors.WaitCursor;          //have to do this again for some reason.
            //Import ClaimForm.xml----------------------------------------------------------------------------------
            myStringWebResource = remoteUri + "ClaimForm.xml";
            WriteToFile         = PrefB.GetString("DocPath") + "ClaimForm.xml";
            if (File.Exists(WriteToFile))
            {
                File.Delete(WriteToFile);
            }
            try{
                InstanceMethod();
            }
            catch {
            }
            int rowsAffected;

            if (File.Exists(WriteToFile))
            {
                int newclaimformnum = 0;
                try{
                    newclaimformnum = FormClaimForms.ImportForm(WriteToFile, true);
                }
                catch (ApplicationException ex) {
                    Cursor = Cursors.Default;
                    MessageBox.Show(ex.Message);
                    return;
                }
                finally{
                    File.Delete(WriteToFile);
                }
                if (newclaimformnum != 0)
                {
                    Prefs.UpdateInt("DefaultClaimForm", newclaimformnum);
                }
                //switch all insplans over to new claimform
                ClaimForm oldform = null;
                for (int i = 0; i < ClaimForms.ListLong.Length; i++)
                {
                    if (ClaimForms.ListLong[i].UniqueID == OldClaimFormID)
                    {
                        oldform = ClaimForms.ListLong[i];
                    }
                }
                if (oldform != null)
                {
                    rowsAffected = InsPlans.ConvertToNewClaimform(oldform.ClaimFormNum, newclaimformnum);
                    MessageBox.Show("Number of insurance plans changed to new form: " + rowsAffected.ToString());
                }
                DataValid.SetInvalid(InvalidTypes.ClaimForms | InvalidTypes.Prefs);
            }
            //Import ProcCodes.xml------------------------------------------------------------------------------------
            myStringWebResource = remoteUri + "ProcCodes.xml";
            WriteToFile         = PrefB.GetString("DocPath") + "ProcCodes.xml";
            if (File.Exists(WriteToFile))
            {
                File.Delete(WriteToFile);
            }
            try {
                InstanceMethod();
            }
            catch {
            }
            if (File.Exists(WriteToFile))
            {
                //move T codes over to a new "Obsolete" category which is hidden
                ProcedureCodes.TcodesMove();
                rowsAffected = 0;
                try {
                    rowsAffected = FormProcCodes.ImportProcCodes(WriteToFile, false);
                }
                catch (ApplicationException ex) {
                    Cursor = Cursors.Default;
                    MessageBox.Show(ex.Message);
                    return;
                }
                finally {
                    File.Delete(WriteToFile);
                }
                ProcedureCodes.Refresh();                //?
                MessageBox.Show("Procedure codes inserted: " + rowsAffected.ToString());
                //Change all procbuttons and autocodes from T to D.
                ProcedureCodes.TcodesAlter();
                DataValid.SetInvalid(InvalidTypes.AutoCodes | InvalidTypes.Defs | InvalidTypes.ProcCodes | InvalidTypes.ProcButtons);
            }
            MsgBox.Show(this, "Done");
            Cursor = Cursors.Default;
        }
コード例 #14
0
        private void butRestore_Click(object sender, System.EventArgs e)
        {
            if (textBackupRestoreFromPath.Text != "" && !textBackupRestoreFromPath.Text.EndsWith("" + Path.DirectorySeparatorChar))
            {
                MessageBox.Show(Lan.g(this, "Paths must end with ") + Path.DirectorySeparatorChar + ".");
                return;
            }
            if (textBackupRestoreToPath.Text != "" && !textBackupRestoreToPath.Text.EndsWith("" + Path.DirectorySeparatorChar))
            {
                MessageBox.Show(Lan.g(this, "Paths must end with ") + Path.DirectorySeparatorChar + ".");
                return;
            }
            if (ShouldUseAtoZFolder())
            {
                if (textBackupRestoreAtoZToPath.Text != "" && !textBackupRestoreAtoZToPath.Text.EndsWith("" + Path.DirectorySeparatorChar))
                {
                    MessageBox.Show(Lan.g(this, "Paths must end with ") + Path.DirectorySeparatorChar + ".");
                    return;
                }
            }
            if (Environment.OSVersion.Platform != PlatformID.Unix)
            {
                //dmg This check will not work on Linux, because mapped drives exist as regular (mounted) paths. Perhaps there
                //is another way to check for this on Linux.
                if (textBackupRestoreToPath.Text != "" && textBackupRestoreToPath.Text.StartsWith("" + Path.DirectorySeparatorChar))
                {
                    MsgBox.Show(this, "The restore database TO folder must be on this computer.");
                    return;
                }
            }
            //pointless to save defaults
            string dbName = MiscData.GetCurrentDatabase();

            if (InnoDb.HasInnoDbTables(dbName))
            {
                //Database has innodb tables. Restore tool does not work on dbs with InnoDb tables.
                MsgBox.Show(this, "InnoDb tables detected. Restore tool cannot run with InnoDb tables.");
                return;
            }
            if (!Directory.Exists(ODFileUtils.CombinePaths(textBackupRestoreFromPath.Text, dbName)))           // D:\opendental
            {
                MessageBox.Show(Lan.g(this, "Restore FROM path is invalid.  Unable to find folder named ") + dbName);
                return;
            }
            if (!Directory.Exists(ODFileUtils.CombinePaths(textBackupRestoreToPath.Text, dbName)))            // C:\mysql\data\opendental
            {
                MessageBox.Show(Lan.g(this, "Restore TO path is invalid.  Unable to find folder named ") + dbName);
                return;
            }
            if (ShouldUseAtoZFolder())
            {
                if (!Directory.Exists(textBackupRestoreAtoZToPath.Text))                 // C:\OpenDentalData\
                {
                    MsgBox.Show(this, "Restore A-Z images TO path is invalid.");
                    return;
                }
                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
                if (!Directory.Exists(ODFileUtils.CombinePaths(textBackupRestoreFromPath.Text, atozDir)))   // D:\OpenDentalData
                {
                    MsgBox.Show(this, "Restore A-Z images FROM path is invalid.");
                    return;
                }
            }
            string        fromPath = ODFileUtils.CombinePaths(new string[] { textBackupRestoreFromPath.Text, dbName, "" }); // D:\opendental\
            DirectoryInfo dirInfo  = new DirectoryInfo(fromPath);                                                           //does not check to see if dir exists

            if (MessageBox.Show(Lan.g(this, "Restore from backup created on") + "\r\n"
                                + dirInfo.LastWriteTime.ToString("dddd") + "  " + dirInfo.LastWriteTime.ToString()
                                , "", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.Cancel)
            {
                return;
            }
            Cursor = Cursors.WaitCursor;
            //stop the service--------------------------------------------------------------------------------------
            ServiceController sc = new ServiceController("MySQL");

            if (!ServicesHelper.Stop(sc))
            {
                MsgBox.Show(this, "Unable to stop MySQL service.");
                Cursor = Cursors.Default;
                return;
            }
            //rename the current database---------------------------------------------------------------------------
            //Get a name for the new directory
            string newDb = dbName + "backup_" + DateTime.Today.ToString("MM_dd_yyyy");

            if (Directory.Exists(ODFileUtils.CombinePaths(textBackupRestoreToPath.Text, newDb)))           //if the new database name already exists
            //find a unique one
            {
                int    uniqueID      = 1;
                string originalNewDb = newDb;
                do
                {
                    newDb = originalNewDb + "_" + uniqueID.ToString();
                    uniqueID++;
                }while(Directory.Exists(ODFileUtils.CombinePaths(textBackupRestoreToPath.Text, newDb)));
            }
            //move the current db (rename)
            Directory.Move(ODFileUtils.CombinePaths(textBackupRestoreToPath.Text, dbName)
                           , ODFileUtils.CombinePaths(textBackupRestoreToPath.Text, newDb));
            //Restore----------------------------------------------------------------------------------------------
            string toPath = textBackupRestoreToPath.Text;          // C:\mysql\data\

            Directory.CreateDirectory(ODFileUtils.CombinePaths(toPath, dirInfo.Name));
            FileInfo[] files = dirInfo.GetFiles();
            curVal = 0;          //curVal gets increased
            for (int i = 0; i < files.Length; i++)
            {
                File.Copy(files[i].FullName, ODFileUtils.CombinePaths(new string[] { toPath, dirInfo.Name, files[i].Name }));
            }
            //start the service--------------------------------------------------------------------------------------
            ServicesHelper.Start(sc);
            Cursor = Cursors.Default;
            //restore A-Z folder, and give user a chance to cancel it.
            if (ShouldUseAtoZFolder())
            {
                FormP        = new FormProgress();
                FormP.MaxVal = 100;              //We will be setting maxVal from worker thread.  (double)fileSize/1024;
                FormP.NumberMultiplication = 100;
                FormP.DisplayText          = ""; //We will set the text from the worker thread.
                FormP.NumberFormat         = "N1";
                //start the thread that will perform the database copy
                Thread workerThread = new Thread(new ThreadStart(InstanceMethodRestore));
                workerThread.Start();
                //display the progress dialog to the user:
                FormP.ShowDialog();
                if (FormP.DialogResult == DialogResult.Cancel)
                {
                    workerThread.Abort();
                    return;
                }
            }
            Version programVersionDb  = new Version(PrefC.GetStringNoCache(PrefName.ProgramVersion));
            Version programVersionCur = new Version(Application.ProductVersion);

            if (programVersionDb != programVersionCur)
            {
                MsgBox.Show(this, "The restored database version is different than the version installed and requires a restart.  The program will now close.");
                FormOpenDental.S_ProcessKillCommand();
                return;
            }
            else
            {
                DataValid.SetInvalid(Cache.GetAllCachedInvalidTypes().ToArray());
            }
            MsgBox.Show(this, "Done");
            Close();
            return;
        }
コード例 #15
0
        private void SaveAttachment()
        {
            Patient PatCur = Patients.GetPat(PatNum);

            //if(PatCur.ImageFolder=="") {
            //	MsgBox.Show(this,"Invalid patient image folder.");
            //	return;
            //}
            if (PrefC.AtoZfolderUsed == DataStorageType.InDatabase)
            {
                MsgBox.Show(this, "Error. Not using AtoZ images folder.");
                return;
            }
            string patfolder = ImageStore.GetPatientFolder(PatCur, ImageStore.GetPreferredAtoZpath());
            //ODFileUtils.CombinePaths(
            //FormPath.GetPreferredImagePath(),PatCur.ImageFolder.Substring(0,1).ToUpper(),PatCur.ImageFolder);
            //if(!Directory.Exists(patfolder)) {
            //	MsgBox.Show(this,"Patient folder not found in AtoZ folder.");
            //	return;
            //}
            Document doc = Docs[gridMain.GetSelectedIndex()];

            if (!ImageHelper.HasImageExtension(doc.FileName))
            {
                MsgBox.Show(this, "Invalid file.  Only images may be attached, no other file format.");
                return;
            }
            string oldPath = ODFileUtils.CombinePaths(patfolder, doc.FileName);
            Random rnd     = new Random();
            string newName = DateTime.Now.ToString("yyyyMMdd") + "_" + DateTime.Now.TimeOfDay.Ticks.ToString() + rnd.Next(1000).ToString()
                             + Path.GetExtension(oldPath);
            string attachPath = EmailAttaches.GetAttachPath();
            string newPath    = ODFileUtils.CombinePaths(attachPath, newName);

            if (CloudStorage.IsCloudStorage)
            {
                oldPath = oldPath.Replace("\\", "/");
                newPath = newPath.Replace("\\", "/");
            }
            try {
                if (ImageHelper.HasImageExtension(oldPath))
                {
                    if (doc.CropH != 0 ||
                        doc.CropW != 0 ||
                        doc.CropX != 0 ||
                        doc.CropY != 0 ||
                        doc.DegreesRotated != 0 ||
                        doc.IsFlipped ||
                        doc.WindowingMax != 0 ||
                        doc.WindowingMin != 0 ||
                        CloudStorage.IsCloudStorage)
                    {
                        //this does result in a significantly larger images size if jpg.  A later optimization would recompress it.
                        Bitmap bitmapold = null;
                        if (PrefC.AtoZfolderUsed == DataStorageType.LocalAtoZ)
                        {
                            bitmapold = (Bitmap)Bitmap.FromFile(oldPath);
                            Bitmap bitmapnew = ImageHelper.ApplyDocumentSettingsToImage(doc, bitmapold, ImageSettingFlags.ALL);
                            bitmapnew.Save(newPath);
                        }
                        else if (CloudStorage.IsCloudStorage)
                        {
                            //First, download the file.
                            FormProgress FormP = new FormProgress();
                            FormP.DisplayText          = "Downloading Image...";
                            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(patfolder
                                                                                                      , doc.FileName
                                                                                                      , new OpenDentalCloud.ProgressHandler(FormP.OnProgress));
                            FormP.ShowDialog();
                            if (FormP.DialogResult == DialogResult.Cancel)
                            {
                                state.DoCancel = true;
                                return;
                            }
                            //Successfully downloaded, now do stuff with state.FileContent
                            FormP                      = new FormProgress();
                            FormP.DisplayText          = "Uploading Image for Claim Attach...";
                            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.TaskStateUpload state2 = CloudStorage.UploadAsync(attachPath
                                                                                                   , newName
                                                                                                   , state.FileContent
                                                                                                   , new OpenDentalCloud.ProgressHandler(FormP.OnProgress));
                            FormP.ShowDialog();
                            if (FormP.DialogResult == DialogResult.Cancel)
                            {
                                state2.DoCancel = true;
                                return;
                            }
                            //Upload was successful
                        }
                    }
                    else
                    {
                        File.Copy(oldPath, newPath);
                    }
                }
                else
                {
                    File.Copy(oldPath, newPath);
                }
                ClaimAttachNew = new ClaimAttach();
                ClaimAttachNew.DisplayedFileName = Docs[gridMain.GetSelectedIndex()].FileName;
                ClaimAttachNew.ActualFileName    = newName;
                DialogResult = DialogResult.OK;
            }
            catch (FileNotFoundException ex) {
                MessageBox.Show(Lan.g(this, "File not found: ") + ex.Message);
                return;
            }
            catch (Exception ex) {
                MessageBox.Show(ex.Message);
            }
        }
コード例 #16
0
ファイル: FormUpdate.cs プロジェクト: mnisl/OD
		/// <summary>destinationPath includes filename (Setup.exe).  destinationPath2 will create a second copy at the specified path/filename, or it will be skipped if null or empty.</summary>
		public static void DownloadInstallPatchFromURI(string downloadUri,string destinationPath,bool runSetupAfterDownload,bool showShutdownWindow,string destinationPath2){
			string[] dblist=PrefC.GetString(PrefName.UpdateMultipleDatabases).Split(new string[] {","},StringSplitOptions.RemoveEmptyEntries);
			if(showShutdownWindow) {
				//Even if updating multiple databases, extra shutdown signals are not needed.
				FormShutdown FormSD=new FormShutdown();
				FormSD.IsUpdate=true;
				FormSD.ShowDialog();
				if(FormSD.DialogResult==DialogResult.OK) {
					//turn off signal reception for 5 seconds so this workstation will not shut down.
					FormOpenDental.signalLastRefreshed=MiscData.GetNowDateTime().AddSeconds(5);
					Signalod sig=new Signalod();
					sig.ITypes=((int)InvalidType.ShutDownNow).ToString();
					sig.SigType=SignalType.Invalid;
					Signalods.Insert(sig);
					Computers.ClearAllHeartBeats(Environment.MachineName);//always assume success
					//SecurityLogs.MakeLogEntry(Permissions.Setup,0,"Shutdown all workstations.");//can't do this because sometimes no user.
				}
				//continue on even if user clicked cancel
				//no other workstation will be able to start up until this value is reset.
				Prefs.UpdateString(PrefName.UpdateInProgressOnComputerName,Environment.MachineName);
			}
			MiscData.LockWorkstationsForDbs(dblist);//lock workstations for other db's.
			File.Delete(destinationPath);
			WebRequest wr=WebRequest.Create(downloadUri);
			WebResponse webResp=null;
			try{
				webResp=wr.GetResponse();
			}
			catch(Exception ex){
				CodeBase.MsgBoxCopyPaste msgbox=new MsgBoxCopyPaste(ex.Message+"\r\nUri: "+downloadUri);
				msgbox.ShowDialog();
				MiscData.UnlockWorkstationsForDbs(dblist);//unlock workstations since nothing was actually done.
				return;
			}
			int fileSize=(int)webResp.ContentLength/1024;
			FormProgress FormP=new FormProgress();
			//start the thread that will perform the download
			System.Threading.ThreadStart downloadDelegate= delegate { DownloadInstallPatchWorker(downloadUri,destinationPath,ref FormP); };
			Thread workerThread=new System.Threading.Thread(downloadDelegate);
			workerThread.Start();
			//display the progress dialog to the user:
			FormP.MaxVal=(double)fileSize/1024;
			FormP.NumberMultiplication=100;
			FormP.DisplayText="?currentVal MB of ?maxVal MB copied";
			FormP.NumberFormat="F";
			FormP.ShowDialog();
			if(FormP.DialogResult==DialogResult.Cancel) {
				workerThread.Abort();
				MiscData.UnlockWorkstationsForDbs(dblist);//unlock workstations since nothing was actually done.
				return;
			}
			//copy to second destination directory
			if(destinationPath2!=null && destinationPath2!=""){
				if(File.Exists(destinationPath2)){
					File.Delete(destinationPath2);
				}
				File.Copy(destinationPath,destinationPath2);
			}
			//copy the Setup.exe to the AtoZ folders for the other db's.
			List<string> atozNameList=MiscData.GetAtoZforDb(dblist);
			for(int i=0;i<atozNameList.Count;i++) {
				if(destinationPath==Path.Combine(atozNameList[i],"Setup.exe")) {//if they are sharing an AtoZ folder.
					continue;
				}
				if(Directory.Exists(atozNameList[i])) {
					File.Copy(destinationPath,//copy the Setup.exe that was just downloaded to this AtoZ folder
						Path.Combine(atozNameList[i],"Setup.exe"),//to the other atozFolder
						true);//overwrite
				}
			}
			if(!runSetupAfterDownload) {
				return;
			}
			string msg=Lan.g("FormUpdate","Download succeeded.  Setup program will now begin.  When done, restart the program on this computer, then on the other computers.");
			if(dblist.Length > 0){
				msg="Download succeeded.  Setup file probably copied to other AtoZ folders as well.  Setup program will now begin.  When done, restart the program for each database on this computer, then on the other computers.";
			}
			if(MessageBox.Show(msg,"",MessageBoxButtons.OKCancel) !=DialogResult.OK){
				//Clicking cancel gives the user a chance to avoid running the setup program,
				Prefs.UpdateString(PrefName.UpdateInProgressOnComputerName,"");//unlock workstations, since nothing was actually done.
				return;
			}
			#region Stop OpenDent Services
			//If the update has been initiated from the designated update server then try and stop all "OpenDent..." services.
			//They will be automatically restarted once Open Dental has successfully upgraded.
			if(PrefC.GetString(PrefName.WebServiceServerName)!="" && ODEnvironment.IdIsThisComputer(PrefC.GetString(PrefName.WebServiceServerName))) {
				List<ServiceController> listServices=ODEnvironment.GetAllOpenDentServices();
				StringBuilder strBuilder=new StringBuilder();
				if(listServices.Count>0) {
					FormAlertSimple FormAS=new FormAlertSimple(Lan.g("FormUpdate","Stopping services..."));
					FormAS.Show();
					Application.DoEvents();//Allows the form to show up on top of FormUpdate right away.
					//Loop through all Open Dental services and stop them if they have not stopped or are not pending a stop so that their binaries can be updated.
					for(int i=0;i<listServices.Count;i++) {
						if(listServices[i].Status==ServiceControllerStatus.Stopped || listServices[i].Status==ServiceControllerStatus.StopPending) {
							continue;//Already stopped.  Calling Stop again will guarantee an exception is thrown.  Do not try calling Stop on a stopped service.
						}
						try {
							listServices[i].Stop();
							listServices[i].WaitForStatus(ServiceControllerStatus.Stopped,new TimeSpan(0,0,7));
						}
						catch {
							//An InvalidOperationException will get thrown if the service could not stop.  E.g. the user is not running Open Dental as an administrator.
							strBuilder.AppendLine(listServices[i].DisplayName);
						}
					}
					FormAS.Close();
					//Notify the user to go manually stop the services that could not automatically stop.
					if(strBuilder.ToString()!="") {
						MsgBoxCopyPaste msgBCP=new MsgBoxCopyPaste(Lan.g("FormUpdate","The following services could not be stopped.  You need to manually stop them before continuing.")
						+"\r\n"+strBuilder.ToString());
						msgBCP.ShowDialog();
					}
				}
			}
			#endregion
			try {
				Process.Start(destinationPath);
				Application.Exit();
			}
			catch{
				Prefs.UpdateString(PrefName.UpdateInProgressOnComputerName,"");//unlock workstations, since nothing was actually done.
				MsgBox.Show(FormP,"Could not launch setup");
			}
		}
コード例 #17
0
        ///<summary>Uses sheet framework to generate a PDF file, save it to patient's image folder, and attempt to launch file with defualt reader.
        ///If using ImagesStoredInDB it will not launch PDF. If no valid patient is selected you cannot perform this action.</summary>
        private void butPDF_Click(object sender, EventArgs e)
        {
            if (PatCur == null)           //not attached to a patient when form loaded and they haven't selected a patient to attach to yet
            {
                MsgBox.Show(this, "The Medical Lab must be attached to a patient before the PDF can be saved.");
                return;
            }
            if (PatCur.PatNum > 0 && _medLabCur.PatNum != PatCur.PatNum)         //save the current patient attached to the MedLab if it has been changed
            {
                MoveLabsAndImagesHelper();
            }
            Cursor = Cursors.WaitCursor;
            SheetDef sheetDef = SheetUtil.GetMedLabResultsSheetDef();
            Sheet    sheet    = SheetUtil.CreateSheet(sheetDef, _medLabCur.PatNum);

            SheetFiller.FillFields(sheet, null, null, _medLabCur);
            //create the file in the temp folder location, then import so it works when storing images in the db
            string tempPath = ODFileUtils.CombinePaths(PrefC.GetTempFolderPath(), _medLabCur.PatNum.ToString() + ".pdf");

            SheetPrinting.CreatePdf(sheet, tempPath, null, _medLabCur);
            HL7Def defCur   = HL7Defs.GetOneDeepEnabled(true);
            long   category = defCur.LabResultImageCat;

            if (category == 0)
            {
                category = Defs.GetFirstForCategory(DefCat.ImageCats, true).DefNum;             //put it in the first category.
            }
            //create doc--------------------------------------------------------------------------------------
            OpenDentBusiness.Document docc = null;
            try {
                docc = ImageStore.Import(tempPath, category, Patients.GetPat(_medLabCur.PatNum));
            }
            catch (Exception ex) {
                ex.DoNothing();
                Cursor = Cursors.Default;
                MsgBox.Show(this, "Error saving document.");
                return;
            }
            finally {
                //Delete the temp file since we don't need it anymore.
                try {
                    File.Delete(tempPath);
                }
                catch {
                    //Do nothing.  This file will likely get cleaned up later.
                }
            }
            docc.Description = Lan.g(this, "MedLab Result");
            docc.DateCreated = DateTime.Now;
            Documents.Update(docc);
            string filePathAndName = "";

            if (PrefC.AtoZfolderUsed == DataStorageType.LocalAtoZ)
            {
                string patFolder = ImageStore.GetPatientFolder(Patients.GetPat(_medLabCur.PatNum), ImageStore.GetPreferredAtoZpath());
                filePathAndName = ODFileUtils.CombinePaths(patFolder, docc.FileName);
            }
            else if (CloudStorage.IsCloudStorage)
            {
                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(
                    ImageStore.GetPatientFolder(Patients.GetPat(_medLabCur.PatNum), ImageStore.GetPreferredAtoZpath())
                    , docc.FileName
                    , new OpenDentalCloud.ProgressHandler(FormP.OnProgress));
                if (FormP.ShowDialog() == DialogResult.Cancel)
                {
                    state.DoCancel = true;
                    return;
                }
                filePathAndName = PrefC.GetRandomTempFile(Path.GetExtension(docc.FileName));
                File.WriteAllBytes(filePathAndName, state.FileContent);
            }
            Cursor = Cursors.Default;
            if (filePathAndName != "")
            {
                Process.Start(filePathAndName);
            }
            SecurityLogs.MakeLogEntry(Permissions.SheetEdit, sheet.PatNum, sheet.Description + " from " + sheet.DateTimeSheet.ToShortDateString() + " pdf was created");
            DialogResult = DialogResult.OK;
        }
コード例 #18
0
        private void butMerge_Click(object sender, EventArgs e)
        {
            if (_patTo.PatNum == _patFrom.PatNum)
            {
                MsgBox.Show(this, "Cannot merge a patient account into itself. Please select a different patient to merge from.");
                return;
            }
            string msgText = "";

            if (_patFrom.FName.Trim().ToLower() != _patTo.FName.Trim().ToLower() ||
                _patFrom.LName.Trim().ToLower() != _patTo.LName.Trim().ToLower() ||
                _patFrom.Birthdate != _patTo.Birthdate)
            {            //mismatch
                msgText = Lan.g(this, "The two patients do not have the same first name, last name, and birthdate.");
                if (Programs.UsingEcwTightOrFullMode())
                {
                    msgText += "\r\n" + Lan.g(this, "The patients must first be merged from within eCW, then immediately merged in the same order in Open Dental.  "
                                              + "If the patients are not merged in this manner, some information may not properly bridge between eCW and Open Dental.");
                }
                msgText += "\r\n\r\n"
                           + Lan.g(this, "Into patient name") + ": " + Patients.GetNameFLnoPref(_patTo.LName, _patTo.FName, "") + ", "     //using Patients.GetNameFLnoPref to omit MiddleI
                           + Lan.g(this, "Into patient birthdate") + ": " + _patTo.Birthdate.ToShortDateString() + "\r\n"
                           + Lan.g(this, "From patient name") + ": " + Patients.GetNameFLnoPref(_patFrom.LName, _patFrom.FName, "") + ", " //using Patients.GetNameFLnoPref to omit MiddleI
                           + Lan.g(this, "From patient birthdate") + ": " + _patFrom.Birthdate.ToShortDateString() + "\r\n\r\n"
                           + Lan.g(this, "Merge the patient on the bottom into the patient shown on the top?");
                if (MessageBox.Show(msgText, "", MessageBoxButtons.YesNo) != DialogResult.Yes)
                {
                    return;                    //The user chose not to merge
                }
            }
            else              //name and bd match
            {
                if (!MsgBox.Show(this, MsgBoxButtons.YesNo, "Merge the patient at the bottom into the patient shown at the top?"))
                {
                    return;                    //The user chose not to merge.
                }
            }
            if (_patFrom.PatNum == _patFrom.Guarantor)
            {
                Family fam = Patients.GetFamily(_patFrom.PatNum);
                if (fam.ListPats.Length > 1)
                {
                    msgText = Lan.g(this, "The patient you have chosen to merge from is a guarantor.  Merging this patient into another account will cause all "
                                    + "family members of the patient being merged from to be moved into the same family as the patient account being merged into.") + "\r\n"
                              + Lan.g(this, "Do you wish to continue with the merge?");
                    if (MessageBox.Show(msgText, "", MessageBoxButtons.YesNo) != DialogResult.Yes)
                    {
                        return;                        //The user chose not to merge.
                    }
                }
            }
            Cursor = Cursors.WaitCursor;
            if (Patients.MergeTwoPatients(_patTo.PatNum, _patFrom.PatNum))
            {
                //The patient has been successfully merged.
                //Now copy the physical images from the old patient to the new if they are using an AtoZ image share.
                //This has to happen in the UI because the middle tier server might not have access to the image share.
                //If the users are storing images within the database, those images have already been taken care of in the merge method above.
                int fileCopyFailures = 0;
                if (PrefC.AtoZfolderUsed == DataStorageType.LocalAtoZ)
                {
                    #region Copy AtoZ Documents
                    //Move the patient documents within the 'patFrom' A to Z folder to the 'patTo' A to Z folder.
                    //We have to be careful here of documents with the same name. We have to rename such documents
                    //so that no documents are overwritten/lost.
                    string   atoZpath  = ImageStore.GetPreferredAtoZpath();
                    string   atozFrom  = ImageStore.GetPatientFolder(_patFrom, atoZpath);
                    string   atozTo    = ImageStore.GetPatientFolder(_patTo, atoZpath);
                    string[] fromFiles = Directory.GetFiles(atozFrom);
                    foreach (string fileCur in fromFiles)
                    {
                        string fileName     = Path.GetFileName(fileCur);
                        string destFileName = fileName;
                        string destFilePath = ODFileUtils.CombinePaths(atozTo, fileName);
                        if (File.Exists(destFilePath))
                        {
                            //The file being copied has the same name as a possibly different file within the destination a to z folder.
                            //We need to copy the file under a unique file name and then make sure to update the document table to reflect
                            //the change.
                            destFileName = _patFrom.PatNum.ToString() + "_" + fileName;
                            destFilePath = ODFileUtils.CombinePaths(atozTo, destFileName);
                            while (File.Exists(destFilePath))
                            {
                                destFileName = _patFrom.PatNum.ToString() + "_" + fileName + "_" + DateTime.Now.ToString("yyyyMMddhhmmss");
                                destFilePath = ODFileUtils.CombinePaths(atozTo, destFileName);
                            }
                        }
                        try {
                            File.Copy(fileCur, destFilePath);                            //Will throw exception if file already exists.
                        }
                        catch (Exception ex) {
                            ex.DoNothing();
                            fileCopyFailures++;
                            continue;                            //copy failed, increment counter and move onto the next file
                        }
                        //If the copy did not fail, try to delete the old file.
                        //We can now safely update the document FileName and PatNum to the "to" patient.
                        Documents.MergePatientDocument(_patFrom.PatNum, _patTo.PatNum, fileName, destFileName);
                        try {
                            File.Delete(fileCur);
                        }
                        catch (Exception ex) {
                            ex.DoNothing();
                            //If we were unable to delete the file then it is probably because someone has the document open currently.
                            //Just skip deleting the file. This means that occasionally there will be an extra file in their backup
                            //which is just clutter but at least the merge is guaranteed this way.
                        }
                    }
                    #endregion Copy AtoZ Documents
                }                //end if AtoZFolderUsed
                else if (CloudStorage.IsCloudStorage)
                {
                    string       atozFrom = ImageStore.GetPatientFolder(_patFrom, "");
                    string       atozTo   = ImageStore.GetPatientFolder(_patTo, "");
                    FormProgress FormP    = new FormProgress();
                    FormP.DisplayText          = "Moving Documents...";
                    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.TaskStateMove state = CloudStorage.MoveAsync(atozFrom
                                                                                      , atozTo
                                                                                      , new OpenDentalCloud.ProgressHandler(FormP.OnProgress));
                    if (FormP.ShowDialog() == DialogResult.Cancel)
                    {
                        state.DoCancel   = true;
                        fileCopyFailures = state.CountTotal - state.CountSuccess;
                    }
                    else
                    {
                        fileCopyFailures = state.CountFailed;
                    }
                }
                Cursor = Cursors.Default;
                if (fileCopyFailures > 0)
                {
                    MessageBox.Show(Lan.g(this, "Some files belonging to the from patient were not copied.") + "\r\n"
                                    + Lan.g(this, "Number of files not copied") + ": " + fileCopyFailures);
                }
                textPatientIDFrom.Text    = "";
                textPatientNameFrom.Text  = "";
                textPatFromBirthdate.Text = "";
                CheckUIState();
                //Make log entry here not in parent form because we can merge multiple patients at a time.
                SecurityLogs.MakeLogEntry(Permissions.PatientMerge, _patTo.PatNum,
                                          "Patient: " + _patFrom.GetNameFL() + "\r\nPatNum From: " + _patFrom.PatNum + "\r\nPatNum To: " + _patTo.PatNum);
                MsgBox.Show(this, "Patients merged successfully.");
            }            //end MergeTwoPatients
            Cursor = Cursors.Default;
        }
コード例 #19
0
ファイル: FormUpdate.cs プロジェクト: nampn/ODental
 ///<summary>This is the function that the worker thread uses to actually perform the download.  Can also call this method in the ordinary way if the file to be transferred is short.</summary>
 private static void DownloadInstallPatchWorker(string downloadUri,string destinationPath,ref FormProgress progressIndicator)
 {
     int chunk=10;//KB
     byte[] buffer;
     int i=0;
     WebClient myWebClient=new WebClient();
     Stream readStream=myWebClient.OpenRead(downloadUri);
     BinaryReader br=new BinaryReader(readStream);
     FileStream writeStream=new FileStream(destinationPath,FileMode.Create);
     BinaryWriter bw=new BinaryWriter(writeStream);
     try{
         while(true){
             buffer=br.ReadBytes(chunk*1024);
             if(buffer.Length==0){
                 break;
             }
             double curVal=((double)(chunk*i)+((double)buffer.Length/1024))/1024;
             progressIndicator.CurrentVal=curVal;
             bw.Write(buffer);
             i++;
         }
     }
     catch{//for instance, if abort.
         br.Close();
         bw.Close();
         File.Delete(destinationPath);
     }
     finally{
         br.Close();
         bw.Close();
     }
     //myWebClient.DownloadFile(downloadUri,ODFileUtils.CombinePaths(FormPath.GetPreferredImagePath(),"Setup.exe"));
 }
コード例 #20
0
        private void butPickRxListImage_Click(object sender, EventArgs e)
        {
            if (PrefC.AtoZfolderUsed == DataStorageType.InDatabase)
            {
                MsgBox.Show(this, "This option is not supported with images stored in the database.");
                return;
            }
            FormImageSelect formIS = new FormImageSelect();

            formIS.PatNum = PatCur.PatNum;
            formIS.ShowDialog();
            if (formIS.DialogResult != DialogResult.OK)
            {
                return;
            }
            string   patFolder = ImageStore.GetPatientFolder(PatCur, ImageStore.GetPreferredAtoZpath());
            Document doc       = Documents.GetByNum(formIS.SelectedDocNum);

            if (!ImageStore.HasImageExtension(doc.FileName))
            {
                MsgBox.Show(this, "The selected file is not a supported image type.");
                return;
            }
            textDocDateDesc.Text = doc.DateTStamp.ToShortDateString() + " - " + doc.Description.ToString();
            if (BitmapOriginal != null)
            {
                BitmapOriginal.Dispose();
            }
            if (PrefC.AtoZfolderUsed == DataStorageType.LocalAtoZ)
            {
                BitmapOriginal = ImageStore.OpenImage(doc, patFolder);
            }
            else
            {
                FormProgress FormP = new FormProgress();
                FormP.DisplayText          = "Downloading Image...";
                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(patFolder
                                                                                          , doc.FileName
                                                                                          , new OpenDentalCloud.ProgressHandler(FormP.OnProgress));
                FormP.ShowDialog();
                if (FormP.DialogResult == DialogResult.Cancel)
                {
                    state.DoCancel = true;
                    return;
                }
                else
                {
                    using (MemoryStream ms = new MemoryStream(state.FileContent)) {
                        BitmapOriginal = new Bitmap(ms);
                    }
                }
            }
            Bitmap bitmap = ImageHelper.ApplyDocumentSettingsToImage(doc, BitmapOriginal, ImageSettingFlags.ALL);

            pictBox.BackgroundImage = bitmap;
            resizePictBox();
        }
コード例 #21
0
		private void ShowProgressForm(DateTime changedSince){
			if(checkTroubleshooting.Checked) {
				IsTroubleshootMode=true;
			}
			else {
				IsTroubleshootMode=false;
			}
			DateTime timeSynchStarted=MiscData.GetNowDateTime();
			FormP=new FormProgress();
			FormP.MaxVal=100;//to keep the form from closing until the real MaxVal is set.
			FormP.NumberMultiplication=1;
			FormP.DisplayText="Preparing records for upload.";
			FormP.NumberFormat="F0";
			//start the thread that will perform the upload
			ThreadStart uploadDelegate= delegate { UploadWorker(changedSince,timeSynchStarted); };
			Thread workerThread=new Thread(uploadDelegate);
			workerThread.Start();
			//display the progress dialog to the user:
			FormP.ShowDialog();
			if(FormP.DialogResult==DialogResult.Cancel) {
				workerThread.Abort();
			}
			changed=true;
			textDateTimeLastRun.Text=PrefC.GetDateT(PrefName.MobileSyncDateTimeLastRun).ToShortDateString()+" "+PrefC.GetDateT(PrefName.MobileSyncDateTimeLastRun).ToShortTimeString();
		}
コード例 #22
0
        ///<summary>This is the function that the worker thread uses to actually perform the download.  Can also call this method in the ordinary way if the file to be transferred is short.</summary>
        private static void DownloadInstallPatchWorker(string downloadUri, string destinationPath, ref FormProgress progressIndicator)
        {
            int chunk = 10;          //KB

            byte[]       buffer;
            int          i           = 0;
            WebClient    myWebClient = new WebClient();
            Stream       readStream  = myWebClient.OpenRead(downloadUri);
            BinaryReader br          = new BinaryReader(readStream);
            FileStream   writeStream = new FileStream(destinationPath, FileMode.Create);
            BinaryWriter bw          = new BinaryWriter(writeStream);

            try{
                while (true)
                {
                    buffer = br.ReadBytes(chunk * 1024);
                    if (buffer.Length == 0)
                    {
                        break;
                    }
                    double curVal = ((double)(chunk * i) + ((double)buffer.Length / 1024)) / 1024;
                    progressIndicator.CurrentVal = curVal;
                    bw.Write(buffer);
                    i++;
                }
            }
            catch {           //for instance, if abort.
                br.Close();
                bw.Close();
                File.Delete(destinationPath);
            }
            finally{
                br.Close();
                bw.Close();
            }
            //myWebClient.DownloadFile(downloadUri,ODFileUtils.CombinePaths(FormPath.GetPreferredImagePath(),"Setup.exe"));
        }