예제 #1
0
    /// <summary>
    /// 动态设置Iframe路径
    /// </summary>
    /// <param name="url">url</param>
    public void Setframe(string url)
    {
        string parm    = url.Substring(0, url.LastIndexOf("/") + 1);
        string PdfPath = "";
        bool   exist   = true;
        int    count   = 0;

        while (exist)
        {
            if (File.Exists(HttpContext.Current.Server.MapPath(url)))
            {
                bool b = true;
                int  i = 0;
                while (string.IsNullOrEmpty(PdfPath) || b)
                {
                    MoveFile mf = new MoveFile("/Preview");
                    mf.DeleteFile(HttpContext.Current.Server.MapPath(url));
                    string path = mf.GetFilePath(HttpContext.Current.Server.MapPath(url)).Replace("\\", "/");
                    PdfPath = path;
                    FileInfo info = new FileInfo(HttpContext.Current.Server.MapPath(PdfPath));
                    if (info.Exists && info.Length > 1000)
                    {
                        b     = false;
                        exist = false;
                    }
                    ++i;
                    //Thread.Sleep(i * 100);
                }
            }
            else
            {
                if (count >= 100)
                {
                    PrinterLOG.WriterLog(@"Cannot find the file:" + url, "Setframe", true);
                    break;
                }
                ++count;
                exist = true;
                Thread.Sleep(500);
            }
        }

        HttpContext.Current.Response.Write(PdfPath + "?datetime=" + parm);
    }
예제 #2
0
    /// <summary>
    /// 动态设置Iframe路径
    /// </summary>
    /// <param name="url">url</param>
    public void Setframe(string url)
    {
        string   parm    = url.Substring(0, url.LastIndexOf("/") + 1);
        string   PdfPath = "";
        bool     exist   = true;
        DateTime dt1     = new DateTime();

        while (exist)
        {
            if (File.Exists(HttpContext.Current.Server.MapPath(url)))
            {
                bool b = true;
                int  i = 0;
                while (string.IsNullOrEmpty(PdfPath) || b)
                {
                    MoveFile mf = new MoveFile("/Preview");
                    mf.DeleteFile(HttpContext.Current.Server.MapPath(url));
                    string path = mf.GetFilePath(HttpContext.Current.Server.MapPath(url)).Replace("\\", "/");
                    PdfPath = path;
                    FileInfo info = new FileInfo(HttpContext.Current.Server.MapPath(PdfPath));
                    if (info.Exists && info.Length > 1000)
                    {
                        b     = false;
                        exist = false;
                    }
                    ++i;
                    Thread.Sleep(i * 100);
                }
            }
            else
            {
                TimeSpan ts = new DateTime() - dt1;
                if (ts.Minutes == 60)
                {
                    break;
                }
                exist = true;
                Thread.Sleep(3000);
            }
        }

        HttpContext.Current.Response.Write(PdfPath + "?datetime=" + parm);
    }