private void addproperty(HttpContext context) { try { string strjson = context.Request.Form["strjson"]; int ProjectID = int.Parse(context.Request.Params["ProjectID"]); List <string> list = JsonConvert.DeserializeObject <List <string> >(strjson); Project project = Project.GetProject(ProjectID); string PName = string.Empty; List <int> idlist = new List <int>(); int count = 0; ProjectProperty property = new ProjectProperty(); property.AddTime = DateTime.Now; property.MainSortOrder = 0; property.IsBelongProject = true; PropertyInfo[] propertylist = property.GetType().GetProperties(); for (int i = 0; i < list.Count; i++) { if (string.IsNullOrEmpty(list[i])) { continue; } count++; if (count == 1) { property.Title = string.IsNullOrEmpty(project.PName) ? list[i] : project.PName; } PropertyInfo info = propertylist.FirstOrDefault(p => p.Name.Equals("Level" + (count - 1))); if (info != null) { info.SetValue(property, list[i], null); } } var project_property = new Project_Property(); project_property.ProjectID = ProjectID; project_property.SortOrder = 1; project_property.IsHide = false; project_property.AddTime = DateTime.Now; using (SqlHelper helper = new SqlHelper()) { try { helper.BeginTransaction(); property.Save(helper); project_property.RelationID = property.ID; project_property.Save(helper); helper.Commit(); context.Response.Write("0"); } catch (Exception ex) { helper.Rollback(); LogHelper.WriteError("ProjectPropertyHandler", "visit: addproperty", ex); context.Response.Write("1"); } } } catch (Exception ex) { LogHelper.WriteError("ProjectPropertyHandler", "visit: addproperty", ex); context.Response.Write("1"); } }