コード例 #1
0
ファイル: ImageStore.cs プロジェクト: nampn/ODental
        /// <summary></summary>
        public static EobAttach ImportEobAttach(string pathImportFrom, long claimPaymentNum)
        {
            string eobFolder = "";

            if (PrefC.UsingAtoZfolder)
            {
                eobFolder = GetEobFolder();
            }
            EobAttach eob = new EobAttach();

            if (Path.GetExtension(pathImportFrom) == "")           //If the file has no extension
            {
                eob.FileName = ".jpg";
            }
            else
            {
                eob.FileName = Path.GetExtension(pathImportFrom);
            }
            eob.DateTCreated    = File.GetLastWriteTime(pathImportFrom);
            eob.ClaimPaymentNum = claimPaymentNum;
            EobAttaches.Insert(eob);            //creates filename and saves to db
            eob = EobAttaches.GetOne(eob.EobAttachNum);
            try {
                SaveEobAttach(eob, pathImportFrom, eobFolder);
                if (PrefC.UsingAtoZfolder)
                {
                    EobAttaches.Update(eob);
                }
            }
            catch {
                EobAttaches.Delete(eob.EobAttachNum);
                throw;
            }
            return(eob);
        }
コード例 #2
0
ファイル: ImageStore.cs プロジェクト: nampn/ODental
 ///<summary>Also handles deletion of db object.</summary>
 public static void DeleteEobAttach(EobAttach eob)
 {
     if (PrefC.UsingAtoZfolder)
     {
         string eobFolder = GetEobFolder();
         string filePath  = ODFileUtils.CombinePaths(eobFolder, eob.FileName);
         if (File.Exists(filePath))
         {
             try {
                 File.Delete(filePath);
             }
             catch { }                    //file seems to be frequently locked.
         }
     }
     //db
     EobAttaches.Delete(eob.EobAttachNum);
 }
コード例 #3
0
ファイル: ImageStore.cs プロジェクト: nampn/ODental
        /// <summary>Saves to either AtoZ folder or to db.  Saves image as a jpg.  Compression will be according to user setting.</summary>
        public static EobAttach ImportEobAttach(Bitmap image, long claimPaymentNum)
        {
            string eobFolder = "";

            if (PrefC.UsingAtoZfolder)
            {
                eobFolder = GetEobFolder();
            }
            EobAttach eob = new EobAttach();

            eob.FileName        = ".jpg";
            eob.DateTCreated    = DateTime.Now;
            eob.ClaimPaymentNum = claimPaymentNum;
            EobAttaches.Insert(eob);            //creates filename and saves to db
            eob = EobAttaches.GetOne(eob.EobAttachNum);
            long           qualityL = PrefC.GetLong(PrefName.ScannerCompression);
            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 {
                SaveEobAttach(eob, image, myImageCodecInfo, myEncoderParameters, eobFolder);
                if (!PrefC.UsingAtoZfolder)
                {
                    EobAttaches.Update(eob);                    //because SaveEobAttach stuck the image in eob.RawBase64.
                    //no thumbnail
                }
            }
            catch {
                EobAttaches.Delete(eob.EobAttachNum);
                throw;
            }
            return(eob);
        }