Ejemplo n.º 1
0
        public virtual ActionResult Download(string filePath)
        {
            string     extension = System.IO.Path.GetExtension(filePath);
            ZFileTypes fileType  = LibraryHelper.GetFileType(extension);

            return(File(filePath, LibraryHelper.GetContentType(fileType), Path.GetFileName(filePath)));
        }
Ejemplo n.º 2
0
        public ActionResult RDLExport(string exportFormat, string reportDirectory, string reportName)
        {
            OperationResultModel viewModel = new OperationResultModel();

            string exportPath = Path.Combine(Server.MapPath(ConfigurationHelper.AppSettings <string>("EasyLOB.Directory.Export")),
                                             reportName + String.Format(".{0:yyyyMMdd.HHmmss.fff}", DateTime.Now));

            IDictionary <string, string> reportParameters = new Dictionary <string, string>();

            if (System.Web.HttpContext.Current.Request.QueryString.Count > 3)
            {
                for (int q = 3; q < System.Web.HttpContext.Current.Request.QueryString.Count; q++)
                {
                    reportParameters.Add(System.Web.HttpContext.Current.Request.QueryString.AllKeys[q],
                                         System.Web.HttpContext.Current.Request.QueryString[q]);
                }
            }

            if (SyncfusionHelper.ExportRDL(viewModel.OperationResult, ref exportPath, exportFormat,
                                           reportDirectory, reportName, reportParameters))
            {
                byte[] file = System.IO.File.ReadAllBytes(exportPath);
                return(File(file,
                            LibraryHelper.GetContentType(LibraryHelper.GetFileType(Path.GetExtension(exportPath))),
                            Path.GetFileName(exportPath)));
            }

            return(ZViewOperationResult(viewModel.OperationResult));
        }
Ejemplo n.º 3
0
        public ActionResult Read(string entityName, int id, string acronym)
        {
            ZFileTypes fileType = LibraryHelper.GetFileType(acronym);

            byte[] file      = EDMManager.ReadFile(entityName, id, fileType);
            string extension = LibraryHelper.GetFileExtension(fileType);

            return(File(file, LibraryHelper.GetContentType(fileType), entityName + "-" + id.ToString().Trim() + extension));
        }
Ejemplo n.º 4
0
        public ActionResult Read(string entityName, int id, string acronym)
        {
            IEdmManager edmManager = DependencyResolver.Current.GetService <IEdmManager>();
            ZFileTypes  fileType   = LibraryHelper.GetFileType(acronym);

            byte[] file      = edmManager.ReadFile(entityName, id, fileType);
            string extension = LibraryHelper.GetFileExtension(fileType);

            return(File(file, LibraryHelper.GetContentType(fileType), entityName + "-" + id.ToString().Trim() + extension));
        }
        public ActionResult Delete(CustomerDocumentItemModel customerDocumentItemModel) // !!!
        {
            try
            {
                int        customerDocumentId = customerDocumentItemModel.CustomerDocument.CustomerDocumentId;
                ZFileTypes fileType           = LibraryHelper.GetFileType(customerDocumentItemModel.CustomerDocument.FileAcronym);

                if (Application.Delete(customerDocumentItemModel.OperationResult, (CustomerDocumentDTO)customerDocumentItemModel.CustomerDocument.ToDTO()))
                {
                    IEdmManager edmManager = DependencyResolver.Current.GetService <IEdmManager>();
                    edmManager.DeleteFile("CustomerDocument", customerDocumentId, fileType);

                    return(RedirectToUrlDictionary());
                }
            }
            catch (Exception exception)
            {
                customerDocumentItemModel.OperationResult.ParseException(exception);
            }

            customerDocumentItemModel.IsSecurityOperations = IsSecurityOperations;

            return(View(customerDocumentItemModel));
        }
        public ActionResult Create(CustomerDocumentItemModel customerDocumentItemModel) // !!!
        {
            try
            {
                if (ValidateModelState(Application.Repository))
                {
                    if (customerDocumentItemModel.Upload != null && customerDocumentItemModel.Upload.ContentLength > 0)
                    {
                        ZFileTypes fileType = LibraryHelper.GetFileType(Path.GetExtension(customerDocumentItemModel.Upload.FileName));
                        string     acronym  = LibraryHelper.GetAcronym(fileType);
                        customerDocumentItemModel.CustomerDocument.FileAcronym = acronym;

                        CustomerDocumentDTO customerDocumentDTO = (CustomerDocumentDTO)customerDocumentItemModel.CustomerDocument.ToDTO();

                        if (Application.Create(customerDocumentItemModel.OperationResult, customerDocumentDTO))
                        {
                            byte[] uploadArray = new byte[customerDocumentItemModel.Upload.ContentLength];
                            customerDocumentItemModel.Upload.InputStream.Read(uploadArray, 0, uploadArray.Length);

                            IEdmManager edmManager = DependencyResolver.Current.GetService <IEdmManager>();
                            edmManager.WriteFile("CustomerDocument", customerDocumentDTO.CustomerDocumentId, fileType, uploadArray);

                            return(RedirectToUrlDictionary());
                        }
                    }
                }
            }
            catch (Exception exception)
            {
                customerDocumentItemModel.OperationResult.ParseException(exception);
            }

            customerDocumentItemModel.IsSecurityOperations = IsSecurityOperations;

            return(View(customerDocumentItemModel));
        }