Exemplo n.º 1
0
        private byte[] GetTagBytes(Id3Tag tag)
        {
            var bytes = new List <byte>();

            bytes.AddRange(AsciiEncoding.GetBytes("ID3"));
            bytes.AddRange(new byte[] { 3, 0, 0 });
            foreach (Id3Frame frame in tag.Frames)
            {
                if (frame.IsAssigned)
                {
                    FrameHandler mapping = FrameHandlers[frame.GetType()];
                    if (mapping != null)
                    {
                        byte[] frameBytes = mapping.Encoder(frame);
                        bytes.AddRange(AsciiEncoding.GetBytes(GetFrameIdFromFrame(frame)));
                        bytes.AddRange(SyncSafeNumber.EncodeNormal(frameBytes.Length));
                        bytes.AddRange(new byte[] { 0, 0 });
                        bytes.AddRange(frameBytes);
                    }
                }
            }
            int framesSize = bytes.Count - 6;

            bytes.InsertRange(6, SyncSafeNumber.EncodeSafe(framesSize));
            return(bytes.ToArray());
        }
Exemplo n.º 2
0
        public static int EncodeAsciiString(IBerOutput output, string value)
        {
            byte[] bytes = AsciiEncoding.GetBytes(value);

            output.WriteBytes(bytes);

            return(bytes.Length);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Writes an ASCII encoded string
        /// </summary>
        /// <param name="value">the string to write</param>
        /// <returns>the number of bytes written</returns>
        public int WriteAsciiString(string value)
        {
            if (string.IsNullOrEmpty(value))
            {
                return(0);
            }

            byte[] data = AsciiEncoding.GetBytes(value);
            this.dataStream.Write(data, 0, data.Length);
            return(data.Length);
        }
Exemplo n.º 4
0
        public override ExifInterOperability GetInteroperability(BitConverterEx.ByteOrder fileByteOrder)
        {
            //if (mEncoding == null)
            //    enc = "\0\0\0\0\0\0\0\0";
            //else if (mEncoding.EncodingName == "US-ASCII")
            //    enc = "ASCII\0\0\0";
            //else if (mEncoding.EncodingName == "Japanese (JIS 0208-1990 and 0212-1990)")
            //    enc = "JIS\0\0\0\0\0";
            //else if (mEncoding.EncodingName == "Unicode")
            //    enc = "Unicode\0";
            //else
            string enc   = "\0\0\0\0\0\0\0\0";
            var    ascii = new AsciiEncoding();

            byte[] benc = ascii.GetBytes(enc);
            byte[] bstr = (mEncoding == null ? ascii.GetBytes(mValue) : mEncoding.GetBytes(mValue));
            byte[] data = new byte[benc.Length + bstr.Length];
            Array.Copy(benc, 0, data, 0, benc.Length);
            Array.Copy(bstr, 0, data, benc.Length, bstr.Length);

            return(new ExifInterOperability(ExifTagFactory.GetTagID(mTag), 7, (uint)data.Length, data));
        }
Exemplo n.º 5
0
        /// <summary>
        /// Writes an ASCII encoded string resizes it to the given length
        /// </summary>
        /// <param name="value">The string to write</param>
        /// <param name="length">The desired length of the string (including potential null terminator)</param>
        /// <param name="ensureNullTerminator">If True, there will be a \0 added at the end</param>
        /// <returns>the number of bytes written</returns>
        public int WriteAsciiString(string value, int length, bool ensureNullTerminator)
        {
            if (length == 0)
            {
                return(0);
            }

            Guard.MustBeGreaterThan(length, 0, nameof(length));

            if (value == null)
            {
                value = string.Empty;
            }

            byte paddingChar  = (byte)' ';
            int  lengthAdjust = 0;

            if (ensureNullTerminator)
            {
                paddingChar  = 0;
                lengthAdjust = 1;
            }

            value = value.Substring(0, Math.Min(length - lengthAdjust, value.Length));

            byte[] textData     = AsciiEncoding.GetBytes(value);
            int    actualLength = Math.Min(length - lengthAdjust, textData.Length);

            this.dataStream.Write(textData, 0, actualLength);
            for (int i = 0; i < length - actualLength; i++)
            {
                this.dataStream.WriteByte(paddingChar);
            }

            return(length);
        }
Exemplo n.º 6
0
        private void b_DocumentCompleted(object sender, NavigationEventArgs e)
        {
            WebBrowser b = sender as WebBrowser;

            string response = "";

            response = b.SaveToString();


            string        postData = "ctl00_ContentPlaceHolder1_ctl00_ToolkitScriptManager_CauHinh_HiddenField=&__EVENTTARGET=&__EVENTARGUMENT=&__VIEWSTATE=%2FwEPDwUKMTIyNzU5NDYyNA9kFgJmD2QWAgIDD2QWCgIBDxYCHgRUZXh0BQMoMClkAgMPFgIfAAUSxJBvw6BuIEhp4bq%2FdSBUw6JtZAIFD2QWAgIBD2QWAmYPZBYIAgQPDxYIHgtfIURhdGFCb3VuZ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ZAIGD2QWAmYPFQgFMTQtMTUBMgZEVFYwMTIuTMO9IHRodXnhur90IE3huqFjaCBz4buRIChjaG8gQ8O0bmcgTmdo4buHIFRUKQMzLjAGMTRDVFQzBCA1LjAENS4wMGQCBw9kFgJmDxUIBTE0LTE1ATIGQ1RUMDEwEk5o4bqtcCBtw7RuIENOVFQgMgMzLjAHMTRDVFQzMQQxMC4wBTEwLjAwZAIID2QWAmYPFQgFMTQtMTUBMgZUQ0gwMDINVGjhu4MgZOG7pWMgMgMyLjAHMTRDVFQzMQQgNS4wBDUuMDBkAgkPZBYCZg8VCAUxNC0xNQEyBkRUVjA5MhhUaOG7sWMgaMOgbmggbeG6oWNoIHPhu5EDMS4wBzE0Q1RUMzIEIDkuMAQ5LjAwZAIHDxYCHwAFBTIuMi44ZAIJDxYCHwAFCzIwMDcgLSAyMDE0ZBgBBR5fX0NvbnRyb2xzUmVxdWlyZVBvc3RCYWNrS2V5X18WAgU3Y3RsMDAkQ29udGVudFBsYWNlSG9sZGVyMSRjdGwwMCRjYm9OYW1Ib2NfZ3ZES0hQTGljaFRoaQU2Y3RsMDAkQ29udGVudFBsYWNlSG9sZGVyMSRjdGwwMCRjYm9Ib2NLeV9ndkRLSFBMaWNoVGhp5EqBE0WY4dx7mg4r%2F8fsGwu2GyFCJBYU6p%2F8QvJKE14%3D&ctl00%24ContentPlaceHolder1%24ctl00%24cboNamHoc_gvDKHPLichThi%24ob_CbocboNamHoc_gvDKHPLichThiTB=--T%E1%BA%A5t+c%E1%BA%A3--&ctl00%24ContentPlaceHolder1%24ctl00%24cboNamHoc_gvDKHPLichThi%24ob_CbocboNamHoc_gvDKHPLichThiSIS=0&ctl00%24ContentPlaceHolder1%24ctl00%24cboNamHoc_gvDKHPLichThi=0&ctl00%24ContentPlaceHolder1%24ctl00%24cboHocKy_gvDKHPLichThi%24ob_CbocboHocKy_gvDKHPLichThiSIS=0&ctl00%24ContentPlaceHolder1%24ctl00%24cboHocKy_gvDKHPLichThi=&ctl00%24ContentPlaceHolder1%24ctl00%24btnXemDiemThi=Xem+K%E1%BA%BFt+Qu%E1%BA%A3+H%E1%BB%8Dc+T%E1%BA%ADp";
            AsciiEncoding enc      = new AsciiEncoding();

            time1++;

            //  we are encoding the postData to a byte array
            b.Navigate(new Uri("http://portal1.hcmus.edu.vn/SinhVien.aspx?pid=211"), enc.GetBytes(postData), "Content-Type: application/x-www-form-urlencoded\r\n");


            // response = b.DocumentText;


            string res = "";

            if (response.Contains("Điểm Tổng Kết"))
            {
                isLoggedIn = true;
                int index_start = response.IndexOf("Điểm Tổng Kết");
                int index_end   = response.IndexOf("</fieldset>");

                res = response.Substring(index_start, (index_end - index_start));
                //textBox2.Text = "<!DOCTYPE html>\r\n<html xmlns='http://www.w3.org/1999/xhtml'>\r\n<head>\r\n\t<title></title>\r\n</head>\r\n<body>\r\n\t<table id='tbDiemThiGK' class='dkhp-table'>\r\n\t\t<thead>\r\n\t\t\t<tr>\r\n\t\t\t\t<th title='Năm Học'>Năm Học</th>\r\n\t\t\t\t<th title='Học Kỳ'>Học Kỳ</th>\r\n\t\t\t\t<th title='Mã MH'>Mã Môn Học</th>\r\n\t\t\t\t<th class='left' title='Môn Học'>Môn Học</th>\r\n\t\t\t\t<th title='Số Tín Chỉ'>Số TC</th>\r\n\t\t\t\t<th title='Lớp'>Lớp</th>\r\n\t\t\t\t<th class='left'>Điểm Thi</th>\r\n\t\t\t<th class='left'>"
                //   + res
                // + "</body>\r\n</html>";
            }
            else
            {
                time1++;
                isLoggedIn = false;
            }



            //textBox3.Text = response;


            if (time1 == 2)
            {
                b.LoadCompleted -= new LoadCompletedEventHandler(b_DocumentCompleted);
                time1            = 0;

                if (isLoggedIn)
                {
                    txtBox_state.Text = "Thành công!";
                    test = "<!DOCTYPE html>\r\n<html xmlns='http://www.w3.org/1999/xhtml'>\r\n<head>\r\n\t<title></title>\r\n</head>\r\n<body>\r\n\t<table id='tbDiemThiGK' class='dkhp-table'>\r\n\t\t<thead>\r\n\t\t\t<tr>\r\n\t\t\t\t<th title='Năm Học'>Năm Học</th>\r\n\t\t\t\t<th title='Học Kỳ'>Học Kỳ</th>\r\n\t\t\t\t<th title='Mã MH'>Mã Môn Học</th>\r\n\t\t\t\t<th class='left' title='Môn Học'>Môn Học</th>\r\n\t\t\t\t<th title='Số Tín Chỉ'>Số TC</th>\r\n\t\t\t\t<th title='Lớp'>Lớp</th>\r\n\t\t\t\t<th class='left'>Điểm Thi</th>\r\n\t\t\t<th class='left'>"
                           + res
                           + "</body>\r\n</html>";
                    webBrowser1.NavigateToString(test);
                    isLoggedIn = false;
                    test       = "";
                }
                else
                {
                    txtBox_state.Text = "Sai tài khoản \nhoặc mật khẩu!";
                }
            }
        }
Exemplo n.º 7
0
        private void b_LoadCompleted(object sender, NavigationEventArgs e)
        {
            //this.Text = "Đang load!";
            WebBrowser b = sender as WebBrowser;


            string response = b.SaveToString();


            // format our data that we are going to post to the server
            // this will include our post parameters.  They do not need to be in a specific
            //	order, as long as they are concatenated together using an ampersand ( & )
            string        postData = "__LASTFOCUS=''&__EVENTTARGET=''&__EVENTARGUMENT=''&__VIEWSTATE=" + _VIEWSTATE + "&ctl00%24ContentPlaceHolder1%24txtUsername="******"&ctl00%24ContentPlaceHolder1%24txtPassword="******"&ctl00%24ContentPlaceHolder1%24btnLogin=%C4%90%C4%83ng+nh%E1%BA%ADp&ctl00$ContentPlaceHolder1$ctl00$cboNamHoc_gvDKHPLichThi$ob_CbocboNamHoc_gvDKHPLichThiTB=--T%E1%BA%A5t+c%E1%BA%A3--&ctl00$ContentPlaceHolder1$ctl00$cboNamHoc_gvDKHPLichThi$ob_CbocboNamHoc_gvDKHPLichThiSIS=0&ctl00$ContentPlaceHolder1$ctl00$cboNamHoc_gvDKHPLichThi=0&ctl00$ContentPlaceHolder1$ctl00$cboHocKy_gvDKHPLichThi$ob_CbocboHocKy_gvDKHPLichThiSIS=0&ctl00$ContentPlaceHolder1$ctl00$cboHocKy_gvDKHPLichThi=''&ctl00$ContentPlaceHolder1$ctl00$btnXemDiemThi=Xem+K%E1%BA%BFt+Qu%E1%BA%A3+H%E1%BB%8Dc+T%E1%BA%ADp";
            AsciiEncoding enc      = new AsciiEncoding();

            //  we are encoding the postData to a byte array
            b.Navigate(new Uri("http://portal1.hcmus.edu.vn/Login.aspx?ReturnUrl=%2fSinhVien.aspx%3fpid%3d211&pid=211"), enc.GetBytes(postData), "Content-Type: application/x-www-form-urlencoded\r\n");



            // unregisters the first event handler
            // adds a second event handler
            b.LoadCompleted += new LoadCompletedEventHandler(b_DocumentCompleted);

            b.LoadCompleted -= new LoadCompletedEventHandler(b_LoadCompleted);
        }