Example #1
0
        public ClientLogger GetPDFfromURLPDF(string sURL, string sPath, string sFileName, string sVolume, string sSection)
        {
            ClientLogger oLog = new ClientLogger();
            using (WebClient client = new WebClient())
            {

                var sw = Stopwatch.StartNew();
                // business logic

                oLog._sFile = sFileName;
                oLog._sStart = GetTimeStamp();
                oLog._Section = sSection;
                oLog._Volume = sVolume;
                oLog._sPath = sPath + sVolume + "\\" + sFileName;
                client.Credentials = new System.Net.NetworkCredential("echavez","chavez9909", "COURTS");
                client.DownloadFile(sURL, oLog._sPath);

                while (client.IsBusy)
                {
                    System.Threading.Thread.Sleep(1000);
                }

                sw.Stop();
                TimeSpan time = sw.Elapsed;
                oLog._sSpan = time.ToString();
            }

            oLog._sEnd = GetTimeStamp();

            return oLog;
        }
Example #2
0
    protected void btnGetPDFs_Click(object sender, EventArgs e)
    {
        if (IsPostBack){

            string sDir = "";
            string sTemp;

            List<ClientLogger> LogList = new List<ClientLogger>();

            BaseMethods sFldr = new BaseMethods();
            sDir = sFldr.GenerateRandomFolderName();
            DirectoryInfo di = Directory.CreateDirectory(sTmpFolderPath + sDir);
            sTemp = sTmpFolderPath + sDir + "\\" ;

            foreach (GridViewRow rw in gvDocsToPDF.Rows)
            {
                if (rw.RowType == DataControlRowType.DataRow)
                {
                    CheckBox cbPDF = new CheckBox();
                    cbPDF = (CheckBox)(rw.FindControl("cbSelect"));

                    if (cbPDF.Checked)
                    {

                        string sVolume, sSection, sFileName, sFileURL;
                        sVolume = rw.Cells[1].Text.ToString();
                        sSection = rw.Cells[2].Text.ToString();
                        sFileName = rw.Cells[3].Text.ToString();
                        sFileURL = rw.Cells[4].Text.ToString();

                        DirectoryInfo oCreate = Directory.CreateDirectory(sTemp + sVolume);

                        BaseMethods oJob = new BaseMethods();
                        LogList.Add(oJob.GetPDFfromURLPDF(sFileURL, sTemp, sFileName, sVolume, sSection));
                        oJob = null;

                    }

                }
            }

            Session["sLogs"] = LogList;
            Session["sDir"] = sDir;

            BaseMethods oJobr = new BaseMethods();

            foreach (System.IO.DirectoryInfo g in di.GetDirectories())
            {

                List<ClientLogger> PDFList = new List<ClientLogger>();

                System.IO.DirectoryInfo dir = new System.IO.DirectoryInfo(g.FullName);
                foreach (System.IO.FileInfo f in dir.GetFiles("*.*"))
                {

                    ClientLogger pdfLt = new ClientLogger(){
                        _sFile = f.Name,
                        _sPath = f.DirectoryName,
                    };

                    PDFList.Add(pdfLt);

                }

                oJobr.GetSinglePDFfromManyPDFs(PDFList, g.FullName, "_Vol.pdf");

            }

            Response.Redirect("Processed.aspx");

        }
    }