[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Tiff G5 format problem

Posted on 2011-10-12
5
Medium Priority
?
347 Views
Last Modified: 2012-05-12
Okay so I have a really fun one.........

My company uses IBM for Document Imaging.
We are having staff upload PDF's that ar in TIFF G5 format which is acceptable but they are 32 bit (which is not)
Does anyone out there know how to turn a 32bit into a 1 bit? is there any way to use the file upload tool in VS 2010 to convert it into a 1 bit ?

Thanks Matt
0
Comment
Question by:HawaiiDragon
  • 4
5 Comments
 

Author Comment

by:HawaiiDragon
ID: 36959030
Guess it would help if I put some code up!
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
using System.IO;
using System.Text;
using System.Drawing;
using System.Drawing.Text;
using System.Drawing.Imaging;

// This is for Enrollment Adjustment.
// This creates a tif file and an index txt file for DMS. 
// File names are EAForm_[ParkID]_[recordID].[tif or txt].  
// Funding and FinAid are filled out by the requestor.   Aid/NoAid is determined by CX.
// Current DMS contacts Mike Bishop and Yahya Rice.

// when testing, there is 3 spots to change the drive/folder; in MAIN you can test for a single record; 
//               in MAIN you can comment out the changing of the printed flag

// NOTE!!!  in Index file; Academic Year is hard-coded.   This should be fixed.

namespace PARK_Enroll_Adj_DMS_v1_07_28_2011
{
    class Program
    {
        static void funWriteText(int intIDtoWrite)
        {
            //  this writes out the Document Imaging form that the users see.
            string strFileName;
            SqlConnection sqlSingleRecordConn = new SqlConnection("Data Source=park-sparrow;Initial Catalog=Wdb_Enroll_Adj;User Id=Wdb_EnrollAdj_DocImage;Password=Print4MyChanges");
            SqlCommand sqlSingleRecordCommand = new SqlCommand("P_sp_DMS_Get_Single_Enroll_Adj", sqlSingleRecordConn);
            SqlDataReader sqlSingleRecordReader;
            sqlSingleRecordConn.Open();
            sqlSingleRecordCommand.CommandType = CommandType.StoredProcedure;
            sqlSingleRecordCommand.Parameters.AddWithValue("ID", intIDtoWrite);
            sqlSingleRecordReader = sqlSingleRecordCommand.ExecuteReader();
            try
            {
                if (sqlSingleRecordReader.Read())
                {

                    TextWriter twSingleOutput;
                    // testing to send file to c drive and folder [make sure you have it already created]
                    //strFileName = "c:\\EDMS_DATA\\Downloads\\EA_Forms\\EAForm_" + sqlSingleRecordReader["ParkID"].ToString().Trim() + "_" + intIDtoWrite.ToString() + ".tif";
                    // putting file to DMS's predetermined drive and folder
                    strFileName = "D:\\EDMS_DATA\\Downloads\\EA_Forms\\EAForm_" + sqlSingleRecordReader["ParkID"].ToString().Trim() + "_" + intIDtoWrite.ToString() + ".tif";

                    twSingleOutput = new StreamWriter(strFileName);
                    StringBuilder sbTextFile = new StringBuilder();
                    // writing each field ["\r\n" => carriage return and newline]
                    sbTextFile.Append("Enrollment Adjustment " + "\r\n");
                    sbTextFile.Append("----------------------\r\n");

                    sbTextFile.Append("ParkID        :" + sqlSingleRecordReader["ParkID"].ToString().Trim() + "\r\n");
                    sbTextFile.Append("FirstName     :" + sqlSingleRecordReader["FirstName"].ToString().Trim() + "\r\n");
                    sbTextFile.Append("LastName      :" + sqlSingleRecordReader["LastName"].ToString().Trim() + "\r\n");
                    sbTextFile.Append("Initial       :" + sqlSingleRecordReader["Initial"].ToString().Trim() + "\r\n");
                    sbTextFile.Append("SubProgram    :" + sqlSingleRecordReader["SubProgram"].ToString().Trim() + "\r\n");
                    sbTextFile.Append("SessionYear   :" + sqlSingleRecordReader["SessionYear"].ToString().Trim() + "\r\n");
                    sbTextFile.Append("RequestRole   :" + sqlSingleRecordReader["ReqRole"].ToString().Trim() + "\r\n");
                    sbTextFile.Append("Funding       :" + sqlSingleRecordReader["Funding"].ToString().Trim() + "\r\n");
                    if ((sqlSingleRecordReader["Funding"].ToString().Trim()) == "Yes")
                    {
                        sbTextFile.Append("FinAid        :" + sqlSingleRecordReader["FinAid"].ToString().Trim() + "\r\n");
                    }

                    sbTextFile.Append("CXFinAid      :" + sqlSingleRecordReader["CXFinAid"].ToString().Trim() + "\r\n");

                    if (((sqlSingleRecordReader["AddCrsNo1"].ToString().Trim()) != "") || 
                        ((sqlSingleRecordReader["AddCrsTitle1"].ToString().Trim()) != ""))
                    {
                        sbTextFile.Append("AddCrsNo1     :" + sqlSingleRecordReader["AddCrsNo1"].ToString().Trim() + "\r\n");
                        sbTextFile.Append("AddCrsTtl1    :" + sqlSingleRecordReader["AddCrsTitle1"].ToString().Trim() + "\r\n");
                        sbTextFile.Append("AddCrdHrs1    :" + sqlSingleRecordReader["AddCrdHrs1"].ToString().Trim() + "\r\n");
                    }

                    if (((sqlSingleRecordReader["AddCrsNo2"].ToString().Trim()) != "") ||
                        ((sqlSingleRecordReader["AddCrsTitle2"].ToString().Trim()) != ""))
                    {
                        sbTextFile.Append("AddCrsNo2     :" + sqlSingleRecordReader["AddCrsNo2"].ToString().Trim() + "\r\n");
                        sbTextFile.Append("AddCrsTtl2    :" + sqlSingleRecordReader["AddCrsTitle2"].ToString().Trim() + "\r\n");
                        sbTextFile.Append("AddCrdHrs2    :" + sqlSingleRecordReader["AddCrdHrs2"].ToString().Trim() + "\r\n");
                    }
                    if (((sqlSingleRecordReader["AddCrsNo3"].ToString().Trim()) != "") ||
                        ((sqlSingleRecordReader["AddCrsTitle3"].ToString().Trim()) != ""))
                    {
                            sbTextFile.Append("AddCrsNo3     :" + sqlSingleRecordReader["AddCrsNo3"].ToString().Trim() + "\r\n");
                            sbTextFile.Append("AddCrsTtl3    :" + sqlSingleRecordReader["AddCrsTitle3"].ToString().Trim() + "\r\n");
                            sbTextFile.Append("AddCrdHrs3    :" + sqlSingleRecordReader["AddCrdHrs3"].ToString().Trim() + "\r\n");
                    }
                    if (((sqlSingleRecordReader["AddCrsNo4"].ToString().Trim()) != "") ||
                        ((sqlSingleRecordReader["AddCrsTitle4"].ToString().Trim()) != ""))
                    {
                        sbTextFile.Append("AddCrsNo4     :" + sqlSingleRecordReader["AddCrsNo4"].ToString().Trim() + "\r\n");
                        sbTextFile.Append("AddCrsTtl4    :" + sqlSingleRecordReader["AddCrsTitle4"].ToString().Trim() + "\r\n");
                        sbTextFile.Append("AddCrdHrs4    :" + sqlSingleRecordReader["AddCrdHrs4"].ToString().Trim() + "\r\n");
                    }
                    if (((sqlSingleRecordReader["DropCrsNo1"].ToString().Trim()) != "") ||
                        ((sqlSingleRecordReader["DropCrsTitle1"].ToString().Trim()) != ""))
                    {
                        sbTextFile.Append("DropCrsNo1    :" + sqlSingleRecordReader["DropCrsNo1"].ToString().Trim() + "\r\n");
                        sbTextFile.Append("DropCrsTtl1   :" + sqlSingleRecordReader["DropCrsTitle1"].ToString().Trim() + "\r\n");
                        sbTextFile.Append("DropCrdHrs1   :" + sqlSingleRecordReader["DropCrdHrs1"].ToString().Trim() + "\r\n");
                    }
                    if (((sqlSingleRecordReader["DropCrsNo2"].ToString().Trim()) != "") ||
                        ((sqlSingleRecordReader["DropCrsTitle2"].ToString().Trim()) != ""))
                    {
                        sbTextFile.Append("DropCrsNo2    :" + sqlSingleRecordReader["DropCrsNo2"].ToString().Trim() + "\r\n");
                        sbTextFile.Append("DropCrsTtl2   :" + sqlSingleRecordReader["DropCrsTitle2"].ToString().Trim() + "\r\n");
                        sbTextFile.Append("DropCrdHrs2   :" + sqlSingleRecordReader["DropCrdHrs2"].ToString().Trim() + "\r\n");
                    }
                    if (((sqlSingleRecordReader["DropCrsNo3"].ToString().Trim()) != "") ||
                        ((sqlSingleRecordReader["DropCrsTitle3"].ToString().Trim()) != ""))
                    {
                        sbTextFile.Append("DropCrsNo3    :" + sqlSingleRecordReader["DropCrsNo3"].ToString().Trim() + "\r\n");
                        sbTextFile.Append("DropCrsTtl3   :" + sqlSingleRecordReader["DropCrsTitle3"].ToString().Trim() + "\r\n");
                        sbTextFile.Append("DropCrdHrs3   :" + sqlSingleRecordReader["DropCrdHrs3"].ToString().Trim() + "\r\n");
                    }
                    if (((sqlSingleRecordReader["DropCrsNo4"].ToString().Trim()) != "") ||
                        ((sqlSingleRecordReader["DropCrsTitle4"].ToString().Trim()) != ""))
                    {
                        sbTextFile.Append("DropCrsNo4    :" + sqlSingleRecordReader["DropCrsNo4"].ToString().Trim() + "\r\n");
                        sbTextFile.Append("DropCrsTtl4   :" + sqlSingleRecordReader["DropCrsTitle4"].ToString().Trim() + "\r\n");
                        sbTextFile.Append("DropCrdHrs4   :" + sqlSingleRecordReader["DropCrdHrs4"].ToString().Trim() + "\r\n");
                    }
                    if ((sqlSingleRecordReader["ReqRole"].ToString().Trim()) == "Student")
                    {
                        if (((sqlSingleRecordReader["WDStudCrsNo1"].ToString().Trim()) != "") ||
                            ((sqlSingleRecordReader["WDStudCrsTitle1"].ToString().Trim()) != ""))
                        {
                            sbTextFile.Append("WDStudCrsNo1  :" + sqlSingleRecordReader["WDStudCrsNo1"].ToString().Trim() + "\r\n");
                            sbTextFile.Append("WDStudCrsTtl1 :" + sqlSingleRecordReader["WDStudCrsTitle1"].ToString().Trim() + "\r\n");
                            sbTextFile.Append("WDStudCrdHrs1 :" + sqlSingleRecordReader["WDStudCrdHrs1"].ToString().Trim() + "\r\n");
                        }
                        if (((sqlSingleRecordReader["WDStudCrsNo2"].ToString().Trim()) != "") ||
                            ((sqlSingleRecordReader["WDStudCrsTitle2"].ToString().Trim()) != ""))
                        {
                            sbTextFile.Append("WDStudCrsNo2  :" + sqlSingleRecordReader["WDStudCrsNo2"].ToString().Trim() + "\r\n");
                            sbTextFile.Append("WDStudCrsTtl2 :" + sqlSingleRecordReader["WDStudCrsTitle2"].ToString().Trim() + "\r\n");
                            sbTextFile.Append("WDStudCrdHrs2 :" + sqlSingleRecordReader["WDStudCrdHrs2"].ToString().Trim() + "\r\n");
                        }
                        if (((sqlSingleRecordReader["WDStudCrsNo3"].ToString().Trim()) != "") ||
                            ((sqlSingleRecordReader["WDStudCrsTitle3"].ToString().Trim()) != ""))
                        {
                            sbTextFile.Append("WDStudCrsNo3  :" + sqlSingleRecordReader["WDStudCrsNo3"].ToString().Trim() + "\r\n");
                            sbTextFile.Append("WDStudCrsTtl3 :" + sqlSingleRecordReader["WDStudCrsTitle3"].ToString().Trim() + "\r\n");
                            sbTextFile.Append("WDStudCrdHrs3 :" + sqlSingleRecordReader["WDStudCrdHrs3"].ToString().Trim() + "\r\n");
                        }
                        if (((sqlSingleRecordReader["WDStudCrsNo4"].ToString().Trim()) != "") ||
                            ((sqlSingleRecordReader["WDStudCrsTitle4"].ToString().Trim()) != ""))
                        {
                            sbTextFile.Append("WDStudCrsNo4  :" + sqlSingleRecordReader["WDStudCrsNo4"].ToString().Trim() + "\r\n");
                            sbTextFile.Append("WDStudCrsTtl4 :" + sqlSingleRecordReader["WDStudCrsTitle4"].ToString().Trim() + "\r\n");
                            sbTextFile.Append("WDStudCrdHrs4 :" + sqlSingleRecordReader["WDStudCrdHrs4"].ToString().Trim() + "\r\n");
                        }
                        if (((sqlSingleRecordReader["WDStudCrsNo5"].ToString().Trim()) != "") ||
                            ((sqlSingleRecordReader["WDStudCrsTitle5"].ToString().Trim()) != ""))
                        {
                            sbTextFile.Append("WDStudCrsNo5  :" + sqlSingleRecordReader["WDStudCrsNo5"].ToString().Trim() + "\r\n");
                            sbTextFile.Append("WDStudCrsTtl5 :" + sqlSingleRecordReader["WDStudCrsTitle5"].ToString().Trim() + "\r\n");
                            sbTextFile.Append("WDStudCrdHrs5 :" + sqlSingleRecordReader["WDStudCrdHrs5"].ToString().Trim() + "\r\n");
                        }
                        if (((sqlSingleRecordReader["WDStudCrsNo6"].ToString().Trim()) != "") ||
                            ((sqlSingleRecordReader["WDStudCrsTitle6"].ToString().Trim()) != ""))
                        {
                            sbTextFile.Append("WDStudCrsNo6  :" + sqlSingleRecordReader["WDStudCrsNo6"].ToString().Trim() + "\r\n");
                            sbTextFile.Append("WDStudCrsTtl6 :" + sqlSingleRecordReader["WDStudCrsTitle6"].ToString().Trim() + "\r\n");
                            sbTextFile.Append("WDStudCrdHrs6 :" + sqlSingleRecordReader["WDStudCrdHrs6"].ToString().Trim() + "\r\n");
                        }
                    }
                    //  Admin role and 
                    if ((sqlSingleRecordReader["ReqRole"].ToString().Trim()) == "Admin")
                    {
                        if (((sqlSingleRecordReader["WDAdminCrsNo1"].ToString().Trim()) != "") ||
                            ((sqlSingleRecordReader["WDAdminCrsTitle1"].ToString().Trim()) != ""))
                        {
                            sbTextFile.Append("WDAdmnCrsNo1  :" + sqlSingleRecordReader["WDAdminCrsNo1"].ToString().Trim() + "\r\n");
                            sbTextFile.Append("WDAdmnCrsTtl1 :" + sqlSingleRecordReader["WDAdminCrsTitle1"].ToString().Trim() + "\r\n");
                            sbTextFile.Append("WDAdmnCrdHrs1 :" + sqlSingleRecordReader["WDAdminCrdHrs1"].ToString().Trim() + "\r\n");
                            sbTextFile.Append("WDAdmnLDA1    :" + sqlSingleRecordReader["WDAdminLDA1"].ToString().Trim() + "\r\n");
                        }
                        if (((sqlSingleRecordReader["WDAdminCrsNo2"].ToString().Trim()) != "") ||
                            ((sqlSingleRecordReader["WDAdminCrsTitle2"].ToString().Trim()) != ""))
                        {
                            sbTextFile.Append("WDAdmnCrsNo2  :" + sqlSingleRecordReader["WDAdminCrsNo2"].ToString().Trim() + "\r\n");
                            sbTextFile.Append("WDAdmnCrsTtl2 :" + sqlSingleRecordReader["WDAdminCrsTitle2"].ToString().Trim() + "\r\n");
                            sbTextFile.Append("WDAdmnCrdHrs2 :" + sqlSingleRecordReader["WDAdminCrdHrs2"].ToString().Trim() + "\r\n");
                            sbTextFile.Append("WDAdmnLDA2    :" + sqlSingleRecordReader["WDAdminLDA2"].ToString().Trim() + "\r\n");
                        }
                        if (((sqlSingleRecordReader["WDAdminCrsNo3"].ToString().Trim()) != "") ||
                            ((sqlSingleRecordReader["WDAdminCrsTitle3"].ToString().Trim()) != ""))
                        {
                            sbTextFile.Append("WDAdmnCrsNo3  :" + sqlSingleRecordReader["WDAdminCrsNo3"].ToString().Trim() + "\r\n");
                            sbTextFile.Append("WDAdmnCrsTtl3 :" + sqlSingleRecordReader["WDAdminCrsTitle3"].ToString().Trim() + "\r\n");
                            sbTextFile.Append("WDAdmnCrdHrs3 :" + sqlSingleRecordReader["WDAdminCrdHrs3"].ToString().Trim() + "\r\n");
                            sbTextFile.Append("WDAdmnLDA3    :" + sqlSingleRecordReader["WDAdminLDA3"].ToString().Trim() + "\r\n");
                        }
                        if (((sqlSingleRecordReader["WDAdminCrsNo4"].ToString().Trim()) != "") ||
                            ((sqlSingleRecordReader["WDAdminCrsTitle4"].ToString().Trim()) != ""))
                        {
                            sbTextFile.Append("WDAdmnCrsNo4  :" + sqlSingleRecordReader["WDAdminCrsNo4"].ToString().Trim() + "\r\n");
                            sbTextFile.Append("WDAdmnCrsTtl4 :" + sqlSingleRecordReader["WDAdminCrsTitle4"].ToString().Trim() + "\r\n");
                            sbTextFile.Append("WDAdmnCrdHrs4 :" + sqlSingleRecordReader["WDAdminCrdHrs4"].ToString().Trim() + "\r\n");
                            sbTextFile.Append("WDAdmnLDA4    :" + sqlSingleRecordReader["WDAdminLDA4"].ToString().Trim() + "\r\n");
                        }
                        if (((sqlSingleRecordReader["WDAdminCrsNo5"].ToString().Trim()) != "") ||
                            ((sqlSingleRecordReader["WDAdminCrsTitle5"].ToString().Trim()) != ""))
                        {
                            sbTextFile.Append("WDAdmnCrsNo5  :" + sqlSingleRecordReader["WDAdminCrsNo5"].ToString().Trim() + "\r\n");
                            sbTextFile.Append("WDAdmnCrsTtl5 :" + sqlSingleRecordReader["WDAdminCrsTitle5"].ToString().Trim() + "\r\n");
                            sbTextFile.Append("WDAdmnCrdHrs5 :" + sqlSingleRecordReader["WDAdminCrdHrs5"].ToString().Trim() + "\r\n");
                            sbTextFile.Append("WDAdmnLDA5    :" + sqlSingleRecordReader["WDAdminLDA5"].ToString().Trim() + "\r\n");
                        }
                        if (((sqlSingleRecordReader["WDAdminCrsNo6"].ToString().Trim()) != "") ||
                            ((sqlSingleRecordReader["WDAdminCrsTitle6"].ToString().Trim()) != ""))
                        {
                            sbTextFile.Append("WDAdmnCrsNo6  :" + sqlSingleRecordReader["WDAdminCrsNo6"].ToString().Trim() + "\r\n");
                            sbTextFile.Append("WDAdmnCrsTtl6 :" + sqlSingleRecordReader["WDAdminCrsTitle6"].ToString().Trim() + "\r\n");
                            sbTextFile.Append("WDAdmnCrdHrs6 :" + sqlSingleRecordReader["WDAdminCrdHrs6"].ToString().Trim() + "\r\n");
                            sbTextFile.Append("WDAdmnLDA6    :" + sqlSingleRecordReader["WDAdminLDA6"].ToString().Trim() + "\r\n");
                        }
                    }
                    sbTextFile.Append("Reasons       :" + sqlSingleRecordReader["Reason"].ToString().Trim() + "\r\n");
                    sbTextFile.Append("ReasonExplain :" + sqlSingleRecordReader["ReasonExplain"].ToString().Trim() + "\r\n");
                    // commented out, as Pam and Tiffani don't want this field anymore per mtg on 8-11-2011
                    //sbTextFile.Append("CrdHrsPrior   :" + sqlSingleRecordReader["CrdHrsPrior"].ToString().Trim() + "\r\n");
                    //sbTextFile.Append("CrdHrsAfter   :" + sqlSingleRecordReader["CrdHrsAfter"].ToString().Trim() + "\r\n");
                    if ((sqlSingleRecordReader["ReqRole"].ToString().Trim()) == "Student")
                    {
                        sbTextFile.Append("StudentSig    :" + sqlSingleRecordReader["StudSig"].ToString().Trim() + "\r\n");
                        sbTextFile.Append("StudentDate   :" + sqlSingleRecordReader["StudDate"].ToString().Trim() + "\r\n");
                    }
                    if ((sqlSingleRecordReader["ReqRole"].ToString().Trim()) == "Admin")
                    {
                        sbTextFile.Append("AdminSig      :" + sqlSingleRecordReader["AdminSig"].ToString().Trim() + "\r\n");
                        sbTextFile.Append("AdminDate     :" + sqlSingleRecordReader["AdminDate"].ToString().Trim() + "\r\n");
                        sbTextFile.Append("AdminComments :" + sqlSingleRecordReader["AdminComments"].ToString().Trim() + "\r\n");
                    }
                    sbTextFile.Append("SubmittedDate :" + sqlSingleRecordReader["SubmittedDate"].ToString().Trim() + "\r\n");
                    sbTextFile.Append("Web Upload");

                    twSingleOutput.WriteLine(sbTextFile.ToString());
                    twSingleOutput.Close();
                    funWriteTiff(strFileName, sbTextFile.ToString());

                    //   Index file for DMS
                    TextWriter twSingleOutputResult;
                    // testing to send file to c drive and folder [make sure you have it already created]
                    //strFileName = "c:\\EDMS_DATA\\Downloads\\EA_Forms\\EAForm_" + sqlSingleRecordReader["ParkID"].ToString().Trim() + "_" + intIDtoWrite.ToString() + ".txt";
                    // putting file to DMS's predetermined drive and folder
                    strFileName = "D:\\EDMS_DATA\\Downloads\\EA_Forms\\EAForm_" + sqlSingleRecordReader["ParkID"].ToString().Trim() + "_" + intIDtoWrite.ToString() + ".txt";

                    twSingleOutputResult = new StreamWriter(strFileName);

                    // AcadYear is hard-coded and should be fixed as an input from the form.
                    string AcadYear = "2011-2012";
                    string roleFund;

                    if ((sqlSingleRecordReader["ReqRole"].ToString().Trim()) == "Admin")
                    {
                        if ((sqlSingleRecordReader["CXFinAid"].ToString().Trim()) == "Yes")
                        {
                            roleFund = "AdminAid";
                        }
                        else
                        {
                            roleFund = "AdminNoAid";
                        }
                    }
                    else
                    {
                        if ((sqlSingleRecordReader["CXFinAid"].ToString().Trim()) == "Yes")
                        {
                            roleFund = "StudAid";
                        }
                        else
                        {
                            roleFund = "StudNoAid";
                        }
                    }


                    twSingleOutputResult.Write(sqlSingleRecordReader["ParkID"].ToString().Trim() + "|");
                    twSingleOutputResult.Write(sqlSingleRecordReader["LastName"].ToString().ToUpper().Substring(0, 1));
                    twSingleOutputResult.Write(sqlSingleRecordReader["LastName"].ToString().ToLower().Substring(1, sqlSingleRecordReader["LastName"].ToString().Length - 1) + ", ");
                    twSingleOutputResult.Write(sqlSingleRecordReader["FirstName"].ToString().ToUpper().Substring(0, 1));
                    twSingleOutputResult.Write(sqlSingleRecordReader["FirstName"].ToString().ToLower().Substring(1, sqlSingleRecordReader["FirstName"].ToString().Length - 1));
                    twSingleOutputResult.Write(sqlSingleRecordReader["Initial"].ToString().Trim() + "|");
                    // this is blank field (just writing a pipe) due to not having birth date to pass
                    twSingleOutputResult.Write("|");
                    // currently, DMS is getting the Subprogram from CX (hence why just writing a pipe)
                    // twSingleOutputResult.Write(sqlSingleRecordReader["SubProgram"].ToString().Trim() + "|");
                    twSingleOutputResult.Write("|");
                    twSingleOutputResult.Write(AcadYear.ToString().Trim() + "|");
                    // this is blank field (just writing a pipe) due to not having to pass comments
                    twSingleOutputResult.Write("|");
                    twSingleOutputResult.Write(roleFund.ToString().Trim() + "|");
                    twSingleOutputResult.Close();
                }
                else
                {
                    TextWriter twSingleOutputError;
                    // testing to send file to c drive and folder [make sure you have it already created]
                    //twSingleOutputError = new StreamWriter("c:\\EDMS_DATA\\Downloads\\EA_Forms" + "Error_" + intIDtoWrite.ToString() + ".txt");
                    // putting file to DMS's predetermined drive and folder
                    twSingleOutputError = new StreamWriter("D:\\EDMS_DATA\\Downloads\\EA_Forms" + "Error_" + intIDtoWrite.ToString() + ".txt");

                    twSingleOutputError.WriteLine("Could not find database for ID = " + intIDtoWrite.ToString());
                    twSingleOutputError.Close();
                }

            }
            finally
            {
                sqlSingleRecordReader.Close();
                sqlSingleRecordConn.Close();
            }
            return;
        }


        static void funMarkPrinted(int intID)
        {
            // change the "printed" flag from 0 (not printed) to 1 (printed)

            SqlConnection sqlSingleRecordConn = new SqlConnection("Data Source=park-sparrow;Initial Catalog=Wdb_Enroll_Adj;User Id=Wdb_EnrollAdj_DocImage;Password=Print4MyChanges");
            SqlCommand sqlSingleRecordCommand = new SqlCommand("P_sp_DMS_Mark_As_Printed_EnrollAdj", sqlSingleRecordConn);
            sqlSingleRecordConn.Open();
            sqlSingleRecordCommand.CommandType = CommandType.StoredProcedure;
            sqlSingleRecordCommand.Parameters.AddWithValue("ID", intID);
            try
            {
                sqlSingleRecordCommand.ExecuteNonQuery();
            }
            finally
            {
                sqlSingleRecordConn.Close();
            }
            return;
        }

        public void funwritetiff2(string strFileName, string strActualText)
        { 
           
        
        
        }



        static void funWriteTiff(string strFileName, string strActualText)
        {
            //  Change bitmap values to match your file size
            //Image imgThumb = new Bitmap(4000, 1500);
            Bitmap imgThumb = new Bitmap(4000, 1500, PixelFormat.Format16bppGrayScale);
            MemoryStream ms = new MemoryStream();
            //System.Drawing.Bitmap b = new System.Drawing.Bitmap(imgThumb);
          //  b.PixelFormat = System.Drawing.Imaging.PixelFormat.Format8bppIndexed;
            Graphics objGraphics = Graphics.FromImage(imgThumb);
            //  Font objFont = new Font("Arial", 12, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Pixel);
            Font objFont = new Font("Courier New", 12, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Pixel);
            objGraphics = Graphics.FromImage(imgThumb);

            // Set Background color
            objGraphics.Clear(Color.White);
            //objGraphics.SmoothingMode = SmoothingMode.AntiAlias;
            objGraphics.TextRenderingHint = TextRenderingHint.AntiAlias;
            //Color.FromArgb (0,0,0) = black; change values to change text color
            objGraphics.DrawString(strActualText, objFont, new SolidBrush(Color.FromArgb(0, 0, 0)), 0, 0);

            imgThumb.Save(ms, System.Drawing.Imaging.ImageFormat.Tiff);
            byte[] be = ms.ToArray();
            using (var fileStream = File.OpenWrite(strFileName))
            {
                ms.WriteTo(fileStream);
            
            
            }

        }



        static void Main(string[] args)
        {
            int intID;
            SqlConnection sqlMainConn = new SqlConnection("Data Source=park-sparrow;Initial Catalog=Wdb_Enroll_Adj;User Id=Wdb_EnrollAdj_DocImage;Password=Print4MyChanges");
            SqlCommand sqlMainCommand = new SqlCommand("P_sp_DMS_List_Enroll_Adj_to_Print", sqlMainConn);
            SqlDataReader sqlMainReader;
            sqlMainConn.Open();
            sqlMainCommand.CommandType = CommandType.StoredProcedure;
            sqlMainReader = sqlMainCommand.ExecuteReader();
            try
            {
                while (sqlMainReader.Read())
                {
                    intID = Int32.Parse(sqlMainReader["ID"].ToString());
                    // If you have a testing number put it here
                    //                    intID = 559;
                    funWriteText(intID);
                    // testing to keep it from being marked as printed.  
                    // UNCOMMENT when done testing
                    funMarkPrinted(intID);
                }
            }
            finally
            {
                sqlMainReader.Close();
                sqlMainConn.Close();
            }

            return;
        }
    }
}

Open in new window

0
 
LVL 2

Accepted Solution

by:
ddurgaprasad earned 2000 total points
ID: 36963680
GDAL is a library that has command line tools for handling tiff image format.
http://www.gdal.org/gdal_utilities.html
0
 

Author Comment

by:HawaiiDragon
ID: 36963712
forgive me but how do I use any of these. I am looking at them now
0
 

Author Comment

by:HawaiiDragon
ID: 36963791
Okay so I have learned a little bit.... I need to make the color of this project BLACK and White ONLY... NO Grey No Pink just B & W can some one take a look and tell me how to manually do this?
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
using System.IO;
using System.Text;
using System.Drawing;
using System.Drawing.Text;
using System.Drawing.Imaging;

// This is for Enrollment Adjustment.
// This creates a tif file and an index txt file for DMS. 
// File names are EAForm_[ParkID]_[recordID].[tif or txt].  
// Funding and FinAid are filled out by the requestor.   Aid/NoAid is determined by CX.


// when testing, there is 3 spots to change the drive/folder; in MAIN you can test for a single record; 
//               in MAIN you can comment out the changing of the printed flag

// NOTE!!!  in Index file; Academic Year is hard-coded.   This should be fixed.

namespace PARK_Enroll_Adj_DMS_v1_07_28_2011
{
    class Program
    {
        static void funWriteText(int intIDtoWrite)
        {
            //  this writes out the Document Imaging form that the users see.
            string strFileName;
            SqlConnection sqlSingleRecordConn = new SqlConnection("Data Source=park-sparrow;Initial Catalog=Wdb_Enroll_Adj;User Id=Wdb_EnrollAdj_DocImage;Password=Print4MyChanges");
            SqlCommand sqlSingleRecordCommand = new SqlCommand("P_sp_DMS_Get_Single_Enroll_Adj", sqlSingleRecordConn);
            SqlDataReader sqlSingleRecordReader;
            sqlSingleRecordConn.Open();
            sqlSingleRecordCommand.CommandType = CommandType.StoredProcedure;
            sqlSingleRecordCommand.Parameters.AddWithValue("ID", intIDtoWrite);
            sqlSingleRecordReader = sqlSingleRecordCommand.ExecuteReader();
            try
            {
                if (sqlSingleRecordReader.Read())
                {

                    TextWriter twSingleOutput;
                    // testing to send file to c drive and folder [make sure you have it already created]
                    strFileName = "c:\\EDMS_DATA\\Downloads\\EA_Forms\\EAForm_" + sqlSingleRecordReader["ParkID"].ToString().Trim() + "_" + intIDtoWrite.ToString() + ".tif";
                    // putting file to DMS's predetermined drive and folder
                    //strFileName = "D:\\EDMS_DATA\\Downloads\\EA_Forms\\EAForm_" + sqlSingleRecordReader["ParkID"].ToString().Trim() + "_" + intIDtoWrite.ToString() + ".tif";

                    twSingleOutput = new StreamWriter(strFileName);
                    StringBuilder sbTextFile = new StringBuilder();
                    // writing each field ["\r\n" => carriage return and newline]
                    sbTextFile.Append("Enrollment Adjustment " + "\r\n");
                    sbTextFile.Append("----------------------\r\n");

                    sbTextFile.Append("ParkID        :" + sqlSingleRecordReader["ParkID"].ToString().Trim() + "\r\n");
                    sbTextFile.Append("FirstName     :" + sqlSingleRecordReader["FirstName"].ToString().Trim() + "\r\n");
                    sbTextFile.Append("LastName      :" + sqlSingleRecordReader["LastName"].ToString().Trim() + "\r\n");
                    sbTextFile.Append("Initial       :" + sqlSingleRecordReader["Initial"].ToString().Trim() + "\r\n");
                    sbTextFile.Append("SubProgram    :" + sqlSingleRecordReader["SubProgram"].ToString().Trim() + "\r\n");
                    sbTextFile.Append("SessionYear   :" + sqlSingleRecordReader["SessionYear"].ToString().Trim() + "\r\n");
                    sbTextFile.Append("RequestRole   :" + sqlSingleRecordReader["ReqRole"].ToString().Trim() + "\r\n");
                    sbTextFile.Append("Funding       :" + sqlSingleRecordReader["Funding"].ToString().Trim() + "\r\n");
                    if ((sqlSingleRecordReader["Funding"].ToString().Trim()) == "Yes")
                    {
                        sbTextFile.Append("FinAid        :" + sqlSingleRecordReader["FinAid"].ToString().Trim() + "\r\n");
                    }

                    sbTextFile.Append("CXFinAid      :" + sqlSingleRecordReader["CXFinAid"].ToString().Trim() + "\r\n");

                    if (((sqlSingleRecordReader["AddCrsNo1"].ToString().Trim()) != "") || 
                        ((sqlSingleRecordReader["AddCrsTitle1"].ToString().Trim()) != ""))
                    {
                        sbTextFile.Append("AddCrsNo1     :" + sqlSingleRecordReader["AddCrsNo1"].ToString().Trim() + "\r\n");
                        sbTextFile.Append("AddCrsTtl1    :" + sqlSingleRecordReader["AddCrsTitle1"].ToString().Trim() + "\r\n");
                        sbTextFile.Append("AddCrdHrs1    :" + sqlSingleRecordReader["AddCrdHrs1"].ToString().Trim() + "\r\n");
                    }

                    if (((sqlSingleRecordReader["AddCrsNo2"].ToString().Trim()) != "") ||
                        ((sqlSingleRecordReader["AddCrsTitle2"].ToString().Trim()) != ""))
                    {
                        sbTextFile.Append("AddCrsNo2     :" + sqlSingleRecordReader["AddCrsNo2"].ToString().Trim() + "\r\n");
                        sbTextFile.Append("AddCrsTtl2    :" + sqlSingleRecordReader["AddCrsTitle2"].ToString().Trim() + "\r\n");
                        sbTextFile.Append("AddCrdHrs2    :" + sqlSingleRecordReader["AddCrdHrs2"].ToString().Trim() + "\r\n");
                    }
                    if (((sqlSingleRecordReader["AddCrsNo3"].ToString().Trim()) != "") ||
                        ((sqlSingleRecordReader["AddCrsTitle3"].ToString().Trim()) != ""))
                    {
                            sbTextFile.Append("AddCrsNo3     :" + sqlSingleRecordReader["AddCrsNo3"].ToString().Trim() + "\r\n");
                            sbTextFile.Append("AddCrsTtl3    :" + sqlSingleRecordReader["AddCrsTitle3"].ToString().Trim() + "\r\n");
                            sbTextFile.Append("AddCrdHrs3    :" + sqlSingleRecordReader["AddCrdHrs3"].ToString().Trim() + "\r\n");
                    }
                    if (((sqlSingleRecordReader["AddCrsNo4"].ToString().Trim()) != "") ||
                        ((sqlSingleRecordReader["AddCrsTitle4"].ToString().Trim()) != ""))
                    {
                        sbTextFile.Append("AddCrsNo4     :" + sqlSingleRecordReader["AddCrsNo4"].ToString().Trim() + "\r\n");
                        sbTextFile.Append("AddCrsTtl4    :" + sqlSingleRecordReader["AddCrsTitle4"].ToString().Trim() + "\r\n");
                        sbTextFile.Append("AddCrdHrs4    :" + sqlSingleRecordReader["AddCrdHrs4"].ToString().Trim() + "\r\n");
                    }
                    if (((sqlSingleRecordReader["DropCrsNo1"].ToString().Trim()) != "") ||
                        ((sqlSingleRecordReader["DropCrsTitle1"].ToString().Trim()) != ""))
                    {
                        sbTextFile.Append("DropCrsNo1    :" + sqlSingleRecordReader["DropCrsNo1"].ToString().Trim() + "\r\n");
                        sbTextFile.Append("DropCrsTtl1   :" + sqlSingleRecordReader["DropCrsTitle1"].ToString().Trim() + "\r\n");
                        sbTextFile.Append("DropCrdHrs1   :" + sqlSingleRecordReader["DropCrdHrs1"].ToString().Trim() + "\r\n");
                    }
                    if (((sqlSingleRecordReader["DropCrsNo2"].ToString().Trim()) != "") ||
                        ((sqlSingleRecordReader["DropCrsTitle2"].ToString().Trim()) != ""))
                    {
                        sbTextFile.Append("DropCrsNo2    :" + sqlSingleRecordReader["DropCrsNo2"].ToString().Trim() + "\r\n");
                        sbTextFile.Append("DropCrsTtl2   :" + sqlSingleRecordReader["DropCrsTitle2"].ToString().Trim() + "\r\n");
                        sbTextFile.Append("DropCrdHrs2   :" + sqlSingleRecordReader["DropCrdHrs2"].ToString().Trim() + "\r\n");
                    }
                    if (((sqlSingleRecordReader["DropCrsNo3"].ToString().Trim()) != "") ||
                        ((sqlSingleRecordReader["DropCrsTitle3"].ToString().Trim()) != ""))
                    {
                        sbTextFile.Append("DropCrsNo3    :" + sqlSingleRecordReader["DropCrsNo3"].ToString().Trim() + "\r\n");
                        sbTextFile.Append("DropCrsTtl3   :" + sqlSingleRecordReader["DropCrsTitle3"].ToString().Trim() + "\r\n");
                        sbTextFile.Append("DropCrdHrs3   :" + sqlSingleRecordReader["DropCrdHrs3"].ToString().Trim() + "\r\n");
                    }
                    if (((sqlSingleRecordReader["DropCrsNo4"].ToString().Trim()) != "") ||
                        ((sqlSingleRecordReader["DropCrsTitle4"].ToString().Trim()) != ""))
                    {
                        sbTextFile.Append("DropCrsNo4    :" + sqlSingleRecordReader["DropCrsNo4"].ToString().Trim() + "\r\n");
                        sbTextFile.Append("DropCrsTtl4   :" + sqlSingleRecordReader["DropCrsTitle4"].ToString().Trim() + "\r\n");
                        sbTextFile.Append("DropCrdHrs4   :" + sqlSingleRecordReader["DropCrdHrs4"].ToString().Trim() + "\r\n");
                    }
                    if ((sqlSingleRecordReader["ReqRole"].ToString().Trim()) == "Student")
                    {
                        if (((sqlSingleRecordReader["WDStudCrsNo1"].ToString().Trim()) != "") ||
                            ((sqlSingleRecordReader["WDStudCrsTitle1"].ToString().Trim()) != ""))
                        {
                            sbTextFile.Append("WDStudCrsNo1  :" + sqlSingleRecordReader["WDStudCrsNo1"].ToString().Trim() + "\r\n");
                            sbTextFile.Append("WDStudCrsTtl1 :" + sqlSingleRecordReader["WDStudCrsTitle1"].ToString().Trim() + "\r\n");
                            sbTextFile.Append("WDStudCrdHrs1 :" + sqlSingleRecordReader["WDStudCrdHrs1"].ToString().Trim() + "\r\n");
                        }
                        if (((sqlSingleRecordReader["WDStudCrsNo2"].ToString().Trim()) != "") ||
                            ((sqlSingleRecordReader["WDStudCrsTitle2"].ToString().Trim()) != ""))
                        {
                            sbTextFile.Append("WDStudCrsNo2  :" + sqlSingleRecordReader["WDStudCrsNo2"].ToString().Trim() + "\r\n");
                            sbTextFile.Append("WDStudCrsTtl2 :" + sqlSingleRecordReader["WDStudCrsTitle2"].ToString().Trim() + "\r\n");
                            sbTextFile.Append("WDStudCrdHrs2 :" + sqlSingleRecordReader["WDStudCrdHrs2"].ToString().Trim() + "\r\n");
                        }
                        if (((sqlSingleRecordReader["WDStudCrsNo3"].ToString().Trim()) != "") ||
                            ((sqlSingleRecordReader["WDStudCrsTitle3"].ToString().Trim()) != ""))
                        {
                            sbTextFile.Append("WDStudCrsNo3  :" + sqlSingleRecordReader["WDStudCrsNo3"].ToString().Trim() + "\r\n");
                            sbTextFile.Append("WDStudCrsTtl3 :" + sqlSingleRecordReader["WDStudCrsTitle3"].ToString().Trim() + "\r\n");
                            sbTextFile.Append("WDStudCrdHrs3 :" + sqlSingleRecordReader["WDStudCrdHrs3"].ToString().Trim() + "\r\n");
                        }
                        if (((sqlSingleRecordReader["WDStudCrsNo4"].ToString().Trim()) != "") ||
                            ((sqlSingleRecordReader["WDStudCrsTitle4"].ToString().Trim()) != ""))
                        {
                            sbTextFile.Append("WDStudCrsNo4  :" + sqlSingleRecordReader["WDStudCrsNo4"].ToString().Trim() + "\r\n");
                            sbTextFile.Append("WDStudCrsTtl4 :" + sqlSingleRecordReader["WDStudCrsTitle4"].ToString().Trim() + "\r\n");
                            sbTextFile.Append("WDStudCrdHrs4 :" + sqlSingleRecordReader["WDStudCrdHrs4"].ToString().Trim() + "\r\n");
                        }
                        if (((sqlSingleRecordReader["WDStudCrsNo5"].ToString().Trim()) != "") ||
                            ((sqlSingleRecordReader["WDStudCrsTitle5"].ToString().Trim()) != ""))
                        {
                            sbTextFile.Append("WDStudCrsNo5  :" + sqlSingleRecordReader["WDStudCrsNo5"].ToString().Trim() + "\r\n");
                            sbTextFile.Append("WDStudCrsTtl5 :" + sqlSingleRecordReader["WDStudCrsTitle5"].ToString().Trim() + "\r\n");
                            sbTextFile.Append("WDStudCrdHrs5 :" + sqlSingleRecordReader["WDStudCrdHrs5"].ToString().Trim() + "\r\n");
                        }
                        if (((sqlSingleRecordReader["WDStudCrsNo6"].ToString().Trim()) != "") ||
                            ((sqlSingleRecordReader["WDStudCrsTitle6"].ToString().Trim()) != ""))
                        {
                            sbTextFile.Append("WDStudCrsNo6  :" + sqlSingleRecordReader["WDStudCrsNo6"].ToString().Trim() + "\r\n");
                            sbTextFile.Append("WDStudCrsTtl6 :" + sqlSingleRecordReader["WDStudCrsTitle6"].ToString().Trim() + "\r\n");
                            sbTextFile.Append("WDStudCrdHrs6 :" + sqlSingleRecordReader["WDStudCrdHrs6"].ToString().Trim() + "\r\n");
                        }
                    }
                    //  Admin role and 
                    if ((sqlSingleRecordReader["ReqRole"].ToString().Trim()) == "Admin")
                    {
                        if (((sqlSingleRecordReader["WDAdminCrsNo1"].ToString().Trim()) != "") ||
                            ((sqlSingleRecordReader["WDAdminCrsTitle1"].ToString().Trim()) != ""))
                        {
                            sbTextFile.Append("WDAdmnCrsNo1  :" + sqlSingleRecordReader["WDAdminCrsNo1"].ToString().Trim() + "\r\n");
                            sbTextFile.Append("WDAdmnCrsTtl1 :" + sqlSingleRecordReader["WDAdminCrsTitle1"].ToString().Trim() + "\r\n");
                            sbTextFile.Append("WDAdmnCrdHrs1 :" + sqlSingleRecordReader["WDAdminCrdHrs1"].ToString().Trim() + "\r\n");
                            sbTextFile.Append("WDAdmnLDA1    :" + sqlSingleRecordReader["WDAdminLDA1"].ToString().Trim() + "\r\n");
                        }
                        if (((sqlSingleRecordReader["WDAdminCrsNo2"].ToString().Trim()) != "") ||
                            ((sqlSingleRecordReader["WDAdminCrsTitle2"].ToString().Trim()) != ""))
                        {
                            sbTextFile.Append("WDAdmnCrsNo2  :" + sqlSingleRecordReader["WDAdminCrsNo2"].ToString().Trim() + "\r\n");
                            sbTextFile.Append("WDAdmnCrsTtl2 :" + sqlSingleRecordReader["WDAdminCrsTitle2"].ToString().Trim() + "\r\n");
                            sbTextFile.Append("WDAdmnCrdHrs2 :" + sqlSingleRecordReader["WDAdminCrdHrs2"].ToString().Trim() + "\r\n");
                            sbTextFile.Append("WDAdmnLDA2    :" + sqlSingleRecordReader["WDAdminLDA2"].ToString().Trim() + "\r\n");
                        }
                        if (((sqlSingleRecordReader["WDAdminCrsNo3"].ToString().Trim()) != "") ||
                            ((sqlSingleRecordReader["WDAdminCrsTitle3"].ToString().Trim()) != ""))
                        {
                            sbTextFile.Append("WDAdmnCrsNo3  :" + sqlSingleRecordReader["WDAdminCrsNo3"].ToString().Trim() + "\r\n");
                            sbTextFile.Append("WDAdmnCrsTtl3 :" + sqlSingleRecordReader["WDAdminCrsTitle3"].ToString().Trim() + "\r\n");
                            sbTextFile.Append("WDAdmnCrdHrs3 :" + sqlSingleRecordReader["WDAdminCrdHrs3"].ToString().Trim() + "\r\n");
                            sbTextFile.Append("WDAdmnLDA3    :" + sqlSingleRecordReader["WDAdminLDA3"].ToString().Trim() + "\r\n");
                        }
                        if (((sqlSingleRecordReader["WDAdminCrsNo4"].ToString().Trim()) != "") ||
                            ((sqlSingleRecordReader["WDAdminCrsTitle4"].ToString().Trim()) != ""))
                        {
                            sbTextFile.Append("WDAdmnCrsNo4  :" + sqlSingleRecordReader["WDAdminCrsNo4"].ToString().Trim() + "\r\n");
                            sbTextFile.Append("WDAdmnCrsTtl4 :" + sqlSingleRecordReader["WDAdminCrsTitle4"].ToString().Trim() + "\r\n");
                            sbTextFile.Append("WDAdmnCrdHrs4 :" + sqlSingleRecordReader["WDAdminCrdHrs4"].ToString().Trim() + "\r\n");
                            sbTextFile.Append("WDAdmnLDA4    :" + sqlSingleRecordReader["WDAdminLDA4"].ToString().Trim() + "\r\n");
                        }
                        if (((sqlSingleRecordReader["WDAdminCrsNo5"].ToString().Trim()) != "") ||
                            ((sqlSingleRecordReader["WDAdminCrsTitle5"].ToString().Trim()) != ""))
                        {
                            sbTextFile.Append("WDAdmnCrsNo5  :" + sqlSingleRecordReader["WDAdminCrsNo5"].ToString().Trim() + "\r\n");
                            sbTextFile.Append("WDAdmnCrsTtl5 :" + sqlSingleRecordReader["WDAdminCrsTitle5"].ToString().Trim() + "\r\n");
                            sbTextFile.Append("WDAdmnCrdHrs5 :" + sqlSingleRecordReader["WDAdminCrdHrs5"].ToString().Trim() + "\r\n");
                            sbTextFile.Append("WDAdmnLDA5    :" + sqlSingleRecordReader["WDAdminLDA5"].ToString().Trim() + "\r\n");
                        }
                        if (((sqlSingleRecordReader["WDAdminCrsNo6"].ToString().Trim()) != "") ||
                            ((sqlSingleRecordReader["WDAdminCrsTitle6"].ToString().Trim()) != ""))
                        {
                            sbTextFile.Append("WDAdmnCrsNo6  :" + sqlSingleRecordReader["WDAdminCrsNo6"].ToString().Trim() + "\r\n");
                            sbTextFile.Append("WDAdmnCrsTtl6 :" + sqlSingleRecordReader["WDAdminCrsTitle6"].ToString().Trim() + "\r\n");
                            sbTextFile.Append("WDAdmnCrdHrs6 :" + sqlSingleRecordReader["WDAdminCrdHrs6"].ToString().Trim() + "\r\n");
                            sbTextFile.Append("WDAdmnLDA6    :" + sqlSingleRecordReader["WDAdminLDA6"].ToString().Trim() + "\r\n");
                        }
                    }
                    sbTextFile.Append("Reasons       :" + sqlSingleRecordReader["Reason"].ToString().Trim() + "\r\n");
                    sbTextFile.Append("ReasonExplain :" + sqlSingleRecordReader["ReasonExplain"].ToString().Trim() + "\r\n");
                    // commented out, as Pam and Tiffani don't want this field anymore per mtg on 8-11-2011
                    //sbTextFile.Append("CrdHrsPrior   :" + sqlSingleRecordReader["CrdHrsPrior"].ToString().Trim() + "\r\n");
                    //sbTextFile.Append("CrdHrsAfter   :" + sqlSingleRecordReader["CrdHrsAfter"].ToString().Trim() + "\r\n");
                    if ((sqlSingleRecordReader["ReqRole"].ToString().Trim()) == "Student")
                    {
                        sbTextFile.Append("StudentSig    :" + sqlSingleRecordReader["StudSig"].ToString().Trim() + "\r\n");
                        sbTextFile.Append("StudentDate   :" + sqlSingleRecordReader["StudDate"].ToString().Trim() + "\r\n");
                    }
                    if ((sqlSingleRecordReader["ReqRole"].ToString().Trim()) == "Admin")
                    {
                        sbTextFile.Append("AdminSig      :" + sqlSingleRecordReader["AdminSig"].ToString().Trim() + "\r\n");
                        sbTextFile.Append("AdminDate     :" + sqlSingleRecordReader["AdminDate"].ToString().Trim() + "\r\n");
                        sbTextFile.Append("AdminComments :" + sqlSingleRecordReader["AdminComments"].ToString().Trim() + "\r\n");
                    }
                    sbTextFile.Append("SubmittedDate :" + sqlSingleRecordReader["SubmittedDate"].ToString().Trim() + "\r\n");
                    sbTextFile.Append("Web Upload");

                    twSingleOutput.WriteLine(sbTextFile.ToString());
                    twSingleOutput.Close();
                    funWriteTiff(strFileName, sbTextFile.ToString());

                    //   Index file for DMS
                    TextWriter twSingleOutputResult;
                    // testing to send file to c drive and folder [make sure you have it already created]
                    strFileName = "c:\\EDMS_DATA\\Downloads\\EA_Forms\\EAForm_" + sqlSingleRecordReader["ParkID"].ToString().Trim() + "_" + intIDtoWrite.ToString() + ".txt";
                    // putting file to DMS's predetermined drive and folder
                    //strFileName = "D:\\EDMS_DATA\\Downloads\\EA_Forms\\EAForm_" + sqlSingleRecordReader["ParkID"].ToString().Trim() + "_" + intIDtoWrite.ToString() + ".txt";

                    twSingleOutputResult = new StreamWriter(strFileName);

                    // AcadYear is hard-coded and should be fixed as an input from the form.
                    string AcadYear = "2011-2012";
                    string roleFund;

                    if ((sqlSingleRecordReader["ReqRole"].ToString().Trim()) == "Admin")
                    {
                        if ((sqlSingleRecordReader["CXFinAid"].ToString().Trim()) == "Yes")
                        {
                            roleFund = "AdminAid";
                        }
                        else
                        {
                            roleFund = "AdminNoAid";
                        }
                    }
                    else
                    {
                        if ((sqlSingleRecordReader["CXFinAid"].ToString().Trim()) == "Yes")
                        {
                            roleFund = "StudAid";
                        }
                        else
                        {
                            roleFund = "StudNoAid";
                        }
                    }


                    twSingleOutputResult.Write(sqlSingleRecordReader["ParkID"].ToString().Trim() + "|");
                    twSingleOutputResult.Write(sqlSingleRecordReader["LastName"].ToString().ToUpper().Substring(0, 1));
                    twSingleOutputResult.Write(sqlSingleRecordReader["LastName"].ToString().ToLower().Substring(1, sqlSingleRecordReader["LastName"].ToString().Length - 1) + ", ");
                    twSingleOutputResult.Write(sqlSingleRecordReader["FirstName"].ToString().ToUpper().Substring(0, 1));
                    twSingleOutputResult.Write(sqlSingleRecordReader["FirstName"].ToString().ToLower().Substring(1, sqlSingleRecordReader["FirstName"].ToString().Length - 1));
                    twSingleOutputResult.Write(sqlSingleRecordReader["Initial"].ToString().Trim() + "|");
                    // this is blank field (just writing a pipe) due to not having birth date to pass
                    twSingleOutputResult.Write("|");
                    // currently, DMS is getting the Subprogram from CX (hence why just writing a pipe)
                    // twSingleOutputResult.Write(sqlSingleRecordReader["SubProgram"].ToString().Trim() + "|");
                    twSingleOutputResult.Write("|");
                    twSingleOutputResult.Write(AcadYear.ToString().Trim() + "|");
                    // this is blank field (just writing a pipe) due to not having to pass comments
                    twSingleOutputResult.Write("|");
                    twSingleOutputResult.Write(roleFund.ToString().Trim() + "|");
                    twSingleOutputResult.Close();
                }
                else
                {
                    TextWriter twSingleOutputError;
                    // testing to send file to c drive and folder [make sure you have it already created]
                    twSingleOutputError = new StreamWriter("c:\\EDMS_DATA\\Downloads\\EA_Forms" + "Error_" + intIDtoWrite.ToString() + ".txt");
                    // putting file to DMS's predetermined drive and folder
                    //twSingleOutputError = new StreamWriter("D:\\EDMS_DATA\\Downloads\\EA_Forms" + "Error_" + intIDtoWrite.ToString() + ".txt");

                    twSingleOutputError.WriteLine("Could not find database for ID = " + intIDtoWrite.ToString());
                    twSingleOutputError.Close();
                }

            }
            finally
            {
                sqlSingleRecordReader.Close();
                sqlSingleRecordConn.Close();
            }
            return;
        }


        static void funMarkPrinted(int intID)
        {
            // change the "printed" flag from 0 (not printed) to 1 (printed)

            SqlConnection sqlSingleRecordConn = new SqlConnection("Data Source=park-sparrow;Initial Catalog=Wdb_Enroll_Adj;User Id=Wdb_EnrollAdj_DocImage;Password=Print4MyChanges");
            SqlCommand sqlSingleRecordCommand = new SqlCommand("P_sp_DMS_Mark_As_Printed_EnrollAdj", sqlSingleRecordConn);
            sqlSingleRecordConn.Open();
            sqlSingleRecordCommand.CommandType = CommandType.StoredProcedure;
            sqlSingleRecordCommand.Parameters.AddWithValue("ID", intID);
            try
            {
                sqlSingleRecordCommand.ExecuteNonQuery();
            }
            finally
            {
                sqlSingleRecordConn.Close();
            }
            return;
        }

        public void funwritetiff2(string strFileName, string strActualText)
        { 
           
        
        
        }



        static void funWriteTiff(string strFileName, string strActualText)
        {
            //  Change bitmap values to match your file size
            Bitmap imgThumb = new Bitmap(1024, 1024, PixelFormat.Format4bppIndexed);
            MemoryStream ms = new MemoryStream();
            //Image imgThumb = new Bitmap(4000, 1500);
            //System.Drawing.Bitmap b = new System.Drawing.Bitmap(imgThumb);
          //  b.PixelFormat = System.Drawing.Imaging.PixelFormat.Format8bppIndexed;
            Graphics objGraphics = Graphics.FromImage(imgThumb);
            //  Font objFont = new Font("Arial", 12, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Pixel);
            Font objFont = new Font("Courier New", 12, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Pixel);
            objGraphics = Graphics.FromImage(imgThumb);

            // Set Background color
            objGraphics.Clear(Color.White);
            //objGraphics.SmoothingMode = SmoothingMode.AntiAlias;
            objGraphics.TextRenderingHint = TextRenderingHint.AntiAlias;
            //Color.FromArgb (0,0,0) = black; change values to change text color
            objGraphics.DrawString(strActualText, objFont, new SolidBrush(Color.FromArgb(0, 0, 0)), 0, 0);

            imgThumb.Save(ms, System.Drawing.Imaging.ImageFormat.Tiff);
            byte[] be = ms.ToArray();
            using (var fileStream = File.OpenWrite(strFileName))
            {
                ms.WriteTo(fileStream);
            }
            

        }



        static void Main(string[] args)
        {
            int intID;
            SqlConnection sqlMainConn = new SqlConnection("Data Source=park-sparrow;Initial Catalog=Wdb_Enroll_Adj;User Id=Wdb_EnrollAdj_DocImage;Password=Print4MyChanges");
            SqlCommand sqlMainCommand = new SqlCommand("P_sp_DMS_List_Enroll_Adj_to_Print", sqlMainConn);
            SqlDataReader sqlMainReader;
            sqlMainConn.Open();
            sqlMainCommand.CommandType = CommandType.StoredProcedure;
            sqlMainReader = sqlMainCommand.ExecuteReader();
            try
            {
                while (sqlMainReader.Read())
                {
                    intID = Int32.Parse(sqlMainReader["ID"].ToString());
                    // If you have a testing number put it here
                    //                    intID = 559;
                    funWriteText(intID);
                    // testing to keep it from being marked as printed.  
                    // UNCOMMENT when done testing
                    funMarkPrinted(intID);
                }
            }
            finally
            {
                sqlMainReader.Close();
                sqlMainConn.Close();
            }

            return;
        }
    }
}

Open in new window

0
 

Author Closing Comment

by:HawaiiDragon
ID: 37084092
As I have moved on from this project I am closing this question
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Hello there! As a developer I have modified and refactored the unit tests which was written by fellow developers in the past. On the course, I have gone through various misconceptions and technical challenges when it comes to implementation. I would…
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
Suggested Courses

873 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question