Example #1
0
        public FileUploadResult ProcessUpload(HttpContext context)
        {
            var result = new FileUploadResult();

            try
            {
                if (!SecurityContext.IsAuthenticated && SettingsManager.Instance.LoadSettings <WizardSettings>(TenantProvider.CurrentTenantID).Completed)
                {
                    throw new SecurityException(Resource.PortalSecurity);
                }
                if (context.Request.Files.Count == 0)
                {
                    throw new Exception(Resource.ErrorEmptyUploadFileSelected);
                }

                var licenseFile = context.Request.Files[0];
                LicenseReader.SaveLicenseTemp(licenseFile.InputStream);

                result.Message = Resource.LicenseUploaded;
                result.Success = true;
            }
            catch (Exception ex)
            {
                LogManager.GetLogger(typeof(LicenseReader)).Error("License upload", ex);
                result.Message = ex.Message.HtmlEncode();
            }

            return(result);
        }
        public FileUploadResult ProcessUpload(HttpContext context)
        {
            var result = new FileUploadResult();

            try
            {
                if (!SecurityContext.IsAuthenticated && WizardSettings.Load().Completed)
                {
                    throw new SecurityException(Resource.PortalSecurity);
                }
                if (context.Request.Files.Count == 0)
                {
                    throw new Exception(Resource.ErrorEmptyUploadFileSelected);
                }

                var licenseFile = context.Request.Files[0];
                var dueDate     = LicenseReader.SaveLicenseTemp(licenseFile.InputStream);

                result.Message = dueDate >= DateTime.UtcNow.Date
                                     ? Resource.LicenseUploaded
                                     : string.Format(
                    (TenantExtra.GetTenantQuota().Update
                                              ? Resource.LicenseUploadedOverdueSupport
                                              : Resource.LicenseUploadedOverdue),
                    "<span class='tariff-marked'>",
                    "</span>",
                    dueDate.Date.ToLongDateString());
                result.Success = true;
            }
            catch (LicenseExpiredException ex)
            {
                Log.Error("License upload", ex);
                result.Message = Resource.LicenseErrorExpired;
            }
            catch (LicenseQuotaException ex)
            {
                Log.Error("License upload", ex);
                result.Message = Resource.LicenseErrorQuota;
            }
            catch (LicensePortalException ex)
            {
                Log.Error("License upload", ex);
                result.Message = Resource.LicenseErrorPortal;
            }
            catch (Exception ex)
            {
                Log.Error("License upload", ex);
                result.Message = Resource.LicenseError;
            }

            return(result);
        }
Example #3
0
        public FileUploadResult UploadLicense(IEnumerable <HttpPostedFileBase> attachments)
        {
            if (!CoreContext.Configuration.Standalone)
            {
                throw new NotSupportedException();
            }

            var license = attachments.FirstOrDefault();

            if (license == null)
            {
                throw new Exception(Resource.ErrorEmptyUploadFileSelected);
            }

            var result = new FileUploadResult();

            try
            {
                var dueDate = LicenseReader.SaveLicenseTemp(license.InputStream);

                result.Message = dueDate >= DateTime.UtcNow.Date
                                         ? Resource.LicenseUploaded
                                         : string.Format(Resource.LicenseUploadedOverdue,
                                                         string.Empty,
                                                         string.Empty,
                                                         dueDate.Date.ToLongDateString());
                result.Success = true;
            }
            catch (LicenseExpiredException ex)
            {
                LogManager.GetLogger("ASC").Error("License upload", ex);
                result.Message = Resource.LicenseErrorExpired;
            }
            catch (LicenseQuotaException ex)
            {
                LogManager.GetLogger("ASC").Error("License upload", ex);
                result.Message = Resource.LicenseErrorQuota;
            }
            catch (LicensePortalException ex)
            {
                LogManager.GetLogger("ASC").Error("License upload", ex);
                result.Message = Resource.LicenseErrorPortal;
            }
            catch (Exception ex)
            {
                LogManager.GetLogger("ASC").Error("License upload", ex);
                result.Message = Resource.LicenseError;
            }

            return(result);
        }
Example #4
0
        public FileUploadResult ProcessUpload(HttpContext context)
        {
            var result = new FileUploadResult();

            try
            {
                if (!SecurityContext.IsAuthenticated && WizardSettings.Load().Completed)
                {
                    throw new SecurityException(Resource.PortalSecurity);
                }
                if (context.Request.Files.Count == 0)
                {
                    throw new Exception(Resource.ErrorEmptyUploadFileSelected);
                }

                var licenseFile = context.Request.Files[0];
                LicenseReader.SaveLicenseTemp(licenseFile.InputStream);

                result.Message = Resource.LicenseUploaded;
                result.Success = true;
            }
            catch (LicenseExpiredException ex)
            {
                LogManager.GetLogger(typeof(LicenseReader)).Error("License upload", ex);
                result.Message = Resource.LicenseErrorExpired;
            }
            catch (LicenseQuotaException ex)
            {
                LogManager.GetLogger(typeof(LicenseReader)).Error("License upload", ex);
                result.Message = Resource.LicenseErrorQuota;
            }
            catch (LicensePortalException ex)
            {
                LogManager.GetLogger(typeof(LicenseReader)).Error("License upload", ex);
                result.Message = Resource.LicenseErrorPortal;
            }
            catch (Exception ex)
            {
                LogManager.GetLogger(typeof(LicenseReader)).Error("License upload", ex);
                result.Message = Resource.LicenseError;
            }

            return(result);
        }