May 17, 2016, 2:31 PM
[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:
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.