private string MoveObjects(HttpContext context) { string msg = string.Empty; string paras = context.Request["objects"]; int target = 0; if (int.TryParse(context.Request["target"], out target)) { if (string.IsNullOrEmpty(paras)) { return("Arguments Error!"); } FileApplication fileApp = new FileApplication(); string[] items = paras.Split(",".ToCharArray(), StringSplitOptions.RemoveEmptyEntries); if (items.Length > 0) { StringBuilder sbdireids = new StringBuilder("0,"); StringBuilder sbobjids = new StringBuilder("0,"); foreach (string item in items) { string[] keyorvalue = item.Split("-".ToCharArray(), StringSplitOptions.RemoveEmptyEntries); if (keyorvalue.Length == 2) { int id = 0; if (int.TryParse(keyorvalue[1], out id) && keyorvalue[0] == DirectoryObjectType.Directory.ToString()) { sbdireids.Append(id); sbdireids.Append(","); } else { sbobjids.Append(id); sbobjids.Append(","); } } } sbdireids.Append(";"); sbdireids.Append(sbobjids); if (!fileApp.ChangeParent(sbdireids.ToString(), target) && fileApp.BrokenRuleMessages.Count > 0) { msg = fileApp.BrokenRuleMessages[0].Message; } return(msg); } else { return("Arguments Error!"); } } else { return("Arguments Error!"); } }
protected void btnSave_Click(object sender, EventArgs e) { int target = 0; if (!int.TryParse(hidSelectedDirectory.Value, out target)) { ShowMessageToClient("Please select a directory", 0, false, false); return; } FileApplication fileApp = new FileApplication(); string[] items = Request.Params["objects"].Split(",".ToCharArray(), StringSplitOptions.RemoveEmptyEntries); if (items.Length > 0) { StringBuilder sbdireids = new StringBuilder("0,"); StringBuilder sbobjids = new StringBuilder("0,"); foreach (string item in items) { string[] keyorvalue = item.Split("-".ToCharArray(), StringSplitOptions.RemoveEmptyEntries); if (keyorvalue.Length == 2) { int id = 0; if (int.TryParse(keyorvalue[1], out id) && keyorvalue[0] == DirectoryObjectType.Directory.ToString()) { sbdireids.Append(id); sbdireids.Append(","); } else { sbobjids.Append(id); sbobjids.Append(","); } } } sbdireids.Append(";"); sbdireids.Append(sbobjids); if (!fileApp.ChangeParent(sbdireids.ToString(), target)) { ShowFailMessageToClient(fileApp.BrokenRuleMessages); } else { ShowSuccessMessageToClient(); } } }