protected void btnBeginRollCall_Click(object sender, EventArgs e)
        {
            RollCall rollCall = new RollCall();
            RollCallHandler rollCallHandler = new RollCallHandler();

            //add roll call entry to DB
            rollCall.TimeOfRollCall = DateTime.Now.ToString();
            rollCall.ModuleID = Convert.ToInt32(dlModules.SelectedValue);
            //rollCall.Status = "Enabled"; not needed

            rollCallID = rollCallHandler.AddNewRollCall(rollCall);

            //generate and display QR Code and pin
            string encodeQR = rollCallID.ToString();

            QRCodeEncoder encoder = new QRCodeEncoder();
            Bitmap hi = encoder.Encode(encodeQR);
            hi.Save(Server.MapPath("~/temp/" + encodeQR + ".jpg"), ImageFormat.Jpeg);
            QRcode.ImageUrl = "~/temp/" + encodeQR + ".jpg";

            litPin.Text = "<div class='alert alert-info'>Pin: " + rollCallID + "</div>";
            //change interface to suite active roll call session
            btnBeginRollCall.Visible = false;
            dlModules.Visible = false;

            //litAutoDisable.Visible = true;
            txtTime.Visible = true;
            txtDate.Visible = true;
            btnAutoDisable.Visible = true;

            btnPauseRollCall.Visible = true;
            btnEndRollCall.Visible = true;

            Page.ClientScript.RegisterStartupScript(this.GetType(), "CallMyFunction", "makeVisible()", true);
        }
Exemplo n.º 2
0
 // Create QR Code
 private void btnCreate_Click(object sender, EventArgs e)
 {
     string URL = txtURL.Text;
     QRCodeEncoder encoder = new QRCodeEncoder();
     Bitmap qrcode = encoder.Encode(URL);
     pbQR.Image = (Image) qrcode;
 }
Exemplo n.º 3
0
        private Image KareKodOlustur(string giris, int kkDuzey)
        {
            var deger = giris;

            MessagingToolkit.QRCode.Codec.QRCodeEncoder qre = new MessagingToolkit.QRCode.Codec.QRCodeEncoder();

            if (rad_ALPHA_NUMERIC.Checked == true)
            {
                qre.QRCodeEncodeMode = QRCodeEncoder.ENCODE_MODE.ALPHA_NUMERIC;
            }

            if (rad_BYTE.Checked == true)
            {
                qre.QRCodeEncodeMode = QRCodeEncoder.ENCODE_MODE.BYTE;
            }

            if (rad_NUMERIC.Checked == true)
            {
                qre.QRCodeEncodeMode = QRCodeEncoder.ENCODE_MODE.NUMERIC;
            }

            qre.QRCodeErrorCorrect = QRCodeEncoder.ERROR_CORRECTION.L;
            qre.QRCodeVersion      = kkDuzey;
            System.Drawing.Bitmap bm = qre.Encode(deger);
            return(bm);
        }
Exemplo n.º 4
0
        protected void btnaddexp_Click(object sender, EventArgs e)
        {
            Int32 uniexpid = getuniexperinceid("addexper", TextBox1.Text.ToString());
            QRCodeEncoder qe = new QRCodeEncoder();
            qe.QRCodeEncodeMode = QRCodeEncoder.ENCODE_MODE.BYTE;
            qe.QRCodeErrorCorrect = QRCodeEncoder.ERROR_CORRECTION.L;
            System.Drawing.Image im = qe.Encode(uniexpid.ToString());
            MemoryStream ms = new MemoryStream();
            im.Save(ms, System.Drawing.Imaging.ImageFormat.Png);
            byte[] bt = ms.ToArray();

            string type = ".png";
            string name = addexperuserid.Text.ToString();
            string path = "c:\\" + name + type;

            Response.Buffer = true;
            Response.Charset = "";
            Response.Cache.SetCacheability(HttpCacheability.NoCache);
            Response.ContentType = AHRMS1.specueopag.MimeType(Path.GetExtension(path));
            Response.AddHeader("content-disposition", "attachment;filename=" + name + type);
            Response.BinaryWrite(bt);
            Response.Flush();
            Response.End();

            lbladdexpsucess.Text = "Experience Succesfully Added (Please paste the QR Code on Experience Letter)";
        }
Exemplo n.º 5
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                WxConfig = EasyWeixin.CommonAPIs.CommonApi.GetWxConfigResult(appid, appsecert, Request.Url.ToString());
                QRCodeEncoder encoder = new QRCodeEncoder();
                Bitmap bt = encoder.Encode(Request.Url.ToString());

                var md5 = new MD5CryptoServiceProvider();
                var start = Encoding.Default.GetBytes(Request.Url.ToString());
                byte[] output = md5.ComputeHash(start);
                var result = BitConverter.ToString(output).Replace("-", "");

                var direName = "~/tmpQrImg/";
                var filename = direName + result + ".png";
                var filepath = Server.MapPath(filename);

                if (!Directory.Exists(direName))
                {
                    Directory.CreateDirectory(direName);
                }

                if (!File.Exists(filename))
                {
                    bt.Save(filename, ImageFormat.Png);
                }
                ImgSrc = filename;
            }
        }
Exemplo n.º 6
0
        private void Form1_Load(object sender, EventArgs e)
        {
            MessagingToolkit.QRCode.Codec.QRCodeEncoder xencoder = new MessagingToolkit.QRCode.Codec.QRCodeEncoder(); //建立 encoder
            string xcontent = "https://www.baidu.com";                                                                // "wgscd你好啊";

            System.Drawing.Bitmap qrcode = xencoder.Encode(xcontent);                                                 //將內容轉碼成 QR code
            qrcode.Save("qrcode_1.png");                                                                              //把 QRcode 另存為 PNG 圖檔,並放置於 images 資料夾底下
        }
Exemplo n.º 7
0
        private void generate_Click(object sender, EventArgs e)
        {
            string URL = url.Text;
            QRCodeEncoder encoder = new QRCodeEncoder();
            Bitmap qrcode = encoder.Encode(URL);

            QRImage.Image = qrcode as Image;
        }
Exemplo n.º 8
0
 // GET: Default
 public ActionResult Index()
 {
     QRCodeEncoder encoder = new QRCodeEncoder();
     Bitmap img =  encoder.Encode("www.teste.com.br");
     var path = Server.MapPath("~/Content/images/");
     img.Save(path +"imgQrCode.jpg", ImageFormat.Jpeg);
     return View();
 }
Exemplo n.º 9
0
        public static void CreateImage(string text, string name)
        {
            MessagingToolkit.QRCode.Codec.QRCodeEncoder encoder = new MessagingToolkit.QRCode.Codec.QRCodeEncoder();
            encoder.QRCodeVersion = 0;
            Bitmap bmp = encoder.Encode(text);

            bmp.Save(name + ".png");
        }
Exemplo n.º 10
0
        public static System.Drawing.Image GetPictureFromText(string code)
        {
            QRCodeEncoder encoder = new QRCodeEncoder();
            encoder.QRCodeEncodeMode = QRCodeEncoder.ENCODE_MODE.BYTE; //ALPHA_NUMERIC, nonostante il nome, non va bene per codificare un GUID.
            encoder.QRCodeErrorCorrect = QRCodeEncoder.ERROR_CORRECTION.L;
            encoder.QRCodeVersion = 3;

            return encoder.Encode(code);
        }
Exemplo n.º 11
0
 private Image QRGen(string input, int qrlevel)
 {
     MessagingToolkit.QRCode.Codec.QRCodeEncoder qe = new MessagingToolkit.QRCode.Codec.QRCodeEncoder();
     qe.QRCodeEncodeMode   = QRCodeEncoder.ENCODE_MODE.BYTE;
     qe.QRCodeErrorCorrect = QRCodeEncoder.ERROR_CORRECTION.L;
     qe.QRCodeVersion      = qrlevel;
     System.Drawing.Bitmap bm = qe.Encode(input);
     return(bm);
 }
Exemplo n.º 12
0
        void LoadQRCode(String eventid, String room)
        {

            string url = "http://wsv-att1snd.uol.le.ac.uk/registration.aspx?event=" + eventid + "&room=" + room;

            QRCodeEncoder encoder = new QRCodeEncoder();
            Bitmap hi = encoder.Encode(url);
            hi.Save(Server.MapPath("~/images/ji.jpg"), ImageFormat.Jpeg);
            img.ImageUrl = "~/images/ji.jpg";

        }
Exemplo n.º 13
0
        protected void ImprimirQRCode(object sender, EventArgs e)
        {
            string texto = Convert.ToString(idpaciente);
            QRCodeEncoder encoder = new QRCodeEncoder();
            MemoryStream ms = new MemoryStream();
            Bitmap img = encoder.Encode(texto);
            img.Save(ms, ImageFormat.Bmp);
            qrcode = ms.ToArray();

            GerarQRCode(qrcode);
            Response.Redirect("~/Pacientes/ImprimirQRCode.aspx?id=" + idpaciente);
        }
Exemplo n.º 14
0
        private Image karekodolustur(string durum, string bad, string bno, string bas, string tarih, string gec, string dokuman, string belges, string sasi, string telno, string giris, int kduzey)
        {
            giris = durum + "\n\n" + bad + "\n\n" + bno + "\n\n" + bas + "\n\n" + tarih + "\n\n" + gec + "\n\n" + dokuman + "\n\n" + belges + "\n\n" + sasi + "\n\n" + telno;

            var deger = giris;

            MessagingToolkit.QRCode.Codec.QRCodeEncoder qe = new MessagingToolkit.QRCode.Codec.QRCodeEncoder();
            qe.QRCodeEncodeMode   = QRCodeEncoder.ENCODE_MODE.BYTE;
            qe.QRCodeErrorCorrect = QRCodeEncoder.ERROR_CORRECTION.L;
            qe.QRCodeVersion      = kduzey;
            System.Drawing.Bitmap bm = qe.Encode(deger);
            return(bm);
        }
Exemplo n.º 15
0
        private void button1_Click(object sender, EventArgs e)
        {
            QRCodeEncoder qrCodecEncoder = new QRCodeEncoder();
            qrCodecEncoder.QRCodeBackgroundColor = System.Drawing.Color.White;
            qrCodecEncoder.QRCodeForegroundColor = System.Drawing.Color.Black;
            qrCodecEncoder.CharacterSet = "UTF-8";
            qrCodecEncoder.QRCodeEncodeMode = QRCodeEncoder.ENCODE_MODE.BYTE;
            qrCodecEncoder.QRCodeScale = 6;
            qrCodecEncoder.QRCodeVersion = 0;
            qrCodecEncoder.QRCodeErrorCorrect = QRCodeEncoder.ERROR_CORRECTION.Q;

            Image imageQRCode;
            //string a ser gerada
            String data = textBox1.Text;

            TripleDESCryptoServiceProvider tripledescryptoserviceprovider = new TripleDESCryptoServiceProvider();
            MD5CryptoServiceProvider md5cryptoserviceprovider = new MD5CryptoServiceProvider();

            try
            {
                if (data.Trim() != "")
                {
                    //Aqui vc inclui uma chave qualquer para servir de base para cifrar, que deve ser a mesma no método Decodificar
                    string chave = "asdfg";
                    tripledescryptoserviceprovider.Key = md5cryptoserviceprovider.ComputeHash(Encoding.Default.GetBytes(chave));
                    tripledescryptoserviceprovider.Mode = CipherMode.ECB;
                    ICryptoTransform desdencrypt = tripledescryptoserviceprovider.CreateEncryptor();
                    byte[] buff = Encoding.Default.GetBytes(data);

            data =  Convert.ToBase64String(desdencrypt.TransformFinalBlock(buff, 0, buff.Length));

                }
                else
                {
                   data= "";
                }
            }
            catch (Exception exception)
            {
                throw exception;
            }
            finally
            {
                tripledescryptoserviceprovider = null;
                md5cryptoserviceprovider = null;
            }

            imageQRCode = qrCodecEncoder.Encode(data);
            pictureBox1.Image = imageQRCode;
        }
Exemplo n.º 16
0
        protected void Page_Load(object sender, EventArgs e)
        {
            QRCodeEncoder encoder = new QRCodeEncoder();

            encoder.QRCodeErrorCorrect = QRCodeEncoder.ERROR_CORRECTION.H;
            encoder.QRCodeScale = 4;

             
            // change this so the id is passed to create the code
          Bitmap img = encoder.Encode("https://reptilemanager.azurewebsites.net/");
          img.Save("C:\\Users\\Stephen\\Documents\\GitHub\\4thYearPro\\ReptileManager\\ReptileManager\\qrImage.jpg",ImageFormat.Jpeg);

          QRImage.ImageUrl = "qrImage.jpg";
        }
Exemplo n.º 17
0
        public static byte[] generar(string input, int qrlevel = 10)
        {
            string toenc = input;
            var qe = new QRCodeEncoder();
            qe.QRCodeEncodeMode = QRCodeEncoder.ENCODE_MODE.BYTE;
            qe.QRCodeErrorCorrect = QRCodeEncoder.ERROR_CORRECTION.Q;
          
            qe.QRCodeVersion = qrlevel;
            var bm = qe.Encode(toenc);



            return imageToByteArray(bm);
        }
        public string GetBusinessCoder(string urlBusiness)
        {
            MessagingToolkit.QRCode.Codec.QRCodeEncoder encoder = myBllBusiness.GetBusinessCoder(urlBusiness);
            Bitmap bmp = encoder.Encode(urlBusiness);
            //return bmp;
            MemoryStream ms = new MemoryStream();

            bmp.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);
            //ms.ToArray();
            byte[] arr          = ms.ToArray();
            string base64String = Convert.ToBase64String(arr);

            return(base64String);
        }
Exemplo n.º 19
0
        /// <summary>
        /// Girilen değeri karekod resim olarak döndürür.
        /// </summary>
        /// <param name="veri">Karekod için gerekli değer.</param>
        /// <param name="kkDuzey">Karekod düzeyi. Genelde 1 olarak ayarlanır.</param>
        /// <returns></returns>
        public static Image KareKodOlustur(string veri, int kkDuzey)
        {
            MessagingToolkit.QRCode.Codec.QRCodeEncoder qe = new MessagingToolkit.QRCode.Codec.QRCodeEncoder();

            qe.QRCodeEncodeMode = QRCodeEncoder.ENCODE_MODE.ALPHA_NUMERIC;

            qe.QRCodeErrorCorrect = QRCodeEncoder.ERROR_CORRECTION.L;

            qe.QRCodeVersion = kkDuzey;

            Bitmap bm = qe.Encode(veri);

            return(bm);
        }
Exemplo n.º 20
0
        void Redraw()
        {
            string data = string.Format(templateQrCode, _name, _code);

            QRCodeEncoder encoder = new QRCodeEncoder();

            encoder.QRCodeEncodeMode = QRCodeEncoder.ENCODE_MODE.BYTE;
            encoder.QRCodeErrorCorrect = QRCodeEncoder.ERROR_CORRECTION.H;
            encoder.QRCodeBackgroundColor = Color.White;
            encoder.QRCodeForegroundColor = Color.Black;
            encoder.QRCodeScale = 1;
            Bitmap b = encoder.Encode(data);
            encoder.QRCodeScale = this.Width / b.Width;
            this.pbx_qrcode.Image = (Image)encoder.Encode(data);
        }
Exemplo n.º 21
0
        public QRCodeEncoder GetBusinessCoder(string urlBusiness)
        {
            try
            {
                PurpleBadgeEntities db = new PurpleBadgeEntities();
                // db.Filter=@"JPEG files|*.jpg;*.jpeg";
                MessagingToolkit.QRCode.Codec.QRCodeEncoder encoder = new MessagingToolkit.QRCode.Codec.QRCodeEncoder();
                encoder.QRCodeScale = 8;

                return(encoder);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
Exemplo n.º 22
0
        /// <summary>
        /// Método que devuelve un la imagen generada
        /// El primer parámetro es la palabra(s) a convertir
        /// y el segundo parámetro es el nivel. Este parámetro  es muy importante
        /// </summary>
        /// <param name="input"></param>
        /// <param name="qrlevel"></param>
        /// <returns></returns>
        public static Image QuickResponseGenerador(string input, int qrlevel)
        {
            string toenc = input;

            MessagingToolkit.QRCode.Codec.QRCodeEncoder qe = new MessagingToolkit.QRCode.Codec.QRCodeEncoder();

            qe.QRCodeEncodeMode = QRCodeEncoder.ENCODE_MODE.BYTE;

            qe.QRCodeErrorCorrect = QRCodeEncoder.ERROR_CORRECTION.L; // - Using LOW for more storage

            qe.QRCodeVersion = qrlevel;

            System.Drawing.Bitmap bm = qe.Encode(toenc);

            return(bm);
        }
Exemplo n.º 23
0
        public System.Drawing.Image GenerateImage(string data)
        {
            QRCodeEncoder encoder = new QRCodeEncoder();

            switch (this.EncoderType) {
                case EncodingType.Byte:
                    encoder.QRCodeEncodeMode = QRCodeEncoder.ENCODE_MODE.BYTE;
                break;
                case EncodingType.Alphanumeric:
                    encoder.QRCodeEncodeMode = QRCodeEncoder.ENCODE_MODE.ALPHA_NUMERIC;
                break;
                case EncodingType.Numeric:
                    encoder.QRCodeEncodeMode = QRCodeEncoder.ENCODE_MODE.NUMERIC;
                break;
                default:
                    encoder.QRCodeEncodeMode = QRCodeEncoder.ENCODE_MODE.ALPHA_NUMERIC;
                break;
            }

            switch (this.ErrorCorrection) {
                case ErrorCorrectionLevel.H:
                    encoder.QRCodeErrorCorrect = QRCodeEncoder.ERROR_CORRECTION.H;
                break;
                case ErrorCorrectionLevel.Q:
                    encoder.QRCodeErrorCorrect = QRCodeEncoder.ERROR_CORRECTION.Q;
                break;
                case ErrorCorrectionLevel.L:
                    encoder.QRCodeErrorCorrect = QRCodeEncoder.ERROR_CORRECTION.L;
                break;
                case ErrorCorrectionLevel.M:
                    encoder.QRCodeErrorCorrect = QRCodeEncoder.ERROR_CORRECTION.M;
                break;
                default:
                    encoder.QRCodeErrorCorrect = QRCodeEncoder.ERROR_CORRECTION.H;
                break;
            }

            encoder.QRCodeScale = this.Size;
            encoder.QRCodeVersion = this.Version;

            encoder.QRCodeErrorCorrect = QRCodeEncoder.ERROR_CORRECTION.M;
            encoder.QRCodeEncodeMode = QRCodeEncoder.ENCODE_MODE.BYTE;

            System.Drawing.Image qrCodeImage = encoder.Encode(data);

            return qrCodeImage;
        }
Exemplo n.º 24
0
        public static Bitmap GenerateImage(string text, Int32 scale)
        {
            if (!String.IsNullOrEmpty(text))
            {
                QRCodeEncoder qrCodeEncoder = new QRCodeEncoder();
                qrCodeEncoder.QRCodeScale = scale;
                String encoding = "Byte";
                if (encoding == "Byte")
                {
                    qrCodeEncoder.QRCodeEncodeMode = QRCodeEncoder.ENCODE_MODE.BYTE;
                }
                else if (encoding == "AlphaNumeric")
                {
                    qrCodeEncoder.QRCodeEncodeMode = QRCodeEncoder.ENCODE_MODE.ALPHA_NUMERIC;
                }
                else if (encoding == "Numeric")
                {
                    qrCodeEncoder.QRCodeEncodeMode = QRCodeEncoder.ENCODE_MODE.NUMERIC;
                }

                string errorCorrect = "L";
                if (errorCorrect == "L")
                    qrCodeEncoder.QRCodeErrorCorrect = QRCodeEncoder.ERROR_CORRECTION.L;
                else if (errorCorrect == "M")
                    qrCodeEncoder.QRCodeErrorCorrect = QRCodeEncoder.ERROR_CORRECTION.M;
                else if (errorCorrect == "Q")
                    qrCodeEncoder.QRCodeErrorCorrect = QRCodeEncoder.ERROR_CORRECTION.Q;
                else if (errorCorrect == "H")
                    qrCodeEncoder.QRCodeErrorCorrect = QRCodeEncoder.ERROR_CORRECTION.H;

                Image image = qrCodeEncoder.Encode(text);
                var g = Graphics.FromImage(image);

                Bitmap returnBitmap = new Bitmap(scale * 45, scale * 45);
                var rg = Graphics.FromImage(returnBitmap);
                rg.DrawImage(image, 0, 0);
                return returnBitmap;
            }
            else
            {
                return null;
            }
        }
Exemplo n.º 25
0
        public IActionResult Index()
        {
            var builder = new StringBuilder();

            builder.Append("00020101021229370016A0000006770101110113006691493165953037645802TH6304");
            var payload = builder.ToString().Select(x => Convert.ToByte(x)).ToArray();
            var crc     = new CRC16().ComputeCheckSum(payload);

            builder.Append(crc.ToString("X").PadLeft(4, '0'));
            var str = builder.ToString();

            MessagingToolkit.QRCode.Codec.QRCodeEncoder encoder = new MessagingToolkit.QRCode.Codec.QRCodeEncoder();
            encoder.QRCodeScale = 8;
            Bitmap bmp = encoder.Encode(str);



            return(View());
        }
Exemplo n.º 26
0
    //按鈕產生QRCode & 寫入資料庫
    protected void btnQRCode_Click(object sender, EventArgs e)
    {
        string strTitle = txtTitle.Text;
        string strContent = txtContent.Text;
        int couponID = 0;
        try
        {
            couponID = db.Coupon.OrderByDescending(cpID => cpID.couponID).FirstOrDefault().couponID+1;
        }
        catch (Exception)
        {
            couponID = 10010;
        }

        string docupath = Request.PhysicalApplicationPath; //抓取實際目錄路徑
        if (strTitle != "" && strContent != "") //判斷使用者輸入
        {
            string mContent = txtContent.Text;
            string mTime = DateTime.Now.Millisecond.ToString(); //取得當亂數

            lblMsg.Text = "qr_" + couponID + ".png"; //顯示檔名
            QRCodeEncoder mEncoder = new QRCodeEncoder(); //建立 encoder
            System.Drawing.Bitmap qrcode = mEncoder.Encode(couponID.ToString()); //將內容轉碼成 QR code

            qrcode.Save(docupath + "mPic\\qrcode\\qr_" + couponID + ".jpg"); //把 QRcode 另存為 jpg 圖檔,並放置於 images 資料夾底下
            imgQRCode.ImageUrl = "~\\mPic\\qrcode\\qr_" + couponID + ".jpg"; //設定組件 Image 的來源
        }
        else // txtContent 沒內容就不轉 QRcode + 提示訊息
        {
            lblMsg.Text = "請輸入資料!!";
            lblMsg.Visible = true;
            return;
        }

        //LINQ寫入資料庫
        Coupon coupon = new Coupon();
        coupon.title = strTitle;
        coupon.content = strContent;
        coupon.qrCode = "qrcode/qr_" + couponID + ".jpg";
        coupon.facilityID = (int)Session[CDictionary.SESSION_FACILITY_ID];
        db.Coupon.InsertOnSubmit(coupon);
        db.SubmitChanges();
    }
        internal Response MakeTransaction(Candidate candidate)
        {
            Response res     = new Response();
            string   message = "This is to certify that '" + candidate.name + "' has successfully completed the Web Design certification course at LearnUp Labs, Ranchi from 20th December 2019 to 24th December 2019";

            try
            {
                JObject jobj = JObject.Parse(RpcObj.SendToAddress(address, 0.00001M, "BLOCKCHAIN SUMMIT 2019 RANCHI", "BLOCKCHAIN SUMMIT 2019 RANCHI", false, false, 1, "UNSET", message));
                if (string.IsNullOrEmpty(jobj["error"].ToString()))
                {
                    transtrackurl += jobj["result"].ToString();
                    res.resp       = true;
                    res.type       = "Successful";
                    res.transID    = jobj["result"].ToString();

                    MessagingToolkit.QRCode.Codec.QRCodeEncoder encoder = new MessagingToolkit.QRCode.Codec.QRCodeEncoder();
                    encoder.QRCodeScale = 8;
                    Bitmap bmp = encoder.Encode(transtrackurl);

                    bmp.Save(FileName, ImageFormat.Jpeg);
                }
                else
                {
                    res.resp = false;
                    res.type = "Response Error";
                }
            }
            catch (RpcInternalServerErrorException rpc_exp)
            {
                res.resp = false;
                res.type = "Rpc Server Error Exception";
            }
            catch (Exception exp)
            {
                res.resp = false;
                res.type = "General Exception";
            }

            return(res);
        }
Exemplo n.º 28
0
        private Image QRCodeOlustur(string Veri1, int QrCodeDuzey)
        {
            string veri = Veri1;

            MessagingToolkit.QRCode.Codec.QRCodeEncoder QrCodeEncode = new MessagingToolkit.QRCode.Codec.QRCodeEncoder();
            QrCodeEncode.QRCodeEncodeMode = QRCodeEncoder.ENCODE_MODE.BYTE;
            string ECC = comboBox2.SelectedItem.ToString();

            if (ECC == "L")
            {
                QrCodeEncode.QRCodeErrorCorrect = QRCodeEncoder.ERROR_CORRECTION.L;
            }
            else if (ECC == "M")
            {
                QrCodeEncode.QRCodeErrorCorrect = QRCodeEncoder.ERROR_CORRECTION.M;
            }
            else if (ECC == "Q")
            {
                QrCodeEncode.QRCodeErrorCorrect = QRCodeEncoder.ERROR_CORRECTION.Q;
            }
            else if (ECC == "H")
            {
                QrCodeEncode.QRCodeErrorCorrect = QRCodeEncoder.ERROR_CORRECTION.H;
            }

            QrCodeEncode.QRCodeVersion = QrCodeDuzey;
            try
            {
                System.Drawing.Bitmap BitMap = QrCodeEncode.Encode(veri);
                return(BitMap);
            }
            catch (Exception)
            { MessageBox.Show("Lütfen Kategori Ayarını Doğru Seçiniz");
              string hata = "Hata";
              System.Drawing.Bitmap BitMap2 = QrCodeEncode.Encode(hata);
              return(BitMap2); }
        }
Exemplo n.º 29
0
        private Image QRCodeOlustur(string Veri1, int QrCodeDuzey)
        {
            string veri = Veri1;
                MessagingToolkit.QRCode.Codec.QRCodeEncoder QrCodeEncode = new MessagingToolkit.QRCode.Codec.QRCodeEncoder();
                QrCodeEncode.QRCodeEncodeMode = QRCodeEncoder.ENCODE_MODE.BYTE;
                string ECC = comboBox2.SelectedItem.ToString();
                if (ECC == "L") { QrCodeEncode.QRCodeErrorCorrect = QRCodeEncoder.ERROR_CORRECTION.L; }
                else if (ECC == "M") { QrCodeEncode.QRCodeErrorCorrect = QRCodeEncoder.ERROR_CORRECTION.M; }
                else if (ECC == "Q") { QrCodeEncode.QRCodeErrorCorrect = QRCodeEncoder.ERROR_CORRECTION.Q; }
                else if (ECC == "H") { QrCodeEncode.QRCodeErrorCorrect = QRCodeEncoder.ERROR_CORRECTION.H; }

                  QrCodeEncode.QRCodeVersion = QrCodeDuzey;
                  try
                  {
                      System.Drawing.Bitmap BitMap = QrCodeEncode.Encode(veri);
                      return BitMap;
                  }
                  catch (Exception)
                  {   MessageBox.Show("Lütfen Kategori Ayarını Doğru Seçiniz");
                      string hata="Hata";
                      System.Drawing.Bitmap BitMap2 = QrCodeEncode.Encode(hata);
                      return BitMap2;
                  }
        }
Exemplo n.º 30
0
        public ActionResult Imprimirnoco(int id)
        {
            DETALLECONFIRMAR valor = new DETALLECONFIRMAR();
            valor.detalle = new List<Detalle>();
            valor.notacompra = new NotaCompra();
            valor.notacompra = db.NotaCompra.Find(id);
            var maqueta3 = db.Maqueta3.Where(r => r.IDNOTACOMPRA == id).ToList();
            int? suma = 0;
            int? suma2 = 0;
            foreach (Maqueta3 item in maqueta3)
            {
                Detalle var = new Detalle();
                var.CANTIDAD = item.CANTIDAD;
                var.CODIGO = item.CODIGO;
                var.DESCRIPCION = item.DESCRIPCION;
                var.ID = item.ID;
                var.PRECIO = item.PRECIO;
                var.TOTAL = item.CANTIDAD * item.PRECIO;
                var.PROVEEDOR = item.Proveedores.Nombre;
                valor.detalle.Add(var);
                suma = suma + var.TOTAL;
                suma2 = suma2 + (item.PRECIOVENTA * item.CANTIDAD);
            }

            ViewBag.CostoFijo = suma;
            ViewBag.MargenVenta = suma2 - suma;
            float c = (float)suma2;
            c = 100 / c;
            ViewBag.margen = ((suma2 - suma) * c);
            ViewBag.check = valor.notacompra.CONFIRMACION;

            QRCodeEncoder encoder = new QRCodeEncoder();

            string URL = "http://ygd.cl/NotaCompra/Imprimirnoco/" + valor.notacompra.ID;
            string WorkingDirectory = this.Server.MapPath("~/uploadedFolder/");
            Bitmap img = encoder.Encode(URL);

            img.Save(WorkingDirectory + "img2.jpg", ImageFormat.Jpeg);
            return View(valor);
        }
Exemplo n.º 31
0
        private static sbyte[] CalculateRSECC(sbyte[] codewords, sbyte rsEccCodewords, sbyte[] rsBlockOrder, int maxDataCodewords, int maxCodewords)
        {
            sbyte[][] numArray1 = new sbyte[256][];
            for (int index = 0; index < 256; ++index)
            {
                numArray1[index] = new sbyte[(int)rsEccCodewords];
            }
            try
            {
                Stream         embeddedFile   = QRCodeEncoder.GetEmbeddedFile(QRCodeEncoder.DATA_PATH + ".rsc" + rsEccCodewords.ToString() + ".dat");
                BufferedStream bufferedStream = new BufferedStream(embeddedFile);
                for (int index = 0; index < 256; ++index)
                {
                    SystemUtils.ReadInput((Stream)bufferedStream, numArray1[index], 0, numArray1[index].Length);
                }
                bufferedStream.Close();
                embeddedFile.Close();
            }
            catch (Exception ex)
            {
                SystemUtils.WriteStackTrace(ex, Console.Error);
            }
            int index1 = 0;
            int index2 = 0;

            sbyte[][] numArray2 = new sbyte[rsBlockOrder.Length][];
            sbyte[]   numArray3 = new sbyte[maxCodewords];
            Array.Copy((Array)codewords, 0, (Array)numArray3, 0, codewords.Length);
            for (int index3 = 0; index3 < rsBlockOrder.Length; ++index3)
            {
                numArray2[index3] = new sbyte[((int)rsBlockOrder[index3] & (int)byte.MaxValue) - (int)rsEccCodewords];
            }
            for (int index3 = 0; index3 < maxDataCodewords; ++index3)
            {
                var s = codewords[index3];
                //numArray2[index2][index1] = codewords[index3];
                ++index1;
                if (index1 >= ((int)rsBlockOrder[index2] & (int)byte.MaxValue) - (int)rsEccCodewords)
                {
                    index1 = 0;
                    ++index2;
                }
            }
            for (int index3 = 0; index3 < rsBlockOrder.Length; ++index3)
            {
                sbyte[] numArray4 = new sbyte[numArray2[index3].Length];
                numArray2[index3].CopyTo((Array)numArray4, 0);
                for (int index4 = ((int)rsBlockOrder[index3] & (int)byte.MaxValue) - (int)rsEccCodewords; index4 > 0; --index4)
                {
                    sbyte num = numArray4[0];
                    if ((int)num != 0)
                    {
                        sbyte[] xa = new sbyte[numArray4.Length - 1];
                        Array.Copy((Array)numArray4, 1, (Array)xa, 0, numArray4.Length - 1);
                        sbyte[] xb = numArray1[(int)num & (int)byte.MaxValue];
                        numArray4 = QRCodeEncoder.CalculateByteArrayBits(xa, xb, "xor");
                    }
                    else if ((int)rsEccCodewords < numArray4.Length)
                    {
                        sbyte[] numArray5 = new sbyte[numArray4.Length - 1];
                        Array.Copy((Array)numArray4, 1, (Array)numArray5, 0, numArray4.Length - 1);
                        numArray4 = new sbyte[numArray5.Length];
                        numArray5.CopyTo((Array)numArray4, 0);
                    }
                    else
                    {
                        sbyte[] numArray5 = new sbyte[(int)rsEccCodewords];
                        Array.Copy((Array)numArray4, 1, (Array)numArray5, 0, numArray4.Length - 1);
                        numArray5[(int)rsEccCodewords - 1] = (sbyte)0;
                        numArray4 = new sbyte[numArray5.Length];
                        numArray5.CopyTo((Array)numArray4, 0);
                    }
                }
                Array.Copy((Array)numArray4, 0, (Array)numArray3, codewords.Length + index3 * (int)rsEccCodewords, (int)(byte)rsEccCodewords);
            }
            return(numArray3);
        }
Exemplo n.º 32
0
        public ActionResult DownloadPDF(int SuggId)
        {
            try
            {
                ISuggestionService suggestionService = new SuggestionService();
                suggestion suggestions = suggestionService.GetSuggestionById(SuggId);


               

                var model = new GeneratePDFModel();

                //get the information to display in pdf from database
                //for the time
                //Hard coding values are here, these are the content to display in pdf 

                var logoFile = @"/Images/logo.png";


                model.PDFLogo = Server.MapPath(logoFile);
                QRCodeEncoder en = new QRCodeEncoder();
                Image a = en.Encode("WLEED FLY 2015" + suggestions.offre.id + " " + suggestions.offre1.id);

                a.Save(Server.MapPath(@"~/Content/qr.bmp"), ImageFormat.Bmp);
                var content = "<div><table style='float: left' cellspacing='3'><tr><td><h1>trader 1 Username :"******"session"] + "<h1></td><td> </td><tr><td><h1>Offer Name:" + Session["cuser"].ToString() + "<h1></td><td> </td></tr></table></div>" +
              "<div><table  style='float: left' cellspacing='3'><tr><td><h1>trader 2 Username :<h1></td><td> </td><tr><td><h1>Offer Name:" + suggestions.offre1.name + "<h1></td><td> </td></tr></table></div>" + "<img src=" + char.ConvertFromUtf32(34) + Server.MapPath(@"~/Content/qr.bmp") + char.ConvertFromUtf32(34) + ";>";
                // @"~/Content/qr.bmp"
                //Use ViewAsPdf Class to generate pdf using GeneratePDF.cshtml view
                model.PDFContent = content;

                return new Rotativa.ViewAsPdf("GeneratePDF", model) { FileName = "firstPdf.pdf" };

            }
            catch (Exception)
            {

                throw;
            } 

        }
Exemplo n.º 33
0
 //generate qrcode based on the string
 private Bitmap generateQRCode()
 {
     string qrString = getQRString();
     QRCodeEncoder enc = new QRCodeEncoder();
     Bitmap qrBitmapCode = enc.Encode(qrString);
     //borrameQRCode.Save(@"C:\test1.txt");
     return qrBitmapCode;
 }
Exemplo n.º 34
0
        public ActionResult Imprimir(FormCollection formulario, string GUIA)
        {
            string TEXTO = "<h2>PRODUCTOS RETIRO BODEGAL-PROBAG CON LOGOS</h2>";
            TEXTO = "<table><tr><th>DESCRIPCION</th><th>LOGO</th><th>CAJAS</th><th>CODIGO</th><th>UNI.x CAJA</th><th>TOTAL</th><th>SOBRANTE</th><th>GUIA</th><th>MAQUETA</th><th>VENDEDOR</th><th>CLIENTE</th><th>STOCK</th></tr>";
            List<Datos> datos = new List<Datos>();
            IValueProvider valueProvider = formulario.ToValueProvider();
            for (int i = 2; i < formulario.Count; i++)
            {
                Datos dato = new Datos();
                //PEDIDOS A BODEGAL
                string valor = formulario.Keys[i].ToString();

                Maqueta maqueta = db.Maqueta.Find(valor);
                maqueta.ESTADO = "PEDIDOS A BODEGAL";
                db.Entry(maqueta).State = EntityState.Modified;

                Estado estado = new Estado();
                estado.FECHA = DateTime.Now;
                estado.IDMAQUETA = maqueta.CODIGO;
                estado.NOMBRE = "PEDIDOS A BODEGAL";
                db.Estado.Add(estado);
                db.SaveChanges();

                Detalle detalle = new Detalle();
                detalle.CANTIDAD = int.Parse(maqueta.CANTIDAD.ToString());
                detalle.ACUMULADO = int.Parse(maqueta.CANTIDAD.ToString());
                detalle.FECHA = DateTime.Now;
                detalle.TIPO = "PEDIDOS A BODEGAL";
                detalle.IDMAQUETA = maqueta.CODIGO;
                detalle.MOVIMIENTO = formulario.Keys[0].ToString();
                detalle.ORIGEN = "BODEGAL";

                Producto producto = db.Producto.Find(maqueta.CODPRODUCTO);  //PIDO PRODUCTO
                int auxiliarmio =0;
                int cantidad = int.Parse(maqueta.CANTIDAD.ToString());      //GUARDO TOTAL
                int unicajas = int.Parse(maqueta.Producto.UNIDADESXCAJA.ToString()); //GUARDO UNIDADES POR CAJA

                if (producto.STOCKLOCAL != 0 && producto.STOCKLOCAL != null)//VERIFICO SI HAY EN STOCKLOCAL
                {
                    auxiliarmio = producto.STOCKLOCAL.Value;
                    if (cantidad >= producto.STOCKLOCAL.Value) //VERIFICO SI EL STOCK LOCAL ES MENOR IGUAL A LA CANTIDAD PEDIDA
                    {
                        cantidad = cantidad - producto.STOCKLOCAL.Value; //RESTO STOCKLOCAL A LA CANTIDAD PEDIDA
                        if (cantidad == 0)
                        {
                            producto.STOCKLOCAL = producto.STOCKLOCAL.Value - int.Parse(maqueta.CANTIDAD.ToString());
                        }
                        else
                        {
                            producto.STOCKLOCAL = 0;
                        }
                    }
                    else
                    {
                        cantidad = 0;
                        producto.STOCKLOCAL = producto.STOCKLOCAL.Value - int.Parse(maqueta.CANTIDAD.ToString());
                    }
                }

                int entero = cantidad / unicajas;
                int sobra = cantidad % unicajas;
                int sobrantes = 0;
                if (sobra != 0)
                {
                    entero++;
                    sobrantes = unicajas * entero;
                    sobrantes = sobrantes - cantidad;
                }

                dato.NombrEProductO = maqueta.Producto.NOMBRE;
                dato.CajaS = entero;
                dato.CodigOProductO = maqueta.Producto.CODIGO;
                dato.UnidadeSXCajA = int.Parse(maqueta.Producto.UNIDADESXCAJA.ToString());
                dato.CantidaD = int.Parse(maqueta.CANTIDAD.ToString());
                dato.GuiA = GUIA;
                dato.MaquetA = maqueta.CODIGO;
                dato.SobrantE = sobrantes - auxiliarmio;
                dato.VendedoR = maqueta.Usuario.NOMBRE.ToString();
                dato.LogO = maqueta.LOGOTIPO;
                if(maqueta.IDCLIENTE!=null)
                    dato.Cliente = maqueta.Cliente.EMPRESA.ToString();

                //DESCONTAR DE STOCK
                producto.STOCK = producto.STOCK - dato.CajaS;
                if (sobra != 0)
                {
                    producto.STOCKLOCAL = producto.STOCKLOCAL + (producto.UNIDADESXCAJA - sobra);
                }
                db.Entry(producto).State = EntityState.Modified;
                db.SaveChanges();

                Bodegal bodegal = new Bodegal();
                bodegal.Guia = int.Parse(dato.GuiA);
                bodegal.Fecha = DateTime.Now;
                bodegal.Movido = dato.CajaS;
                bodegal.Sobrantes = dato.SobrantE;
                bodegal.Stock = producto.STOCK.Value;
                bodegal.Donde = true;
                bodegal.FkProducto = producto.ID;
                db.Bodegal.Add(bodegal);

                dato.StocK = producto.STOCK.Value;
                datos.Add(dato);

                //AGREGAR EN STRING PARA CORREO;
                TEXTO =TEXTO + "<tr><td>"+dato.NombrEProductO + "</td><td>"+dato.LogO+"</td><td>"+dato.CajaS+"</td><td>"+dato.CodigOProductO+"</td><td>"+dato.UnidadeSXCajA+"</td><td>"+dato.CantidaD+"</td><td>"+dato.SobrantE+"</td><td>"+dato.GuiA+"</td><td>"+dato.MaquetA+"</td><td>"+dato.VendedoR+"</td><td>"+dato.Cliente+"</td><td>"+dato.StocK + "</td></tr>";
            }
            TEXTO = TEXTO + "</table>";
            List<string> correos = db.Usuario.Where(r => r.IDCARGO == 8 || r.IDCARGO == 1).Select(r => r.EMAIL).ToList();
            _MailService.SendEmailvarioscorreos("Pedido a Bodegal CON LOGO", correos, TEXTO);

            Datos primer = datos.FirstOrDefault();
            QRCodeEncoder encoder = new QRCodeEncoder();
            string URL = "Numero de la Guia: " + primer.GuiA;
            string WorkingDirectory = this.Server.MapPath("~/uploadedFolder/");
            Bitmap img = encoder.Encode(URL);
            img.Save(WorkingDirectory + "img3.jpg", ImageFormat.Jpeg);

            return View(datos.ToList());
        }
Exemplo n.º 35
0
 internal static Bitmap GetEmbeddedImage(string fileName)
 {
     return(new Bitmap(QRCodeEncoder.GetEmbeddedFile(fileName)));
 }
Exemplo n.º 36
0
 /// <summary>
 ///     Generates a QRCode with the given string to be encoded and the level (ie size) of the qr code.
 /// </summary>
 /// <param name="encodedString">The string that should be encoded into the QRCode.</param>
 /// <param name="level">Detail level of QRCode can be changed using this. Higher = more detail but less time to process.</param>
 /// <returns>bitmap of the generated QRCode</returns>
 private Image QRGenerator(string encodedString, int level)
 {
     var qrEncoder = new QRCodeEncoder
     {
         QRCodeEncodeMode = QRCodeEncoder.ENCODE_MODE.BYTE,
         QRCodeErrorCorrect = QRCodeEncoder.ERROR_CORRECTION.L,
         QRCodeVersion = level
     };
     // Encode image into new bitmap instance.
     Bitmap bitmap = qrEncoder.Encode(encodedString);
     return bitmap;
 }
Exemplo n.º 37
0
        private void ShowReport(string category, string path, string catName)
        {
            var myqr = new QRCodeEncoder();
            Bitmap img = myqr.Encode(category + _counter);
            img.Save(path + _counter + ".jpg", ImageFormat.Jpeg);

            BitmapImage bim = new BitmapImage();
            bim.BeginInit();
            bim.UriSource = new Uri(path + _counter + ".jpg", UriKind.Relative);
            bim.CacheOption = BitmapCacheOption.OnLoad;
            bim.EndInit();

            new Window1(bim, category + _counter, catName).Show();
        }
Exemplo n.º 38
0
        public ViewResult Imprimir(string id)
        {
            tipusu();
            LosDos variable = new LosDos();
            variable.NotaVenta = db.NotaVenta.Find(id);
            variable.DetalleNotaVenta = db.Maqueta2.Where(r => r.IDNOTAVENTA == id).ToList();

            QRCodeEncoder encoder = new QRCodeEncoder();

            string URL = "http://ygd.cl/NotaVenta/Details/" + variable.NotaVenta.ID;
            string WorkingDirectory = this.Server.MapPath("~/uploadedFolder/");
            Bitmap img= encoder.Encode(URL);

            img.Save(WorkingDirectory+"img.jpg",ImageFormat.Jpeg);

            return View(variable);
        }
Exemplo n.º 39
0
        public virtual bool[][] CalQrcode(byte[] qrcodeData)
        {
            int index1  = 0;
            int length1 = qrcodeData.Length;

            int[]   data = new int[length1 + 32];
            sbyte[] bits = new sbyte[length1 + 32];
            if (length1 <= 0)
            {
                return new bool[1][] { new bool[1] }
            }
            ;
            if (this.qrcodeStructureappendN > 1)
            {
                data[0] = 3;

                bits[0] = (sbyte)4;
                data[1] = this.qrcodeStructureappendM - 1;
                bits[1] = (sbyte)4;
                data[2] = this.qrcodeStructureappendN - 1;
                bits[2] = (sbyte)4;
                data[3] = this.qrcodeStructureappendParity;
                bits[3] = (sbyte)8;
                index1  = 4;
            }
            bits[index1] = (sbyte)4;
            int[] numArray1;
            int   index2;
            int   index3;

            switch (this.qrcodeEncodeMode)
            {
            case QRCodeEncoder.ENCODE_MODE.ALPHA_NUMERIC:
                numArray1 = new int[41]
                {
                    0,
                    0,
                    0,
                    0,
                    0,
                    0,
                    0,
                    0,
                    0,
                    0,
                    2,
                    2,
                    2,
                    2,
                    2,
                    2,
                    2,
                    2,
                    2,
                    2,
                    2,
                    2,
                    2,
                    2,
                    2,
                    2,
                    2,
                    4,
                    4,
                    4,
                    4,
                    4,
                    4,
                    4,
                    4,
                    4,
                    4,
                    4,
                    4,
                    4,
                    4
                };
                data[index1] = 2;
                int index4 = index1 + 1;
                data[index4] = length1;
                bits[index4] = (sbyte)9;
                index2       = index4;
                int index5 = index4 + 1;
                for (int index6 = 0; index6 < length1; ++index6)
                {
                    char  ch  = (char)qrcodeData[index6];
                    sbyte num = 0;
                    if ((int)ch >= 48 && (int)ch < 58)
                    {
                        num = (sbyte)((int)ch - 48);
                    }
                    else if ((int)ch >= 65 && (int)ch < 91)
                    {
                        num = (sbyte)((int)ch - 55);
                    }
                    else
                    {
                        if ((int)ch == 32)
                        {
                            num = (sbyte)36;
                        }
                        if ((int)ch == 36)
                        {
                            num = (sbyte)37;
                        }
                        if ((int)ch == 37)
                        {
                            num = (sbyte)38;
                        }
                        if ((int)ch == 42)
                        {
                            num = (sbyte)39;
                        }
                        if ((int)ch == 43)
                        {
                            num = (sbyte)40;
                        }
                        if ((int)ch == 45)
                        {
                            num = (sbyte)41;
                        }
                        if ((int)ch == 46)
                        {
                            num = (sbyte)42;
                        }
                        if ((int)ch == 47)
                        {
                            num = (sbyte)43;
                        }
                        if ((int)ch == 58)
                        {
                            num = (sbyte)44;
                        }
                    }
                    if (index6 % 2 == 0)
                    {
                        data[index5] = (int)num;
                        bits[index5] = (sbyte)6;
                    }
                    else
                    {
                        data[index5] = data[index5] * 45 + (int)num;
                        bits[index5] = (sbyte)11;
                        if (index6 < length1 - 1)
                        {
                            ++index5;
                        }
                    }
                }
                index3 = index5 + 1;
                break;

            case QRCodeEncoder.ENCODE_MODE.NUMERIC:
                numArray1 = new int[41]
                {
                    0,
                    0,
                    0,
                    0,
                    0,
                    0,
                    0,
                    0,
                    0,
                    0,
                    2,
                    2,
                    2,
                    2,
                    2,
                    2,
                    2,
                    2,
                    2,
                    2,
                    2,
                    2,
                    2,
                    2,
                    2,
                    2,
                    2,
                    4,
                    4,
                    4,
                    4,
                    4,
                    4,
                    4,
                    4,
                    4,
                    4,
                    4,
                    4,
                    4,
                    4
                };
                data[index1] = 1;
                int index7 = index1 + 1;
                data[index7] = length1;
                bits[index7] = (sbyte)10;
                index2       = index7;
                int index8 = index7 + 1;
                for (int index6 = 0; index6 < length1; ++index6)
                {
                    if (index6 % 3 == 0)
                    {
                        data[index8] = (int)qrcodeData[index6] - 48;
                        bits[index8] = (sbyte)4;
                    }
                    else
                    {
                        data[index8] = data[index8] * 10 + ((int)qrcodeData[index6] - 48);
                        if (index6 % 3 == 1)
                        {
                            bits[index8] = (sbyte)7;
                        }
                        else
                        {
                            bits[index8] = (sbyte)10;
                            if (index6 < length1 - 1)
                            {
                                ++index8;
                            }
                        }
                    }
                }
                index3 = index8 + 1;
                break;

            default:
                numArray1 = new int[41]
                {
                    0,
                    0,
                    0,
                    0,
                    0,
                    0,
                    0,
                    0,
                    0,
                    0,
                    8,
                    8,
                    8,
                    8,
                    8,
                    8,
                    8,
                    8,
                    8,
                    8,
                    8,
                    8,
                    8,
                    8,
                    8,
                    8,
                    8,
                    8,
                    8,
                    8,
                    8,
                    8,
                    8,
                    8,
                    8,
                    8,
                    8,
                    8,
                    8,
                    8,
                    8
                };
                data[index1] = 4;
                int index9 = index1 + 1;
                data[index9] = length1;
                bits[index9] = (sbyte)8;
                index2       = index9;
                int num1 = index9 + 1;
                for (int index6 = 0; index6 < length1; ++index6)
                {
                    data[index6 + num1] = (int)qrcodeData[index6] & (int)byte.MaxValue;
                    bits[index6 + num1] = (sbyte)8;
                }
                index3 = num1 + length1;
                break;
            }
            int num2 = 0;

            for (int index6 = 0; index6 < index3; ++index6)
            {
                num2 += (int)bits[index6];
            }
            int index10;

            switch (this.qrcodeErrorCorrect)
            {
            case QRCodeEncoder.ERROR_CORRECTION.L:
                index10 = 1;
                break;

            case QRCodeEncoder.ERROR_CORRECTION.Q:
                index10 = 3;
                break;

            case QRCodeEncoder.ERROR_CORRECTION.H:
                index10 = 2;
                break;

            default:
                index10 = 0;
                break;
            }
            int[][] numArray2 = new int[4][]
            {
                new int[41]
                {
                    0,
                    128,
                    224,
                    352,
                    512,
                    688,
                    864,
                    992,
                    1232,
                    1456,
                    1728,
                    2032,
                    2320,
                    2672,
                    2920,
                    3320,
                    3624,
                    4056,
                    4504,
                    5016,
                    5352,
                    5712,
                    6256,
                    6880,
                    7312,
                    8000,
                    8496,
                    9024,
                    9544,
                    10136,
                    10984,
                    11640,
                    12328,
                    13048,
                    13800,
                    14496,
                    15312,
                    15936,
                    16816,
                    17728,
                    18672
                },
                new int[41]
                {
                    0,
                    152,
                    272,
                    440,
                    640,
                    864,
                    1088,
                    1248,
                    1552,
                    1856,
                    2192,
                    2592,
                    2960,
                    3424,
                    3688,
                    4184,
                    4712,
                    5176,
                    5768,
                    6360,
                    6888,
                    7456,
                    8048,
                    8752,
                    9392,
                    10208,
                    10960,
                    11744,
                    12248,
                    13048,
                    13880,
                    14744,
                    15640,
                    16568,
                    17528,
                    18448,
                    19472,
                    20528,
                    21616,
                    22496,
                    23648
                },
                new int[41]
                {
                    0,
                    72,
                    128,
                    208,
                    288,
                    368,
                    480,
                    528,
                    688,
                    800,
                    976,
                    1120,
                    1264,
                    1440,
                    1576,
                    1784,
                    2024,
                    2264,
                    2504,
                    2728,
                    3080,
                    3248,
                    3536,
                    3712,
                    4112,
                    4304,
                    4768,
                    5024,
                    5288,
                    5608,
                    5960,
                    6344,
                    6760,
                    7208,
                    7688,
                    7888,
                    8432,
                    8768,
                    9136,
                    9776,
                    10208
                },
                new int[41]
                {
                    0,
                    104,
                    176,
                    272,
                    384,
                    496,
                    608,
                    704,
                    880,
                    1056,
                    1232,
                    1440,
                    1648,
                    1952,
                    2088,
                    2360,
                    2600,
                    2936,
                    3176,
                    3560,
                    3880,
                    4096,
                    4544,
                    4912,
                    5312,
                    5744,
                    6032,
                    6464,
                    6968,
                    7288,
                    7880,
                    8264,
                    8920,
                    9368,
                    9848,
                    10288,
                    10832,
                    11408,
                    12016,
                    12656,
                    13328
                }
            };
            int num3 = 0;

            if (this.qrcodeVersion == 0)
            {
                this.qrcodeVersion = 1;
                for (int index6 = 1; index6 <= 40; ++index6)
                {
                    if (numArray2[index10][index6] >= num2 + numArray1[this.qrcodeVersion])
                    {
                        num3 = numArray2[index10][index6];
                        break;
                    }
                    ++this.qrcodeVersion;
                }
            }
            else
            {
                num3 = numArray2[index10][this.qrcodeVersion];
            }
            int num4 = num2 + numArray1[this.qrcodeVersion];

            bits[index2] = (sbyte)((int)bits[index2] + numArray1[this.qrcodeVersion]);
            int maxCodewords = new int[41]
            {
                0,
                26,
                44,
                70,
                100,
                134,
                172,
                196,
                242,
                292,
                346,
                404,
                466,
                532,
                581,
                655,
                733,
                815,
                901,
                991,
                1085,
                1156,
                1258,
                1364,
                1474,
                1588,
                1706,
                1828,
                1921,
                2051,
                2185,
                2323,
                2465,
                2611,
                2761,
                2876,
                3034,
                3196,
                3362,
                3532,
                3706
            }[this.qrcodeVersion];
            int num5 = 17 + (this.qrcodeVersion << 2);

            int[] numArray3 = new int[41]
            {
                0,
                0,
                7,
                7,
                7,
                7,
                7,
                0,
                0,
                0,
                0,
                0,
                0,
                0,
                3,
                3,
                3,
                3,
                3,
                3,
                3,
                4,
                4,
                4,
                4,
                4,
                4,
                4,
                3,
                3,
                3,
                3,
                3,
                3,
                3,
                0,
                0,
                0,
                0,
                0,
                0
            };
            int length2 = numArray3[this.qrcodeVersion] + (maxCodewords << 3);

            sbyte[] target1 = new sbyte[length2];
            sbyte[] target2 = new sbyte[length2];
            sbyte[] target3 = new sbyte[length2];
            sbyte[] target4 = new sbyte[15];
            sbyte[] target5 = new sbyte[15];
            sbyte[] target6 = new sbyte[1];
            sbyte[] target7 = new sbyte[128];
            try
            {
                Stream         embeddedFile   = QRCodeEncoder.GetEmbeddedFile(QRCodeEncoder.DATA_PATH + ".qrv" + Convert.ToString(this.qrcodeVersion) + "_" + Convert.ToString(index10) + ".dat");
                BufferedStream bufferedStream = new BufferedStream(embeddedFile);
                SystemUtils.ReadInput((Stream)bufferedStream, target1, 0, target1.Length);
                SystemUtils.ReadInput((Stream)bufferedStream, target2, 0, target2.Length);
                SystemUtils.ReadInput((Stream)bufferedStream, target3, 0, target3.Length);
                SystemUtils.ReadInput((Stream)bufferedStream, target4, 0, target4.Length);
                SystemUtils.ReadInput((Stream)bufferedStream, target5, 0, target5.Length);
                SystemUtils.ReadInput((Stream)bufferedStream, target6, 0, target6.Length);
                SystemUtils.ReadInput((Stream)bufferedStream, target7, 0, target7.Length);
                bufferedStream.Close();
                embeddedFile.Close();
            }
            catch (Exception ex)
            {
                SystemUtils.WriteStackTrace(ex, Console.Error);
            }
            sbyte num6 = 1;

            for (byte index6 = 1; (int)index6 < 128; ++index6)
            {
                if ((int)target7[(int)index6] == 0)
                {
                    num6 = (sbyte)index6;
                    break;
                }
            }
            sbyte[] rsBlockOrder = new sbyte[(int)num6];
            Array.Copy((Array)target7, 0, (Array)rsBlockOrder, 0, (int)(byte)num6);
            sbyte[] numArray4 = new sbyte[15]
            {
                (sbyte)0,
                (sbyte)1,
                (sbyte)2,
                (sbyte)3,
                (sbyte)4,
                (sbyte)5,
                (sbyte)7,
                (sbyte)8,
                (sbyte)8,
                (sbyte)8,
                (sbyte)8,
                (sbyte)8,
                (sbyte)8,
                (sbyte)8,
                (sbyte)8
            };
            sbyte[] numArray5 = new sbyte[15]
            {
                (sbyte)8,
                (sbyte)8,
                (sbyte)8,
                (sbyte)8,
                (sbyte)8,
                (sbyte)8,
                (sbyte)8,
                (sbyte)8,
                (sbyte)7,
                (sbyte)5,
                (sbyte)4,
                (sbyte)3,
                (sbyte)2,
                (sbyte)1,
                (sbyte)0
            };
            int maxDataCodewords = num3 >> 3;
            int length3          = 4 * this.qrcodeVersion + 17;

            sbyte[] target8 = new sbyte[length3 * length3 + length3];
            try
            {
                Stream         embeddedFile   = QRCodeEncoder.GetEmbeddedFile(QRCodeEncoder.DATA_PATH + ".qrvfr" + Convert.ToString(this.qrcodeVersion) + ".dat");
                BufferedStream bufferedStream = new BufferedStream(embeddedFile);
                SystemUtils.ReadInput((Stream)bufferedStream, target8, 0, target8.Length);
                bufferedStream.Close();
                embeddedFile.Close();
            }
            catch (Exception ex)
            {
                SystemUtils.WriteStackTrace(ex, Console.Error);
            }
            if (num4 <= num3 - 4)
            {
                data[index3] = 0;
                bits[index3] = (sbyte)4;
            }
            else if (num4 < num3)
            {
                data[index3] = 0;
                bits[index3] = (sbyte)(num3 - num4);
            }
            else if (num4 > num3)
            {
                Console.Out.WriteLine("overflow");
            }
            sbyte[]   rsecc         = QRCodeEncoder.CalculateRSECC(QRCodeEncoder.DivideDataBy8Bits(data, bits, maxDataCodewords), target6[0], rsBlockOrder, maxDataCodewords, maxCodewords);
            sbyte[][] matrixContent = new sbyte[length3][];
            for (int index6 = 0; index6 < length3; ++index6)
            {
                matrixContent[index6] = new sbyte[length3];
            }
            for (int index6 = 0; index6 < length3; ++index6)
            {
                for (int index11 = 0; index11 < length3; ++index11)
                {
                    matrixContent[index11][index6] = (sbyte)0;
                }
            }
            for (int index6 = 0; index6 < maxCodewords; ++index6)
            {
                sbyte num7 = rsecc[index6];
                for (int index11 = 7; index11 >= 0; --index11)
                {
                    int index12 = index6 * 8 + index11;
                    matrixContent[(int)target1[index12] & (int)byte.MaxValue][(int)target2[index12] & (int)byte.MaxValue] = (sbyte)((int)byte.MaxValue * ((int)num7 & 1) ^ (int)target3[index12]);
                    num7 = (sbyte)SystemUtils.URShift((int)num7 & (int)byte.MaxValue, 1);
                }
            }
            for (int index6 = numArray3[this.qrcodeVersion]; index6 > 0; --index6)
            {
                int index11 = index6 + maxCodewords * 8 - 1;
                matrixContent[(int)target1[index11] & (int)byte.MaxValue][(int)target2[index11] & (int)byte.MaxValue] = (sbyte)((int)byte.MaxValue ^ (int)target3[index11]);
            }
            sbyte num8  = QRCodeEncoder.SelectMask(matrixContent, numArray3[this.qrcodeVersion] + maxCodewords * 8);
            sbyte num9  = (sbyte)(1 << (int)num8);
            sbyte num10 = (sbyte)(index10 << 3 | (int)(byte)num8);

            string[] strArray = new string[32]
            {
                "101010000010010",
                "101000100100101",
                "101111001111100",
                "101101101001011",
                "100010111111001",
                "100000011001110",
                "100111110010111",
                "100101010100000",
                "111011111000100",
                "111001011110011",
                "111110110101010",
                "111100010011101",
                "110011000101111",
                "110001100011000",
                "110110001000001",
                "110100101110110",
                "001011010001001",
                "001001110111110",
                "001110011100111",
                "001100111010000",
                "000011101100010",
                "000001001010101",
                "000110100001100",
                "000100000111011",
                "011010101011111",
                "011000001101000",
                "011111100110001",
                "011101000000110",
                "010010010110100",
                "010000110000011",
                "010111011011010",
                "010101111101101"
            };
            for (int startIndex = 0; startIndex < 15; ++startIndex)
            {
                sbyte num7 = sbyte.Parse(strArray[(int)num10].Substring(startIndex, startIndex + 1 - startIndex));
                matrixContent[(int)numArray4[startIndex] & (int)byte.MaxValue][(int)numArray5[startIndex] & (int)byte.MaxValue] = (sbyte)((int)num7 * (int)byte.MaxValue);
                matrixContent[(int)target4[startIndex] & (int)byte.MaxValue][(int)target5[startIndex] & (int)byte.MaxValue]     = (sbyte)((int)num7 * (int)byte.MaxValue);
            }
            bool[][] flagArray = new bool[length3][];
            for (int index6 = 0; index6 < length3; ++index6)
            {
                flagArray[index6] = new bool[length3];
            }
            int index13 = 0;

            for (int index6 = 0; index6 < length3; ++index6)
            {
                for (int index11 = 0; index11 < length3; ++index11)
                {
                    int num7 = ((int)matrixContent[index11][index6] & (int)num9) != 0 ? 0 : ((int)target8[index13] != 49 ? 1 : 0);
                    flagArray[index11][index6] = num7 == 0;
                    ++index13;
                }
                ++index13;
            }
            return(flagArray);
        }
Exemplo n.º 40
0
        private void CreateQRCode(
            int scale,
            string errCorrection,
            string fullUrl,
            string explanation,
            int cornerRadius,
            bool animate,
            string backgroundImage,
            string foregroundImage,
            string backgroundColor,
            string foregroundColor,
            string fontName,
            int fontSize,
            string fontColor,
            int rotateAngle,
            string physicalPath)
        {
            // Setting up our QR Code Generator ...
            QRCodeEncoder qrCodeEncoder = new QRCodeEncoder();
            qrCodeEncoder.QRCodeEncodeMode = QRCodeEncoder.ENCODE_MODE.BYTE;
            qrCodeEncoder.QRCodeScale = scale;
            qrCodeEncoder.QRCodeErrorCorrect =
                (QRCodeEncoder.ERROR_CORRECTION)
                    Enum.Parse(typeof(QRCodeEncoder.ERROR_CORRECTION),
                    errCorrection);
            qrCodeEncoder.QRCodeBackgroundColor = Color.White;
            qrCodeEncoder.QRCodeForegroundColor = Color.Black;

            if (!string.IsNullOrEmpty(foregroundColor))
                qrCodeEncoder.QRCodeForegroundColor = System.Drawing.ColorTranslator.FromHtml(foregroundColor);

            if (!string.IsNullOrEmpty(backgroundColor))
                qrCodeEncoder.QRCodeBackgroundColor = System.Drawing.ColorTranslator.FromHtml(backgroundColor);

            // 'Guessing' the version number according to number of bytes ...
            qrCodeEncoder.QRCodeVersion = GetQRCodeVersion(fullUrl, errCorrection);

            // Encoding the QR Code, raw format ...
            using (Image qrRaw = qrCodeEncoder.Encode(fullUrl, Encoding.UTF8))
            {
                // Adding "white borders".
                // MUST be done before the 'effect' is applied ...
                using (Image qrScaled = GetAdditionalBorders(
                    qrRaw,
                    qrCodeEncoder.QRCodeScale,
                    !string.IsNullOrEmpty(explanation),
                    cornerRadius,
                    backgroundColor))
                {

                    // 'Animating' the QR Code [skews the black and white]
                    using (Image imgBlurred = GetAnimatedImage(
                        qrScaled,
                        qrCodeEncoder.QRCodeScale - 1,
                        animate))
                    {
                        using (Image imgBackgroundExchanged =
                            ExchangeColorWithTextureBrush(
                                imgBlurred,
                                backgroundImage,
                                Color.FromArgb(255, 255, 255, 255)))
                        {
                            using (Image imgForegroundExchanged =
                                ExchangeColorWithTextureBrush(
                                    imgBackgroundExchanged,
                                    foregroundImage,
                                    Color.FromArgb(255, 0, 0, 0)))
                            {
                                if (!string.IsNullOrEmpty(explanation))
                                {
                                    using (Graphics gText = Graphics.FromImage(imgForegroundExchanged))
                                    {
                                        if (fontSize == -1)
                                        {
                                            // Figuring out the optimal font size automatically
                                            int maxSize = imgForegroundExchanged.Width - 20;
                                            fontSize = 25; // default
                                            while (true)
                                            {
                                                using (Font font = new Font(fontName, fontSize))
                                                {
                                                    SizeF size = gText.MeasureString(explanation, font);
                                                    if (size.Width < maxSize)
                                                        break;
                                                    if (fontSize < 10)
                                                        break;
                                                    fontSize -= 1;
                                                }
                                            }
                                        }
                                        using (Font font = new Font(
                                                fontName,
                                                fontSize))
                                        {
                                            gText.PageUnit = GraphicsUnit.Pixel;
                                            SizeF size = gText.MeasureString(explanation, font);
                                            using (Brush b = CreateBrush(fontColor))
                                            {
                                                gText.DrawString(
                                                    explanation,
                                                    font,
                                                    b,
                                                    Math.Max(5,
                                                    (imgForegroundExchanged.Width / 2) - (int)size.Width / 2) +
                                                        fontSize / 4,
                                                    imgForegroundExchanged.Height -
                                                        ((qrCodeEncoder.QRCodeScale * 5) +
                                                            ((int)size.Height / 2)),
                                                    StringFormat.GenericTypographic);
                                            }
                                        }
                                    }
                                }
                                using (Bitmap last =
                                    GetRotateImage(
                                        (Bitmap)imgForegroundExchanged,
                                        rotateAngle))
                                {
                                    // This is our 'end product', though not entirely finished yet ...
                                    using (Image finalResult =
                                        new Bitmap(
                                            last.Width,
                                            last.Height,
                                            PixelFormat.Format32bppArgb))
                                    {
                                        using (Graphics g = Graphics.FromImage(finalResult))
                                        {
                                            ImageAttributes atrs = new ImageAttributes();
                                            atrs.SetColorKey(
                                                Color.FromArgb(255, 254, 254, 254),
                                                Color.FromArgb(255, 254, 254, 254));
                                            g.DrawImage(
                                                last,
                                                new Rectangle(0, 0, last.Width, last.Height),
                                                0,
                                                0,
                                                last.Width,
                                                last.Height,
                                                GraphicsUnit.Pixel,
                                                atrs);
                                        }
                                        finalResult.Save(physicalPath, ImageFormat.Png);
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
Exemplo n.º 41
0
        public void ProcessRequest(HttpContext context)
        {
            String data = context.Request["t"];
            if (!string.IsNullOrEmpty(data))
            {
                QRCodeEncoder qrCodeEncoder = new QRCodeEncoder();
                qrCodeEncoder.QRCodeEncodeMode = QRCodeEncoder.ENCODE_MODE.BYTE;
                qrCodeEncoder.QRCodeScale = 4;
                qrCodeEncoder.QRCodeVersion = 8;
                qrCodeEncoder.QRCodeErrorCorrect = QRCodeEncoder.ERROR_CORRECTION.M;
                System.Drawing.Image image = qrCodeEncoder.Encode(data);
                System.IO.MemoryStream MStream = new System.IO.MemoryStream();
                image.Save(MStream, System.Drawing.Imaging.ImageFormat.Png);

                System.IO.MemoryStream MStream1 = new System.IO.MemoryStream();
                CombinImage(image, context.Server.MapPath("~/images/iconappli1.png")).Save(MStream1, System.Drawing.Imaging.ImageFormat.Png);
                context.Response.ClearContent();
                context.Response.ContentType = "image/png";
                context.Response.BinaryWrite(MStream1.ToArray());
                MStream.Dispose();
                MStream1.Dispose();
            }
            context.Response.Flush();
            context.Response.End();
        }
Exemplo n.º 42
0
        public ActionResult Imprimir2(FormCollection formulario, string GUIA)
        {
            string TEXTO = "<h2>PRODUCTOS RETIRO BODEGAL-PROBAG SIN LOGO</h2>";
            TEXTO = "<table><tr><th>DESCRIPCION</th><th>CAJAS</th><th>CODIGO</th><th>UNI. x CAJA</th><th>CANT. TOTAL</th><th>SOBRANTES</th><th>GUIA</th><th>NOTA VENTA</th><th>VENDEDOR</th><th>STOCK</th></tr>";

            List<Datos2> datos = new List<Datos2>();
            IValueProvider valueProvider = formulario.ToValueProvider();
            for (int i = 2; i < formulario.Count; i++)
            {
                Datos2 dato = new Datos2();
                //PEDIDOS A BODEGAL
                int valor = int.Parse(formulario.Keys[i].ToString());

                Maqueta2 maqueta = db.Maqueta2.Find(valor);
                maqueta.ESTADO = "PEDIDOS A BODEGAL";
                db.Entry(maqueta).State = EntityState.Modified;

                Detalle detalle = new Detalle();
                detalle.CANTIDAD = int.Parse(maqueta.CANTIDAD.ToString());
                detalle.ACUMULADO = int.Parse(maqueta.CANTIDAD.ToString());
                detalle.FECHA = DateTime.Now;
                detalle.TIPO = "PEDIDOS A BODEGAL";
                detalle.IDMAQUETA = maqueta.IDNOTAVENTA;
                detalle.MOVIMIENTO = formulario.Keys[0].ToString();
                detalle.ORIGEN = "BODEGAL";

                Producto producto = db.Producto.Find(maqueta.IDPRODUCTO);

                int cantidad = maqueta.CANTIDAD.Value;
                if (cantidad < producto.STOCKLOCAL.Value)
                {
                    cantidad = 0;
                    producto.STOCKLOCAL = producto.STOCKLOCAL.Value - cantidad;
                }
                else
                {
                    cantidad = cantidad - producto.STOCKLOCAL.Value;
                    producto.STOCKLOCAL = 0;
                }

                int unicajas = producto.UNIDADESXCAJA.Value;
                int entero = cantidad / unicajas;
                int sobra = cantidad % unicajas;
                if (sobra != 0)
                {
                    entero++;
                }

                dato.NombrEProductO = maqueta.Producto.NOMBRE;
                dato.CajaS = entero;
                dato.CodigOProductO = maqueta.Producto.CODIGO;
                dato.UnidadeSXCajA = unicajas;
                dato.CantidaD = maqueta.CANTIDAD.Value;
                dato.GuiA = GUIA;
                dato.Cliente = maqueta.NotaVenta.Cliente.EMPRESA;
                dato.NotaVentA = maqueta.IDNOTAVENTA;
                dato.SobrantE = producto.UNIDADESXCAJA.Value - sobra;
                dato.VendedoR = maqueta.Usuario.NOMBRE;

                //sobra = maqueta.Producto.CODIGO.Length;
                //char[] caracteres = new char[sobra];
                //for (int g = 0; g < sobra; g++)
                //{
                //    caracteres[i] = maqueta.Producto.CODIGO[i];
                //}
                //DESCONTAR DE STOCK
                producto.STOCK = producto.STOCK - entero;
                if (sobra != 0)
                {
                    producto.STOCKLOCAL = producto.STOCKLOCAL + sobra;
                }
                db.Entry(producto).State = EntityState.Modified;
                db.SaveChanges();

                dato.StocK = producto.STOCK.Value;
                datos.Add(dato);

                Bodegal bodegal = new Bodegal();
                bodegal.Guia = int.Parse(dato.GuiA);
                bodegal.Fecha = DateTime.Now;
                bodegal.Movido = dato.CajaS;
                bodegal.Sobrantes = dato.SobrantE;
                bodegal.Stock = producto.STOCK.Value;
                bodegal.Donde = true;
                bodegal.FkProducto = producto.ID;
                db.Bodegal.Add(bodegal);
                db.SaveChanges();
                TEXTO = TEXTO + "<tr><td>" + dato.NombrEProductO + "</td><td>" + dato.CajaS + "</td><td>" + dato.CajaS + "</td><td>" + dato.CodigOProductO + "</td><td>" + dato.UnidadeSXCajA + "</td><td>" + dato.CantidaD + "</td><td>" + dato.SobrantE + "</td><td>" + dato.GuiA + "</td><td>" + dato.NotaVentA + "</td><td>" + dato.VendedoR + "</td><td>" + dato.StocK + "</td></tr>";
            }

            List<string> correos = db.Usuario.Where(r => r.IDCARGO == 8 || r.IDCARGO == 1).Select(r => r.EMAIL).ToList();
            _MailService.SendEmailvarioscorreos("Pedido a Bodegal SIN LOGO", correos, TEXTO);

            Datos2 primer = datos.FirstOrDefault();
            QRCodeEncoder encoder = new QRCodeEncoder();
            string URL = "Numero de la Guia: " + primer.GuiA;
            string WorkingDirectory = this.Server.MapPath("~/uploadedFolder/");
            Bitmap img = encoder.Encode(URL);
            img.Save(WorkingDirectory + "img4.jpg", ImageFormat.Jpeg);

            return View(datos.ToList());
        }
Exemplo n.º 43
0
        public bool sendmail1(string name, string userid, string em,Int32 iii)
        {
            try
            {
                QRCodeEncoder qe = new QRCodeEncoder();
                qe.QRCodeEncodeMode = QRCodeEncoder.ENCODE_MODE.BYTE;
                qe.QRCodeErrorCorrect = QRCodeEncoder.ERROR_CORRECTION.H;
                System.Drawing.Image im = qe.Encode(iii.ToString());

                MemoryStream ms = new MemoryStream();
                im.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);

                byte[] bt = ms.ToArray();

                MemoryStream da = new MemoryStream(bt);

                MailMessage mess = new MailMessage("*****@*****.**", em);
                mess.Subject = "AHRMS welcomes you " + name + "";

                Attachment data = new Attachment(da,"myimage.jpeg","image/jpeg");
                 System.Net.Mime.ContentDisposition disposition = data.ContentDisposition;
                disposition.CreationDate = System.DateTime.Now;
                disposition.ModificationDate = System.DateTime.Now;
                disposition.DispositionType = DispositionTypeNames.Attachment;

                mess.Attachments.Add(data);
                mess.Body = "Hi" + "," + name + "" + Environment.NewLine + Environment.NewLine +

                    "AHRMS" + Environment.NewLine +
                        "Advance Human Resource Management Systems" + Environment.NewLine + Environment.NewLine +

                     "Thank You for regiserting with AHRMS" + Environment.NewLine +
                     "Your USERID is" + "     " + userid + "   " + "   " + "" + Environment.NewLine + Environment.NewLine + Environment.NewLine +
                     "For any further details please contact on the below mailID" + Environment.NewLine +
                     Environment.NewLine +
                     "*****@*****.**" + Environment.NewLine + Environment.NewLine +
                     "Your QR code is attached in the mail please download it" + Environment.NewLine + Environment.NewLine +
                     "Regards" + Environment.NewLine + "AHRMS" + Environment.NewLine + "Admin" + Environment.NewLine +
                     @"<img  src=""../Images/logo.png"" />"+
                     Environment.NewLine + Environment.NewLine +
                     "Note:- This is System generated mail Please do not reply to this mail id" + Environment.NewLine + Environment.NewLine +
                     "Thank You for visiting AHRMS";

                System.Configuration.Configuration config = WebConfigurationManager.OpenWebConfiguration(HttpContext.Current.Request.ApplicationPath);
                MailSettingsSectionGroup settings = (MailSettingsSectionGroup)config.GetSectionGroup("system.net/mailSettings");

                SmtpClient sc = new SmtpClient();
                sc.Credentials = new NetworkCredential(settings.Smtp.Network.UserName, settings.Smtp.Network.Password);
                sc.EnableSsl = true;

                sc.EnableSsl = true;
                sc.Send(mess);
                return true;
            }
            catch (Exception db)
            {
                String ss = db.Message.ToString();
                string sw = db.Source.ToString();
                string sd = db.HResult.ToString();
                errorlog(ss, sw, sd);
                return false;
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            string domain = "http://localhost:2779/";
            string qrCodeImgFileName = new Random().Next().ToString() + ".jpg";

            // QR Code information == QR Code validation url
            string qrCodeInformation = domain + "ValidateQR.aspx?identity=" + qrCodeImgFileName;

            // Generate QR Code
            QRCodeEncoder qe = new QRCodeEncoder();
            System.Drawing.Bitmap bm = qe.Encode(qrCodeInformation);

            // Save QR Code bitmap to memory stream
            var memStream = new MemoryStream();
            bm.Save(memStream, System.Drawing.Imaging.ImageFormat.Jpeg);

            // Save Jpeg stream into file
            using (var fileStream = new FileStream(Server.MapPath("~/QRCodes/") + qrCodeImgFileName, FileMode.CreateNew, FileAccess.ReadWrite))
            {
                memStream.Position = 0;
                memStream.CopyTo(fileStream);
            }

            // View generated QR Code
            // Download free QR Scanner mobile application and scan using mobile, you will see http://localhost:2779/ValidateQR.aspx?identity=some_random as result
            Image1.ImageUrl = "~/QRCodes/" + qrCodeImgFileName;

            Label1.Text = qrCodeInformation;

        }
Exemplo n.º 45
-1
        public void QRcodeimageload(Int32 un, string ff)
        {
            string path = "C:\\Users\\Geetha\\documents\\visual studio 2012\\Projects\\AHRMS1\\AHRMS1\\QRImages\\";
            QRCodeEncoder encoder = new QRCodeEncoder();

            encoder.QRCodeBackgroundColor = System.Drawing.Color.White;
            encoder.QRCodeForegroundColor = System.Drawing.Color.Black;
            encoder.QRCodeErrorCorrect = QRCodeEncoder.ERROR_CORRECTION.H; // 30%
            encoder.QRCodeScale = 4;
            string ss = un.ToString();
            System.Drawing.Image img = encoder.Encode(ss);

            img.Save(path +ff+".png", ImageFormat.Png);

            QRImag.ImageUrl = "~//QRImages//"+ff+".png";
        }