Exemplo n.º 1
0
        public static EhrAmendment ImportAmdAttach(string pathImportFrom, EhrAmendment amd)
        {
            string amdFolder   = "";
            string amdFilename = "";

            if (PrefC.AtoZfolderUsed)
            {
                amdFolder   = GetAmdFolder();
                amdFilename = amd.FileName;
            }
            amd.FileName = DateTime.Now.ToString("yyyyMMdd_HHmmss_") + amd.EhrAmendmentNum + Path.GetExtension(pathImportFrom);
            if (Path.GetExtension(pathImportFrom) == "")           //If the file has no extension
            {
                amd.FileName += ".jpg";
            }
            //EhrAmendments.Update(amd);
            //amd=EhrAmendments.GetOne(amd.EhrAmendmentNum);
            try {
                SaveAmdAttach(amd, pathImportFrom, amdFolder);
            }
            catch {
                //EhrAmendments.Delete(amd.EhrAmendmentNum);
                throw;
            }
            if (PrefC.AtoZfolderUsed)
            {
                amd.DateTAppend = DateTime.Now;
                EhrAmendments.Update(amd);
                CleanAmdAttach(amdFilename);
            }
            return(amd);
        }
Exemplo n.º 2
0
 ///<summary>If usingAtoZfoler, then eobFolder must be fully qualified and valid.  If not usingAtoZ folder, this fills the eob.RawBase64 which must then be updated to db.</summary>
 public static void SaveAmdAttach(EhrAmendment amd, string pathSourceFile, string amdFolder)
 {
     if (PrefC.AtoZfolderUsed)
     {
         File.Copy(pathSourceFile, ODFileUtils.CombinePaths(amdFolder, amd.FileName));
     }
     else              //saving to db
     {
         byte[] rawData = File.ReadAllBytes(pathSourceFile);
         amd.RawBase64 = Convert.ToBase64String(rawData);
         EhrAmendments.Update(amd);
     }
 }
Exemplo n.º 3
0
 ///<summary>If usingAtoZfolder, then patFolder must be fully qualified and valid.  If not usingAtoZ folder, this fills the eob.RawBase64 which must then be updated to db.</summary>
 public static void SaveAmdAttach(EhrAmendment amd, Bitmap image, ImageCodecInfo codec, EncoderParameters encoderParameters, string amdFolder)
 {
     if (PrefC.AtoZfolderUsed)
     {
         image.Save(ODFileUtils.CombinePaths(amdFolder, amd.FileName), codec, encoderParameters);
     }
     else              //saving to db
     {
         using (MemoryStream stream = new MemoryStream()) {
             image.Save(stream, codec, encoderParameters);
             byte[] rawData = stream.ToArray();
             amd.RawBase64 = Convert.ToBase64String(rawData);
             EhrAmendments.Update(amd);
         }
     }
 }
Exemplo n.º 4
0
        public static EhrAmendment ImportAmdAttach(Bitmap image, EhrAmendment amd)
        {
            string amdFolder = "";

            if (PrefC.AtoZfolderUsed)
            {
                amdFolder = GetAmdFolder();
            }
            amd.FileName    = DateTime.Now.ToString("yyyyMMdd_HHmmss_") + amd.EhrAmendmentNum;
            amd.FileName   += ".jpg";
            amd.DateTAppend = DateTime.Now;
            EhrAmendments.Update(amd);
            amd = EhrAmendments.GetOne(amd.EhrAmendmentNum);
            long           qualityL = (long)ComputerPrefs.LocalComputer.ScanDocQuality;
            ImageCodecInfo myImageCodecInfo;

            ImageCodecInfo[] encoders;
            encoders         = ImageCodecInfo.GetImageEncoders();
            myImageCodecInfo = null;
            for (int j = 0; j < encoders.Length; j++)
            {
                if (encoders[j].MimeType == "image/jpeg")
                {
                    myImageCodecInfo = encoders[j];
                }
            }
            EncoderParameters myEncoderParameters = new EncoderParameters(1);
            EncoderParameter  myEncoderParameter  = new EncoderParameter(System.Drawing.Imaging.Encoder.Quality, qualityL);

            myEncoderParameters.Param[0] = myEncoderParameter;
            try {
                SaveAmdAttach(amd, image, myImageCodecInfo, myEncoderParameters, amdFolder);
            }
            catch {
                //EhrAmendments.Delete(amd.EhrAmendmentNum);
                throw;
            }
            if (!PrefC.AtoZfolderUsed)
            {
                //EhrAmendments.Update(amd);
                //no thumbnail
            }
            return(amd);
        }
Exemplo n.º 5
0
 ///<summary>Also handles deletion of db object.</summary>
 public static void DeleteAmdAttach(EhrAmendment amendment)
 {
     if (PrefC.AtoZfolderUsed)
     {
         string amdFolder = GetAmdFolder();
         string filePath  = ODFileUtils.CombinePaths(amdFolder, amendment.FileName);
         if (File.Exists(filePath))
         {
             try {
                 File.Delete(filePath);
             }
             catch {
                 MessageBox.Show("Delete was unsuccessful. The file may be in use.");
                 return;
             }                    //file seems to be frequently locked.
         }
     }
     //db
     amendment.DateTAppend = DateTime.MinValue;
     amendment.FileName    = "";
     amendment.RawBase64   = "";
     EhrAmendments.Update(amendment);
 }