Beispiel #1
0
        private void UpdateMetadata(int metadataId)
        {
            try
            {
                string name      = NameTextBox.Text;
                string reference = ExternalRefTextBox.Text;
                string synonyms  = SynonymsTextBox.Text;

                MetadataManager.Update(metadataId, name, reference, synonyms, CurrentUser);
                MessageLabel1.SetSuccessMessage("Metadata updated successfully");
            }
            catch (BaseEntityException <Metadata> ex)
            {
                if (ex.Errors.Count > 0)
                {
                    MessageLabel1.SetErrorMessage("Unable to update metadata; The following errors occured:", ex.Errors);
                }
                else
                {
                    MessageLabel1.SetErrorMessage(ex.Message);
                }
            }
            catch (Exception ex)
            {
                m_Logger.Fatal(string.Format("Error editing metadata with id: {0}", metadataId), ex);
                MessageLabel1.SetErrorMessage("An unhandled error occured", ex.ToString());
            }
        }
Beispiel #2
0
        protected void AssetFilePathsDataGrid_OnItemCommand(object source, DataGridCommandEventArgs e)
        {
            if (e.CommandName == "add")
            {
                try
                {
                    TextBox NewFilePathTextBox = (TextBox)e.Item.FindControl("NewFilePathTextBox");
                    string  path = NewFilePathTextBox.Text;

                    AssetFilePathManager.CreateNew(path);
                    AuditLogManager.LogUserAction(CurrentUser, AuditUserAction.AddFilepath, string.Format("Added file path: {0}", path));

                    MessageLabel1.SetSuccessMessage("Asset file path added successfully");

                    BindList();
                }
                catch (InvalidAssetFilePathException iafpex)
                {
                    ErrorList errors = iafpex.Errors;

                    if (errors.Count == 1)
                    {
                        MessageLabel1.SetErrorMessage(errors[0].ToString());
                    }
                    else
                    {
                        MessageLabel1.SetErrorMessage("Unable to add new file path", errors);
                    }
                }
            }
        }
Beispiel #3
0
        protected void UpdateAccountExpiryDateLinkButton_Click(object sender, EventArgs e)
        {
            // Get the user
            int  userId = GetRequiredQueryStringParameter("UserId", "UserList.aspx");
            User user   = Data.User.Get(userId);

            // Get the expiry date
            DateTime expiryDate = user.GetAccountExpiryDate();

            // Update it, if the user has an expiry date (ie. is non expiring)
            if (expiryDate < DateTime.MaxValue)
            {
                DateTime dt            = (expiryDate < DateTime.Now) ? DateTime.Now : expiryDate;
                DateTime newExpiryDate = dt.AddDays(UserManager.AccountExpiryDays);

                // Also approve user
                user.UserStatus = UserStatus.Approved;

                // Update user
                user.AccountExpiryDate = newExpiryDate;
                Data.User.Update(user);

                // Update UI
                DisplayUserAccountExpiryDate(user);
                MessageLabel1.SetSuccessMessage(string.Format("account expiry date updated to: {0}", newExpiryDate.ToString(Global.DateTimeFormat)));

                // Update audit log
                AuditLogManager.LogUserAction(CurrentUser, AuditUserAction.ModifyUser, string.Format("Updated {0}'s (Userid: {1}) account expiry date to: {2}", user.FullName, user.UserId, newExpiryDate.ToString("dd MMM yyyy HH:mm")));
            }
            else
            {
                MessageLabel1.SetErrorMessage("account never expires, expiry date not updated");
            }
        }
Beispiel #4
0
        protected void PreviewButton_Click(object sender, EventArgs e)
        {
            // Get the homepage being edited
            Homepage homepage = Homepage.Get(HomepageId);

            // Create a copy if the homepage is published
            if (homepage.IsPublished)
            {
                homepage = HomepageManager.GetCopy(homepage);
            }

            // List of images
            IList <BinaryFile> imageList = new List <BinaryFile>();

            // Get the homepage and images
            GetHomepageAndImages(ref homepage, ref imageList);

            try
            {
                HomepageManager.PreviewHomepage(CurrentUser, homepage, imageList);
                MessageLabel1.SetSuccessMessage("Homepage preview created successfully.");
                DisplayHomepage(homepage);

                string script = "window.open('" + ResolveUrl("~/Default.aspx?HideBumper=1&PreviewHomepageId=") + homepage.HomepageId + "', 'HomepagePreview');";
                Page.ClientScript.RegisterStartupScript(GetType(), "PreviewHomepageScript", script, true);
            }
            catch (InvalidHomepageException ihex)
            {
                MessageLabel1.SetErrorMessage("the following errors occured:", ihex.Errors);
            }
        }
        protected override void Grid_ItemCommand(object source, DataGridCommandEventArgs e)
        {
            if (e.CommandName == "add")
            {
                TextBox           NameTextBox        = (TextBox)e.Item.FindControl("NewNameTextBox");
                BrandCheckBoxList BrandsCheckBoxList = (BrandCheckBoxList)e.Item.FindControl("NewBrandsCheckBoxList");
                TextBox           DomainTextBox      = (TextBox)e.Item.FindControl("NewDomainTextBox");
                CheckBox          InternalCheckBox   = (CheckBox)e.Item.FindControl("NewInternalCheckBox");

                try
                {
                    Company company = Company.New();

                    company.Name            = NameTextBox.Text;
                    company.Domain          = DomainTextBox.Text;
                    company.IsInternal      = InternalCheckBox.Checked;
                    company.CreateDate      = DateTime.Now;
                    company.CreatedByUserId = CurrentUser.UserId.GetValueOrDefault();

                    AddBrandsToCompany(company, BrandsCheckBoxList);

                    CompanyManager.SaveCompany(company);

                    AuditLogManager.LogUserAction(CurrentUser, AuditUserAction.AddCompany, string.Format("Added Approved Company: {0}, CompanyId: {1}", company.Name, company.CompanyId));

                    ResetGridState();
                    MessageLabel1.SetSuccessMessage("Company added successfully");
                }
                catch (InvalidCompanyException iacex)
                {
                    MessageLabel1.SetErrorMessage("Unable to add company", iacex.Errors);
                }
            }
        }
        protected override void Grid_UpdateCommand(object source, DataGridCommandEventArgs e)
        {
            int               id                 = Convert.ToInt32(e.CommandArgument);
            TextBox           NameTextBox        = (TextBox)e.Item.FindControl("NameTextBox");
            BrandCheckBoxList BrandsCheckBoxList = (BrandCheckBoxList)e.Item.FindControl("BrandsCheckBoxList");
            TextBox           DomainTextBox      = (TextBox)e.Item.FindControl("DomainTextBox");
            CheckBox          InternalCheckBox   = (CheckBox)e.Item.FindControl("InternalCheckBox");

            try
            {
                Company company = Company.Get(id);

                company.Name       = NameTextBox.Text;
                company.Domain     = DomainTextBox.Text;
                company.IsInternal = InternalCheckBox.Checked;

                AddBrandsToCompany(company, BrandsCheckBoxList);

                CompanyManager.SaveCompany(company);

                AuditLogManager.LogUserAction(CurrentUser, AuditUserAction.ModifyCompany, string.Format("Modified Approved Company: {0}, CompanyId: {1}", company.Name, company.CompanyId));

                ResetGridState();
                MessageLabel1.SetSuccessMessage("Company updated successfully");
            }
            catch (InvalidCompanyException iacex)
            {
                MessageLabel1.SetErrorMessage("Unable to save company", iacex.Message);
            }
        }
Beispiel #7
0
        protected void PublishButton_Click(object sender, EventArgs e)
        {
            // Get the homepage being edited
            Homepage homepage = Homepage.Get(HomepageId);

            // If the homepage being edited is not for the brand being edited
            // then create a copy of it, which will become the brand homepage.
            if (homepage.BrandId != EditingBrandId)
            {
                homepage = HomepageManager.GetCopy(homepage);
            }

            // List of images
            IList <BinaryFile> imageList = new List <BinaryFile>();

            // Get the homepage and images
            GetHomepageAndImages(ref homepage, ref imageList);

            try
            {
                HomepageManager.PublishHomepage(CurrentUser, homepage, imageList);
                MessageLabel1.SetSuccessMessage("Homepage published successfully");
                DisplayHomepage(homepage);
            }
            catch (InvalidHomepageException ihex)
            {
                MessageLabel1.SetErrorMessage("the following errors occured:", ihex.Errors);
            }
        }
        protected override void Grid_ItemCommand(object source, DataGridCommandEventArgs e)
        {
            if (e.CommandName == "add")
            {
                TextBox  NewNameTextBox       = (TextBox)e.Item.FindControl("NewNameTextBox");
                CheckBox NewIsVisibleCheckBox = (CheckBox)e.Item.FindControl("NewIsVisibleCheckBox");

                try
                {
                    AssetType assetType = AssetType.New();
                    assetType.Name      = NewNameTextBox.Text.Trim();
                    assetType.IsVisible = NewIsVisibleCheckBox.Checked;
                    AssetTypeManager.SaveAssetType(assetType);

                    AuditLogManager.LogUserAction(CurrentUser, AuditUserAction.AddAssetType, string.Format("Added Asset Type: {0}, AssetTypeId: {1}", assetType.Name, assetType.AssetTypeId));

                    ResetGridState();
                    MessageLabel1.SetSuccessMessage("Asset type added successfully");
                }
                catch (InvalidAssetTypeException imtex)
                {
                    MessageLabel1.SetErrorMessage("Unable to add asset type", imtex.Errors);
                    BindGrid(CurrentPage);
                }
            }
        }
Beispiel #9
0
        private void CreateMetadata(int parentId)
        {
            try
            {
                string name      = NameTextBox.Text;
                string reference = ExternalRefTextBox.Text;
                string synonyms  = SynonymsTextBox.Text;

                Metadata o = MetadataManager.Add(name, parentId, BrandId, GroupNumber, reference, synonyms, CurrentUser);

                MetadataIdTextBox.Value = o.MetadataId.ToString();
                MessageLabel1.SetSuccessMessage("metadata created successfully");
            }
            catch (BaseEntityException <Metadata> ex)
            {
                if (ex.Errors.Count > 0)
                {
                    MessageLabel1.SetErrorMessage("Unable to create metadata; The following errors occured:", ex.Errors);
                }
                else
                {
                    MessageLabel1.SetErrorMessage(ex.Message);
                }
            }
            catch (Exception ex)
            {
                m_Logger.Fatal(string.Format("Error creating metadata with parent id: {0}", parentId), ex);
                MessageLabel1.SetErrorMessage("An unhandled error occured", ex.ToString());
            }
        }
Beispiel #10
0
        protected void UpdateDefaultButton_Click(object sender, EventArgs e)
        {
            foreach (DataGridItem dgi in AssetFilePathsDataGrid.Items)
            {
                HiddenField AssetFilePathIdHiddenField = (HiddenField)dgi.FindControl("AssetFilePathIdHiddenField");
                RadioButton IsDefaultRadioButton       = (RadioButton)dgi.FindControl("IsDefaultRadioButton");

                if (IsDefaultRadioButton.Checked)
                {
                    int assetFilePathId = NumericUtils.ParseInt32(AssetFilePathIdHiddenField.Value, 0);

                    try
                    {
                        AssetFilePathManager.SetDefault(assetFilePathId);
                        AuditLogManager.LogUserAction(CurrentUser, AuditUserAction.ChangeDefaultFilepath, string.Format("Changed default file path to AssetFilePathId: {0}", assetFilePathId));

                        MessageLabel1.SetSuccessMessage("Default asset file path updated successfully");
                    }
                    catch (InvalidAssetFilePathException ifpx)
                    {
                        MessageLabel1.SetErrorMessage("Unable to change default path", ifpx.Errors);
                    }

                    break;
                }
            }
        }
        protected override void Grid_DeleteCommand(object source, DataGridCommandEventArgs e)
        {
            int id = Convert.ToInt32(e.CommandArgument);

            IpAddress.Delete(id);
            AuditLogManager.LogUserAction(CurrentUser, AuditUserAction.DeleteIpAddress, string.Format("Deleted Ip Address with IpAddressId: {0}", id));

            BindGrid(CurrentPage);
            MessageLabel1.SetSuccessMessage("IP Address deleted successfully");
        }
        protected void WorkflowDeleteLinkButton_Command(object sender, CommandEventArgs e)
        {
            int worfkflowId = Convert.ToInt32(e.CommandArgument);

            Workflow workflow = Workflow.Get(worfkflowId);

            workflow.IsDeleted = true;
            Workflow.Update(workflow);

            PerformSearchAndBindGrid(CurrentPage);
            MessageLabel1.SetSuccessMessage("Workflow deleted successfully");
        }
Beispiel #13
0
 protected void PasswordReminderButton_Click(object sender, EventArgs e)
 {
     try
     {
         UserManager.ResetPasswordAndSend(GetEmailAddress());
         MessageLabel1.SetSuccessMessage("A new password has been emailed to you.");
     }
     catch (InvalidUserException iuex)
     {
         MessageLabel1.SetErrorMessage(iuex.Message);
     }
 }
        protected void CreateWorkflowFromBrandButton_Click(object sender, EventArgs e)
        {
            if (BrandDropDownList.SelectedId <= 0)
            {
                MessageLabel1.SetErrorMessage("Please select a brand");
                return;
            }

            int   brandId = BrandDropDownList.SelectedId;
            Brand brand   = Brand.Get(brandId);

            if (brand.IsNull)
            {
                MessageLabel1.SetErrorMessage("Invalid brand");
                return;
            }

            // Remove old items
            SelectedUsersListBox.Items.Clear();

            // New workflow will have same name as brand
            WorkflowNameTextBox.Text = brand.Name;

            // First get superadmin
            User firstSuperAdmin = GetFirstUser(UserRole.SuperAdministrator, 0);

            // first BU Admin
            User firstBrandAdmin = GetFirstUser(UserRole.BrandAdministrator, brandId);

            // Add super admin to listbox
            if (!firstSuperAdmin.IsNull)
            {
                AddUserToListBox(firstSuperAdmin, SelectedUsersListBox);
            }

            // Add BU Admin to listbox
            if (!firstBrandAdmin.IsNull)
            {
                AddUserToListBox(firstBrandAdmin, SelectedUsersListBox);
            }

            // Deselect the brand
            BrandDropDownList.SelectedIndex = -1;

            // Show feedback
            MessageLabel1.SetSuccessMessage("Default workflow created for brand.  Add or remove users, or press 'Save' to finish.");
        }
        protected override void Grid_DeleteCommand(object source, DataGridCommandEventArgs e)
        {
            int id = Convert.ToInt32(e.CommandArgument);

            try
            {
                CompanyManager.DeleteCompany(id);

                AuditLogManager.LogUserAction(CurrentUser, AuditUserAction.DeleteCompany, string.Format("Deleted Company with CompanyId: {0}", id));
                MessageLabel1.SetSuccessMessage("Company deleted successfully");

                BindGrid(CurrentPage);
            }
            catch (Exception ex)
            {
                MessageLabel1.SetErrorMessage("Error deleting company: " + ex.Message);
            }
        }
        protected override void Grid_DeleteCommand(object source, DataGridCommandEventArgs e)
        {
            try
            {
                int       assetTypeId = Convert.ToInt32(e.CommandArgument);
                AssetType assetType   = AssetTypeCache.Instance.GetById(assetTypeId);

                AssetTypeManager.DeleteAssetType(assetTypeId);
                AuditLogManager.LogUserAction(CurrentUser, AuditUserAction.DeleteAssetType, string.Format("Deleted Asset Type: {0}, AssetTypeId: {1}", assetType.Name, assetTypeId));

                MessageLabel1.SetSuccessMessage("Asset type deleted successfully");
            }
            catch (SystemException sysex)
            {
                MessageLabel1.SetErrorMessage(sysex.Message);
            }

            BindGrid(CurrentPage);
        }
        protected override void Grid_UpdateCommand(object source, DataGridCommandEventArgs e)
        {
            TextBox EntityTextBox = (TextBox)e.Item.FindControl("EntityTextBox");
            int     id            = Convert.ToInt32(e.CommandArgument);

            try
            {
                string ipAddress = EntityTextBox.Text;

                IpAddressManager.Update(id, ipAddress);
                AuditLogManager.LogUserAction(CurrentUser, AuditUserAction.ModifyIpAddress, string.Format("Modified Ip Address: {0}, IpAddressId: {1}", id, ipAddress));

                ResetGridState();
                MessageLabel1.SetSuccessMessage("IP Address updated successfully");
            }
            catch (InvalidIpAddressException ex)
            {
                MessageLabel1.SetErrorMessage(ex.Message);
            }
        }
Beispiel #18
0
        protected void SaveSettingsButton_Click(object sender, EventArgs e)
        {
            var brand      = BrandCache.Instance.GetById(BrandId);
            var setting    = brand.GetCustomMetadataSetting(GroupNumber);
            var selectable = ucEditDetails.RetrieveSetting();
            var updateVals = false;

            if (!setting.IsNew && !setting.IsNull && setting.UiControlType == (int)BrandMetadataUiControlType.Select)
            {//check if the type is not changing which would require updating all metadata vals entries of all assets in the database
                //as that will no longer be reflecting the right values
                updateVals = setting.SelectableSetting.SelectableType != selectable.SelectableType;
            }

            selectable.BrandMetadataSettingId = setting.BrandMetadataSettingId.GetValueOrDefault();

            BrandMetadataSelectableSetting.Update(selectable);

            ucEditDetails.BrandMetadataSelectableSettingId = selectable.BrandMetadataSelectableSettingId.GetValueOrDefault();

            if (updateVals)
            {
                var assets = Asset.FindMany(new AssetFinder()
                {
                    IsDeleted = false
                });
                foreach (var asset in assets)
                {
                    asset.MetadataList.ToString();
                    asset.MetadataTextFieldsList.ToString();
                    asset.MetadataTextAreasList.ToString();

                    Asset.SaveAssetMetadata(asset);
                }
            }

            var msg = "Metadata selection options updated successfully" + (updateVals? ".<br />Asset search metadata updated successfully." : "");

            MessageLabel1.SetSuccessMessage(msg);

            CacheManager.InvalidateCache("BrandMetadata", CacheType.All);
        }
        protected override void Grid_ItemCommand(object source, DataGridCommandEventArgs e)
        {
            if (e.CommandName == "add")
            {
                TextBox NewEntityTextBox = (TextBox)e.Item.FindControl("NewEntityTextBox");
                string  ipAddress        = NewEntityTextBox.Text.Trim();

                try
                {
                    IpAddress ipa = IpAddressManager.Add(ipAddress);
                    AuditLogManager.LogUserAction(CurrentUser, AuditUserAction.AddIpAddress, string.Format("Added Ip Address: {0}, IpAddressId: {1}", ipa.IpAddressValue, ipa.IpAddressId));

                    ResetGridState();
                    MessageLabel1.SetSuccessMessage("IP Address added successfully");
                }
                catch (InvalidIpAddressException ex)
                {
                    MessageLabel1.SetErrorMessage(ex.Message);
                }
            }
        }
        protected void SaveButton_Click(object sender, EventArgs e)
        {
            Workflow.BrandId = WorkflowBrandDropDownList.SelectedId;
            Workflow.Name    = WorkflowNameTextBox.Text;

            Workflow.WorkflowUserList.Clear();

            int position = 0;

            foreach (ListItem li in SelectedUsersListBox.Items)
            {
                position++;

                int userId = Convert.ToInt32(li.Value);

                WorkflowUser wfu = WorkflowUser.New();
                wfu.UserId    = userId;
                wfu.Position  = position;
                wfu.DateAdded = DateTime.Now;

                Workflow.WorkflowUserList.Add(wfu);
            }

            try
            {
                WorkflowManager.SaveWorkflow(Workflow);
                MessageLabel1.SetSuccessMessage("Workflow saved successfully");

                CancelButton.Text   = "Back to workflow list";
                CancelButton.Prompt = string.Empty;

                DeselectAllUsers();
            }
            catch (ValidationException vex)
            {
                MessageLabel1.SetErrorMessage("Error saving workflow", vex.Errors);
            }
        }
        protected void SubmitButton_Click(object sender, EventArgs e)
        {
            bool   isApproved = (ApprovedRadioButtonList.SelectedValue == "1");
            string notes      = NotesTextBox.Text.Trim();

            try
            {
                int  userId = GetRequiredQueryStringParameter("userId", "UserList.aspx");
                User user   = Data.User.Get(userId);
                UserManager.ProcessNonEmployee(user, CurrentUser, isApproved, notes);

                MessageLabel1.SetSuccessMessage("User processed successfully");

                ApprovedRadioButtonList.Enabled = false;
                NotesTextBox.Enabled            = false;
                SubmitButton.Visible            = false;

                ChangeCancelButton();
            }
            catch (SystemException sysex)
            {
                MessageLabel1.SetErrorMessage(sysex.Message);
            }
        }
        protected override void Grid_UpdateCommand(object source, DataGridCommandEventArgs e)
        {
            int      assetTypeId       = Convert.ToInt32(e.CommandArgument);
            TextBox  NameTextBox       = (TextBox)e.Item.FindControl("NameTextBox");
            CheckBox IsVisibleCheckBox = (CheckBox)e.Item.FindControl("IsVisibleCheckBox");

            try
            {
                AssetType assetType = AssetType.Get(assetTypeId);
                assetType.Name      = NameTextBox.Text.Trim();
                assetType.IsVisible = IsVisibleCheckBox.Checked;
                AssetTypeManager.SaveAssetType(assetType);

                AuditLogManager.LogUserAction(CurrentUser, AuditUserAction.ModifyAssetType, string.Format("Modified Asset Type: {0}, AssetTypeId: {1}", assetType.Name, assetType.AssetTypeId));

                ResetGridState();
                MessageLabel1.SetSuccessMessage("Asset type updated successfully");
            }
            catch (InvalidAssetTypeException imtex)
            {
                MessageLabel1.SetErrorMessage("Unable to update asset type", imtex.Message);
                BindGrid(CurrentPage);
            }
        }
        protected void BulkRegeneratePreviewsButton_Click(object sender, EventArgs e)
        {
            List <int> selectedIdList = GetSelectedAssetIdList();

            if (selectedIdList.Count == 0)
            {
                MessageLabel1.SetErrorMessage("No assets selected");
                return;
            }

            // Get the assets that we need to reprocess
            AssetFinder finder = new AssetFinder();

            finder.AssetIdList.Add(0);
            finder.AssetIdList.AddRange(selectedIdList);
            List <Asset> selectedAssets = Asset.FindMany(finder);

            if (selectedAssets.Count == 0)
            {
                MessageLabel1.SetErrorMessage("Selected assets no longer exist");
                return;
            }

            // Initialise error list for problems that might occur as assets are processed
            ErrorList errors = new ErrorList();

            // Counters
            int successCount = 0;
            int failCount    = 0;

            foreach (Asset asset in selectedAssets)
            {
                m_Logger.DebugFormat("Re-processing asset ID = {0}", asset.AssetId);

                AssetFileInfo afi = new AssetFileInfo(asset);

                if (!afi.FileExists)
                {
                    errors.Add(string.Format("Asset file for asset with ID {0} is missing or unavailable", asset.AssetId));
                    m_Logger.Warn("Asset file does not exist.  Cannot reprocess");
                    continue;
                }

                try
                {
                    if (APSGateway.Instance.ProcessFile(asset, false, FileOutputs.All))
                    {
                        asset.IsProcessed = false;
                        Asset.Update(asset);
                        successCount++;

                        m_Logger.DebugFormat("Asset {0} resubmitted for processing successfully", asset.AssetId);
                    }
                    else
                    {
                        failCount++;
                        errors.Add(string.Format("#{0} : An error occured when submitting the asset to the processing service", asset.AssetId));
                        m_Logger.DebugFormat("Asset {0} not submitted to the processing service. An error occurred.", asset.AssetId);
                    }
                }
                catch (InvalidAssetException iaex)
                {
                    failCount++;
                    m_Logger.Warn(string.Format("An error occured when processing the asset: {0}", asset.AssetId), iaex);
                    errors.Add(string.Format("#{0}: Error submitting asset for processing: {1}", asset.AssetId, iaex.Message));
                }
                catch (Exception ex)
                {
                    failCount++;
                    m_Logger.Warn(string.Format("An unknown error occured when processing the asset: {0}", asset.AssetId), ex);
                    errors.Add(string.Format("#{0}: Error submitting asset for processing", asset.AssetId));

                    ExceptionHandler.HandleException(ex, "Error bulk regenerating previews");
                }
            }

            m_Logger.DebugFormat("Asset processing result: {0} success, {1} failures, Errors: {2}", successCount, failCount, errors);

            if (successCount == 0)
            {
                MessageLabel1.SetErrorMessage("The selected assets could not be submitted for processing", errors);
                return;
            }

            if (failCount == 0)
            {
                MessageLabel1.SetSuccessMessage("All selected assets were resubmitted for reprocessing successfully");
                return;
            }

            if (successCount > 0 && failCount > 0)
            {
                MessageLabel1.SetErrorMessage("Some of the selected assets could not be resubmitted for processing", errors);
                return;
            }
        }
Beispiel #24
0
        protected void Page_Load(object sender, EventArgs e)
        {
            PasswordReminderButton.Visible = (ConfigurationManager.AppSettings.GetBoolValue("PasswordResetEnabled"));

            if (!Page.IsPostBack)
            {
                if (!CurrentUser.IsNull && WebUtils.GetRequestParam("action") == "logout")
                {
                    SessionEndModule.EndSession();
                    LoginManager.Logout(CurrentUser);
                    SessionInfo.Current.Reset();

                    const string url = "~/login.aspx?message=LoggedOut";
                    Response.Redirect(url, false);

                    return;
                }

                // Get message key from querystring
                string message = WebUtils.GetRequestParam("message", string.Empty);

                switch (message)
                {
                case "AccountReactivated":
                    MessageLabel1.SetSuccessMessage("Your account has been reactivated successfully");
                    break;

                case "PasswordChanged":
                    MessageLabel1.SetSuccessMessage("Your new password has been activated");
                    break;

                case "LoggedOut":
                    MessageLabel1.SetSuccessMessage("You have been logged out");
                    break;

                case "EmailConfirmed":
                    MessageLabel1.SetSuccessMessage("Your email address has been confirmed.  Please login below.");
                    break;

                case "AccessDenied":
                    MessageLabel1.SetErrorMessage("Access to the requested page is denied due to insufficient user credentials.");
                    break;

                case "NoUserOnLoad":
                case "NoUserOnPostback":

                    break;
                }


                string cookieEmail = CookieManager.GetValue("EmailAddress");
                RememberMeCheckBox.Checked = (cookieEmail != string.Empty);

                DropDownList dd = SiteUtils.FindControlRecursive(Page, "UserDropDownList") as DropDownList;

                if (dd != null)
                {
                    ListItem li = dd.Items.FindByValue(cookieEmail);

                    if (li != null)
                    {
                        dd.SelectedIndex = -1;
                        li.Selected      = true;
                    }
                }
                else
                {
                    EmailTextBox.Text = cookieEmail;
                }
            }
        }
Beispiel #25
0
        protected void ProcessButton_Click(object sender, EventArgs e)
        {
            EntityList <OrderItem> orderItems = new EntityList <OrderItem>();

            foreach (RepeaterItem ri in OrderItemsRepeater.Items)
            {
                switch (ri.ItemType)
                {
                case (ListItemType.Item):
                case (ListItemType.AlternatingItem):

                    // Get the controls
                    HiddenField     OrderItemIdHiddenField         = (HiddenField)ri.FindControl("OrderItemIdHiddenField");
                    TextBox         CommentsTextBox                = (TextBox)ri.FindControl("CommentsTextBox");
                    RadioButtonList OrderItemStatusRadioButtonList = (RadioButtonList)ri.FindControl("OrderItemStatusRadioButtonList");

                    // Get the values
                    int    orderItemId       = NumericUtils.ParseInt32(OrderItemIdHiddenField.Value, 0);
                    string comments          = CommentsTextBox.Text;
                    int    orderItemStatusId = NumericUtils.ParseInt32(OrderItemStatusRadioButtonList.SelectedValue, 0);

                    // Skip if the order item or status is missing
                    if (orderItemId == 0 || orderItemStatusId == 0)
                    {
                        continue;
                    }

                    // Get the order item
                    OrderItem orderItem = OrderItem.Get(orderItemId);

                    // Assume we're not processing it
                    bool process = false;

                    // Check if a comment was entered
                    if (!StringUtils.IsBlank(comments))
                    {
                        process = true;
                        orderItem.AddComment(CurrentUser.UserId.GetValueOrDefault(), comments);
                    }

                    // .. Or the status has been changed
                    if (orderItem.OrderItemStatusId != orderItemStatusId)
                    {
                        process = true;
                        orderItem.OrderItemStatusId     = orderItemStatusId;
                        orderItem.OrderItemStatusDate   = DateTime.Now;
                        orderItem.OrderItemStatusUserId = CurrentUser.UserId;
                    }

                    // If something was changed, then add this order item to the list
                    // of order items that we will submit for processing.
                    if (process)
                    {
                        orderItems.Add(orderItem);
                    }

                    break;
                }
            }

            try
            {
                OrderManager.ProcessOrderItems(orderItems, CurrentUser);
                MessageLabel1.SetSuccessMessage("Selected items processed successfully");
                PerformSearchAndBindGrid(CurrentPage);

                // We know there's at least one order item or the OrderManager.ProcessOrderItems() method
                // will throw an InvalidOrderItemException which will be caught below.
                Order order = orderItems[0].Order;

                HideProcessButtonIfComplete(order);
            }
            catch (InvalidOrderItemException ioex)
            {
                MessageLabel1.SetErrorMessage(ioex.Message);
            }
        }