public static void CopyFromNonRoot(FarmRootPanel target, FarmPanel source) { // fill all value-fields except idftarget foreach (var prop in target.GetType().GetProperties().Select(x => x.Name)) { if (COPY_EXTENSIONS.Contains(prop)) { continue; } object val = source.GetValue(prop); target.SetValue(prop, val == null ? "" : val.ToString()); } source.Address.CopyFieldsTo(target.Address); source._blnAllowFarmReload = false; source.idfRootFarm = target.idfFarm; }
private static FarmPanel CopyRootValues(DbManagerProxy manager, FarmRootPanel parent, bool copyAvianTree = true, bool copyLivestockTree = true, long?idfCase = null) { int?hacode = parent._HACode.HasValue ? parent._HACode.Value : (copyLivestockTree ? (int)eidss.model.Enums.HACode.Livestock : (int)eidss.model.Enums.HACode.Avian); var farm = FarmPanel.Accessor.Instance(null).CreateByHACode(manager, parent, hacode); farm._blnAllowFarmReload = false; farm.idfRootFarm = parent.idfFarm; // fill all value-fields except idfFarm foreach (var prop in farm.GetType().GetProperties().Select(x => x.Name)) { if (COPY_EXTENSIONS.Contains(prop)) { continue; } object val = parent.GetValue(prop); farm.SetValue(prop, val == null ? "" : val.ToString()); } parent.Address.CopyFieldsTo(farm.Address); farm.idfCase = idfCase; //copy vetfarmtree var vetTreeBase = farm.FarmTree[0]; farm.FarmTree.Clear(); if (parent.FarmAvianTree.Count > 1 && copyAvianTree) { farm.FarmTree.AddRange(RootTreeToFarm(manager, parent, parent.FarmAvianTree, idfCase)); } if (parent.FarmLivestockTree.Count > 1 && copyLivestockTree) { farm.FarmTree.AddRange(RootTreeToFarm(manager, parent, parent.FarmLivestockTree, idfCase)); } if (farm.FarmTree.Count == 0) { farm.FarmTree.Add(vetTreeBase); } return(farm); }