private void _twain_EndXfer(object sender, Twain32.EndXferEventArgs e)
 {
     try
     {
         bool flag = e.Image != null;
         if (flag)
         {
             string            text = this.GetSetting().ImageDir + DateTime.Now.ToString("yyyyMMddHHmmssfff") + "." + this.GetSetting().FType.ToString();
             EncoderParameters encoderParameters = new EncoderParameters(1);
             EncoderParameter  encoderParameter  = new EncoderParameter(Encoder.Quality, this.GetSetting().ImgRatio);
             encoderParameters.Param[0] = encoderParameter;
             e.Image.Save(text, this.GetSetting().FType.ToImageCodecInfo(), encoderParameters);
             bool flag2 = File.Exists(text);
             if (flag2)
             {
                 TmpFileMgr.AddTmpFile(text);
             }
             bool flag3 = this.OnAcquired != null;
             if (flag3)
             {
                 this.OnAcquired(this, new TEventArg <string>(text));
             }
         }
     }
     catch (Exception ex)
     {
         AppContext.GetInstance().MS.LogError(ex.ToString());
         MessageBox.Show(ex.Message, ex.GetType().Name, MessageBoxButtons.OK, MessageBoxIcon.Hand);
     }
 }
Пример #2
0
        public static NBatchInfo GetBatch(string batchNo)
        {
            string url = HttpUtil.GetHttpGetBatchURL(batchNo);

            //提交批次信息
            byte[] resultBytes = Post(url, batchNo).Result;

            NResultInfo resultInfo = NResultInfo.FromNetMsg(MsgResultInfo.ParseFrom(resultBytes));

            resultInfo.EnsureResultSuccess();

            NBatchInfo        batchInfo = resultInfo.BatchInfo;
            IList <NFileInfo> fileInfos = batchInfo.FileInfos;

            string tmpDir   = AppContext.GetInstance().Config.GetConfigParamValue("AppSetting", "TmpFileDir");
            string batchDir = Path.Combine(tmpDir, batchInfo.BatchNO);

            Directory.CreateDirectory(batchDir);
            TmpDirMgr.AddTmpDir(batchDir);

            foreach (NFileInfo fileInfo in fileInfos)
            {
                string filePath = Path.Combine(batchDir, fileInfo.FileNO);
                fileInfo.LocalPath = filePath;
                File.WriteAllBytes(filePath, fileInfo.Data);
                TmpFileMgr.AddTmpFile(filePath);
            }
            return(batchInfo);
        }
Пример #3
0
        private void AddtoListivew(NewFrameEventArgs eventArgs)
        {
            string text = string.Concat(new object[]
            {
                this._parent.GetSetting().ImageDir,
                DateTime.Now.ToString("yyyyMMddHHmmssfff"),
                ".",
                this._parent.GetSetting().FType
            });
            EncoderParameters encoderParameters = new EncoderParameters(1);
            EncoderParameter  encoderParameter  = new EncoderParameter(Encoder.Quality, this._parent.GetSetting().ImgRatio);

            encoderParameters.Param[0] = encoderParameter;
            eventArgs.Frame.Save(text, this._parent.GetSetting().FType.ToImageCodecInfo(), encoderParameters);
            TmpFileMgr.AddTmpFile(text);
            bool flag = File.Exists(text);

            if (flag)
            {
                ListViewItem listViewItem = new ListViewItem();
                Image        value        = UCPreviewer.LoadSizedImage(text, this._parent.GetSetting().ThumbWidth, this._parent.GetSetting().ThumbHeight);
                this._iconlist.Images.Add(value);
                listViewItem.ImageIndex = this._iconlist.Images.Count - 1;
                listViewItem.Text       = text;
                this.listView1.Items.Add(listViewItem);
            }
        }
Пример #4
0
        private void SaveToFile(int i, Bitmap bmp)
        {
            if (this.Setting == null)
            {
                return;
            }
            String fname = this.Setting.ImageDir + DateTime.Now.ToYMDHMS() + i.ToString() + "." + this.Setting.FType.ToString();

            EncoderParameter  p;
            EncoderParameters ps;

            ps          = new EncoderParameters(1);
            p           = new EncoderParameter(System.Drawing.Imaging.Encoder.Quality, this.Setting.ImgRatio);
            ps.Param[0] = p;

            bmp.Save(fname, this.Setting.FType.ToImageCodecInfo(), ps);

            if (File.Exists(fname))
            {
                TmpFileMgr.AddTmpFile(fname);
            }

            _images.Add(fname);
        }