Beispiel #1
0
        private void Page_Load(object sender, System.EventArgs e)
        {
            if (!IsPostBack)
            {
                if (Session["sFileType"].ToString() == "S3")
                {
                    WebRefNew.DownloadNew objService2 = new WebRefNew.DownloadNew();
                    if (objService2 != null)
                    {
                        objService2.Url = GetURLNew();
                        byte[]           byteArray = objService2.GetMultiPages(Session["sFile"].ToString(), Convert.ToInt32(Request.QueryString["iPageNo"]));
                        System.IO.Stream _stream   = new MemoryStream(byteArray);

                        Response.ContentType = "image/jpeg";
                        Response.BinaryWrite(byteArray);
                    }
                }
                else
                {
                    WEBRef.FileDownload objService = new WEBRef.FileDownload();
                    if (objService != null)
                    {
                        objService.Url = GetURL();
                        byte[]           byteArray = objService.GetMultiPages(Session["sFile"].ToString(), Convert.ToInt32(Request.QueryString["iPageNo"]));
                        System.IO.Stream _stream   = new MemoryStream(byteArray);

                        Response.ContentType = "image/jpeg";
                        Response.BinaryWrite(byteArray);
                    }
                }
            }
        }
        private bool UploadFile(string sFileName, HtmlInputFile httpFile)
        {
            Stream oStream;
            int    FileLen;
            string strReturn = "";
            bool   bolResult = false;

            WebRefNew.DownloadNew objService2 = new WebRefNew.DownloadNew();
            objService2.Url = GetURL2();

            try
            {
                FileLen = httpFile.PostedFile.ContentLength;
                byte[] oFileByte = new byte[FileLen];
                oStream = httpFile.PostedFile.InputStream;
                oStream.Read(oFileByte, 0, FileLen);
                bolResult = objService2.UploadFileNew(sFileName, oFileByte, strReturn, strChildBuyer);
                if (bolResult == false)
                {
                    throw new Exception(strReturn);
                }
            }
            catch (Exception ex)
            {
                string ss = ex.Message;
            }
            finally
            {
                objService2 = null;
            }
            return(bolResult);
        }
Beispiel #3
0
        private bool ForceDownload(string sPath, int iStep)
        {
            bool   bRetVal   = false;
            string sFileName = sPath;

            if (iStep == 0)
            {
                try
                {
                    Session["sFile"]     = sFileName.ToString();
                    Session["sFileType"] = "S2";
                    WEBRef.FileDownload objService = new WEBRef.FileDownload();
                    if (objService != null)
                    {
                        objService.Url    = GetURL();
                        Session["sPages"] = Convert.ToString(objService.GetPageCount(sFileName));
                        Response.Redirect("ImgViewNew.htm");
                    }
                    else
                    {
                        Utility.ErrorLog(Server.MapPath(@"..\..\Logs\ErrorLog.txt"), "Webservice not accessible");
                    }
                }
                catch (Exception ex)
                {
                    Utility.ErrorLog(Server.MapPath(@"..\..\Logs\ErrorLog.txt"), ex.Message);
                }
            }
            else if (iStep == 1)
            {
                try
                {
                    Session["sFile"]     = sFileName.ToString();
                    Session["sFileType"] = "S3";
                    WebRefNew.DownloadNew objService2 = new WebRefNew.DownloadNew();
                    if (objService2 != null)
                    {
                        objService2.Url   = GetURLNew();
                        Session["sPages"] = Convert.ToString(objService2.GetPageCount(sFileName));
                    }

                    Response.Redirect("ImgViewNew.htm");
                }
                catch (Exception ex)
                {
                    Utility.ErrorLog(Server.MapPath(@"..\..\Logs\ErrorLog.txt"), ex.Message);
                }
            }
            return(bRetVal);
        }