[CLOSED] Mask on DirectMethod

  1. #1

    [CLOSED] Mask on DirectMethod

    Hello,

    I use a DirectMethod to download a file from server. Because of downloading process is too long, I use mask to show loading...
    ShowMask works well but, after file downloaded mask doesn't hide automatically. I try some workaround to hide mask but didn't work.
    How can I hide mask after file downloaded?

    Code from frontend:

     var DownloadFile = function (data) {
                InvoiceView.Download(data, { isUpload: true });
            };
    
     <ext:Button ID="btnExportXml" runat="server" Text="XML Ä°ndir" Icon="Printer" Handler="DownloadFile(0);" Width="100"></ext:Button>
    Code from backend:

    [DirectMethod(Namespace = "InvoiceView", ShowMask=true)]
            public void Download(string data)
            {
                try
                {
                    string password = SessionManager.GetPassword();
                    string companyId = SessionManager.GetCompanyID();
                    string invoiceUid = SessionManager.GetInvoiceUID();
                    string filetype = data == "1" ? "pdf" : "invoice";
                    string invoicetype = SessionManager.GetInvoiceType() == 1 ? "efatura" : "earsiv"; //burda earsiv yazmak çok önemli değil.
                    string resultMessage = string.Empty;
    
                    PdfAndXmlDownloader downloader = new PdfAndXmlDownloader();
    
                    var fileBytes = downloader.GetStreamOnWebServiceForInvoice(invoicetype, filetype, invoiceUid, companyId, password, out resultMessage);
                    if (resultMessage == "ok")
                    {
                        Response.Clear();
                        Response.ContentType = "application/pdf";
                        if (filetype == "pdf")
                            Response.AddHeader("Content-Disposition", "attachment; filename=" + invoiceUid + ".pdf");
                        else
                            Response.AddHeader("Content-Disposition", "attachment; filename=" + invoiceUid + ".xml");
    
                        using (MemoryStream memoryStream = new MemoryStream(fileBytes))
                        {
                            memoryStream.WriteTo(Response.OutputStream);
                            memoryStream.Close();
                        }
    
                        HttpContext.Current.ApplicationInstance.CompleteRequest();
                    }
                    else
                    {
                        X.Msg.Notify("Sonuç", "An error occurs when downloading file :" + resultMessage).Show();
                    }
                }
                catch (Exception ex)
                {
                    Messages.ShowMessageBox("HATA", "An error occurs when downloading file.", MessageBox.Icon.ERROR, "Ext.net.Mask.hide()");
                    logman.ToTextFile(ex);
                }
            }
    Last edited by fabricio.murta; May 18, 2016 at 4:56 PM.
  2. #2
    Hello @yusuf! It is not possible to know when a download finished, unfortunately, unless you use a SWF Flash download tool that provides such feedback.

    Please refer to this forum thread for details and alternatives: How to show and Hide mask while saving file to local?.

    Hope this helps!
    Fabrício Murta
    Developer & Support Expert
  3. #3
    Thank you fabricio.murta

    I apply this approach http://forums.ext.net/showthread.php?19430#post83757
    And it works well.
  4. #4
    Great! Glad you could find a solution that fits your needs, and thanks for sharing the outcome!
    Fabrício Murta
    Developer & Support Expert

Similar Threads

  1. [CLOSED] Load Mask custom message for Ext.net.DirectMethod.request
    By PriceRightHTML5team in forum 2.x Legacy Premium Help
    Replies: 3
    Last Post: Sep 11, 2013, 12:53 PM
  2. Show a load mask with a DirectMethod call
    By ashwinrath in forum 1.x Help
    Replies: 2
    Last Post: Apr 21, 2012, 6:35 PM
  3. [CLOSED] help with DirectMethod mask
    By Pablo_Azevedo in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Aug 04, 2011, 8:59 PM
  4. [CLOSED] Difference between DirectMethod , DirectEvent, Static DirectMethod
    By syllabusarq in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Mar 01, 2011, 11:37 AM
  5. Ext.net.DirectMethod.request MASK
    By sipo in forum 1.x Help
    Replies: 5
    Last Post: May 07, 2010, 5:30 AM

Tags for this Thread

Posting Permissions