Пример #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            BackgroundWorker bgWorker = new BackgroundWorker();

            bgWorker.WorkerReportsProgress = true;
            bgWorker.ProgressChanged      += (o, args) => { progressBar1.Value = args.ProgressPercentage; };
            var index = 1;

            bgWorker.DoWork += (o, args) =>
            {
                foreach (var itemLine in File.ReadAllLines("./list.text"))
                {
                    var item = itemLine.Split(',');
                    var img  = WebSnapshotsHelper.GetWebSiteThumbnail($"http://{IP}/studentportal.php/" +
                                                                      $"Jxxx/xskbxx/optype/2/xn/{year1.Text}-{year2.Text}/xq/{semester.Text}/dqz/{week.Text}/" +
                                                                      $"sybmdmstr/{item[0]}/bjmc/{item[1]}"
                                                                      , 1200, 600, 1200, 600);

                    Bitmap bitmap = new Bitmap(img);
                    if (MakeTransparent.Checked)
                    {
                        bitmap.MakeTransparent(Color.White);
                    }
                    bitmap.Save($"{item[1]}.jpg");
                    bgWorker.ReportProgress(index++);
                    Thread.Sleep(1000);
                }

                MessageBox.Show(@"done!");
            };
            bgWorker.RunWorkerAsync();
        }
Пример #2
0
        /// <summary>
        /// 编辑按钮
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnSumit_Click(object sender, EventArgs e)
        {
            StringBuilder   sql      = new StringBuilder();
            List <SqlParam> ilistStr = new List <SqlParam>();

            sql.Append(@"SELECT  * FROM  V_Base_UserInfoRoles WHERE   1 = 1  and IsAdmin = '2'  and AdminHotelid = @AdminHotelid   and DeleteMark = '1' and User_Account!='sewa' ");
            ilistStr.Add(new SqlParam("@AdminHotelid", Hdhoteladmin.Value));
            if (hdHotelId.Value != "0" && hdHotelId.Value != "-1")
            {
                sql.Append(" AND hotelid = @hotelid");
                ilistStr.Add(new SqlParam("@hotelid", hdHotelId.Value));
            }
            DataTable dt = DataFactory.SqlDataBase().GetDataTableBySQL(sql, ilistStr.ToArray());

            //查询生成当前酒店用户二维码
            if (dt != null && dt.Rows.Count > 0)
            {
                List <string> listFJ     = new List <string>(); //保存附件路径
                List <string> listFJName = new List <string>(); //保存附件名字
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    string wjmc = dt.Rows[i]["User_Name"].ToString() + " - " + dt.Rows[i]["HotelNames"].ToString();
                    string url  = Request.Url.ToString();
                    url = url.Substring(0, url.LastIndexOf("/"));
                    // <param name="Url">网页地址</param>
                    //<param name="BrowserWidth">页面宽度</param>
                    // <param name="BrowserHeight">页面高度</param>
                    // <param name="ThumbnailWidth">图像宽度</param>
                    //<param name="ThumbnailHeight">图像高度</param>
                    Bitmap m_Bitmap = WebSnapshotsHelper.GetWebSiteThumbnail(url + "/code_imgnew03.aspx?AdminHotelid=" + dt.Rows[i]["AdminHotelid"] + "&User_ID=" + dt.Rows[i]["User_ID"], 540, 540, 540, 540); //宽高根据要获取快照的网页决定
                    string filename = "~/Upload/QRcode/" + wjmc + ".jpg";
                    string fpath    = HttpContext.Current.Server.MapPath(filename);
                    m_Bitmap.Save(fpath, System.Drawing.Imaging.ImageFormat.Jpeg); //图片格式可以自由控制
                    try
                    {
                        listFJ.Add(fpath);
                        listFJName.Add(wjmc + ".jpg");
                    }
                    catch
                    {
                    }
                }
                string time = DateTime.Now.Ticks.ToString();
                ZipFileMain(listFJ.ToArray(), listFJName.ToArray(), Server.MapPath("~\\upload\\QRcode\\" + time + ".zip"), 6);//压缩文件
                string HotelName = "(" + dt.Rows[0]["HotelName"].ToString() + ")" + "员工推广码.zip";
                DownloadFile(Server.UrlEncode(HotelName), Server.MapPath("~\\upload\\QRcode\\" + time + ".zip"));
            }
        }
Пример #3
0
        /// <summary>
        /// 编辑按钮
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnSumits_Click(object sender, EventArgs e)
        {
            string url = Request.Url.ToString();

            url = url.Substring(0, url.LastIndexOf("/"));
            // <param name="Url">网页地址</param>
            //<param name="BrowserWidth">页面宽度</param>
            // <param name="BrowserHeight">页面高度</param>
            // <param name="ThumbnailWidth">图像宽度</param>
            //<param name="ThumbnailHeight">图像高度</param>
            Bitmap m_Bitmap  = WebSnapshotsHelper.GetWebSiteThumbnail(url + "/code_imgnew04.aspx?AdminHotelid=" + Hdhoteladmin.Value + "&User_ID=" + HdUser_ID.Value + "", 595, 842, 595, 842); //宽高根据要获取快照的网页决定
            string PhotoName = Span_Name.InnerText + "-" + HdHotelName.Value + "展牌.jpg";
            string filename  = "~/Upload/QRcode/" + PhotoName;
            string fpath     = HttpContext.Current.Server.MapPath(filename);

            m_Bitmap.Save(fpath, System.Drawing.Imaging.ImageFormat.Jpeg); //图片格式可以自由控制
            DownloadFile(Server.UrlEncode(PhotoName), Server.MapPath(filename));
        }
Пример #4
0
        protected void btnDownloads_Click(object sender, EventArgs e)
        {
            string url = Request.Url.ToString();

            url = url.Substring(0, url.LastIndexOf("/"));
            // <param name="Url">网页地址</param>
            //<param name="BrowserWidth">页面宽度</param>
            // <param name="BrowserHeight">页面高度</param>
            // <param name="ThumbnailWidth">图像宽度</param>
            //<param name="ThumbnailHeight">图像高度</param>
            Bitmap m_Bitmap  = WebSnapshotsHelper.GetWebSiteThumbnail(url + "/CardMoneyCode.aspx?AdminHotelid=" + hdAdminHotelId.Value, 540, 540, 540, 540); //宽高根据要获取快照的网页决定
            string PhotoName = "快捷支付二维码.jpg";
            string filename  = "~/Upload/QRcode/" + PhotoName;
            string fpath     = HttpContext.Current.Server.MapPath(filename);

            m_Bitmap.Save(fpath, System.Drawing.Imaging.ImageFormat.Jpeg); //图片格式可以自由控制
            DownloadFile(Server.UrlEncode(PhotoName), Server.MapPath(filename));
        }
Пример #5
0
        public JsonResult <BaseResponse> Snapshot([FromBody] string url)
        {
            BaseResponse response = new BaseResponse();

            try
            {
                Bitmap m_Bitmap = WebSnapshotsHelper.GetWebSiteThumbnail(url, 414, 736, 414, 736); //宽高根据要获取快照的网页决定
                var    name     = $"/upload/{Guid.NewGuid()}.png";
                string path     = System.AppDomain.CurrentDomain.BaseDirectory.ToString() + name;

                m_Bitmap.Save(path, System.Drawing.Imaging.ImageFormat.Png); //图片格式可以自由控制
                response.code = 200;
                response.msg  = "成功";
                response.data = name;
            }
            catch (Exception)
            {
                response.code = 500;
                response.msg  = "服务端错误";
            }
            return(Json(response));
        }
Пример #6
0
        static void Main(string[] args)
        {
            Bitmap m_Bitmap = WebSnapshotsHelper.GetWebSiteThumbnail("http://www.cnblogs.com/", 414, 736, 414, 736); //宽高根据要获取快照的网页决定

            m_Bitmap.Save(@"G:\WebImg\render_img2.bmp", System.Drawing.Imaging.ImageFormat.Png);                     //图片格式可以自由控制
        }
Пример #7
0
        public static CustomJsonResult GetCarInsOffer(OrderToCarInsure order, List <OrderToCarInsureOfferCompany> offerCompany, List <OrderToCarInsureOfferKind> kinds)
        {
            CustomJsonResult result = new CustomJsonResult();

            List <YdtInscarInquiryOffer> offerList = new List <YdtInscarInquiryOffer>();

            order.RecipientAddress     = "测试地址";
            order.RecipientPhoneNumber = "13800138000";


            var    au     = YdtUtils.GetToken();
            YdtApi ydtApi = new YdtApi();

            InscarAddbaseModel model = new InscarAddbaseModel();

            model.auto = 1;

            //todo 新车怎么标识
            switch (order.CarVechicheType)
            {
            case Enumeration.CarVechicheType.HC:
                model.carType = 3;
                break;

            default:
                model.carType = 1;
                break;
            }


            switch (order.CarUserCharacter)
            {
            case Enumeration.CarUserCharacter.JTZYQC:
                model.belong = 1;
                break;

            default:
                model.belong = 2;
                break;
            }

            #region 车辆信息
            InsCarInfoModel carInfo = new InsCarInfoModel();
            carInfo.licensePlateNo    = order.CarPlateNo;
            carInfo.vin               = order.CarVin;
            carInfo.engineNo          = order.CarEngineNo;
            carInfo.modelCode         = order.CarModel;
            carInfo.modelName         = order.CarModelName;
            carInfo.firstRegisterDate = order.CarRegisterDate;
            // carInfo.displacement = ;
            // carInfo.marketYear = ;

            //switch (order.CarSeat)
            //{
            //    case Enumeration.CarSeat.S6:
            carInfo.ratedPassengerCapacity = order.CarSeat;
            //        break;
            //    case Enumeration.CarSeat.S10:
            //        carInfo.ratedPassengerCapacity = 10;
            //        break;
            //    case Enumeration.CarSeat.S12:
            //        carInfo.ratedPassengerCapacity = 12;
            //        break;
            //    case Enumeration.CarSeat.S30:
            //        carInfo.ratedPassengerCapacity = 30;
            //        break;
            //    case Enumeration.CarSeat.S36:
            //        carInfo.ratedPassengerCapacity = 36;
            //        break;
            //    default:
            //        carInfo.ratedPassengerCapacity = 9;
            //        break;
            //}

            carInfo.ratedPassengerCapacity = order.CarSeat;
            carInfo.replacementValue       = order.CarPurchasePrice.Value;
            carInfo.licensePlateNo         = order.CarPlateNo;

            //todo
            carInfo.replacementValue = 0;
            carInfo.chgownerType     = "0";



            model.car = carInfo;

            #endregion



            #region 被保人,投保人,车主
            List <InsCustomers> customers = new List <InsCustomers>();

            InsCustomers insured = new InsCustomers();
            insured.insuredFlag = 1;
            insured.name        = order.CarOwner;
            insured.certNo      = order.CarOwnerIdNumber;
            insured.mobile      = order.RecipientPhoneNumber;
            insured.address     = order.RecipientAddress;

            YdtUpload ydtUpdate_SFZ       = new YdtUpload(au.token, au.session, "1", order.CZ_SFZ_ImgUrl);
            var       ydtUpdateResult_SFZ = ydtApi.DoPostFile(ydtUpdate_SFZ, Path.GetFileName(order.CZ_SFZ_ImgUrl));

            if (ydtUpdateResult_SFZ.code != 0)
            {
                return(new CustomJsonResult(ResultType.Failure, ydtUpdateResult_SFZ.msg));
            }

            insured.identityFacePic = ydtUpdateResult_SFZ.data.file.key;
            insured.identityBackPic = ydtUpdateResult_SFZ.data.file.key;

            InsCustomers holder = new InsCustomers();
            holder.insuredFlag     = 2;
            holder.name            = insured.name;
            holder.certNo          = insured.certNo;
            holder.mobile          = insured.mobile;
            holder.address         = insured.address;
            holder.identityFacePic = insured.identityFacePic;
            holder.identityBackPic = insured.identityBackPic;

            InsCustomers carOwner = new InsCustomers();
            carOwner.insuredFlag     = 3;
            carOwner.name            = insured.name;
            carOwner.certNo          = insured.certNo;
            carOwner.mobile          = insured.mobile;
            carOwner.address         = insured.address;
            carOwner.identityFacePic = insured.identityFacePic;
            carOwner.identityBackPic = insured.identityBackPic;


            customers.Add(insured);
            customers.Add(holder);
            customers.Add(carOwner);
            #endregion


            model.customers = customers;


            var ydtUpdate       = new YdtUpload(au.token, au.session, "1", order.CZ_SFZ_ImgUrl);
            var ydtUpdateResult = ydtApi.DoPostFile(ydtUpdate, Path.GetFileName(order.CZ_SFZ_ImgUrl));
            if (ydtUpdateResult.code != 0)
            {
                return(new CustomJsonResult(ResultType.Failure, ydtUpdateResult.msg));
            }

            #region pic
            InsPicModel insPic = new InsPicModel();
            insPic.licensePic      = ydtUpdateResult.data.file.key;
            insPic.licenseOtherPic = "";
            insPic.carCertPic      = "";
            insPic.carInvoicePic   = "";

            model.pic = insPic;
            #endregion



            YdtInscarAddbase ydtInscarAddbase = new YdtInscarAddbase(au.token, au.session, YdtPostDataType.Json, model);
            var ydtInscarCarResult            = ydtApi.DoPost(ydtInscarAddbase);

            if (ydtInscarCarResult.code != 0)
            {
                return(new CustomJsonResult(ResultType.Failure, ydtInscarCarResult.msg));
            }

            var insCarAdvicevalueModel = new InsCarAdvicevalueModel();
            insCarAdvicevalueModel.startDate        = order.PeriodStart.Value.ToString("yyyy-MM-dd");
            insCarAdvicevalueModel.registDate       = order.CarRegisterDate;
            insCarAdvicevalueModel.replacementValue = order.CarPurchasePrice.Value;
            var ydtInscarAdvicevalue       = new YdtInscarAdvicevalue(au.token, au.session, YdtPostDataType.Json, insCarAdvicevalueModel);
            var ydtInscarAdvicevalueResult = ydtApi.DoPost(ydtInscarAdvicevalue);

            if (ydtInscarAdvicevalueResult.code != 0)
            {
                return(new CustomJsonResult(ResultType.Failure, ydtInscarAdvicevalueResult.msg));
            }

            InsCarInquiryModel insCarInquiryModel = new InsCarInquiryModel();
            insCarInquiryModel.auto     = 1;
            insCarInquiryModel.orderSeq = ydtInscarCarResult.data.orderSeq;
            insCarInquiryModel.risk     = YdtDataMap.GetRisk(kinds);

            if (insCarInquiryModel.risk == 2 || insCarInquiryModel.risk == 3)
            {
                insCarInquiryModel.ciStartDate = order.PeriodStart.Value.ToString("yyyy-MM-dd");
            }

            if (insCarInquiryModel.risk == 1 || insCarInquiryModel.risk == 3)
            {
                insCarInquiryModel.biStartDate = order.PeriodStart.Value.ToString("yyyy-MM-dd");
            }


            insCarInquiryModel.coverages = YdtDataMap.GetCoverages(kinds, ydtInscarAdvicevalueResult.data.actualPrice, order.CarSeat);



            foreach (var company in offerCompany)
            {
                var insCompany = YdtDataMap.GetCompanyCode(company.InsuranceCompanyId);
                insCarInquiryModel.companyCode = insCompany.YdtCode;//"006000";
                YdtInscarInquiry ydtInscarInquiry = new YdtInscarInquiry(au.token, au.session, YdtPostDataType.Json, insCarInquiryModel);
                var ydtInscarInquiryResult        = ydtApi.DoPost(ydtInscarInquiry);

                YdtInscarInquiryOffer offer = new YdtInscarInquiryOffer();



                offer.UplinkInsCompanyId = company.InsuranceCompanyId;
                offer.YdtInsCompanyId    = insCarInquiryModel.companyCode;
                offer.Inquiry            = ydtInscarInquiryResult;

                if (ydtInscarInquiryResult.code == 0)
                {
                    OfferImgModel offerImgModel = new OfferImgModel();
                    offerImgModel.Company   = insCompany.PrintName;
                    offerImgModel.OfferTime = DateTime.Now;
                    offerImgModel.Offerer   = "";

                    OfferImgCarInfo offerImgCarInfo = new OfferImgCarInfo();
                    offerImgCarInfo.CarOwner     = order.CarOwner;
                    offerImgCarInfo.CarPlateNo   = order.CarPlateNo;
                    offerImgCarInfo.CarEngineNo  = order.CarEngineNo;
                    offerImgCarInfo.CarVin       = order.CarVin;
                    offerImgCarInfo.CarModelName = order.CarModelName;

                    offerImgModel.CarInfo = offerImgCarInfo;

                    string postData = "";
                    if (offer.Inquiry != null)
                    {
                        if (offer.Inquiry.data != null)
                        {
                            if (offer.Inquiry.data.coverages != null)
                            {
                                var coverages = offer.Inquiry.data.coverages;
                                foreach (var coverage in coverages)
                                {
                                    OfferImgCoverage offerImgCoverage = new OfferImgCoverage();
                                    offerImgCoverage.Name     = coverage.name;
                                    offerImgCoverage.Discount = coverage.discount;
                                    offerImgCoverage.Premium  = coverage.standardPremium;

                                    if (coverage.code == "006")
                                    {
                                        if (coverage.glassType != null)
                                        {
                                            if (coverage.glassType.Value == 1)
                                            {
                                                offerImgCoverage.Coverage = "国产";
                                            }
                                            else
                                            {
                                                offerImgCoverage.Coverage = "进口";
                                            }
                                        }
                                    }
                                    else if (coverage.name.IndexOf("不计免赔") > -1)
                                    {
                                        offerImgCoverage.Coverage = "";
                                    }
                                    else
                                    {
                                        if (coverage.amount != null)
                                        {
                                            offerImgCoverage.Coverage = coverage.amount.Value.ToF2Price();
                                        }
                                    }

                                    offerImgModel.CommercialCoverageInfo.Coverages.Add(offerImgCoverage);
                                }
                                offerImgModel.CommercialCoverageInfo.PeriodStart = order.PeriodStart;
                                offerImgModel.CommercialCoverageInfo.PeriodEnd   = order.PeriodEnd;
                            }

                            if (offer.Inquiry.data.inquirys != null)
                            {
                                var commercial = offer.Inquiry.data.inquirys.Where(m => m.risk == 1).FirstOrDefault();
                                if (commercial != null)
                                {
                                    offerImgModel.CommercialCoverageInfo.SumPremium = commercial.standardPremium;
                                }

                                var compulsory = offer.Inquiry.data.inquirys.Where(m => m.risk == 2).FirstOrDefault();

                                if (compulsory != null)
                                {
                                    offerImgModel.CompulsoryInfo.PeriodStart = order.PeriodStart;
                                    offerImgModel.CompulsoryInfo.PeriodEnd   = order.PeriodEnd;
                                    offerImgModel.CompulsoryInfo.Premium     = compulsory.standardPremium - compulsory.sumPayTax;
                                    offerImgModel.TravelTax = compulsory.sumPayTax;
                                }
                            }

                            offerImgModel.SumPremium = offer.Inquiry.data.inquirys.Sum(m => m.standardPremium);
                        }
                    }

                    postData = Newtonsoft.Json.JsonConvert.SerializeObject(offerImgModel);

                    int height = 840;
                    if (offer.Inquiry.data.coverages != null)
                    {
                        if (offer.Inquiry.data.coverages.Count > 5)
                        {
                            height = height + (offer.Inquiry.data.coverages.Count - 5) * 40;
                        }
                    }



                    Bitmap m_Bitmap = WebSnapshotsHelper.GetWebSiteThumbnail("http://localhost:12060/App/CarInsureOffer/OfferImg", 1280, height, 1280, height, postData); //宽高根据要获取快照的网页决定

                    byte[] bytes = Bitmap2Byte(m_Bitmap);

                    string           fileExt = ".jpg";
                    UploadFileEntity entity  = new UploadFileEntity();
                    entity.FileName     = DateTime.Now.ToString("yyyyMMddHHmmss") + fileExt;//自定义文件名称,这里以当前时间为例
                    entity.FileData     = bytes;
                    entity.UploadFolder = "offerImg";
                    entity.GenerateSize = false;
                    var rm = HttpClientOperate.Post <CustomJsonResult>(entity.UploadFolder, ConfigurationManager.AppSettings["custom:UploadServerUrl"], entity);//封装的POST提交方
                    if (rm.Result == ResultType.Success)
                    {
                        ImageUpload imageUpload = Newtonsoft.Json.JsonConvert.DeserializeObject <ImageUpload>(rm.Data.ToString());
                        offer.OfferImgUrl = imageUpload.OriginalPath;
                    }
                }


                offerList.Add(offer);
            }

            result.Result = ResultType.Success;
            result.Code   = ResultCode.Success;
            result.Data   = offerList;

            return(result);
        }