protected void ItemGrid_Delete(object sender, BXDeleteEventArgs e) { categorieCollection col; try { BXFilter filter = (e.Keys == null) ? new BXFilter(ItemFilter.CurrentFilter, categorie.Fields) : new BXFilter(new BXFilterItem(categorie.Fields.id, BXSqlFilterOperators.Equal, e.Keys["id"])); col = categorie.GetList(filter, null); } catch (Exception ex) { ErrorMessage.AddErrorMessage(ex.Message); return; } bool errorTextAdded = false; foreach (var item in col) { try { item.Delete(); e.DeletedCount++; } catch { if (!errorTextAdded) { ErrorMessage.AddErrorMessage(GetMessage("categorie.DeleteFailure")); errorTextAdded = true; } } } }
protected void MailerGridView_Delete(object sender, BXDeleteEventArgs e) { try { if (!currentUserCanModify) return; BXMailerTemplateCollection templates; if (e.Keys != null) { templates = new BXMailerTemplateCollection(); templates.Add(BXMailerTemplate.GetById(e.Keys["Id"])); } else templates = BXMailerTemplate.GetList(new BXFilter(Filter.CurrentFilter, BXMailerTemplate.Fields), null); foreach (BXMailerTemplate template in templates) { if (template == null) continue; template.Delete(); e.DeletedCount++; } } catch { } }
protected void GridView_Delete(object sender, BXDeleteEventArgs e) { try { if (!currentUserCanModify) throw new UnauthorizedAccessException(GetMessageRaw("Exception.YouDontHaveRightsToPerformThisOperation")); if (e.Keys != null) BXLanguage.Delete(e.Keys["Id"]); else BXLanguage.Delete(null); e.DeletedCount++; } catch (Exception ex) { Summary.AddErrorMessage(ex.Message); } }
protected void BXGridView1_Delete(object sender, BXDeleteEventArgs e) { try { if (!currentUserCanModifySettings) throw new PublicException(GetMessageRaw("InsufficientRightsToDeleteCustomFields")); BXCustomFieldCollection fields; if (e.Keys != null) { fields = new BXCustomFieldCollection(); fields.Add(BXCustomField.GetById(e.Keys["Id"])); } else fields = BXCustomField.GetList(new BXFilter(BXAdminFilter1.CurrentFilter, BXCustomField.Fields), null); foreach(BXCustomField f in fields) f.Delete(); } catch(Exception ex) { ProcessException(ex); } }
protected void GridView1_Delete(object sender, BXDeleteEventArgs e) { BXGridView grid = (BXGridView)sender; try { BXIBlockTypeCollection elements; if (e.Keys != null) //Delete one element { elements = new BXIBlockTypeCollection(); int typeId; Int32.TryParse(e.Keys["TypeId"].ToString(), out typeId); if (typeId <= 0) throw new PublicException(GetMessageRaw("Error.CodeOfTypeIsNotFound")); BXIBlockType elem = BXIBlockType.GetById(typeId); if (elem == null) throw new PublicException(GetMessageRaw("Exception.TypeIsNotFound")); elements.Add(elem); } else //All elements { elements = BXIBlockType.GetList(new BXFilter(MakeCurrentFilter(), BXIBlockType.Fields), null); } int iblocksCount; int delErrorCount = 0; string elemName; foreach (BXIBlockType element in elements) { if (element == null) throw new PublicException(GetMessageRaw("Exception.ElementIsNotFound")); if (!currentUserCanModifyType) throw new PublicException(GetMessageRaw("Exception.YouDontHaveRightsToDeleteThisRecord")); iblocksCount = BXIBlock.Count(new BXFilter(new BXFilterItem(BXIBlock.Fields.Type.ID, BXSqlFilterOperators.Equal, element.Id))); elemName = element.Translations[BXLoc.CurrentLocale].Name; if (iblocksCount > 0) { delErrorCount++; errorMessage.AddErrorText(String.Format(GetMessageRaw("Exception.IBlockTypeContainsIBlocks"),BXTextEncoder.HtmlTextEncoder.Decode(elemName) )); } else { //throw new PublicException(GetMessageRaw("Exception.AnErrorHasOccurredWhileDeletingElement")); //successMessage.AddErrorText(String.Format("\"{0}\"", BXTextEncoder.HtmlTextEncoder.Decode(element.Translations[BXLoc.CurrentLocale].Name))); BXIBlockType.Delete(element.Id); deletedList.Append(String.Format("<li>\"{0}\"</li>",elemName )); e.DeletedCount++; } } if (delErrorCount == 0) successMessage.Visible = true; } catch (Exception ex) { ProcessException(ex, errorMessage.AddErrorText); } grid.MarkAsChanged(); }
protected void BXSubscriptionsGrid_Delete(object sender, BXDeleteEventArgs e) { if (e.Keys != null) { int[] ids = new int[e.Keys.Count]; e.Keys.Values.CopyTo(ids, 0); BXForumSubscriptionCollection subs = BXForumSubscription.GetList( new BXFilter( new BXFilterItem( BXForumSubscription.Fields.Id, BXSqlFilterOperators.In, ids ) ) , null); foreach (BXForumSubscription sub in subs) { if (sub == null) continue; try { sub.Delete(); } catch (Exception ex) { ErrorMessage.AddErrorMessage(ex.Message); } e.DeletedCount++; } } }
protected void GridView_Delete(object sender, BXDeleteEventArgs e) { if (currentUserCanModify) { List<string> templates = new List<string>(); if (e.Keys != null) templates.Add(e.Keys["ID"].ToString()); else foreach (DirectoryInfo info in new DirectoryInfo(BXPath.MapPath(BXConfigurationUtility.Constants.TemplatesFolderPath)).GetDirectories()) templates.Add(info.Name); foreach (string t in templates) { string templateDirectory = BXPath.Combine(BXConfigurationUtility.Constants.TemplatesFolderPath, t); try { BXSecureIO.DirectoryDelete(templateDirectory, true); } catch (IOException) { BXSecureIO.DirectoryDelete(templateDirectory, true); } } } }
protected void ItemGrid_Delete(object sender, BXDeleteEventArgs e) { if (!BXPrincipal.Current.IsCanOperate(BXBlog.Operations.AdminManagement)) return; BXBlogCollection blogs; try { BXFilter filter = (e.Keys == null) ? new BXFilter(ItemFilter.CurrentFilter, BXBlog.Fields) : new BXFilter(new BXFilterItem(BXBlog.Fields.Id, BXSqlFilterOperators.Equal, e.Keys["ID"])); blogs = BXBlog.GetList(filter, null); } catch (Exception ex) { ErrorMessage.AddErrorMessage(ex.Message); return; } bool errorTextAdded = false; foreach (BXBlog blog in blogs) { try { blog.Delete(); e.DeletedCount++; } catch (Exception ex2) { if (!errorTextAdded) { ErrorMessage.AddErrorMessage(GetMessage("Blog.DeleteFailure")); errorTextAdded = true; } } } }
protected void ItemGrid_Delete(object sender, BXDeleteEventArgs e) { //if (!BXPrincipal.Current.IsCanOperate()) // return; BXRatingVotingCollection col; try { BXFilter filter = (e.Keys == null) ? new BXFilter(ItemFilter.CurrentFilter, BXRatingVoting.Fields) : new BXFilter(new BXFilterItem(BXRatingVoting.Fields.Id, BXSqlFilterOperators.Equal, e.Keys["ID"])); col = BXRatingVoting.GetList(filter, null); } catch (Exception ex) { ErrorMessage.AddErrorMessage(ex.Message); return; } bool errorTextAdded = false; foreach (BXRatingVoting item in col) { try { item.Delete(); e.DeletedCount++; } catch (Exception ex2) { if (!errorTextAdded) { ErrorMessage.AddErrorMessage(GetMessage("RatingVoting.DeleteFailure")); errorTextAdded = true; } } } }
protected void GridView1_Delete(object sender, BXDeleteEventArgs e) { BXGridView grid = (BXGridView)sender; try { BXIBlockCommonCollection elements; if (e.Keys != null) //Delete one element { elements = new BXIBlockCommonCollection(); int tempId; Int32.TryParse(e.Keys["ID"].ToString(), out tempId); string tempKey = e.Keys["CommonElementType"].ToString(); if (tempId <= 0 || (!string.Equals(tempKey, "E", StringComparison.OrdinalIgnoreCase) && !string.Equals(tempKey, "S", StringComparison.OrdinalIgnoreCase))) { throw new PublicException(GetMessageRaw("Error.ElementCodeIsNotFound")); } if (string.Equals(tempKey, "E", StringComparison.OrdinalIgnoreCase)) { BXIBlockElement elem = BXIBlockElement.GetById(tempId); if (elem == null) throw new PublicException(GetMessageRaw("Exception.ElementIsNotFound")); elements.Add(elem); } else { BXIBlockSection sect = BXIBlockSection.GetById(tempId); if (sect == null) throw new PublicException(GetMessageRaw("Exception.SectionIsNotFound")); elements.Add(sect); } } else //All elements { elements = BXIBlockSection.GetMixedList(MakeCurrentFilter(), null); } foreach (BXEntity element in elements) { if (element == null) throw new PublicException(GetMessageRaw("Exception.ElementIsNotFound")); if (element is BXIBlockElement) { BXIBlockElement elem = (BXIBlockElement)element; if (!BXIBlock.IsUserCanOperate(elem.IBlockId, BXIBlock.Operations.IBlockModifyElements)) throw new PublicException(GetMessageRaw("ExceptionText.YouDontHaveRightsToDeleteThisRecord")); elem.Delete(); } else { BXIBlockSection sect = (BXIBlockSection)element; if (!BXIBlock.IsUserCanOperate(sect.IBlockId, BXIBlock.Operations.IBlockModifySections)) throw new PublicException(GetMessageRaw("Exception.YouDontHaveRightsToDeleteThisRecord")); sect.Delete(); //if (!BXInfoBlockSectionManagerOld.Delete(sect.Id)) //throw new Exception(GetMessageRaw("Exception.AnErrorHasOccurredWhileDeletingSection")); } e.DeletedCount++; } successMessage.Visible = true; } catch (Exception ex) { ProcessException(ex, errorMessage.AddErrorText); } grid.MarkAsChanged(); }
protected void ItemGrid_Delete(object sender, BXDeleteEventArgs e) { if (!canModify) return; BXContentTagCollection tags; try { BXFilter filter = (e.Keys == null) ? new BXFilter(ItemFilter.CurrentFilter, BXContentTag.Fields) : new BXFilter(new BXFilterItem(BXContentTag.Fields.Id, BXSqlFilterOperators.Equal, e.Keys["Id"])); tags = BXContentTag.GetList(filter, null); } catch (Exception ex) { ErrorMessage.AddErrorMessage(ex.Message); return; } foreach(BXContentTag tag in tags) try { tag.Delete(); e.DeletedCount++; } catch (Exception ex) { ErrorMessage.AddErrorMessage(ex.Message); } }
protected void AuthOperationsGridView_Delete(object sender, BXDeleteEventArgs e) { BXGridView grid = (BXGridView)sender; try { if (!currentUserCanModifySettings) throw new PublicException(GetMessageRaw("ExceptionText.YouDontHaveRightsToDeleteThisRecord")); BXRoleOperationCollection elements; if (e.Keys != null) //Delete one element { elements = new BXRoleOperationCollection(); elements.Add(BXRoleOperationManager.GetById((int)e.Keys["OperationId"])); } else //All elements { elements = BXRoleOperationManager.GetList(BXAdminFilter1.CurrentFilter, null); } foreach(BXRoleOperation element in elements) { if (element == null) throw new PublicException(GetMessageRaw("ExceptionText.OperationIsNotFound")); if (!BXRoleOperationManager.Delete(element.OperationId)) throw new PublicException(GetMessageRaw("ExceptionText.DeletionIsFailed")); e.DeletedCount++; } successMessage.Visible = true; } catch (PublicException ex) { errorMessage.AddErrorMessage(Encode(ex.Message)); } catch(Exception ex) { errorMessage.AddErrorMessage(GetMessage("Kernel.UnknownError")); BXLogService.LogAll(ex, 0, BXLogMessageType.Error, AppRelativeVirtualPath); } grid.MarkAsChanged(); }
protected void Grid_Delete(object sender, BXDeleteEventArgs e) { try { if (!currentUserCanModify) throw new SecurityException(GetMessageRaw("Exception.YouDontHaveRightsToPerformThisOperation")); if (e.Keys == null) BXSchedulerAgent.Delete(null); else BXSchedulerAgent.Delete(e.Keys["Id"]); e.DeletedCount = 1; ShowOk(); } catch (Exception ex) { ShowError(ex); } }
protected void ItemGrid_Delete(object sender, BXDeleteEventArgs e) { if (!BXPrincipal.Current.IsCanOperate(BXRoleOperation.Operations.ProductSettingsManage)) return; BXStorageConfigurationCollection entities; try { BXFilter filter = e.Keys != null ? new BXFilter(new BXFilterItem(BXStorageConfiguration.Fields.Id, BXSqlFilterOperators.Equal, e.Keys["ID"])) : null; entities = BXStorageConfiguration.GetList(filter, null); } catch (Exception ex) { ErrorMessage.AddErrorMessage(ex.Message); return; } bool errorTextAdded = false; foreach (BXStorageConfiguration entity in entities) { try { entity.Delete(); e.DeletedCount++; } catch { if (!errorTextAdded) { ErrorMessage.AddErrorMessage(GetMessage("StorageConfiguration.DeleteFailure")); errorTextAdded = true; } } } }
protected void GridView1_Delete(object sender, BXDeleteEventArgs e) { BXGridView grid = (BXGridView)sender; try { BXInfoBlockCollectionOld elements; if (e.Keys != null) //Delete one element { elements = new BXInfoBlockCollectionOld(); elements.Add(BXInfoBlockManagerOld.GetById((int)e.Keys["IBlockId"])); } else //All elements { elements = BXInfoBlockManagerOld.GetList(MakeCurrentFilter(), null); } foreach (BXInfoBlockOld element in elements) { if (element == null) throw new PublicException(GetMessageRaw("ExceptionText.BlockIsNotFound")); if (!BXIBlock.IsUserCanOperate(element.IBlockId, BXIBlock.Operations.IBlockManageAdmin)) throw new PublicException(GetMessageRaw("ExceptionText.YouDontHaveRightsToDeleteThisRecord")); BXIBlock.Delete(element.IBlockId); e.DeletedCount++; } successMessage.Visible = true; } catch (Exception ex) { ProcessException(ex, errorMessage.AddErrorText); } grid.MarkAsChanged(); }
protected void BXForumGrid_Delete(object sender, BXDeleteEventArgs e) { BXForumCollection forums; if (e.Keys != null) { forums = new BXForumCollection(); forums.Add(BXForum.GetById(e.Keys["ID"])); } else forums = BXForum.GetList(new BXFilter(BXForumFilter.CurrentFilter, BXForum.Fields), null); foreach (BXForum forum in forums) { if (forum == null || !BXPrincipal.Current.IsCanOperate(BXForum.Operations.ForumAdminManage, "forum", forum.Id)) continue; try { forum.Delete(); } catch (Exception ex) { ErrorMessage.AddErrorMessage(ex.Message); } e.DeletedCount++; } }
protected void GridView_Delete(object sender, BXDeleteEventArgs e) { try { if (!currentUserCanModify) throw new PublicException(GetMessageRaw("Exception.YouDontHaveRightsToDeleteThisRecord")); BXSiteCollection sites; if (e.Keys != null) { sites = new BXSiteCollection(); sites.Add(BXSite.GetById(e.Keys["ID"])); } else sites = BXSite.GetList(new BXFilter(BXAdminFilter1.CurrentFilter, BXSite.Fields), null); foreach (BXSite site in sites) { if (site == null) continue; try { site.Delete(); } catch (InvalidOperationException ex) { throw new PublicException(ex); } e.DeletedCount++; } } catch (Exception ex) { ProcessException(ex, errorMessage.AddErrorText); } }
protected void ItemGrid_Delete(object sender, BXDeleteEventArgs e) { if (!BXPrincipal.Current.IsCanOperate(BXBlog.Operations.AdminManagement)) return; try { BXBlogComment.Delete(e.Keys["ID"]); e.DeletedCount++; } catch (Exception ex) { ErrorMessage.AddErrorMessage(ex.Message); } }
protected void ItemGrid_Delete(object sender, BXDeleteEventArgs e) { }