Example #1
0
 public static string FormatMaterialName(RDEMaterial material)
 {
     return Format(Config.GetProfile<string>(PluginManager.Instance.User, "Material.MaterialNameFormat", DEFAULT_MATERIAL_NAME_FORMAT), material);
 }
Example #2
0
 public void UpdateMaterialRDE(RDEMaterial material)
 {
     StoredProcUpdate("spMaterialUpdateRDE",
         _P("intMaterialID", material.MaterialID),
         _P("vchrMaterialName", material.MaterialName),
         _P("intBiotaID", material.BiotaID),
         _P("vchrIDBy", material.ClassifiedBy),
         _P("vchrIDDate", material.IDDate),
         _P("vchrMaterialSource", material.MaterialSource),
         _P("vchrInstitution", material.Institution),
         _P("vchrAccessionNo", material.AccessionNo),
         _P("vchrRegNo", material.RegNo),
         _P("vchrCollectorNo", material.CollectorNo),
         _P("vchrMacroHabitat", material.MacroHabitat),
         _P("vchrMicroHabitat", material.MicroHabitat),
         _P("intTrapID", material.TrapID),
         _P("vchrCollectionMethod", material.CollectionMethod),
         _P("intSiteVisitID", material.SiteVisitID)
     );
 }
Example #3
0
        private RDEMaterial CreateNewMaterial(out List<Trait> traits, out List<Associate> associates, out List<MaterialPart> subparts)
        {
            RDEMaterialViewModel copyFrom = null;

            traits = null;
            associates = null;
            subparts = null;

            IEnumerable<Associate> copyFromAssociates = null;
            IEnumerable<MaterialPart> copyFromSubparts = null;

            switch (_autoFillMode) {
                case AutoFillMode.CopyCurrentData:
                    copyFrom = grpMaterial.SelectedItem as RDEMaterialViewModel;
                    if (copyFrom != null) {
                        var control = grpMaterial.Content as MaterialRDEControl;
                        if (control != null) {
                            copyFrom.Traits = control.GetTraits();
                            copyFromAssociates = control.GetAssociates();
                            copyFromSubparts = control.GetSubParts();
                        }
                    }
                    break;
                case AutoFillMode.TemplateData:
                    copyFrom = _materialTemplate;
                    if (_materialTemplate != null) {
                        copyFromAssociates = _materialTemplate.Associates.Select(vm => {
                                                                                     var associateViewModel = vm as AssociateViewModel;
                                                                                     return associateViewModel != null ? associateViewModel.Model : null;
                                                                                 });
                        copyFromSubparts = _materialTemplate.SubParts.Select(vm => {
                                                                                 var materialPartViewModel = vm as MaterialPartViewModel;
                                                                                 return materialPartViewModel != null ? materialPartViewModel.Model : null;
                                                                             });
                    }
                    break;
            }

            RDEMaterial ret;
            if (copyFrom != null) {
                ret = ReflectionUtils.Clone(copyFrom.Model);
                ret.MaterialID = -1;
                ret.MaterialName = null;

                traits = new List<Trait>();
                associates = new List<Associate>();
                subparts = new List<MaterialPart>();

                foreach (Trait t in copyFrom.Traits) {
                    var newTrait = ReflectionUtils.Clone(t);
                    newTrait.IntraCatID = -1;
                    newTrait.TraitID = -1;
                    traits.Add(newTrait);
                }

                if (copyFromAssociates != null) {
                    foreach (Associate a in copyFromAssociates) {
                        var newAssoc = ReflectionUtils.Clone(a);
                        newAssoc.AssociateID = -1;
                        newAssoc.AssociateID = -1;
                        associates.Add(newAssoc);
                    }
                }

                if (copyFromSubparts != null) {
                    foreach (MaterialPart p in copyFromSubparts) {
                        var newSubpart = ReflectionUtils.Clone(p);
                        newSubpart.MaterialPartID = -1;
                        newSubpart.MaterialID = -1;
                        subparts.Add(newSubpart);
                    }
                }
            } else {
                ret = new RDEMaterial();
            }

            ret.Locked = false;

            return ret;
        }