Пример #1
0
        private bool ForceDownload(string sPath, int iStep)
        {
            bool   bRetVal   = false;
            string sFileName = sPath;

            if (iStep == 0)
            {
                System.IO.FileStream fs1 = null;
                try
                {
                    WEBRef.FileDownload objService = new WEBRef.FileDownload();
                    objService.Url = GetURL();
                    byte[] bytBytes = objService.DownloadFile(sFileName);
                    if (bytBytes != null)
                    {
                        Response.AppendHeader("content-disposition", "attachment; filename=" + Path.GetFileName(sFileName));
                        Response.ContentType = "application//octet-stream";
                        Response.BinaryWrite(bytBytes);
                        Response.Flush();
                        Response.End();
                        fs1.Close();
                        fs1     = null;
                        bRetVal = true;
                    }
                }
                catch
                {
                }
            }
            else if (iStep == 1)
            {
                System.IO.FileStream fs1 = null;
                try
                {
                    WEBRef2.FileDownload objService2 = new WEBRef2.FileDownload();
                    objService2.Url = GetURL2();
                    byte[] bytBytes = objService2.DownloadFile(sFileName);
                    if (bytBytes != null)
                    {
                        Response.AppendHeader("content-disposition", "attachment; filename=" + Path.GetFileName(sFileName));
                        Response.ContentType = "application//octet-stream";
                        Response.BinaryWrite(bytBytes);
                        Response.Flush();
                        Response.End();
                        fs1.Close();
                        fs1     = null;
                        bRetVal = true;
                    }
                }
                catch
                {
                }
            }
            return(bRetVal);
        }
Пример #2
0
        private bool ForceDownload(string sPath, int iStep)
        {
            bool   bRetVal   = false;
            string sFileName = sPath;

            if (iStep == 0)
            {
                try
                {
                    WEBRef.FileDownload objService = new WEBRef.FileDownload();
                    objService.Url = GetURL();
                    byte[] bytBytes = objService.DownloadFile(sFileName);
                    if (bytBytes != null)
                    {
                        Response.Clear();
                        Response.ContentType = "image/tiff";
                        Response.BinaryWrite(bytBytes);
                        Response.End();
                        objService.Dispose();
                        bRetVal = true;
                    }
                }
                catch (Exception ex)
                {
                    Utility.ErrorLog(@"D:\inetpub\wwwroot\p2dgroup\Logs\ErrorLog.txt", ex.Message);
                }
            }
            else if (iStep == 1)
            {
                try
                {
                    WEBRef2.FileDownload objService2 = new WEBRef2.FileDownload();
                    objService2.Url = GetURL2();
                    byte[] bytBytes = objService2.DownloadFile(sFileName);
                    if (bytBytes != null)
                    {
                        Response.Clear();
                        Response.ContentType = "image/tiff";
                        Response.BinaryWrite(bytBytes);
                        Response.End();
                        objService2.Dispose();
                        bRetVal = true;
                    }
                }
                catch (Exception ex)
                {
                    Utility.ErrorLog(@"D:\inetpub\wwwroot\p2dgroup\Logs\ErrorLog.txt", ex.Message);
                }
            }
            return(bRetVal);
        }
Пример #3
0
        private bool RemoveFile(string sPath, int iStep)
        {
            string sFileName = "";
            bool   bRetVal   = false;

            if (iStep == 0)
            {
                try
                {
                    sFileName = sPath.Replace("I:", "C:\\P2D");
                    sFileName = sFileName.Replace("\\90104-server2", "C:\\P2D");

                    WEBRef.FileDownload objService = new WEBRef.FileDownload();
                    objService.Url = GetURL();
                    bRetVal        = objService.RemoveFile(sFileName);
                }
                catch
                {
                }
            }
            if (iStep == 1)
            {
                try
                {
                    WEBRef2.FileDownload objService2 = new WEBRef2.FileDownload();
                    objService2.Url = GetURL2();
                    sFileName       = sPath.Replace("\\90107-server3", @"C:\File Repository");
                    sFileName       = GetTrimFirstSlash(sFileName);
                    bRetVal         = objService2.RemoveFile(sFileName);
                }
                catch
                {
                }
            }
            return(bRetVal);
        }