Пример #1
0
 private void butExport_Click(object sender, EventArgs e)
 {
     #region Web Build
     if (ODBuild.IsWeb())
     {
         string fileName = ElementCur.SigText + ".wav";
         string tempPath = ODFileUtils.CombinePaths(Path.GetTempPath(), fileName);
         try {
             PIn.Sound(ElementCur.Sound, tempPath);
         }
         catch (ApplicationException ex) {
             MessageBox.Show(ex.Message);
             return;
         }
         ThinfinityUtils.ExportForDownload(tempPath);
         return;
     }
     #endregion Web Build
     saveFileDialog1.FileName   = "";
     saveFileDialog1.DefaultExt = "wav";
     if (saveFileDialog1.ShowDialog() != DialogResult.OK)
     {
         return;
     }
     try {
         PIn.Sound(ElementCur.Sound, saveFileDialog1.FileName);
     }
     catch (ApplicationException ex) {
         MessageBox.Show(ex.Message);
     }
 }
Пример #2
0
        ///<summary>Throws Exception.  Exports all medications to the passed in filename. Throws Exceptions.</summary>
        public static int ExportMedications(string filename, List <Medication> listMedications)
        {
            StringBuilder strBldrOutput = new StringBuilder();

            string encapsulate(string text)
            {
                return("\"" + text.Replace("\"", "\\\"") + "\"");
            }

            foreach (Medication med in listMedications)             //Loop through medications.
            {
                strBldrOutput.AppendLine(encapsulate(med.MedName) + '\t' + encapsulate(Medications.GetGenericName(med.GenericNum)) + '\t' + encapsulate(med.Notes)
                                         + '\t' + encapsulate(POut.Long(med.RxCui)));
            }
            if (ODBuild.IsWeb())
            {
                ThinfinityUtils.ExportForDownload(filename, strBldrOutput.ToString());
            }
            else
            {
                File.WriteAllText(filename, strBldrOutput.ToString());               //Allow Exception to trickle up.
            }
            SecurityLogs.MakeLogEntry(Permissions.Setup, 0,
                                      Lans.g("Medications", "Exported") + " " + POut.Int(listMedications.Count) + " " + Lans.g("Medications", "medications to:") + " " + filename
                                      );
            return(listMedications.Count);
        }
Пример #3
0
        private void butExportGrid_Click(object sender, EventArgs e)
        {
            StringBuilder sb = new StringBuilder();

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

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

            System.IO.File.WriteAllText(filename, sb.ToString());
            if (MsgBox.Show(this, MsgBoxButtons.YesNo, "Would you like to open the file now?"))
            {
                try {
                    System.Diagnostics.Process.Start(filename);
                }
                catch (Exception ex) { ex.DoNothing(); }
            }
        }
Пример #4
0
        private void buttonExport_Click(object sender, EventArgs e)
        {
            string fileName = Lan.g(this, "Treatment Finder");
            string filePath = ODFileUtils.CombinePaths(Path.GetTempPath(), fileName);

            if (ODBuild.IsWeb())
            {
                //file download dialog will come up later, after file is created.
                filePath += ".txt";              //Provide the filepath an extension so that Thinfinity can offer as a download.
            }
            else
            {
                SaveFileDialog saveFileDialog2 = new SaveFileDialog();
                saveFileDialog2.AddExtension = true;
                saveFileDialog2.Title        = Lan.g(this, "Treatment Finder");
                saveFileDialog2.FileName     = Lan.g(this, "Treatment Finder");
                if (!Directory.Exists(PrefC.GetString(PrefName.ExportPath)))
                {
                    try {
                        Directory.CreateDirectory(PrefC.GetString(PrefName.ExportPath));
                        saveFileDialog2.InitialDirectory = PrefC.GetString(PrefName.ExportPath);
                    }
                    catch {
                        //initialDirectory will be blank
                    }
                }
                else
                {
                    saveFileDialog2.InitialDirectory = PrefC.GetString(PrefName.ExportPath);
                }
                saveFileDialog2.Filter      = "Text files(*.txt)|*.txt|Excel Files(*.xls)|*.xls|All files(*.*)|*.*";
                saveFileDialog2.FilterIndex = 0;
                if (saveFileDialog2.ShowDialog() != DialogResult.OK)
                {
                    return;
                }
                filePath = saveFileDialog2.FileName;
            }
            try{
                using (StreamWriter sw = new StreamWriter(filePath, false))
                {
                    sw.WriteLine(string.Join("\t", gridMain.ListGridColumns.Select(x => x.Heading)));
                    gridMain.ListGridRows.ForEach(x => sw.WriteLine(
                                                      string.Join("\t", x.Cells.Select(y => string.Concat(y.Text.Where(z => !z.In('\r', '\n', '\t', '\"')))))));
                }
            }
            catch {
                MessageBox.Show(Lan.g(this, "File in use by another program.  Close and try again."));
                return;
            }
            if (ODBuild.IsWeb())
            {
                ThinfinityUtils.ExportForDownload(filePath);
            }
            else
            {
                MessageBox.Show(Lan.g(this, "File created successfully"));
            }
        }
Пример #5
0
        private void butExport_Click(object sender, EventArgs e)
        {
            if (gridCustomSheet.GetSelectedIndex() == -1)
            {
                MsgBox.Show(this, "Please select a sheet from the list first.");
                return;
            }
            SheetDef             sheetdef           = SheetDefs.GetSheetDef(_listSheetDefs[gridCustomSheet.GetSelectedIndex()].SheetDefNum);
            List <SheetFieldDef> listFieldDefImages = sheetdef.SheetFieldDefs
                                                      .Where(x => x.FieldType == SheetFieldType.Image && x.FieldName != "Patient Info.gif")
                                                      .ToList();

            if (!listFieldDefImages.IsNullOrEmpty())             //Alert them of any images they need to copy if there are any.
            {
                string sheetImagesPath = "";
                ODException.SwallowAnyException(() => {
                    sheetImagesPath = SheetUtil.GetImagePath();
                });
                StringBuilder strBuilder = new StringBuilder();
                strBuilder.AppendLine(Lan.g(this, "The following images will need to be manually imported with the same file name when importing this "
                                            + "sheet to a new environment."));
                strBuilder.AppendLine();
                listFieldDefImages.ForEach(x => strBuilder.AppendLine(ODFileUtils.CombinePaths(sheetImagesPath, x.FieldName)));
                MsgBoxCopyPaste msgBox = new MsgBoxCopyPaste(strBuilder.ToString());
                msgBox.ShowDialog();
            }
            XmlSerializer serializer = new XmlSerializer(typeof(SheetDef));
            string        filename   = "SheetDefCustom.xml";

            if (ODBuild.IsWeb())
            {
                StringBuilder strbuild = new StringBuilder();
                using (XmlWriter writer = XmlWriter.Create(strbuild)) {
                    serializer.Serialize(writer, sheetdef);
                }
                ThinfinityUtils.ExportForDownload(filename, strbuild.ToString());
            }
            else
            {
                SaveFileDialog saveDlg = new SaveFileDialog();
                saveDlg.InitialDirectory = PrefC.GetString(PrefName.ExportPath);
                saveDlg.FileName         = filename;
                if (saveDlg.ShowDialog() != DialogResult.OK)
                {
                    return;
                }
                using (TextWriter writer = new StreamWriter(saveDlg.FileName)) {
                    serializer.Serialize(writer, sheetdef);
                }
            }
            MsgBox.Show(this, "Exported");
        }
Пример #6
0
        ///<summary>Writes a set of serialized AutoNotes and AutoNoteControls in JSON format to the specified path.</summary>
        public static void WriteAutoNotesToJson(List <SerializableAutoNote> listAutoNotes, List <SerializableAutoNoteControl> listAutoNoteControls,
                                                string path)
        {
            //No need to check RemotingRole; no call to db.
            TransferableAutoNotes export = new TransferableAutoNotes(listAutoNotes, listAutoNoteControls);
            string json = JsonConvert.SerializeObject(export);

            if (ODBuild.IsWeb())
            {
                ThinfinityUtils.ExportForDownload(path, json);
            }
            else
            {
                File.WriteAllText(path, json);
            }
        }
Пример #7
0
        ///<summary>Only exports for the current culture.</summary>
        private void butExport_Click(object sender, System.EventArgs e)
        {
            string fileName = CultureInfo.CurrentCulture.Name + ".sql";        //eg en-US.sql
            string filePath = ODFileUtils.CombinePaths(Path.GetTempPath(), fileName);

            if (ODBuild.IsWeb())
            {
                //file download dialog will come up later, after file is created.
            }
            else
            {
                saveFileDialog1.InitialDirectory = Application.StartupPath;
                saveFileDialog1.FileName         = fileName;
                if (saveFileDialog1.ShowDialog() != DialogResult.OK)
                {
                    return;
                }
                filePath = saveFileDialog1.FileName;
            }
            StreamWriter sw = new StreamWriter(filePath, false, System.Text.Encoding.UTF8);

            sw.WriteLine("DELETE FROM languageforeign WHERE Culture='" + CultureInfo.CurrentCulture.Name + "';");
            LanguageForeign[] LFList = LanguageForeigns.GetListForCurrentCulture();
            for (int i = 0; i < LFList.Length; i++)
            {
                sw.WriteLine(
                    "INSERT INTO languageforeign (ClassType,English,Culture,Translation,Comments) VALUES ('" + POut.String(LFList[i].ClassType)
                    + "', '" + POut.String(LFList[i].English)
                    + "', '" + POut.String(LFList[i].Culture)
                    + "', '" + POut.String(LFList[i].Translation)
                    + "', '" + POut.String(LFList[i].Comments) + "');"
                    );
            }            //for
            sw.Close();
            if (ODBuild.IsWeb())
            {
                ThinfinityUtils.ExportForDownload(filePath);
            }
            else
            {
                MessageBox.Show("Done");
            }
        }
Пример #8
0
        private void butExport_Click(object sender, EventArgs e)
        {
            SaveFileDialog sd = new SaveFileDialog()
            {
                Filter           = "PDF (*.pdf)|*.pdf",
                FilterIndex      = 1,
                RestoreDirectory = true,
            };

            if (ODBuild.IsWeb())
            {
                sd.FileName = ODFileUtils.CombinePaths(Path.GetTempPath(), "chart_export.pdf");
            }
            else
            {
                if (sd.ShowDialog() != DialogResult.OK)
                {
                    return;
                }
            }
            using (PdfDocument pdfDoc = new PdfDocument()) {
                //save the chart into the memoryStream as a BitMap
                try {
                    PdfPage page = new PdfPage();
                    pdfDoc.Pages.Add(page);
                    page.Orientation = checkLandscape.Checked ? PdfSharp.PageOrientation.Landscape : PdfSharp.PageOrientation.Portrait;
                    using (XGraphics xGraphics = XGraphics.FromPdfPage(page)) {
                        xGraphics.DrawImage(_bmpSheet, 0, 0, page.Width, page.Height);
                    }
                    pdfDoc.Save(sd.FileName);
                    if (ODBuild.IsWeb())
                    {
                        ThinfinityUtils.ExportForDownload(sd.FileName);
                    }
                    MessageBox.Show(Lans.g(this, "Chart saved."));
                }
                catch (Exception ex) {
                    MessageBox.Show("Chart not saved." + "\r\n" + ex.Source + "\r\n" + ex.Message + "\r\n" + ex.StackTrace);
                }
            }
        }
Пример #9
0
        ///<summary>Export a custom claim form. Even though we could probably allow this for internal claim forms as well,
        ///users can always copy over an internal claim form to a custom form and then export it.</summary>
        private void butExport_Click(object sender, System.EventArgs e)
        {
            if (gridCustom.GetSelectedIndex() == -1)
            {
                MsgBox.Show(this, "Please select a Custom Claim Form first.");
                return;
            }
            ClaimForm claimFormCur = (ClaimForm)gridCustom.ListGridRows[gridCustom.GetSelectedIndex()].Tag;
            string    filename     = "ClaimForm" + claimFormCur.Description + ".xml";

            if (ODBuild.IsWeb())
            {
                StringBuilder strbuild = new StringBuilder();
                using (XmlWriter writer = XmlWriter.Create(strbuild)) {
                    XmlSerializer serializer = new XmlSerializer(typeof(ClaimForm));
                    serializer.Serialize(writer, claimFormCur);
                }
                ThinfinityUtils.ExportForDownload(filename, strbuild.ToString());
                return;
            }
            try {
                using (SaveFileDialog saveDlg = new SaveFileDialog()) {
                    saveDlg.InitialDirectory = PrefC.GetString(PrefName.ExportPath);
                    saveDlg.FileName         = filename;
                    if (saveDlg.ShowDialog() != DialogResult.OK)
                    {
                        return;
                    }
                    XmlSerializer serializer = new XmlSerializer(typeof(ClaimForm));
                    using (TextWriter writer = new StreamWriter(saveDlg.FileName)) {
                        serializer.Serialize(writer, claimFormCur);
                    }
                }
                MsgBox.Show(this, "Exported");
            }
            catch (Exception ex) {
                ex.DoNothing();
                MsgBox.Show(this, "Export failed.  This could be due to lack of permissions in the designated folder.");
            }
        }
        //Copied from FormRpOutstandingIns.cs
        private void butExport_Click(object sender, System.EventArgs e)
        {
            string fileName = Lan.g(this, "Unfinalized Insurance Payments");
            string filePath = ODFileUtils.CombinePaths(Path.GetTempPath(), fileName);

            if (ODBuild.IsWeb())
            {
                //file download dialog will come up later, after file is created.
                filePath += ".txt";              //Provide the filepath an extension so that Thinfinity can offer as a download.
            }
            else
            {
                SaveFileDialog saveFileDialog = new SaveFileDialog();
                saveFileDialog.AddExtension = true;
                saveFileDialog.FileName     = fileName;
                if (!Directory.Exists(PrefC.GetString(PrefName.ExportPath)))
                {
                    try {
                        Directory.CreateDirectory(PrefC.GetString(PrefName.ExportPath));
                        saveFileDialog.InitialDirectory = PrefC.GetString(PrefName.ExportPath);
                    }
                    catch {
                        //initialDirectory will be blank
                    }
                }
                else
                {
                    saveFileDialog.InitialDirectory = PrefC.GetString(PrefName.ExportPath);
                }
                saveFileDialog.Filter      = "Text files(*.txt)|*.txt|Excel Files(*.xls)|*.xls|All files(*.*)|*.*";
                saveFileDialog.FilterIndex = 0;
                if (saveFileDialog.ShowDialog() != DialogResult.OK)
                {
                    return;
                }
                filePath = saveFileDialog.FileName;
            }
            try {
                using (StreamWriter sw = new StreamWriter(filePath, false))
                {
                    String line = "";
                    for (int i = 0; i < gridMain.ListGridColumns.Count; i++)
                    {
                        line += gridMain.ListGridColumns[i].Heading + "\t";
                    }
                    sw.WriteLine(line);
                    for (int i = 0; i < gridMain.ListGridRows.Count; i++)
                    {
                        line = "";
                        for (int j = 0; j < gridMain.ListGridColumns.Count; j++)
                        {
                            line += gridMain.ListGridRows[i].Cells[j].Text;
                            if (j < gridMain.ListGridColumns.Count - 1)
                            {
                                line += "\t";
                            }
                        }
                        sw.WriteLine(line);
                    }
                }
            }
            catch {
                MessageBox.Show(Lan.g(this, "File in use by another program.  Close and try again."));
                return;
            }
            if (ODBuild.IsWeb())
            {
                ThinfinityUtils.ExportForDownload(filePath);
            }
            else
            {
                MessageBox.Show(Lan.g(this, "File created successfully"));
            }
        }