GetPreamble() public method

public GetPreamble ( ) : byte[]
return byte[]
コード例 #1
0
        public void PosTest1()
        {
            UTF8Encoding UTF8NoPreamble = new UTF8Encoding();
            Byte[] preamble;

            preamble = UTF8NoPreamble.GetPreamble();
        }
コード例 #2
0
ファイル: SourceTextTests.cs プロジェクト: Rickinio/roslyn
        public void EncodingBOM()
        {
            var utf8BOM = new UTF8Encoding(encoderShouldEmitUTF8Identifier: true);

            var bytes = utf8BOM.GetPreamble().Concat(utf8BOM.GetBytes("abc")).ToArray();
            Assert.Equal(utf8BOM, SourceText.From(bytes, bytes.Length, s_unicode).Encoding);
            Assert.Equal(utf8BOM, SourceText.From(bytes, bytes.Length, null).Encoding);

            var stream = new MemoryStream(bytes);
            Assert.Equal(utf8BOM, SourceText.From(stream, s_unicode).Encoding);
            Assert.Equal(utf8BOM, SourceText.From(stream, null).Encoding);
        }
コード例 #3
0
 static public int GetPreamble(IntPtr l)
 {
     try {
         System.Text.UTF8Encoding self = (System.Text.UTF8Encoding)checkSelf(l);
         var ret = self.GetPreamble();
         pushValue(l, true);
         pushValue(l, ret);
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
コード例 #4
0
ファイル: Database.cs プロジェクト: raiker/PhotoWeasel
        private static string GetSQLResource(string SQLName)
        {
            var resourceStream = new MemoryStream();
            var assemblyStream = Assembly.GetExecutingAssembly().GetManifestResourceStream(SQLName);
            if (assemblyStream == null)
                throw new DatabaseConfigurationException("Could not find the resource " + SQLName);
            assemblyStream.CopyTo(resourceStream);
            byte[] resourceBytes = resourceStream.ToArray();
            var encoder = new UTF8Encoding(true, true); //without byte order mark

            //Strip the BOM out of the resource if it's present
            byte[] bom = encoder.GetPreamble();
            bool haveBom = true;
            for (int i = 0; i < bom.Length; i++)
            {
                if (resourceBytes[i] != bom[i])
                    haveBom = false;
            }
            int startOffset = haveBom ? bom.Length : 0;

            return encoder.GetString(resourceBytes, startOffset, resourceBytes.Length - startOffset);
        }
コード例 #5
0
ファイル: program.cs プロジェクト: ChelseaStats/BomlessFiles
        static void Main(string[] args)
        {
            var files = Directory.GetFiles(@"C:\files\");
            var result = new List<string>();

            foreach (var file in files)
            {
                 var bytes = File.ReadAllBytes(file);
                
                    var enc = new UTF8Encoding(true);
                    var preamble = enc.GetPreamble();

                if (preamble.Where((p, i) => p != bytes[i]).Any())
                {
                    result.Add(file);
                }

            }

            Console.WriteLine(string.Join(Environment.NewLine, result));
            Console.WriteLine("done");
            Console.ReadLine();
        }
コード例 #6
0
 private void SendWebRequest()
 {
     Encoding encoding = new UTF8Encoding(true);
     RequestProperties selectedObject = this.propRequest.SelectedObject as RequestProperties;
     HttpWebRequest request = (HttpWebRequest)WebRequest.CreateDefault(new Uri(selectedObject.Url));
     if ((selectedObject.HttpProxy != null) && (selectedObject.HttpProxy.Length != 0))
     {
         request.Proxy = new WebProxy(selectedObject.HttpProxy);
     }
     request.Method = selectedObject.Method.ToString();
     request.ContentType = selectedObject.ContentType;
     request.Headers["SOAPAction"] = selectedObject.SOAPAction;
     request.SendChunked = selectedObject.SendChunked;
     request.AllowAutoRedirect = selectedObject.AllowAutoRedirect;
     request.AllowWriteStreamBuffering = selectedObject.AllowWriteStreamBuffering;
     request.KeepAlive = selectedObject.KeepAlive;
     request.Pipelined = selectedObject.Pipelined;
     request.PreAuthenticate = selectedObject.PreAuthenticate;
     request.Timeout = selectedObject.Timeout;
     HttpWebClientProtocol proxy = this.GetCurrentMethodProperty().GetProxyProperty().GetProxy();
     if (selectedObject.UseCookieContainer)
     {
         if (proxy.CookieContainer != null)
         {
             request.CookieContainer = proxy.CookieContainer;
         }
         else
         {
             request.CookieContainer = new CookieContainer();
         }
     }
     CredentialCache cache = new CredentialCache();
     bool flag = false;
     if ((selectedObject.BasicAuthUserName != null) && (selectedObject.BasicAuthUserName.Length != 0))
     {
         cache.Add(new Uri(selectedObject.Url), "Basic", new NetworkCredential(selectedObject.BasicAuthUserName, selectedObject.BasicAuthPassword));
         flag = true;
     }
     if (selectedObject.UseDefaultCredential)
     {
         cache.Add(new Uri(selectedObject.Url), "NTLM", (NetworkCredential)CredentialCache.DefaultCredentials);
         flag = true;
     }
     if (flag)
     {
         request.Credentials = cache;
     }
     if (selectedObject.Method == RequestProperties.HttpMethod.POST)
     {
         request.ContentLength = this.richRequest.Text.Length + encoding.GetPreamble().Length;
         StreamWriter writer = new StreamWriter(request.GetRequestStream(), encoding);
         writer.Write(this.richRequest.Text);
         writer.Close();
     }
     try
     {
         HttpWebResponse response = (HttpWebResponse)request.GetResponse();
         this.DumpResponse(response);
         response.Close();
     }
     catch (WebException exception)
     {
         if (exception.Response != null)
         {
             this.DumpResponse((HttpWebResponse)exception.Response);
         }
         else
         {
             this.richResponse.Text = exception.ToString();
         }
     }
     catch (Exception exception2)
     {
         this.richResponse.Text = exception2.ToString();
     }
 }
コード例 #7
0
        public ActionResult DownloadTags(int id = invalidId, string formatString = "", bool setFormatString = false, bool includeHeader = false)
        {
            if (id == invalidId)
                return NoId();

            if (setFormatString) {
                userQueries.SetAlbumFormatString(formatString);
            } else if (string.IsNullOrEmpty(formatString) && LoginManager.IsLoggedIn) {
                formatString = LoginManager.LoggedUser.AlbumFormatString;
            }

            if (string.IsNullOrEmpty(formatString))
                formatString = TagFormatter.TagFormatStrings[0];

            var album = Service.GetAlbum(id);
            var tagString = Service.GetAlbumTagString(id, formatString, includeHeader);

            var enc = new UTF8Encoding(true);
            var data = enc.GetPreamble().Concat(enc.GetBytes(tagString)).ToArray();

            return File(data, "text/csv", album.Name + ".csv");
        }
    public void createTable_NEW_QR(string FileName, int spl_id, string id_1)
    {
        System.Text.Encoding enc = new System.Text.UTF8Encoding(true, true);

        //Get the BOM
        byte[] bom = enc.GetPreamble();

        //Get the raw bytes for the string
        byte[] bytes = enc.GetBytes("");

        //Combine the byte arrays
        byte[] final = new byte[bom.Length + bytes.Length];
        System.Buffer.BlockCopy(bom, 0, final, 0, bom.Length);
        System.Buffer.BlockCopy(bytes, 0, final, bom.Length, bytes.Length);

        var r = new Rectangle(160, 100)
        {
            //BackgroundColor=new BaseColor(179,227,238), remove this in original code
            Border = 0
        };


        Document dc = new Document(r, 0, 0, 0, 0);

        // PdfWriter writer = PdfWriter.GetInstance(dc, new FileStream(HttpContext.Current.Request.PhysicalApplicationPath + FileName + "/" + spl_id + ".pdf", FileMode.Create));

        PdfWriter writer = PdfWriter.GetInstance(dc, new FileStream(HttpContext.Current.Request.PhysicalApplicationPath + FileName + "/" + id_1 + ".pdf", FileMode.Create));

        dc.Open();

        // BaseFont customfont = BaseFont.CreateFont("d:\\ss.ttf", BaseFont.CP1252, BaseFont.EMBEDDED);

        BaseFont customfont = BaseFont.CreateFont();
        int      a          = spl_id;

        //string connectionString = "Data Source=ALRAR;Persist Security Info=True;User ID=AMOGH;Password=ALRAR2020;Unicode=True";

        OracleConnection conn = WebTools.GetIpmsConnection();

        // string query = "SELECT iso_title1,spl_rev,spool,round(spl_size,2) as spl_size ,area_l1,round(weight,2),mat_type,line_no,unit FROM view_total_spool_list WHERE spl_id=" + spl_id;

        string query = "SELECT mat_code1,heat_no,nvl(paint_code,'NA')  as paint_code,wall_thk,joint_thk,size1,nvl(mat_type,'XXX') as mat_type,substr(mat_descr,1,100) AS mat_descr, SubStr(mat_descr,101,100) AS mat_descr2, SubStr(mat_descr,201,100) AS mat_descr3 FROM  view_bulk_paint_barcode WHERE spl_id=" + spl_id;


        OracleCommand cmd = new OracleCommand(query, conn);

        if (conn.State == ConnectionState.Closed)
        {
            conn.Open();
        }


        OracleDataReader rdr = cmd.ExecuteReader();
        // Font bigFont = new Font(Font.FontFamily.TIMES_ROMAN, 6.5f, Font.NORMAL);
        Font bigFont      = FontFactory.GetFont("Calibri", BaseFont.CP1252, BaseFont.EMBEDDED, 8, Font.BOLD, BaseColor.BLACK);
        Font smallFont    = FontFactory.GetFont("Calibri", BaseFont.CP1252, BaseFont.EMBEDDED, 7, Font.BOLD, BaseColor.BLACK);
        Font mediumFont   = FontFactory.GetFont("Calibri", BaseFont.CP1252, BaseFont.EMBEDDED, 6, Font.BOLD, BaseColor.BLACK);
        Font mediumFont_a = FontFactory.GetFont("Calibri", BaseFont.CP1252, BaseFont.EMBEDDED, 4, Font.BOLD, BaseColor.BLACK);
        Font headfont     = new Font(Font.FontFamily.COURIER, 14f, Font.BOLD);

        iTextSharp.text.pdf.PdfContentByte cb = writer.DirectContent;


        //table.AddCell(new Paragraph("Item code:" + rdr[0].ToString(), mediumFont));
        //table.AddCell(new Paragraph("Paint Code:" + rdr[2].ToString(), mediumFont));
        //table.AddCell(new Paragraph("Heat No:" + rdr[1].ToString(), mediumFont));
        //table.AddCell(new Paragraph("Sch & Thk:" + rdr[3].ToString() + " & " + rdr[4].ToString(), mediumFont));
        //table.AddCell(new Paragraph("Pipe-Size:" + rdr[5].ToString(), mediumFont));
        //table.AddCell(new Paragraph("Main-Mat:" + rdr[6].ToString(), mediumFont));
        //table.AddCell(new Paragraph("Pipe-Description:" + rdr[7].ToString(), mediumFont_a));
        //table.AddCell(new Paragraph(rdr[8].ToString(), mediumFont_a));
        //table.AddCell(new Paragraph(rdr[9].ToString(), mediumFont_a));


        rdr.Read();
        string s1 = "Item-Code / Paint-Code :" + "  " + rdr[0].ToString() + "/" + rdr[2].ToString();
        string s2 = "  " + "Heat-No / Sch &Thk :" + " " + rdr[1].ToString() + "/" + rdr[3].ToString() + " & " + rdr[4].ToString();
        string s3 = "  " + "Pipe-Size / Main-Mat :" + rdr[5].ToString() + "/" + rdr[6].ToString();
        string s4 = "  " + "Pipe-Description :" + rdr[7].ToString();

        BarcodeQRCode bcd = new BarcodeQRCode(s1.ToString() + "    " + s2.ToString() + "    " + s3.ToString() + "    " + s4.ToString(), 10, 10, null);

        PdfPTable table = new PdfPTable(2);

        table.SetWidthPercentage(new float[] { 70, 70 }, r);
        //table.SetWidths(new float[] { 145, 80 });
        table.SetWidths(new float[] { 100, 80 });
        table.DefaultCell.Border = Rectangle.NO_BORDER;
        table.DefaultCell.NoWrap = true;

        // PdfPCell cell = new PdfPCell(new Paragraph("Petrofac / Rabigh"));
        //PdfPCell cell = new PdfPCell(new Paragraph("Petrofac / JI-2014", headfont));
        PdfPCell cell = new PdfPCell();

        cell.Image = iTextSharp.text.Image.GetInstance(bcd.GetImage());


        cell.Colspan             = 2;
        cell.Border              = 0;
        cell.HorizontalAlignment = 1; //0=Left, 1=Centre, 2=Right
        table.AddCell(cell);


        conn.Close();
        dc.Add(table);
        dc.Close();



        //Barcode128 bc = new Barcode128();
        //bc.ChecksumText = true;
        //bc.Code = a.ToString().PadLeft(16, '0');
        //bc.Size = 4;
        //bc.BarHeight = 15;
        //bc.Baseline = 4;
        //PdfPTable table = new PdfPTable(2);
        //// table.SetWidths(new float[]{158,68});
        //table.SetWidthPercentage(new float[] { 100, 100 }, r);
        //table.SetWidths(new float[] { 145, 80 });
        //table.DefaultCell.Border = Rectangle.NO_BORDER;
        //table.DefaultCell.NoWrap = true;
        //// PdfPCell cell = new PdfPCell(new Paragraph("Petrofac / Rabigh"));
        //PdfPCell cell = new PdfPCell(new Paragraph("Job: Petrofac/JI-2037", headfont));
        //cell.Colspan = 2;
        //cell.Rowspan = 4;
        //cell.HorizontalAlignment = 1; //0=Left, 1=Centre, 2=Right
        //cell.Border = 0;
        //cell.Padding = 4;
        //table.AddCell(cell);
        //cell = new PdfPCell();
        //cell.Image = iTextSharp.text.Image.GetInstance(bc.CreateImageWithBarcode(cb, null, null));
        //cell.Colspan = 2;
        //cell.Border = 0;
        //cell.HorizontalAlignment = 1; //0=Left, 1=Centre, 2=Right
        //table.AddCell(cell);
        //rdr.Read();


        //table.AddCell(new Paragraph("Item code:" + rdr[0].ToString(), mediumFont));
        //table.AddCell(new Paragraph("Paint Code:" + rdr[2].ToString(), mediumFont));
        //table.AddCell(new Paragraph("Heat No:" + rdr[1].ToString(), mediumFont));
        //table.AddCell(new Paragraph("Sch & Thk:" + rdr[3].ToString() + " & " + rdr[4].ToString(), mediumFont));
        //table.AddCell(new Paragraph("Pipe-Size:" + rdr[5].ToString(), mediumFont));
        //table.AddCell(new Paragraph("Main-Mat:" + rdr[6].ToString(), mediumFont));
        //table.AddCell(new Paragraph("Pipe-Description:" + rdr[7].ToString(), mediumFont_a));
        //table.AddCell(new Paragraph(rdr[8].ToString(), mediumFont_a));
        //table.AddCell(new Paragraph(rdr[9].ToString(), mediumFont_a));



        //table.AddCell("");
        ////NEW  CONDITION
        //rdr.Close();
        ////END
        //conn.Close();
        //dc.Add(table);
        //dc.Close();
    }
    //public void createTable_QR(string FileName, int spl_id, string id_1)
    //{
    //    //PdfPTable table = new PdfPTable(8);

    //    //PdfPCell cell;

    //    //cell = new PdfPCell();
    //    ////cell.setRowspan(2);
    //    //cell.Rowspan = 2;
    //    //table.AddCell(cell);

    //    //for (int aw = 0; aw < 8; aw++)
    //    //{
    //    //    table.AddCell("hi");
    //    //}


    //    System.Text.Encoding enc = new System.Text.UTF8Encoding(true, true);

    //    //Get the BOM
    //    byte[] bom = enc.GetPreamble();

    //    //Get the raw bytes for the string
    //    byte[] bytes = enc.GetBytes("");


    //    //Combine the byte arrays
    //    byte[] final = new byte[bom.Length + bytes.Length];
    //    System.Buffer.BlockCopy(bom, 0, final, 0, bom.Length);
    //    System.Buffer.BlockCopy(bytes, 0, final, bom.Length, bytes.Length);

    //    var r = new Rectangle(165, 71)
    //    {
    //        //BackgroundColor=new BaseColor(179,227,238), remove this in original code
    //        Border = 0
    //    };

    //    Document dc = new Document(r, 0, 0, 0, 0);



    //    PdfWriter writer = PdfWriter.GetInstance(dc, new FileStream(HttpContext.Current.Request.PhysicalApplicationPath + FileName + "/" + id_1 + ".pdf", FileMode.Create));

    //    dc.Open();

    //    // BaseFont customfont = BaseFont.CreateFont("d:\\ss.ttf", BaseFont.CP1252, BaseFont.EMBEDDED);
    //    BaseFont customfont = BaseFont.CreateFont();
    //    int a = spl_id;
    //    string connectionString = WebTools.GetIpmsConnection().ConnectionString;
    //    OracleConnection conn = new OracleConnection(connectionString);
    //    // string query = "SELECT iso_title1,spl_rev,spool,round(spl_size,2) as spl_size ,area_l1,round(weight,2),mat_type,line_no,unit FROM view_total_spool_list WHERE spl_id=" + spl_id;
    //    string query = "SELECT iso_title1,spl_rev,spool,spl_size,area_l1,weight,unit,mat_type,line_no FROM view_bc_image_dt WHERE spl_id=" + spl_id;
    //    OracleCommand cmd = new OracleCommand(query, conn);
    //    conn.Open();
    //    OracleDataReader rdr = cmd.ExecuteReader();
    //    // Font bigFont = new Font(Font.FontFamily.TIMES_ROMAN, 6.5f, Font.NORMAL);
    //    Font bigFont = FontFactory.GetFont("Calibri", BaseFont.CP1252, BaseFont.EMBEDDED, 6.3f, Font.BOLD, BaseColor.BLACK);
    //    Font headfont = new Font(Font.FontFamily.COURIER, 14f, Font.BOLD);
    //    iTextSharp.text.pdf.PdfContentByte cb = writer.DirectContent;


    //    rdr.Read();

    //    string qrstring = rdr[0].ToString() + " / " + rdr[2].ToString();

    //    BarcodeQRCode bcd = new BarcodeQRCode(qrstring.ToString(), 7000, 7000, null);



    //    // a table with three columns
    //    PdfPTable table_100 = new PdfPTable(2);
    //    //  table_100.SetWidthPercentage(new float[] { 40, 120 }, r);
    //    //  table_100.SetWidths(new float[] { 50, 120 });

    //    table_100.SetWidthPercentage(new float[] { 75, 100 }, r);
    //    table_100.SetWidths(new float[] { 75, 100 });
    //    table_100.DefaultCell.Border = Rectangle.NO_BORDER;
    //    // the cell object
    //    PdfPCell cell_100 = new PdfPCell();

    //    table_100.HorizontalAlignment = Element.ALIGN_LEFT;

    //    cell_100.Border = 0;
    //    cell_100.PaddingTop = 3;

    //    cell_100.Image = iTextSharp.text.Image.GetInstance(bcd.GetImage());

    //    cell_100.HorizontalAlignment = 0; //0=Left, 1=Centre, 2=Right

    //    table_100.AddCell(cell_100);

    //    //var splitter =  "Iso:" + rdr[0].ToString() + "\n" + "\n" + "Spool:" + rdr[2].ToString();

    //    var splitter = "Line No :" + rdr[8].ToString() + "\n" + "\n" + "Iso:" + rdr[0].ToString() + "\n" + "\n" + "Spool:" + rdr[2].ToString() + "\n" + "\n" + "Weight:" + rdr[5].ToString();

    //    var splitter1 = splitter.Split('_');


    //    //var splitter1 = splitter.Split('_');

    //    iTextSharp.text.Paragraph paragraph;
    //    paragraph = new Paragraph();

    //    paragraph.Add(new Chunk(ConvertStringArrayToString(splitter1), bigFont));
    //    cell_100 = new PdfPCell(paragraph);
    //    cell_100.PaddingTop = 8;
    //    cell_100.Border = 0;

    //    table_100.AddCell(cell_100);

    //    //table_100.AddCell(new Paragraph(ConvertStringArrayToString(splitter1), bigFont));

    //    conn.Close();
    //    dc.Add(table_100);
    //    dc.Close();



    //}

    public void createTable_QR(string FileName, int joint_id, string id_1)
    {
        System.Text.Encoding enc = new System.Text.UTF8Encoding(true, true);

        //Get the BOM
        byte[] bom = enc.GetPreamble();

        //Get the raw bytes for the string
        byte[] bytes = enc.GetBytes("");


        //Combine the byte arrays
        byte[] final = new byte[bom.Length + bytes.Length];
        System.Buffer.BlockCopy(bom, 0, final, 0, bom.Length);
        System.Buffer.BlockCopy(bytes, 0, final, bom.Length, bytes.Length);

        var r = new Rectangle(216, 144)
                //var r = new Rectangle(216, 144)
        {
            //BackgroundColor=new BaseColor(179,227,238), remove this in original code
        };
        Document dc = new Document(r, 0, 0, 0, 0);

        PdfWriter writer = PdfWriter.GetInstance(dc, new FileStream(HttpContext.Current.Request.PhysicalApplicationPath + FileName + "/" + id_1 + ".pdf", FileMode.Create));

        dc.Open();


        BaseFont         customfont = BaseFont.CreateFont();
        int              a          = joint_id;
        OracleConnection conn       = WebTools.GetIpmsConnection();
        // string query = "SELECT iso_title1,spl_rev,spool,round(spl_size,2) as spl_size ,area_l1,round(weight,2),mat_type,line_no,unit FROM view_total_spool_list WHERE spl_id=" + spl_id;
        string        query = "SELECT * FROM VIEW_BC_IMAGE_DETAIL_FLANGE WHERE JOINT_ID=" + joint_id;
        OracleCommand cmd   = new OracleCommand(query, conn);

        if (conn.State == ConnectionState.Closed)
        {
            conn.Open();
        }
        OracleDataReader rdr = cmd.ExecuteReader();
        // Font bigFont = new Font(Font.FontFamily.TIMES_ROMAN, 6.5f, Font.NORMAL);
        Font bigFont = FontFactory.GetFont("Arial", BaseFont.CP1252, BaseFont.EMBEDDED, 7, Font.BOLD, BaseColor.BLACK);


        Font headfont = new Font(Font.FontFamily.COURIER, 14f, Font.BOLD);

        iTextSharp.text.pdf.PdfContentByte cb = writer.DirectContent;


        rdr.Read();

        string qrstring = rdr[0].ToString() + " / " + rdr[2].ToString();

        BarcodeQRCode bcd = new BarcodeQRCode(qrstring.ToString(), 300, 300, null);

        // a table with three columns
        PdfPTable table_100 = new PdfPTable(2);

        //  table_100.SetWidthPercentage(new float[] { 40, 120 }, r);
        //  table_100.SetWidths(new float[] { 50, 120 });

        table_100.SetWidthPercentage(new float[] { 90, 170 }, r);
        table_100.SetWidths(new float[] { 90, 170 });


        Font     headerFont = new Font(Font.FontFamily.COURIER, 15f, Font.BOLD);
        PdfPCell cell       = new PdfPCell(new Paragraph("Job: BIFP/P11570", headerFont));

        cell.Colspan = 2;

        cell.HorizontalAlignment = 1; //0=Left, 1=Centre, 2=Right
        cell.Border = 0;


        table_100.AddCell(cell);

        // the cell object
        PdfPCell cell_100 = new PdfPCell();

        table_100.HorizontalAlignment = Element.ALIGN_LEFT;

        cell_100.Border       = 0;
        cell_100.PaddingTop   = 10;
        cell_100.PaddingRight = 0;

        cell_100.Image = iTextSharp.text.Image.GetInstance(bcd.GetImage());

        cell_100.HorizontalAlignment = 0; //0=Left, 1=Centre, 2=Right

        table_100.AddCell(cell_100);

        //var splitter =  "Iso:" + rdr[0].ToString() + "\n" + "\n" + "Spool:" + rdr[2].ToString();

        //var splitter = "\n" + "\n"+"Iso:" + rdr[0].ToString() + "\n" + "\n" + "Joint:" + rdr[2].ToString() + "\n" + "\n" + "Joint size:" + rdr[4].ToString();
        var splitter  = "Line No:" + rdr[8].ToString() + "\n" + "\n" + "Iso:" + rdr[0].ToString() + "\n" + "\n" + "Joint:" + rdr[2].ToString() + "\n" + "\n" + "Joint size:" + rdr[4].ToString() + "\n" + "\n" + "Item Code1:" + rdr[11].ToString() + "\n" + "\n" + "Item Code2:" + rdr[12].ToString();
        var splitter1 = splitter.Split('_');


        //var splitter1 = splitter.Split('_');

        iTextSharp.text.Paragraph paragraph;
        paragraph = new Paragraph();

        paragraph.Add(new Chunk(ConvertStringArrayToString(splitter1), bigFont));
        cell_100             = new PdfPCell(paragraph);
        cell_100.PaddingTop  = 15;
        cell_100.PaddingLeft = 0;
        cell_100.Border      = 0;

        table_100.AddCell(cell_100);

        //table_100.AddCell(new Paragraph(ConvertStringArrayToString(splitter1), bigFont));

        conn.Close();
        dc.Add(table_100);
        dc.Close();
    }
コード例 #10
0
 private void SendWebRequest()
 {
     Encoding encoding1 = new UTF8Encoding(true);
     RequestProperties properties1 = propRequest.SelectedObject as RequestProperties;
     if (properties1 != null)
     {
         HttpWebRequest request1 = (HttpWebRequest)WebRequest.CreateDefault(new Uri(properties1.Url));
         if ((properties1.HttpProxy != null) && (properties1.HttpProxy.Length != 0))
         {
             request1.Proxy = new WebProxy(properties1.HttpProxy);
         }
         request1.Method = properties1.Method.ToString();
         request1.ContentType = properties1.ContentType;
         request1.Headers["SOAPAction"] = properties1.SOAPAction;
         request1.SendChunked = properties1.SendChunked;
         request1.AllowAutoRedirect = properties1.AllowAutoRedirect;
         request1.AllowWriteStreamBuffering = properties1.AllowWriteStreamBuffering;
         request1.KeepAlive = properties1.KeepAlive;
         request1.Pipelined = properties1.Pipelined;
         request1.PreAuthenticate = properties1.PreAuthenticate;
         request1.Timeout = properties1.Timeout;
         MethodProperty property1 = GetCurrentMethodProperty();
         HttpWebClientProtocol protocol1 = property1.GetProxyProperty().GetProxy();
         if (properties1.UseCookieContainer)
         {
             if (protocol1.CookieContainer != null)
             {
                 request1.CookieContainer = protocol1.CookieContainer;
             }
             else
             {
                 request1.CookieContainer = new CookieContainer();
             }
         }
         CredentialCache cache1 = new CredentialCache();
         bool flag1 = false;
         if ((properties1.BasicAuthUserName != null) && (properties1.BasicAuthUserName.Length != 0))
         {
             cache1.Add(new Uri(properties1.Url), "Basic",
                        new NetworkCredential(properties1.BasicAuthUserName, properties1.BasicAuthPassword));
             flag1 = true;
         }
         if (properties1.UseDefaultCredential)
         {
             cache1.Add(new Uri(properties1.Url), "NTLM", (NetworkCredential)CredentialCache.DefaultCredentials);
             flag1 = true;
         }
         if (flag1)
         {
             request1.Credentials = cache1;
         }
         if (properties1.Method == RequestProperties.HttpMethod.POST)
         {
             request1.ContentLength = richRequest.Text.Length + encoding1.GetPreamble().Length;
             StreamWriter writer1 = new StreamWriter(request1.GetRequestStream(), encoding1);
             writer1.Write(richRequest.Text);
             writer1.Close();
         }
         try
         {
             HttpWebResponse response1 = (HttpWebResponse)request1.GetResponse();
             DumpResponse(response1);
             response1.Close();
         }
         catch (WebException exception1)
         {
             if (exception1.Response != null)
             {
                 DumpResponse((HttpWebResponse)exception1.Response);
                 return;
             }
             richResponse.Text = exception1.ToString();
         }
         catch (Exception exception2)
         {
             richResponse.Text = exception2.ToString();
         }
     }
 }
コード例 #11
0
        public FileContentResult DownloadTags(int id)
        {
            var album = Service.GetAlbum(id);
            var tagString = Service.GetAlbumTagString(id, TagFormatter.TagFormatStrings[0]);
            var enc = new UTF8Encoding(true);
            var data = enc.GetPreamble().Concat(enc.GetBytes(tagString)).ToArray();

            return File(data, "text/csv", album.Name + ".csv");
        }
コード例 #12
0
ファイル: RequestHelper.cs プロジェクト: TaylorLi/gettogether
 public static string SendWebRequest(string url, string action, string rqt, string method, string requestContentType, int timeout)
 {
     string responseXml = string.Empty;
     Encoding encoding = new UTF8Encoding(true);
     HttpWebRequest request = (HttpWebRequest)WebRequest.CreateDefault(new Uri(url));
     System.Net.CookieContainer cc = new CookieContainer();
     request.Method = method;
     request.ContentType = requestContentType;
     request.Headers["SOAPAction"] = action;
     request.AllowAutoRedirect = true;
     request.AllowWriteStreamBuffering = true;
     request.SendChunked = false;
     request.KeepAlive = false;
     request.Pipelined = false;
     request.PreAuthenticate = false;
     request.Timeout = timeout;
     request.CookieContainer = new CookieContainer();
     CredentialCache cache = new CredentialCache();
     #region Pending
     //request.Proxy=...
     //bool flag = false;
     //if (basicAuthUserName != null && basicAuthUserName!=null))
     //{
     //    cache.Add(new Uri(selectedObject.Url), "Basic", new NetworkCredential(basicAuthUserName, basicAuthPassword));
     //    flag = true;
     //}
     //if (useDefaultCredential)
     //{
     //    cache.Add(new Uri(selectedObject.Url), "NTLM", (NetworkCredential)CredentialCache.DefaultCredentials);
     //    flag = true;
     //}
     //if (flag)
     //{
     //    request.Credentials = cache;
     //}
     #endregion
     request.ContentLength = rqt.Length + encoding.GetPreamble().Length;
     StreamWriter writer = new StreamWriter(request.GetRequestStream(), encoding);
     writer.Write(rqt);
     writer.Close();
     try
     {
         HttpWebResponse response = (HttpWebResponse)request.GetResponse();
         responseXml = GetResponse(response);
         response.Close();
     }
     catch (WebException exception)
     {
         if (exception.Response != null)
         {
             responseXml = GetResponse((HttpWebResponse)exception.Response);
         }
         else
         {
             responseXml = exception.ToString();
         }
     }
     catch (Exception exception2)
     {
         responseXml = exception2.ToString();
     }
     return responseXml;
 }