Example #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (null == Request.QueryString["id"])
            {
                return;
            }

            strThumbID = Common.Common.NoHtml(Request.QueryString["id"].ToString());
            DAL.Album.UserPhotoDAL dal = new DAL.Album.UserPhotoDAL();
            DataSet ds = dal.GetMyThumb(strThumbID);

            Model.Album.UserPhoto model = new Model.Album.UserPhoto();
            if (null != ds && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
            {
                model = DataConvert.DataRowToModel <Model.Album.UserPhoto>(ds.Tables[0].Rows[0]);
            }

            strSiteCode = model.SiteCode.ToString();
            strOpenID   = model.OpenId.ToString();
            strThumbMsg = Common.Common.NoHtml(Request.Form["thumbMsg"].ToString());

            strClientID = "WSY08";


            if (string.IsNullOrEmpty(strClientID))
            {
                Response.Write("<script>alert('打印码已经使用过!')</script>");
                Response.Write("<script>document.addEventListener('WeixinJSBridgeReady', function onBridgeReady() {	WeixinJSBridge.call('closeWindow');});</script>");
                return;
            }

            int    iPrintCount  = 1;
            string strPrintCode = "";

            //判断如果是单数据不用输入打印码
            DAL.HP.HPClientDAL dalClient = new DAL.HP.HPClientDAL();
            DataSet            dsClient  = dalClient.GetPrintClient(strSiteCode);

            if (null != dsClient && dsClient.Tables.Count > 0 && dsClient.Tables[0].Rows.Count > 0)
            {
                iPrintCount = int.Parse(dsClient.Tables[0].Rows[0]["FreeAmount"].ToString());
            }

            if (null != dsClient && dsClient.Tables.Count > 0 && dsClient.Tables[0].Rows.Count > 0)
            {
                if (dsClient.Tables[0].Rows.Count == 1)
                {
                    strPrintCode = dsClient.Tables[0].Rows[0]["FreeCode"].ToString();
                    strClientID  = dsClient.Tables[0].Rows[0]["ClientCode"].ToString();
                }
            }

            DAL.HP.PhotoDAL dalPhoto = new DAL.HP.PhotoDAL();

            if (dalPhoto.OpenIDPhotoCount(strOpenID) > iPrintCount)
            {
                Response.Write("<script>alert('你已经提交过打印照片!')</script>");
                Response.Write("<script>document.addEventListener('WeixinJSBridgeReady', function onBridgeReady() {	WeixinJSBridge.call('closeWindow');});</script>");
            }
            else
            {
                //照片处理
                strSFilePath = "~/User_Photo/" + model.FilePath;
                strFilePath  = model.FilePath;
                string[] urls = strSFilePath.Split('.');
                string   _url = strOpenID + "." + urls.Last();

                string inputurl  = Server.MapPath("~/User_Photo/") + strFilePath;
                string outputurl = Server.MapPath("~/HP_Photo/") + _url;

                int width  = 260;
                int height = 260;

                System.IO.FileStream fs = new System.IO.FileStream(inputurl, System.IO.FileMode.Open);
                //ZoomAuto(fs, outputurl,width, height, "", "");
                CutForCustom(fs, outputurl, width, height, 100);
                fs.Close();


                Model.HP.Photo modelPhoto = new Model.HP.Photo()
                {
                    SiteCode   = strSiteCode,
                    OpenId     = strOpenID,
                    ClientID   = strClientID,
                    PrintCode  = strPrintCode,
                    Img        = strOpenID + "." + model.FilePath.Split('.').Last(),
                    AttachText = strThumbMsg
                };
                dalPhoto.InsertInfo(modelPhoto);
                Response.Write("<script>alert('提交成功!')</script>");
                Response.Write("<script>document.addEventListener('WeixinJSBridgeReady', function onBridgeReady() {	WeixinJSBridge.call('closeWindow');});</script>");
            }
        }
Example #2
0
        void PrintPhoto(string imgsrc)
        {
            string imgname = string.Empty;

            string[] imgarray = imgsrc.Split('.');
            imgname = imgarray[0];
            string openid = string.Empty;

            if (userid != null && userid != "")
            {
                MSCustomersDAL customerDal = new MSCustomersDAL();
                try
                {
                    openid = customerDal.GetCustomerValueByID("OpenID", userid).ToString();
                }
                catch (Exception)
                {
                }
            }
            if (openid == null || openid == "")
            {
                openid = strID;
            }

            DAL.HP.PhotoDAL dalPhoto = new DAL.HP.PhotoDAL();
            //照片处理
            strSFilePath = "../../PalmShop/ShopCode/" + imgsrc;
            strFilePath  = imgsrc;
            string[] urls    = strSFilePath.Split('.');
            string   _url    = openid + "." + urls.Last();
            string   saveurl = "../../HP_Photo/";

            saveurl = Server.MapPath(saveurl);
            if (!Directory.Exists(saveurl))
            {
                Directory.CreateDirectory(saveurl);
            }
            string inputurl  = Server.MapPath("../../PalmShop/ShopCode/") + strFilePath;
            string outputurl = Server.MapPath("../../HP_Photo/") + _url;

            int width  = 260;
            int height = 310;

            System.IO.FileStream fs = new System.IO.FileStream(inputurl, System.IO.FileMode.Open);
            //ZoomAuto(fs, outputurl,width, height, "", "");
            CutForCustom(fs, outputurl, width, height, 100);
            fs.Close();

            string SiteCode = "VYIGO";

            if (Session["strSiteCode"].ToString() != null && Session["strSiteCode"].ToString() != "")
            {
                SiteCode = Session["strSiteCode"].ToString();
            }

            // DAL.HP.PrintCodeDAL dalPrintCode = new DAL.HP.PrintCodeDAL();
            // DataSet printds = dalPrintCode.AddPrintCode(1, SiteCode,"0000", "2014-01-01", "2019-12-31");
            //string strPID = string.Empty;
            //if (printds != null && printds.Tables.Count > 0 && printds.Tables[0].Rows.Count > 0)
            //{
            //    strPID = printds.Tables[0].Rows[0]["ID"].ToString();
            //}

            string strPID = Guid.NewGuid().ToString("N");

            Model.HP.Photo modelPhoto = new Model.HP.Photo()
            {
                ID         = strPID,
                OpenId     = openid,
                SiteCode   = SiteCode,
                ClientID   = "WSY01",
                PrintCode  = "1111",
                Img        = openid + "." + imgsrc.Split('.').Last(),
                AttachText = AttachText.Text + "\r\n"
            };
            dalPhoto.InsertInfo(modelPhoto);

            //插入V币记录
            if (userid != null && userid != "" && strPID != null && strPID != "")
            {
                int              award          = GetAwardChance();
                MSVAcct          msvModel       = new MSVAcct();
                MSVAcctDAL       msvDal         = new MSVAcctDAL();
                MSVAcctDetail    msvdetailModel = new MSVAcctDetail();
                MSVAcctDetailDAL msvdetailDal   = new MSVAcctDetailDAL();
                if (!msvDal.ExistMSVAcct(userid, SiteCode))
                {
                    msvModel.CustID   = userid;
                    msvModel.SiteCode = SiteCode;
                    msvModel.V_Amont  = award;
                    msvDal.AddMSVAcct(msvModel);
                }
                else
                {
                    int count = Convert.ToInt32(msvDal.GetMSVAcct("V_Amont", userid).ToString());
                    count             = count + award;
                    msvModel.CustID   = userid;
                    msvModel.SiteCode = SiteCode;
                    msvModel.V_Amont  = count;
                    msvDal.UpdateMSVAcct(msvModel);
                }
                msvdetailModel.CustID     = userid;
                msvdetailModel.Amount     = award;
                msvdetailModel.ChargeType = "首次购物";
                msvdetailModel.Ext_Fld1   = strPID;
                msvdetailModel.SiteCode   = SiteCode;
                msvdetailDal.AddMSVAcctDetail(msvdetailModel);
            }
            //插入活动券
            if (!string.IsNullOrEmpty(openid))
            {
                string            strGuid = Guid.NewGuid().ToString("N");
                DAL.ACT.CouponDAL cdal    = new DAL.ACT.CouponDAL();
                if (!cdal.ExistCoupon(SiteCode, "56DBFD79AFF94FD6B0FE7E72CE7589E6", openid))
                {
                    Model.ACT.Coupon coupon = null;
                    coupon = new Model.ACT.Coupon()
                    {
                        ID             = strGuid,
                        SiteCode       = SiteCode,
                        SiteActivityID = "56DBFD79AFF94FD6B0FE7E72CE7589E6",
                        OpenID         = openid,
                        CouponStatus   = 0
                    };
                    cdal.InsertInfo(coupon);
                }
            }
        }