private bool canView(object aObject) { if (fileUrl == null) { if (TaxPayerIsLink.GetValueOrDefault(false)) { fileUrl = (CustomUri.GetAbsoluteUrl("upload/" + TaxPayerLinkId.Value) + "/" + TaxPayerDocumentName); } else { fileUrl = (CustomUri.GetAbsoluteUrl("upload/" + TaxPayerId.Value) + "/" + TaxPayerDocumentName); } } if (fileUrl != null) { int lastDot = fileUrl.LastIndexOf("."); if (lastDot <= 0) { return(false); } String lExt = fileUrl.Substring(lastDot, fileUrl.Length - lastDot).ToLower(); if (lExt == ".pdf" || lExt == ".doc" || lExt == ".docx" || lExt == ".xls" || lExt == ".xlsx" || lExt == ".jpeg" || lExt == ".jpg" || lExt == ".png" || lExt == ".bmp" || lExt == ".tiff" || lExt == ".tif" || lExt == ".gif") { if (!TaxPayerUpdateTime.HasValue) { return(false); } DateTime lToday = DateTime.Now; if (lToday.Year == TaxPayerUpdateTime.Value.Year && lToday.Month == TaxPayerUpdateTime.Value.Month && lToday.Day == TaxPayerUpdateTime.Value.Day) { return(false); } return(true); } else { return(false); } } else { return(false); } }
private void onView() { if (fileUrl == null) { if (TaxPayerIsLink.GetValueOrDefault(false)) { fileUrl = (CustomUri.GetAbsoluteUrl("upload/" + TaxPayerLinkId.Value) + "/" + TaxPayerDocumentName); } else { fileUrl = (CustomUri.GetAbsoluteUrl("upload/" + TaxPayerId.Value) + "/" + TaxPayerDocumentName); } } ReviewWindow review = new ReviewWindow(fileUrl + ".xod"); review.Show(); }
private void onDownload() { if (fileUrl == null) { if (TaxPayerIsLink.GetValueOrDefault(false)) { fileUrl = (CustomUri.GetAbsoluteUrl("upload/" + TaxPayerLinkId.Value) + "/" + TaxPayerDocumentName); } else { fileUrl = (CustomUri.GetAbsoluteUrl("upload/" + TaxPayerId.Value) + "/" + TaxPayerDocumentName); } } try { saveFileDialog = new SaveFileDialog(); saveFileDialog.Filter = "All Files|*.*"; saveFileDialog.GetType().GetMethod("set_DefaultFileName").Invoke(saveFileDialog, new object[] { TaxPayerDocumentName }); bool?dialogResult = saveFileDialog.ShowDialog(); if (dialogResult != true) { return; } WebClient client = new WebClient(); Uri uri = new Uri(fileUrl, UriKind.RelativeOrAbsolute); client.OpenReadCompleted += new OpenReadCompletedEventHandler(OpenReadCompleted); client.DownloadProgressChanged += new DownloadProgressChangedEventHandler(DownloadProgressChanged); client.OpenReadAsync(uri); DownLoading = Visibility.Visible; } catch (System.Exception ex) { MessageBox.Show(ex.StackTrace); } }