void TasksTree_RemoteRemove(object sender, RemoteActionEventArgs e) { try { if (e.NodeID.IsEmpty()) { e.Accept = true; return; } int nodeId = int.Parse(e.NodeID); //root if (nodeId == 1) { e.Accept = false; e.RefusalMessage = "The root node can't be deleted"; } SimpleTasksDataContext ctx = this.DBContext; Category category = (from tl in ctx.Categories where tl.ID == nodeId select tl).First(); // remove children lists foreach (Category childrenList in category.Categories) { ctx.Categories.DeleteOnSubmit(childrenList); } // remove category ctx.Categories.DeleteOnSubmit(category); ctx.SubmitChanges(); e.Accept = true; } catch (Exception exception) { e.Accept = false; e.RefusalMessage = exception.Message; } }
void TasksTree_RemoteRemove(object sender, RemoteActionEventArgs e) { try { int nodeId = int.Parse(e.NodeID); //root if (nodeId == 1) { e.Accept = false; e.RefusalMessage = "The root node can't be deleted"; } var ctx = this.DBContext; Category category = (from tl in ctx.Categories where tl.ID == nodeId select tl).First(); // remove children lists foreach (Category childrenList in category.Categories) { ctx.Categories.DeleteOnSubmit(childrenList); } // remove category ctx.Categories.DeleteOnSubmit(category); ctx.SubmitChanges(); e.Accept = true; } catch (Exception exception) { e.Accept = false; e.RefusalMessage = exception.Message; } }
private void ShowError(string msg, RemoteActionEventArgs e) { e.RefusalMessage = msg; e.Accept = false; Ext.Net.X.Msg.Alert("错误", msg, new JFunction("var tree=App." + this.ID + ";tree.editingPlugin.startEdit(tree.getSelectionModel().getSelection()[0],tree.columns[1]);")).Show(); }
public void RaiseAjaxPostBackEvent(string eventArgument, ParameterCollection extraParams) { bool success = true; string msg = null; Response response = new Response(); try { if (eventArgument.IsEmpty()) { throw new ArgumentNullException("eventArgument"); } string data = null; if (this.DirectConfig != null) { JToken serviceToken = this.DirectConfig.SelectToken("config.serviceParams", false); if (serviceToken != null) { data = JSON.ToString(serviceToken); } } switch(eventArgument) { case "nodeload": //NodeLoadEventArgs e = new NodeLoadEventArgs(extraParams); //PageTreeLoader loader = (PageTreeLoader) this.Loader.Primary; //loader.OnNodeLoad(e); //TreeNodeCollection nodes = e.Nodes; //success = e.Success; //msg = e.ErrorMessage; //response.Data = nodes != null ? nodes.ToJson() : null; break; case "submit": SubmitEventArgs se = new SubmitEventArgs(extraParams, JSON.Deserialize<SubmittedNode>(data, new CamelCasePropertyNamesContractResolver())); this.OnSubmit(se); break; case "raRename": RemoteRenameEventArgs rr = new RemoteRenameEventArgs(data,extraParams); this.OnRemoteRename(rr); success = rr.Accept; msg = rr.RefusalMessage; break; case "raRemove": RemoteActionEventArgs rrm = new RemoteActionEventArgs(data, extraParams); this.OnRemoteRemove(rrm); success = rrm.Accept; msg = rrm.RefusalMessage; break; case "raInsert": case "raAppend": RemoteAppendEventArgs ra = new RemoteAppendEventArgs(eventArgument == "raInsert", data, extraParams); this.OnRemoteAppend(ra); success = ra.Accept; msg = ra.RefusalMessage; break; case "raMove": RemoteMoveEventArgs rm = new RemoteMoveEventArgs(data, extraParams); this.OnRemoteMove(rm); success = rm.Accept; msg = rm.RefusalMessage; break; } } catch (Exception ex) { success = false; msg = this.IsDebugging ? ex.ToString() : ex.Message; if (this.ResourceManager.RethrowAjaxExceptions) { throw; } } response.Success = success; response.Message = msg; ResourceManager.ServiceResponse = response; }
internal virtual void OnRemoteRemove(RemoteActionEventArgs e) { RemoteActionEventHandler handler = (RemoteActionEventHandler)Events[EventRemove]; if (handler != null) { handler(this, e); } }