private void UploadPaper()
        {
            // 根据 ProgressBar.htm 显示进度条界面
            string       templateFileName = Path.Combine(Server.MapPath("."), "ProgressBar.htm");
            StreamReader reader           = new StreamReader(@templateFileName, System.Text.Encoding.GetEncoding("gb2312"));
            string       html             = reader.ReadToEnd();

            reader.Close();
            Response.Write(html);
            Response.Flush();
            System.Threading.Thread.Sleep(200);

            string strId = Request.QueryString.Get("RandomExamID");
            //获取当前考试的生成试卷的状态和次数
            RandomExamBLL objBll = new RandomExamBLL();

            RailExam.Model.RandomExam obj = objBll.GetExam(Convert.ToInt32(strId));

            string       typeid = Request.QueryString.Get("typeid");
            string       strSql, strKey = "0";
            OracleAccess db = new OracleAccess();

            int orgId = Convert.ToInt32(ConfigurationManager.AppSettings["StationID"]);

            try
            {
                RandomExamResultBLL objResultBll = new RandomExamResultBLL();

                strSql = "select SYNCHRONIZE_LOG_SEQ.NextVal@link_sf from dual";
                DataRow dr = db.RunSqlDataSet(strSql).Tables[0].Rows[0];
                strKey = dr[0].ToString();

                strSql = "insert into  SYNCHRONIZE_LOG@link_sf values(" + strKey + ","
                         + orgId + ",6,sysdate,null,1," + PrjPub.ServerNo + ")";
                db.ExecuteNonQuery(strSql);

                strSql =
                    @"select Examinee_ID,Random_Exam_Result_ID from Random_Exam_Result@link_sf where Random_Exam_ID=" + obj.RandomExamId + @"
                                      and org_id=" + PrjPub.StationID + @" and examinee_id in (select employee_Id from Random_Exam_Result_Detail a
                                      inner join Computer_Room b on a.Computer_Room_ID=b.Computer_Room_ID
                                      inner join Computer_Server c on b.Computer_Server_ID=c.Computer_Server_ID
                                      where to_number(c.Computer_Server_No)=" + PrjPub.ServerNo + @" and a.Random_Exam_ID=" + obj.RandomExamId + ")";
                DataSet dsResult = db.RunSqlDataSet(strSql);


                IList <RandomExamResult> randomExamResults = objResultBll.GetRandomExamResultByExamID(obj.RandomExamId);
                int count = randomExamResults.Count + dsResult.Tables[0].Rows.Count + 1;
                System.Threading.Thread.Sleep(10);
                string jsBlock = "<script>SetPorgressBar('正在上传考试答卷,请等待......','" + ((1 * 100) / ((double)count)).ToString("0.00") + "'); </script>";
                Response.Write(jsBlock);
                Response.Flush();


                string    strUrl = "ftp://" + PrjPub.ServerIP + "/Photo";
                Uri       directoryToDownload = new Uri(strUrl);
                FtpClient ftpSession          = FtpClient.GetFtpClient(directoryToDownload.Host);

                if (ftpSession == null)
                {
                    Pub.AddFtp();
                    ftpSession = FtpClient.GetFtpClient(directoryToDownload.Host);
                }

                ftpSession.MakeDirectory("/Photo/" + obj.RandomExamId);

                int progressNum = 2;

                foreach (DataRow drResult in dsResult.Tables[0].Rows)
                {
                    ftpSession.DeleteFile(new Uri(strUrl + "/" + obj.RandomExamId + "/" + drResult["Examinee_ID"] + "_" + drResult["Random_Exam_Result_ID"] + "_00.jpg"));
                    ftpSession.DeleteFile(new Uri(strUrl + "/" + obj.RandomExamId + "/" + drResult["Examinee_ID"] + "_" + drResult["Random_Exam_Result_ID"] + "_01.jpg"));
                    ftpSession.DeleteFile(new Uri(strUrl + "/" + obj.RandomExamId + "/" + drResult["Examinee_ID"] + "_" + drResult["Random_Exam_Result_ID"] + "_02.jpg"));
                    ftpSession.DeleteFile(new Uri(strUrl + "/" + obj.RandomExamId + "/" + drResult["Examinee_ID"] + "_" + drResult["Random_Exam_Result_ID"] + "_03.jpg"));

                    System.Threading.Thread.Sleep(10);
                    jsBlock = "<script>SetPorgressBar('正在上传考试答卷,请等待......','" + ((progressNum * 100) / ((double)count)).ToString("0.00") + "'); </script>";
                    Response.Write(jsBlock);
                    Response.Flush();

                    progressNum++;
                }

                //先删除路局的考试成绩和答卷
                objResultBll.DeleteRandomExamResultServer(obj.RandomExamId);

                foreach (RandomExamResult randomExamResult in randomExamResults)
                {
                    if (randomExamResult.IsTemp == 1)
                    {
                        //从中间提交表到正式表
                        objResultBll.RemoveResultAnswerTemp(randomExamResult.RandomExamResultId);
                    }

                    //获取路局的主键ID
                    strSql = "select Random_Exam_Result_Seq.Nextval@link_sf from dual";
                    DataRow drSeq    = db.RunSqlDataSet(strSql).Tables[0].Rows[0];
                    int     serverId = Convert.ToInt32(drSeq[0]);

                    //将成绩插入路局
                    objResultBll.InsertRandomExamResultServer(randomExamResult.RandomExamResultId, serverId, obj.RandomExamId);

                    if (typeid == "2")
                    {
                        //将答卷插入路局
                        objResultBll.InsertRandomExamResultAnswerServer(obj.RandomExamId, randomExamResult.RandomExamResultId, serverId);
                    }

                    strSql = "select * from Random_Exam_Result_Photo where Random_Exam_ID=" + obj.RandomExamId +
                             " and Random_Exam_Result_ID=" + randomExamResult.RandomExamResultId;
                    DataSet ds = db.RunSqlDataSet(strSql);
                    if (ds.Tables[0].Rows.Count > 0)
                    {
                        DataRow drPhoto = ds.Tables[0].Rows[0];

                        int employeeId = Convert.ToInt32(drPhoto["Employee_ID"]);
                        Uri ftpUri     = new Uri(strUrl + "/" + obj.RandomExamId + "/");
                        if (drPhoto["FingerPrint"] != DBNull.Value)
                        {
                            SavePhotoToServer(employeeId, (byte[])drPhoto["FingerPrint"], 0, serverId, ftpSession, ftpUri);
                        }

                        if (drPhoto["Photo1"] != DBNull.Value)
                        {
                            SavePhotoToServer(employeeId, (byte[])drPhoto["Photo1"], 1, serverId, ftpSession, ftpUri);
                        }

                        if (drPhoto["Photo2"] != DBNull.Value)
                        {
                            SavePhotoToServer(employeeId, (byte[])drPhoto["Photo2"], 2, serverId, ftpSession, ftpUri);
                        }

                        if (drPhoto["Photo3"] != DBNull.Value)
                        {
                            SavePhotoToServer(employeeId, (byte[])drPhoto["Photo3"], 3, serverId, ftpSession, ftpUri);
                        }
                    }

                    System.Threading.Thread.Sleep(10);
                    jsBlock = "<script>SetPorgressBar('正在上传考试答卷,请等待......','" + ((progressNum * 100) / ((double)count)).ToString("0.00") + "'); </script>";
                    Response.Write(jsBlock);
                    Response.Flush();

                    progressNum++;
                }

                if (typeid == "1")
                {
                    //只上传成绩须更新时间
                    strSql = "update Random_Exam_Computer_Server@link_sf set  "
                             + "Last_Upload_Date=sysdate   where random_exam_id=" + obj.RandomExamId
                             + " and Computer_server_no=" + PrjPub.ServerNo;
                    db.ExecuteNonQuery(strSql);
                }
                else
                {
                    //如果考试已经结束上传,将上传标志置为已经上传
                    if (obj.IsStart == 2)
                    {
                        objBll.UpdateIsUpload(obj.RandomExamId, PrjPub.ServerNo, 1);
                    }
                    else
                    {
                        objBll.UpdateIsUpload(obj.RandomExamId, PrjPub.ServerNo, 0);
                    }
                }

                strSql = "update SYNCHRONIZE_LOG@link_sf set SYNCHRONIZE_STATUS_ID=2,End_Time=sysdate where SYNCHRONIZE_LOG_ID=" + strKey;
                db.ExecuteNonQuery(strSql);
            }
            catch (Exception ex)
            {
                strSql = "update SYNCHRONIZE_LOG@link_sf set SYNCHRONIZE_STATUS_ID=3,End_Time=sysdate where SYNCHRONIZE_LOG_ID=" + strKey;
                db.ExecuteNonQuery(strSql);
                Response.Write("<script>alert('" + ex.Message.Replace("\n", "\r\n") + "');window.close();</script>");
                return;
            }

            Response.Write("<script>top.returnValue='true';window.close();</script>");
        }