public async Task <HttpResponseMessage> Duplicate() { var user = GetSessionUser(Request.Headers.GetCookies().FirstOrDefault()); List <NodeDto> successEntity = new List <NodeDto>(); //成功处理的Entity信息 JDBCEntity currentEntity = null; //当前处理的Entity信息 try { var dict = ParseToQueryDictionary(Request.RequestUri); NameValueCollection form = Request.Content.ReadAsFormDataAsync().Result; var recursive = false; if (dict.ContainsKey("recursive") && dict["recursive"] == "true") { recursive = true; } var copydata = false; if (dict.ContainsKey("copydata") && dict["copydata"] == "true") { copydata = true; } var fromNodes = await MyCoreApi.FindNodeByUriAsync(new Uri("jdbc://" + GetValueFromForm(form, "from").Replace(";", "&").Replace(",", "&").Trim("'\"()[]{}".ToCharArray()))); //获取源entity var toNodes = await MyCoreApi.FindNodeByUriAsync(new Uri("jdbc://" + GetValueFromForm(form, "to").Replace(";", "&").Replace(",", "&").Trim("'\"()[]{}".ToCharArray()))); //获取目的entity var newname = GetValueFromForm(form, "newname"); foreach (var fromNode in fromNodes) { foreach (var toNode in toNodes) { currentEntity = toNode; if (!await MyCoreApi.Authorization(currentEntity.Id, user, "1")) { throw new Exception("Not authorization!"); } var newNode = await MyCoreApi.DuplicateAsync(fromNode.Id, toNode.Id, newname, recursive, copydata); //复制entity到新的父节点下 successEntity.Add(Mapper.Map <NodeDto>(newNode)); //保存处理结果 } } return(new HttpResponseMessage { Content = new StringContent(SerializeObjectToString(successEntity), System.Text.Encoding.GetEncoding("UTF-8"), "application/json") }); } catch (Exception e) { if (currentEntity == null) { return(new HttpResponseMessage { StatusCode = HttpStatusCode.Forbidden, Content = new StringContent(e.InnerException != null ? e.InnerException.Message : e.Message) }); } var response = new ResponseEntityMessage { Fail = new { Description = e.InnerException != null ? e.InnerException.Message : e.Message, Id = currentEntity.Id, Path = currentEntity.Path }, Success = successEntity }; return(new HttpResponseMessage { StatusCode = HttpStatusCode.Forbidden, Content = new StringContent(SerializeObjectToString(response), System.Text.Encoding.GetEncoding("UTF-8"), "application/json") }); } }