//[OutputCache(Duration = 60 * 60 * 24, VaryByParam = "id")] public ActionResult SpecSheet(string id, string objectId, string returnUrl, string type) { if (ConfigurationManager.AppSettings["EnableBynder"] == "true") { byte[] file = BynderHelper.GetDocumentAsByteArray((string)Session["Culture"], objectId, "specification"); if (file != null && file.Length > 0) { return(File(file, System.Net.Mime.MediaTypeNames.Application.Pdf, objectId + ".pdf")); } else { return(View("DownlError")); } } else { //TODO Awaiting Riwal - Must be changed to get the spec sheet from Google Drive or wherever Riwal upload it HttpWebResponse response = GetResponseFrom(String.Format("{0}/SpecSheet/{1}?custKey={2}&type={3}", baseURL, id, this.ActiveCustomer.CustomerKey, type)); if (response == null || response.StatusCode != HttpStatusCode.OK) { ViewBag.returnUrl = Url.IsLocalUrl(returnUrl) ? returnUrl : Url.Action("Index", "Overview"); ViewBag.returnUrl = (Request.ApplicationPath == "/" ? "" : Request.ApplicationPath) + ViewBag.returnUrl; var parms = new Dictionary <string, string>(); parms.Add("Document:", "Specifications Sheet"); parms.Add("Full Name:", ((System.Security.Claims.ClaimsIdentity)User.Identity).FindFirst("FullName").Value); parms.Add("UserName:"******"Company ID:", this.ActiveCustomer.CompanyId); parms.Add("Customer ID:", this.ActiveCustomer.CustomerId); parms.Add("Customer name:", this.ActiveCustomer.Name); if (type == "Item") { parms.Add("Machine item:", id); MailClient.SendEmailError( this.ActiveCustomer, "A MyRiwal user failed to download a document", parms, "These documents are stored in Dynarent under Inventory -> Items <br>" + "Please check that this document is available there for the mentioned machine item."); } else { parms.Add("Machine type:", id); MailClient.SendEmailError( this.ActiveCustomer, "A MyRiwal user failed to download a document", parms, "These documents are stored in Dynarent under Rental -> Rental stock product <br>" + "Please check that this document is available there for the mentioned machine type."); } return(View("DownlError")); } return(File(response.GetResponseStream(), System.Net.Mime.MediaTypeNames.Application.Pdf, id + ".pdf")); } }
public ActionResult InspectionSheet(string objectId, string item, string returnUrl) { if (ConfigurationManager.AppSettings["EnableBynder"] == "true") { byte[] file = BynderHelper.GetDocumentAsByteArray((string)Session["Culture"], objectId, "InspectionSheet"); if (file != null && file.Length > 0) { return(File(file, System.Net.Mime.MediaTypeNames.Application.Pdf, objectId + ".pdf")); } } else { MemoryStream downloadStream = null; // Create the path for the file string brand = item.Substring(0, 3); string model = item.Substring(4, item.Length - 4); string filePath = "RiwalOnline/" + brand + "/" + model + "/" + objectId + "/" + objectId + "_IS.pdf"; // Get the download stream for the file downloadStream = new Helpers.Google.API( Helpers.Google.API.SERVICE_ACCOUNT_EMAIL, Helpers.Google.API.KEY_FILE_PATH, Helpers.Google.API.SCOPES, Helpers.Google.API.G_SUITE_ADMIN_EMAIL, Helpers.Google.API.G_SUITE_DOMAIN ) .GetGoogleDriveFileStream(filePath); if (downloadStream != null && downloadStream.Length > 0) { return(File(downloadStream, System.Net.Mime.MediaTypeNames.Application.Pdf, objectId + ".pdf")); } } return(View("DownlError")); }