protected void ItemGrid_MultiOperationActionRun(object sender, UserMadeChoiceEventArgs e) { if (e.ApplyForAll) { if (e.CommandOfChoice.CommandName == "SendSelectItems") { var items = BXMailerEventEntity.GetList(new BXFilter(ItemFilter.CurrentFilter, BXMailerEventEntity.Fields), null); BXMailerEventEntity.SetStatus(BXMailerEventStatus.NotProcessed); } else if (e.CommandOfChoice.CommandName == "DeleteSelectItems") { var items = BXMailerEventEntity.GetList(new BXFilter(ItemFilter.CurrentFilter, BXMailerEventEntity.Fields), null); foreach (var item in items) item.Delete(); } } else { if (e.CommandOfChoice.CommandName == "SendSelectItems") { var indexRows = ItemGrid.GetSelectedRowsIndices(); string ids = ""; foreach (int index in indexRows) ids += ItemGrid.DataKeys[index].Value.ToString() + ","; var chArray = new char[] { ',' }; BXMailerEventEntity.SetStatus(BXMailerEventStatus.NotProcessed, ids.TrimEnd(chArray).Split(chArray)); } else if (e.CommandOfChoice.CommandName == "DeleteSelectItems") { var indexRows = ItemGrid.GetSelectedRowsIndices(); List<string> ids = new List<string>(); foreach (int index in indexRows) ids.Add(ItemGrid.DataKeys[index].Value.ToString()); var items = BXMailerEventEntity.GetList(new BXFilter(new BXFilterItem(BXMailerEventEntity.Fields.Id, BXSqlFilterOperators.In, ids.ToArray())), null); foreach (var item in items) item.Delete(); } } Redirect(BackUrl); }
protected void ItemGrid_MultiOperationActionRun(object sender, UserMadeChoiceEventArgs e) { try { switch (e.CommandOfChoice.CommandName) { case "approve": if((e.ApplyForAll ? ApproveAllComments(true) : ApproveComments(ItemGrid.GetSelectedRowsIndices(), true)) > 0) Response.Redirect(Request.RawUrl); break; case "disapprove": if((e.ApplyForAll ? ApproveAllComments(false) : ApproveComments(ItemGrid.GetSelectedRowsIndices(), false)) > 0) Response.Redirect(Request.RawUrl); break; } } catch (Exception ex) { ErrorMessage.AddErrorMessage(ex.Message); } }
void DoFileSecurity(UserMadeChoiceEventArgs e, string singleEntry) { StringBuilder s = new StringBuilder(); if (singleEntry != null && e == null) s.Append(HttpUtility.UrlEncode(singleEntry)); else if (e.ApplyForAll) { DataView entities = null; if (BXSecureIO.DirectoryExists(this.curPath)) entities = BXSecureIO.DirectoryList(this.curPath, true, null, new string[] { "name" }); if (entities != null) foreach (DataRowView r in entities) { if (s.Length > 0) s.Append('|'); s.Append(HttpUtility.UrlEncode((string)r["name"])); } } else { int[] sel = fileManGrid.GetSelectedRowsIndices(); foreach (int i in sel) { DataKey key = fileManGrid.DataKeys[i]; if (String.IsNullOrEmpty((string)key["type"])) continue; if (s.Length > 0) s.Append('|'); s.Append(HttpUtility.UrlEncode((string)key["name"])); } } Response.Redirect("FileManSecurity.aspx?path=" + this.curPath + "&items=" + s.ToString()); }
void DoFileOperation(FileOperation operation, UserMadeChoiceEventArgs e, string singleEntry) { if (operation == FileOperation.Nothing) return; string source = this.curPath; string target = targetFolder.Text; try { target = target.Trim().Trim('/', '\\'); target = BXPath.ToVirtualRelativePath(target); } catch { ShowError(Encode(string.Format(GetMessageRaw("FormattedErrorMassage.SpecifiedPathIsInvalid"), targetFolder.Text))); return; } List<string> files; if (e == null) { if (singleEntry == null) return; files = new List<string>(); files.Add(singleEntry); } else files = FormFileList(e); if (files.Count == 0) return; this.errorTemplateNoRightsToDelete = String.Format("{0}: {{0}}", GetMessageRaw("Message.InsufficientRightsToDelete")); this.errorTemplateUnknownSource = String.Format("{0}: {{0}}", GetMessageRaw("Message.UnknownItem")); this.errorTemplateUnableToDelete = String.Format("{0}: {{0}}", GetMessageRaw("Message.UnableToDelete")); this.errorTemplateTargetExists = String.Format("{0}: {{0}} -> {{1}}", GetMessageRaw("Message.TargetItemAlreadyExists")); this.errorTemplateUnableToWrite = String.Format("{0}: {{0}} -> {{1}}", GetMessageRaw("Message.UnableToWrite")); this.errorTemplateCantCopyIntoItself = String.Format("{0}: {{0}} -> {{1}}", GetMessageRaw("Message.CantCopyIntoItself")); if ((operation & FileOperation.Copy) > 0 && !CheckForCopyOperation(source, target)) return; for (int i = 0; i < files.Count; i++) { try { string filename = files[i]; string sourcePath = BXPath.Combine(source, filename); bool isFile; if (BXSecureIO.FileExists(sourcePath)) isFile = true; else if (BXSecureIO.DirectoryExists(sourcePath)) isFile = false; else throw new Exception(String.Format(this.errorTemplateUnknownSource, sourcePath)); if ((operation & FileOperation.Copy) > 0) DoFileCopyMove(sourcePath, BXPath.Combine(target, filename), (operation & FileOperation.Delete) > 0, isFile); else if ((operation & FileOperation.Delete) > 0) DoFileDelete(sourcePath, isFile); } catch (Exception ex) { ShowError(Encode(ex.Message)); } } ShowOk(); fileManGrid.MarkAsChanged(); }
List<string> FormFileList(UserMadeChoiceEventArgs e) { List<string> files = new List<string>(); string fullCurPath = BXPath.ToPhysicalPath(this.curPath); if (!Directory.Exists(fullCurPath)) return files; if (!e.ApplyForAll) { int[] sel = fileManGrid.GetSelectedRowsIndices(); foreach (int i in sel) { DataKey key = fileManGrid.DataKeys[i]; if (String.IsNullOrEmpty((string)key["type"])) continue; files.Add((string)key["name"]); } } else { List<string> entities = new List<string>(); DataView view = BXSecureIO.DirectoryList(this.curPath, true); view.RowFilter = Filter.CurrentFilter.BuildDataViewFilter(); foreach (DataRowView v in view) files.Add((string)v["name"]); } return files; }
protected void AuthUserGridView_MultiOperationActionRun(object sender, UserMadeChoiceEventArgs e) { if (e.CommandOfChoice.CommandName != "delete" && e.CommandOfChoice.CommandName != "deleteProvider") return; successMessage.Visible = false; e.Cancel = true; BXGridView grid = AuthUserGridView; try { BXUserCollection users; if (e.ApplyForAll) { users = Bitrix.Security.BXUser.GetList( new BXFilter(BXAdminFilter1.CurrentFilter, Bitrix.Security.BXUser.Fields), null ); } else { List<object> keys = new List<object>(); foreach (int index in grid.GetSelectedRowsIndices()) keys.Add(grid.DataKeys[index]["UserId"]); users = Bitrix.Security.BXUser.GetList( new BXFilter( new BXFilterItem(Bitrix.Security.BXUser.Fields.UserId, BXSqlFilterOperators.In, keys) ), null ); } foreach (var user in users) { if (!CanDelete(user.UserId)) throw new PublicException(GetMessageRaw("ExceptionText.YouDontHaveRightsToDeleteUsers")); } DeleteUsers(users, e.CommandOfChoice.CommandName == "deleteProvider"); successMessage.Visible = true; } catch (Exception ex) { ProcessException(ex); } grid.MarkAsChanged(); }
protected void AuthRolesGridView_MultiOperationActionRun(object sender, UserMadeChoiceEventArgs e) { if (e.CommandOfChoice.CommandName != "delete" && e.CommandOfChoice.CommandName != "deleteProvider") return; successMessage.Visible = false; e.Cancel = true; try { if (!currentUserCanModifySettings) throw new PublicException(GetMessageRaw("ExceptionText.YouDontHaveRightsToDeleteThisRecord")); BXRoleCollection roles; if (e.ApplyForAll) roles = BXRoleManager.GetList(BXAdminFilter1.CurrentFilter, null); else { roles = new BXRoleCollection(); foreach (int i in AuthRolesGridView.GetSelectedRowsIndices()) { DataKey row = AuthRolesGridView.DataKeys[i]; roles.Add(BXRoleManager.GetById((int)row.Value)); } } DeleteRoles(roles, e.CommandOfChoice.CommandName == "deleteProvider"); 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); } AuthRolesGridView.MarkAsChanged(); }