Esempio n. 1
0
        public ActionResult CECertificate(string objectId, string item, string returnUrl)
        {
            // Get the stock item for the given item code
            Dictionary <string, string> stockItem = ROLWeb.Helpers.InspHire.API.Get <Dictionary <string, string> >("stock/" + item, null);
            MemoryStream downloadStream           = null;

            if (stockItem != null && stockItem.Count > 0)
            {
                // Create the path for the file
                string itemGroupCode   = stockItem["GRPCODE"];
                string itemVendorName  = itemGroupCode.Substring(0, itemGroupCode.IndexOf("-"));
                string itemMachineType = itemGroupCode.Substring(itemGroupCode.IndexOf("-") + 1);
                string filePath        = "RiwalOnline/" + itemVendorName + "/" + itemMachineType + "/" + objectId + "/" + objectId + ".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 a download stream for the file wasn't found then send an error email
            if (downloadStream == null || downloadStream.Length == 0)
            {
                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:", "CE Certificate");
                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);
                parms.Add("Machine Item:", item);
                parms.Add("Machine Serial number:", objectId);

                MailClient.SendEmailError(
                    this.ActiveCustomer,
                    "A MyRiwal user failed to download a document",
                    parms,
                    "");

                return(View("DownlError"));
            }

            return(File(downloadStream, System.Net.Mime.MediaTypeNames.Application.Pdf, objectId + "_CE.pdf"));
        }
Esempio n. 2
0
        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"));
        }
Esempio n. 3
0
        //[OutputCache(Duration = 60 * 60 * 24, VaryByParam = "RentalStockId")]
        public ActionResult OperatingManual(string RentalStockId, string returnUrl)
        {
            //TODO With AX - Ensure this works when not using InspHire
            string language = "";

            string culture = (string)Session["Culture"];

            switch (culture)
            {
            case "nl-NL":
                language = "NL";
                break;

            case "en-GB":
                language = "EN";
                break;

            case "da-DK":
                language = "DK";
                break;

            case "es-ES":
                language = "ES";
                break;

            case "fr-FR":
                language = "FR";
                break;

            case "pl-PL":
                language = "PL";
                break;

            default:
                language = "EN";
                break;
            }

            MemoryStream downloadStream = null;

            if (RentalStockId != null && RentalStockId.Length > 0 && RentalStockId.Contains("-"))
            {
                // Create the path for the file
                string itemSerialNumber = RentalStockId;
                string itemVendorName   = itemSerialNumber.Substring(0, itemSerialNumber.IndexOf("-"));
                string itemMachineType  = itemSerialNumber.Substring(itemSerialNumber.IndexOf("-") + 1);
                string filePath         = "RiwalOnline/" + itemVendorName + "/" + itemMachineType + "/" + itemVendorName + "_" + itemMachineType + "_OM_" + language + ".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 no download stream for the file was found then send an error email
            if (downloadStream == null || downloadStream.Length == 0)
            {
                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:", "Operating Manual");
                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);
                parms.Add("Machine type:", RentalStockId);

                MailClient.SendEmailError(
                    this.ActiveCustomer,
                    "A MyRiwal user failed to download a document",
                    parms,
                    "");
                return(View("DownlError"));
            }
            else
            {
                return(File(downloadStream, System.Net.Mime.MediaTypeNames.Application.Pdf, RentalStockId + ".pdf"));
            }
        }