/// <summary>
        /// 窗体加载事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void OnFormLoaded(object sender, EventArgs e)
        {
            SetFunctionVisable();
            EUploadType eUpType = (EUploadType)OrderHelper.GetUploadType();

            _uploadFolder = CnasUtilityTools.GetFolderName(eUpType);
            string tempCode = _imageMode != 3 ? BatchNum : BarCode;

            LoadData(tempCode);
        }
Exemple #2
0
        public HCSWF_device_result_add(SortedList data, int resultMode)
        {
            InitializeComponent();
            Data       = data;
            ResultMode = resultMode;
            EUploadType eUpType = (EUploadType)GetUploadType();

            _uploadFolder = CnasUtilityTools.GetFolderName(eUpType);
            InitalizeData(data);
            InitializeButtonImage();
            Icon = new Icon(ResourcesImageHelper.Instance.GetResourcesStream("Common.icon", "MainIco", EnumImageType.ICO));
        }
        /// <summary>
        /// 图片保存事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void tsm_save_Click(object sender, EventArgs e)
        {
            string str_ImageData    = this.ImageData01.GetXML();
            string str_ImageAddData = "";

            if (this.Sl_par.Count > 0)
            {
                str_ImageAddData = "<ImageAddData>";
                for (int i = 0; i < Sl_par.Count; i++)
                {
                    ImageAddData ImageAddDatatmp = (ImageAddData)Sl_par.GetByIndex(i);
                    str_ImageAddData = str_ImageAddData + ImageAddDatatmp.GetXML();
                }
                str_ImageAddData = str_ImageAddData + "</ImageAddData>";
            }
            string strxmltmp = "<Data>" + str_ImageData + str_ImageAddData + "</Data>";

            //UserXmlUpdate(sender, e, strxmltmp);


            #region 保存对应条码包的照片
            //ftp: test.cnasis.cn:cnasftp:ftp123
            tsm_view_Click(null, null);
            Bitmap _NewBitmap = new Bitmap(this.pic_view.Width, pic_view.Height);
            //_NewBitmap.SetResolution(203, 203);
            pic_design.DrawToBitmap(_NewBitmap, new Rectangle(0, 0, _NewBitmap.Width, _NewBitmap.Height));
            MemoryStream memStream = new MemoryStream();
            _NewBitmap.Save(memStream, ImageFormat.Jpeg);

            string folderName = CnasUtilityTools.GetFolderName(EUploadType.Set);

            ImageCache imageCache = new ImageCache();
            //保存图片
            bool result = imageCache.SaveImageCache(folderName, ImageData01.Name + ".jpg", memStream);

            #endregion

            if (!result)
            {
                MessageBox.Show("对不起!上传图片失败,请检查文件服务器和网络.");
                return;
            }
            else
            {
                this.pic_view.Image = imageCache.GetImageByFolderNameFileName(folderName, ImageData01.Name + ".jpg");
            }

            MessageBox.Show("恭喜你!图片生成成功。");
        }
        /// <summary>
        /// 获取图片
        /// </summary>
        private List <Image> GetImages(CnasRemotCall reCnasRemotCall, string match_code, string batch_num)
        {
            string       tempStr       = string.Format("BatchNum_{0}_", batch_num);//dataurl  前缀
            List <Image> images        = new List <Image>();
            SortedList   pic_condition = new SortedList();

            pic_condition.Add(1, (int)EUploadType.SterilizerResultMonitor);
            pic_condition.Add(2, 1);
            pic_condition.Add(3, match_code);
            pic_condition.Add(4, tempStr);
            string    testSql     = reCnasRemotCall.RemotInterface.CheckSelectData("HCS-image-sec004", pic_condition);
            DataTable dtImageList = reCnasRemotCall.RemotInterface.SelectData("HCS-image-sec004", pic_condition);

            if (dtImageList != null && dtImageList.Rows != null && dtImageList.Rows.Count > 0)
            {
                Image image = null;
                foreach (DataRow item in dtImageList.Rows)
                {
                    string fileName = "";
                    image = null;
                    if (item["data_url"] != null)
                    {
                        fileName = item["data_url"].ToString();
                        fileName = fileName.Substring(tempStr.Length - 1);
                    }
                    if (!string.IsNullOrEmpty(fileName))
                    {
                        ImageCache imageCache = new ImageCache();
                        image = imageCache.GetImageByFolderNameFileName(CnasUtilityTools.GetFolderName(EUploadType.SetResultMonitor), fileName);
                        if (image != null)
                        {
                            images.Add(image);
                        }
                    }
                }
                if (images == null || images.Count == 0)
                {
                    images = _defaultImage;
                }
            }
            else
            {
                images = _defaultImage;
            }
            return(images);
        }
        /// <summary>
        /// 图片保存事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void tsm_save_Click(object sender, EventArgs e)
        {
            string str_ImageData    = this.ImageData01.GetXML();
            string str_ImageAddData = "";

            if (this.Sl_par.Count > 0)
            {
                str_ImageAddData = "<ImageAddData>";
                for (int i = 0; i < Sl_par.Count; i++)
                {
                    ImageAddData ImageAddDatatmp = (ImageAddData)Sl_par.GetByIndex(i);
                    str_ImageAddData = str_ImageAddData + ImageAddDatatmp.GetXML();
                }
                str_ImageAddData = str_ImageAddData + "</ImageAddData>";
            }
            string strxmltmp = "<Data>" + str_ImageData + str_ImageAddData + "</Data>";
            //UserXmlUpdate(sender, e, strxmltmp);


            //上传到FTP文件夹的名称
            string folderName = "";

            int upType = Convert.ToInt32(Sl_Parameter["type"]);
            //包图片名称
            string dataUrl = ImageData01.Name + ".jpg";

            // 确定上传图片的类型
            // 1-包  2-器械
            EUploadType eUpType = (EUploadType)upType;

            folderName = CnasUtilityTools.GetFolderName(eUpType);


            #region 保存对应条码包的照片
            //ftp: test.cnasis.cn:cnasftp:ftp123
            tsm_view_Click(null, null);
            Bitmap _NewBitmap = new Bitmap(this.PrictureView.Width, PrictureView.Height);
            //_NewBitmap.SetResolution(203, 203);
            prictureDesign.DrawToBitmap(_NewBitmap, new Rectangle(0, 0, _NewBitmap.Width, _NewBitmap.Height));
            MemoryStream memStream = new MemoryStream();
            _NewBitmap.Save(memStream, ImageFormat.Jpeg);


            ImageCache imageCache = new ImageCache();

            //保存图片
            bool result = imageCache.SaveImageCache(folderName, ImageData01.Name + ".jpg", memStream);
            if (!result)
            {
                MessageBox.Show(PromptMessageXmlHelper.Instance.GetPromptMessage("errorimage", EnumPromptMessage.error, new string[] { "系统错误" }), "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            #endregion

            //获取图片
            Image picViewImage = imageCache.GetImageByFolderNameFileName(folderName, ImageData01.Name + ".jpg");
            //返回不等于""说明有错误信息返回,弹出提示
            if (picViewImage == null)
            {
                MessageBox.Show(PromptMessageXmlHelper.Instance.GetPromptMessage("errorseeim", EnumPromptMessage.error, new string[] { "" }), "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            else
            {
                this.PrictureView.Image = picViewImage;
            }

            //rexxie通过条形码更新数据库:关联文件名
            CnasRemotCall reCnasRemotCall = new CnasRemotCall();
            SortedList    sltmp           = new SortedList();
            SortedList    sltmp01         = new SortedList();

            //图片存储类型
            sltmp.Add(1, upType);
            //包ID
            sltmp.Add(2, Sl_Parameter["pack_id"]);
            //包条码
            sltmp.Add(3, Sl_Parameter["pack_barcode"]);
            //图片名称
            sltmp.Add(4, dataUrl);
            //状态默认可用
            sltmp.Add(5, 1);
            sltmp01.Add(1, sltmp);
            //string gg = reCnasRemotCall.RemotInterface.CheckUPData(1, "HCS_image-data-add001", sltmp01, null);
            int recint = reCnasRemotCall.RemotInterface.UPData(1, "HCS_image-data-add001", sltmp01, null);

            if (recint > -1)
            {
                MessageBox.Show(PromptMessageXmlHelper.Instance.GetPromptMessage("addsuccessful", EnumPromptMessage.warning, new string[] { "照片" }), "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
                this.DialogResult = DialogResult.OK;
                this.Close();
            }
        }