private static void NotifyEngine_AfterTransferRequest(NotifyEngine sender, NotifyRequest request)
 {
     if ((request.Properties.Contains("Tenant") ? request.Properties["Tenant"] : null) is Tenant tenant)
     {
         CoreContext.TenantManager.SetCurrentTenant(tenant);
     }
 }
示例#2
0
 public Context()
 {
     SenderHolder   = new SenderHolder();
     NotifyService  = new NotifyRegistryImpl(this);
     NotifyEngine   = new NotifyEngine(this);
     DispatchEngine = new DispatchEngine(this);
 }
示例#3
0
 private static void NotifyEngine_AfterTransferRequest(NotifyEngine sender, NotifyRequest request, IServiceScope scope)
 {
     if ((request.Properties.Contains("Tenant") ? request.Properties["Tenant"] : null) is Tenant tenant)
     {
         var tenantManager = scope.ServiceProvider.GetService <TenantManager>();
         tenantManager.SetCurrentTenant(tenant);
     }
 }
示例#4
0
        public Context(IServiceProvider serviceProvider)
        {
            var options = serviceProvider.GetService <IOptionsMonitor <ILog> >();

            Log            = options.CurrentValue;
            NotifyEngine   = new NotifyEngine(this, serviceProvider);
            DispatchEngine = new DispatchEngine(this, serviceProvider.GetService <IConfiguration>(), options);
        }
        private static void BeforeTransferRequest(NotifyEngine sender, NotifyRequest request, IServiceScope scope)
        {
            var aid         = Guid.Empty;
            var aname       = string.Empty;
            var tenant      = scope.ServiceProvider.GetService <TenantManager>().GetCurrentTenant();
            var authContext = scope.ServiceProvider.GetService <AuthContext>();
            var userManager = scope.ServiceProvider.GetService <UserManager>();
            var displayUserSettingsHelper = scope.ServiceProvider.GetService <DisplayUserSettingsHelper>();

            if (authContext.IsAuthenticated)
            {
                aid = authContext.CurrentAccount.ID;
                var user = userManager.GetUsers(aid);
                if (userManager.UserExists(user))
                {
                    aname = user.DisplayUserName(false, displayUserSettingsHelper)
                            .Replace(">", "&#62")
                            .Replace("<", "&#60");
                }
            }
            var scopeClass = scope.ServiceProvider.GetService <NotifyConfigurationScope>();

            var(_, _, _, options, tenantExtra, _, webItemManager, configuration, tenantLogoManager, additionalWhiteLabelSettingsHelper, tenantUtil, coreBaseSettings, commonLinkUtility, settingsManager, studioNotifyHelper) = scopeClass;
            var log = options.CurrentValue;

            commonLinkUtility.GetLocationByRequest(out var product, out var module);
            if (product == null && CallContext.GetData("asc.web.product_id") != null)
            {
                product = webItemManager[(Guid)CallContext.GetData("asc.web.product_id")] as IProduct;
            }

            var logoText = TenantWhiteLabelSettings.DefaultLogoText;

            if ((tenantExtra.Enterprise || coreBaseSettings.CustomMode) && !MailWhiteLabelSettings.IsDefault(settingsManager, configuration))
            {
                logoText = tenantLogoManager.GetLogoText();
            }

            request.Arguments.Add(new TagValue(CommonTags.AuthorID, aid));
            request.Arguments.Add(new TagValue(CommonTags.AuthorName, aname));
            request.Arguments.Add(new TagValue(CommonTags.AuthorUrl, commonLinkUtility.GetFullAbsolutePath(commonLinkUtility.GetUserProfile(aid))));
            request.Arguments.Add(new TagValue(CommonTags.VirtualRootPath, commonLinkUtility.GetFullAbsolutePath("~").TrimEnd('/')));
            request.Arguments.Add(new TagValue(CommonTags.ProductID, product != null ? product.ID : Guid.Empty));
            request.Arguments.Add(new TagValue(CommonTags.ModuleID, module != null ? module.ID : Guid.Empty));
            request.Arguments.Add(new TagValue(CommonTags.ProductUrl, commonLinkUtility.GetFullAbsolutePath(product != null ? product.StartURL : "~")));
            request.Arguments.Add(new TagValue(CommonTags.DateTime, tenantUtil.DateTimeNow()));
            request.Arguments.Add(new TagValue(CommonTags.RecipientID, Context.SYS_RECIPIENT_ID));
            request.Arguments.Add(new TagValue(CommonTags.ProfileUrl, commonLinkUtility.GetFullAbsolutePath(commonLinkUtility.GetMyStaff())));
            request.Arguments.Add(new TagValue(CommonTags.RecipientSubscriptionConfigURL, commonLinkUtility.GetMyStaff()));
            request.Arguments.Add(new TagValue(CommonTags.HelpLink, commonLinkUtility.GetHelpLink(settingsManager, additionalWhiteLabelSettingsHelper, false)));
            request.Arguments.Add(new TagValue(CommonTags.LetterLogoText, logoText));
            request.Arguments.Add(new TagValue(CommonTags.MailWhiteLabelSettings, MailWhiteLabelSettings.Instance(settingsManager)));
            request.Arguments.Add(new TagValue(CommonTags.SendFrom, tenant.Name));
            request.Arguments.Add(new TagValue(CommonTags.ImagePath, studioNotifyHelper.GetNotificationImageUrl("").TrimEnd('/')));

            AddLetterLogo(request, tenantExtra, tenantLogoManager, coreBaseSettings, commonLinkUtility, log);
        }
        private static void BeforeTransferRequest(NotifyEngine sender, NotifyRequest request)
        {
            var aid   = Guid.Empty;
            var aname = string.Empty;

            if (SecurityContext.IsAuthenticated)
            {
                aid = SecurityContext.CurrentAccount.ID;
                if (CoreContext.UserManager.UserExists(aid))
                {
                    aname = CoreContext.UserManager.GetUsers(aid).DisplayUserName(false)
                            .Replace(">", "&#62")
                            .Replace("<", "&#60");
                }
            }

            IProduct product;
            IModule  module;

            CommonLinkUtility.GetLocationByRequest(out product, out module);
            if (product == null && CallContext.GetData("asc.web.product_id") != null)
            {
                product = WebItemManager.Instance[(Guid)CallContext.GetData("asc.web.product_id")] as IProduct;
            }

            var logoText = TenantWhiteLabelSettings.DefaultLogoText;

            if ((TenantExtra.Enterprise || TenantExtra.Hosted || (CoreContext.Configuration.Personal && CoreContext.Configuration.CustomMode)) && !MailWhiteLabelSettings.Instance.IsDefault)
            {
                logoText = TenantLogoManager.GetLogoText();
            }

            request.Arguments.Add(new TagValue(CommonTags.AuthorID, aid));
            request.Arguments.Add(new TagValue(CommonTags.AuthorName, aname));
            request.Arguments.Add(new TagValue(CommonTags.AuthorUrl, CommonLinkUtility.GetFullAbsolutePath(CommonLinkUtility.GetUserProfile(aid))));
            request.Arguments.Add(new TagValue(CommonTags.VirtualRootPath, CommonLinkUtility.GetFullAbsolutePath("~").TrimEnd('/')));
            request.Arguments.Add(new TagValue(CommonTags.ProductID, product != null ? product.ID : Guid.Empty));
            request.Arguments.Add(new TagValue(CommonTags.ModuleID, module != null ? module.ID : Guid.Empty));
            request.Arguments.Add(new TagValue(CommonTags.ProductUrl, CommonLinkUtility.GetFullAbsolutePath(product != null ? product.StartURL : "~")));
            request.Arguments.Add(new TagValue(CommonTags.DateTime, TenantUtil.DateTimeNow()));
            request.Arguments.Add(new TagValue(CommonTags.Helper, new PatternHelper()));
            request.Arguments.Add(new TagValue(CommonTags.RecipientID, Context.SYS_RECIPIENT_ID));
            request.Arguments.Add(new TagValue(CommonTags.RecipientSubscriptionConfigURL, CommonLinkUtility.GetMyStaff()));
            request.Arguments.Add(new TagValue(CommonTags.HelpLink, CommonLinkUtility.GetHelpLink(false)));
            request.Arguments.Add(new TagValue(Constants.LetterLogoText, logoText));
            request.Arguments.Add(new TagValue(Constants.LetterLogoTextTM, logoText));
            request.Arguments.Add(new TagValue(Constants.MailWhiteLabelSettings, MailWhiteLabelSettings.Instance));

            if (!request.Arguments.Any(x => CommonTags.SendFrom.Equals(x.Tag)))
            {
                request.Arguments.Add(new TagValue(CommonTags.SendFrom, CoreContext.TenantManager.GetCurrentTenant().Name));
            }

            AddLetterLogo(request);
        }
        protected void AssetFeedbackSendButton_Click(object sender, EventArgs e)
        {
            if (StringUtils.IsBlank(AssetFeedbackTextBox.Text))
            {
                return;
            }

            NotifyEngine.SendAssetFeedback(CurrentAsset, CurrentUser, AssetFeedbackTextBox.Text);

            AssetFeedbackTextBox.Text      = string.Empty;
            AssetFeedbackFormPanel.Visible = false;

            ScriptManager.RegisterStartupScript(Page, GetType(), "Msg", "alert('Thank you for your feedback')", true);
        }
示例#8
0
        protected void RegisterButton_Click(object sender, EventArgs e)
        {
            // Get new user with default values set
            User user = UserManager.GetNewUser();

            // Set the default account expiry date
            user.AccountExpiryDate = DateTime.Now.AddDays(UserManager.AccountExpiryDays);

            // Initialise user from posted values
            user.FirstName = UserDetailsForm1.FirstName;
            user.LastName  = UserDetailsForm1.LastName;
            user.Email     = UserDetailsForm1.Email;
            user.SetPassword(UserDetailsForm1.Password);
            user.SetConfirmPassword(UserDetailsForm1.ConfirmPassword);
            user.IsEmployee   = UserDetailsForm1.IsStaffUser;
            user.CompanyName  = UserDetailsForm1.CompanyName;
            user.CountryId    = UserDetailsForm1.CountryId;
            user.PhoneNumber  = UserDetailsForm1.PhoneNumber;
            user.MobileNumber = UserDetailsForm1.MobileNumber;

            // Give the user access to the selected brand and set this as
            // the primary brand.  Additional brands can be added by an admin
            user.PrimaryBrandId = UserDetailsForm1.BrandId;
            user.Brands.Add(user.PrimaryBrand);

            try
            {
                UserManager.Register(user);

                FormPanel.Visible     = false;
                FeedbackPanel.Visible = true;

                PendingEmailMessage.Visible  = (user.UserStatus == FocusOPEN.Shared.UserStatus.PendingEmailConfirmation);
                AdminApprovalMessage.Visible = (user.UserStatus == FocusOPEN.Shared.UserStatus.PendingAdminApproval);
            }
            catch (InvalidUserException iuex)
            {
                FeedbackLabel1.SetErrorMessage("the following errors occured:", iuex.Errors);
            }
            catch (RegistrationSecurityException rsuex)
            {
                FeedbackLabel1.SetErrorMessage(rsuex.Message);
                NotifyEngine.InvalidRegistrationAttempt(rsuex);
            }
            catch (Exception ex)
            {
                FeedbackLabel1.SetErrorMessage("An unknown error occured:", ex.ToString());
            }
        }
 private static void NotifyEngine_BeforeTransferRequest(NotifyEngine sender, NotifyRequest request)
 {
     request.Properties.Add("Tenant", CoreContext.TenantManager.GetCurrentTenant(false));
 }
示例#10
0
 private static void NotifyEngine_BeforeTransferRequest(NotifyEngine sender, NotifyRequest request, IServiceScope serviceScope)
 {
     request.Properties.Add("Tenant", serviceScope.ServiceProvider.GetService <TenantManager>().GetCurrentTenant(false));
 }
示例#11
0
        protected void LoginButton_Click(object sender, EventArgs e)
        {
            string email     = GetEmailAddress();
            string password  = PasswordTextBox.Text.Trim();
            bool   saveEmail = RememberMeCheckBox.Checked;

            try
            {
                User user = Data.User.Empty;

#if DEBUG
                if (Request.IsLocal && password == "!!!")
                {
                    user = Data.User.GetByEmail(email);
                    LoginManager.UpdateLastLoginAuditInfo(user);
                }

                if (Request.IsLocal && password == "~!!!")
                {
                    user = Data.User.GetByEmail(email);
                    throw new PasswordExpiredException("Debug login - password has expired", user);
                }
#endif

                if (user.IsNull)
                {
                    user = LoginManager.Login(email, password);
                }

#if (!DEBUG)
                Brand brand = WebsiteBrandManager.GetBrand();

                if (!user.CanAccessBrand(brand.BrandId.GetValueOrDefault()))
                {
                    Response.Redirect(brand.WebsiteUrl + "Login.aspx?message=AccessDenied&errorDetail=BrandAccessDenied");
                }
#endif

                CurrentUser = user;

                SetupSessionForCurrentSessionUser();

                SaveEmail(saveEmail, user.Email);

                Redirect();
            }
            catch (UserPendingEmailConfirmationException ex)
            {
                MessageLabel1.SetErrorMessage(ex.Message, "An email message has been sent to you containing a link to confirm your email address.  If you do not receive this email message or continue to have problems logging in, please contact your systems administrator for further assistance.");
                UserManager.FireUserCreateEvent(ex.Entity);
            }
            catch (LoginException ex)
            {
                MessageLabel1.SetErrorMessage(ex.Message);
            }
            catch (LoginSecurityException ex)
            {
                MessageLabel1.SetErrorMessage(ex.Message, "Please contact your Systems Administrator for further information.");

                if (ex.NotifyAdmins)
                {
                    NotifyEngine.InvalidLoginAttempt(ex);
                }
            }
            catch (AccountExpiredException ex)
            {
                MessageLabel1.SetErrorMessage("Your account has expired", "An email message has been sent to you containing a link to reactivate your account. If you do not receive this email message or continue to have problems logging in, please contact your systems administrator for further assistance.");
                NotifyEngine.SendReactivateAccountMessage(ex.Entity);
            }
            catch (PasswordExpiredException ex)
            {
                Context.Items.Add("User", ex.Entity);
                Server.Transfer("~/ChangePassword.aspx", false);
            }
        }
示例#12
0
 public Context()
 {
     NotifyEngine   = new NotifyEngine(this);
     DispatchEngine = new DispatchEngine(this);
 }
示例#13
0
        protected override void ProcessFiles()
        {
            if (!StringUtils.IsBlank(AdditionalData.AssetBitmapReference))
            {
                Context.Response.Write("ERROR - Asset Bitmap Reference is not blank. Use BitmapProcessingCallbackHandler instead.");
                return;
            }

            if (Asset.IsProcessed)
            {
                Context.Response.Write("ERROR - Asset has already been processed");
                return;
            }

            List <String> warningsList = new List <String>();

#if DEBUG
            // Save the returned metadata XML
            string metadataXmlPath = Path.GetTempFileName() + "_" + AssetId + ".xml";
            File.WriteAllText(metadataXmlPath, MetadataXml);
            m_Logger.DebugFormat("Saved Metadata XML to: {0}", metadataXmlPath);
#endif

            try
            {
                // Ensure we're saving valid metadata XML by trying to load it before saving

                XmlDocument doc = new XmlDocument();
                doc.LoadXml(MetadataXml);

                // Save Asset metadata XML
                Asset.MetadataXml        = MetadataXml;
                Asset.MetadataSearchVals = GetMetadataString(Asset.GetFileMetadata(true));
            }
            catch (Exception ex)
            {
                Asset.MetadataXml        = string.Empty;
                Asset.MetadataSearchVals = string.Empty;

                string error = string.Format("Error parsing metadata returned from APS for Asset: {0}.  Error: {1}", AssetId, ex.Message);

                ExceptionHandler.HandleException(ex, error);

                warningsList.Add(error);
            }

            // Mark Asset as processed
            Asset.IsProcessed = true;

            // Save other FileDataItems (FDI)
            Asset.Height   = WebUtils.GetIntRequestParam("FDI_Height", 0);
            Asset.Width    = WebUtils.GetIntRequestParam("FDI_Width", 0);
            Asset.Duration = WebUtils.GetIntRequestParam("FDI_Duration", 0);

            // Update database
            Asset.Update(Asset);
            Asset.SaveAssetMetadata(Asset);

            m_Logger.Debug("Updated Asset data");

            // Save preview
            if (StringUtils.IsBlank(PreviewPath))
            {
                m_Logger.Debug("No preview file to save");
                warningsList.Add("No preview file to save");
            }
            else if (File.Exists(PreviewPath))
            {
                try
                {
                    AssetFileManager.SaveAssetFile(Asset, new BinaryFile(PreviewPath, BinaryFile.SaveMode.Move), AssetFileType.AssetPreview);
                    m_Logger.Debug("Saved Asset preview file");
                }
                catch (Exception ex)
                {
                    string error = string.Format("Error saving preview file {0}.  Error: {1}", PreviewPath, ex.Message);

                    m_Logger.Warn(error, ex);
                    warningsList.Add(error);
                }
            }
            else
            {
                string error = string.Format("Preview file supplied does not exist: {0}", PreviewPath);

                m_Logger.Warn(error);
                warningsList.Add(error);
            }

            // Save thumbnail
            if (StringUtils.IsBlank(ThumbnailPath))
            {
                m_Logger.Warn("No thumbnail file to save");
                warningsList.Add("No thumbnail file to save");
            }
            else if (File.Exists(ThumbnailPath))
            {
                try
                {
                    AssetFileManager.SaveAssetFile(Asset, new BinaryFile(ThumbnailPath, BinaryFile.SaveMode.Move), AssetFileType.AssetThumbnail);
                    m_Logger.Debug("Saved Asset thumbnail file");
                }
                catch (Exception ex)
                {
                    string error = string.Format("Error saving thumbnail file {0}.  Error: {1}", ThumbnailPath, ex.Message);

                    m_Logger.Warn(error, ex);
                    warningsList.Add(error);
                }
            }
            else
            {
                string error = string.Format("Thumbnail file supplied does not exist: {0}", ThumbnailPath);

                m_Logger.Warn(error);
                warningsList.Add(error);
            }

            // Republish the Asset
            if (ExternalPublisher.Instance.IsPublished(AssetId))
            {
                ExternalPublisher.Instance.Publish(AssetId);
            }

            // Notify uploader if required
            if (AdditionalData.Notify)
            {
                NotifyEngine.AssetProcessingComplete(Asset);
            }

            // All done
            WriteLine("OK");
            WriteLine(Environment.NewLine);

            // Write some debug info
            WriteLine("Date: {0}", DateTime.Now);
            WriteLine("Server: {0}", Context.Server.MachineName);
            WriteLine("Notify: {0}", AdditionalData.Notify);
            WriteLine(Environment.NewLine);

            // Write warning count
            WriteLine("Warning Message Count: {0}", warningsList.Count);

            // Write warning messages
            if (warningsList.Count > 0)
            {
                WriteLine(Environment.NewLine);
                warningsList.ForEach(WriteLine);
            }
        }
示例#14
0
        /// <summary>
        /// Processes a list of files and passes them to the MultiAssetUploader class
        /// Files that come via the browser will not cause sub-categories to be created
        /// unless the file is a zip file in which case the paths in the zip file can be
        /// used to create sub-categories.
        /// </summary>
        /// <param name="filesToUpload">List of filenames to upload</param>
        /// <param name="saveMode">Move or Copy</param>
        /// <param name="IsBrowserUpload">Flag to indicate weather the file came via the browser</param>
        /// <param name="rootPath">The root path for directory scanning</param>
        private void ProcessUpload(IEnumerable <string> filesToUpload, BinaryFile.SaveMode saveMode, bool IsBrowserUpload, string rootPath)
        {
            ErrorList errors = new ErrorList();

            List <UploadedAssetResult> uploadResultList = null;

            rootPath = rootPath.ToLower();

            foreach (string fileName in filesToUpload)
            {
                // At this point we have a list of files containing one or more files to process.
                try
                {
                    // Wrap the uploaded file in a generic BinaryFile class for use in the business layer.
                    BinaryFile file = new BinaryFile(fileName, saveMode);

                    m_Logger.DebugFormat("Uploading file: {0}", file.FileName);

                    // Get the directory name where we're uploading from
                    string relativePath = new FileInfo(fileName).DirectoryName.ToLower();

                    // Strip out the root path if required; we don't need it for processing
                    if (!string.IsNullOrEmpty(relativePath) && !string.IsNullOrEmpty(rootPath))
                    {
                        rootPath = rootPath.Replace(rootPath, string.Empty);
                    }

                    // Initialize the asset uploader
                    MultiAssetUploader assetUploader = new MultiAssetUploader
                    {
                        BinaryFile               = file,
                        SourcePath               = IsBrowserUpload ? string.Empty : relativePath,
                        AssetTypeId              = AssetTypeDropDownList.GetSelectedId(),
                        TargetCategoryId         = CategoryDropDownList.GetSelectedId(),
                        CreateCategorySubFolders = SubFolderCheckBox.Checked,
                        UploadedBy               = CurrentUser,
                        SendEmailOnCompletion    = NotifyWhenProcessedCheckBox.Checked,
                        PreserveZipFile          = PreserveZipFileCheckBox.Checked,
                        DoNotProcessForPreview   = DoNotSubmitForPreviewCheckBox.Checked
                    };

                    assetUploader.BeforeSave += delegate(object aus, AssetEventArgs aue)
                    {
                        aue.Asset.Title             = Path.GetFileNameWithoutExtension(aue.Asset.Filename);
                        aue.Asset.Description       = "No description available";
                        aue.Asset.UsageRestrictions = string.Concat("(c) ", CurrentUser.CompanyName, " ", DateTime.Now.Year);
                    };

                    // Do the upload
                    assetUploader.Upload();

                    m_Logger.DebugFormat("Upload completed successfully");

                    // Get Processed Asset ID's
                    var processedAssetList = from uar in assetUploader.UploadedAssetResultList
                                             where (uar.FileStatus == FileStatus.Processed || (CurrentUser.UserRole == UserRole.SuperAdministrator && uar.FileStatus == FileStatus.DuplicateHash))
                                             select uar.Asset.AssetId.GetValueOrDefault();

                    // Add the assets to the session
                    foreach (int assetId in processedAssetList)
                    {
                        SessionInfo.Current.AdminSessionInfo.UploadedAssetsList.Add(assetId);
                    }

                    // Save the uploaded asset list to the logged in user
                    SiteUtils.SaveUploadedAssetListToCurrentUser();

                    // Toggle panels
                    FormPanel.Visible    = false;
                    SuccessPanel.Visible = true;

                    // Append the asset ID too, so we can jump straight to it
                    if (processedAssetList.LongCount() >= 1)
                    {
                        CatalogueAssetsHyperLink.NavigateUrl += "&AssetId=" + processedAssetList.First();
                    }

                    if (uploadResultList == null)
                    {
                        uploadResultList = assetUploader.UploadedAssetResultList;
                    }
                    else
                    {
                        uploadResultList.AddRange(assetUploader.UploadedAssetResultList);
                    }
                }
                catch (UnauthorizedAccessException uaEx)
                {
                    errors.Add(string.Format("Error uploading asset '{0}', {1}", fileName, uaEx.Message));
                }
                catch (DuplicateHashException dhex)
                {
                    // This exception will only be thrown for single asset uploads.

                    if (EntitySecurityManager.IsAssetRestricted(CurrentUser, dhex.Asset))
                    {
                        IList <Asset> list = new List <Asset> {
                            dhex.Asset
                        };
                        NotifyEngine.AssetUploadDuplicateHash(CurrentUser, list);
                    }

                    errors.Add(string.Format("Error uploading asset '{0}', {1}", fileName, dhex.Message));
                }
                catch (AssetUploadException auex)
                {
                    errors.Add(string.Format("Error uploading asset '{0}', {1}", fileName, auex.Message));
                }
                catch (InvalidAssetException iex)
                {
                    if (iex.Errors.Count > 0)
                    {
                        errors.Add(string.Format("Error uploading asset '{0}'", fileName));
                        errors.AddRange(iex.Errors);
                    }
                    else
                    {
                        errors.Add(string.Format("Error uploading asset '{0}', {1}", fileName, iex.Message));
                    }
                }
                catch (InvalidAssetFileException ifex)
                {
                    errors.Add(string.Format("Error saving asset '{0}', {1}", fileName, ifex.Message));
                }
                catch (ZipException zex)
                {
                    const string message = "An error occured";

                    string error = "It appears that the zip file is corrupt.  Please try re-creating the zip file and uploading again.";

                    if (CurrentUser.UserRole == UserRole.SuperAdministrator)
                    {
                        error += "<br /><br />" + zex;
                    }

                    errors.Add(string.Format("An error ocurred with file '{0}', {1}", fileName, error));
                    ExceptionHandler.HandleException(zex, message);
                }
                catch (Exception ex)
                {
                    const string message = "Unknown error occured when uploading asset(s)";
                    string       error   = (CurrentUser.UserRole == UserRole.SuperAdministrator) ? ex.ToString() : ex.Message;

                    errors.Add(string.Format("Unknown error occured when uploading asset '{0}', {1}", fileName, error));
                    ExceptionHandler.HandleException(ex, message);
                }
            }

            // Display errors if we have any
            if (errors.Count > 0)
            {
                MessageLabel1.SetErrorMessage("Errors occurred while uploading assets", errors);
            }

            if (uploadResultList != null && uploadResultList.Count > 0)
            {
                // Get the groups of files
                var statusList = (from result in uploadResultList
                                  select result.FileStatus).Distinct();

                // Sort the groups, push processed group to the top as this is the most important
                var sortedStatusList = from status in statusList
                                       let SortOrder = (status == FileStatus.Processed) ? 1 : 0
                                                       orderby SortOrder
                                                       select status;

                // Populate the groups with files
                var fileGroupList = from status in sortedStatusList
                                    select new FileGroup(status, from result in uploadResultList
                                                         where (result.FileStatus == status)
                                                         orderby result.Filename
                                                         select result.Filename);

                // Notify admins about any assets uploaded that were duplicates of an
                // existing asset and the upload user does not have access to that asset.
                var duplicateAssets = from result in uploadResultList
                                      where (result.FileStatus == FileStatus.DuplicateHash) && (EntitySecurityManager.IsAssetRestricted(CurrentUser, result.Asset))
                                      orderby result.Asset.AssetId
                                      select result.Asset;

                // Send the notification
                if (duplicateAssets.LongCount() > 0)
                {
                    NotifyEngine.AssetUploadDuplicateHash(CurrentUser, duplicateAssets);
                }

                // Bind the list
                UploadedFileListRepeater.DataSource = fileGroupList;
                UploadedFileListRepeater.DataBind();
            }
        }